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.
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
Semicolon as statement ender #7
Semicolon as statement ender #7
Changes from 9 commits
a4428c1
2ab1bb8
687e419
96116d4
88e46a6
f18fc25
b25f19c
8f6b7de
3c75ed2
b74b6fc
0bfa6da
ddc6099
cad1fec
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function should be the one checking for semicolons, not parseStatement.
Although it would be best to pass in a predicate like
separator
, except namedterminator
or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandersn Not sure if I got the exercise right this time. imteekay/mini-typescript@b74b6fc
The whole idea was
terminator
) to handle semicolonspeek
function to see the next token and if it's indeed a semicolon, call the parse statement to get theEmptyStatement
nodeDoes that make sense? Maybe it can be improved for this particular case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the way Typescript does it, as I recall:
where
peek
returns true if the current token could be the start of a new Statement, andterminator
doesn't consume a token if terminators are optional. This relies on the first token of statements to be distinguishable from from non-statements, but the only non-statement that can come after a statement list is Token.EOF, sopeek
is just going to be() => lexer.token !== Token.EOF
This way is a bit simpler than yours, and generalises to other kinds of lists, like parameter lists, arrays, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified it, the implementation seems much better now! ✨ imteekay/mini-typescript@cad1fec