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

[cucumber/gherkin] - comments in feature description cause a parse error #19

Open
ciaranmcnulty opened this issue Mar 9, 2021 · 4 comments

Comments

@ciaranmcnulty
Copy link
Contributor

Summary

It looks like comments in any part of the feature description are currently disallowed:

Feature: Using a comment in feature description

  # comment 1
  This is the feature description
  # comment 2

  Example: A normal example

Current Behavior

The text line that comprises the feature description is not allowed to follow the comment 1 so a parse error is thrown. The comment 2 is allowed because it's followed by an Example, so if only comment 1 is removed the file parses correctly.

(4:3): expected: #EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty, got '  This is the feature description'

Context & Motivation

I'm generally looking at where comments are allowed by the parser for behat compatibility and this came up

Your Environment

  • Version used: Go gherkin binary, 17.0.2 darwin amd64
  • Operating System and version: macOS Big Sur (M1)
@gasparnagy
Copy link
Member

Yes, this seem to be disallowed by the grammar. I don't know whether this was intentional though.
https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin.berp#L37

FeatureHeader! := #Language? Tags? #FeatureLine DescriptionHelper
...
DescriptionHelper := #Empty* Description? #Comment*

@ciaranmcnulty
Copy link
Contributor Author

Whether it was intentional I think it's clearly wrong - I don't know how to fix it though? ;)

@The-BDD-Coach
Copy link

@ciaranmcnulty Are commented lines allowed before the Feature? It is sometimes important to add comments to tags; if those tags precede 'Feature' then comments should be allowed there as well. (And lines that are neither comments nor tags should probably raise a parser error.)

If comments are not allowed before 'Feature', I think that should be addressed at the same time as this issue.

@enkessler
Copy link

Duplicate of #16?

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

No branches or pull requests

4 participants