@gobstones/gobstones-parser
Version:
Gobstones parser
256 lines • 9.95 kB
TypeScript
import { SourceReader } from './reader';
import { Token } from './token';
export declare const N_Main: unique symbol;
export declare const N_DefProgram: unique symbol;
export declare const N_DefInteractiveProgram: unique symbol;
export declare const N_DefProcedure: unique symbol;
export declare const N_DefFunction: unique symbol;
export declare const N_DefType: unique symbol;
export declare const N_StmtBlock: unique symbol;
export declare const N_StmtReturn: unique symbol;
export declare const N_StmtIf: unique symbol;
export declare const N_StmtRepeat: unique symbol;
export declare const N_StmtForeach: unique symbol;
export declare const N_StmtWhile: unique symbol;
export declare const N_StmtSwitch: unique symbol;
export declare const N_StmtAssignVariable: unique symbol;
export declare const N_StmtAssignTuple: unique symbol;
export declare const N_StmtProcedureCall: unique symbol;
export declare const N_PatternWildcard: unique symbol;
export declare const N_PatternVariable: unique symbol;
export declare const N_PatternNumber: unique symbol;
export declare const N_PatternStructure: unique symbol;
export declare const N_PatternTuple: unique symbol;
export declare const N_PatternTimeout: unique symbol;
export declare const N_ExprVariable: unique symbol;
export declare const N_ExprConstantNumber: unique symbol;
export declare const N_ExprConstantString: unique symbol;
export declare const N_ExprChoose: unique symbol;
export declare const N_ExprMatching: unique symbol;
export declare const N_ExprList: unique symbol;
export declare const N_ExprRange: unique symbol;
export declare const N_ExprTuple: unique symbol;
export declare const N_ExprStructure: unique symbol;
export declare const N_ExprStructureUpdate: unique symbol;
export declare const N_ExprFunctionCall: unique symbol;
export declare const N_SwitchBranch: unique symbol;
export declare const N_MatchingBranch: unique symbol;
export declare const N_FieldBinding: unique symbol;
export declare const N_ConstructorDeclaration: unique symbol;
export declare type ASTDef = ASTDefType | ASTDefProgram | ASTDefInteractiveProgram | ASTDefFunction;
/** An instance of ASTNode represents a node of the abstract syntax tree.
* - tag should be a node tag symbol.
* - children should be (recursively) a possibly empty array of ASTNode's.
* - startPos and endPos represent the starting and ending
* position of the code fragment in the source code, to aid error
* reporting.
**/
export declare class ASTNode {
private _tag;
private _children;
private _startPos;
private _endPos;
private _attributes;
constructor(tag: symbol, children: any[]);
toMulangLike(): any;
toString(): string;
get tag(): symbol;
get children(): any[];
set startPos(position: SourceReader);
get startPos(): SourceReader;
set endPos(position: SourceReader);
get endPos(): SourceReader;
get attributes(): Record<string, ASTDef>;
set attributes(attributes: Record<string, ASTDef>);
}
export declare class ASTMain extends ASTNode {
constructor(definitions: ASTDef[]);
get definitions(): ASTDef[];
}
export declare class ASTDefProgram extends ASTNode {
constructor(body: ASTStmtBlock);
get body(): ASTStmtBlock;
}
export declare abstract class ASTNodeWithBranches extends ASTNode {
get branches(): ASTNodeWithPattern[];
}
export declare class ASTDefInteractiveProgram extends ASTNodeWithBranches {
constructor(branches: ASTNode[]);
get branches(): ASTNodeWithPattern[];
}
export declare class ASTDefProcedure extends ASTNode {
constructor(name: Token, parameters: Token[], body: ASTNode);
get name(): Token;
get parameters(): Token[];
get body(): ASTNode;
}
export declare class ASTDefFunction extends ASTNode {
constructor(name: Token, parameters: Token[], body: ASTNode);
get name(): Token;
get parameters(): Token[];
get body(): ASTNode;
}
export declare class ASTDefType extends ASTNode {
constructor(typeName: Token, constructorDeclarations: ASTConstructorDeclaration[]);
get typeName(): Token;
get constructorDeclarations(): ASTConstructorDeclaration[];
}
export declare class ASTStmtBlock extends ASTNode {
constructor(statements: ASTNode[]);
get statements(): ASTNode[];
}
export declare class ASTStmtReturn extends ASTNode {
constructor(result: ASTExpr);
get result(): ASTExpr;
}
export declare class ASTStmtIf extends ASTNode {
constructor(condition: ASTExpr, thenBlock: ASTNode, elseBlock: ASTNode);
get condition(): ASTExpr;
get thenBlock(): ASTNode;
get elseBlock(): ASTNode;
}
export declare class ASTStmtRepeat extends ASTNode {
constructor(times: ASTExpr, body: ASTNode);
get times(): ASTExpr;
get body(): ASTNode;
}
export declare abstract class ASTNodeWithPattern extends ASTNode {
get pattern(): ASTPattern;
}
export declare class ASTStmtForeach extends ASTNodeWithPattern {
constructor(pattern: ASTNode, range: ASTExpr, body: ASTNode);
get pattern(): ASTPattern;
get range(): ASTExpr;
get body(): ASTNode;
}
export declare class ASTStmtWhile extends ASTNode {
constructor(condition: ASTExpr, body: ASTNode);
get condition(): ASTExpr;
get body(): ASTNode;
}
export declare class ASTStmtSwitch extends ASTNodeWithBranches {
constructor(subject: ASTExpr, branches: ASTNodeWithPattern[]);
get subject(): ASTExpr;
get branches(): ASTNodeWithPattern[];
}
export declare class ASTSwitchBranch extends ASTNodeWithPattern {
constructor(pattern: ASTPattern, body: ASTNode);
get pattern(): ASTPattern;
get body(): ASTNode;
}
export declare class ASTMatchingBranch extends ASTNodeWithPattern {
constructor(pattern: ASTPattern, body: ASTExpr);
get pattern(): ASTPattern;
get body(): ASTExpr;
}
export declare class ASTStmtAssignVariable extends ASTNode {
constructor(variable: Token, value: ASTExpr);
get variable(): Token;
get value(): ASTExpr;
}
export declare class ASTStmtAssignTuple extends ASTNode {
constructor(variables: Token[], value: ASTExpr);
get variables(): Token[];
get value(): ASTExpr;
}
export declare class ASTStmtProcedureCall extends ASTNode {
constructor(procedureName: Token, args: ASTExpr[]);
get procedureName(): Token;
get args(): ASTExpr[];
}
export declare type ASTPattern = ASTPatternWildcard | ASTPatternVariable | ASTPatternNumber | ASTPatternStructure | ASTPatternTuple | ASTPatternTimeout;
export declare class ASTPatternWildcard extends ASTNode {
constructor(statement?: ASTStmtBlock);
get boundVariables(): ASTNode[];
}
export declare class ASTPatternVariable extends ASTNode {
constructor(variableName: Token);
get variableName(): Token;
get boundVariables(): Token[];
}
export declare class ASTPatternNumber extends ASTNode {
constructor(number: Token);
get number(): Token;
get boundVariables(): ASTNode[];
}
export declare class ASTPatternStructure extends ASTNode {
constructor(constructorName: Token, parameters: Token[]);
get constructorName(): Token;
get boundVariables(): Token[];
}
export declare class ASTPatternTuple extends ASTNode {
constructor(parameters: Token[]);
get boundVariables(): Token[];
}
export declare class ASTPatternTimeout extends ASTNode {
constructor(timeout: Token);
get boundVariables(): ASTNode[];
get timeout(): number;
}
export declare type ASTExpr = ASTExprVariable | ASTExprConstantNumber | ASTExprConstantString | ASTExprChoose | ASTExprMatching | ASTExprList | ASTExprRange | ASTExprTuple | ASTExprStructure | ASTExprStructureUpdate | ASTExprFunctionCall;
export declare class ASTExprVariable extends ASTNode {
constructor(variableName: Token);
get variableName(): Token;
}
export declare class ASTExprConstantNumber extends ASTNode {
constructor(number: Token);
get number(): Token;
}
export declare class ASTExprConstantString extends ASTNode {
constructor(string: Token);
get string(): Token;
}
export declare class ASTExprChoose extends ASTNode {
constructor(condition: ASTExpr, trueExpr: ASTExpr, falseExpr: ASTExpr);
get condition(): ASTExpr;
get trueExpr(): ASTExpr;
get falseExpr(): ASTExpr;
}
export declare class ASTExprMatching extends ASTNodeWithBranches {
constructor(subject: ASTExpr, branches: ASTNode[]);
get subject(): ASTExpr;
get branches(): ASTNodeWithPattern[];
}
export declare class ASTExprList extends ASTNode {
constructor(elements: ASTExpr[]);
get elements(): ASTExpr[];
}
export declare class ASTExprRange extends ASTNode {
constructor(first: ASTExpr, second: ASTExpr, last: ASTExpr);
get first(): ASTExpr;
get second(): ASTExpr;
get last(): ASTExpr;
}
export declare class ASTExprTuple extends ASTNode {
constructor(elements: ASTExpr[]);
get elements(): ASTExpr[];
}
export declare class ASTExprStructure extends ASTNode {
constructor(constructorName: Token, fieldBindings: ASTFieldBinding[]);
get constructorName(): Token;
get fieldBindings(): ASTFieldBinding[];
fieldNames(): ASTNode[];
}
export declare class ASTExprStructureUpdate extends ASTNode {
constructor(constructorName: Token, original: ASTExpr, fieldBindings: ASTFieldBinding[]);
get constructorName(): Token;
get original(): ASTExpr;
get fieldBindings(): ASTFieldBinding[];
fieldNames(): Token[];
}
export declare class ASTExprFunctionCall extends ASTNode {
constructor(functionName: Token, args: ASTExpr[]);
get functionName(): Token;
get args(): ASTExpr[];
}
export declare class ASTFieldBinding extends ASTNode {
constructor(fieldName: Token, value: ASTExpr);
get fieldName(): Token;
get value(): ASTExpr;
}
export declare class ASTConstructorDeclaration extends ASTNode {
constructor(constructorName: Token, fieldNames: Token[]);
get constructorName(): Token;
get fieldNames(): Token[];
}
//# sourceMappingURL=ast.d.ts.map