@launchmenu/core
Version:
An environment for visual keyboard controlled applets
75 lines • 3.54 kB
TypeScript
import { Lexer, ILexerConfig, ILexingError } from "chevrotain";
import { IHighlightMultiModeLexerDefinition } from "./_types/IHighlightMultiModeLexerDefinition";
import { IHighlightTokenType } from "./_types/IHighlightTokenType";
import { IHighlightToken } from "./_types/IHighlightToken";
import { IHighlighter } from "./_types/IHighlighter";
import { IHighlightNode } from "./_types/IHighlightNode";
import { IHighlightError } from "./_types/IHighlightError";
export declare class HighlightLexer extends Lexer implements IHighlighter {
protected highlightLexer: Lexer;
/**
* Creates a new highlight lexer
* @param lexerDefinition -
* Structure composed of Tokens Types this lexer will identify.
*
* In the simple case the structure is an array of TokenTypes.
* In the case of `IHighlightMultiModeLexerDefinition` the structure is an object with two properties:
* 1. a "modes" property where each value is an array of TokenTypes.
* 2. a "defaultMode" property specifying the initial lexer mode.
*
* for example:
*
* ```
* {
* modes : {
* modeX : [Token1, Token2],
* modeY : [Token3, Token4]
* },
*
* defaultMode : "modeY"
* }
* ```
*
* A lexer with `IHighlightMultiModesDefinition` is simply multiple Lexers where only one Lexer(mode) can be active at the same time.
* This is useful for lexing languages where there are different lexing rules depending on context.
*
* The current lexing mode is selected via a "mode stack".
* The last (peek) value in the stack will be the current mode of the lexer.
* Defining entering and exiting lexer modes is done using the "push_mode" and "pop_mode" properties
* of the `config` parameter.
*
* - The Lexer will match the **first** pattern that matches, Therefor the order of Token Types is significant.
* For example when one pattern may match a prefix of another pattern.
*
* Note that there are situations in which we may wish to order the longer pattern after the shorter one.
* For example: [keywords vs Identifiers](https://github.com/SAP/chevrotain/tree/master/examples/lexer/keywords_vs_identifiers).
* @param config The lexer configuration file
*/
constructor(lexerDefinition: IHighlightTokenType[] | IHighlightMultiModeLexerDefinition, config?: ILexerConfig);
/**
* Extracts the full highlight data from the given syntax
* @param syntax The syntax to highlight
* @returns The tokens including ones with groups that should be skipped and highlighting tags and possible errors
*/
getHighlightData(syntax: string): {
errors: ILexingError[];
tokens: IHighlightToken[];
};
/**
* Extracts the highlight data from the given syntax
* @param syntax The syntax to highlight
* @returns The highlight nodes and possibly a syntax error
*/
highlight(syntax: string): {
nodes: IHighlightNode[];
errors: IHighlightError[];
};
/**
* Maps a lexing error to a highlight error
* @param syntax The syntax the error corresponds to
* @param error The error to map
* @returns The highlight error
*/
static mapError(syntax: string, { message, offset, length }: ILexingError): IHighlightError;
}
//# sourceMappingURL=HighlightLexer.d.ts.map