3
votes

I have a grammar which has the following productions:

S-> if e then S else | while e do S| begin L end |s

L-> S; L|S

I am supposed to construct the operator precedence parsing table for the above. But I'm little confused about how to decide the precedence of various terminals here. Till now, we used to work on normal operators (like, +,I,(,id etc). But how to decide in this? I googled to find how to parse if-else grammar using operator precedence parser, but couldn't find any link explaining the same. I actually need to design the error correcting routines for parsing this grammar using operator precedence and SLR parser. Any help will be appreciated (a question from the book Compiler Design, Aho Ullman)!

Thanks in advance!!

1
The algorithms are all presented in Aho&Ullman, as well.rici
Can you please tell me the edition in which it's there? I didn't see the algorithm mentioned in the pdf below in the book I have.user3004790

1 Answers

1
votes

Answering my own question for people who want to learn, read this pdf. It presents a method to do the parsing as per operator precedence parsing for all general operators.