import { EventEmitter } from "events"; import { Token, Comment } from "./Token"; import { BrsError } from "../Error"; /** The results of a Lexer's scanning pass. */ interface ScanResults { /** The tokens produced by the Lexer. */ tokens: Token[]; /** The comments produced by the Lexer. */ comments: Comment[]; /** The errors encountered by the Lexer. */ errors: BrsError[]; } export declare class Lexer { /** Allows consumers to observe errors as they're detected. */ readonly events: EventEmitter<[never]>; /** * A convenience function, equivalent to `new Lexer().scan(toScan)`, that converts a string * containing BrightScript code to an array of `Token` objects that will later be used to build * an abstract syntax tree. * * @param toScan the BrightScript code to convert into tokens * @param filename the name of the file to be scanned * @returns an object containing an array of `errors` and an array of `tokens` to be passed to a parser. */ static scan(toScan: string, filename?: string): ScanResults; /** * Convenience function to subscribe to the `err` events emitted by `lexer.events`. * @param errorHandler the function to call for every Lexer error emitted after subscribing * @returns an object with a `dispose` function, used to unsubscribe from errors */ onError(errorHandler: (err: BrsError) => void): { dispose: () => void; }; /** * Convenience function to subscribe to a single `err` event emitted by `lexer.events`. * @param errorHandler the function to call for the first Lexer error emitted after subscribing */ onErrorOnce(errorHandler: (err: BrsError) => void): void; /** * Converts a string containing BrightScript code to an array of `Token` objects that will * later be used to build an abstract syntax tree. * * @param toScan the BrightScript code to convert into tokens * @param filename the name of the file to be scanned * @returns an object containing an array of `errors` and an array of `tokens` to be passed to a parser. */ scan(toScan: string, filename: string): ScanResults; } export {};