import { Heap } from 'heap-js'; import { HeapMultimap } from '@console-one/multimap'; import { Range } from '../range.js'; import { Signal } from '../signal.js'; import { Scanner, ScannerFactory } from './../scanner.js'; export declare const createPrioritization: (order: Map) => (a: KeyType, b: KeyType) => 0 | 1 | -1; export declare const pivotByOrder: (arr: A[], extract: (input: A) => K) => Map; /** * Runs multiple searches across an input stream. * * Effectively, each input Scanner is a sliding window: * For all Scanners which share the same closed index, feed input incrementally. * * More in server/notes/race-scanner.md * */ export declare class Race implements Scanner { /** * String * The ID of this race lexer which could be used to index it * within other race lexers. */ id: string; /** * Map> * The scanners we are 'racing' within this scanner in order to * find the next token. */ scannerNamesToScanners: Map>; /** * HeapMultimap * A map keyed by numbers representing indexes within the input * character stream. The values of the map are a sorted list * of the names of scanners which are blocked until receiving the * character located at the index of their map key. */ scannerNamesByLastProcessedIndex: HeapMultimap; /** * Map * A map from scanner name to the highest value * character index it has read from the input */ scannerNameToLastInputIndexConsumed: Map; /** * Heap * A Heap of numbers representing the indices * different lexers are blocked at within the input * character stream. */ allScannerLastProcessedIndexes: Heap; /** * Integer * An integer of the last evicted index blocking a scanner from * the min heap. This index, and all before it, inclusive, have * been completely processed by this lexer. */ closedIndex: number; /** * Map * A map of the indexes within the input character stream to the * contiguous data input observed at those indexes. */ data: Map; /** * Map * Each number associated with some input data in the input stream, * to the number which succeeded it in the stream. */ nextNumbers: Map; /** * Map * Each number associated with some input data in the input stream, * to the number which proceeded it in the stream. */ prevNumbers: Map; /** * Integer * The last value observed in the input sequence (consequently the largest). * The only number as value but not key in the 'next numbers' map. */ lastObserved: number; /** * Map * Different input types to a number representing priority in heap. Need to * evaluate how this is used. */ order: Map; /** * * the matchers which have completed at the current index */ currentCompletions: Map>; /** * Boolean - * Whether this lexer has been fed all its input and now terminated. */ completed: boolean; /** * Signal - * The last returned value after the output is found. Re-emitted any subsequent time * this scanner is called. */ terminal: Signal; /** * SEARCHING | FEEDING * If a race result has been concluded, but we are waiting for the terminal * token of the definite winning 'lexer' of the race, we place this scanner * into a state of 'feeding', since the incorporate of the winning lexers * inner logic into this lexers state is forbidden. */ state: 'SEARCHING' | 'FEEDING'; constructor(scanners: Scanner[], id?: string); print(tabs?: number): string; complete(): boolean; applyLabels(result: Range.ReadOutput[]): Range.ReadOutput[]; shift(signal: Signal): Signal; private evacUpto; private setTokenIndexMappings; private close; static factory(crawlerFactories: ScannerFactory[], id?: string): ScannerFactory; } //# sourceMappingURL=race.d.ts.map