During the implementation of the LET command translation using the new translator routines (which is now complete), some areas of improvement were seen in the code that could be made. This changes were kept separate from the latest sub-string assignment implementation commit.
The first was really a correction in the LET translate routine that would be needed once the multiple statements per line ability, separated by colons, was implemented. The issue was when an error is detected at the very beginning of a LET statement. To detect if the error was at the beginning, the column of the token was checked to see if it was zero. This was used to determine which error to return. However, this only works for a LET statement at the very beginning of a line. To correct this, before entering the get references loop, the column of the first token (the command token if there was one, or the first token) is saved. This saved column is then used to detect if the token with an error is at the beginning of the statement.
An improvement was made in how a flag is accessed from a table entry. There were flags() functions (taking either a code or a token pointer) that returned the flags for the table entry (if the code has an entry, otherwise the null flag was returned). The returned value was then anded to the desired flag to see if the result was non-zero (flag set) or zero (flag not set) These were changed to the hasFlag() functions that take a second argument for the desired flag, and return non-zero (flag is set) or zero (flag is not set).
While testing the LET translation, a lot of time was spent chasing down token memory leaks. The solution was to set the UnUsed sub-code in the token if it was not used. Care was needed to not set this sub-code if the token was used (for instance, the token was in the RPN output list or on the hold stack). There were quite a few of these set statements. As an alternative solution, this sub-code is now set once when a token is obtained from the parser by the get token routine. When the token is added to the output list, this sub-code is cleared. A simple output append routine was implemented to do this for all locations appending to the output list.
[commit a67b759432] [commit 6193ef5550] [commit 887cfc06e1]
Subscribe to:
Post Comments (Atom)
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.)