when the input grammar is ambiguous. This is a feature in the common case that the grammar is intended to be unambiguous but is defective. A PEG parser generator will resolve unintended ambiguities earliest-match-first, which may be arbitrary and lead to surprising parses. The ordering of productions in a PEG grammar affects not only the resolution of ambiguity, but also the language matched. For example, consider the first PEG example in Ford's paper (example rewritten in pegjs.org/online notation, and labelled and ): : : Ford notes that The second alternative in the latter PEG rule will never succeed because the first choice is always taken if the input string ... begins with 'a'.. Specifically, (i.e., the language matched by ) includes the input "ab", but does not. Thus, adding a new option to a PEG grammar can remove strings from the language matched, e.g. is the addition of a rule to the single-production grammar , which contains a string not matched by . Furthermore, constructing a grammar to match from PEG grammars and is not always a trivial task. This is in stark contrast to CFG's, in which the addition of a new production cannot remove strings (though, it can introduce problems in the form of ambiguity), and a (potentially ambiguous) grammar for can be constructed S → start(G1) | start(G2) Bottom-up PEG parsing A pika parser uses dynamic programming to apply PEG rules bottom-up and right to left, which is the inverse of the normal recursive descent order of top-down, left to right. Parsing in reverse order solves the left recursion problem, allowing left-recursive rules to be used directly in the grammar without being rewritten into non-left-recursive form, and also conveys optimal error recovery capabilities upon the parser, which historically proved difficult to achieve for recursive descent parsers. Practical use Python reference implementation CPython introduced PEG parser in version 3.9 as an alternative to the LL(1) parser and uses just PEG from version 3.10. The jq programming language uses formalism closely related to PEG. See also Compiler Description Language (CDL) Formal grammar Regular expression Top-down parsing language Comparison of parser generators Parser combinator References External links Converting a string expression into a lambda expression using an expression parser The Packrat Parsing and Parsing Expression Grammars Page The constructed language Lojban has a fairly large PEG grammar allowing unambiguous parsing of Lojban text. An illustrative implementation of a PEG in