import { Aggregator } from './aggregation.js'; import { AbstractScannerFactory } from "./scanner.js"; import { Search } from './scanners/search.js'; import { AggregateStateFactory, DefineStateFactory, StartStateFactory, StateFactory, InheritedStateFactory, TokenStateFactory, TransitionLookahead, TransitionStateFactory } from './scanners/searchbuilder.js'; import { SearchEvent } from './scanners/searchstate.js'; import { Operation } from './scanners/searchop.js'; import { Event } from './event.js'; import { IncrementalSink } from './incremental.js'; /** * Creates a transition that starts from a specific symbol or pattern. * * @param sym - An `AbstractScannerFactory` or a `string` representing the pattern. * @returns A new `TransitionLookahead` object initialized with a `FROM` boundary condition. * * @example * ```typescript * const fromGreen = from('🟢') // or from(match('🟢')) * parse(fromGreen, "🔵🔵🟢🔵🔵🟢🔵🔵🔵"), * fromGreen: "⚪⚪⚫⚫⚫⚫⚫⚫⚫" * ``` */ export declare const from: (sym: AbstractScannerFactory | string) => TransitionLookahead; /** * Creates a transition that starts after a specific symbol or pattern. * * @param sym - An `AbstractScannerFactory` or a `string` representing the pattern. * @returns A new `TransitionLookahead` object initialized with an `AFTER` boundary condition. * * @example * ```typescript * const afterGreen = after('🟢') // or after(match('🟢')) * parse(afterGreen, "🔵🔵🟢🔵🔵🟢🔵🔵🔵"), * afterGreen: "⚪⚪⚪⚫⚫⚫⚫⚫⚫" * ``` */ export declare const after: (sym: AbstractScannerFactory | string) => TransitionLookahead; /** * Creates a transition that ends its state after a specific symbol or pattern. * * @param sym - An `AbstractScannerFactory` or a `string` representing the pattern. * @returns A new `TransitionStateFactory` object initialized with an `AFTER` boundary condition. * * @example * ```typescript * const uptoGreen = upto('🟢') // or upto(match('🟢')) * parse(uptoGreen, "🔵🔵🔵🔵🟢🔵🔵🔵"), * afterGreen: "⚫⚫⚫⚫⚫⚪⚪⚪⚪" * ``` */ export declare const upto: (sym: AbstractScannerFactory | string) => TransitionStateFactory; /** * Creates a transition that ends its state before a specific symbol or pattern. * * @param sym - An `AbstractScannerFactory` or a `string` representing the pattern. * @returns A TransitionStateFactory with a 'FROM' boundary condition and 'TERMINATE' action. * * @example * ```typescript * const beforeGreen = before('🟢') // or before(match('🟢')) * parse(beforeGreenn, "🔵🔵🔵🔵🟢🔵🔵🔵"), * beforeGreen: "⚫⚫⚫⚫⚪⚪⚪⚪" * ``` */ export declare const before: (sym: AbstractScannerFactory | string) => TransitionStateFactory; /** * @deprecate Looking to remove in leiu of match(statefactory) * @param transition - The name of same cached state you want to match * @returns A new `TokenStateFactory` object. * * @example * ```typescript * const greenToRed = define('|🟢-|🔴', before('🔴'), start(from('🟢'))); * const greenToRedBetweenBlue = define('greenToRedBetweenBlue', * token('|🟢-|🔴') * upto('🔵'), * start(after('🔵')), * include(greenToRed) * ); * //... * parse(greenToRedBetweenBlue,`🟢🔵🔴🟢🔵🔴🔵🟢🔴`) * betweenBlue: ⚪⚪⚫⚫⚫⚫⚪⚪⚪ * greenToRed: ⚪⚪⚪⚪⚫⚪⚪⚪⚪ * ``` */ export declare const token: (name: string) => TokenStateFactory; /** * Initializes the start state for your parser or state machine. * * @param transition - A `TransitionLookahead` object to define the initial state. * @returns A new `StartStateFactory` object. * * @example * ```typescript * const greenToRed = define('|🟢-|🔴', before('🔴'), start(from('🟢'))); * const greenToRedBetweenBlue = define('greenToRedBetweenBlue', * token('|🟢-|🔴') * upto('🔵'), * start(after('🔵')), * include(greenToRed) * ); * //... * parse(greenToRedBetweenBlue,`🟢🔵🔴🟢🔵🔴🔵🟢🔴`) * betweenBlue: ⚪⚪⚫⚫⚫⚫⚪⚪⚪ * greenToRed: ⚪⚪⚪⚪⚫⚪⚪⚪⚪ * ``` */ export declare const start: (transition: TransitionLookahead) => StartStateFactory; /** * Matches any of the characters from the given pattern or array of patterns. * * @param pattern - A `string` or an array of `string` patterns to match. * @returns A new factory instance configured with the `ANY` condition. * * @example * ```typescript * const blueAndRed = any(['🔴', '🔵']); // OR any('🔴🔵') * //... * parse(blueAndRed,`🟢🔵🔴🟢🔵🔴🔵🟢🔴`) * blueAndRed: ⚪⚫⚫⚪⚫⚫⚫⚪⚫ * ``` */ export declare const any: (pattern: string | string[]) => import("./scanner.js").ScannerFactory; /** * Matches any of the characters from the given pattern or array of patterns. * * @param pattern - A `string` or an array of `string` patterns to match. * @returns A new factory instance configured with the `ANY` condition. * * @example * ```typescript * const notBlueOrRed = not('🔴🔵'); * // OR * const notBlueOrRed = not(['🔴', '🔵']); * //... * parse(notBlueOrRed,`🟢🔵🔴🟢🔵🔴🔵🟢🔴`) * blueAndRed: `⚫⚪⚪⚫⚪⚪⚪⚫⚪` * ``` */ export declare const not: (pattern: string | string[]) => import("./scanner.js").ScannerFactory; /** * Matches a specific pattern in the text. * * @param pattern - A `string` pattern that should be matched exactly. * @returns A new factory instance configured to match the given pattern. * * @example * ```typescript * const matchPattern = match('🔵🔴🔵'); * //... * parse(matchPattern,`🟢🔵🔴🟢🔵🔴🔵🟢🔴`) * matchPattern: `⚪⚪⚪⚪⚫⚫⚫⚪⚪` * ``` */ export declare const match: (pattern: string) => import("./scanner.js").ScannerFactory; /** * Defines a new named state with associated transitions which can be used to build a parser. * * @param name - A `string` representing the name of the state. * @param transitions - A spread array of `StateFactory` objects representing the state's transitions. * @returns A new `DefineStateFactory` object. * * @example * ```typescript * const adjacentBlues = define('firstBluesAfterRed', start(from('🔵')), after(any('🔵'))); * const blueOrNotGreen = define('blueOrNotGreen', * not('🟢'), * token('firstBluesAfterRed'), * include(adjacentBlues) * ); * //... * parse(blueOrNotGreen,`🔴🟢🔴🔵🔵🔵🟢🔴🟢`) * blueOrNotGreen: `⚫⚪⚫⚫⚫⚫⚪⚫⚪` * ``` */ export declare const define: (name: string, ...transitions: StateFactory[]) => DefineStateFactory; export declare const push: (name: string, ...variables: [string, string?][]) => Operation<"PUSH">; export declare const pop: (num?: number | string | string[]) => Operation<"POP"> | Operation<"POP_TO">; export declare const goto: (name: string, ...variables: [string, string?][]) => Operation<"GOTO">; /** * Attaches a key-value label to a specific state or transition. * * @param key - A `string` representing the key for the label. * @param value - An optional `string` value for the label. Defaults to the value of `key`. * @returns A new aggregate unit with the applied label. * * @example * ```typescript * const labelExample = label('Type', 'Letter'); * // OR * const labelExample = label('Type'); * * ``` */ export declare const label: (key: string, value?: string) => AggregateStateFactory; /** * Combines multiple states or transitions into a single aggregate unit. * * @param key - A `string` representing the key for the aggregate unit. * @param aggregator - An `Aggregator` object used to combine states or transitions. * @returns A new `AggregateStateFactory` object. * * @example * ```typescript * const aggregateExample = aggregate('group1', someAggregator); * ``` */ export declare const aggregate: (key: string, aggregator: Aggregator) => AggregateStateFactory; /** * Creates a new state that inherits its behavior from another state. * * @param other - A `DefineStateFactory` object from which to inherit behavior. * @returns A new `InheritedStateFactory` object. */ export declare const inherit: (other: DefineStateFactory) => InheritedStateFactory; /** * Creates a specialized version of an existing state with additional transitions. * * @param other - A `DefineStateFactory` object from which to base the new state. * @param name - A `string` representing the name of the specialized state. * @param transitions - A spread array of `StateFactory` objects to add to the existing transitions. * @returns A new `DefineStateFactory` object. * ``` */ export declare const substate: (other: DefineStateFactory, name: string, ...transitions: StateFactory[]) => DefineStateFactory; export declare const build: (definedStates: DefineStateFactory, initialState: string, parseID: string, publisher?: IncrementalSink) => Search; export declare const set: (name: any, cb: any) => AggregateStateFactory; export declare const asonly: (childname: string, extraction: any) => (key: any) => Aggregator; export declare const asall: (childname: string, extraction: any) => (key: any) => Aggregator<[import("./range.js").Range, unknown][], [import("./range.js").Range, unknown][]>; export declare const fromclose: (fn: (interval: SearchEvent, states?: any) => any) => (name: any) => Aggregator; export declare const asreduction: (initialize: (first: Event) => State, reduce: (state: State, next: SearchEvent, states: any) => State, close?: (state: State, states: any, last: any) => Output) => (name: any) => Aggregator; export declare const ascancellablereduction: (initialize: (first: Event) => State, reduce: (state: State, next: SearchEvent, states: any) => State, cancel: (state: Output) => boolean, close?: (state: State, states: any, last: any) => Output) => (name: any) => Aggregator; //# sourceMappingURL=grammar.d.ts.map