import { MatchState, Matcher } from './match'; import { InitTag, HasContexts, HasMeta, HasInit, TokenTag, ContextKey, ContextToken, ContextMeta, ParserResult } from './model'; export interface ParseFunc, Meta> { ($: ParserHandle, ...captures: string[]): void; } export interface ParserHandle, Meta> extends MatchState { p: ParserMatchers; a: ParserProcs; c: Ctx; m: Meta; t: ContextToken[]; } export interface InitFunc, Meta> { (m: MetaType): void; } export declare type ParserInits = InitFunc, Meta>[]; export declare const dropToken: any[]; export interface ProcFunc, Meta> { ($: ParserHandle, token: ContextToken): ContextToken[] | void; } export declare type ParserContextProcs, Meta> = { [Tag in TokenTag>]: ProcFunc, Meta>; }; export declare type ParserProcs = { [Ctx in ContextKey]: ParserContextProcs; }; export declare type ParserRuleSimple, Meta> = [Ctx[], // contexts number, // weight (order) string, // regexp to match ParseFunc]; export declare type ParserRuleWithInit, Meta> = [Ctx[], // contexts number, // weight (order) string, // regexp to match ParseFunc, // parsing function InitFunc]; export declare type ParserRuleWithPost, Meta> = [Ctx[], // contexts number, // weight (order) string, // regexp to match ParseFunc, // parsing function TokenTag>[], // token tags ProcFunc]; export declare type ParserRuleWithInitAndPost, Meta> = [Ctx[], // contexts number, // weight (order) string, // regexp to match ParseFunc, // parsing function InitFunc, // init function TokenTag>[], // token tags ProcFunc]; export declare type ParserRule, Meta> = ParserRuleSimple | ParserRuleWithInit | ParserRuleWithPost | ParserRuleWithInitAndPost; export declare type ParserRules = ParserRule, Meta>[]; export declare type ParserMatchers = { [Ctx in ContextKey]: Matcher>; }; export interface Parser> { p: ParserMatchers>; m: ParserInits>; a: ParserProcs>; s: Ctx; } export declare function init(...rules: ParserRules>): Parser; export declare function init>(start: Ctx, ...rules: ParserRules>): Parser; export declare function parse>({ p, a, s, m }: Parser, source: string): ParserResult; export declare function parseNest, NestedCtx extends ContextKey>($: ParserHandle>, src: string, ctx: NestedCtx): ContextToken[]; export declare function parseNest>($: ParserHandle>, src: string): ContextToken[]; export declare function procNest>($: ParserHandle>, tokens: ContextToken[]): void; export declare function procNest, NestedCtx extends ContextKey>($: ParserHandle>, tokens: ContextToken[], ctx: NestedCtx): void; export declare function lastToken, Meta>({ t: tokens }: ParserHandle): ContextToken | void; export declare function pushToken, Meta>({ t: tokens }: ParserHandle, token: ContextToken): void; export interface TextToken { $: keyof any; _: string; } export declare function pushText, Meta, Token extends TextToken & ContextToken>($: ParserHandle, tag: TokenTag, chunk: string): void;