Expand description
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).
Modules§
- unstable_
api - A module for lifting restrictions on visibility by enabling unstable features.
Macros§
- lrlex_
mod - A convenience macro for including statically compiled
.l
files. A filesrc/a/b/c.l
processed by CTLexerBuilder::lexer_in_src_dir can then be used in a crate withlrlex_mod!("a/b/c.l")
.
Structs§
- CTLexer
- An interface to the result of CTLexerBuilder::build().
- CTLexer
Builder - A
CTLexerBuilder
allows one to specify the criteria for building a statically generated lexer. - Default
Lexeme - lrlex’s standard lexeme struct, provided as a convenience.
- Default
Lexer Types - lrlex’s standard LexerTypes
struct
, provided as a convenience. - LRLex
Error - A Lexing error.
- LRNon
Streaming Lexer - An
LRNonStreamingLexer
holds a reference to a string and can lex it into lrpar::Lexemes. Although the struct is tied to a single string, no guarantees are made about whether the lexemes are cached or not. - LRNon
Streaming Lexer Def - This struct represents, in essence, a .l file in memory. From it one can produce an LRNonStreamingLexer which actually lexes inputs.
- LexBuild
Error - Any error from the Lex parser returns an instance of this struct.
- Start
State Id
Enums§
- LexError
Kind - The various different possible Lex parser errors.
- Lexer
Kind - Rust
Edition - Specifies the Rust Edition that will be emitted during code generation.
- Visibility
- Specify the visibility of the module generated by CTLexerBuilder.
Constants§
Traits§
- Lexer
Def - Methods which all lexer definitions must implement.
Functions§
- ct_
token_ map - Create a Rust module named
mod_name
that can be imported withlrlex_mod!(mod_name)
. The module contains oneconst
StorageT
per token intoken_map
, with the token prefixed byT_
. For example withStorageT
u8
,mod_name
x
, andtoken_map
HashMap{"ID": 0, "INT": 1}
the generated module will look roughly as follows:
Type Aliases§
- LexBuild
Result - NonStreaming
Lexer Def Deprecated