Résumé
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 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. PEGs are well-suited to parsing computer languages (and artificial human languages such as Lojban), but not natural languages where the performance of PEG algorithms is comparable to general CFG algorithms such as the Earley algorithm. Formally, a parsing expression grammar consists of: A finite set N of nonterminal symbols. A finite set Σ of terminal symbols that is disjoint from N. A finite set P of parsing rules. An expression eS termed the starting expression. Each parsing rule in P has the form A ← e, where A is a nonterminal symbol and e is a parsing expression. A parsing expression is a hierarchical expression similar to a regular expression, which is constructed in the following fashion: An atomic parsing expression consists of: any terminal symbol, any nonterminal symbol, or the empty string ε. Given any existing parsing expressions e, e1, and e2, a new parsing expression can be constructed using the following operators: Sequence: e1 e2 Ordered choice: e1 / e2 Zero-or-more: e* One-or-more: e+ Optional: e? And-predicate: &e Not-predicate: !e Group: (e) Operator priorities are as follows, based on Table 1 in: The fundamental difference between context-free grammars and parsing expression grammars is that the PEG's choice operator is ordered.
À propos de ce résultat
Cette page est générée automatiquement et peut contenir des informations qui ne sont pas correctes, complètes, à jour ou pertinentes par rapport à votre recherche. Il en va de même pour toutes les autres pages de ce site. Veillez à vérifier les informations auprès des sources officielles de l'EPFL.
Cours associés (10)
CS-320: Computer language processing
We teach the fundamental aspects of analyzing and interpreting computer languages, including the techniques to build compilers. You will build a working compiler from an elegant functional language in
CS-438: Decentralized systems engineering
A decentralized system is one that works when no single party is in charge or fully trusted. This course teaches decentralized systems principles while guiding students through the engineering of thei
CS-234: Technologies for democratic society
This course will offer students a broad but hands-on introduction to technologies of human self-organization.
Afficher plus
Séances de cours associées (48)
Parsing avec les combinateurs
Explore l'analyse du texte dans les arbres à l'aide de combinateurs d'analyseurs dans Scala, couvrant le filtrage, la transformation, le séquençage, les alternatives, la récursion, la manipulation des espaces, le lexing, la nature monadique et la notation.
CYK Parsing Algorithme pour les grammaires générales
Introduit l'algorithme d'analyse CYK pour les grammaires sans contexte, expliquant sa gestion de l'ambiguïté et de l'importance dans l'analyse des grammaires générales.
Combinateurs d'analyseurs orientés objet
Couvre les combinateurs d'analyseurs orientés objet dans Scala pour la construction d'analyseurs, y compris l'analyse et les tests JSON.
Afficher plus
Publications associées (64)
Concepts associés (17)
Grammaire formelle
Une grammaire formelle est un formalisme permettant de définir une syntaxe et donc un langage formel, c'est-à-dire un ensemble de mots admissibles sur un alphabet donné. La notion de grammaire formelle est particulièrement utilisée en programmation logique, compilation (analyse syntaxique), en théorie de la calculabilité et dans le traitement des langues naturelles (tout particulièrement en ce qui concerne leur morphologie et leur syntaxe).
Top-down parsing
Top-down parsing in computer science is a parsing strategy where one first looks at the highest level of the parse tree and works down the parse tree by using the rewriting rules of a formal grammar. LL parsers are a type of parser that uses a top-down parsing strategy. Top-down parsing is a strategy of analyzing unknown data relationships by hypothesizing general parse tree structures and then considering whether the known fundamental structures are compatible with the hypothesis.
Analyse syntaxique ascendante
En informatique, l'analyse syntaxique révèle la structure grammaticale d'un texte. C'est la première étape dans l'étude de son sens. À l'inverse de l'analyse descendante, l'analyse ascendante reconnaît d'abord les plus petites unités du texte (les unités lexicales) analysé avant d'en reconnaître la structure grammaticale en le confrontant à des règles de syntaxe.
Afficher plus