Reputation: 13
What is the difference between operator grammar and operator precedence grammar? Explain with examples too. I am preparing for exam and I am not able to find it.
Upvotes: 0
Views: 864
Reputation: 607
Operator Grammar : A grammar that is generated to define the mathematical operators or identifier
is called operator grammar with some restrictions on grammar.
example: E->E+E/E*E/id
where as; An operator precedence grammar is a context-free grammar that has the property that no production has either an empty right-hand side (null productions) or two adjacent non-terminals in its right-hand side. example:
S->SAS/a
A->bSb/b
Although, we can convert it into an operator grammar:
S->SbSbS/SbS/a
A->bSb/b
hope it would help you..for further learning purpose you can check out this
https://www.geeksforgeeks.org/theory-computation-operator-grammar-precedence-parser/
Upvotes: 0
Reputation: 241971
In an operator grammar, no right-hand side is empty nor does it have two consecutive non-terminals. An operator precedence grammar is an operator grammar whose computed precedence relations are unambiguous.
Floyd's 1963 paper seems to be paywalled these days although you might have access at your University. But the essential properties are summarized in the first couple of pages of Stefano Crespi-Reghizzi's 1978 paper, Algebraic Properties of operator precedence languages.
Upvotes: 2