Question
Here is the grammar for our language. Literal values in the grammar are denoted within single quotes. For example, 'LET' indicates that the uppercase characters
Here is the grammar for our language. Literal values in the grammar are denoted within single quotes. For example, 'LET' indicates that the uppercase characters LET must be observed at that point within the production rule. The grammar is written in a specific form optimal for recursive descent parsing. You can view a graphical form of our grammar on the following website [note, literals must be placed within single quotes within bottlecaps, thus we use the same standard here to make cutting and pasting effective]:
Select the AST class used for each input when applied to the given rule. If multiple apply, select the highest AST. For example, 1 + 2 contains both Ast.Expr.Literal and Ast.Expr.Binary, but the correct answer is Ast.Expr.Binary.
source:
LET x = 10; [ Select ] ["Ast.Source", "Ast.Field", "Ast.Function", "Ast.Stmt.Declaration"]
statement:
x == 10; [ Select ] ["Ast.Stmt", "Ast.Stmt.Expression", "Ast.Expr", "Ast.Expr.Binary"]
x.y = 10; [ Select ] ["Ast.Stmt.Expression", "Ast.Stmt.Assignment", "Ast.Expr.Access", "Ast.Expr.Binary"]
expression:
"string": [ Select ] ["Ast.Expr.Literal", "Ast.Expr.String", "Ast.Expr.Access", "Ast.String"]
x.toString(): [ Select ] ["Ast.Expr.Variable", "Ast.Expr.Access", "Ast.Expr.Function", "Ast.Expr.Method"]
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