@bscotch/gml-parser
Version:
A parser for GML (GameMaker Language) files for programmatic manipulation and analysis of GameMaker projects.
121 lines • 7.94 kB
TypeScript
import { CstParser, type CstNode, type ILexingResult } from 'chevrotain';
import type { GmlVisitor } from '../gml-cst.js';
import type { JsdocSummary } from './jsdoc.js';
import type { GmlParseError } from './project.diagnostics.js';
import type { Reference, ReferenceableType } from './project.location.js';
import type { Signifier } from './signifiers.js';
import type { Type, TypeStore } from './types.js';
export interface GmlParsed {
lexed: ILexingResult;
cst: CstNode;
errors: GmlParseError[];
}
export declare class GmlParser extends CstParser {
/** Parse GML Code, e.g. from a file. */
parse(code: string): GmlParsed;
readonly lexer: import("chevrotain").Lexer;
readonly file: import("chevrotain").ParserMethod<[], CstNode>;
optionallyConsumeSemicolon(): void;
readonly statements: import("chevrotain").ParserMethod<[], CstNode>;
readonly statement: import("chevrotain").ParserMethod<[], CstNode>;
readonly jsdoc: import("chevrotain").ParserMethod<[], CstNode>;
readonly jsdocGml: import("chevrotain").ParserMethod<[], CstNode>;
readonly jsdocJs: import("chevrotain").ParserMethod<[], CstNode>;
readonly stringLiteral: import("chevrotain").ParserMethod<[], CstNode>;
readonly multilineDoubleStringLiteral: import("chevrotain").ParserMethod<[], CstNode>;
readonly multilineSingleStringLiteral: import("chevrotain").ParserMethod<[], CstNode>;
readonly templateLiteral: import("chevrotain").ParserMethod<[], CstNode>;
readonly repeatStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly returnStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly ifStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly elseIfStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly elseStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly blockableStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly blockableStatements: import("chevrotain").ParserMethod<[], CstNode>;
readonly blockStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly expressionStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly expression: import("chevrotain").ParserMethod<[], CstNode>;
readonly binaryExpression: import("chevrotain").ParserMethod<[], CstNode>;
readonly ternaryExpression: import("chevrotain").ParserMethod<[], CstNode>;
readonly primaryExpression: import("chevrotain").ParserMethod<[], CstNode>;
readonly identifier: import("chevrotain").ParserMethod<[], CstNode>;
readonly identifierAccessor: import("chevrotain").ParserMethod<[], CstNode>;
readonly parenthesizedExpression: import("chevrotain").ParserMethod<[], CstNode>;
readonly accessorSuffixes: import("chevrotain").ParserMethod<[], CstNode>;
readonly dotAccessSuffix: import("chevrotain").ParserMethod<[], CstNode>;
readonly arrayAccessSuffix: import("chevrotain").ParserMethod<[], CstNode>;
readonly structAccessorSuffix: import("chevrotain").ParserMethod<[], CstNode>;
readonly listAccessorSuffix: import("chevrotain").ParserMethod<[], CstNode>;
readonly mapAccessorSuffix: import("chevrotain").ParserMethod<[], CstNode>;
readonly gridAccessorSuffix: import("chevrotain").ParserMethod<[], CstNode>;
readonly arrayMutationAccessorSuffix: import("chevrotain").ParserMethod<[], CstNode>;
readonly functionArguments: import("chevrotain").ParserMethod<[], CstNode>;
readonly functionArgument: import("chevrotain").ParserMethod<[], CstNode>;
readonly emptyStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly enumStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly enumMember: import("chevrotain").ParserMethod<[], CstNode>;
readonly constructorSuffix: import("chevrotain").ParserMethod<[], CstNode>;
readonly functionExpression: import("chevrotain").ParserMethod<[], CstNode>;
readonly functionStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly functionParameters: import("chevrotain").ParserMethod<[], CstNode>;
readonly functionParameter: import("chevrotain").ParserMethod<[], CstNode>;
readonly macroStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly forStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly globalVarDeclarationsStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly globalVarDeclarations: import("chevrotain").ParserMethod<[], CstNode>;
readonly globalVarDeclaration: import("chevrotain").ParserMethod<[], CstNode>;
readonly localVarDeclarationsStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly localVarDeclarations: import("chevrotain").ParserMethod<[], CstNode>;
readonly localVarDeclaration: import("chevrotain").ParserMethod<[], CstNode>;
readonly staticVarDeclarationStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly staticVarDeclaration: import("chevrotain").ParserMethod<[], CstNode>;
readonly variableAssignmentStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly variableAssignment: import("chevrotain").ParserMethod<[], CstNode>;
readonly assignment: import("chevrotain").ParserMethod<[], CstNode>;
readonly assignmentRightHandSide: import("chevrotain").ParserMethod<[], CstNode>;
readonly arrayLiteral: import("chevrotain").ParserMethod<[], CstNode>;
readonly structLiteral: import("chevrotain").ParserMethod<[], CstNode>;
readonly structLiteralEntry: import("chevrotain").ParserMethod<[], CstNode>;
readonly whileStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly doUntilStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly switchStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly caseStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly defaultStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly breakStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly continueStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly exitStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly withStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly tryStatement: import("chevrotain").ParserMethod<[], CstNode>;
readonly catchStatement: import("chevrotain").ParserMethod<[], CstNode>;
constructor();
static jsonify(cst: CstNode): string;
}
export type NodeContextKind = 'withCondition' | 'withBody' | 'functionParam' | 'functionArg' | 'functionBody' | 'functionReturn' | 'functionStatement' | 'template' | 'arrayMember' | 'assignment';
export interface Docs {
type: Type[];
jsdoc: JsdocSummary;
}
export interface VisitorContext {
/** We're processing a static variable declaration */
isStatic?: boolean;
/** While processing a function expression or struct literal, the signifier may come from an assignment operation. */
signifier?: Signifier;
/** While processing a function expression, we may have expected type information for the value */
type?: TypeStore;
/** While processing `method()` calls, we may find the self-context
* of the function in the second argument.
*/
self?: Type;
docs?: Docs;
/** Helpful to get general info about the context of the current node. */
ctxKindStack: NodeContextKind[];
/** If we're in a function, the return statement values we've found */
returns?: (Type | TypeStore)[];
}
export declare function withCtxKind<T extends NodeContextKind>(ctx: VisitorContext, kind: T): VisitorContext;
export declare const parser: GmlParser;
export declare const GmlVisitorBase: new (...args: any[]) => GmlVisitor<VisitorContext, undefined | void | Type | (Type | TypeStore)[] | TypeStore | {
item: ReferenceableType;
ref: Reference;
}>;
//# sourceMappingURL=parser.d.ts.map