Created
December 28, 2008 20:53
-
-
Save josephwilk/41042 to your computer and use it in GitHub Desktop.
Cucumber ANTLR grammar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Gherkin; | |
//options { | |
// language=Ruby; | |
//} | |
feature : NEWLINE* comment? NEWLINE* SPACE* tags? NEWLINE* SPACE* feature_keyword SPACE* line_to_eol NEWLINE+ (feature_elements .)* feature_elements ; | |
fragment | |
feature_elements | |
: (scenario_outline | scenario)* ; | |
scenario | |
: comment? tags? scenario_keyword SPACE* line_to_eol NEWLINE+ steps ; | |
scenario_outline | |
: comment? tags? scenario_outline_keyword SPACE* line_to_eol NEWLINE+ steps examples_sections ; | |
steps : step* ; | |
step : step_keyword SPACE* line_to_eol NEWLINE+ multiline_arg? ; | |
examples_sections | |
: examples+ ; | |
examples | |
: examples_keyword SPACE* line_to_eol NEWLINE+ table ; | |
multiline_arg | |
: table ; | |
table : table_row+ ; | |
table_row | |
: SPACE* '|' (cell '|')+ SPACE* (NEWLINE+) ; | |
cell : (~('|' | NEWLINE) .)* ; | |
tags : tag (SPACE tag)* NEWLINE+ ; | |
tag : '@' tag_name=ID ; | |
comment | |
: (comment_line NEWLINE)* ; | |
comment_line | |
: '#' line_to_eol; | |
line_to_eol | |
: (~NEWLINE)* ; | |
feature_keyword | |
: 'Feature' ':'? ; | |
scenario_keyword | |
: 'Scenario' ':'? ; | |
scenario_outline_keyword | |
: 'Scenario Outline' ':'? ; | |
step_keyword | |
: 'Given' | 'When' | 'Then' | 'And' | 'But' ; | |
examples_keyword | |
: 'Examples' ':'? ; | |
ID : ('a'..'z'|'A'..'Z'|'_')+ ; | |
NEWLINE : (('\r')? '\n' )+ ; | |
SPACE : (' '|'\t')+ {skip();}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had trouble with the Ruby bindings so I was never quite sure it worked. It was a spike to test the ground for moving away from treetop.
We ended up going with Ragel instead.