A simple precedence grammar is a
context-free formal grammar
A formal grammar is a set of Terminal and nonterminal symbols, symbols and the Production (computer science), production rules for rewriting some of them into every possible string of a formal language over an Alphabet (formal languages), alphabe ...
that can be parsed with a
simple precedence parser
In computer science, a simple precedence parser is a type of bottom-up parser for context-free grammars that can be used only by simple precedence grammars.
The implementation of the parser is quite similar to the generic bottom-up parser. A ...
. The concept was first created in 1964 by
Claude Pair, and was later rediscovered, from ideas due to
Robert Floyd, by
Niklaus Wirth
Niklaus Emil Wirth ( IPA: ) (15 February 1934 – 1 January 2024) was a Swiss computer scientist. He designed several programming languages, including Pascal, and pioneered several classic topics in software engineering. In 1984, he won the Tu ...
and
Helmut Weber who published a paper, entitled ''EULER: a generalization of ALGOL, and its formal definition'', published in 1966 in the
Communications of the ACM
''Communications of the ACM'' (''CACM'') is the monthly journal of the Association for Computing Machinery (ACM).
History
It was established in 1958, with Saul Rosen as its first managing editor. It is sent to all ACM members.
Articles are i ...
.
Formal definition
G = (''N'', Σ, ''P'', ''S'') is a simple precedence grammar if all the production rules in ''P'' comply with the following constraints:
* There are no
erasing rules (ε-productions)
* There are no
useless rules (unreachable symbols or unproductive rules)
* For each pair of symbols ''X'', ''Y'' (''X'', ''Y''
(''N'' ∪ Σ)) there is only one
Wirth–Weber precedence relation.
* G is
uniquely inversible
Examples
:
;precedence table:
Notes
References
* Alfred V. Aho, Jeffrey D. Ullman (1977). ''Principles of Compiler Design''. 1st Edition. Addison–Wesley.
* William A. Barrett, John D. Couch (1979). ''Compiler construction: Theory and Practice''. Science Research Associate.
* Jean-Paul Tremblay, P. G. Sorenson (1985). ''The Theory and Practice of Compiler Writing''. McGraw–Hill.
External links
"Simple Precedence Relations"at Clemson University
Formal languages
{{Compu-lang-stub