Friday, August 23, 2013

New Translator – Colons

Multiple BASIC statements per line will be supported where statements are separated by a colon.  As mentioned in the last post, the newly implemented get commands routine, as indicated by its name, was intended to be able to process multiple statements per line, though the code to do that was not implemented.

For multiple statements, colons will not be stored in the program.  Instead, there will be a colon sub-code set on the last token of the statement, which is usually the command token, but not always (for example, an assign of a LET or a semicolon of a PRINT).  Multiple consecutive colons or a lone trailing colon will not be permitted as they add nothing.

To add support for multiple statements, the get commands routine was modified by adding a check for a colon token after checking for a RemOp token.  For a colon token, the token is not needed and so it is deleted.  The colon sub-code is set on the last token added to the RPN output list.  The loop then continues with looking for the another command.  Other changes requires was to add the end-statement flag to the colon table entry, to add the colon sub-code definition, and to modify the token text routine to detect and output the colon sub-code.

A new translator test (#16) was added for testing multiple statements with various commands before colons, and with several statements with errors.  The old translator routines crashes on this test as expected since multiple statements are not supported.  This will not be fixed since now that the new translator supports everything the old translator supported, the old translator routines can now be removed.

[commit 734521d17f]

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.)