Question: (Semantic Analysis - Attribute Grammar). Given the following context- free grammar. Add attribute rules to the grammar to accumulate into the root of the tree

(Semantic Analysis - Attribute Grammar). Given the following context- free grammar. Add attribute rules to the grammar to accumulate into the root of the tree a count of the number of subroutine calls. For example, given the string fl (a, f2(b * (c + (d - (e - f))))), the stmt at the root of the tree should have an attribute with a count of 2. stmt rightarrow assignment stmt rightarrow subr call assignment rightarrow id: = expr subr call rightarrow id (arg list) expr rightarrow primary expr tail expr tail rightarrow op expr expr tail rightarrow element primary rightarrow id primary rightarrow subr call primary rightarrow (expr) op rightarrow + | - |*|/arg list rightarrow expr args tail args tail rightarrow, arg list args tail rightarrow elementof
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
