Simple precedence grammar
# Simple precedence grammar

A simple precedence grammar is a context-free formal grammar that can be parsed with a simple precedence parser. The concept was first created in 1964 by Claude Pair, and was later rediscovered, from ideas due to Robert Floyd, by Niklaus Wirth 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.

## 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 $\in$ (N ∪ Σ)) there is only one Wirth–Weber precedence relation.
* G is uniquely inversible

## Examples

    $S\to aSSb|c$

### precedence table

    ${\begin{array}{c|ccccc}&S&a&b&c&\$\\\hline S&{\dot {=}}&\lessdot &{\dot {=}}&\lessdot &\\a&{\dot {=}}&\lessdot &&\lessdot &\\b&&\gtrdot &&\gtrdot &\gtrdot \\c&&\gtrdot &\gtrdot &\gtrdot &\gtrdot \\\$&&\lessdot &&\lessdot &\end{array}}$
