Question
For part (b) of Problem 2.27 (page 157, 3rd edition, Introduction to the theory of computation) Let G =(V, , R,STMT) be the following grammar.
For part (b) of Problem 2.27 (page 157, 3rd edition, Introduction to the theory of computation)
Let G =(V, , R,STMT) be the following grammar. STMTASSIGN|IF-THEN|IF-THEN-ELSE IF-THENif condition then STMT IF-THEN-ELSEif condition then STMT else STMT ASSIGNa:=1 ={if,condition,then,else,a:=1} V = {STMT,IF-THEN,IF-THEN-ELSE,ASSIGN} G is a natural-looking grammar for a fragment of a programming language, but G is ambiguous.
a. Show that G is ambiguous.
b. Give a new unambiguous grammar for the same language.
you are asked to give the pseudo codes of a deterministic finite memory stack program in C-style that parses an if-then/else statement such that an else clause is matched with the closest unmatched if clause.,
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