EVOPEDIA

← all systems · see it in The System

Parser

A parser is a software component that takes input data (typically text) and builds a data structure (a parse tree, an abstract syntax tree or another hierarchy) giving a structural representation of the input while checking for correct syntax, by the rules of a formal grammar. Walked here as the machine, with the people who write grammars and parsers as its practice; human sentence parsing as psycholinguistics studies it is booked on the shelf.

Properties published scienceour proposal

Sourced fields, and our own readings.

born atabout 1959-1963 (compiler-compiler designed from 1959; Floyd's precedence method 1963; Meta I January 1963)
born precisionyears
boundaryInside: the lexer (scanner) where it is separate, the parse tables or parsing functions and their stack, the lookahead buffer, the error handler, the tree builder, and the grammar as held in the parser's code or tables; the people who write grammars and parsers as its practice. Outside: the input and whoever sends it (a programmer, a file, a peer on the network, an attacker), the specification the grammar is drawn from, the parser generator that builds it (a sibling tool), the consumers of its output (a compiler's middle end, an interpreter, an application, a database), and the machine it runs on.
nested levelBuilt from a lexer, a recogniser (tables and stack, or recursive functions) and a tree builder; part of a compiler's front end (compiler L3), a programming language's implementation (programming-language L3), the input-handling code of every program that reads a format or protocol (software L4, runtime and libraries); its output is the structure the next component acts on.
scaletechnological

Measures (18) published science

characteristic clock: sentences parsed per second by a neural dependency parsermore than 1000 sentences per second
JSON parsing throughput on one core (simdjson)gigabytes per second
instructions relative to RapidJSONa quarter or fewer ratio
LR parsing timelinear in the input length time complexity
general context-free parsing, worst caseO(n^3) for CYK, Earley and GLR; best combinatorial O(n^3/log^3 n); Valiant's O(n^ω), ω < 2.373 (1975), still unbeaten time complexity
accuracy lost and speed gained by distilling a dependency parser to 20% of its parametersabout 1 point (UAS and LAS); 2.30x faster on CPU, 1.19x on GPU points; speed ratio
inference energy for 8K test sentences (full model; distilled to 20%)0.32; 0.24 kJ
share of X.509 certificates in use that are syntactically invalid21.5 %
syntactically incorrect certificates accepted by TLS libraries631k to 1,156k (5.7%-10.5%) across 7 libraries certificates
JSON parsers compared in one differential test22 parsers
centre embeddings a human reader can parse3 at most in written language; practically none in speech embeddings
typical lookahead in programming-language parsers1 tokens
C parser states without and with lookaheadabout 10,000; about 300 states
data formats implemented in Daedalus20 formats
cadence of attacks on X.509 certificate parsingsteady over the last 10 years reports
CPython's PEG parser against its LL(1) parser, speed and memorywithin 10%
syntax-error repair rate (CPCT+, 200,000 invalid Java files)98.37 % of files within 0.5 s
error locations reported: CPCT+ against panic mode435,812 against 981,628 error locations

Open contentions (4) open contention

Where sources or readings disagree. Both stay on the map.

Cross-scale patterns seen here (25) our proposal

Shapes that recur when the same kind of problem is solved at different scales, and how each shows in Parser. Each links to every other system that shows it.

Valence: what it trades, and with whom (14) published science

Each exchange with a neighbour, read from both sides: who gains, who pays, and what carries it.

Partners and parts published science

Built from / builds (7)

Sits inside / holds (4)

expressed by (22)

floor filled by (17)

Kinds (13)

wired (2)

Notes published science

Layers

The ways it takes in its world, where they meet, and how it acts back, each from L1 (where it meets the world) up.

a parser as computer scientists describe it: a stream of symbols in, through tokens and the grammar's recognition, to a structure handed on and acted on (reader's view)

  1. L1: The input stream: characters or bytes in a file, a document or a network message (source code, JSON, XML, HTML, certificates), or the words of a sentence
  2. L2: Lexical analysis: a scanner, usually a finite-state machine from regular expressions, splits the characters into tokens (scannerless parsers fold this floor into the next)
  3. L3: Recognition: the automaton and stack apply the grammar's rules, top-down (LL, recursive descent: predict and match) or bottom-up (LR: shift and reduce), with k tokens of lookahead
  4. L4: Structure: a parse tree, abstract syntax tree or other hierarchy; for ambiguous input, a parse forest
  5. L5: Validation and the verdict: contextual rules the grammar cannot carry, checked after a relaxed parse; syntax errors reported, repaired or recovered from; the input accepted or rejected
  6. L6: Output contract: the tree type, AST schema or event interface that the consuming component is built against (CPython's internal AST converted to ast.AST objects; a verified parser's value-and-length result; registered callbacks)
  7. L7: Action on the input: the program works out what the validated input means and acts (an interpreter evaluates, a compiler generates code, a browser renders) or refuses it

the boardroom (shared floors)

  1. L3: Recognition: the automaton and its stack (or recursive functions) apply the grammar to the tokens, top-down or bottom-up, choosing with k tokens of lookahead; deterministic methods in linear time, general ones up to cubic
  2. L4: Structure: phrases reduced into one tree (parse tree, abstract syntax tree), or a parse forest for ambiguous input
  3. L5: Validation and the verdict: contextual rules the grammar cannot carry, limits, syntax errors reported, repaired or recovered from; the input accepted or rejected
  4. L6: Output contract: the tree type, AST schema or event interface that the consuming component is built against (CPython's internal AST converted to ast.AST objects; a verified parser's value-and-length result; registered callbacks)
  5. L7: Action on the input: the program works out what the validated input means and acts (evaluate, generate code, render, answer) or refuses it

way in: A person's edits to a file open in an editor (incremental parsing)

  1. L1: The edited text of a file

way in: Hand-parsed corpora (treebanks) for statistical and neural parsers

  1. L1: Sentences annotated with their structure by hand (a treebank such as the Penn Treebank)
  2. L2: Learned statistics or dense features: how often constructions occur in context

way in: Messages and documents arriving over the network (JSON, X.509 certificates, TLS, HTML)

  1. L1: Bytes of a protocol message or data-format document received from a peer
  2. L2: Framing and structural indexing: the encoding checked and the structural characters located (simdjson's first stage, with SIMD instructions)

way in: Names already declared (the symbol table fed back to the lexer)

  1. L1: The symbol table's entries in memory: typedef names and variable names
  2. L2: The lexer asks the symbol table before it gives a name its token class

way in: Resource limits: memory, text size, nesting depth

  1. L1: The machine's memory and the limits an implementation sets
  2. L2: Caps set inside the parser: memory allocated to one parser capped, or entities expanded lazily only when used
  3. L3: Recursion handled in constant stack space by design

way in: Test inputs run through several parsers of one format (differential testing, red teams)

  1. L1: Generated or collected inputs, each given to many parsers
  2. L2: Consensus normalisation: each parser's output reduced to a common form for comparison

way in: Text in a computer or data language (source code, documents, files)

  1. L1: Characters in a file or document, written by people or generated by programs
  2. L2: The lexer: a finite-state machine from regular expressions groups characters into tokens

way in: The grammar (and the specification it is drawn from)

  1. L1: Grammar rules (BNF, EBNF, PEG, ASN.1-derived) written by language and format designers
  2. L2: The parser generator reads the grammar and derives the tables (the LR automaton, itself a finite-state machine over stack symbols), or the grammar is hand-translated into recursive functions

way in: The parser's own stack (its left context)

  1. L1: The parse stack in memory: previously parsed phrases and their states
  2. L2: The topmost state number summarises all relevant left context

way out: Energy spent as heat by the machine that parses

  1. L1: Energy consumed in inference (0.32 kJ for 8K sentences with the full model)
  2. L3: Parsing computation on a CPU or GPU

way out: Events to registered handlers (push parsing)

  1. L1: The application's handler code runs
  2. L3: Relevant tokens detected during recognition

way out: Refusal to a peer: a fatal error instead of recovery

  1. L1: The peer meets the refusal (a terminated connection)
  2. L5: A fatal error is generated for a condition the specification does not allow

way out: Serialisation (unparsing): a value written back as bytes, paired with the parser

  1. L1: Formatted output: the complement of parsing (printf to scanf)
  2. L6: A parser and its serialiser verified as one pair over a non-malleable format

way out: Syntax error messages to the person

  1. L1: A message listing what could have come next
  2. L5: The error is found at a blank table cell

way out: The program's action: evaluate, generate code, render

  1. L1: An interpreter evaluates, a compiler generates code
  2. L7: The implications of the validated input are worked out

way out: The tree or internal representation handed to the consumer (compiler middle end, interpreter, application)

  1. L1: Held in memory for the next component
  2. L6: The internal representation is handed on

Sources (47) published science

Compiler (Wikipedia, rev 1373605841, 2026-09-06, via Wikimedia Enterprise)
Parsing (Wikipedia, via Wikimedia Enterprise)
LR parser (Wikipedia, via Wikimedia Enterprise) (behind its links)
Lexical analysis (Wikipedia, via Wikimedia Enterprise) (behind its links)
Thomson, M. and Schinazi, D. (2023) RFC 9413: Maintaining robust protocols. IETF/IAB. doi:10.17487/rfc9413 (sections: abstract, 4, 5.1) (behind its links)
Ambiguous grammar (Wikipedia, via Wikimedia Enterprise) (behind its links)
Möller, J., Weißberg, F., Pirch, L., Eisenhofer, T. and Rieck, K. (2024) Cross-language differential testing of JSON parsers. ACM AsiaCCS. doi:10.1145/3634737.3657003 (behind its links)
Diatchki, I. S. et al. (2024) Daedalus: safer document parsing. Proceedings of the ACM on Programming Languages (PLDI). doi:10.1145/3656410 (behind its links)
Diekmann, L. and Tratt, L. (2020) Don't panic! Better, fewer, syntax errors for LR parsers. ECOOP; arXiv:1804.07133 (behind its links)
van Rossum, G., Galindo, P. and Nikolaou, L. (2020) PEP 617: New PEG parser for CPython (sections: overview, rules that are not LL(1), migration plan, performance) (behind its links)
Knuth, D. E. (1965) On the translation of languages from left to right. Information and Control. doi:10.1016/S0019-9958(65)90426-2 (sections: introduction, II-V and conclusion, OpenAlex stored text) (behind its links)
Compiler-compiler (Wikipedia, via Wikimedia Enterprise) (behind its links)
Chen, D. and Manning, C. D. (2014) A fast and accurate dependency parser using neural networks. EMNLP. doi:10.3115/v1/d14-1082 (behind its links)
Langdale, G. and Lemire, D. (2019) Parsing gigabytes of JSON per second. VLDB Journal. doi:10.1007/s00778-019-00578-5; arXiv:1902.08318 (sections: abstract, introduction, stages) (behind its links)
Anderson, M. and Gómez-Rodríguez, C. (2020) Distilling neural networks for greener and faster dependency parsing. IWPT. doi:10.18653/v1/2020.iwpt-1.2 (sections: abstract, introduction, results table 4) (behind its links)
Barenghi, A., Mainardi, N. and Pelosi, G. (2018) Systematic parsing of X.509: eradicating security issues with a parse tree. Journal of Computer Security. doi:10.3233/jcs-171110 (sections: abstract, introduction, preliminaries) (behind its links)
Karlsson, F. (2007) Constraints on multiple center-embedding of clauses. Journal of Linguistics. doi:10.1017/s0022226707004616 (behind its links)
Parser combinator (Wikipedia, via Wikimedia Enterprise) (behind its links)
Sassaman, L., Patterson, M. L., Bratus, S., Locasto, M. E. and Shubina, A. (2011) Security applications of formal language theory. Dartmouth Computer Science Technical Report TR2011-709 (sections: introduction, 3.1, 4.1, Part II sections 9-10) (behind its links)
Robustness principle (Wikipedia, rev 1362213472, 2026-07-02, via Wikimedia Enterprise) (behind its links)
Bray, T., ed. (2017) RFC 8259: The JavaScript Object Notation (JSON) data interchange format. IETF (sections: 4 objects, 9 parsers) (behind its links)
Billion laughs attack (Wikipedia, via Wikimedia Enterprise) (behind its links)
Ramananandro, T., Ebner, G., Martínez, G. and Swamy, N. (2025) Secure parsing and serializing with separation logic applied to CBOR, CDDL, and COSE. ACM CCS. doi:10.1145/3719027.3765120 (sections: abstract, introduction, section 2 parser specifications) (behind its links)
History of compiler construction (Wikipedia, via Wikimedia Enterprise) (behind its links)
LL parser (Wikipedia, via Wikimedia Enterprise) (behind its links)
Earley parser (Wikipedia, via Wikimedia Enterprise) (behind its links)
Ford, B. (2002) Packrat parsing: simple, powerful, lazy, linear time. ICFP 2002; arXiv:cs/0603077 (sections: abstract, introduction, limitations) (behind its links)
Chomsky hierarchy (Wikipedia, via Wikimedia Enterprise) (behind its links)
Momot, F., Bratus, S., Hallberg, S. M. and Patterson, M. L. (2016) The seven turrets of Babel: a taxonomy of LangSec errors and how to expunge them. IEEE SecDev. doi:10.1109/secdev.2016.019 (behind its links)
Poll, E. (2018) LangSec revisited: input security flaws of the second kind. IEEE Security and Privacy Workshops. doi:10.1109/spw.2018.00051 (sections: introduction, II, III) (behind its links)
Hale, J. (2001) A probabilistic Earley parser as a psycholinguistic model. NAACL. doi:10.3115/1073336.1073357 (sections: abstract, introduction, Stolcke's algorithm) (behind its links)
Levy, R. (2008) Expectation-based syntactic comprehension. Cognition. doi:10.1016/j.cognition.2007.05.006 (behind its links)
Garden-path sentence (Wikipedia, via Wikimedia Enterprise) (behind its links)
Nelson MJ, El Karoui I, Giber K, et al., Dehaene S 2017. Neurophysiological dynamics of phrase-structure building during sentence processing. PNAS 114:E3669-E3678. doi:10.1073/pnas.1701590114 (PMC5422821) (behind its links)
Pallier, C., Devauchelle, A.-D. and Dehaene, S. (2011) Cortical representation of the constituent structure of sentences. PNAS. doi:10.1073/pnas.1018711108; PMC3038732 (behind its links)
Parsing expression grammar (Wikipedia, via Wikimedia Enterprise) (behind its links)
Ford, B. (2004) Parsing expression grammars: a recognition-based syntactic foundation. POPL. doi:10.1145/964001.964011 (sections: abstract, introduction, section on expressiveness, open problems; author's open PDF) (behind its links)
Abboud, A., Backurs, A. and Vassilevska Williams, V. (2015) If the current clique algorithms are optimal, so is Valiant's parser. FOCS; arXiv:1504.01431 (sections: abstract, introduction) (behind its links)
Dullien, T. (2017) Weird machines, exploitability, and provable unexploitability. IEEE Transactions on Emerging Topics in Computing. doi:10.1109/tetc.2017.2785299 (behind its links)
Manès VJM et al. The art, science, and engineering of fuzzing: a survey. arXiv:1812.00140 (IEEE TSE 2019) (behind its links)
Fuzzing (Wikipedia, via Wikimedia Enterprise snapshot) (behind its links)
Allman, E. (2011) The robustness principle reconsidered. Communications of the ACM. doi:10.1145/1978542.1978557 (sections: opening, standards and interoperability, security) (behind its links)
van Schijndel, M. and Linzen, T. (2021) Single-stage prediction models do not explain the magnitude of syntactic disambiguation difficulty. Cognitive Science. doi:10.1111/cogs.12988 (behind its links)
Deterministic pushdown automaton (Wikipedia, via Wikimedia Enterprise) (behind its links)
GLR parser (Wikipedia, via Wikimedia Enterprise) (behind its links)
Backus–Naur form (Wikipedia, via Wikimedia Enterprise) (behind its links)
Treebank (Wikipedia, via Wikimedia Enterprise) (behind its links)