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 semicolon line attribution #178

Merged
merged 1 commit into from
May 10, 2022
Merged

Conversation

alex-pinkus
Copy link
Owner

For some reason, we were continuing to look for more whitespace tokens after consuming an explicit semicolon. This is unnecessary since the scanner can just come back for the remaining whitespace, if any exists. It also leads to incorrect attribution of the location of the semicolon, so it's better to just break at the semicolon.

Fixes #177 -- with this change, the test file in that issue gets parsed as:

(source_file [0, 0] - [2, 0]
  (simple_identifier [0, 0] - [0, 3])
  (_semi [0, 3] - [0, 4])
  (simple_identifier [1, 0] - [1, 3])
  (_semi [1, 3] - [1, 4]))

For some reason, we were continuing to look for more whitespace tokens
after consuming an explicit semicolon. This is unnecessary since the
scanner can just come back for the remaining whitespace, if any exists.
It also leads to incorrect attribution of the location of the semicolon,
so it's better to just break at the semicolon.

Fixes #177 -- with this change, the test file in that issue gets parsed
as:

```
(source_file [0, 0] - [2, 0]
  (simple_identifier [0, 0] - [0, 3])
  (_semi [0, 3] - [0, 4])
  (simple_identifier [1, 0] - [1, 3])
  (_semi [1, 3] - [1, 4]))
```
@alex-pinkus alex-pinkus merged commit c61122a into main May 10, 2022
@alex-pinkus alex-pinkus deleted the fix-semicolon-attribution branch May 10, 2022 04:37
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.

Semicolons get attributed to the following line
1 participant