import { Matcher } from './matcher'; import { Sink } from './sink'; import { Instruction } from './instructions'; import { FormatterCall } from './instructions'; import { Opcode } from './opcodes'; import { FormatterTable, PredicateTable } from './plugin'; type ParserState = () => ParserState | null; /** * Parse a template and send instructions to the given sink. */ export declare class Parser { private str; private sink; private matcher; private formatters; private predicates; private idx; private len; constructor(str: string, sink: Sink, matcher: Matcher, formatters?: FormatterTable, predicates?: PredicateTable); /** * Parse the input string, transitioning through the states. */ parse(): void; push(inst: Instruction | Opcode): void; parseTag(start: number, end: number): boolean; parseInstruction(start: number, end: number): boolean; /** * Parse a BINDVAR instruction. Example: * * {.var @foo bar,baz|foo arg1 arg2|bar arg1} */ parseBindvar(): boolean; parseCtxvar(): boolean; /** * Parse an EVAL instruction. Example: * * {.eval @foo = 1 + 2 ; @bar = 3 * @index0 ; @foo + @bar} */ parseEval(): boolean; /** * Parse an IF instruction. Example: * * {.if foo || bar} */ parseIf(): boolean; /** * Parse an INCLUDE instruction. Example: * * {.include partial suppress} */ parseInclude(): boolean; /** * Parse an INJECT instruction. Example: * * {.inject @bar ./messages-en_US.json} */ parseInject(): boolean; /** * Parse a MACRO instruction. Example: * * {.macro person-info} */ parseMacro(): boolean; /** * Parse an OR_PREDICATE or PREDICATE instruction with arguments. Examples: * * {.equal? foo "bar"} * {.or} * {.or greaterThan? year 2017} */ parsePredicate(op: Opcode): boolean; /** * Parse a SECTION or REPEATED instruction. Examples: * * {.section foo.bar} * {.repeated section items} */ parseSection(op: Opcode): boolean; /** * Parse a variable reference and optional formatters. Examples: * * {foo.bar} * {items.0.name} * {$foo.bar} * {@baz} * * {a, b, c|html|json-pretty} * {timestamp|date %c} */ parseVariable(): boolean; /** * Flush characters between start and end as a text instruction and * set the stream pointer to the end. */ flushText(start: number, end: number): void; /** * Main parser state. Parses alternating text / code instructions. */ stateMain(): ParserState | null; /** * Multi-line comment parser state. */ stateMultiLineComment(): ParserState | null; checkFormatters(formatters: null | 0 | FormatterCall[]): boolean; } export {};