Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help! 2.17 Extend the grammar of Figure 2.25 to include if statements and while loops, along the lines suggested by the following examples: abs
Please help!
2.17 Extend the grammar of Figure 2.25 to include if statements and while loops, along the lines suggested by the following examples: abs := n if n 0 do read n sum != sum + n count := count - 1 od write sum Your grammar should support the six standard comparison operations in conditions, with arbitrary expressions as operands. It should also allow an arbitrary number of statements in the body of an if or while statement. -> 7. expr 8. expr 1. program stmt_list $$ 2. stmt_list - stmt_list stmt 3. stmt list simt 4. stmt - id :- expr 5. stmt - read id 6. stmt - write expr term expr add.op term 9. term factor 10. term term mult op factor 11. factor (expr ) 12. factor - id 13. factor - number 14. add.op 15. add op 16. mult_op 17. mult op Figure 2.25 LR(I) grammar for the calculator language. Productions have been numbered for reference in future figures Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started