#lexer #compiler #language #rustc-lexer #automatic #token #syntax

ra-ap-rustc_lexer

Automatically published version of the package rustc_lexer in the rust-lang/rust repository from commit f6cb952dc115fd1311b02b694933e31d8dc8b002 The publishing script for this crate lives at: https://github.com/rust-analyzer/rustc-auto-publish

78 breaking releases

new 0.85.0 Dec 9, 2024
0.80.0 Nov 24, 2024
0.79.0 Nov 17, 2024
0.62.0 Jul 21, 2024
0.7.0 Jun 27, 2023

#18 in Programming languages

Download history 16397/week @ 2024-08-23 17167/week @ 2024-08-30 17705/week @ 2024-09-06 18562/week @ 2024-09-13 19678/week @ 2024-09-20 18622/week @ 2024-09-27 20264/week @ 2024-10-04 19715/week @ 2024-10-11 21092/week @ 2024-10-18 21198/week @ 2024-10-25 21120/week @ 2024-11-01 20818/week @ 2024-11-08 20903/week @ 2024-11-15 20697/week @ 2024-11-22 22334/week @ 2024-11-29 18750/week @ 2024-12-06

85,524 downloads per month
Used in 54 crates (9 directly)

MIT/Apache

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