UNPKG

tell-me-when

Version:
100 lines 3.78 kB
import { ParseNode } from './ParseNode'; import { ParseState } from './ParseState'; export declare abstract class GrammarNode { abstract parse(state: ParseState): ParseNode; parseAs(parseAs: new (node: ParseNode) => ParseNode): ParseAsNode; /** * Matches this node once or zero times */ maybe(): MaybeNode; /** * Matches this node or the alternate node */ or(alternate: GrammarNode): OrNode; /** * Matches one of the given nodes. The first option to parse successfully wins */ static oneOf(...options: (string | RegExp | GrammarNode | (() => GrammarNode))[]): OrNode; /** * Matches one of the given nodes. Tries all of the options, and the one that * successfully parses the farthest in the input wins */ static longestOf(...options: (string | RegExp | GrammarNode | (() => GrammarNode))[]): LongestOfNode; /** * Matches this node repeated the given number of times */ repeat(count: number): RepeatNode; /** * Matches this node repeated between min and max (inclusive) times */ repeat(min: number, max: number): RepeatNode; static toGrammarNode(factor: string | RegExp | GrammarNode | (() => GrammarNode)): GrammarNode; /** * Matches the given string or regular expression */ static token(token: string | RegExp): TokenNode; /** * Matches the given nodes in sequence */ static group(...sequence: (string | RegExp | GrammarNode | (() => GrammarNode))[]): GroupNode; /** * Creates a named group that matches the given nodes in sequence. * Same as {@link group} but the {@link ParseNode} returned by {@link parse} * will have the given name. */ static named(name: string, ...sequence: (string | RegExp | GrammarNode | (() => GrammarNode))[]): GroupNode; static negativeLookahead(...sequence: (string | RegExp | GrammarNode | (() => GrammarNode))[]): NegativeLookaheadNode; } export declare class GrammarNodeRef extends GrammarNode { ref: () => GrammarNode; constructor(ref: () => GrammarNode); parse(state: ParseState): ParseNode; } export declare class TokenNode extends GrammarNode { token: string | RegExp; constructor(token: string | RegExp); parse(state: ParseState): ParseNode; } export declare class MaybeNode extends GrammarNode { node: GrammarNode; constructor(node: GrammarNode); parse(state: ParseState): ParseNode; } export declare class RepeatNode extends GrammarNode { node: GrammarNode; count: number | [number, number]; constructor(node: GrammarNode, count: number | [number, number]); parse(state: ParseState): ParseNode; } export declare class OrNode extends GrammarNode { options: GrammarNode[]; constructor(...options: GrammarNode[]); parse(state: ParseState): ParseNode; } export declare class LongestOfNode extends GrammarNode { options: GrammarNode[]; constructor(...options: GrammarNode[]); parse(state: ParseState): ParseNode; } export declare class GroupNode extends GrammarNode { name: string | undefined; factors: GrammarNode[]; constructor(name: string | undefined, ...factors: GrammarNode[]); parse(state: ParseState): ParseNode; } export declare class NegativeLookaheadNode extends GrammarNode { node: GrammarNode; constructor(node: GrammarNode); parse(state: ParseState): ParseNode; } export declare class ParseAsNode extends GrammarNode { node: { parse: (state: ParseState) => ParseNode; }; private parseAsClass; constructor(node: { parse: (state: ParseState) => ParseNode; }, parseAsClass: new (node: ParseNode) => ParseNode); parse(state: ParseState): ParseNode; } //# sourceMappingURL=GrammarNode.d.ts.map