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

Improve parser for block-comment #89

Merged
merged 3 commits into from
Sep 5, 2018

Conversation

wisn
Copy link
Contributor

@wisn wisn commented Sep 5, 2018

Why improve block-comment parser? The block-comment will breaks if we do these below.

/*!
 * Block comment
 */
/*
   Block comment until EOF
<<<EOF

Please review @gdotdesign

Copy link
Member

@gdotdesign gdotdesign left a 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.

@@ -7,7 +7,7 @@ module Mint

def component : Ast::Component | Nil
start do |start_position|
comment = self.comment
comment = self.comment || self.inline_comment
Copy link
Member

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 to block_comment
  • create a new comment function which parses a block_comment or an inline_comment
  • rename the Ast::Comment node to Ast::BlockComment and create an alias: alias Comment = BlockComment | InlineComment

Then all current related code would work unchanged.

@wisn
Copy link
Contributor Author

wisn commented Sep 5, 2018

Thanks for the review, @gdotdesign! Okay. I will update this PR. For the #81, it will be on separated PR.

@wisn wisn changed the title Improve parser for block-comment and add inline-comment Improve parser for block-comment Sep 5, 2018
@gdotdesign gdotdesign merged commit 9b646ed into mint-lang:master Sep 5, 2018
@gdotdesign
Copy link
Member

Thank you 👍

@wisn wisn deleted the improve-comment branch September 5, 2018 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants