Question: In C++, a programmer can declare several variables with the syntax: int col, row; This declaration can be described with the following grammar with

In C++, a programmer can declare several variables with the syntax: int col, row; This declaration can be described with the following grammar with start symbol 'decl' and terminals: int, float, id. decl type id_list ; type int | float id_list id_list, id | id (a) Given the following attribute grammar for the above grammar. Syntax Rules Semantic Rules decl type id_list; id_listo id_list, id id_list id F id_list.type type.value id_listi.type id_listo.type id.type id_listo.type id.type id_listo.type - - (i) Discuss each of the semantic rules for the associated syntax rules. (ii) Decide whether the attributes are synthesized or inherited. Explain. [2+1=3 marks] (b) Why is the above grammar only applicable for bottom-up parsing but not suitable for top-down parsing? Explain. [2 marks] (c) Modify the original grammar so that it can be utilized for top-down parsing. Show the steps. [5 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
