Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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. \[ \begin{array}{l} \text { decl } ightarrow \text { type id_list ; } \\ \text { type } ightarrow \text { int I float } \\ \text { id_list } ightarrow \text { id_list, id I id } \end{array} \] (a) Given the following attribute grammar for the above grammar. (i) Discuss each of the semantic rules for the associated syntax rules. (ii) Decide whether the attributes are synthesized or inherited. Explain. [2+1=3marks] (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
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