-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
Improve parser for block-comment #89
Conversation
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.
The initial implementation looks great 👍
However its not complete:
- there is no AST node for inline comment so parsed inline comments would be formatted as block comments by the formatter
- as commented in the code, changes are needed to allow inline comments to work across all of the language
We could break up the two features into separate PRs, because the block-comment parser improvements could be merged right now.
src/parsers/component.cr
Outdated
@@ -7,7 +7,7 @@ module Mint | |||
|
|||
def component : Ast::Component | Nil | |||
start do |start_position| | |||
comment = self.comment | |||
comment = self.comment || self.inline_comment |
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.
There are a lot of places where the comment
function is called. Adding || self.inline_comment
to each would not be a good solution.
Probably we should:
- rename the
comment
function toblock_comment
- create a new
comment
function which parses ablock_comment
or aninline_comment
- rename the
Ast::Comment
node toAst::BlockComment
and create an alias:alias Comment = BlockComment | InlineComment
Then all current related code would work unchanged.
Thanks for the review, @gdotdesign! Okay. I will update this PR. For the #81, it will be on separated PR. |
Thank you 👍 |
Why improve block-comment parser? The block-comment will breaks if we do these below.
Please review @gdotdesign