Comparison of parser generators
Template:Short description Template:More citations needed
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.)
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.
| Name | Parsing algorithm | Output languages | Grammar, code | Development platform | License |
|---|---|---|---|---|---|
| AustenX | Packrat (modified) | Java | Template:D-P | All | Free, BSD |
| Aurochs | Packrat | C, OCaml, Java | Template:D-A | All | Free, GNU GPL |
| BNFlite | Recursive descent | C++ | Template:D-A | All | Free, MIT |
| Canopy | Packrat | Java, JavaScript, Python, Ruby | Template:D-P | All | Free, GNU GPL |
| CL-peg | Packrat | Common Lisp | Template:D-A | All | Free, MIT |
| Drat! | Packrat | D | Template:D-A | All | Free, GNU GPL |
| Frisby | Packrat | Haskell | Template:D-A | All | Free, BSD |
| grammar::peg | Packrat | Tcl | Template:D-A | All | Free, BSD |
| Grako | Packrat + Cut + Left Recursion | Python, C++ (beta) | Template:D-P | All | Free, BSD |
| IronMeta | Packrat | C# | Template:D-A | Windows | Free, BSD |
| Laja | 2-phase scannerless top-down backtracking + runtime support | Java | Template:D-P | All | Free, GNU GPL |
| lars::Parser | Packrat (supporting left-recursion and grammar ambiguity) | C++ | Identical | All | Free, BSD |
| LPeg | Parsing machine | Lua | Template:D-A | All | Free, MIT |
| lug | Parsing machine | C++17 | Template:D-A | All | Free, MIT |
| Mouse | Recursive descent (modified, limited memoization and left-recursion) | Java | Template:D-P | Java virtual machine | Free, Apache 2.0 |
| Narwhal | Packrat | C | Template:D-A | POSIX, Windows | Free, BSD |
| Nearley | Earley | JavaScript | Template:D-A | All | Free, MIT |
| Nemerle.Peg | Recursive descent + Pratt | Nemerle | Template:D-P | All | Free, BSD |
| neotoma | Packrat | Erlang | Template:D-P | All | Free, MIT |
| nez[35] | Parsing machine | Java, C | Template:D-P | Java virtual machine | Free, BSD |
| NPEG | Recursive descent | C# | Template:D-A | All | Free, MIT |
| OMeta | Packrat (modified, partial memoization) | JavaScript, Squeak, Python | Template:D-A | All | Free, MIT |
| PackCC | Packrat (modified, left-recursion support) | C | Template:D-A | All | Free, MIT |
| Packrat | Packrat | Scheme | Template:D-A | All | Free, MIT |
| Pappy | Packrat | Haskell | Template:D-A | All | Free, BSD |
| parboiled | Recursive descent | Java, Scala | Template:D-A | Java virtual machine | Free, Apache 2.0 |
| Lambda PEG | Recursive descent | Java | Template:D-A | Java virtual machine | Free, Apache 2.0 |
| parsepp | Recursive descent | C++ | Template:D-A | All | Free, public domain |
| Parsnip | Packrat | C++ | Template:D-A | Windows | Free, GNU GPL |
| Patterns | Parsing machine | Swift | Identical | All | Free, MIT |
| peg | Recursive descent | C | Template:D-A | All | Free, MIT |
| PEG.js | Packrat (partial memoization) | JavaScript | Template:D-A | All | Free, MIT |
| Peggy[36] | Packrat (partial memoization) | JavaScript | Template:D-A | All | Free, MIT |
| Pegasus | Recursive descent, Packrat (selectively) | C# | Template:D-A | Windows | Free, MIT |
| pegc | Recursive descent | C | Template:D-A | All | Free, public domain |
| pest | Recursive descent | Rust | Template:D-P | All | Free, MIT, Apache 2.0 |
| PetitParser | Packrat | Smalltalk, Java, Dart | Template:D-A | All | Free, MIT |
| PEGTL[37] | Recursive descent | C++11, C++17 | Template:D-A | All | Free, Boost |
| Parser Grammar Engine (PGE) | Hybrid recursive descent / operator precedence[38] | Parrot bytecode | Template:D-A | Parrot virtual machine | Free, Artistic 2.0 |
| PyPy rlib | Packrat | Python | Template:D-A | All | Free, MIT |
| Rats! | Packrat | Java | Template:D-A | Java virtual machine | Free, GNU LGPL |
| Spirit2 | Recursive descent | C++ | Template:D-A | All | Free, Boost |
| Treetop | Recursive descent | Ruby | Template:D-A | All | Free, MIT |
| Yard | Recursive descent | C++ | Template:D-A | All | Free, MIT or public domain |
| Waxeye | Parsing machine | C, Java, JavaScript, Python, Racket, Ruby | Template:D-P | All | Free, MIT |
| PHP PEG | PEG Parser? | PHP | Template:D-A | 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.
| Name | Parsing algorithm | Input grammar notation | Output languages | Grammar, code | Lexer | Development platform | IDE | License |
|---|---|---|---|---|---|---|---|---|
| ACCENT | Earley | Yacc variant | C | Template:D-A | external | All | No | Free, GNU GPL |
| APaGeD | GLR, LALR(1), LL(k) | ? | D | Template:D-A | generated | All | No | Free, Artistic |
| Bison | LALR(1), LR(1), IELR(1), GLR | Yacc | C, C++, D,[39] Java, XML | Template:D-A, except XML | external | All | No | Free, GNU GPL |
| DMS Software Reengineering Toolkit | GLR | ? | Parlanse | Template:D-A | generated | Windows | No | Template:Proprietary |
| DParser | Scannerless GLR | ? | C | Template:D-A | scannerless | POSIX | No | Free, BSD |
| Dypgen | Runtime-extensible GLR | ? | OCaml | Template:D-A | generated | All | No | Free, CeCILL-B |
| E3 | Earley | ? | OCaml | Template:D-A | external, or scannerless | All | No | ? |
| Elkhound | GLR | ? | C++, OCaml | Template:D-A | external | All | No | Free, BSD |
| GDK | LALR(1), GLR | ? | C, Lex, Haskell, HTML, Java, Object Pascal, Yacc | Template:D-A | generated | POSIX | No | Free, MIT |
| Happy | LALR, GLR | ? | Haskell | Template:D-A | external | All | No | Free, BSD |
| Hime Parser Generator | GLR | ? | C#, Java, Rust | Template:D-P | generated | .NET framework, Java virtual machine | No | Free, GNU LGPL |
| IronText Library | LALR(1), GLR | C# | C# | Template:D-A | generated or external | .NET framework | No | Free, Apache 2.0 |
| Jison | LALR(1), LR(0), SLR(1) | Yacc | JavaScript, C#, PHP | Template:D-A | generated | 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 | Template:D-A | generated | All | No | Free, MIT |
| Laja | Scannerless, two phase | Laja | Java | Template:D-P | scannerless | All | No | Free, GNU GPL |
| ModelCC | Earley | Annotated class model | Java | Generated | generated | All | No | Free, BSD |
| P3 | Earley–combinators | BNF-like | OCaml | Template:D-A | external, or scannerless | All | No | ? |
| P4 | Earley–combinators, infinitary CFGs | BNF-like | OCaml | Template:D-A | external, or scannerless | All | No | ? |
| Scannerless Boolean Parser | Scannerless GLR (Boolean grammars) | ? | Haskell, Java | Template:D-P | scannerless | Java virtual machine | No | Free, BSD |
| SDF/SGLR | Scannerless GLR | SDF | C, Java | Template:D-P | scannerless | All | Yes | Free, BSD |
| SmaCC | GLR(1), LALR(1), LR(1) | ? | Smalltalk | Template:D-A | internal | All | Yes | Free, MIT |
| SPARK | Earley | ? | Python | Template:D-A | external | All | No | Free, MIT |
| Tom | GLR | ? | C | Generated | none | All | No | Free, "No licensing or copyright restrictions" |
| UltraGram | LALR, LR, GLR | ? | C++, C#, Java, Visual Basic .NET | Template:D-P | generated | Windows | Yes | Template:Proprietary |
| Wormhole | Pruning, LR, GLR, Scannerless GLR | ? | C, Python | Template:D-A | scannerless | Windows | No | Free, MIT |
| Whale Calf | General tabular, SLL(k), Linear normal form (conjunctive grammars), LR, Binary normal form (Boolean grammars) | ? | C++ | Template:D-P | external | All | No | Template:Proprietary |
| yaep | Earley | Yacc-like | C | Template:D-A | external | All | No | Free, GNU LGPL |
Context-sensitive grammars
This table compares parser generators with context-sensitive grammars.
| Name | Parsing algorithm | Input grammar notation | Boolean grammar abilities | Development platform | License |
|---|---|---|---|---|---|
| bnf2xml | Recursive descent (is a text filter output is xml) | simple BNFTemplate:Clarify grammar (input matching), output is xml | ? | Beta, and not a full EBNF parser | Free, GNU GPL |
See also
Notes
References
External links
- ↑ Script error: No such module "citation/CS1".
- ↑ http://www.colm.net/open-source/ragel/ Script error: No such module "Unsubst".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ a b Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ http://www.slkpg.com/license.txt Template:Bare URL plain text
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Maintained fork of PEG.js
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".