%%{ 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 = ('\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+; StartTable = space* '|' >start_table; EndTable = EOL space* ^('|') >next_keyword_start; Cell = '|' (any - '|')* >begin_cell_content %store_cell_content; Row = space* Cell* >start_row '|' :>> (space* EOL+ space*) %store_row; Table = StartTable :>> Row+ %store_table <: EndTable?; 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 | Table | PyString)* (space | EOL)* EOF; main := Tokens %end_feature @!end_feature; }%%