Question: Language Design ( 2 0 points ) Pat is writing a compiler for equality tests on numbers, and wants to handle both integers and floating

Language Design (20 points)
Pat is writing a compiler for equality tests on numbers, and wants to handle both integers and floating point values. Pat's initial version looks like this:
This version works fine with Pat's shift-reduce parser generator, but Pat wants the lan-
guage to also allow comparisons between integers and floating point values (converting the integer to floating point before comparison), and adds one more production to the
grammar, changing the fltval rule to:
fltval rarr FLOAT | INT
a)(5 points) This augmented grammar is no longer SLR(1). What conflict(s) will there
be in the generation of the parsing table? Can they be resolved with precedence
declarations on operators? Why or why not?
b)(5 points) Pat's friend Chris suggests using a recursive descent parser instead. Will a
recursive descent parser (using the augmented grammar as written) generate the parse
tree that Pat wants in all cases? Justify your answer.
c)(5 points) Pat's other friend Francis thinks that the problem can be solved in the
lexical analysis. Is this possible? Justify your answer.
d)(5 points) Drew thinks the right answer is to change the language to use a different operator (e.g.^(=)) for floating-point comparisons. Explain how this resolves the
conflict(s) in the SLR(1) parsing table, or show what conflict(s) remain.
Language Design ( 2 0 points ) Pat is writing a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!