Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Translate the following four BL programs into their executable form in the tables next to each example using the code generation patterns discussed in class(especially
Translate the following four BL programs into their executable form in the tables next to each example using the code generation "patterns" discussed in class(especially slides 30-47).
http://web.cse.ohio-state.edu/software/2231/web-sw2/extras/slides/28.Code-Generation.pdf
Use only the primitives: MOVE, TURNLEFT, TURNRIGHT, INFECT, SKIP, and HALT; unconditional jump: JUMP; and the conditional jumps: JUMP_IF_NOT_NEXT_IS_EMPTY, JUMP_IF_NOT_NEXT_IS_NOT_EMPTY, etc.) Note that the tables may be bigger than the actual length of the generated code.
PROGRAM Example1 IS BEGIN IF next-is-wall THEN turnright turnright infect END IF END Example1 |
|
PROGRAM Example2 IS BEGIN IF next-is-wall THEN turnright turnright infect ELSE infect move END IF END Example2 |
|
PROGRAM Example3 IS BEGIN WHILE next-is-not-empty DO IF next-is-wall THEN turnright turnright infect ELSE infect move END IF END WHILE END Example3 |
|
PROGRAM Example4 IS INSTRUCTION TurnBackAndInfect IS turnright turnright IF next-is-enemy THEN infect END IF END TurnBackAndInfect BEGIN WHILE true DO TurnBackAndInfect END WHILE END Example4 |
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
The question is incomplete because it refers to ...
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