common icon indicating copy to clipboard operation
common copied to clipboard

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

Open ciaranmcnulty opened this issue 4 years ago • 2 comments

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)

ciaranmcnulty avatar Mar 09 '21 11:03 ciaranmcnulty

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*

gasparnagy avatar May 06 '21 07:05 gasparnagy

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

ciaranmcnulty avatar Jul 09 '22 09:07 ciaranmcnulty