Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The STEP language is implemented using the following grammar: = point main begin end ( , ) = 1 ::= 1 I origin? (
The STEP language is implemented using the following grammar: = point main begin end ( , ) = 1 ::= 1 I origin? ( ) | if ( ) { } else { } 1 move ( *) { * } ::= a program point expr number origin expr if expr move expr identifier block expr val up expr down expr left expr right expr I val = up ( ) down ( ) left ( ) right ( ) Top level program variant that contains an expr List containing two numbers (coordinates) "a program" "point expr" "num expr" "origin? expr" "if expr" "move expr" "iden expr" "block expr" "val" "up expr" "down expr" "left expr" "right expr" Number variant Returns true if expr is (0,0) false otherwise Executes expr2 if exprl if correct otherwise executes expr3 Moves expr (point) using the directions dir-expr (one or more than one) Symbol that is the name of a variable Block in which the assignments in var-expr (any number) is visible Assigns the identifier a value obtained from expr (expr evaluates to a number) Used in move expr to move a point in the up direction Used in move expr to move a point in the down direction Used in move expr to move a point in the left direction Used in move expr to move a point in the right direction 2.b (20 points) Implement the the helper functions move and add-variables that work on list of directions and list of variable respectively. If you have a fully working implementation, then you do not need to im- plement these functions, otherwise these functions will be looked at to give you partial points.
Step by Step Solution
★★★★★
3.39 Rating (155 Votes )
There are 3 Steps involved in it
Step: 1
Move Function The move function takes two parameters a list of directions and a point a pair of coordinates The function iterates through the list of ...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