Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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}

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.

Give a new unambiguous grammar for the same language.

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_2

Step: 3

blur-text-image_3

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

b. Does senior management trust the team?

Answered: 1 week ago

Question

RECOMMEND how to manage transfers and promotions more effectively.

Answered: 1 week ago

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago