CSE 321: BL Context-free Grammar


          ---------------------------------------------------------------
          --- Program Parse ---------------------------------------------
          ---------------------------------------------------------------
          
          <program> -> PROGRAM <identifier> IS
                           { <new_instruction> }
                       BEGIN
                           <block>
                       END <identifier>
          
          <new_instruction> -> INSTRUCTION <identifier> IS
                                   <block>
                               END <identifier>
          
          ---------------------------------------------------------------
          --- Statement Parse -------------------------------------------
          ---------------------------------------------------------------
          
          <block> -> { <statement> }
          
          <statement> -> <if> | <while> | <call>
          
          <if> -> <if_only> | <if_else>

          <if_only> -> IF <condition> THEN
                           <block>
                       END IF

          <if_else> -> IF <condition> THEN
                           <block>
                       ELSE
                           <block>
                       END IF
          
          <while> -> WHILE <condition> DO
                         <block>
                     END WHILE
          
          <call> -> <identifier>
          
          <condition> -> next-is-empty  | next-is-not-empty  |
                         next-is-wall   | next-is-not-wall   |
                         next-is-enemy  | next-is-not-enemy  |
                         next-is-friend | next-is-not-friend |
                         random         | true
          
          ---------------------------------------------------------------
          --- Tokenizer -------------------------------------------------
          ---------------------------------------------------------------
          
          <identifier> -> <letter> { <letter> | <digit> | - }
          
          <letter> -> a | b | ... | z | A | B | ...  | Z
          
          <digit> -> 0 | 1 | ... | 9