42 releases

Uses new Rust 2024

0.14.2 Apr 30, 2026
0.14.1 Jan 20, 2026
0.14.0 Oct 22, 2025
0.13.10 Feb 28, 2025
0.1.1 Dec 18, 2018

#67 in Parser tooling

Download history 9544/week @ 2026-02-22 13099/week @ 2026-03-01 12899/week @ 2026-03-08 9757/week @ 2026-03-15 9669/week @ 2026-03-22 11442/week @ 2026-03-29 14036/week @ 2026-04-05 13550/week @ 2026-04-12 14352/week @ 2026-04-19 11005/week @ 2026-04-26 11582/week @ 2026-05-03 37205/week @ 2026-05-10 24305/week @ 2026-05-17 21323/week @ 2026-05-24 21722/week @ 2026-05-31 21522/week @ 2026-06-07

90,310 downloads per month
Used in 22 crates (11 directly)

Apache-2.0/MIT

695KB
16K SLoC

lrlex is a partial replacement for lex / flex. It takes in a .l file and statically compiles it to Rust code. The resulting [LRNonStreamingLexerDef] can then be given an input string, from which it instantiates an [LRNonStreamingLexer]. This provides an iterator which can produce the sequence of lrpar::Lexemes for that input, as well as answer basic queries about cfgrammar::Spans (e.g. extracting substrings, calculating line and column numbers).


lrlex

lrlex is a partial replacement for lex / flex. It takes an input string and splits it into lexemes based on a .l file. Unfortunately, many real-world languages have corner cases which exceed the power that lrlex can provide. However, when it is suitable, it is a very convenient way of expressing lexing.

lrlex also has a simple command-line interface, allowing you to check whether your lexing rules are working as expected:

$ cat C.java
class C {
    int x = 0;
}
$ cargo run --lrlex java.l /tmp/C.java
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `target/debug/lrlex ../grammars/java7/java.l /tmp/C.java`
CLASS class
IDENTIFIER C
LBRACE {
INT int
IDENTIFIER x
EQ =
INTEGER_LITERAL 0
SEMICOLON ;
RBRACE }

Dependencies

~4.5–7MB
~119K SLoC