Expand description
§SCNR2 Code Generation Library
This crate provides compile-time code generation for creating efficient lexical scanners. It converts regex patterns into optimized DFA-based scanners that can be used at runtime.
§Example Usage
ⓘ
use scnr2_macro::scanner;
scanner! {
MyScanner {
mode INITIAL {
token r"\d+" => NUMBER;
token r"[a-zA-Z_]\w*" => IDENTIFIER;
}
}
}
Modules§
- character_
classes - The character_classes module contains the character class definitions and utilities for SCNR2 generation. Module with data structures and algorithms to handle character classes for SCNR2 generation
- dfa
- The dfa module contains the DFA implementation.
- generate
- The codegen module contains the code generation logic for SCNR2.
- ids
- The id module contains the ID types used in the SCNR2 generation.
- minimizer
- Module that provides functions and types related to DFA minimization.
- nfa
- The nfa module contains the NFA implementation. This module contains the NFA (Non-deterministic Finite Automaton) representation of the regex syntax. The NFA is created from the high-level intermediate representation (HIR) of the regex syntax. Furthermore, it provides methods to support the conversion of the NFA into a DFA (Deterministic Finite Automaton), like ‘epsilon closure’ and ‘subset construction’.
- pattern
- The pattern module contains the pattern matching implementation. A pattern as a data structure that is used during the construction of the NFA. It contains the pattern string and the associated metadata. Metadata includes the terminal type and a possibly empty lookahead constraint.
- scanner_
data - The scanner data module.
- scanner_
mode - The scanner mode module contains the scanner mode’s implementation.