Question: 2. Draw a parse tree for the grammar of example 3.1.3 and the string id (id+id) id. Example 3.1.3: programs written in any programming lang

2. Draw a parse tree for the grammar of example 3.1.3 and the string id (id+id) id. Example 3.1.3: programs written in any programming lang must some rigid criteria in order be and there- amenable to mechanical interpretation. Fortunately, the syntax of most programm languages can unlike that of human languages, be captured by context-free grammars. We shall see in Section 3.7 that being context-free is extremely derstan helpful when it comes to parsing a program, that is, a alyzing it to its syntax. Here, we give a grammar that generates a fragment of common programming languages. This language consists of all strings the alphabet ,id) that represent syntactically correct arithmetic essions involving t and id stands for any identifier at is to say, variabl many e t Examples of such strings are id (id e id d), but not id t (or id and Let G (V, E, R, E) where v and R are as follows. (RI) (E) (R6) The symbols E, T, and F are abbreviations for expression, term, and factor, respectively. The grammar G generates the string (id id+ id) (id id) by the following derivation E T by Rule R2 by Rule R3 T (E) by Rule R5 by Rule R1 Chapter 3: CONTEXT FREE LANG by Rule 3.1 T) by Rule T Thu 118 by Ru T (id T) by Rui may e R4 T. (id t F) by Rule R6 it is d id) by Rule RA F (id id) by Rule Ex (E) (id id) (we by Rule R (E t T) (id id) by Rule RA (E+ F) (id id) Fo by Rule R6 the (E id) (id id) NC by Rule R2 (T+ id) (id id) th (TT F t id) (id id) by Rule R3 co (F* F+ id) (id id) by Rule RA by Rule R6 (F id t id) (id id) fre (id id id) (id id) by Rule R6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
