The STEP language is implemented using the following grammar: = point main begin end ( ,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The STEP language is implemented using the following grammar: <program>= point main begin <expr> end (<expr>, <expr>) <number> <expr>= 1 <var-expr> ::= 1 I origin? (<expr>) | if (<expr>) { <expr> } else { <expr>} 1 move (<expr> <dir-expr> <dir-expr>*) <identifier> {<var-expr>* <expr> } <dir-expr> ::= 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 <identifier> = <expr> up (<number>) down (<number>) left (<number>) right (<number>) 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. The STEP language is implemented using the following grammar: <program>= point main begin <expr> end (<expr>, <expr>) <number> <expr>= 1 <var-expr> ::= 1 I origin? (<expr>) | if (<expr>) { <expr> } else { <expr>} 1 move (<expr> <dir-expr> <dir-expr>*) <identifier> {<var-expr>* <expr> } <dir-expr> ::= 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 <identifier> = <expr> up (<number>) down (<number>) left (<number>) right (<number>) 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.
Expert Answer:
Answer rating: 100% (QA)
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 ... View the full answer
Related Book For
Managerial accounting
ISBN: 978-0471467854
1st edition
Authors: ramji balakrishnan, k. s i varamakrishnan, Geoffrey b. sprin
Posted Date:
Students also viewed these databases questions
-
Dan Bergstrom has approached your bank for a loan to start a hazardous waste management business. There are a number of biotechnology and chemical companies in Dans community, and such companies...
-
The Glory Mountain State Ski Are expects to attract 292,500 skier days during the coming ski season. A skier day represents one skier at the mountain for one day. In addition to a $ 2,000,000 per...
-
a. What is the goal of the automatic stay? b. How did Dan Holiday Furniture violate the automatic stay provisions? c. But didn't Frank Jackson say he wanted to continue paying the store? d. The court...
-
- You have identified several risks on your project for which purchasing insurance is a possibility. The insurance company your firm uses has quoted reasonable rates, and your analysis shows that...
-
Rita converted an RRSP balance of $119 875.67 into a RRIF that will pay her $1800 at the end of every month for nine years. What is the nominal annual rate of interest compounded monthly?
-
A beam of \(650-\mathrm{nm}\) light passes through a small round hole and falls on a screen \(350 \mathrm{~mm}\) past the hole. If the diameter of the Airy disk on the screen is \(139 \mathrm{~mm}\),...
-
Use the Whitney-Nuismer average stress criterion to estimate the allowable internal pressure for Problem 9.5 if the unnotched tensile strength of the material is \(\sigma_{0}=1500 \mathrm{MPa}\) and...
-
On July 1, 2012, Macready Inc. invested $720,000 in a mine estimated to have 800,000 tons of ore of uniform grade. During the last 6 months of 2012, 100,000 tons of ore were mined and sold....
-
What are some strategies an interviewer can use to build rapport? What can be an issue if an applicant becomes too relaxed?
-
The controller of New Wave Sounds Inc. prepared the following product profitability report for management, using activity-based costing methods for allocating both the factory overhead and the...
-
The performance metrics you should track depend on the goals you set; performance evaluation varies by goal. These are some suggestions that organisations may use: Graphic ratings scales This method...
-
Fran McClure of Alba Advisers is estimating the cost of capital of Frontier Corporation as part of her valuation analysis of Frontier.McClure will be using this estimate, along with projected cash...
-
Chelsea Clinic projected the following budget information for 2015: a. Construct Chelsea Clinics operating budget for 2015. b. Discuss how each key budget assumption might result in a budget...
-
What is pay-for-performance?
-
With regard to the net present value (NPV) profiles of two projects, the crossover rate is best described as the discount rate at which: A. two projects have the same NPV. B. two projects have the...
-
What are the key differences between traditional and ABC?
-
A queen is looking for a bodyguard. A swordsman nominates himself, but the queen is unsure if this man is a hero or a coward. The swordsman knows whether he is a hero or a coward, but the queens...
-
A superior criticized a sales manager for selling high-revenue, low-profit items instead of lower-revenue but higher-profit items. The sales manager responded, My income is based on commissions that...
-
What three steps are followed under the account classification method to estimate the change in variable costs?
-
Ashwini Gupta owns a retail store that sells hand-made leather goods from around the world. Unfortunately, overseas suppliers are less than trusting when dealing with small clients, as it is common...
-
McMaster Fabrication has two manufacturing departments: machine operations and assembly. McMaster projected the following numbers for the most recent year. McMaster applies machine operations...
-
1. Describe the bases of power held by Dr. Jamie Thompson. Describe the bases of power held by Dr. Elizabeth Clarke. 2. What activities and people have contributed to Jaime Thompsons power? What...
-
What is the current in the wire in Figure Q22.1? 1.0 VR + 1.0-1.0V + FIGURE Q22.1
-
Electroplating uses electrolysis to coat one metal with another. In a copper-plating bath, copper ions with a charge of +2e move through the electrolyte from the copper anode to the cathode the metal...
Study smarter with the SolutionInn App