Question: please help me solve 3 and 4. i have provided the code as well. 3. Consider the attribute grammar for type checking of assignment statements

 please help me solve 3 and 4. i have provided theplease help me solve 3 and 4. i have provided the code as well.
code as well. 3. Consider the attribute grammar for type checking of
assignment statements given in the Supplement. a. Suppose typeLookup('a') = float, type
Lookup('b') = long, and typeLookup(*c') = float Sketch the decorated parse tree

3. Consider the attribute grammar for type checking of assignment statements given in the Supplement. a. Suppose typeLookup('a') = float, type Lookup('b') = long, and typeLookup(*c') = float Sketch the decorated parse tree for the following assignment statement: a = b + c b. According to the predicate for expressions given in the Supplement, is this assignment statement type-correct? Explain your answer. 4. Consider the (non-standard) grammar and denotational semantics for statement lists, statement pair lists, statement pairs, and assignment statements given in the Supplement Suppose the current state is s - {, , , ident - {SEMANTIC RULE: .permittedTypes + if (typeLookup (ident.lexeme) - int) then (int) else if (typeLookup (ident. lexeme) == long) then (int, long! else if (typeLookup (ident. lexeme) - float) then (int, float) else if (type Lookup (ident.lexeme) == double) then (int,long, float, double) [2] + [3 {SEMANTIC RULE: .actualType if ( [2].actualType =- int AND [3] .actualType == int) then int else if ( [2] .actualType {int, long) and [3] .actualType E {int, long) then long else if (( [2] .actualType E (int,float) and [3] .actualType E (int,float) then float else double PREDICATE: .actualType E .permittedTypes } ident { SEMANTIC RULE: .actualType { typeLookup (ident. lexeme) PREDICATE: .actualType E .permittedTypes ) The following non-standard grammar and denotational semantics are used in item 4. 1 ; I { Mai ( => Map: (,s) ; => Mg(, Mspl (, S)) => Ms (; s) [1]; { Mspa (, s) A- case [1]; => Msp (, Mspa ([1], S)) => Map (, s) [1]; [2] { Msp (, s) A- Ms ([1], Ms ([2], s)) > x = { Ms (, s) A= if (Me (,s) == error) then error else s' = {, , ..., (in, va'>) where for k = 1,2,...,n if(ix==x) then vi' = Me (,s) else vk' = VARMAP (iks) (continued on next page) y + z { Me (, ) A= if (VARMAP (y, S) == undef OR VARMAP (2,s) - then error else VARMAP (y) + VARMAP (2) undef) y * z. { Me (, s) A= if (VARMAP (y,s) -- undef OR VARMAP (2,5) == undef) then error else VARMAP (y) * VARMAP (2) 3. Consider the attribute grammar for type checking of assignment statements given in the Supplement. a. Suppose typeLookup('a') = float, type Lookup('b') = long, and typeLookup(*c') = float Sketch the decorated parse tree for the following assignment statement: a = b + c b. According to the predicate for expressions given in the Supplement, is this assignment statement type-correct? Explain your answer. 4. Consider the (non-standard) grammar and denotational semantics for statement lists, statement pair lists, statement pairs, and assignment statements given in the Supplement Suppose the current state is s - {, , , ident - {SEMANTIC RULE: .permittedTypes + if (typeLookup (ident.lexeme) - int) then (int) else if (typeLookup (ident. lexeme) == long) then (int, long! else if (typeLookup (ident. lexeme) - float) then (int, float) else if (type Lookup (ident.lexeme) == double) then (int,long, float, double) [2] + [3 {SEMANTIC RULE: .actualType if ( [2].actualType =- int AND [3] .actualType == int) then int else if ( [2] .actualType {int, long) and [3] .actualType E {int, long) then long else if (( [2] .actualType E (int,float) and [3] .actualType E (int,float) then float else double PREDICATE: .actualType E .permittedTypes } ident { SEMANTIC RULE: .actualType { typeLookup (ident. lexeme) PREDICATE: .actualType E .permittedTypes ) The following non-standard grammar and denotational semantics are used in item 4. 1 ; I { Mai ( => Map: (,s) ; => Mg(, Mspl (, S)) => Ms (; s) [1]; { Mspa (, s) A- case [1]; => Msp (, Mspa ([1], S)) => Map (, s) [1]; [2] { Msp (, s) A- Ms ([1], Ms ([2], s)) > x = { Ms (, s) A= if (Me (,s) == error) then error else s' = {, , ..., (in, va'>) where for k = 1,2,...,n if(ix==x) then vi' = Me (,s) else vk' = VARMAP (iks) (continued on next page) y + z { Me (, ) A= if (VARMAP (y, S) == undef OR VARMAP (2,s) - then error else VARMAP (y) + VARMAP (2) undef) y * z. { Me (, s) A= if (VARMAP (y,s) -- undef OR VARMAP (2,5) == undef) then error else VARMAP (y) * VARMAP (2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!