Fix positions of statements#506
Merged
stevenh merged 10 commits intorobertkrimen:masterfrom Jul 25, 2023
Merged
Conversation
Contributor
tyamagu2
commented
Jul 24, 2023
- Fix Idx1 of BranchStatement so that it points to the character after the label if Label exists, or the one after Token if Label does not exist.
- Fix Idx1 of LabelledStatement so that it points to the character after the statement.
- Fix Idx1 of ReturnStatement so that it points to the character after the argument if Argument exists, or the one after return keyword if Argument does not exist.
- Set Idx0 of SwitchStatement and fix Idx1 of SwitchStatement so that it points to the character after the right brace.
- Fix Idx0 of ThrowStatement to point to the start of throw keyword and fix Idx1 of ThrowStatement so that it points to the next character after Argument.
- Fix Idx1 of TryStatement to point to the character after Finally if Finally exists, or after Catch if Finally does not exist.
- Set Idx0 of WithStatement which was not previously set.
- Set WhileStatement.While so that Idx0 points to the right place.
- Set Idx0 of DoWhileStatement and fix Idx1 to point to the next character after the right parenthesis.
Fix Idx1 of BranchStatement so that it points to the character after the label if label exists, or the one after token if label does not exist.
Fix Idx1 of LabelledStatement so that it points to the character after the statement.
Fix Idx1 of ReturnStatement so that it points to the character after the argument if argument exists, or the one after return if argument does not exist.
Set Idx0 of SwitchStatement which was previously not set. Fix Idx1 of SwitchStatement so that it points to the character after the right brace.
Fix Idx0 of ThrowStatement to point to the start of throw keyword. Fix Idx1 of ThrowStatement so that it points to the next character after Argument.
Fix Idx1 of TryStatement to point to the character after Finally if Finally exists, or after Catch if Finally does not exist.
Set Idx0 of WithStatement which was not previously set.
Set WhileStatement.While so that Idx0 points to the right place.
Set Idx0 of DoWhileStatement and fix Idx1 to points to the next character after the right parenthesis.
stevenh
requested changes
Jul 24, 2023
Collaborator
stevenh
left a comment
There was a problem hiding this comment.
Thanks for working on this again, just one which looks like we could improve the test?
parser/parser_test.go
Outdated
| is(node.Idx0(), 40) | ||
| is(parser.slice(node.Idx0(), node.Idx1()), "break") | ||
|
|
||
| parser = newParser("", "xyz: for (i = 0; i < 10; i++) { if (i == 5) continue xyz; }", 1, nil) |
Collaborator
There was a problem hiding this comment.
Could we improve this one with function wrap so it actually indexes in?
stevenh
approved these changes
Jul 25, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.