UNPKG

@prism-lang/core

Version:

A programming language for uncertainty

208 lines 6.79 kB
import { ASTNode, Program } from './ast'; import { ConfidenceValue as ConfidenceLib } from './confidence'; import { LLMProvider } from './llm-types'; export declare class RuntimeError extends Error { node?: ASTNode | undefined; line?: number; column?: number; constructor(message: string, node?: ASTNode | undefined, location?: { line: number; column: number; }); } export declare class LoopControlError extends Error { type: 'break' | 'continue'; constructor(type: 'break' | 'continue'); } export declare class ReturnException extends Error { value?: Value | undefined; constructor(value?: Value | undefined); } export declare abstract class Value { abstract type: string; abstract value: unknown; abstract equals(other: Value): boolean; abstract isTruthy(): boolean; abstract toString(): string; } export declare class NumberValue extends Value { value: number; type: string; constructor(value: number); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class StringValue extends Value { value: string; type: string; constructor(value: string); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class BooleanValue extends Value { value: boolean; type: string; constructor(value: boolean); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class NullValue extends Value { type: string; value: null; constructor(); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class UndefinedValue extends Value { type: string; value: undefined; constructor(); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class ConfidenceValue extends Value { value: Value; confidence: ConfidenceLib; type: string; constructor(value: Value, confidence: ConfidenceLib); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class ArrayValue extends Value { elements: Value[]; type: string; value: Value[]; constructor(elements: Value[]); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class ObjectValue extends Value { properties: Map<string, Value>; type: string; value: Map<string, Value>; constructor(properties: Map<string, Value>); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class FunctionValue extends Value { name: string; value: (args: Value[]) => Promise<Value>; arity?: number | undefined; type: string; constructor(name: string, value: (args: Value[]) => Promise<Value>, arity?: number | undefined); equals(other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class PromiseValue extends Value { value: Promise<Value>; type: string; constructor(value: Promise<Value>); equals(_other: Value): boolean; isTruthy(): boolean; toString(): string; } export declare class Environment { private parent?; private variables; constructor(parent?: Environment | undefined); define(name: string, value: Value, mutable?: boolean, declared?: boolean): void; get(name: string): Value; set(name: string, value: Value): void; getAllVariables(): Map<string, Value>; } export declare class Interpreter { environment: Environment; private contextManager; private llmProviders; private defaultLLMProvider?; constructor(); private setupBuiltins; registerLLMProvider(name: string, provider: LLMProvider): void; setDefaultLLMProvider(name: string): void; getDefaultLLMProviderName(): string | undefined; private getDefaultLLMProvider; interpret(node: ASTNode): Promise<Value>; private interpretProgram; private interpretNumberLiteral; private interpretStringLiteral; private interpretInterpolatedString; private interpretBooleanLiteral; private interpretNullLiteral; private interpretUndefinedLiteral; private interpretIdentifier; private interpretBinaryExpression; private applyBinaryOperator; private applyBinaryOperatorWithConfidence; private applyConfidenceChaining; private applyConfidenceCoalesce; private applyConfidentLogical; private applyConfidentArithmetic; private applyConfidentComparison; private applyConfidentPropertyAccess; private applyParallelConfidence; private applyThresholdGate; private applyConfidenceThresholdGate; private interpretUnaryExpression; private interpretCallExpression; private interpretTernaryExpression; private interpretConfidentTernaryExpression; private interpretArrayLiteral; private interpretObjectLiteral; private interpretPropertyAccess; private interpretOptionalChainAccess; private interpretIndexAccess; private interpretLambdaExpression; private interpretConfidenceExpression; private interpretAssignmentStatement; private interpretAssignmentExpression; private interpretAwaitExpression; private interpretDestructuringAssignment; private destructureArray; private meetsConfidenceThreshold; private destructureObject; private interpretIfStatement; private interpretUncertainIfStatement; private interpretContextStatement; private interpretAgentDeclaration; private interpretBlockStatement; private interpretExpressionStatement; private interpretFunctionDeclaration; private interpretReturnStatement; private interpretVariableDeclaration; private interpretImportStatement; private interpretExportStatement; private bindParameters; private interpretForLoop; private interpretForInLoop; private interpretWhileLoop; private interpretDoWhileLoop; private interpretUncertainForLoop; private interpretUncertainWhileLoop; private looseEquals; private toNumber; } export declare class Runtime { private interpreter; constructor(); execute(program: Program): Promise<Value>; registerLLMProvider(name: string, provider: LLMProvider): void; setDefaultLLMProvider(name: string): void; getDefaultLLMProvider(): string | undefined; getVariable(name: string): Value; getAllVariables(): Map<string, Value>; defineVariable(name: string, value: Value): void; createObjectValue(properties: any): Value; interpret(node: ASTNode): Promise<Value>; get environment(): Environment; } export declare function createRuntime(): Runtime; //# sourceMappingURL=runtime.d.ts.map