Expand description
Hand-rolled recursive-descent parser for the minimal BibTeX subset.
The grammar is intentionally tiny:
bibtex := ws* (entry ws*)*
entry := '@' type '{' key (',' fields)? '}'
fields := field (',' field)* ','?
field := name '=' value
value := '{' .. '}' | '"' .. '"' | bareEntry types and field names are lowercased; citation keys are kept
verbatim. Brace values balance nested {} by naive counting, so
{The {LaTeX} Companion} is captured whole, but their contents are
stored as raw text; no TeX decoding, no @string / @preamble macro
expansion, no # concatenation, no name parsing.
Structsยง
- Parsed
Entry ๐ - Parsed
Key ๐ - Parser ๐
- A byte cursor over the BibTeX source. All structural delimiters
(
@ { } " , =) and whitespace are ASCII, so scanning byte-by-byte never splits a multi-byte UTF-8 sequence and every recorded offset lands on acharboundary.
Functionsยง
- is_
bare_ ๐value_ byte - Bytes allowed in a bare (unquoted, unbraced) value.
- is_
identifier_ ๐byte - Bytes allowed in an entry type or field name.
- is_
key_ ๐byte - Bytes allowed in a citation key: anything but a structural delimiter or whitespace.
- parse_
bibtex - Parse
inputas a minimal BibTeX database.