CS606 Assignment 3 Solution Feb 2015

CS606 Compiler Construction Assignment 3 Solution Feb 2015

Question No 1:                                                                                                                       Marks 20

Consider the following grammar productions. Suppose you have an attribute E.type which can be set to either INT or BOOL.  Assume that the type of an expression is set to INT if an error is detected and you have a routine msg() similar to printf() that can be used to print error message.

E  à   CONST                               {E.type=??}

| ID                                      {E.type =getType(ID.name);}

| E1 -E2                              {E.type=??}

| E1> E2                              {E.type=??}

| E1= =E2                            {E.type=??}

| (E1)                                    {E.type=??}

Provide the parse tree for the expression (10 > 8) = = (13 – B).

Solution:

DOWNLOAD SOLUTION HERE
loading...