Question: Problem 2: Consider the following grammar (yes, it is ambiguous but that is unimportant). The subscripts are used to distinguish otherwise identical non-terminals for the

 Problem 2: Consider the following grammar (yes, it is ambiguous but

Problem 2: Consider the following grammar (yes, it is ambiguous but that is unimportant). The subscripts are used to distinguish otherwise identical non-terminals for the purpose of the questions below expression2> ; int double - value values var> Kinteger> a legal name in the language base 10 representation of an integer a base 10 representation of a floating point number Suppose our static semantic description has five attributes integer, double { type typetable () } integer, double, error true, false, error } - (, \ integer, double )) (, { true, false )) inittable () { = typebinding initialized typetable maps each possible variable name to its declared type, and inittable maps each possible variable name to a boolean indicating whether the variable has been assigned a value. Initially, both typetable and inittable will map all possible variable names to error to indicate that the variables have not been declared in the program typebinding maps a single variable name to its declared type, and initialized maps a single variable name to whether it has been assigned a value For each subscripted non-terminal, provide a rule to calculate its type, table, inittable, typebindig, and ini tialized attributes, if that non-terminal requires that attribute. Each attribute should either be inherited or synthesized, but not both. For example, here are two such rules . type := integer declare 1 >.initialized := (, false) (Here I am using :- to create a mapping so you can useto mean only mathematical equality.) Problem 2: Consider the following grammar (yes, it is ambiguous but that is unimportant). The subscripts are used to distinguish otherwise identical non-terminals for the purpose of the questions below expression2> ; int double - value values var> Kinteger> a legal name in the language base 10 representation of an integer a base 10 representation of a floating point number Suppose our static semantic description has five attributes integer, double { type typetable () } integer, double, error true, false, error } - (, \ integer, double )) (, { true, false )) inittable () { = typebinding initialized typetable maps each possible variable name to its declared type, and inittable maps each possible variable name to a boolean indicating whether the variable has been assigned a value. Initially, both typetable and inittable will map all possible variable names to error to indicate that the variables have not been declared in the program typebinding maps a single variable name to its declared type, and initialized maps a single variable name to whether it has been assigned a value For each subscripted non-terminal, provide a rule to calculate its type, table, inittable, typebindig, and ini tialized attributes, if that non-terminal requires that attribute. Each attribute should either be inherited or synthesized, but not both. For example, here are two such rules . type := integer declare 1 >.initialized := (, false) (Here I am using :- to create a mapping so you can useto mean only mathematical equality.)

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!