Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a recursive descent parser in c++ that will also perform type checking (using static semantics) of a language for assignment statements with arithmetic expressions

Write a recursive descent parser in c++ that will also perform type checking (using static semantics) of a language for assignment statements with arithmetic expressions in which the variables may be of type int or float, mixed-type expressions are allowed with an automatic widening type conversion, but mixed-type assignments are not allowed. At the first occurrence of each identifier randomly generate its type and store it in a symbol table, so that you can look up the type of any further occurrence of this identifier. Allow the user to see the contents of the symbol table after each assignment statement. the grammar and attributes are the following and should accept sentences like:

Example sentences:

a = b + a * c;

b = (x + y) * b;

b = ---b;

x = -(a * b) + c;

x = (((a * b))) - + c;

BNF Grammar:

:= =

:=

| +

| -

:=

| *

| /

:= ()

|

|

:= a | b | c

Grammar Attributes and rules:

:= =

.type = .type

:=

.type = .type

:= +

Predicate: .type == .type

.type <- .type

:= -

Predicate: .type == .type

.type <- .type

:=

.type == .type

:= *

.type == .type

.type <- .type

:= /

.type == .type

.type <- .type

:= ()

.type = (.type)

:=

.type <- .type

:= a | b | c

.type lookup(.lexeme)

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

4. What sales experience have you had?

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago