Question: CS 415 Compilers: Problem Set 7 Due date: Wednesday, April 18, 11:59pm Problem 1 - Attribute Grammars and Syntax-Directed Translation Schemes Assume the following partial


CS 415 Compilers: Problem Set 7 Due date: Wednesday, April 18, 11:59pm Problem 1 - Attribute Grammars and Syntax-Directed Translation Schemes Assume the following partial grammar: vardel ::= idlist: type idlist :?idlist. ID | ID type ::- integer l real I double I. Write an attribute granmar that computes the attribute type for each identifier. i.e., for each occurrence of an ID node in a subtree with as its root. State for each attribute that you are using whether it is synthesized or inherited. 2. Show the parse tree for the input string a, b, c, d: double with all attribute instances and the final values of these attributes, i.e., show the decorated tree. 3. Is your attribute grammar S-attributed or L-attributed? Write a syntax-directed translation scheme that stores the types of the variables in a symbol table. You may use pseudo code in your embedded actions. Assume that each ID has a pre-defined synthesized attribute name that contains its lexeme. The routine insert (id, type) inserts an identifier of a particular type into the symbol table Use YACC-like notation (e.g. SS.name or $1.type CS 415 Compilers: Problem Set 7 Due date: Wednesday, April 18, 11:59pm Problem 1 - Attribute Grammars and Syntax-Directed Translation Schemes Assume the following partial grammar: vardel ::= idlist: type idlist :?idlist. ID | ID type ::- integer l real I double I. Write an attribute granmar that computes the attribute type for each identifier. i.e., for each occurrence of an ID node in a subtree with as its root. State for each attribute that you are using whether it is synthesized or inherited. 2. Show the parse tree for the input string a, b, c, d: double with all attribute instances and the final values of these attributes, i.e., show the decorated tree. 3. Is your attribute grammar S-attributed or L-attributed? Write a syntax-directed translation scheme that stores the types of the variables in a symbol table. You may use pseudo code in your embedded actions. Assume that each ID has a pre-defined synthesized attribute name that contains its lexeme. The routine insert (id, type) inserts an identifier of a particular type into the symbol table Use YACC-like notation (e.g. SS.name or $1.type