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

Add multiline comments to Pest's PEG format #332

Merged
merged 2 commits into from
Nov 6, 2018

Conversation

felix91gr
Copy link
Contributor

Implementation of #330. At least, that's what I think.

Probably needs tests. How do I make one, or update the existing ones?

And how can I test it manually?

Thanks <3

@CAD97
Copy link
Contributor

CAD97 commented Nov 6, 2018

If we want this to mirror Rust's block comments, they should probably nest:

block_comment = _{ "/*" ~ (block_comment | !"*/" ~ ANY)* ~ "*/" }

You can test by patching a use site to use a path dependency on your local pest (or your git branch).

@felix91gr
Copy link
Contributor Author

You can test by patching a use site to use a path dependency on your local pest (or your git branch).

Yo, that is awesome! It took me less than 5 minutes to make that work and test it with my project :D (PS: it accepts my multiline comments now c: )

If we want this to mirror Rust's block comments, they should probably nest

I have no opinion on this, but it sounds better. I didn't think of nested multiline comments, that's probably a pretty good use case. It also makes more sense from the ergonomics standpoint: when I used to work in C#, the multiline comments were as I have just implemented them and it was very weird that a single */ could stop all the /* in the universe. Letting them be nested makes it a lot more useable, I think.

So, what's missing now are some tests for this, I'd think. Where can I put such a test? Something like a couple of example grammars with multiline comments would be nice to have as a test :)

@felix91gr
Copy link
Contributor Author

Now I've uploaded an update that makes multiline comments nestable. Thanks @CAD97 ^^

- Add multiline comment to PEG's format grammar, at COMMENT pattern's definition
- Add test for single line comments
- Add test for multiline one-line comments
- Add test for multiline n-line comments
- Add test for nested:
--: Single line in multiline
--: (Multiline in) multiline
--: Invalid grammar pattern definition inside multiline
@felix91gr
Copy link
Contributor Author

felix91gr commented Nov 6, 2018

Now that it has tests, I think the PR is ready for review. What do you think?

This is what's implemented:

  • Multiline comments
  • Test for single-lined comments
  • Test for multiline one-line comments
  • Test for multiline n-line comments
  • Test for nested:
    • Single line in multiline
    • (Multiline in) multiline
    • Invalid grammar pattern definition inside multiline: if there are rules generated from inside a multiline comment, this should fail to produce a parse tree. If, on the other hand, definitions inside multiline comments are ignored, then this test should pass.

Copy link
Contributor

@dragostis dragostis left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this! Everything looks good, but I'd like to ask a favor: will you please symlink all *.pest files from derive/tests in vm/tests so they don't have to be updated separately? As I said before, my testing can get sloppy sometimes...

@felix91gr
Copy link
Contributor Author

Will you please symlink all *.pest files from derive/tests in vm/tests so they don't have to be updated separately?

Sure, I can do that. But is that something related to this PR (like, something I might have broken), or is it something else that the repo needs and hasn't been done yet? If it's the second, then maybe it should be done in a separate PR? To separate these two additions and all that. Or maybe just in a separate commit, and then we can merge two commits with the same PR. What do you think?

@dragostis
Copy link
Contributor

It should be a separate PR, yes, but it's a very small change I'd hoped to get away with. 😃 We're currently not squashing PR commits before merging, so the whole history is there.

@felix91gr
Copy link
Contributor Author

Hahaha, okay 😄
I'll do it, then. Which files should link where?

Something like: "for each file file in vm/tests, file should link to derive/tests/file"?

@dragostis
Copy link
Contributor

Yes, but only the *.pest grammar files need to be replaced.

@felix91gr
Copy link
Contributor Author

Okay, I'll add it :)

@felix91gr
Copy link
Contributor Author

Added! :)

@dragostis
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Nov 6, 2018
332: [WIP] Add multiline comments to Pest's PEG format r=dragostis a=felix91gr

Implementation of #330. At least, that's what I think.

Probably needs tests. How do I make one, or update the existing ones?

And how can I test it manually?

Thanks <3

Co-authored-by: Félix Fischer <[email protected]>
Co-authored-by: Félix Fischer <[email protected]>
@bors
Copy link
Contributor

bors bot commented Nov 6, 2018

Build succeeded

@bors bors bot merged commit b312f6f into pest-parser:master Nov 6, 2018
@felix91gr
Copy link
Contributor Author

Wooo :D

@felix91gr
Copy link
Contributor Author

@felix91gr felix91gr changed the title [WIP] Add multiline comments to Pest's PEG format Add multiline comments to Pest's PEG format Jan 10, 2019
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.

3 participants