2 releases (1 stable)
new 1.83.0 | Nov 29, 2024 |
---|---|
0.1.0 | Nov 29, 2024 |
#484 in Rust patterns
234 downloads per month
Used in 7 crates
(3 directly)
74KB
1.5K
SLoC
Low-level Rust lexer.
The idea with rustc_lexer
is to make a reusable library,
by separating out pure lexing and rustc-specific concerns, like spans,
error reporting, and interning. So, rustc_lexer operates directly on &str
,
produces simple tokens which are a pair of type-tag and a bit of original text,
and does not report errors, instead storing them as flags on the token.
Tokens produced by this lexer are not yet ready for parsing the Rust syntax.
For that see rustc_parse::lexer
, which converts this basic token stream
into wide tokens used by actual parser.
The purpose of this crate is to convert raw sources into a labeled sequence of well-known token types, so building an actual Rust token stream will be easier.
The main entity of this crate is the TokenKind
enum which represents common
lexeme types.
Dependencies
~350KB