forked from cucumber-attic/gherkin2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexer_common.rl.erb
46 lines (36 loc) · 2.92 KB
/
lexer_common.rl.erb
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
%%{
machine lexer_common;
# Language specific
I18N_Feature = (<%= ragel_list(@i18n.feature_keywords) %> ':') >start_keyword %end_keyword;
I18N_Background = (<%= ragel_list(@i18n.background_keywords) %> ':') >start_keyword %end_keyword;
I18N_ScenarioOutline = (<%= ragel_list(@i18n.scenario_outline_keywords) %> ':') >start_keyword %end_keyword;
I18N_Scenario = (<%= ragel_list(@i18n.scenario_keywords) %> ':') >start_keyword %end_keyword;
I18N_Step = <%= ragel_list(@i18n.step_keywords) %> >start_keyword %end_keyword;
I18N_Examples = (<%= ragel_list(@i18n.examples_keywords) %> ':') >start_keyword %end_keyword;
EOF = '%_FEATURE_END_%'; # Explicit EOF added before scanning begins
EOL = ('\n' | '\r\n') @inc_line_number @last_newline;
FeatureHeadingEnd = EOL+ space* (I18N_Background | I18N_Scenario | I18N_ScenarioOutline | '@' | '#' | EOF) >next_keyword_start;
ScenarioHeadingEnd = EOL+ space* ( I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
BackgroundHeadingEnd = EOL+ space* ( I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#'| EOF ) >next_keyword_start;
ScenarioOutlineHeadingEnd = EOL+ space* ( I18N_Scenario | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
ExamplesHeadingEnd = EOL+ space* '|' >next_keyword_start;
FeatureHeading = space* I18N_Feature %begin_content ^FeatureHeadingEnd* :>> FeatureHeadingEnd @store_feature_content;
BackgroundHeading = space* I18N_Background %begin_content ^BackgroundHeadingEnd* :>> BackgroundHeadingEnd @store_background_content;
ScenarioHeading = space* I18N_Scenario %begin_content ^ScenarioHeadingEnd* :>> ScenarioHeadingEnd @store_scenario_content;
ScenarioOutlineHeading = space* I18N_ScenarioOutline %begin_content ^ScenarioOutlineHeadingEnd* :>> ScenarioOutlineHeadingEnd @store_scenario_outline_content;
ExamplesHeading = space* I18N_Examples %begin_content ^ExamplesHeadingEnd* :>> ExamplesHeadingEnd @store_examples_content;
Step = space* I18N_Step %begin_content ^EOL+ %store_step_content :> EOL+;
Comment = space* '#' >begin_content ^EOL* %store_comment_content :> EOL+;
Tag = ( '@' [^@\r\n\t ]+ >begin_content ) %store_tag_content;
Tags = space* (Tag space*)+ EOL+;
StartRow = space* '|' >start_row;
EndRow = EOL space* ^('|') >next_keyword_start;
Cell = '|' (any - '|')* >begin_cell_content %store_cell_content;
RowBody = space* Cell* '|' :>> (space* EOL+ space*) %store_row;
Row = StartRow :>> RowBody <: EndRow?;
StartPyString = '"""' >start_pystring space* :>> EOL;
EndPyString = (space* '"""') >next_keyword_start;
PyString = space* StartPyString %begin_pystring_content (^EOL | EOL)* :>> EndPyString %store_pystring_content space* EOL+;
Tokens = (space | EOL)* (Tags | Comment | FeatureHeading | BackgroundHeading | ScenarioHeading | ScenarioOutlineHeading | ExamplesHeading | Step | Row | PyString)* (space | EOL)* EOF;
main := Tokens %end_feature @!end_feature;
}%%