Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.1 Using the grammar G(integer) from page 26, (a) develop a leftmost derivation for the integer 4520. (b) How many steps are required for this

2.1 Using the grammar G(integer) from page 26, (a) develop a leftmost derivation for the integer 4520. (b) How many steps are required for this derivation? (c) In general, how many steps are required to derive an integer with an arbitrary number, say d, of Digits'? 2.2 Using the grammar G(integer), develop a rightmost derivation for the integer 4520. 2.3 Develop a leftmost derivation for the Identifier value a2i, using the BNF syntax given in Figure 2.7. 2.4 Develop a rightmost derivation for the Identifier value a2i, using the BNF syntax given in Figure 2.7. 2.5 Using the grammar of Figure 2.7, draw parse trees for each of the following: (a) x = x+a-1; (b) a = b*c/d; (c) i = i + j * k - 3; 2.6 Using the following grammar: Expr -> Expr + Term | Expr * Term | Term Term -> 0 | ... | 9 | (Expr) draw a parse tree for each of the following: (a) 5+4*3 (b) 5*4+3 2.7 Using the following grammar: Expr -> Term + Expr | Term x Expr | Term Term -> 0 | ... | 9 | (Expr) draw a parse tree for each of the following: (a) 5 + 4 * 3 (b) 5 * 4 + 3 2.8 Using the following grammar: Expr -> Expr + Term | Term Term -> Term * Factor | Factor i Factor -> 0 | ... | 9 I (Expr) draw a parse tree for each of the following: (a) 5+4*3 (b) 5*4+3 2.9 Using the following grammar: Expr -> Expr + Expr | Expr * Expr 0 | ... | 9 | (Expr) draw a parse tree for each of the following: (a) 5+4*3 (b) 5*4+3 2.10 Using the following grmmnar: Expr -> + Expr Expr | * Expr Expr| 0 | ... | 9 draw a parse tree for each of the following: (a) + 5 * 4 3 (b) + * 5 4 3 2.12 Show how the Java subgrammar for IfThenStatement eliminates any ambiguity in the if statement. That is, sketch the parse tree using the Java BNF rules, and then argue that no other parse trees can be found using these rules. 2.14 Give a grammar and an example if statement for each of the following languages: (a) Perl, (b) Python, (c) Ada. 

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

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

Provide examples of Dimensional Tables.

Answered: 1 week ago