Complete the code to represent the root of a parse tree.
root = ParseTreeNode([1])The root of a parse tree typically holds a token representing the start symbol or main expression.
Complete the code to create a derivation step from a non-terminal to a production.
derivation = DerivationStep([1], production_rule)A derivation step starts from a non-terminal symbol and applies a production rule.
Fix the error in the code to correctly build a parse tree node with children.
node = ParseTreeNode(symbol=[1], children=children_list)Parse tree nodes represent non-terminal symbols with children nodes representing expansions.
Fill both blanks to create a dictionary comprehension mapping non-terminals to their productions.
{ [1]: [2] for [1] in grammar.non_terminals }This comprehension maps each non-terminal (nt) to its list of productions.
Fill all three blanks to filter productions that derive a terminal symbol.
[prod for prod in productions if prod.[1] == [2] and prod.[3]]
This list comprehension selects productions whose right side is a terminal and confirms it is terminal.