Fix parsing of end and step in array slice#37
Conversation
|
The Is there some antlr magic that means we don't get coverage over the missing lines? The tests are for the array slice subscript method mostly not the upper level parser itself. |
|
There are some array slice tests in |
This adds two tests to complete the coverage nessisary for pacifica#37 Signed-off-by: David Brown <dmlb2000@gmail.com>
This adds two tests to complete the coverage nessisary for pacifica#37 Signed-off-by: David Brown <dmlb2000@gmail.com>
The grammer did not allow parsing of sliceable expressions with a trailing colon. In Python at least, slices like `[:2:]` and `[2::]` are allowed. This change makes the sliceable expression in the grammer allow the last number to be optional. Signed-off-by: David Brown <dmlb2000@gmail.com>
|
@markborkum I created a pull request to your branch to complete the coverage testing without ignoring the code. I also found a situation that doesn't parse correctly. Please checkout markborkum#1 then we can merge this pull request. I did check coverage and adding the additional testing does cover the method without the |
Add extra tests to complete coverage.
dmlb2000
left a comment
There was a problem hiding this comment.
I'm fine with this pull request.
Description
This issue is caused by the way that ANTLR4 indexes terminals in a context. In ANTLR4, when two or more terminals with the same name are present in the same production, but only a subset of terminals are parsed, the indexing does not reflect the position of the terminal within the production.
For #35, when the string "::n" is parsed, for a given "n", the context contains only 1 "NUMBER" terminal, which is assigned the index 0, where the index 1 would be expected (with the index 0 returning
Noneor a similar sentinel value).The mitigation is to test for the presence of the second "COLON" terminal and then to verify that it came before the second "NUMBER" terminal.
Issues Resolved
Fixes #35
Check List