Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.,

your program should be designed as a parser, but for the purpose of the homework, it is not required to build the parse tree, or print the parse tree, but just have to report "Yes" or "No".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

which of the following is not an example of a business rule

Answered: 1 week ago

Question

define EFFECTIVE PARTICIPATION

Answered: 1 week ago