UNPKG

@mojir/lits

Version:

Lits is a Lisp dialect implemented in TypeScript

56 lines (55 loc) 2.05 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 { Cache } from './Cache'; export interface LitsRuntimeInfo { astCache: Cache | null; astCacheSize: number | null; debug: boolean; } export interface JsFunction { fn: (...args: any[]) => unknown; arity?: Arity; docString?: string; } export interface ContextParams { globalContext?: Context; contexts?: Context[]; values?: Record<string, unknown>; jsFunctions?: Record<string, JsFunction>; globalModuleScope?: boolean; } export interface MinifyParams { minify?: boolean; } export interface FilePathParams { filePath?: string; } interface LitsConfig { initialCache?: Record<string, Ast>; astCacheSize?: number | null; debug?: boolean; } export declare class Lits { private astCache; private astCacheSize; private debug; constructor(config?: LitsConfig); getRuntimeInfo(): LitsRuntimeInfo; run(program: string, params?: ContextParams & FilePathParams): unknown; context(programOrAst: string | Ast, params?: ContextParams & FilePathParams): Context; getUndefinedSymbols(programOrAst: string | Ast, params?: ContextParams): Set<string>; tokenize(program: string, tokenizeParams?: FilePathParams & MinifyParams): TokenStream; parse(tokenStream: TokenStream): Ast; evaluate(ast: Ast, params: ContextParams): Any; transformSymbols(tokenStream: TokenStream, transformer: (symbol: string) => string): TokenStream; untokenize(tokenStream: TokenStream): string; apply(fn: LitsFunction, fnParams: unknown[], params?: ContextParams): Any; private generateApplyFunctionCall; private generateAst; getAutoCompleter(program: string, position: number, params?: ContextParams): AutoCompleter; } export {};