Expand description
An extremely fast, lookup table based, ECMAScript lexer which yields SyntaxKind tokens used by the rslint_parse parser.
For the purposes of error recovery, tokens may have an error attached to them, which is reflected in the Iterator Item.
The lexer will also yield COMMENT
and WHITESPACE
tokens.
The lexer operates on raw bytes to take full advantage of lookup table optimizations, these bytes must be valid utf8,
therefore making a lexer from a &[u8]
is unsafe since you must make sure the bytes are valid utf8.
Do not use this to learn how to lex JavaScript, this is just needlessly fast and demonic because i can’t control myself :)
basic ANSI syntax highlighting is also offered through the highlight
feature.
§Warning ⚠️
>>
and >>>
are not emitted as single tokens, they are emitted as multiple >
tokens. This is because of
TypeScript parsing and productions such as T<U<N>>
Re-exports§
pub use ansi_term;
Macros§
- T
- Utility macro for creating a SyntaxKind through simple macro syntax
Structs§
- ANSI
Generic String - An
ANSIGenericString
includes a generic string type and aStyle
to display that string.ANSIString
andANSIByteString
are aliases for this type onstr
and\[u8]
, respectively. - Highlighter
- A structure for syntax highlighting pieces of JavaScript source code using ANSI.
- Lexer
- An extremely fast, lookup table based, lossless ECMAScript lexer
- Style
- A style is a collection of properties that can format a string using ANSI escape codes.
- Token
- A single raw token such as
>>
or||
or"abc"
.
Enums§
- Color
- A colour is one specific type of ANSI escape code, and can refer to either the foreground or background colour.
- Syntax
Kind - The kind of syntax node, e.g.
IDENT
,FUNCTION_KW
, orFOR_STMT
.
Functions§
- color
- Colors a piece of source code using ANSI.
The string returned will be unaltered if stdout and stderr are not terminals. - is_
linebreak - Check if a char is a JS linebreak