@gobstones/gobstones-parser
Version:
Gobstones parser
84 lines • 4.11 kB
TypeScript
import { ASTExpr, ASTExprChoose, ASTExprConstantNumber, ASTExprConstantString, ASTExprFunctionCall, ASTExprList, ASTExprMatching, ASTExprRange, ASTExprStructure, ASTExprStructureUpdate, ASTExprTuple, ASTExprVariable, ASTMain, ASTNode, ASTNodeWithPattern, ASTPattern, ASTPatternNumber, ASTPatternStructure, ASTPatternTimeout, ASTPatternTuple, ASTPatternVariable, ASTPatternWildcard, ASTStmtBlock, ASTStmtSwitch, ASTSwitchBranch } from './ast';
import { Input, SourceReader } from './reader';
import { Token } from './token';
export declare class Parser {
private _lexer;
private _currentToken;
constructor(input: Input);
parse(): ASTMain;
getLanguageOptions(): string[];
/** Definitions **/
_parseDefinition(): ASTNode;
_parseDefProgram(): ASTNode;
_parseDefInteractiveProgram(): ASTNode;
_parseDefProcedure(): ASTNode;
_parseDefFunction(): ASTNode;
_parseDefType(): ASTNode;
_parseDefTypeRecord(startPos: SourceReader, typeName: Token): ASTNode;
_parseDefTypeVariant(startPos: SourceReader, typeName: Token): ASTNode;
_parseConstructorDeclaration(): ASTNode;
_parseFieldNames(): Token[];
/** Statements **/
_parseStatement(): ASTNode;
_parsePureStatement(): ASTNode;
_parseStmtBlock(): ASTStmtBlock;
_parseStmtEllipsis(): ASTNode;
_parseStmtReturn(): ASTNode;
_parseStmtIf(expectInitialIf: boolean): ASTNode;
_parseStmtRepeat(): ASTNode;
_parseStmtForeach(): ASTNode;
_parseStmtWhile(): ASTNode;
_parseStmtSwitch(): ASTStmtSwitch;
_parseStmtLet(): ASTNode;
_parseStmtAssignVariable(): ASTNode;
_parseStmtAssignTuple(): ASTNode;
_parseStmtProcedureCall(): ASTNode;
/** Patterns **/
_parsePattern(): ASTPattern;
_parsePatternWildcard(): ASTPatternWildcard;
_parsePatternVariable(): ASTPatternVariable;
_parsePatternNumber(): ASTPatternNumber;
_parsePatternStructure(): ASTPatternStructure;
_parsePatternTuple(): ASTPatternTuple;
_parsePatternTimeout(): ASTPatternTimeout;
/** Expressions **/
_parseExpression(): ASTExpr;
_parseExprOperator(level: number): ASTExpr;
_parseExprOperatorInfix(level: number): ASTExpr;
_parseExprOperatorInfixL(level: number): ASTExpr;
_parseExprOperatorInfixR(level: number): ASTExpr;
_parseExprOperatorPrefix(level: number): ASTExpr;
_parseExprAtom(): ASTExpr;
_parseExprEllipsis(): ASTExprFunctionCall;
_parseExprVariableOrFunctionCall(): ASTExprVariable | ASTExprFunctionCall;
_parseExprConstantNumber(): ASTExprConstantNumber;
_parseExprConstantString(): ASTExprConstantString;
_parseExprChoose(expectInitialChoose: boolean): ASTExprChoose;
_parseExprMatching(): ASTExprMatching;
_parseExprStructureOrStructureUpdate(): ASTExprStructure | ASTExprStructureUpdate;
_parseStructure(constructorName: Token, fieldName1: Token): ASTExprStructure;
_parseStructureUpdate(constructorName: Token, original: ASTExpr): ASTExprStructureUpdate;
_parseExprListOrRange(): ASTExprList | ASTExprRange;
_parseExprListRemainder(startPos: SourceReader, prefix: ASTExpr[]): ASTExprList;
_parseExprRange(startPos: SourceReader, first: ASTExpr, second?: ASTExpr): ASTExprRange;
_parseExprTuple(possiblyEmpty: boolean): ASTExprTuple;
/** SwitchBranch **/
_parseSwitchBranches(): ASTNodeWithPattern[];
_parseSwitchBranch(): ASTSwitchBranch;
/** MatchingBranch **/
_parseMatchingBranches(): ASTNode[];
_parseMatchingBranch(): ASTNode;
/** FieldBinding **/
_parseFieldBinding(): ASTNode;
/** Helpers **/
_nextToken(): void;
_match(tokenTag: symbol): void;
_matchExpected(tokenTag: symbol, tagList: symbol[]): void;
_parseDelimitedSeq<T>(rightDelimiter: symbol, separator: symbol, parseElement: () => T): T[];
_parseNonEmptyDelimitedSeq<T>(rightDelimiter: symbol, separator: symbol, prefix: T[], parseElement: () => T): T[];
_parseLowerid(): Token;
_parseUpperid(): Token;
_parseLoweridSeq(): Token[];
_parseExpressionSeq(rightDelimiter: symbol): ASTExpr[];
}
//# sourceMappingURL=parser.d.ts.map