UNPKG

ima-parse

Version:

Easy Simple Parser, that only requires a Grammar JSON to output an AST.

24 lines (23 loc) 1.04 kB
import { ParsedRule, Input, ParsedPart } from "./definitionParsers"; import { GrammarRule, Grammar } from "./grammarTypes"; import { Cursor, Position, Result } from "../helpers/helpers"; export declare class RuleParser { rule: GrammarRule; grammar: Grammar; parent?: RuleParser | undefined; parsedParts: ParsedPart[]; /** Rules that are not part of the definition of this rule but are children of this one (comments/macros and such) */ globalParsedParts: ParsedRule[]; constructor(rule: GrammarRule, grammar: Grammar, parent?: RuleParser | undefined); /** * Try to parse whatever phrase is given with the current or next part. It's not up to us to decide if it must succeed, we just try * to do it and if it succeeds, we add another ParsedPart to the progress list (`this.parsedParts`) */ parsePhrase(input: Input): Result<{ ruleParser: RuleParser; }>; hasRequiredPartsLeft(): boolean; getPosition(): Position; getStartCursor(): Cursor; getEndCursor(): Cursor; }