Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer the question correctly and show all the steps used. 3. [9 marks] Suppose that the base ASTNode class had a setPosition(int n) method
Please answer the question correctly and show all the steps used.
3. [9 marks] Suppose that the base ASTNode class had a setPosition(int n) method that sets the position of the node in the abstract syntax tree. The position is location of the symbol in its inner most list. E.g., for ((a) b (cd) e) the position of atom (a) is 0, the position of atom bis 1, the position of atom atom (c d) is 2, the position of atom c is 0, the position of atom d is 1, and the position of atom e is 3. Extend the S-attributed grammar from Question 2 into an L-attributed grammar that also sets the position of each node in the abstract syntax tree as it is created. Provide a brief explanation of how the grammar works. 3. [9 marks] Suppose that the base ASTNode class had a setPosition(int n) method that sets the position of the node in the abstract syntax tree. The position is location of the symbol in its inner most list. E.g., for ((a) b (cd) e) the position of atom (a) is 0, the position of atom bis 1, the position of atom atom (c d) is 2, the position of atom c is 0, the position of atom d is 1, and the position of atom e is 3. Extend the S-attributed grammar from Question 2 into an L-attributed grammar that also sets the position of each node in the abstract syntax tree as it is created. Provide a brief explanation of how the grammar worksStep 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