Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6.1 Please complete the following sentence level BNF grammar definition for expressions like: int myresult = 5 + 1 2 or int VarA = 2.5

6.1 Please complete the following sentence level BNF grammar definition for expressions like:

int myresult = 5 + 1 2 or int VarA = 2.5 + 1.11 + 1 - 3

For simplicity, we assume some of the token level BNF grammar rules are already defined (identifier and literals are defined and can be directly used). For example, in derivation and tree building, you could directly replace literal with 66 in one step. Also, we do not consider other variable definition expression formats, nor do we consider math operators other than + and -.

Sentence level BNF grammar only here. Please fill in the 4 blanks to make the grammar complete.

int_def_exp -> keyword identifier ___ ___

keyword -> int

equal_op -> =

math_exp -> literal + math_exp | ___ | ___

6.2 Please use the defined BNF grammar and write down the left-most derivation for expression:

int myres = 5.5 + 1 2.1

Left-most derivation:

___

6.3 Please draw the parser tree from your derivation for expression int myres = 5.5 + 1 2.1

Your parser tree here:

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

5. Discuss the role of the Web in career management.

Answered: 1 week ago

Question

4. Design a career management system.

Answered: 1 week ago

Question

4. Evaluation is ongoing and used to improve the system.

Answered: 1 week ago