- Carefully read the Lab3 assignment and study the specifications
for Program_Parse
and Statement_Parse
in your 321 class notes.
- Show the value (a picture or a careful description) of self after
a call to the Parse operation for Program, if the input stream initially
contains the following BL program:
PROGRAM TryToGuess IS
INSTRUCTION FindObstacle IS
WHILE next-is-empty DO
move
END WHILE
END FindObstacle
BEGIN # TryToGuess
WHILE true DO
FindObstacle
IF next-is-enemy THEN
infect
ELSE
IF next-is-wall THEN
turnleft
ELSE # next-is-friend
skip
END IF
END IF
END WHILE
END TryToGuess
- Consider the Statement_Parse component. It is an extension to
Statement that exports two operations: Parse and Parse_Block. Which kinds
of statements do Parse and Parse_Block respectively parse?
- Show the value (a picture or a careful description) of self after
a call to the Parse operation for Statement, if the input stream initially
contains the following BL statement:
WHILE next-is-empty DO
move
END WHILE
- Show the value (a picture or a careful description) of self after
a call to the Parse_Block operation for Statement, if the input stream initially
contains the following BL statements:
move
IF next-is-enemy THEN
infect
END IF
turnright