gherkin
                                
                                
                                
                                    gherkin copied to clipboard
                            
                            
                            
                        [cucumber/gherkin] - comments in feature description cause a parse error
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)
 
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*
                                    
                                    
                                    
                                
Whether it was intentional I think it's clearly wrong - I don't know how to fix it though? ;)
@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.
Duplicate of #16?