CSE 321 Homework 16


  1. The representation for BL_Tokenizing_Machine_Kernel_1 has three fields: where buffer_state can be one of the following Integer values:
    enumeration Buffer_State
    {
        EMPTY_BS,
        ID_OR_KEYWORD_OR_CONDITION_BS,
        WHITE_SPACE_BS,
        COMMENT_BS,
        ERROR_BS
    };
    

    The initial representation for a BL_Tokenizing_Machine_Kernel_1 object is:

    buffer_rep
    empty_string
    EMPTY_BS
    false
    buffer_state
    token_ready

    And here are the convention and the correspondence:

    
    math definition CONV (
            buffer: string of character
            buffer_state: integer
            token_ready: boolean
        ): boolean is
        token_ready =
            there exists c: character
                (LAST_OF (buffer) = <c> and
                 IS_COMPLETE_TOKEN_TEXT (ALL_BUT_LAST_OF (buffer), c)) and
        if buffer = empty_string
        then
            buffer_state = EMPTY_BS
        else
            there exists str: string of character, c: character
                ((if token_ready
                  then
                      buffer = str * <c>
                  else
                      buffer = str) and
                 (if IS_KEYWORD (str) or
                     IS_CONDITION_NAME (str) or
                     IS_IDENTIFIER (str)
                  then
                      buffer_state = ID_OR_KEYWORD_OR_CONDITION_BS
                  else if IS_WHITE_SPACE (str)
                  then
                      buffer_state = WHITE_SPACE_BS
                  else if IS_COMMENT (str)
                  then
                      buffer_state = COMMENT_BS
                  else
                      buffer_state = ERROR_BS))
    
    convention
        CONV (self.buffer_rep, self.buffer_state, self.token_ready)
    
    correspondence
        self.buffer = self.buffer_rep and
        self.ready_to_dispense = self.token_ready
    
    

    In this homework you will trace the internal state (representation) of the tokenizing machine after each Insert and Dispense operation when inserting the following characters:

    IF true THE!@ move

    Fill in all empty fields of the BL_Tokenizing_Machine_Kernel_1 representation below as characters are inserted and tokens are dispensed.

1. Insert ('I') 2. Insert ('F') 3. Insert (' ') 4. Dispense 5. Insert ('t')
buffer_rep
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
buffer_state
token_ready
6. Dispense 7. Insert ('r') 8. Insert ('u') 9. Insert ('e') 10. Insert (' ')
buffer_rep
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
buffer_state
token_ready
11. Dispense 12. Insert ('T') 13. Dispense 14. Insert ('H') 15. Insert ('E')
buffer_rep
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
buffer_state
token_ready
16. Insert ('!') 17. Dispense 18. Insert ('@') 19. Insert (' ') 20. Dispense
buffer_rep
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
buffer_state
token_ready
21. Insert ('m') 22. Dispense 23. Insert ('o') 24. Insert ('v') 25. Insert ('e')
buffer_rep
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
buffer_state
token_ready