In Sect. 2.16.3 it is mentioned that user-defined operator precedences in programming languages can be handled by parsing all operators with a single fixed precedence and associativity and then using...



In Sect. 2.16.3 it is mentioned that user-defined operator precedences in programming languages can be handled by parsing all operators with a


single fixed precedence and associativity and then using a separate pass to restructure the syntax tree to reflect the declared precedences. Below are two other methods


that have been used for this purpose:


a) An ambiguous grammar is used and conflicts exist in the SLR table. Whenever


a conflict arises during parsing, the parser consults a table of precedences to


resolve this conflict. The precedence table is extended whenever a precedence


declaration is read.


b) A terminal symbol is made for every possible precedence and associativity combination. A conflict-free parse table is made either by writing an unambiguous


grammar or by eliminating conflicts in the usual way. The lexical analyser uses


a table of precedences to assign the correct terminal symbol to each operator it


reads.


Compare all three methods. What are the advantages and disadvantages of each


method?



May 26, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here