Saturday, February 19, 2011

INPUT Command – Execution Procedure

To determine how the INPUT command will be encoded into internal memory, the internal codes need to be arranged according to how the INPUT command will be executed including handling errors. Using the same “INPUT I%,A(I%)” example statement from before, here is the procedure (for the moment without taking into account error handling):
  1. Issue prompt (for this statement, the default “? ” prompt)
  2. Get the input from the user (allowing for editing like backspace, cursor left/right, insert/overwrite, delete, and terminated by enter)
  3. Parse an integer value from the input for I% and save it (I% can't actually be assigned yet)
  4. Check if the next character in the input is a comma
  5. Parse a double value from the input for A(I%) and save it (A(I%) can't be assigned yet since I% hasn't been assigned)
  6. Check if there are no more characters
  7. Push reference of I% to evaluation stack
  8. Assign saved integer value to reference on top of stack – I%
  9. Push value of I% to evaluation stack (I% has now been assigned)
  10. Calculate reference for array A by popping index from evaluation stack, push calculated reference, A(I%), to stack
  11. Assign saved double value to reference on top of stack – A(%)
  12. End of INPUT command, advance to next line of output
Codes need to be defined for these steps. Some of these steps are already standard token types, step 7 is I%<ref>, step 9 is I%, and step 10 is A(<ref>. The rest of the steps will be INPUT command related codes.

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)