CSE 321 Homework 13


  1. Carefully read the Lab3 assignment and study the specifications for Program_Parse and Statement_Parse in your 321 class notes.

  2. 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:
  3.     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
  4. 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?

  5. 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:
  6.     WHILE next-is-empty DO
            move
        END WHILE
    
  7. 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:
  8.     move
        IF next-is-enemy THEN
            infect
        END IF
        turnright