Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 that is unimportant). The subscripts are used to distinguish otherwise identical non-terminals for the purpose of the questions below. ; int double = a legal name in the language a base 10 representation of an integer a base 10 representation of a floating point number = = Suppose our static semantic description has five attributes: type { integer, double } typetable() { integer, double, error } inittable() { true, false, error } typebinding (, { integer, double }) initialized (, { true, false }) 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, typebinding, and initialized 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 .initialized := (, false) (Here I am using := to create a mapping so you can use = to 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. ; int double = a legal name in the language a base 10 representation of an integer a base 10 representation of a floating point number = = Suppose our static semantic description has five attributes: type { integer, double } typetable() { integer, double, error } inittable() { true, false, error } typebinding (, { integer, double }) initialized (, { true, false }) 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, typebinding, and initialized 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 .initialized := (, false) (Here I am using := to create a mapping so you can use = to mean only mathematical equality.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started