The command handler functions are friends of the Translator class, like the token handler functions; necessary so that pointers to these functions can be put into the table entries. The interface to these functions are similar to the token handlers except a pointer to the command stack item is passed for the second argument instead of a reference to a token pointer. This gives the command handler access to the code and flag information in the command stack item in addition to the token pointer of the command. If an error occurs and a different token needs to be pointed to for the error, the token pointer can be changed (the original token needs to be deleted first).
- Command handlers will now be in charge of checking if an expression has been ended correctly and will make sure the done stack has been emptied. The end-of-line handler is responsible for:
- Checking if the command stack is not empty (otherwise a “command stack empty” bug error occurs).
- Checking if the command on top of the command stack has a command handler (otherwise a “not yet implemented” bug error occurs).
- Popping the command item from command stack and calling its command handler.
- Popping the initial null token from the hold stack.
- Checking if the done stack is empty.
- Checking if the command stack is empty.
- Deleting the EOL token and return a done status.
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.)