Elise is a modern, modular, allocation-light language frontend engine written in Rust. It provides a generic, lossless Green Tree concrete syntax representation, a high-throughput single-pass lexer driver with perfect-hash keyword tables, and a deterministic event-fold tree constructor.
Elise is language-agnostic: the core engine (elise/) contains zero language-specific coupling, powering both the Silver reference compiler (agc) and multi-language parsers like the C11 preprocessor & parser (c-parser).
elise/
├── core/ # elise-core: Immutable Green Tree, NodeRef cursors, SourceGraph, spans
├── lex/ # elise-lex: Byte-class scan driver, FNV-1a keyword table, longest-match trie, Preprocess hooks
├── parse/ # elise-parse: Event folding (Enter/Advance/Exit -> Green Tree), trivia interleaving
└── examples/
└── c-parser/ # Full C11 lexer, preprocessor (#include/#define/#ifdef), and Pratt parser sample
All benchmarks are measured over the full Silver repository corpus (269 files across std/, tests/, and examples/, totaling 1,261,570 bytes (~1.26 MB) and 38,001 lines), using Criterion under the optimized release profile (opt-level = 3).
- Lexer Throughput: 3.4× faster than the legacy hand-written lexer (~253 MiB/s).
- End-to-End Parse Pipeline: 3.3× faster than the legacy compiler frontend (~63.7 MiB/s ≈ 1.92 Million lines/sec).
- Average Single-File Latency: ~1.1 ms / file.
| Corpus Scope | File Count | Byte Size | Legacy Lexer | elise-lex |
Speedup | Throughput |
|---|---|---|---|---|---|---|
std/ |
44 files | 557 KB | 7.73 ms | 2.78 ms | 2.8× faster | ~200 MiB/s |
tests/ |
196 files | 647 KB | 6.76 ms | 1.97 ms | 3.4× faster | ~328 MiB/s |
examples/ |
29 files | 57 KB | 0.70 ms | 0.22 ms | 3.2× faster | ~259 MiB/s |
| Full Corpus Total | 269 files | 1.26 MB | 17.15 ms | 4.99 ms | 3.4× faster | ~253 MiB/s |
| Stage | Scope | Legacy Hand-Written Parser | Elise Full Pipeline | Delta / Improvement |
|---|---|---|---|---|
| Lexing | Full Corpus | 17.15 ms | 4.99 ms | 3.4× faster |
| Parsing & Tree Folding | Full Corpus | 47.78 ms | ~14.8 ms | 3.2× faster |
| Total End-to-End Pipeline | Full Corpus (1.26 MB) | 64.93 ms | ~19.8 ms | 3.3× faster (~63.7 MiB/s) |
The C11 sample (elise/examples/c-parser), which runs macro preprocessing, conditional compilation, typedef disambiguation, and Pratt expression parsing, compared head-to-head with clang -fsyntax-only -std=c11 (Clang 22.1.8):
| C Source / Codebase | Scope / Lines | Byte Size | Elise (c-parser) |
Clang (-fsyntax-only) |
Speedup vs. Clang |
|---|---|---|---|---|---|
sqlite3ext.h |
730 lines | 38.6 KB | 0.96 ms | 24.69 ms | 25.6× faster |
sqlite3.h (SQLite Core Header) |
13,968 lines | 671.8 KB | 7.82 ms | 23.42 ms | 3.0× faster |
wuffs.c (Real-World Amalgamation) |
86,663 lines | 3.29 MB | 16.68 ms | 156.23 ms | 9.4× faster |
Full SQLite Repository (All 357 .c/.h files) |
443,143 lines | 14.45 MB | 219.36 ms (~0.22s) | 13,365.10 ms (~13.37s) | 60.9× faster |
-
Lossless Concrete Syntax Tree (Green Tree):
- Position-independent, immutable,
Rc-sharedGreennodes. - Trivia (whitespace, line comments, block comments, docstrings) is tracked out-of-band in
TokenBufand interleaved deterministically during the event fold. graph.text() == original_sourcebyte-for-byte across all 269 corpus files with 0 byte drift.
- Position-independent, immutable,
-
Zero-Allocation Token Storage (
TokenBuf):- Sequential, cache-friendly flat vectors storing
TokenRow { kind, start, len }. - Trivia preserved in
TriviaRowwithout polluting active token iterations.
- Sequential, cache-friendly flat vectors storing
-
Fast Keyword & Operator Matching:
KeywordMap: Open-addressed FNV-1a perfect hash table for O(1) keyword classification with zero heap allocation.OpTrie: Longest-match compact array trie for multi-character punctuators and operators (<<=,->,...,&&).
-
Modular Preprocessing Hooks (
Preprocess):- Pre-lex source transformations with zero-overhead default no-op (
Cow::Borrowed). - Line continuations, macro substitutions, and conditional
#ifbranches masked with span-preserving whitespace.
- Pre-lex source transformations with zero-overhead default no-op (
-
Deterministic Event Fold:
- Flat
Enter(kind),Advance(count),Exitevent stream folded into structured trees viaTreeBuilder. - Resilient against malformed streams with built-in event balance safety nets.
- Flat
use elise_lex::{LexSpec, TokenBuf};
use elise_parse::TreeBuilder;
use elise_core::SourceGraph;
// 1. Run lexical scanning
let mut spec = MyLanguageLexSpec::new();
let token_buf = elise_lex::scan(&mut spec, source_code).expect("lexical scan");
// 2. Parse into flat event stream
let events = parse_tokens(token_buf.rows());
// 3. Materialize lossless SourceGraph
let graph = TreeBuilder::new(source_code, &token_buf)
.root_kind(MyNodeKind::File as u16)
.finish(&events);
// 4. Inspect or traverse
assert_eq!(graph.text(), source_code);
for child in graph.root().children() {
println!("Node kind: {}, span: {:?}", child.kind(), child.span());
}# Run all Elise tests
cargo test -p elise-core -p elise-lex -p elise-parse -p c-parser
# Run differential parity tests over the Silver corpus
cargo test -p agc --test elise_lexer_parity --test elise_item_parity --test elise_source_graph
# Run criterion benchmark suite
cargo bench -p agc --bench corpus