Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ILexerConfig

Hierarchy

  • ILexerConfig

Index

Properties

Optional deferDefinitionErrorsHandling

deferDefinitionErrorsHandling: boolean

An optional flag indicating that lexer definition errors should not automatically cause an error to be raised. This can be useful when wishing to indicate lexer errors in another manner than simply throwing an error (for example in an online playground).

Optional lineTerminatorsPattern

lineTerminatorsPattern: RegExp | ILineTerminatorsTester

A regExp defining custom line terminators. This will be used to calculate the line and column information.

Note that the regExp should use the global flag, for example: /\n/g

The default is: /\n|\r\n?/g

But some grammars have a different definition, for example in ECMAScript: http://www.ecma-international.org/ecma-262/8.0/index.html#sec-line-terminators U+2028 and U+2029 are also treated as line terminators.

In that case we would use /\n|\r|\u2028|\u2029/g

Note that it is also possible to supply an optimized RegExp like implementation as only a subset of the RegExp is needed, @see {ILineTerminatorsRegExp} for details.

keep in mind that for the default pattern: /\n|\r\n?/g an optimized implementation is already built-in. This means the optimization is only relevant for lexers overriding the default pattern.

Optional positionTracking

positionTracking: "full" | "onlyStart" | "onlyOffset"

"full" location information means all six combinations of /(end|start)(Line|Column|Offset)/ properties. "onlyStart" means that only startLine, startColumn and startOffset will be tracked "onlyOffset" means that only the startOffset will be tracked.

The less position tracking the faster the Lexer will be and the less memory used. However the difference is not large (~10% On V8), thus reduced location tracking options should only be used in edge cases where every last ounce of performance is needed.

Generated using TypeDoc