ntsTest.com


Spring2009_CS606_05

Consider the following grammar productions Assume 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.

Assume 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=??}

 

Add rules to the attribute grammar to calculate E.type for each grammar production.

 

Solution:

Spring 2009_CS606_5_SOL


Related Posts


Comments

2 responses to “Spring2009_CS606_05”

Leave your response
  1. daigoumee says:

    It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing.

  2. Dan Zutell says:

    found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later