import Lexer from './lexer'; import { Token, TokenType } from './lexer/token'; import { ASTAssignmentStatement, ASTBase, ASTBaseBlockWithScope, ASTChunk, ASTForGenericStatement, ASTIdentifier, ASTIdentifierKind, ASTLiteral, ASTProvider, ASTWhileStatement } from './parser/ast'; import Validator from './parser/validator'; import { ErrorCode, ParserException } from './types/errors'; import { Range } from './types/range'; import { Selector, SelectorGroup } from './types/selector'; import { Stack } from './utils/stack'; import { PendingBlock } from './parser/pending-block'; import { LineRegistry } from './parser/line-registry'; import { Comment } from './types/comment'; import { NoopConsumer } from './parser/noop-consumer'; import { PrefixOp, InfixOp, AtomOp, KeywordOp } from './types/ops'; import { ParserShape } from './types/parser'; import { ParserState } from './parser/state'; export interface ParserOptions { validator?: Validator; astProvider?: ASTProvider; lexer?: Lexer; unsafe?: boolean; tabWidth?: number; preserve?: boolean; prefixOps?: PrefixOp[]; infixOps?: InfixOp[]; atomOps?: AtomOp[]; keywordOps?: KeywordOp[]; state?: ParserState; strictMode?: boolean; } export default class Parser implements ParserShape { token: Token | null; previousToken: Token | null; currentScope: ASTBaseBlockWithScope; outerScopes: ASTBaseBlockWithScope[]; currentAssignment: ASTAssignmentStatement; iteratorStack: (ASTForGenericStatement | ASTWhileStatement)[]; state: ParserState; backpatches: Stack; pendingLeadingComments: string[]; lastStatement: ASTBase | null; content: string; lexer: Lexer; validator: Validator; astProvider: ASTProvider; preserve: boolean; noopConsumer: NoopConsumer | null; errors: Error[]; strictMode: boolean; prefixOps: PrefixOp[]; infixOps: InfixOp[]; atomOps: AtomOp[]; keywordOps: KeywordOp[]; constructor(content: string, options?: ParserOptions); getState(): ParserState; get lineRegistry(): LineRegistry; next(): void; isType(type: TokenType): boolean; consume(selector: Selector): boolean; consumeMany(selectorGroup: SelectorGroup): boolean; requireType(type: TokenType, fromLine?: number, fromChar?: number, context?: string): Token | null; requireToken(selector: Selector, fromLine?: number, fromChar?: number, context?: string): Token | null; requireTokenOfAny(selectorGroup: SelectorGroup, fromLine?: number, fromChar?: number, context?: string): Token | null; protected createComment(token: Token): Comment; consumeNoop(): number; consumeNoopStatement(): number; attachPendingComments(item: ASTBase): void; flushPendingComments(): void; consumeEndTrailingComment(): void; consumeInlineComment(target: ASTBase): void; pushScope(scope: ASTBaseBlockWithScope): void; popScope(): void; finishRemainingScopes(): void; parseChunk(): ASTChunk | ASTBase; parseStatement(): void; parseAssignment(): ASTBase; parseExpr(base: ASTBase, asLval?: boolean, statementStart?: boolean): ASTBase; parseFunctionDeclaration(base: ASTBase, asLval: boolean, statementStart: boolean): ASTBase; parseExprPrecedence(minPrec: number, asLval?: boolean, statementStart?: boolean): ASTBase; parsePrefix(minPrec: number, asLval?: boolean, statementStart?: boolean): ASTBase; parseAtom(): ASTBase; parseLiteral(): ASTLiteral; parseIdentifier(kind: ASTIdentifierKind): ASTIdentifier | ASTBase; parseInvalidCode(): ASTBase; raise(message: string, range: Range, code?: ErrorCode, hint?: string): ParserException; } declare const UnsafeParser_base: { new (...args: any[]): { statementErrors: Error[]; raise(message: string, range: Range, code?: ErrorCode, hint?: string): ParserException; parseStatement(): void; tryToRecover(snapshot: import("./mixins/unsafe-parser-mixin").ParserSnapshot): void; finishRemainingScopes(): void; token: Token | null; previousToken: Token | null; state: ParserState; outerScopes: ASTBaseBlockWithScope[]; iteratorStack: (ASTForGenericStatement | ASTWhileStatement)[]; lineRegistry: LineRegistry; currentScope: ASTBaseBlockWithScope; currentAssignment: ASTAssignmentStatement; backpatches: Stack; errors: Error[]; lexer: any; getState(): ParserState; next(): void; }; } & typeof Parser; export declare class UnsafeParser extends UnsafeParser_base { constructor(content: string, options?: ParserOptions); } export {};