import type { JsFunction } from '../Lits/Lits'; import type { SpecialExpressionType } from '../builtin'; import type { Arity } from '../builtin/interface'; import type { specialExpressionTypes } from '../builtin/specialExpressionTypes'; import type { FunctionType, NodeType, NodeTypes } from '../constants/constants'; import type { Context } from '../evaluator/interface'; import type { Any, Arr, Coll } from '../interface'; import type { ReservedSymbol } from '../tokenizer/reservedNames'; import type { SourceCodeInfo } from '../tokenizer/token'; import type { FUNCTION_SYMBOL, REGEXP_SYMBOL } from '../utils/symbols'; export type EvaluatedFunction = [BindingTarget[], AstNode[], Context]; interface GenericLitsFunction { [FUNCTION_SYMBOL]: true; sourceCodeInfo?: SourceCodeInfo; functionType: FunctionType; arity: Arity; } export interface RegularExpression { [REGEXP_SYMBOL]: true; sourceCodeInfo?: SourceCodeInfo; s: string; f: string; } export interface NativeJsFunction extends GenericLitsFunction { functionType: 'NativeJsFunction'; name: string | undefined; nativeFn: JsFunction; docString: string; } export interface UserDefinedFunction extends GenericLitsFunction { functionType: 'UserDefined'; name: string | undefined; evaluatedfunction: EvaluatedFunction; docString: string; } export interface PartialFunction extends GenericLitsFunction { functionType: 'Partial'; function: FunctionLike; params: Arr; placeholders: number[]; } export interface CompFunction extends GenericLitsFunction { functionType: 'Comp'; params: Arr; } export interface ConstantlyFunction extends GenericLitsFunction { functionType: 'Constantly'; value: Any; } export interface JuxtFunction extends GenericLitsFunction { functionType: 'Juxt'; params: Arr; } export interface ComplementFunction extends GenericLitsFunction { functionType: 'Complement'; function: FunctionLike; } export interface EveryPredFunction extends GenericLitsFunction { functionType: 'EveryPred'; params: Arr; } export interface SomePredFunction extends GenericLitsFunction { functionType: 'SomePred'; params: Arr; } export interface FNullFunction extends GenericLitsFunction { functionType: 'Fnull'; function: FunctionLike; params: Arr; } export interface NormalBuiltinFunction extends GenericLitsFunction { functionType: 'Builtin'; normalBuiltinSymbolType: number; name: string; } export interface SpecialBuiltinFunction extends GenericLitsFunction { functionType: 'SpecialBuiltin'; specialBuiltinSymbolType: typeof specialExpressionTypes['&&'] | typeof specialExpressionTypes['||'] | typeof specialExpressionTypes['array'] | typeof specialExpressionTypes['object'] | typeof specialExpressionTypes['defined?'] | typeof specialExpressionTypes['recur'] | typeof specialExpressionTypes['throw'] | typeof specialExpressionTypes['??']; } export interface ModuleFunction extends GenericLitsFunction { functionType: 'Module'; moduleName: string; functionName: string; } export type LitsFunction = NativeJsFunction | UserDefinedFunction | NormalBuiltinFunction | SpecialBuiltinFunction | ModuleFunction | PartialFunction | CompFunction | ConstantlyFunction | JuxtFunction | ComplementFunction | EveryPredFunction | SomePredFunction | FNullFunction; export type LitsFunctionType = LitsFunction['functionType']; export type FunctionLike = LitsFunction | Coll | number; export type AstNode = [T, Payload] | [T, Payload, SourceCodeInfo]; export type ExpressionNode = NormalExpressionNode | SpecialExpressionNode | NumberNode | StringNode; export type SpreadNode = AstNode; export type NumberNode = AstNode; export type StringNode = AstNode; export type UserDefinedSymbolNode = AstNode; export type NormalBuiltinSymbolNode = AstNode; export type SpecialBuiltinSymbolNode = AstNode; export type SymbolNode = UserDefinedSymbolNode | NormalBuiltinSymbolNode | SpecialBuiltinSymbolNode; export type ReservedSymbolNode = AstNode; export type SpecialExpressionNode = AstNode; export type NormalExpressionNodeWithName = AstNode; export type NormalExpressionNodeExpression = AstNode; export type NormalExpressionNode = NormalExpressionNodeWithName | NormalExpressionNodeExpression; export declare const bindingTargetTypes: { readonly symbol: 11; readonly rest: 12; readonly object: 13; readonly array: 14; readonly literal: 15; readonly wildcard: 16; }; export type BindingTargetType = typeof bindingTargetTypes[keyof typeof bindingTargetTypes]; type GenericTarget = [T, Payload] | [T, Payload, SourceCodeInfo]; export type SymbolBindingTarget = GenericTarget; export type RestBindingTarget = GenericTarget; export type ObjectBindingTarget = GenericTarget, AstNode | undefined]>; export type ArrayBindingTarget = GenericTarget; export type LiteralBindingTarget = GenericTarget; export type WildcardBindingTarget = GenericTarget; export type BindingTarget = SymbolBindingTarget | RestBindingTarget | ObjectBindingTarget | ArrayBindingTarget | LiteralBindingTarget | WildcardBindingTarget; export type BindingNode = AstNode; type AstBody = AstNode[]; export interface Ast { body: AstBody; hasDebugData: boolean; } export {};