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

comments should not change parser state #334

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jacob-wieland-gematik
Copy link

@jacob-wieland-gematik jacob-wieland-gematik commented Dec 9, 2024

πŸ€” What's changed?

⚑️ What's your motivation?

🏷️ What kind of change is this?

  • πŸ“– Documentation (improvements without changing code)
  • 🏦 Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)
  • πŸ› Bug fix (non-breaking change which fixes a defect)
  • ⚑ New feature (non-breaking change which adds new behaviour)
  • πŸ’₯ Breaking change (incompatible changes to the API)

♻️ Anything particular you want feedback on?

πŸ“‹ Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Dec 9, 2024

The parser is generated. To change the parser you'll have to change the grammar.

gherkin/gherkin.berp

Lines 35 to 38 in 00fcc43

// we need to explicitly mention comment, to avoid merging it into the description line's #Other token
// we also eat the leading empty lines, the tailing lines are not removed by the parser to avoid lookahead, this has to be done by the AST builder
DescriptionHelper := #Empty* Description? #Comment*
Description! := #Other+

To regenerate the parsers you can follow these instructions:

https://github.com/cucumber/gherkin/blob/main/CONTRIBUTING.md#generating-parsers

@jacob-wieland-gematik
Copy link
Author

I have changed the grammar to allow any mixture of empty lines, comments and other-lines as the description.

Extracting only the other-lines from the Description-AST-Node (as before) should yield the description-text without the comments and empty lines.

Only difference is now that a collection of ony empty-lines and comments would yield an empty description text instead of a non-existing Description node.

@mpkorstanje mpkorstanje self-requested a review December 10, 2024 18:12
@jacob-wieland-gematik
Copy link
Author

Changed the grammar in a way that is more consistent with the former test cases (treating empty lines inside description blocks as '#Other' lines).

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