retagged by
2,130 views

1 Answer

3 votes
3 votes

Operator Grammar : It is a CFG which is used to generally define the mathematical operations with some restrictions on it like

                                 a) It shouldn't have any epsilon productions.

                                 b) In the right hand side of any production, there should not be any two variables side by side.

For example :      E -> E+T/T

                               T -> T*F/F

                               F -> id

                           Unambiguous and operator grammar..                     

Operator Precedence grammar : An operator precedence grammar is an operator grammar in which the parsing automaton can decide whether to shift or reduce based simply on a precedence relationship between the terminal closest to the top of the parsing stack and the look ahead token.

Operator precedence parser can parse some of the ambiguous grammars using the operator precedence table. Intuitively, ambiguity is resolved by using precedence of operator.

 For example : E -> E+E/E*E/id

                        Ambiguous and operator grammar..

 

Related questions

0 votes
0 votes
1 answer
1
jatin khachane 1 asked Jun 7, 2017
478 views
E → E + E | E * E | ( E ) | idWhat will be operator precedence for above grammar.Is precedence differs due to ambiguity
2 votes
2 votes
3 answers
2
radha gogia asked Mar 19, 2018
1,059 views
If I have the grammar :E->E*F | F+E |FF->id ,Now here although + and * are defined at the same level , with different associativity but this grammar produces 2 different ...
0 votes
0 votes
3 answers
3
2 votes
2 votes
0 answers
4
junaid ahmad asked Nov 16, 2017
872 views
Can anyone explain why operator precedence parsing cannot handle unary minus,and what are the approach to handle it.