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

The parser cursor should skip line terminators by default #340

Closed
Razican opened this issue Apr 21, 2020 · 2 comments
Closed

The parser cursor should skip line terminators by default #340

Razican opened this issue Apr 21, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request parser Issues surrounding the parser
Milestone

Comments

@Razican
Copy link
Member

Razican commented Apr 21, 2020

Line terminators are almost always just a simple white space. The lexer needs to take them into account to allow automatic semicolon insertion and allow checking for places where line terminators are not allowed.

So, in this scenario, I would propose for the parser cursor to automatically skip line terminators when calling next(), peek() or expect(). We already have a expect_semicolon() function that will take into account line terminators. We would also need a peek_semicolon() that would check if a semicolon could be inserted (or is present), to check for things such as continue; or continue expr;.

Finally, we would need another expect_no_lineterminator() function, that would make sure that there is no line terminator at the given position. I think this would make it easier to implement the spec, or at least our parsing code would be closer to what we see in the spec.

This would also allow removing the skip() function, the {peek/next}_skip_lineterminator() functions, and review the next_if() functions, since there seems to be a lot of duplicated functionality here.

@Razican Razican added enhancement New feature or request parser Issues surrounding the parser labels Apr 21, 2020
@HalidOdat
Copy link
Member

HalidOdat commented Apr 28, 2020

Don't we skip line terminators in #304 by default?

@Razican
Copy link
Member Author

Razican commented Apr 29, 2020

Yes! This is solved :)

@Razican Razican added this to the v0.8.0 milestone Apr 29, 2020
@Razican Razican self-assigned this Apr 29, 2020
@Razican Razican closed this as completed Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parser Issues surrounding the parser
Projects
None yet
Development

No branches or pull requests

2 participants