#lexer #compiler #rustc #source #token #language #lexing

rustc-ap-rustc_lexer

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

192 major breaking releases

727.0.0 Jul 6, 2021
726.0.0 Jun 29, 2021
725.0.0 Jun 22, 2021
724.0.0 Jun 15, 2021
535.0.0 Jul 22, 2019

#244 in Programming languages

Download history 3790/week @ 2024-07-20 5969/week @ 2024-07-27 4166/week @ 2024-08-03 4307/week @ 2024-08-10 3867/week @ 2024-08-17 4181/week @ 2024-08-24 3975/week @ 2024-08-31 4418/week @ 2024-09-07 3217/week @ 2024-09-14 4614/week @ 2024-09-21 3080/week @ 2024-09-28 3519/week @ 2024-10-05 4092/week @ 2024-10-12 3921/week @ 2024-10-19 2584/week @ 2024-10-26 4164/week @ 2024-11-02

15,443 downloads per month
Used in 41 crates (8 directly)

MIT/Apache

64KB
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

~58KB