Extend the grammar of figure 2. 25 to include if statements and while loops, along the lines suggested by the following examples:
1. Program — stmt_list $$ 2. Stmt_list + stmt_list stmt 3. Stmt list → stmt 4. Stmt - id := expr 5. Stmt + read id 6. Stmt + write expr 7. Expr + term 8. Expr + 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 1 Figure 2. 25 LR(1) grammar for the calculator language. Productions have been numbered for reference in future figures.
abs := n
if n < 0 then abs := 0 - abs fi
sum := 0
read count
while count > 0 do
read n
sum := sum + n
count := count - 1
od
write sum
Q) 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