Skip to content

Lexer, helpers and comments cleanup #5063

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

Merged

Conversation

GeoffreyBooth
Copy link
Collaborator

#5045 had various improvements to comments and the lexer that were unrelated to that PR’s goal of passing extra token data through the parser. This PR wraps up those unrelated improvements.

@helixbass @zdenko

Copy link
Collaborator

@helixbass helixbass left a comment

Choose a reason for hiding this comment

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

@@ -946,19 +947,19 @@ exports.Lexer = class Lexer

# Same as `token`, except this just returns the token without adding it
# to the results.
makeToken: (tag, value, offsetInChunk = 0, length = value.length) ->
makeToken: (tag, value, offsetInChunk = 0, length = value.length, origin) ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

@GeoffreyBooth ah I see ya once this is merged I can merge into preserve-string-literal and convert to an option arg that gets passed along by token()

# and therefore matching `tokenHash`es, merge the comments from both/all
# tokens together into one array, even if there are duplicate comments;
# they will get sorted out later.
if tokenData[tokenHash].comments?
Copy link
Collaborator

Choose a reason for hiding this comment

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

@GeoffreyBooth I know this is just basically moving existing code, but a way I like to write this pattern is:

(tokenData[tokenHash].comments ?= []).push token.comments...

@GeoffreyBooth GeoffreyBooth merged commit 7cf739e into jashkenas:master May 13, 2018
@GeoffreyBooth GeoffreyBooth deleted the lexer-data-unrelated-improvements branch May 13, 2018 23:58
@GeoffreyBooth
Copy link
Collaborator Author

Thanks @helixbass I made the change you recommended.

@GeoffreyBooth GeoffreyBooth mentioned this pull request May 20, 2018
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