josephwilk (owner)

Revisions

gist: 41042 Download_button fork
public
Description:
Cucumber ANTLR grammar
Public Clone URL: git://gist.github.com/41042.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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();};