UNPKG

@mojir/lits

Version:

Lits is a pure functional programming language implemented in TypeScript

68 lines (67 loc) 2.54 kB
import type { Context } from '../evaluator/interface'; import type { Any } from '../interface'; import type { Ast, LitsFunction } from '../parser/types'; import type { TokenStream } from '../tokenizer/tokenize'; import { AutoCompleter } from '../AutoCompleter/AutoCompleter'; import type { Arity } from '../builtin/interface'; import type { LitsModule } from '../builtin/modules/interface'; import type { LitsBundle } from '../bundler/interface'; import type { MaybePromise } from '../utils/maybePromise'; import { Cache } from './Cache'; export interface LitsRuntimeInfo { astCache: Cache | null; astCacheSize: number | null; debug: boolean; } export interface JsFunction { fn: (...args: any[]) => unknown; arity?: Arity; pure?: boolean; docString?: string; } export interface ContextParams { globalContext?: Context; contexts?: Context[]; bindings?: Record<string, unknown>; globalModuleScope?: boolean; } export interface MinifyParams { minify?: boolean; } export interface FilePathParams { filePath?: string; } export interface PureParams { pure?: boolean; } interface LitsConfig { initialCache?: Record<string, Ast>; astCacheSize?: number | null; debug?: boolean; modules?: LitsModule[]; } export declare class Lits { private astCache; private astCacheSize; private debug; private modules; constructor(config?: LitsConfig); getRuntimeInfo(): LitsRuntimeInfo; readonly async: { run: (programOrBundle: string | LitsBundle, params?: ContextParams & FilePathParams & PureParams) => Promise<unknown>; apply: (fn: LitsFunction, fnParams: unknown[], params?: ContextParams & PureParams) => Promise<unknown>; }; run(programOrBundle: string | LitsBundle, params?: ContextParams & FilePathParams & PureParams): unknown; private runBundle; getUndefinedSymbols(programOrAst: string | Ast, params?: ContextParams): Set<string>; tokenize(program: string, tokenizeParams?: FilePathParams & MinifyParams): TokenStream; parse(tokenStream: TokenStream): Ast; private evaluate; transformSymbols(tokenStream: TokenStream, transformer: (symbol: string) => string): TokenStream; untokenize(tokenStream: TokenStream): string; apply(fn: LitsFunction, fnParams: unknown[], params?: ContextParams & PureParams): MaybePromise<Any>; private generateApplyFunctionCall; private generateAst; getAutoCompleter(program: string, position: number, params?: ContextParams): AutoCompleter; } export {};