Question: Abstract Syntax Trees in Code Write a constructor for the node type of each production SH+E E E number (5) E_node* NumNode(int val){ ... }

Abstract Syntax Trees in Code Write a constructor for the node type of each production SH+E E E number (5) E_node* NumNode(int val){ ... } E_node* ParenNode(s_node* s){ } S_node* PlusNode (S_node* lhs, E_node* rhs) { ... } S_node* ENode (E_node* e) { ... } Exercise: Write code for the AST of 1 + 2 + 3). Hint: Start from the bottom. The AST for 2 is NumNode(2). What's the AST for 2 + 3? PlusNode(ENode(NumNode(2)), NumNode(3)) PlusNode NumNode(1), ParenNode( PlusNode. ENode (NumNode (2)), NumNode (3)))) 11 Abstract Syntax Trees in Code Write a constructor for the node type of each production SH+E E E number (5) E_node* NumNode(int val){ ... } E_node* ParenNode(s_node* s){ } S_node* PlusNode (S_node* lhs, E_node* rhs) { ... } S_node* ENode (E_node* e) { ... } Exercise: Write code for the AST of 1 + 2 + 3). Hint: Start from the bottom. The AST for 2 is NumNode(2). What's the AST for 2 + 3? PlusNode(ENode(NumNode(2)), NumNode(3)) PlusNode NumNode(1), ParenNode( PlusNode. ENode (NumNode (2)), NumNode (3)))) 11
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
