Fix https://github.com/vlachoudis/brexx/issues/8 #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the WORDPARSE operation from section 8.3.1.7 (pp. 86-90) of the ANSI X3J18-199X REXX Standard. This changes bREXX's
PARSE
instruction to correctly parse blank-separated targets between triggers, including the implied start-of-string and end-of-string triggers.Because bREXX splits the FINDNEXTBREAK operation from the standard between the compiler and the interpreter, and out of a desire to make the fix as non-invasive as reasonably possible, I chose to leave most of the processing intact, with several significant changes:
PARSE
no longer proceeds in a straight path fromOP_PARSE
toOP_TR_END
andOP_POP
. Instead, I insertedOP_JMP
s such that parsing of word-separated targets does not begin until after the trigger to their right has been evaluated. This results in all blank-separated targets are now correctly parsing only the data between the triggers to their immediate left and right.word_start
andword_end
. These are used by the blank-separated-target parsing code to walk through the words in the input substring that was isolated by the triggers.bRexx has no test suite, but I created a set of tests for
PARSE
that verify correct operation. To do so, I pulled many examples from my collection of Rexx code, and I typed in all the examples from Mike Cowlishaw's The Rexx Language, 2nd edition. I have attached the fileparse_.txt
, which demonstrates the failure described in Issue #8 (test 2 in the file), as well as several others I discovered while investigating this bug (tests 3, 8, and 20). It also shows one questionable behavior, that I need to confirm against the original VM/CMS Rexx implementation (test 16), and one separate bug that I'll open up another issue for (test 19). This PR fixes all but the last two, which will be addressed separately (if at all). Run the tests by simply runningbrexx parse_.txt
.parse_.txt