Posted by : Anonymous Sunday, 3 February 2013


Consider the following grammar productions. Suppose you have an attribute E.type which can be set to either INT, 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.

CONST                       {E.type=??}

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

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

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

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

| (E1)                            {E.type=??}
You are required to add rules to the attribute grammar to calculate E.type for each grammar production.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © virtual university of pakistan - Skyblue - Powered by Blogger - Designed by Johanes Djogan -