Skip to content

Fix positions of statements#506

Merged
stevenh merged 10 commits intorobertkrimen:masterfrom
tyamagu2:fix-stmt-idx
Jul 25, 2023
Merged

Fix positions of statements#506
stevenh merged 10 commits intorobertkrimen:masterfrom
tyamagu2:fix-stmt-idx

Conversation

@tyamagu2
Copy link
Copy Markdown
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.

tyamagu2 added 9 commits July 24, 2023 12:45
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
Copy Markdown
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
Copy Markdown
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
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