In computer science, a parsing expression grammar (PEG) is a type of analytic formal grammar, i.e. it describes a formal language in terms of a set of rules for recognizing strings in the language. The formalism was introduced by Bryan Ford in 2004[1] and is closely related to the family of top-down parsing languages introduced in the early 1970s.
Syntactically, PEGs also look similar to context-free grammars (CFGs), but they have a different interpretation: the choice operator selects the first match in PEG, while it is ambiguous in CFG. This is closer to how string recognition tends to be done in practice, e.g. by a recursive descent parser.
Unlike CFGs, PEGs cannot be ambiguous; a string has exactly one valid parse tree or none. It is conjectured that there exist context-free languages that cannot be recognized by a PEG, but this is not yet proven.[1] PEGs are well-suited to parsing computer languages (and artificial human languages such as Lojban) where multiple interpretation alternatives can be disambiguated locally, but are less likely to be useful for parsing natural languages where disambiguation may have to be global.[2]
^ ab
Ford, Bryan (January 2004). "Parsing Expression Grammars: A Recognition Based Syntactic Foundation" (PDF). Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM. pp. 111–122. doi:10.1145/964001.964011. ISBN 1-58113-729-X.
In computer science, a parsingexpressiongrammar (PEG) is a type of analytic formal grammar, i.e. it describes a formal language in terms of a set of...
languages or data structures, conforming to the rules of a formal grammar. The term parsing comes from Latin pars (orationis), meaning part (of speech). The...
combinatory parsing, a method of factoring recursive descent parser designs Parsingexpressiongrammar – another form representing recursive descent grammar Recursive...
examining the positional relationships between pairs of words. Parsingexpressiongrammars (PEGs): a more recent generalization of TDPL designed around...
it takes parsingexpressiongrammars (PEGs) as input rather than LL grammars. In 1970, Alexander Birman laid the groundwork for packrat parsing by introducing...
the Parrot virtual machine. PGE uses these rules to convert a parsingexpressiongrammar into Parrot bytecode. It is therefore compiling rules into a program...
LL parser is called an LL(k) parser if it uses k tokens of lookahead when parsing a sentence. A grammar is called an LL(k) grammar if an LL(k) parser can...
A parse tree or parsing tree or derivation tree or concrete syntax tree is an ordered, rooted tree that represents the syntactic structure of a string...
larger framework called rules, which provide the capabilities of a parsingexpressiongrammar, as well as acting as a closure with respect to their lexical...
parser). LR parsers can handle a larger range of languages and grammars than precedence parsers or top-down LL parsing. This is because the LR parser...
non-ambiguous context-free grammar. Alternatively, one may rely on a non-context-free grammar or a parsingexpressiongrammar. The problem can also be solved...
the definition of parsingexpressiongrammars. The result is a mini-language called Raku rules, which are used to define Raku grammar as well as provide...
Research Institute. The language is based on parsingexpressiongrammar (PEGs) rather than context-free grammar with the intent of providing "a natural and...
nullable grammars. The algorithm, named after its inventor, Jay Earley, is a chart parser that uses dynamic programming; it is mainly used for parsing in computational...
context-sensitive parsing rules, so the overall phrase grammar is unambiguous.[citation needed] Some parsing algorithms (such as Earley or GLR parsers) can generate...
source file. The grammar of an output parser can be described in a PEG (ParsingExpressionGrammar). The PEG is a top-down parsing language, and is similar...
evaluation of arithmetic expressions, attribute grammar may be used to describe the entire task to be performed besides parsing in straightforward way;...
an article called "Parsing as Deduction", describing things such as how the Earley Deduction proof procedure is used for parsing. Pereira also collaborated...
Ford demonstrated that memoization could guarantee that parsingexpressiongrammars could parse in linear time even those languages that resulted in worst-case...
dialect belongs to the family of grammars represented by the top-down parsing language or the parsingexpressiongrammar (PEG). The main similarity is the...