Recent Post

Operator Precedence Parsing

We define 3 precedence relation operations between pairs of terminals

(i)   ⋖
(ii)  ⋗
(iii)  ≐

Use:- They helps us in selection of handles.


a ⋖ b  : 'a' has lower precedence than 'b'.
a  ⋗ b :  'a' has higher precedence than 'b'.
a  ≐ b  : 'a' has equal precedence as 'b'.

How to Assign Relations ?
- Using Associativity and precedence
- For all terminal (including $) we design an operator precedence table.

Examples :-

Advantage and Disadvantage 


(i) Simplicity of the method
(ii) Error detecting capability of parser
(iii) Capability of parser to parse ambiguous grammars (Simple parse Tree)

Disadvantage :-

(i) Only a small class of grammar can be parsed using O.P. Technique

(ii) Difficult to handle operators which may have different roles (precedence) in different situations 

(iii) As the number of terminals increase the size of the precedence table also increases  n terminals

Operator Precedence Function:-

- Map terminals to integers.
- Select 2 functions f and g such that for symbols a and b

(1) f(a) < g(b)   when a ⋖ b
(2) f(a) = g(b)  when  a  ≐ b
(3) f(a) > g(b)  when  a  ⋗ b

No comments