Comparison of parser generators: Difference between revisions

Content deleted Content added
m Autowikibrowser clean up, typo(s) fixed: ectly- → ectly (2)
Line 1:
{{More citations needed|date=July 2023}}
{{short description|None}}
{{More citations needed|date=July 2023}}
 
This is a list of notable [[lexer generator]]s and [[parser generator]]s for various language classes.
 
== Regular languages ==
[[Regular language]]s are a category of languages (sometimes termed [[Chomsky hierarchy|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;"
Line 55:
 
== Deterministic context-free languages ==
[[Context-free language]]s are a category of languages (sometimes termed [[Chomsky hierarchy|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 language]]s are a proper subset of the context-free languages which can be efficiently parsed by [[deterministic pushdown automata]].<!-- More parsing algorithms and output formats supported. See http://gdk.sourceforge.net/gdkref.pdf -->
Line 113:
| Lapg || [[LALR parser|LALR]](1) || ? || [[C (programming language)|C]], [[C++]], [[C Sharp (programming language)|C#]], [[Java (programming language)|Java]], [[JavaScript]] || {{D-A|Mixed}} || generated || {{Some|[[Java virtual machine]]}} || {{No}} || {{Free}}, [[GNU General Public License|GNU GPL]]
|-
| Lark || [[LALR parser|LALR]](1), [[Earley_parserEarley parser|Earley (SPPF)]] || [[Extended Backus–Naur form|EBNF]] || [[Python (programming language)|Python]], [[JavaScript]] || {{D-A|Mixed}} || generated || {{Yes|All}} || {{Yes}} || {{Free}}, [[MIT license|MIT]]
|-
| [[Lemon (parser generator)|Lemon]] || [[LALR parser|LALR]](1) ||BNF dialect<ref>{{Cite web |title=The Lemon Parser Generator |url=https://sqlite.org/src/doc/trunk/doc/lemon.html#syntax |access-date=2023-11-30 |website=sqlite.org}}</ref>|| [[C (programming language)|C]] || {{D-A|Mixed}} || external || {{Yes|All}} || {{No}} || {{Free}}, [[public ___domain]]