# organ programming language (Assignment 2)

Anonymous

Question description

1 Using the grammar Ginteger• develop a leftmost derivation for the integer 4520. How many .steps are required for this derivation? In general, how many steps are required to derive an integer with an arbitrary number, say d, of Digits'? 2 Using the grammar Gimeger, develop a rightmost derivation for the integer 4520. 3 Develop a leftmost derivation for the Jdenl{fier value a2i, using the BNF syntax given in Figure 2.7. 4 Develop a rightmost derivation for the Jdent{fier value a2i, using the BNF syntax given in Figure 2.7. 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 I d; (c) i i + j * k - 3; P1·ogran~ -----+ int main ( ) { Declarations Statenwnts } Declarations -----+ { Declaration } Declaration--> Type Identifier [ [ Integer] ] { , Ident'ifier [ [ Integer] ] } Type --> int I bool I float I char Statements --> { Statement } Staternent --> ; I Block I Assigmnent I IfStatement I WhileStatement Block --> {Statements} Assignrnent --> Identifier' [ [ EJ:pression ] ] = E:r;pression ; If Statement --> if ( Exwession ) Statement [ else Statement
Studypool has helped 1,244,100 students
flag Report DMCA

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors