Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix positions of statements #506

Merged
merged 10 commits into from
Jul 25, 2023
Merged

Conversation

tyamagu2
Copy link
Contributor

  • 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.
@tyamagu2 tyamagu2 marked this pull request as ready for review July 24, 2023 04:39
Copy link
Collaborator

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this again, just one which looks like we could improve the test?

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we improve this one with function wrap so it actually indexes in?

@tyamagu2 tyamagu2 requested a review from stevenh July 25, 2023 02:16
@stevenh stevenh merged commit 11288b7 into robertkrimen:master Jul 25, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants