Friday, August 23, 2013

New Translator – Complete (Tagged)

The implementation of the new translator routines is now complete for all the items previously completed in the old translator routines (LET, PRINT, INPUT and REM, with the additional item of multiple statement support).  Before removing the old translator routines, this is a good place to set a tag even though it has been only three commits from the last tag.  This \will be the last commit that will contain the old translator routines.

Version v0.4.5 has been tagged.  All tests, including the new multiple statement test (#16) with the new translator routines.  Test #16 does not pass with the old translator routines since multiple statement support was never added (would have required a new colon token handler).  Some comments were added indicating items that need to be removed with the old translators, which will now commence.

[commit 51ef63448b]

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]