|
SciLex
A header-only C++20 lexer built on REAL
|
SciLex is one point in a wide design space. This page states, as facts rather than claims, what SciLex is built around and what each neighbouring tool is built around — including where those tools do things SciLex does not. It leads with the axes, no adjectives; the measured throughput (with its comparability caveats) is at the end and in full in the performance baseline, BENCHMARKS.md.
(kind, pattern) rules built at runtime; adding or changing a rule needs no code-generation or build step. Patterns are real::regex strings.error token per unlexable run and resumes, so a whole document tokenizes in one pass..lex format.Each entry names what that tool does that SciLex does not, alongside where they differ.
.l / generator run) and a fixed grammar, in exchange for a lexer specialised to native code — raw scanner throughput is their axis. SciLex keeps the grammar as runtime data (no codegen), runs on an NFA with a linear guarantee, and adds modes/layout/recovery/bindings; the DFA fast path is an opt-in, not the delivery model.If your need is raw scanner throughput on one fixed grammar compiled into a binary, a code-generator (flex / re2c / Logos) is on the right axis. If it is incremental, error-tolerant parsing inside an editor, tree-sitter is. If it is a ready lexer for an existing language for highlighting, Pygments is. SciLex is on the axis of a grammar-as-data, linear-time, ReDoS-safe lexer with modes, layout, recovery, and first-class C++/Python use — the trade it makes deliberately.
Measured on the same inputs and the same task (a full tokenization pass), best-of-N with a bootstrap CI (benchmarks/bench_compare.py; full table and caveats in BENCHMARKS.md). Read them with the note that the tools produce different things:
BENCHMARKS.md). tree-sitter returns a C tree handle without per-token Python objects; flex, a code-generated native DFA, is the ceiling at ~160 MB/s — ~15–30× any Python-embedded option, exactly the codegen axis SciLex does not compete on.The numbers confirm the axes above rather than overturn them: SciLex's case is linear-time safety, grammar-as-data, modes/layout/recovery, and dual C++/Python use — not raw scanner throughput.