Comparison of parser generators
{{short description|None}}
{{More citations needed|date=July 2023}}
This is a list of notable lexer generators and parser generators for various language classes.
Regular languages
Regular languages are a category of languages (sometimes termed Chomsky Type 3) which can be matched by a state machine (more specifically, by a deterministic finite automaton or a nondeterministic finite automaton) constructed from a regular expression. In particular, a regular language can match constructs like "A follows B", "Either A or B", "A, followed by zero or more instances of B", but cannot match constructs which require consistency between non-adjacent elements, such as "some instances of A followed by the same number of instances of B", and also cannot express the concept of recursive "nesting" ("every A is eventually followed by a matching B"). A classic example of a problem which a regular grammar cannot handle is the question of whether a given string contains correctly nested parentheses. (This is typically handled by a Chomsky Type 2 grammar, also termed a context-free grammar.)
class="wikitable sortable" style="text-align: center; font-size: 85%; width: auto;" | |||||
Name | Lexer algorithm | Output languages | Grammar, code | Development platform | License |
---|---|---|---|---|---|
Alex | DFA | Haskell | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, BSD |
AnnoFlex | DFA | Java | {{D-A|Mixed}} | {{Some|Java virtual machine}} | {{Free}}, BSD |
Astir | DFA table driven, with branching | C++ | {{D-P|Only grammar (actioned)}} | {{Yes|All}} | {{Free}}, MIT |
AustenX | DFA | Java | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, BSD |
C# Flex | DFA | C# | {{D-A|Mixed}} | {{Some|.NET CLR}} | {{Free}}, GNU GPL |
C# Lex | DFA | C# | {{D-A|Mixed}} | {{Some|.NET CLR}} | ? |
CookCC | DFA | Java | {{D-A|Mixed}} | {{Some|Java virtual machine}} | {{Free}}, Apache 2.0 |
DFA | DFA compressed matrix | C, C++ | {{D-P|Separate}} | Windows, Visual Studio | BSD |
Dolphin | DFA | C++ | {{D-P|Separate}} | {{Yes|All}} | {{Proprietary}} |
Flex | DFA table driven | C, C++ | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, BSD |
gelex | DFA | Eiffel | {{D-A|Mixed}} | {{Some|Eiffel}} | {{Free}}, MIT |
golex | DFA | Go | {{D-A|Mixed}} | {{Some|Go}} | {{Free}}, BSD-style |
gplex | DFA | C# | {{D-A|Mixed}} | {{Some|.NET CLR}} | {{Free}}, BSD-like |
JFlex | DFA | Java | {{D-A|Mixed}} | {{Some|Java virtual machine}} | {{Free}}, BSD |
JLex | DFA | Java | {{D-A|Mixed}} | {{Some|Java virtual machine}} | {{Free}}, BSD-like |
lex | DFA | C | {{D-A|Mixed}} | {{Some|POSIX}} | {{Partial}}, proprietary, CDDL |
lexertl | DFA | C++ | ? | {{Yes|All}} | {{Free}}, GNU LGPL |
Quex | DFA direct code | C, C++ | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, GNU LGPL |
Ragel | DFA | Go, C, C++, Java, assembly | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, GNU GPL, MIT{{Cite web|url=http://www.colm.net/open-source/ragel/|title = Ragel State Machine Compiler}}http://www.colm.net/open-source/ragel/ {{verify source |date=November 2020 |reason=This ref was deleted Special:Diff/987467678 by a bug in VisualEditor and later restored by a bot from the original cite located at Special:Permalink/987467450 cite #1 - verify the cite is accurate and delete this template. User:GreenC bot/Job 18}} |
RE/flex | DFA direct code, DFA table driven, and NFA regex libraries | C++ | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, BSD |
re2c | DFA direct code | C, C++, Go, Rust | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, public domain |
Deterministic context-free languages
Context-free languages are a category of languages (sometimes termed Chomsky Type 2) which can be matched by a sequence of replacement rules, each of which essentially maps each non-terminal element to a sequence of terminal elements and/or other nonterminal elements. Grammars of this type can match anything that can be matched by a regular grammar, and furthermore, can handle the concept of recursive "nesting" ("every A is eventually followed by a matching B"), such as the question of whether a given string contains correctly nested parentheses. The rules of Context-free grammars are purely local, however, and therefore cannot handle questions that require non-local analysis such as "Does a declaration exist for every variable that is used in a function?". To do so technically would require a more sophisticated grammar, like a Chomsky Type 1 grammar, also termed a context-sensitive grammar. However, parser generators for context-free grammars often support the ability for user-written code to introduce limited amounts of context-sensitivity. (For example, upon encountering a variable declaration, user-written code could save the name and type of the variable into an external data structure, so that these could be checked against later variable references detected by the parser.)
The deterministic context-free languages are a proper subset of the context-free languages which can be efficiently parsed by deterministic pushdown automata.
Parsing expression grammars, deterministic Boolean grammars
This table compares parser generators with parsing expression grammars, deterministic Boolean grammars.
class="wikitable sortable" style="text-align: center; font-size: 85%; width: auto;" | |||||
Name | Parsing algorithm | Output languages | Grammar, code | Development platform | License |
---|---|---|---|---|---|
AustenX | Packrat (modified) | Java | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, BSD |
Aurochs | Packrat | C, OCaml, Java | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, GNU GPL |
BNFlite | Recursive descent | C++ | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Canopy | Packrat | Java, JavaScript, Python, Ruby | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, GNU GPL |
CL-peg | Packrat | Common Lisp | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Drat! | Packrat | D | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, GNU GPL |
Frisby | Packrat | Haskell | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, BSD |
grammar::peg | Packrat | Tcl | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, BSD |
Grako | Packrat + Cut + Left Recursion | Python, C++ (beta) | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, BSD |
IronMeta | Packrat | C# | {{D-A|Mixed}} | {{Some|Windows}} | {{Free}}, BSD |
Laja | 2-phase scannerless top-down backtracking + runtime support | Java | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, GNU GPL |
lars::Parser | Packrat (supporting left-recursion and grammar ambiguity) | C++ | Identical | {{Yes|All}} | {{Free}}, BSD |
LPeg | Parsing machine | Lua | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
lug | Parsing machine | C++17 | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Mouse | Recursive descent (modified, limited memoization and left-recursion) | Java | {{D-P|Separate}} | {{Some|Java virtual machine}} | {{Free}}, Apache 2.0 |
Narwhal | Packrat | C | {{D-A|Mixed}} | {{Some|POSIX, Windows}} | {{Free}}, BSD |
Nearley | Earley | JavaScript | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Nemerle.Peg | Recursive descent + Pratt | Nemerle | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, BSD |
neotoma | Packrat | Erlang | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, MIT |
nez{{Citation |title=Nez: practical open grammar language |date=2015-11-26 |arxiv=1511.08307 |last1=Kuramitsu |first1=Kimio }} | Parsing machine | Java, C | {{D-P|Separate}} | {{Some|Java virtual machine}} | {{Free}}, BSD |
NPEG | Recursive descent | C# | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
OMeta | Packrat (modified, partial memoization) | JavaScript, Squeak, Python | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
PackCC | Packrat (modified, left-recursion support) | C | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Packrat | Packrat | Scheme | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Pappy | Packrat | Haskell | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, BSD |
parboiled | Recursive descent | Java, Scala | {{D-A|Mixed}} | {{Some|Java virtual machine}} | {{Free}}, Apache 2.0 |
Lambda PEG | Recursive descent | Java | {{D-A|Mixed}} | {{Some|Java virtual machine}} | {{Free}}, Apache 2.0 |
parsepp | Recursive descent | C++ | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, public domain |
Parsnip | Packrat | C++ | {{D-A|Mixed}} | {{Some|Windows}} | {{Free}}, GNU GPL |
Patterns | Parsing machine | Swift | Identical | {{Yes|All}} | {{Free}}, MIT |
peg | Recursive descent | C | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
PEG.js | Packrat (partial memoization) | JavaScript | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
PeggyMaintained fork of PEG.js | Packrat (partial memoization) | JavaScript | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Pegasus | Recursive descent, Packrat (selectively) | C# | {{D-A|Mixed}} | {{Some|Windows}} | {{Free}}, MIT |
pegc | Recursive descent | C | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, public domain |
pest | Recursive descent | Rust | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, MIT, Apache 2.0 |
PetitParser | Packrat | Smalltalk, Java, Dart | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
PEGTL{{Citation |title=taocpp/PEGTL |date=2024-03-14 |url=https://github.com/taocpp/PEGTL |access-date=2024-03-16 |publisher=The Art of C++}} | Recursive descent | C++11, C++17 | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, Boost |
Parser Grammar Engine (PGE) | Hybrid recursive descent / operator precedence{{cite web |url=https://parrot.github.com/html/docs/book/pct/ch04_pge.pod.html |title=Parrot: Grammar Engine |year=2011 |publisher=The Parrot Foundation |quote=PGE rules provide the full power of recursive descent parsing and operator precedence parsing.}} | Parrot bytecode | {{D-A|Mixed}} | {{Some|Parrot virtual machine}} | {{Free}}, Artistic 2.0 |
PyPy rlib | Packrat | Python | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Rats! | Packrat | Java | {{D-A|Mixed}} | {{Some|Java virtual machine}} | {{Free}}, GNU LGPL |
Spirit2 | Recursive descent | C++ | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, Boost |
Treetop | Recursive descent | Ruby | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT |
Yard | Recursive descent | C++ | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, MIT or public domain |
Waxeye | Parsing machine | C, Java, JavaScript, Python, Racket, Ruby | {{D-P|Separate}} | {{Yes|All}} | {{Free}}, MIT |
PHP PEG | PEG Parser? | PHP | {{D-A|Mixed}} | {{Yes|All}} | {{Free}}, BSD |
General context-free, conjunctive, or Boolean languages
This table compares parser generator languages with a general context-free grammar, a conjunctive grammar, or a Boolean grammar.
class="wikitable sortable" style="text-align: center; font-size: 85%; width: auto;" | ||||||||
Name | Parsing algorithm | Input grammar notation || Output languages | Grammar, code | Lexer | Development platform | IDE | License | |
---|---|---|---|---|---|---|---|---|
ACCENT | Earley | Yacc variant | C | {{D-A|Mixed}} | external | {{Yes|All}} | {{No}} | {{Free}}, GNU GPL |
APaGeD | GLR, LALR(1), LL(k) | ? | D | {{D-A|Mixed}} | generated | {{Yes|All}} | {{No}} | {{Free}}, Artistic |
Bison | LALR(1), LR(1), IELR(1), GLR | Yacc | C, C++, D,{{cite web |title=Decl Summary (Bison 3.8.1) |url=https://www.gnu.org/software/bison/manual/html_node/Decl-Summary.html |website=www.gnu.org}} Java, XML | {{D-A|Mixed}}, except XML | external | {{Yes|All}} | {{No}} | {{Free}}, GNU GPL |
DMS Software Reengineering Toolkit | GLR | ? | Parlanse | {{D-A|Mixed}} | generated | {{Some|Windows}} | {{No}} | {{Proprietary}} |
DParser | Scannerless GLR | ? | C | {{D-A|Mixed}} | scannerless | {{Some|POSIX}} | {{No}} | {{Free}}, BSD |
Dypgen | Runtime-extensible GLR | ? | OCaml | {{D-A|Mixed}} | generated | {{Yes|All}} | {{No}} | {{Free}}, CeCILL-B |
E3 | Earley | ? | OCaml | {{D-A|Mixed}} | external, or scannerless | {{Yes|All}} | {{No}} | ? |
Elkhound | GLR | ? | C++, OCaml | {{D-A|Mixed}} | external | {{Yes|All}} | {{No}} | {{Free}}, BSD |
GDK | LALR(1), GLR | ? | C, Lex, Haskell, HTML, Java, Object Pascal, Yacc | {{D-A|Mixed}} | generated | {{Some|POSIX}} | {{No}} | {{Free}}, MIT |
Happy | LALR, GLR | ? | Haskell | {{D-A|Mixed}} | external | {{Yes|All}} | {{No}} | {{Free}}, BSD |
Hime Parser Generator | GLR | ? | C#, Java, Rust | {{D-P|Separate}} | generated | {{Some|.NET framework, Java virtual machine}} | {{No}} | {{Free}}, GNU LGPL |
IronText Library | LALR(1), GLR | C# | C# | {{D-A|Mixed}} | generated or external | {{Some|.NET framework}} | {{No}} | {{Free}}, Apache 2.0 |
Jison | LALR(1), LR(0), SLR(1) | Yacc | JavaScript, C#, PHP | {{D-A|Mixed}} | generated | {{Yes|All}} | {{No}} | {{Free}}, MIT |
Syntax | LALR(1), LR(0), SLR(1) CLR(1) LL(1) | JSON/Yacc | JavaScript, Python, PHP, Ruby, C++, C#, Rust, Java | {{D-A|Mixed}} | generated | {{Yes|All}} | {{No}} | {{Free}}, MIT |
Laja | Scannerless, two phase | Laja | Java | {{D-P|Separate}} | scannerless | {{Yes|All}} | {{No}} | {{Free}}, GNU GPL |
ModelCC | Earley | Annotated class model | Java | Generated | generated | {{Yes|All}} | {{No}} | {{Free}}, BSD |
P3 | Earley–combinators | BNF-like | OCaml | {{D-A|Mixed}} | external, or scannerless | {{Yes|All}} | {{No}} | ? |
P4 | Earley–combinators, infinitary CFGs | BNF-like | OCaml | {{D-A|Mixed}} | external, or scannerless | {{Yes|All}} | {{No}} | ? |
Scannerless Boolean Parser | Scannerless GLR (Boolean grammars) | ? | Haskell, Java | {{D-P|Separate}} | scannerless | {{Some|Java virtual machine}} | {{No}} | {{Free}}, BSD |
SDF/SGLR | Scannerless GLR | SDF | C, Java | {{D-P|Separate}} | scannerless | {{Yes|All}} | {{Yes}} | {{Free}}, BSD |
SmaCC | GLR(1), LALR(1), LR(1) | ? | Smalltalk | {{D-A|Mixed}} | internal | {{Yes|All}} | {{Yes}} | {{Free}}, MIT |
SPARK | Earley | ? | Python | {{D-A|Mixed}} | external | {{Yes|All}} | {{No}} | {{Free}}, MIT |
Tom | GLR | ? | C | Generated | none | {{Yes|All}} | {{No}} | {{Free}}, "No licensing or copyright restrictions" |
UltraGram | LALR, LR, GLR | ? | C++, C#, Java, Visual Basic .NET | {{D-P|Separate}} | generated | {{Some|Windows}} | {{Yes}} | {{Proprietary}} |
Wormhole | Pruning, LR, GLR, Scannerless GLR | ? | C, Python | {{D-A|Mixed}} | scannerless | {{Some|Windows}} | {{No}} | {{Free}}, MIT |
Whale Calf | General tabular, SLL(k), Linear normal form (conjunctive grammars), LR, Binary normal form (Boolean grammars) | ? | C++ | {{D-P|Separate}} | external | {{Yes|All}} | {{No}} | {{Proprietary}} |
yaep | Earley | Yacc-like | C | {{D-A|Mixed}} | external | {{Yes|All}} | {{No}} | {{Free}}, GNU LGPL |
Context-sensitive grammars
This table compares parser generators with context-sensitive grammars.
class="wikitable sortable"
! Name !! Parsing algorithm !! Input grammar notation !! Boolean grammar abilities !! Development platform !! License | |||||
[http://sourceforge.net/p/bnf2xml/ bnf2xml] | Recursive descent (is a text filter output is xml) | simple BNF{{clarify|Only context-free grammars can be denoted in BNF.|date=January 2018}} grammar (input matching), output is xml | ? | Beta, and not a full EBNF parser | {{Free}}, GNU GPL |
See also
Notes
References
{{Reflist}}
External links
- [http://catalog.compilertools.net/lexparse.html The Catalog of Compiler Construction Tools]
- [http://java-source.net/open-source/parser-generators Open Source Parser Generators in Java]
{{Parsers}}
{{DEFAULTSORT:Comparison of parser generators}}