UNPKG

decaffeinate-parser

Version:

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

32 lines (31 loc) 1.62 kB
import SourceTokenList from 'coffee-lex/dist/SourceTokenList'; import { Base, Block, LocationData } from 'decaffeinate-coffeescript2/lib/coffeescript/nodes'; import LinesAndColumns from 'lines-and-columns'; import { ClassProtoAssignOp, Constructor } from '../nodes'; /** * Any information we need to know about the current state of parsing. While the * hope is that this is mostly immutable, with replace operations as we walk the * AST, it is partially mutable to collect bound method names in a class. */ export declare class ParseState { readonly currentClassBoundMethods: Array<ClassProtoAssignOp> | null; currentClassCtor: Constructor | null; constructor(currentClassBoundMethods: Array<ClassProtoAssignOp> | null); isInClassBody(): boolean; recordBoundMethod(method: ClassProtoAssignOp): void; recordConstructor(ctor: Constructor): void; pushCurrentClass(): ParseState; dropCurrentClass(): ParseState; static initialState(): ParseState; } export default class ParseContext { readonly source: string; readonly linesAndColumns: LinesAndColumns; readonly sourceTokens: SourceTokenList; readonly ast: Block; readonly parseState: ParseState; constructor(source: string, linesAndColumns: LinesAndColumns, sourceTokens: SourceTokenList, ast: Block, parseState: ParseState); getRange(locatable: Base | LocationData): [number, number] | null; static fromSource(source: string, sourceLex: (source: string) => SourceTokenList, parse: (source: string) => Block): ParseContext; updateState(updater: (oldState: ParseState) => ParseState): ParseContext; }