From b55b1706f3d6a12e97dbb0694a2473863371ffe1 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 28 Apr 2023 17:57:34 +0200 Subject: [PATCH 01/76] chore: adding cpp implementation --- cpp/gherkin-cpp-rules.razor | 14 ++ cpp/gherkin-cpp.razor | 284 ++++++++++++++++++++++++++ cpp/include/gherkin/file.hpp | 12 ++ cpp/include/gherkin/line.hpp | 16 ++ cpp/include/gherkin/location.hpp | 0 cpp/include/gherkin/parser.hpp | 17 ++ cpp/include/gherkin/token.hpp | 26 +++ cpp/include/gherkin/token_scanner.hpp | 39 ++++ cpp/src/gherkin/token.cpp | 13 ++ cpp/src/gherkin/token_scanner.cpp | 56 +++++ 10 files changed, 477 insertions(+) create mode 100644 cpp/gherkin-cpp-rules.razor create mode 100644 cpp/gherkin-cpp.razor create mode 100644 cpp/include/gherkin/file.hpp create mode 100644 cpp/include/gherkin/line.hpp create mode 100644 cpp/include/gherkin/location.hpp create mode 100644 cpp/include/gherkin/parser.hpp create mode 100644 cpp/include/gherkin/token.hpp create mode 100644 cpp/include/gherkin/token_scanner.hpp create mode 100644 cpp/src/gherkin/token.cpp create mode 100644 cpp/src/gherkin/token_scanner.cpp diff --git a/cpp/gherkin-cpp-rules.razor b/cpp/gherkin-cpp-rules.razor new file mode 100644 index 000000000..d917784f9 --- /dev/null +++ b/cpp/gherkin-cpp-rules.razor @@ -0,0 +1,14 @@ +// This file is generated. Do not edit! Edit gherkin-cpp-rules.razor instead. +#pragma once + +namespace gherkin { + +enum class rule { + None = 0, + @foreach(var rule in Model.RuleSet.Where(r => !r.TempRule)) + { @rule.Name.Replace("#", ""), /* @rule.ToString(true) */ +} + Count +}; + +} diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor new file mode 100644 index 000000000..9af955e86 --- /dev/null +++ b/cpp/gherkin-cpp.razor @@ -0,0 +1,284 @@ +@using Berp; +@helper CallProduction(ProductionRule production) +{ + switch(production.Type) + { + case ProductionRuleType.Start: + @: start_rule(context, Rule_@production.RuleName); + break; + case ProductionRuleType.End: + @: end_rule(context, Rule_@production.RuleName); + break; + case ProductionRuleType.Process: + @: build(context, token); + break; + } +} +@helper HandleParserError(IEnumerable expectedTokens, State state) +{ + /* "State: @state.Id - @Raw(state.Comment)" */ + std::string expected_tokens = L"@Raw(string.Join(", ", expectedTokens))"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return @state.Id;} +@helper MatchToken(TokenType tokenType) +{match_@(tokenType)(context, token)} +// This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. +#include +#include +#include +//#include + +namespace gherkin { + +struct ParserContext { + bool stop_at_first_error; + TokenScanner* token_scanner; + TokenMatcher* token_matcher; + Builder* builder; + TokenQueue* token_queue; + ErrorList* errors; +} ParserContext; + +struct @Model.ParserClassName { + ParserContext* parser_context; + Builder* builder; + ErrorList* errors; +}; + +static Token* read_token(ParserContext* context); + +static void start_rule(ParserContext* context, RuleType rule_type); + +static void end_rule(ParserContext* context, RuleType rule_type); + +static int match_token(int state, Token* token, ParserContext* context); + +ParserContext* ParserContext_new(TokenScanner* token_scanner, TokenMatcher* token_matcher, Builder* builder, TokenQueue* token_queue, ErrorList* errors) { + ParserContext* parser_context = (ParserContext*)malloc(sizeof(ParserContext)); + parser_context->stop_at_first_error = false; + parser_context->token_scanner = token_scanner; + parser_context->token_matcher = token_matcher; + parser_context->builder = builder; + parser_context->token_queue = token_queue; + parser_context->errors = errors; + return parser_context; +} + +void ParserContext_delete(ParserContext* parser_context) { + free((void*)parser_context); +} + +@Model.ParserClassName* @(Model.ParserClassName)_new(Builder* builder) { + @Model.ParserClassName* parser = (Parser*)malloc(sizeof(@Model.ParserClassName)); + parser->parser_context = 0; + parser->builder = builder; + parser->errors = ErrorList_new(); + return parser; +} + +void @(Model.ParserClassName)_delete(@Model.ParserClassName* parser) { + if (parser->errors) { + ErrorList_delete(parser->errors); + } + if (parser->parser_context) { + ParserContext_delete(parser->parser_context); + } + free((void*)parser); +} + +int @(Model.ParserClassName)_parse(@Model.ParserClassName* parser, TokenMatcher* token_matcher, TokenScanner* token_scanner) { + parser->builder->reset(parser->builder); + parser->builder->set_error_context(parser->builder, parser->errors); + token_matcher->reset(token_matcher); + token_matcher->errors = parser->errors; + TokenQueue* token_queue = TokenQueue_new(); + ParserContext* context = ParserContext_new(token_scanner, token_matcher, parser->builder, token_queue, parser->errors); + + int val = 0; + jmp_buf env; + val = setjmp(env); + ErrorList_set_global_rescue_env(parser->errors, &env); + + if (val == 0) { + start_rule(context, Rule_@Model.RuleSet.StartRule.Name); + int state = 0; + bool token_is_eof; + Token* token = 0; + do { + token = read_token(context); + token_is_eof = Token_is_eof(token); + state = match_token(state, token, context); + } while (!token_is_eof); + + end_rule(context, Rule_@Model.RuleSet.StartRule.Name); + } + + int result_code = ErrorList_is_empty(context->errors) ? 0 : 1; + + ParserContext_delete(context); + TokenQueue_delete(token_queue); + return result_code; +} +bool Parser_has_more_errors(Parser* parser) { + return ErrorList_has_more_errors(parser->errors); +} + +Error* Parser_next_error(Parser* parser) { + return ErrorList_next_error(parser->errors); +} + +static Token* read_token(ParserContext* context) { + if (!TokenQueue_is_empty(context->token_queue)) + return TokenQueue_remove(context->token_queue); + else + return context->token_scanner->read(context->token_scanner); +} + +static void build(ParserContext* context, Token* token) { + context->builder->build(context->builder, token); +} + +static void handle_ast_error(ParserContext* context, RuleType rule_type, rule_function action) { + if (context->stop_at_first_error) { + action(context->builder, rule_type); + return; + } + + jmp_buf env; + int val = setjmp(env); + ErrorList_set_local_rescue_env(context->errors, &env); + if (val == 0) { + action(context->builder, rule_type); + } +} + +static void start_rule(ParserContext* context, RuleType rule_type) { + handle_ast_error(context, rule_type, context->builder->start_rule); +} + +static void end_rule(ParserContext* context, RuleType rule_type) { + handle_ast_error(context, rule_type, context->builder->end_rule); +} + +static bool handle_external_error(ParserContext* context, Token* token, match_function action) { + if (context->stop_at_first_error) { + return action(context->token_matcher, token); + } + + jmp_buf env; + int val = setjmp(env); + ErrorList_set_local_rescue_env(context->errors, &env); + if (val == 0) { + return action(context->token_matcher, token); + } + return false; +} + +@foreach(var rule in Model.RuleSet.TokenRules) +{ +static bool match_@(rule.Name.Replace("#", ""))(ParserContext* context, Token* token) { + @if (rule.Name != "#EOF") + { + @:if (token->matched_type == Token_EOF) { + @: return false; + @:}; + } + @if (rule.Name != "#TagLine") + { + @:return handle_external_error(context, token, context->token_matcher->match_@(rule.Name.Replace("#", ""))); + } + @if (rule.Name == "#TagLine") + { + @:bool match_result = handle_external_error(context, token, context->token_matcher->match_TagLine); + @:if (match_result) { + @: bool tag_error = ErrorList_check_token_tags_for_whitespace(context->errors, token); + @: if (tag_error && context->stop_at_first_error) { + @: ErrorList_jump_to_global_rescue_env(context->errors); + @: } + @:} + @:return match_result; + } +} +} + +@foreach(var lookAheadHint in Model.RuleSet.LookAheadHints) +{ + +static bool lookahead_@(lookAheadHint.Id)(ParserContext* context) { + Token* token = 0; + TokenQueue* queue = TokenQueue_new(); + bool match = false; + while (true) { + token = read_token(context); + TokenQueue_add(queue, token); + + if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {@MatchToken(tokenType) || }false) { + match = true; + break; + } + + if (!(@foreach(var tokenType in lookAheadHint.Skip) {@MatchToken(tokenType) || }false)) { + break; + } + } + + TokenQueue_extend(context->token_queue, queue); + + return match; +} + +} + +@foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) +{ +/* @Raw(state.Comment) */ +static int match_token_at_@(state.Id)(Token* token, ParserContext* context) { + @foreach(var transition in state.Transitions) + { + @:if (@MatchToken(transition.TokenType)) { + if (transition.LookAheadHint != null) + { + @:if (lookahead_@(transition.LookAheadHint.Id)(context)) { + } + foreach(var production in transition.Productions) + { + @CallProduction(production) + } + @:return @transition.TargetState; + if (transition.LookAheadHint != null) + { + @:} + } + @:} + } + @HandleParserError(state.Transitions.Select(t => "#" + t.TokenType.ToString()).Distinct(), state) +} +} + +static int match_token(int state, Token* token, ParserContext* context) { + switch (state) { + @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) + { + @:case @state.Id: + @:return match_token_at_@(state.Id)(token, context); + } + default: + ErrorList_add_invalid_operation_error(context->errors, state); + ErrorList_jump_to_global_rescue_env(context->errors); + return -1; + } +} + +} diff --git a/cpp/include/gherkin/file.hpp b/cpp/include/gherkin/file.hpp new file mode 100644 index 000000000..e616e0c6c --- /dev/null +++ b/cpp/include/gherkin/file.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace gherkin { + +struct file +{ + std::string path; +}; + +} diff --git a/cpp/include/gherkin/line.hpp b/cpp/include/gherkin/line.hpp new file mode 100644 index 000000000..6273bc615 --- /dev/null +++ b/cpp/include/gherkin/line.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +namespace gherkin { + +struct line +{ + std::string text; + std::size_t number; + std::size_t indent; + std::string trimmed_text; +}; + +} diff --git a/cpp/include/gherkin/location.hpp b/cpp/include/gherkin/location.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp new file mode 100644 index 000000000..760b951d9 --- /dev/null +++ b/cpp/include/gherkin/parser.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace gherkin { + +class parser +{ +public: + parser(); + virtual ~parser(); + +private: + token_scanner s_; +}; + +} diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp new file mode 100644 index 000000000..6a72261e6 --- /dev/null +++ b/cpp/include/gherkin/token.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +#include + +namespace gherkin { + +struct token { + line line; + std::size_t location: + std::string type; + std::string keyword; + std::string keyword_type; + std::string indent; + std::string items; + std::string text; + std::string gherkin_dialect; + + bool is_eof() const; + + std::string_view value() const; +}; + +} diff --git a/cpp/include/gherkin/token_scanner.hpp b/cpp/include/gherkin/token_scanner.hpp new file mode 100644 index 000000000..18918628f --- /dev/null +++ b/cpp/include/gherkin/token_scanner.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include +#include + +#include +#include +#include + +namespace gherkin { + +struct next_line_result +{ + bool has_line = false; + std::string text; +}; + +class token_scanner +{ +public: + token_scanner(const std::string& text); + token_scanner(const file& file); + + virtual ~token_scanner(); + + token read(); + +private: + next_line_result next_line(); + + std::istream& input(); + + using input_ptr = std::unique_ptr; + + std::size_t line_ = 0; + input_ptr ip_; +}; + +} diff --git a/cpp/src/gherkin/token.cpp b/cpp/src/gherkin/token.cpp new file mode 100644 index 000000000..bc060dabc --- /dev/null +++ b/cpp/src/gherkin/token.cpp @@ -0,0 +1,13 @@ +#include + +namespace gherkin { + +bool +token::is_eof() const +{ return line.empty(); } + +std::string_view +token::value() const +{ return line.text(); } + +} diff --git a/cpp/src/gherkin/token_scanner.cpp b/cpp/src/gherkin/token_scanner.cpp new file mode 100644 index 000000000..00013642a --- /dev/null +++ b/cpp/src/gherkin/token_scanner.cpp @@ -0,0 +1,56 @@ +#include + +namespace gherkin { + +token_scanner::token_scanner(const std::string& text) +: ip_(std::make_unique(text)) +{} + +token_scanner::token_scanner(const file& file) +: ip_(std::make_unique(file.path)) +{} + +token_scanner::~token_scanner() +{} + +token +token_scanner::read() +{ + auto r = next_line(); + + if (r.has_line) { + $line =~ s/\r$//; # \n as well as \r\n are considered lines separators + $line_token = + Gherkin::Line->new( + { line_text => $line, line_number => $line_number } + ); + } + return Gherkin::Token->new(line => $line_token, location => $location); +} + +next_line_result +token_scanner::next_line() +{ + next_line_result r; + + if (ip_) { + return r; + } + + input >> r.text; + line_++; + + r.has_line = !r.text.empty(); + + if (!r.has_line) { + ip_.reset(); + } + + return r; +} + +std::istream& +token_scanner::input() +{ return *ip_; } + +} From 70a41a3d1297f0a370f6692f707a73a20dfb1472 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sat, 29 Apr 2023 18:23:30 +0200 Subject: [PATCH 02/76] chore: i18n OK --- cpp/Makefile | 76 + cpp/gherkin-cpp-rules.razor | 14 - cpp/gherkin-cpp.razor | 248 +- cpp/gherkin-i18n.cpp.jq | 45 + cpp/include/gherkin/ast_builder.hpp | 10 + cpp/include/gherkin/i18n.hpp | 16 + cpp/include/gherkin/parser.hpp | 14 +- cpp/include/gherkin/token_scanner.hpp | 8 + cpp/include/gherkin/types.hpp | 20 + cpp/src/gherkin/i18n.cpp | 1283 ++++++++ cpp/src/gherkin/parser.cpp | 4338 +++++++++++++++++++++++++ cpp/src/gherkin/token_scanner.cpp | 21 +- 12 files changed, 5838 insertions(+), 255 deletions(-) create mode 100644 cpp/Makefile delete mode 100644 cpp/gherkin-cpp-rules.razor create mode 100644 cpp/gherkin-i18n.cpp.jq create mode 100644 cpp/include/gherkin/ast_builder.hpp create mode 100644 cpp/include/gherkin/i18n.hpp create mode 100644 cpp/include/gherkin/types.hpp create mode 100644 cpp/src/gherkin/i18n.cpp create mode 100644 cpp/src/gherkin/parser.cpp diff --git a/cpp/Makefile b/cpp/Makefile new file mode 100644 index 000000000..1ff5c0977 --- /dev/null +++ b/cpp/Makefile @@ -0,0 +1,76 @@ +SHELL := /usr/bin/env bash + +GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json +GHERKIN_I18N = src/gherkin/i18n.cpp +GHERKIN_PARSER = src/gherkin/parser.cpp +GHERKIN_RAZOR = gherkin-cpp.razor + +GHERKIN = bin/gherkin +GHERKIN_GENERATE_TOKENS = bin/gherkin-generate-tokens + +GOOD_FEATURE_FILES = $(shell find ../testdata/good -name "*.feature") +BAD_FEATURE_FILES = $(shell find ../testdata/bad -name "*.feature") + +TOKENS = $(patsubst ../testdata/%,acceptance/testdata/%.tokens,$(GOOD_FEATURE_FILES)) +ASTS = $(patsubst ../testdata/%,acceptance/testdata/%.ast.ndjson,$(GOOD_FEATURE_FILES)) +PICKLES = $(patsubst ../testdata/%,acceptance/testdata/%.pickles.ndjson,$(GOOD_FEATURE_FILES)) +SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GOOD_FEATURE_FILES)) +ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES)) + +.DEFAULT_GOAL = help + +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +generate: $(GHERKIN_PARSER) $(GHERKIN_I18N) ## Generate gherkin parser files + +clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files + rm -f $(GHERKIN_PARSER) $(GHERKIN_I18N) + +copy-gherkin-languages: $(GHERKIN_LANGUAGES_JSON) ## Copy gherkin-languages.json and/or generate derived files + echo "Nothing to do" + +clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files + rm -f $(GHERKIN_LANGUAGES_JSON) + +clean: ## Remove all build artifacts and files generated by the acceptance tests + rm -f .built + rm -rf acceptance + +.DELETE_ON_ERROR: + +acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference + +.built: $(SOURCE_FILES) + touch $@ + +$(GHERKIN_PARSER): $(GHERKIN_RAZOR) ../gherkin.berp + berp -g ../gherkin.berp -t $< -o $@ --noBOM + +$(GHERKIN_I18N): $(GHERKIN_LANGUAGES_JSON) + jq -f gherkin-i18n.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ + +acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens + mkdir -p $(@D) + $(GHERKIN_GENERATE_TOKENS) $< > $@ + diff --unified $<.tokens $@ + +acceptance/testdata/%.ast.ndjson: ../testdata/% ../testdata/%.ast.ndjson + mkdir -p $(@D) + $(GHERKIN) --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $@ + diff --unified <(jq "." $<.ast.ndjson) <(jq "." $@) + +acceptance/testdata/%.pickles.ndjson: ../testdata/% ../testdata/%.pickles.ndjson + mkdir -p $(@D) + $(GHERKIN) --no-source --no-ast $< | jq --sort-keys --compact-output "." > $@ + diff --unified <(jq "." $<.pickles.ndjson) <(jq "." $@) + +acceptance/testdata/%.source.ndjson: ../testdata/% ../testdata/%.source.ndjson + mkdir -p $(@D) + $(GHERKIN) --no-ast --no-pickles $< | jq --sort-keys --compact-output "." > $@ + diff --unified <(jq "." $<.source.ndjson) <(jq "." $@) + +acceptance/testdata/%.errors.ndjson: ../testdata/% ../testdata/%.errors.ndjson + mkdir -p $(@D) + $(GHERKIN) --no-source $< | jq --sort-keys --compact-output "." > $@ + diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@) diff --git a/cpp/gherkin-cpp-rules.razor b/cpp/gherkin-cpp-rules.razor deleted file mode 100644 index d917784f9..000000000 --- a/cpp/gherkin-cpp-rules.razor +++ /dev/null @@ -1,14 +0,0 @@ -// This file is generated. Do not edit! Edit gherkin-cpp-rules.razor instead. -#pragma once - -namespace gherkin { - -enum class rule { - None = 0, - @foreach(var rule in Model.RuleSet.Where(r => !r.TempRule)) - { @rule.Name.Replace("#", ""), /* @rule.ToString(true) */ -} - Count -}; - -} diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index 9af955e86..ddcb38db0 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -36,249 +36,27 @@ {match_@(tokenType)(context, token)} // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. #include -#include #include //#include namespace gherkin { -struct ParserContext { - bool stop_at_first_error; - TokenScanner* token_scanner; - TokenMatcher* token_matcher; - Builder* builder; - TokenQueue* token_queue; - ErrorList* errors; -} ParserContext; - -struct @Model.ParserClassName { - ParserContext* parser_context; - Builder* builder; - ErrorList* errors; +enum class rule_type { + None = 0, + @foreach(var rule in Model.RuleSet.Where(r => !r.TempRule)) + { @rule.Name.Replace("#", ""), +} + Count }; -static Token* read_token(ParserContext* context); - -static void start_rule(ParserContext* context, RuleType rule_type); - -static void end_rule(ParserContext* context, RuleType rule_type); - -static int match_token(int state, Token* token, ParserContext* context); - -ParserContext* ParserContext_new(TokenScanner* token_scanner, TokenMatcher* token_matcher, Builder* builder, TokenQueue* token_queue, ErrorList* errors) { - ParserContext* parser_context = (ParserContext*)malloc(sizeof(ParserContext)); - parser_context->stop_at_first_error = false; - parser_context->token_scanner = token_scanner; - parser_context->token_matcher = token_matcher; - parser_context->builder = builder; - parser_context->token_queue = token_queue; - parser_context->errors = errors; - return parser_context; -} - -void ParserContext_delete(ParserContext* parser_context) { - free((void*)parser_context); -} - -@Model.ParserClassName* @(Model.ParserClassName)_new(Builder* builder) { - @Model.ParserClassName* parser = (Parser*)malloc(sizeof(@Model.ParserClassName)); - parser->parser_context = 0; - parser->builder = builder; - parser->errors = ErrorList_new(); - return parser; -} - -void @(Model.ParserClassName)_delete(@Model.ParserClassName* parser) { - if (parser->errors) { - ErrorList_delete(parser->errors); - } - if (parser->parser_context) { - ParserContext_delete(parser->parser_context); - } - free((void*)parser); -} - -int @(Model.ParserClassName)_parse(@Model.ParserClassName* parser, TokenMatcher* token_matcher, TokenScanner* token_scanner) { - parser->builder->reset(parser->builder); - parser->builder->set_error_context(parser->builder, parser->errors); - token_matcher->reset(token_matcher); - token_matcher->errors = parser->errors; - TokenQueue* token_queue = TokenQueue_new(); - ParserContext* context = ParserContext_new(token_scanner, token_matcher, parser->builder, token_queue, parser->errors); - - int val = 0; - jmp_buf env; - val = setjmp(env); - ErrorList_set_global_rescue_env(parser->errors, &env); - - if (val == 0) { - start_rule(context, Rule_@Model.RuleSet.StartRule.Name); - int state = 0; - bool token_is_eof; - Token* token = 0; - do { - token = read_token(context); - token_is_eof = Token_is_eof(token); - state = match_token(state, token, context); - } while (!token_is_eof); - - end_rule(context, Rule_@Model.RuleSet.StartRule.Name); - } - - int result_code = ErrorList_is_empty(context->errors) ? 0 : 1; - - ParserContext_delete(context); - TokenQueue_delete(token_queue); - return result_code; -} -bool Parser_has_more_errors(Parser* parser) { - return ErrorList_has_more_errors(parser->errors); -} - -Error* Parser_next_error(Parser* parser) { - return ErrorList_next_error(parser->errors); -} - -static Token* read_token(ParserContext* context) { - if (!TokenQueue_is_empty(context->token_queue)) - return TokenQueue_remove(context->token_queue); - else - return context->token_scanner->read(context->token_scanner); -} - -static void build(ParserContext* context, Token* token) { - context->builder->build(context->builder, token); -} - -static void handle_ast_error(ParserContext* context, RuleType rule_type, rule_function action) { - if (context->stop_at_first_error) { - action(context->builder, rule_type); - return; - } - - jmp_buf env; - int val = setjmp(env); - ErrorList_set_local_rescue_env(context->errors, &env); - if (val == 0) { - action(context->builder, rule_type); - } -} - -static void start_rule(ParserContext* context, RuleType rule_type) { - handle_ast_error(context, rule_type, context->builder->start_rule); -} - -static void end_rule(ParserContext* context, RuleType rule_type) { - handle_ast_error(context, rule_type, context->builder->end_rule); -} - -static bool handle_external_error(ParserContext* context, Token* token, match_function action) { - if (context->stop_at_first_error) { - return action(context->token_matcher, token); - } - - jmp_buf env; - int val = setjmp(env); - ErrorList_set_local_rescue_env(context->errors, &env); - if (val == 0) { - return action(context->token_matcher, token); - } - return false; -} - -@foreach(var rule in Model.RuleSet.TokenRules) -{ -static bool match_@(rule.Name.Replace("#", ""))(ParserContext* context, Token* token) { - @if (rule.Name != "#EOF") - { - @:if (token->matched_type == Token_EOF) { - @: return false; - @:}; - } - @if (rule.Name != "#TagLine") - { - @:return handle_external_error(context, token, context->token_matcher->match_@(rule.Name.Replace("#", ""))); - } - @if (rule.Name == "#TagLine") - { - @:bool match_result = handle_external_error(context, token, context->token_matcher->match_TagLine); - @:if (match_result) { - @: bool tag_error = ErrorList_check_token_tags_for_whitespace(context->errors, token); - @: if (tag_error && context->stop_at_first_error) { - @: ErrorList_jump_to_global_rescue_env(context->errors); - @: } - @:} - @:return match_result; - } -} -} +parser::parser(const parser_info& pi) +: pi_{pi} +{} -@foreach(var lookAheadHint in Model.RuleSet.LookAheadHints) +int +parser::parse(const file& file) { - -static bool lookahead_@(lookAheadHint.Id)(ParserContext* context) { - Token* token = 0; - TokenQueue* queue = TokenQueue_new(); - bool match = false; - while (true) { - token = read_token(context); - TokenQueue_add(queue, token); - - if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {@MatchToken(tokenType) || }false) { - match = true; - break; - } - - if (!(@foreach(var tokenType in lookAheadHint.Skip) {@MatchToken(tokenType) || }false)) { - break; - } - } - - TokenQueue_extend(context->token_queue, queue); - - return match; -} - -} - -@foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) -{ -/* @Raw(state.Comment) */ -static int match_token_at_@(state.Id)(Token* token, ParserContext* context) { - @foreach(var transition in state.Transitions) - { - @:if (@MatchToken(transition.TokenType)) { - if (transition.LookAheadHint != null) - { - @:if (lookahead_@(transition.LookAheadHint.Id)(context)) { - } - foreach(var production in transition.Productions) - { - @CallProduction(production) - } - @:return @transition.TargetState; - if (transition.LookAheadHint != null) - { - @:} - } - @:} - } - @HandleParserError(state.Transitions.Select(t => "#" + t.TokenType.ToString()).Distinct(), state) -} -} - -static int match_token(int state, Token* token, ParserContext* context) { - switch (state) { - @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) - { - @:case @state.Id: - @:return match_token_at_@(state.Id)(token, context); - } - default: - ErrorList_add_invalid_operation_error(context->errors, state); - ErrorList_jump_to_global_rescue_env(context->errors); - return -1; - } -} + ts_.reset(file); + return 0; } diff --git a/cpp/gherkin-i18n.cpp.jq b/cpp/gherkin-i18n.cpp.jq new file mode 100644 index 000000000..36e42c065 --- /dev/null +++ b/cpp/gherkin-i18n.cpp.jq @@ -0,0 +1,45 @@ +. as $root | +[ + "#include \n\n", + "namespace gherkin {\n\n", + "const keywords_map&\n", + "keywords(const std::string_view& language)\n", + "{\n", + " const keywords_maps kwms = {\n", + " ", + ( + [ + to_entries[] | .key as $lang_orig | + (.key | split("-") | join("_")) as $lang | .value | + [ + ("{\n \"",$lang,"\",\n {\n"), + (" "), + ( + [ + { + "and", "background", "but", "examples", "feature", "given", + "rule", "scenario", "scenarioOutline", "then", "when" + } | to_entries[] | + [ + "{ \"", .key, "\", { ", + ( + [.value[] | + sub("^[[:space:]]+"; "") | sub("[[:space:]]+$"; "") | + [@json] | add] | join(", ") + ), + " } }" + ] | add + ] | join(",\n ") + ), + ("\n }\n }") + ] | add + ] | join(",\n ") + ), + "\n };\n\n", + " return kwms.at(language);\n", + "}\n\n", + "const string_views&\n", + "keyword(const std::string_view& language, const std::string_view& kw)\n", + "{ return keywords(language).at(kw); }\n\n", + "}\n" +] | add diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp new file mode 100644 index 000000000..34796cfd0 --- /dev/null +++ b/cpp/include/gherkin/ast_builder.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace gherkin { + +class ast_builder +{ + +}; + +} diff --git a/cpp/include/gherkin/i18n.hpp b/cpp/include/gherkin/i18n.hpp new file mode 100644 index 000000000..b922b7c54 --- /dev/null +++ b/cpp/include/gherkin/i18n.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace gherkin { + +using keywords_map = std::unordered_map; +using keywords_maps = std::unordered_map; + +const keywords_map& +keywords(const std::string_view& language); + +const string_views& +keywords(const std::string_view& language, const std::string_view& kw); + +} diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index 760b951d9..fab03e2be 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,17 +1,27 @@ #pragma once +#include #include namespace gherkin { +struct parser_info +{ + ast_builer& builder; + std::string language = "en"; +}; + class parser { public: - parser(); + parser(const parser_info& pi); virtual ~parser(); + v + private: - token_scanner s_; + parser_info pi_; + token_scanner ts_; }; } diff --git a/cpp/include/gherkin/token_scanner.hpp b/cpp/include/gherkin/token_scanner.hpp index 18918628f..fcc58dc5b 100644 --- a/cpp/include/gherkin/token_scanner.hpp +++ b/cpp/include/gherkin/token_scanner.hpp @@ -18,14 +18,22 @@ struct next_line_result class token_scanner { public: + token_scanner(); token_scanner(const std::string& text); token_scanner(const file& file); virtual ~token_scanner(); + void reset(const std::string& text); + void reset(const file& file); + + token_scanner(const file& file); + token read(); private: + void reset(); + next_line_result next_line(); std::istream& input(); diff --git a/cpp/include/gherkin/types.hpp b/cpp/include/gherkin/types.hpp new file mode 100644 index 000000000..c6d975fa5 --- /dev/null +++ b/cpp/include/gherkin/types.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace gherkin { + +using strings = std::vector; +using strings_map = std::unordered_map; +using string_set = std::set; +using string_set_map = std::unordered_map; +using string_map = std::unordered_map; + +using string_views = std::vector; +using string_view_set = std::set; + +} diff --git a/cpp/src/gherkin/i18n.cpp b/cpp/src/gherkin/i18n.cpp new file mode 100644 index 000000000..0284f54b4 --- /dev/null +++ b/cpp/src/gherkin/i18n.cpp @@ -0,0 +1,1283 @@ +#include + +namespace gherkin { + +const keywords_map& +keywords(const std::string_view& language) +{ + const keywords_maps kwms = { + { + "af", + { + { "and", { "*", "En" } }, + { "background", { "Agtergrond" } }, + { "but", { "*", "Maar" } }, + { "examples", { "Voorbeelde" } }, + { "feature", { "Funksie", "Besigheid Behoefte", "Vermoë" } }, + { "given", { "*", "Gegewe" } }, + { "rule", { "Regel" } }, + { "scenario", { "Voorbeeld", "Situasie" } }, + { "scenarioOutline", { "Situasie Uiteensetting" } }, + { "then", { "*", "Dan" } }, + { "when", { "*", "Wanneer" } } + } + }, + { + "am", + { + { "and", { "*", "Եվ" } }, + { "background", { "Կոնտեքստ" } }, + { "but", { "*", "Բայց" } }, + { "examples", { "Օրինակներ" } }, + { "feature", { "Ֆունկցիոնալություն", "Հատկություն" } }, + { "given", { "*", "Դիցուք" } }, + { "rule", { "Rule" } }, + { "scenario", { "Օրինակ", "Սցենար" } }, + { "scenarioOutline", { "Սցենարի կառուցվացքը" } }, + { "then", { "*", "Ապա" } }, + { "when", { "*", "Եթե", "Երբ" } } + } + }, + { + "an", + { + { "and", { "*", "Y", "E" } }, + { "background", { "Antecedents" } }, + { "but", { "*", "Pero" } }, + { "examples", { "Eixemplos" } }, + { "feature", { "Caracteristica" } }, + { "given", { "*", "Dau", "Dada", "Daus", "Dadas" } }, + { "rule", { "Rule" } }, + { "scenario", { "Eixemplo", "Caso" } }, + { "scenarioOutline", { "Esquema del caso" } }, + { "then", { "*", "Alavez", "Allora", "Antonces" } }, + { "when", { "*", "Cuan" } } + } + }, + { + "ar", + { + { "and", { "*", "و" } }, + { "background", { "الخلفية" } }, + { "but", { "*", "لكن" } }, + { "examples", { "امثلة" } }, + { "feature", { "خاصية" } }, + { "given", { "*", "بفرض" } }, + { "rule", { "Rule" } }, + { "scenario", { "مثال", "سيناريو" } }, + { "scenarioOutline", { "سيناريو مخطط" } }, + { "then", { "*", "اذاً", "ثم" } }, + { "when", { "*", "متى", "عندما" } } + } + }, + { + "ast", + { + { "and", { "*", "Y", "Ya" } }, + { "background", { "Antecedentes" } }, + { "but", { "*", "Peru" } }, + { "examples", { "Exemplos" } }, + { "feature", { "Carauterística" } }, + { "given", { "*", "Dáu", "Dada", "Daos", "Daes" } }, + { "rule", { "Rule" } }, + { "scenario", { "Exemplo", "Casu" } }, + { "scenarioOutline", { "Esbozu del casu" } }, + { "then", { "*", "Entós" } }, + { "when", { "*", "Cuando" } } + } + }, + { + "az", + { + { "and", { "*", "Və", "Həm" } }, + { "background", { "Keçmiş", "Kontekst" } }, + { "but", { "*", "Amma", "Ancaq" } }, + { "examples", { "Nümunələr" } }, + { "feature", { "Özəllik" } }, + { "given", { "*", "Tutaq ki", "Verilir" } }, + { "rule", { "Rule" } }, + { "scenario", { "Nümunə", "Ssenari" } }, + { "scenarioOutline", { "Ssenarinin strukturu" } }, + { "then", { "*", "O halda" } }, + { "when", { "*", "Əgər", "Nə vaxt ki" } } + } + }, + { + "be", + { + { "and", { "*", "I", "Ды", "Таксама" } }, + { "background", { "Кантэкст" } }, + { "but", { "*", "Але", "Інакш" } }, + { "examples", { "Прыклады" } }, + { "feature", { "Функцыянальнасць", "Фіча" } }, + { "given", { "*", "Няхай", "Дадзена" } }, + { "rule", { "Правілы" } }, + { "scenario", { "Сцэнарый", "Cцэнар" } }, + { "scenarioOutline", { "Шаблон сцэнарыя", "Узор сцэнара" } }, + { "then", { "*", "Тады" } }, + { "when", { "*", "Калі" } } + } + }, + { + "bg", + { + { "and", { "*", "И" } }, + { "background", { "Предистория" } }, + { "but", { "*", "Но" } }, + { "examples", { "Примери" } }, + { "feature", { "Функционалност" } }, + { "given", { "*", "Дадено" } }, + { "rule", { "Правило" } }, + { "scenario", { "Пример", "Сценарий" } }, + { "scenarioOutline", { "Рамка на сценарий" } }, + { "then", { "*", "То" } }, + { "when", { "*", "Когато" } } + } + }, + { + "bm", + { + { "and", { "*", "Dan" } }, + { "background", { "Latar Belakang" } }, + { "but", { "*", "Tetapi", "Tapi" } }, + { "examples", { "Contoh" } }, + { "feature", { "Fungsi" } }, + { "given", { "*", "Diberi", "Bagi" } }, + { "rule", { "Rule" } }, + { "scenario", { "Senario", "Situasi", "Keadaan" } }, + { "scenarioOutline", { "Kerangka Senario", "Kerangka Situasi", "Kerangka Keadaan", "Garis Panduan Senario" } }, + { "then", { "*", "Maka", "Kemudian" } }, + { "when", { "*", "Apabila" } } + } + }, + { + "bs", + { + { "and", { "*", "I", "A" } }, + { "background", { "Pozadina" } }, + { "but", { "*", "Ali" } }, + { "examples", { "Primjeri" } }, + { "feature", { "Karakteristika" } }, + { "given", { "*", "Dato" } }, + { "rule", { "Rule" } }, + { "scenario", { "Primjer", "Scenariju", "Scenario" } }, + { "scenarioOutline", { "Scenariju-obris", "Scenario-outline" } }, + { "then", { "*", "Zatim" } }, + { "when", { "*", "Kada" } } + } + }, + { + "ca", + { + { "and", { "*", "I" } }, + { "background", { "Rerefons", "Antecedents" } }, + { "but", { "*", "Però" } }, + { "examples", { "Exemples" } }, + { "feature", { "Característica", "Funcionalitat" } }, + { "given", { "*", "Donat", "Donada", "Atès", "Atesa" } }, + { "rule", { "Rule" } }, + { "scenario", { "Exemple", "Escenari" } }, + { "scenarioOutline", { "Esquema de l'escenari" } }, + { "then", { "*", "Aleshores", "Cal" } }, + { "when", { "*", "Quan" } } + } + }, + { + "cs", + { + { "and", { "*", "A také", "A" } }, + { "background", { "Pozadí", "Kontext" } }, + { "but", { "*", "Ale" } }, + { "examples", { "Příklady" } }, + { "feature", { "Požadavek" } }, + { "given", { "*", "Pokud", "Za předpokladu" } }, + { "rule", { "Pravidlo" } }, + { "scenario", { "Příklad", "Scénář" } }, + { "scenarioOutline", { "Náčrt Scénáře", "Osnova scénáře" } }, + { "then", { "*", "Pak" } }, + { "when", { "*", "Když" } } + } + }, + { + "cy_GB", + { + { "and", { "*", "A" } }, + { "background", { "Cefndir" } }, + { "but", { "*", "Ond" } }, + { "examples", { "Enghreifftiau" } }, + { "feature", { "Arwedd" } }, + { "given", { "*", "Anrhegedig a" } }, + { "rule", { "Rule" } }, + { "scenario", { "Enghraifft", "Scenario" } }, + { "scenarioOutline", { "Scenario Amlinellol" } }, + { "then", { "*", "Yna" } }, + { "when", { "*", "Pryd" } } + } + }, + { + "da", + { + { "and", { "*", "Og" } }, + { "background", { "Baggrund" } }, + { "but", { "*", "Men" } }, + { "examples", { "Eksempler" } }, + { "feature", { "Egenskab" } }, + { "given", { "*", "Givet" } }, + { "rule", { "Rule" } }, + { "scenario", { "Eksempel", "Scenarie" } }, + { "scenarioOutline", { "Abstrakt Scenario" } }, + { "then", { "*", "Så" } }, + { "when", { "*", "Når" } } + } + }, + { + "de", + { + { "and", { "*", "Und" } }, + { "background", { "Grundlage", "Hintergrund", "Voraussetzungen", "Vorbedingungen" } }, + { "but", { "*", "Aber" } }, + { "examples", { "Beispiele" } }, + { "feature", { "Funktionalität", "Funktion" } }, + { "given", { "*", "Angenommen", "Gegeben sei", "Gegeben seien" } }, + { "rule", { "Rule", "Regel" } }, + { "scenario", { "Beispiel", "Szenario" } }, + { "scenarioOutline", { "Szenariogrundriss", "Szenarien" } }, + { "then", { "*", "Dann" } }, + { "when", { "*", "Wenn" } } + } + }, + { + "el", + { + { "and", { "*", "Και" } }, + { "background", { "Υπόβαθρο" } }, + { "but", { "*", "Αλλά" } }, + { "examples", { "Παραδείγματα", "Σενάρια" } }, + { "feature", { "Δυνατότητα", "Λειτουργία" } }, + { "given", { "*", "Δεδομένου" } }, + { "rule", { "Rule" } }, + { "scenario", { "Παράδειγμα", "Σενάριο" } }, + { "scenarioOutline", { "Περιγραφή Σεναρίου", "Περίγραμμα Σεναρίου" } }, + { "then", { "*", "Τότε" } }, + { "when", { "*", "Όταν" } } + } + }, + { + "em", + { + { "and", { "*", "😂" } }, + { "background", { "💤" } }, + { "but", { "*", "😔" } }, + { "examples", { "📓" } }, + { "feature", { "📚" } }, + { "given", { "*", "😐" } }, + { "rule", { "Rule" } }, + { "scenario", { "🥒", "📕" } }, + { "scenarioOutline", { "📖" } }, + { "then", { "*", "🙏" } }, + { "when", { "*", "🎬" } } + } + }, + { + "en", + { + { "and", { "*", "And" } }, + { "background", { "Background" } }, + { "but", { "*", "But" } }, + { "examples", { "Examples", "Scenarios" } }, + { "feature", { "Feature", "Business Need", "Ability" } }, + { "given", { "*", "Given" } }, + { "rule", { "Rule" } }, + { "scenario", { "Example", "Scenario" } }, + { "scenarioOutline", { "Scenario Outline", "Scenario Template" } }, + { "then", { "*", "Then" } }, + { "when", { "*", "When" } } + } + }, + { + "en_Scouse", + { + { "and", { "*", "An" } }, + { "background", { "Dis is what went down" } }, + { "but", { "*", "Buh" } }, + { "examples", { "Examples" } }, + { "feature", { "Feature" } }, + { "given", { "*", "Givun", "Youse know when youse got" } }, + { "rule", { "Rule" } }, + { "scenario", { "The thing of it is" } }, + { "scenarioOutline", { "Wharrimean is" } }, + { "then", { "*", "Dun", "Den youse gotta" } }, + { "when", { "*", "Wun", "Youse know like when" } } + } + }, + { + "en_au", + { + { "and", { "*", "Too right" } }, + { "background", { "First off" } }, + { "but", { "*", "Yeah nah" } }, + { "examples", { "You'll wanna" } }, + { "feature", { "Pretty much" } }, + { "given", { "*", "Y'know" } }, + { "rule", { "Rule" } }, + { "scenario", { "Awww, look mate" } }, + { "scenarioOutline", { "Reckon it's like" } }, + { "then", { "*", "But at the end of the day I reckon" } }, + { "when", { "*", "It's just unbelievable" } } + } + }, + { + "en_lol", + { + { "and", { "*", "AN" } }, + { "background", { "B4" } }, + { "but", { "*", "BUT" } }, + { "examples", { "EXAMPLZ" } }, + { "feature", { "OH HAI" } }, + { "given", { "*", "I CAN HAZ" } }, + { "rule", { "Rule" } }, + { "scenario", { "MISHUN" } }, + { "scenarioOutline", { "MISHUN SRSLY" } }, + { "then", { "*", "DEN" } }, + { "when", { "*", "WEN" } } + } + }, + { + "en_old", + { + { "and", { "*", "Ond", "7" } }, + { "background", { "Aer", "Ær" } }, + { "but", { "*", "Ac" } }, + { "examples", { "Se the", "Se þe", "Se ðe" } }, + { "feature", { "Hwaet", "Hwæt" } }, + { "given", { "*", "Thurh", "Þurh", "Ðurh" } }, + { "rule", { "Rule" } }, + { "scenario", { "Swa" } }, + { "scenarioOutline", { "Swa hwaer swa", "Swa hwær swa" } }, + { "then", { "*", "Tha", "Þa", "Ða", "Tha the", "Þa þe", "Ða ðe" } }, + { "when", { "*", "Bæþsealf", "Bæþsealfa", "Bæþsealfe", "Ciricæw", "Ciricæwe", "Ciricæwa" } } + } + }, + { + "en_pirate", + { + { "and", { "*", "Aye" } }, + { "background", { "Yo-ho-ho" } }, + { "but", { "*", "Avast!" } }, + { "examples", { "Dead men tell no tales" } }, + { "feature", { "Ahoy matey!" } }, + { "given", { "*", "Gangway!" } }, + { "rule", { "Rule" } }, + { "scenario", { "Heave to" } }, + { "scenarioOutline", { "Shiver me timbers" } }, + { "then", { "*", "Let go and haul" } }, + { "when", { "*", "Blimey!" } } + } + }, + { + "en_tx", + { + { "and", { "Come hell or high water" } }, + { "background", { "Lemme tell y'all a story" } }, + { "but", { "Well now hold on, I'll you what" } }, + { "examples", { "Now that's a story longer than a cattle drive in July" } }, + { "feature", { "This ain’t my first rodeo", "All gussied up" } }, + { "given", { "Fixin' to", "All git out" } }, + { "rule", { "Rule" } }, + { "scenario", { "All hat and no cattle" } }, + { "scenarioOutline", { "Serious as a snake bite", "Busy as a hound in flea season" } }, + { "then", { "There’s no tree but bears some fruit" } }, + { "when", { "Quick out of the chute" } } + } + }, + { + "eo", + { + { "and", { "*", "Kaj" } }, + { "background", { "Fono" } }, + { "but", { "*", "Sed" } }, + { "examples", { "Ekzemploj" } }, + { "feature", { "Trajto" } }, + { "given", { "*", "Donitaĵo", "Komence" } }, + { "rule", { "Rule" } }, + { "scenario", { "Ekzemplo", "Scenaro", "Kazo" } }, + { "scenarioOutline", { "Konturo de la scenaro", "Skizo", "Kazo-skizo" } }, + { "then", { "*", "Do" } }, + { "when", { "*", "Se" } } + } + }, + { + "es", + { + { "and", { "*", "Y", "E" } }, + { "background", { "Antecedentes" } }, + { "but", { "*", "Pero" } }, + { "examples", { "Ejemplos" } }, + { "feature", { "Característica", "Necesidad del negocio", "Requisito" } }, + { "given", { "*", "Dado", "Dada", "Dados", "Dadas" } }, + { "rule", { "Regla", "Regla de negocio" } }, + { "scenario", { "Ejemplo", "Escenario" } }, + { "scenarioOutline", { "Esquema del escenario" } }, + { "then", { "*", "Entonces" } }, + { "when", { "*", "Cuando" } } + } + }, + { + "et", + { + { "and", { "*", "Ja" } }, + { "background", { "Taust" } }, + { "but", { "*", "Kuid" } }, + { "examples", { "Juhtumid" } }, + { "feature", { "Omadus" } }, + { "given", { "*", "Eeldades" } }, + { "rule", { "Reegel" } }, + { "scenario", { "Juhtum", "Stsenaarium" } }, + { "scenarioOutline", { "Raamjuhtum", "Raamstsenaarium" } }, + { "then", { "*", "Siis" } }, + { "when", { "*", "Kui" } } + } + }, + { + "fa", + { + { "and", { "*", "و" } }, + { "background", { "زمینه" } }, + { "but", { "*", "اما" } }, + { "examples", { "نمونه ها" } }, + { "feature", { "وِیژگی" } }, + { "given", { "*", "با فرض" } }, + { "rule", { "Rule" } }, + { "scenario", { "مثال", "سناریو" } }, + { "scenarioOutline", { "الگوی سناریو" } }, + { "then", { "*", "آنگاه" } }, + { "when", { "*", "هنگامی" } } + } + }, + { + "fi", + { + { "and", { "*", "Ja" } }, + { "background", { "Tausta" } }, + { "but", { "*", "Mutta" } }, + { "examples", { "Tapaukset" } }, + { "feature", { "Ominaisuus" } }, + { "given", { "*", "Oletetaan" } }, + { "rule", { "Rule" } }, + { "scenario", { "Tapaus" } }, + { "scenarioOutline", { "Tapausaihio" } }, + { "then", { "*", "Niin" } }, + { "when", { "*", "Kun" } } + } + }, + { + "fr", + { + { "and", { "*", "Et que", "Et qu'", "Et" } }, + { "background", { "Contexte" } }, + { "but", { "*", "Mais que", "Mais qu'", "Mais" } }, + { "examples", { "Exemples" } }, + { "feature", { "Fonctionnalité" } }, + { "given", { "*", "Soit", "Sachant que", "Sachant qu'", "Sachant", "Etant donné que", "Etant donné qu'", "Etant donné", "Etant donnée", "Etant donnés", "Etant données", "Étant donné que", "Étant donné qu'", "Étant donné", "Étant donnée", "Étant donnés", "Étant données" } }, + { "rule", { "Règle" } }, + { "scenario", { "Exemple", "Scénario" } }, + { "scenarioOutline", { "Plan du scénario", "Plan du Scénario" } }, + { "then", { "*", "Alors", "Donc" } }, + { "when", { "*", "Quand", "Lorsque", "Lorsqu'" } } + } + }, + { + "ga", + { + { "and", { "*", "Agus" } }, + { "background", { "Cúlra" } }, + { "but", { "*", "Ach" } }, + { "examples", { "Samplaí" } }, + { "feature", { "Gné" } }, + { "given", { "*", "Cuir i gcás go", "Cuir i gcás nach", "Cuir i gcás gur", "Cuir i gcás nár" } }, + { "rule", { "Rule" } }, + { "scenario", { "Sampla", "Cás" } }, + { "scenarioOutline", { "Cás Achomair" } }, + { "then", { "*", "Ansin" } }, + { "when", { "*", "Nuair a", "Nuair nach", "Nuair ba", "Nuair nár" } } + } + }, + { + "gj", + { + { "and", { "*", "અને" } }, + { "background", { "બેકગ્રાઉન્ડ" } }, + { "but", { "*", "પણ" } }, + { "examples", { "ઉદાહરણો" } }, + { "feature", { "લક્ષણ", "વ્યાપાર જરૂર", "ક્ષમતા" } }, + { "given", { "*", "આપેલ છે" } }, + { "rule", { "Rule" } }, + { "scenario", { "ઉદાહરણ", "સ્થિતિ" } }, + { "scenarioOutline", { "પરિદ્દશ્ય રૂપરેખા", "પરિદ્દશ્ય ઢાંચો" } }, + { "then", { "*", "પછી" } }, + { "when", { "*", "ક્યારે" } } + } + }, + { + "gl", + { + { "and", { "*", "E" } }, + { "background", { "Contexto" } }, + { "but", { "*", "Mais", "Pero" } }, + { "examples", { "Exemplos" } }, + { "feature", { "Característica" } }, + { "given", { "*", "Dado", "Dada", "Dados", "Dadas" } }, + { "rule", { "Rule" } }, + { "scenario", { "Exemplo", "Escenario" } }, + { "scenarioOutline", { "Esbozo do escenario" } }, + { "then", { "*", "Entón", "Logo" } }, + { "when", { "*", "Cando" } } + } + }, + { + "he", + { + { "and", { "*", "וגם" } }, + { "background", { "רקע" } }, + { "but", { "*", "אבל" } }, + { "examples", { "דוגמאות" } }, + { "feature", { "תכונה" } }, + { "given", { "*", "בהינתן" } }, + { "rule", { "כלל" } }, + { "scenario", { "דוגמא", "תרחיש" } }, + { "scenarioOutline", { "תבנית תרחיש" } }, + { "then", { "*", "אז", "אזי" } }, + { "when", { "*", "כאשר" } } + } + }, + { + "hi", + { + { "and", { "*", "और", "तथा" } }, + { "background", { "पृष्ठभूमि" } }, + { "but", { "*", "पर", "परन्तु", "किन्तु" } }, + { "examples", { "उदाहरण" } }, + { "feature", { "रूप लेख" } }, + { "given", { "*", "अगर", "यदि", "चूंकि" } }, + { "rule", { "नियम" } }, + { "scenario", { "परिदृश्य" } }, + { "scenarioOutline", { "परिदृश्य रूपरेखा" } }, + { "then", { "*", "तब", "तदा" } }, + { "when", { "*", "जब", "कदा" } } + } + }, + { + "hr", + { + { "and", { "*", "I" } }, + { "background", { "Pozadina" } }, + { "but", { "*", "Ali" } }, + { "examples", { "Primjeri", "Scenariji" } }, + { "feature", { "Osobina", "Mogućnost", "Mogucnost" } }, + { "given", { "*", "Zadan", "Zadani", "Zadano", "Ukoliko" } }, + { "rule", { "Rule" } }, + { "scenario", { "Primjer", "Scenarij" } }, + { "scenarioOutline", { "Skica", "Koncept" } }, + { "then", { "*", "Onda" } }, + { "when", { "*", "Kada", "Kad" } } + } + }, + { + "ht", + { + { "and", { "*", "Ak", "Epi", "E" } }, + { "background", { "Kontèks", "Istorik" } }, + { "but", { "*", "Men" } }, + { "examples", { "Egzanp" } }, + { "feature", { "Karakteristik", "Mak", "Fonksyonalite" } }, + { "given", { "*", "Sipoze", "Sipoze ke", "Sipoze Ke" } }, + { "rule", { "Rule" } }, + { "scenario", { "Senaryo" } }, + { "scenarioOutline", { "Plan senaryo", "Plan Senaryo", "Senaryo deskripsyon", "Senaryo Deskripsyon", "Dyagram senaryo", "Dyagram Senaryo" } }, + { "then", { "*", "Lè sa a", "Le sa a" } }, + { "when", { "*", "Lè", "Le" } } + } + }, + { + "hu", + { + { "and", { "*", "És" } }, + { "background", { "Háttér" } }, + { "but", { "*", "De" } }, + { "examples", { "Példák" } }, + { "feature", { "Jellemző" } }, + { "given", { "*", "Amennyiben", "Adott" } }, + { "rule", { "Szabály" } }, + { "scenario", { "Példa", "Forgatókönyv" } }, + { "scenarioOutline", { "Forgatókönyv vázlat" } }, + { "then", { "*", "Akkor" } }, + { "when", { "*", "Majd", "Ha", "Amikor" } } + } + }, + { + "id", + { + { "and", { "*", "Dan" } }, + { "background", { "Dasar", "Latar Belakang" } }, + { "but", { "*", "Tapi", "Tetapi" } }, + { "examples", { "Contoh", "Misal" } }, + { "feature", { "Fitur" } }, + { "given", { "*", "Dengan", "Diketahui", "Diasumsikan", "Bila", "Jika" } }, + { "rule", { "Rule", "Aturan" } }, + { "scenario", { "Skenario" } }, + { "scenarioOutline", { "Skenario konsep", "Garis-Besar Skenario" } }, + { "then", { "*", "Maka", "Kemudian" } }, + { "when", { "*", "Ketika" } } + } + }, + { + "is", + { + { "and", { "*", "Og" } }, + { "background", { "Bakgrunnur" } }, + { "but", { "*", "En" } }, + { "examples", { "Dæmi", "Atburðarásir" } }, + { "feature", { "Eiginleiki" } }, + { "given", { "*", "Ef" } }, + { "rule", { "Rule" } }, + { "scenario", { "Atburðarás" } }, + { "scenarioOutline", { "Lýsing Atburðarásar", "Lýsing Dæma" } }, + { "then", { "*", "Þá" } }, + { "when", { "*", "Þegar" } } + } + }, + { + "it", + { + { "and", { "*", "E" } }, + { "background", { "Contesto" } }, + { "but", { "*", "Ma" } }, + { "examples", { "Esempi" } }, + { "feature", { "Funzionalità", "Esigenza di Business", "Abilità" } }, + { "given", { "*", "Dato", "Data", "Dati", "Date" } }, + { "rule", { "Regola" } }, + { "scenario", { "Esempio", "Scenario" } }, + { "scenarioOutline", { "Schema dello scenario" } }, + { "then", { "*", "Allora" } }, + { "when", { "*", "Quando" } } + } + }, + { + "ja", + { + { "and", { "*", "且つ", "かつ" } }, + { "background", { "背景" } }, + { "but", { "*", "然し", "しかし", "但し", "ただし" } }, + { "examples", { "例", "サンプル" } }, + { "feature", { "フィーチャ", "機能" } }, + { "given", { "*", "前提" } }, + { "rule", { "ルール" } }, + { "scenario", { "シナリオ" } }, + { "scenarioOutline", { "シナリオアウトライン", "シナリオテンプレート", "テンプレ", "シナリオテンプレ" } }, + { "then", { "*", "ならば" } }, + { "when", { "*", "もし" } } + } + }, + { + "jv", + { + { "and", { "*", "Lan" } }, + { "background", { "Dasar" } }, + { "but", { "*", "Tapi", "Nanging", "Ananging" } }, + { "examples", { "Conto", "Contone" } }, + { "feature", { "Fitur" } }, + { "given", { "*", "Nalika", "Nalikaning" } }, + { "rule", { "Rule" } }, + { "scenario", { "Skenario" } }, + { "scenarioOutline", { "Konsep skenario" } }, + { "then", { "*", "Njuk", "Banjur" } }, + { "when", { "*", "Manawa", "Menawa" } } + } + }, + { + "ka", + { + { "and", { "*", "და", "ასევე" } }, + { "background", { "კონტექსტი" } }, + { "but", { "*", "მაგრამ", "თუმცა" } }, + { "examples", { "მაგალითები" } }, + { "feature", { "თვისება", "მოთხოვნა" } }, + { "given", { "*", "მოცემული", "მოცემულია", "ვთქვათ" } }, + { "rule", { "წესი" } }, + { "scenario", { "მაგალითად", "მაგალითი", "მაგ", "სცენარი" } }, + { "scenarioOutline", { "სცენარის ნიმუში", "სცენარის შაბლონი", "ნიმუში", "შაბლონი" } }, + { "then", { "*", "მაშინ" } }, + { "when", { "*", "როდესაც", "როცა", "როგორც კი", "თუ" } } + } + }, + { + "kn", + { + { "and", { "*", "ಮತ್ತು" } }, + { "background", { "ಹಿನ್ನೆಲೆ" } }, + { "but", { "*", "ಆದರೆ" } }, + { "examples", { "ಉದಾಹರಣೆಗಳು" } }, + { "feature", { "ಹೆಚ್ಚಳ" } }, + { "given", { "*", "ನೀಡಿದ" } }, + { "rule", { "Rule" } }, + { "scenario", { "ಉದಾಹರಣೆ", "ಕಥಾಸಾರಾಂಶ" } }, + { "scenarioOutline", { "ವಿವರಣೆ" } }, + { "then", { "*", "ನಂತರ" } }, + { "when", { "*", "ಸ್ಥಿತಿಯನ್ನು" } } + } + }, + { + "ko", + { + { "and", { "*", "그리고" } }, + { "background", { "배경" } }, + { "but", { "*", "하지만", "단" } }, + { "examples", { "예" } }, + { "feature", { "기능" } }, + { "given", { "*", "조건", "먼저" } }, + { "rule", { "Rule" } }, + { "scenario", { "시나리오" } }, + { "scenarioOutline", { "시나리오 개요" } }, + { "then", { "*", "그러면" } }, + { "when", { "*", "만일", "만약" } } + } + }, + { + "lt", + { + { "and", { "*", "Ir" } }, + { "background", { "Kontekstas" } }, + { "but", { "*", "Bet" } }, + { "examples", { "Pavyzdžiai", "Scenarijai", "Variantai" } }, + { "feature", { "Savybė" } }, + { "given", { "*", "Duota" } }, + { "rule", { "Rule" } }, + { "scenario", { "Pavyzdys", "Scenarijus" } }, + { "scenarioOutline", { "Scenarijaus šablonas" } }, + { "then", { "*", "Tada" } }, + { "when", { "*", "Kai" } } + } + }, + { + "lu", + { + { "and", { "*", "an", "a" } }, + { "background", { "Hannergrond" } }, + { "but", { "*", "awer", "mä" } }, + { "examples", { "Beispiller" } }, + { "feature", { "Funktionalitéit" } }, + { "given", { "*", "ugeholl" } }, + { "rule", { "Rule" } }, + { "scenario", { "Beispill", "Szenario" } }, + { "scenarioOutline", { "Plang vum Szenario" } }, + { "then", { "*", "dann" } }, + { "when", { "*", "wann" } } + } + }, + { + "lv", + { + { "and", { "*", "Un" } }, + { "background", { "Konteksts", "Situācija" } }, + { "but", { "*", "Bet" } }, + { "examples", { "Piemēri", "Paraugs" } }, + { "feature", { "Funkcionalitāte", "Fīča" } }, + { "given", { "*", "Kad" } }, + { "rule", { "Rule" } }, + { "scenario", { "Piemērs", "Scenārijs" } }, + { "scenarioOutline", { "Scenārijs pēc parauga" } }, + { "then", { "*", "Tad" } }, + { "when", { "*", "Ja" } } + } + }, + { + "mk_Cyrl", + { + { "and", { "*", "И" } }, + { "background", { "Контекст", "Содржина" } }, + { "but", { "*", "Но" } }, + { "examples", { "Примери", "Сценарија" } }, + { "feature", { "Функционалност", "Бизнис потреба", "Можност" } }, + { "given", { "*", "Дадено", "Дадена" } }, + { "rule", { "Rule" } }, + { "scenario", { "Пример", "Сценарио", "На пример" } }, + { "scenarioOutline", { "Преглед на сценарија", "Скица", "Концепт" } }, + { "then", { "*", "Тогаш" } }, + { "when", { "*", "Кога" } } + } + }, + { + "mk_Latn", + { + { "and", { "*", "I" } }, + { "background", { "Kontekst", "Sodrzhina" } }, + { "but", { "*", "No" } }, + { "examples", { "Primeri", "Scenaria" } }, + { "feature", { "Funkcionalnost", "Biznis potreba", "Mozhnost" } }, + { "given", { "*", "Dadeno", "Dadena" } }, + { "rule", { "Rule" } }, + { "scenario", { "Scenario", "Na primer" } }, + { "scenarioOutline", { "Pregled na scenarija", "Skica", "Koncept" } }, + { "then", { "*", "Togash" } }, + { "when", { "*", "Koga" } } + } + }, + { + "mn", + { + { "and", { "*", "Мөн", "Тэгээд" } }, + { "background", { "Агуулга" } }, + { "but", { "*", "Гэхдээ", "Харин" } }, + { "examples", { "Тухайлбал" } }, + { "feature", { "Функц", "Функционал" } }, + { "given", { "*", "Өгөгдсөн нь", "Анх" } }, + { "rule", { "Rule" } }, + { "scenario", { "Сценар" } }, + { "scenarioOutline", { "Сценарын төлөвлөгөө" } }, + { "then", { "*", "Тэгэхэд", "Үүний дараа" } }, + { "when", { "*", "Хэрэв" } } + } + }, + { + "ne", + { + { "and", { "*", "र", "अनि" } }, + { "background", { "पृष्ठभूमी" } }, + { "but", { "*", "तर" } }, + { "examples", { "उदाहरण", "उदाहरणहरु" } }, + { "feature", { "सुविधा", "विशेषता" } }, + { "given", { "*", "दिइएको", "दिएको", "यदि" } }, + { "rule", { "नियम" } }, + { "scenario", { "परिदृश्य" } }, + { "scenarioOutline", { "परिदृश्य रूपरेखा" } }, + { "then", { "*", "त्यसपछि", "अनी" } }, + { "when", { "*", "जब" } } + } + }, + { + "nl", + { + { "and", { "*", "En" } }, + { "background", { "Achtergrond" } }, + { "but", { "*", "Maar" } }, + { "examples", { "Voorbeelden" } }, + { "feature", { "Functionaliteit" } }, + { "given", { "*", "Gegeven", "Stel" } }, + { "rule", { "Rule" } }, + { "scenario", { "Voorbeeld", "Scenario" } }, + { "scenarioOutline", { "Abstract Scenario" } }, + { "then", { "*", "Dan" } }, + { "when", { "*", "Als", "Wanneer" } } + } + }, + { + "no", + { + { "and", { "*", "Og" } }, + { "background", { "Bakgrunn" } }, + { "but", { "*", "Men" } }, + { "examples", { "Eksempler" } }, + { "feature", { "Egenskap" } }, + { "given", { "*", "Gitt" } }, + { "rule", { "Regel" } }, + { "scenario", { "Eksempel", "Scenario" } }, + { "scenarioOutline", { "Scenariomal", "Abstrakt Scenario" } }, + { "then", { "*", "Så" } }, + { "when", { "*", "Når" } } + } + }, + { + "pa", + { + { "and", { "*", "ਅਤੇ" } }, + { "background", { "ਪਿਛੋਕੜ" } }, + { "but", { "*", "ਪਰ" } }, + { "examples", { "ਉਦਾਹਰਨਾਂ" } }, + { "feature", { "ਖਾਸੀਅਤ", "ਮੁਹਾਂਦਰਾ", "ਨਕਸ਼ ਨੁਹਾਰ" } }, + { "given", { "*", "ਜੇਕਰ", "ਜਿਵੇਂ ਕਿ" } }, + { "rule", { "Rule" } }, + { "scenario", { "ਉਦਾਹਰਨ", "ਪਟਕਥਾ" } }, + { "scenarioOutline", { "ਪਟਕਥਾ ਢਾਂਚਾ", "ਪਟਕਥਾ ਰੂਪ ਰੇਖਾ" } }, + { "then", { "*", "ਤਦ" } }, + { "when", { "*", "ਜਦੋਂ" } } + } + }, + { + "pl", + { + { "and", { "*", "Oraz", "I" } }, + { "background", { "Założenia" } }, + { "but", { "*", "Ale" } }, + { "examples", { "Przykłady" } }, + { "feature", { "Właściwość", "Funkcja", "Aspekt", "Potrzeba biznesowa" } }, + { "given", { "*", "Zakładając", "Mając", "Zakładając, że" } }, + { "rule", { "Zasada", "Reguła" } }, + { "scenario", { "Przykład", "Scenariusz" } }, + { "scenarioOutline", { "Szablon scenariusza" } }, + { "then", { "*", "Wtedy" } }, + { "when", { "*", "Jeżeli", "Jeśli", "Gdy", "Kiedy" } } + } + }, + { + "pt", + { + { "and", { "*", "E" } }, + { "background", { "Contexto", "Cenário de Fundo", "Cenario de Fundo", "Fundo" } }, + { "but", { "*", "Mas" } }, + { "examples", { "Exemplos", "Cenários", "Cenarios" } }, + { "feature", { "Funcionalidade", "Característica", "Caracteristica" } }, + { "given", { "*", "Dado", "Dada", "Dados", "Dadas" } }, + { "rule", { "Regra" } }, + { "scenario", { "Exemplo", "Cenário", "Cenario" } }, + { "scenarioOutline", { "Esquema do Cenário", "Esquema do Cenario", "Delineação do Cenário", "Delineacao do Cenario" } }, + { "then", { "*", "Então", "Entao" } }, + { "when", { "*", "Quando" } } + } + }, + { + "ro", + { + { "and", { "*", "Si", "Și", "Şi" } }, + { "background", { "Context" } }, + { "but", { "*", "Dar" } }, + { "examples", { "Exemple" } }, + { "feature", { "Functionalitate", "Funcționalitate", "Funcţionalitate" } }, + { "given", { "*", "Date fiind", "Dat fiind", "Dată fiind", "Dati fiind", "Dați fiind", "Daţi fiind" } }, + { "rule", { "Rule" } }, + { "scenario", { "Exemplu", "Scenariu" } }, + { "scenarioOutline", { "Structura scenariu", "Structură scenariu" } }, + { "then", { "*", "Atunci" } }, + { "when", { "*", "Cand", "Când" } } + } + }, + { + "ru", + { + { "and", { "*", "И", "К тому же", "Также" } }, + { "background", { "Предыстория", "Контекст" } }, + { "but", { "*", "Но", "А", "Иначе" } }, + { "examples", { "Примеры" } }, + { "feature", { "Функция", "Функциональность", "Функционал", "Свойство", "Фича" } }, + { "given", { "*", "Допустим", "Дано", "Пусть" } }, + { "rule", { "Правило" } }, + { "scenario", { "Пример", "Сценарий" } }, + { "scenarioOutline", { "Структура сценария", "Шаблон сценария" } }, + { "then", { "*", "То", "Затем", "Тогда" } }, + { "when", { "*", "Когда", "Если" } } + } + }, + { + "sk", + { + { "and", { "*", "A", "A tiež", "A taktiež", "A zároveň" } }, + { "background", { "Pozadie" } }, + { "but", { "*", "Ale" } }, + { "examples", { "Príklady" } }, + { "feature", { "Požiadavka", "Funkcia", "Vlastnosť" } }, + { "given", { "*", "Pokiaľ", "Za predpokladu" } }, + { "rule", { "Rule" } }, + { "scenario", { "Príklad", "Scenár" } }, + { "scenarioOutline", { "Náčrt Scenáru", "Náčrt Scenára", "Osnova Scenára" } }, + { "then", { "*", "Tak", "Potom" } }, + { "when", { "*", "Keď", "Ak" } } + } + }, + { + "sl", + { + { "and", { "In", "Ter" } }, + { "background", { "Kontekst", "Osnova", "Ozadje" } }, + { "but", { "Toda", "Ampak", "Vendar" } }, + { "examples", { "Primeri", "Scenariji" } }, + { "feature", { "Funkcionalnost", "Funkcija", "Možnosti", "Moznosti", "Lastnost", "Značilnost" } }, + { "given", { "Dano", "Podano", "Zaradi", "Privzeto" } }, + { "rule", { "Rule" } }, + { "scenario", { "Primer", "Scenarij" } }, + { "scenarioOutline", { "Struktura scenarija", "Skica", "Koncept", "Oris scenarija", "Osnutek" } }, + { "then", { "Nato", "Potem", "Takrat" } }, + { "when", { "Ko", "Ce", "Če", "Kadar" } } + } + }, + { + "sr_Cyrl", + { + { "and", { "*", "И" } }, + { "background", { "Контекст", "Основа", "Позадина" } }, + { "but", { "*", "Али" } }, + { "examples", { "Примери", "Сценарији" } }, + { "feature", { "Функционалност", "Могућност", "Особина" } }, + { "given", { "*", "За дато", "За дате", "За дати" } }, + { "rule", { "Правило" } }, + { "scenario", { "Пример", "Сценарио", "Пример" } }, + { "scenarioOutline", { "Структура сценарија", "Скица", "Концепт" } }, + { "then", { "*", "Онда" } }, + { "when", { "*", "Када", "Кад" } } + } + }, + { + "sr_Latn", + { + { "and", { "*", "I" } }, + { "background", { "Kontekst", "Osnova", "Pozadina" } }, + { "but", { "*", "Ali" } }, + { "examples", { "Primeri", "Scenariji" } }, + { "feature", { "Funkcionalnost", "Mogućnost", "Mogucnost", "Osobina" } }, + { "given", { "*", "Za dato", "Za date", "Za dati" } }, + { "rule", { "Pravilo" } }, + { "scenario", { "Scenario", "Primer" } }, + { "scenarioOutline", { "Struktura scenarija", "Skica", "Koncept" } }, + { "then", { "*", "Onda" } }, + { "when", { "*", "Kada", "Kad" } } + } + }, + { + "sv", + { + { "and", { "*", "Och" } }, + { "background", { "Bakgrund" } }, + { "but", { "*", "Men" } }, + { "examples", { "Exempel" } }, + { "feature", { "Egenskap" } }, + { "given", { "*", "Givet" } }, + { "rule", { "Regel" } }, + { "scenario", { "Scenario" } }, + { "scenarioOutline", { "Abstrakt Scenario", "Scenariomall" } }, + { "then", { "*", "Så" } }, + { "when", { "*", "När" } } + } + }, + { + "ta", + { + { "and", { "*", "மேலும்", "மற்றும்" } }, + { "background", { "பின்னணி" } }, + { "but", { "*", "ஆனால்" } }, + { "examples", { "எடுத்துக்காட்டுகள்", "காட்சிகள்", "நிலைமைகளில்" } }, + { "feature", { "அம்சம்", "வணிக தேவை", "திறன்" } }, + { "given", { "*", "கொடுக்கப்பட்ட" } }, + { "rule", { "Rule" } }, + { "scenario", { "உதாரணமாக", "காட்சி" } }, + { "scenarioOutline", { "காட்சி சுருக்கம்", "காட்சி வார்ப்புரு" } }, + { "then", { "*", "அப்பொழுது" } }, + { "when", { "*", "எப்போது" } } + } + }, + { + "th", + { + { "and", { "*", "และ" } }, + { "background", { "แนวคิด" } }, + { "but", { "*", "แต่" } }, + { "examples", { "ชุดของตัวอย่าง", "ชุดของเหตุการณ์" } }, + { "feature", { "โครงหลัก", "ความต้องการทางธุรกิจ", "ความสามารถ" } }, + { "given", { "*", "กำหนดให้" } }, + { "rule", { "Rule" } }, + { "scenario", { "เหตุการณ์" } }, + { "scenarioOutline", { "สรุปเหตุการณ์", "โครงสร้างของเหตุการณ์" } }, + { "then", { "*", "ดังนั้น" } }, + { "when", { "*", "เมื่อ" } } + } + }, + { + "te", + { + { "and", { "*", "మరియు" } }, + { "background", { "నేపథ్యం" } }, + { "but", { "*", "కాని" } }, + { "examples", { "ఉదాహరణలు" } }, + { "feature", { "గుణము" } }, + { "given", { "*", "చెప్పబడినది" } }, + { "rule", { "Rule" } }, + { "scenario", { "ఉదాహరణ", "సన్నివేశం" } }, + { "scenarioOutline", { "కథనం" } }, + { "then", { "*", "అప్పుడు" } }, + { "when", { "*", "ఈ పరిస్థితిలో" } } + } + }, + { + "tlh", + { + { "and", { "*", "'ej", "latlh" } }, + { "background", { "mo'" } }, + { "but", { "*", "'ach", "'a" } }, + { "examples", { "ghantoH", "lutmey" } }, + { "feature", { "Qap", "Qu'meH 'ut", "perbogh", "poQbogh malja'", "laH" } }, + { "given", { "*", "ghu' noblu'", "DaH ghu' bejlu'" } }, + { "rule", { "Rule" } }, + { "scenario", { "lut" } }, + { "scenarioOutline", { "lut chovnatlh" } }, + { "then", { "*", "vaj" } }, + { "when", { "*", "qaSDI'" } } + } + }, + { + "tr", + { + { "and", { "*", "Ve" } }, + { "background", { "Geçmiş" } }, + { "but", { "*", "Fakat", "Ama" } }, + { "examples", { "Örnekler" } }, + { "feature", { "Özellik" } }, + { "given", { "*", "Diyelim ki" } }, + { "rule", { "Kural" } }, + { "scenario", { "Örnek", "Senaryo" } }, + { "scenarioOutline", { "Senaryo taslağı" } }, + { "then", { "*", "O zaman" } }, + { "when", { "*", "Eğer ki" } } + } + }, + { + "tt", + { + { "and", { "*", "Һәм", "Вә" } }, + { "background", { "Кереш" } }, + { "but", { "*", "Ләкин", "Әмма" } }, + { "examples", { "Үрнәкләр", "Мисаллар" } }, + { "feature", { "Мөмкинлек", "Үзенчәлеклелек" } }, + { "given", { "*", "Әйтик" } }, + { "rule", { "Rule" } }, + { "scenario", { "Сценарий" } }, + { "scenarioOutline", { "Сценарийның төзелеше" } }, + { "then", { "*", "Нәтиҗәдә" } }, + { "when", { "*", "Әгәр" } } + } + }, + { + "uk", + { + { "and", { "*", "І", "А також", "Та" } }, + { "background", { "Передумова" } }, + { "but", { "*", "Але" } }, + { "examples", { "Приклади" } }, + { "feature", { "Функціонал" } }, + { "given", { "*", "Припустимо", "Припустимо, що", "Нехай", "Дано" } }, + { "rule", { "Rule" } }, + { "scenario", { "Приклад", "Сценарій" } }, + { "scenarioOutline", { "Структура сценарію" } }, + { "then", { "*", "То", "Тоді" } }, + { "when", { "*", "Якщо", "Коли" } } + } + }, + { + "ur", + { + { "and", { "*", "اور" } }, + { "background", { "پس منظر" } }, + { "but", { "*", "لیکن" } }, + { "examples", { "مثالیں" } }, + { "feature", { "صلاحیت", "کاروبار کی ضرورت", "خصوصیت" } }, + { "given", { "*", "اگر", "بالفرض", "فرض کیا" } }, + { "rule", { "Rule" } }, + { "scenario", { "منظرنامہ" } }, + { "scenarioOutline", { "منظر نامے کا خاکہ" } }, + { "then", { "*", "پھر", "تب" } }, + { "when", { "*", "جب" } } + } + }, + { + "uz", + { + { "and", { "*", "Ва" } }, + { "background", { "Тарих" } }, + { "but", { "*", "Лекин", "Бирок", "Аммо" } }, + { "examples", { "Мисоллар" } }, + { "feature", { "Функционал" } }, + { "given", { "*", "Belgilangan" } }, + { "rule", { "Rule" } }, + { "scenario", { "Сценарий" } }, + { "scenarioOutline", { "Сценарий структураси" } }, + { "then", { "*", "Унда" } }, + { "when", { "*", "Агар" } } + } + }, + { + "vi", + { + { "and", { "*", "Và" } }, + { "background", { "Bối cảnh" } }, + { "but", { "*", "Nhưng" } }, + { "examples", { "Dữ liệu" } }, + { "feature", { "Tính năng" } }, + { "given", { "*", "Biết", "Cho" } }, + { "rule", { "Rule" } }, + { "scenario", { "Tình huống", "Kịch bản" } }, + { "scenarioOutline", { "Khung tình huống", "Khung kịch bản" } }, + { "then", { "*", "Thì" } }, + { "when", { "*", "Khi" } } + } + }, + { + "zh_CN", + { + { "and", { "*", "而且", "并且", "同时" } }, + { "background", { "背景" } }, + { "but", { "*", "但是" } }, + { "examples", { "例子" } }, + { "feature", { "功能" } }, + { "given", { "*", "假如", "假设", "假定" } }, + { "rule", { "Rule", "规则" } }, + { "scenario", { "场景", "剧本" } }, + { "scenarioOutline", { "场景大纲", "剧本大纲" } }, + { "then", { "*", "那么" } }, + { "when", { "*", "当" } } + } + }, + { + "zh_TW", + { + { "and", { "*", "而且", "並且", "同時" } }, + { "background", { "背景" } }, + { "but", { "*", "但是" } }, + { "examples", { "例子" } }, + { "feature", { "功能" } }, + { "given", { "*", "假如", "假設", "假定" } }, + { "rule", { "Rule" } }, + { "scenario", { "場景", "劇本" } }, + { "scenarioOutline", { "場景大綱", "劇本大綱" } }, + { "then", { "*", "那麼" } }, + { "when", { "*", "當" } } + } + }, + { + "mr", + { + { "and", { "*", "आणि", "तसेच" } }, + { "background", { "पार्श्वभूमी" } }, + { "but", { "*", "पण", "परंतु" } }, + { "examples", { "उदाहरण" } }, + { "feature", { "वैशिष्ट्य", "सुविधा" } }, + { "given", { "*", "जर", "दिलेल्या प्रमाणे" } }, + { "rule", { "नियम" } }, + { "scenario", { "परिदृश्य" } }, + { "scenarioOutline", { "परिदृश्य रूपरेखा" } }, + { "then", { "*", "मग", "तेव्हा" } }, + { "when", { "*", "जेव्हा" } } + } + }, + { + "amh", + { + { "and", { "*", "እና" } }, + { "background", { "ቅድመ ሁኔታ", "መነሻ", "መነሻ ሀሳብ" } }, + { "but", { "*", "ግን" } }, + { "examples", { "ምሳሌዎች", "ሁናቴዎች" } }, + { "feature", { "ስራ", "የተፈለገው ስራ", "የሚፈለገው ድርጊት" } }, + { "given", { "*", "የተሰጠ" } }, + { "rule", { "ህግ" } }, + { "scenario", { "ምሳሌ", "ሁናቴ" } }, + { "scenarioOutline", { "ሁናቴ ዝርዝር", "ሁናቴ አብነት" } }, + { "then", { "*", "ከዚያ" } }, + { "when", { "*", "መቼ" } } + } + } + }; + + return kwms.at(language); +} + +const string_views& +keyword(const std::string_view& language, const std::string_view& kw) +{ return keywords(language).at(kw); } + +} + diff --git a/cpp/src/gherkin/parser.cpp b/cpp/src/gherkin/parser.cpp new file mode 100644 index 000000000..42027d9e1 --- /dev/null +++ b/cpp/src/gherkin/parser.cpp @@ -0,0 +1,4338 @@ +// This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. +#include +#include +//#include + +namespace gherkin { + +enum class rule_type { + None = 0, + EOF, + Empty, + Comment, + TagLine, + FeatureLine, + RuleLine, + BackgroundLine, + ScenarioLine, + ExamplesLine, + StepLine, + DocStringSeparator, + TableRow, + Language, + Other, + GherkinDocument, + Feature, + FeatureHeader, + Rule, + RuleHeader, + Background, + ScenarioDefinition, + Scenario, + ExamplesDefinition, + Examples, + ExamplesTable, + Step, + StepArg, + DataTable, + DocString, + Tags, + DescriptionHelper, + Description, + Count +}; + +struct ParserContext { + bool stop_at_first_error; + TokenScanner* token_scanner; + TokenMatcher* token_matcher; + Builder* builder; + TokenQueue* token_queue; + ErrorList* errors; +} ParserContext; + +struct Parser { + ParserContext* parser_context; + Builder* builder; + ErrorList* errors; +}; + +static Token* read_token(ParserContext* context); + +static void start_rule(ParserContext* context, RuleType rule_type); + +static void end_rule(ParserContext* context, RuleType rule_type); + +static int match_token(int state, Token* token, ParserContext* context); + +ParserContext* ParserContext_new(TokenScanner* token_scanner, TokenMatcher* token_matcher, Builder* builder, TokenQueue* token_queue, ErrorList* errors) { + ParserContext* parser_context = (ParserContext*)malloc(sizeof(ParserContext)); + parser_context->stop_at_first_error = false; + parser_context->token_scanner = token_scanner; + parser_context->token_matcher = token_matcher; + parser_context->builder = builder; + parser_context->token_queue = token_queue; + parser_context->errors = errors; + return parser_context; +} + +void ParserContext_delete(ParserContext* parser_context) { + free((void*)parser_context); +} + +Parser* Parser_new(Builder* builder) { + Parser* parser = (Parser*)malloc(sizeof(Parser)); + parser->parser_context = 0; + parser->builder = builder; + parser->errors = ErrorList_new(); + return parser; +} + +void Parser_delete(Parser* parser) { + if (parser->errors) { + ErrorList_delete(parser->errors); + } + if (parser->parser_context) { + ParserContext_delete(parser->parser_context); + } + free((void*)parser); +} + +int Parser_parse(Parser* parser, TokenMatcher* token_matcher, TokenScanner* token_scanner) { + parser->builder->reset(parser->builder); + parser->builder->set_error_context(parser->builder, parser->errors); + token_matcher->reset(token_matcher); + token_matcher->errors = parser->errors; + TokenQueue* token_queue = TokenQueue_new(); + ParserContext* context = ParserContext_new(token_scanner, token_matcher, parser->builder, token_queue, parser->errors); + + int val = 0; + jmp_buf env; + val = setjmp(env); + ErrorList_set_global_rescue_env(parser->errors, &env); + + if (val == 0) { + start_rule(context, Rule_GherkinDocument); + int state = 0; + bool token_is_eof; + Token* token = 0; + do { + token = read_token(context); + token_is_eof = Token_is_eof(token); + state = match_token(state, token, context); + } while (!token_is_eof); + + end_rule(context, Rule_GherkinDocument); + } + + int result_code = ErrorList_is_empty(context->errors) ? 0 : 1; + + ParserContext_delete(context); + TokenQueue_delete(token_queue); + return result_code; +} +bool Parser_has_more_errors(Parser* parser) { + return ErrorList_has_more_errors(parser->errors); +} + +Error* Parser_next_error(Parser* parser) { + return ErrorList_next_error(parser->errors); +} + +static Token* read_token(ParserContext* context) { + if (!TokenQueue_is_empty(context->token_queue)) + return TokenQueue_remove(context->token_queue); + else + return context->token_scanner->read(context->token_scanner); +} + +static void build(ParserContext* context, Token* token) { + context->builder->build(context->builder, token); +} + +static void handle_ast_error(ParserContext* context, RuleType rule_type, rule_function action) { + if (context->stop_at_first_error) { + action(context->builder, rule_type); + return; + } + + jmp_buf env; + int val = setjmp(env); + ErrorList_set_local_rescue_env(context->errors, &env); + if (val == 0) { + action(context->builder, rule_type); + } +} + +static void start_rule(ParserContext* context, RuleType rule_type) { + handle_ast_error(context, rule_type, context->builder->start_rule); +} + +static void end_rule(ParserContext* context, RuleType rule_type) { + handle_ast_error(context, rule_type, context->builder->end_rule); +} + +static bool handle_external_error(ParserContext* context, Token* token, match_function action) { + if (context->stop_at_first_error) { + return action(context->token_matcher, token); + } + + jmp_buf env; + int val = setjmp(env); + ErrorList_set_local_rescue_env(context->errors, &env); + if (val == 0) { + return action(context->token_matcher, token); + } + return false; +} + + +static bool match_EOF(ParserContext* context, Token* token) { + return handle_external_error(context, token, context->token_matcher->match_EOF); +} +static bool match_Empty(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_Empty); +} +static bool match_Comment(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_Comment); +} +static bool match_TagLine(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + bool match_result = handle_external_error(context, token, context->token_matcher->match_TagLine); + if (match_result) { + bool tag_error = ErrorList_check_token_tags_for_whitespace(context->errors, token); + if (tag_error && context->stop_at_first_error) { + ErrorList_jump_to_global_rescue_env(context->errors); + } + } + return match_result; +} +static bool match_FeatureLine(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_FeatureLine); +} +static bool match_RuleLine(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_RuleLine); +} +static bool match_BackgroundLine(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_BackgroundLine); +} +static bool match_ScenarioLine(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_ScenarioLine); +} +static bool match_ExamplesLine(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_ExamplesLine); +} +static bool match_StepLine(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_StepLine); +} +static bool match_DocStringSeparator(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_DocStringSeparator); +} +static bool match_TableRow(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_TableRow); +} +static bool match_Language(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_Language); +} +static bool match_Other(ParserContext* context, Token* token) { + if (token->matched_type == Token_EOF) { + return false; + }; + return handle_external_error(context, token, context->token_matcher->match_Other); +} + +static bool lookahead_0(ParserContext* context) { + Token* token = 0; + TokenQueue* queue = TokenQueue_new(); + bool match = false; + while (true) { + token = read_token(context); + TokenQueue_add(queue, token); + + if (match_ScenarioLine(context, token) || false) { + match = true; + break; + } + + if (!(match_Empty(context, token) || match_Comment(context, token) || match_TagLine(context, token) || false)) { + break; + } + } + + TokenQueue_extend(context->token_queue, queue); + + return match; +} + +static bool lookahead_1(ParserContext* context) { + Token* token = 0; + TokenQueue* queue = TokenQueue_new(); + bool match = false; + while (true) { + token = read_token(context); + TokenQueue_add(queue, token); + + if (match_ExamplesLine(context, token) || false) { + match = true; + break; + } + + if (!(match_Empty(context, token) || match_Comment(context, token) || match_TagLine(context, token) || false)) { + break; + } + } + + TokenQueue_extend(context->token_queue, queue); + + return match; +} + + +/* Start */ +static int match_token_at_0(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + build(context, token); + return 42; + } + if (match_Language(context, token)) { + start_rule(context, Rule_Feature); + start_rule(context, Rule_FeatureHeader); + build(context, token); + return 1; + } + if (match_TagLine(context, token)) { + start_rule(context, Rule_Feature); + start_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 2; + } + if (match_FeatureLine(context, token)) { + start_rule(context, Rule_Feature); + start_rule(context, Rule_FeatureHeader); + build(context, token); + return 3; + } + if (match_Comment(context, token)) { + build(context, token); + return 0; + } + if (match_Empty(context, token)) { + build(context, token); + return 0; + } + + /* "State: 0 - Start" */ + std::string expected_tokens = L"#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 0;} +/* GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 */ +static int match_token_at_1(Token* token, ParserContext* context) { + if (match_TagLine(context, token)) { + start_rule(context, Rule_Tags); + build(context, token); + return 2; + } + if (match_FeatureLine(context, token)) { + build(context, token); + return 3; + } + if (match_Comment(context, token)) { + build(context, token); + return 1; + } + if (match_Empty(context, token)) { + build(context, token); + return 1; + } + + /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ + std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 1;} +/* GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 */ +static int match_token_at_2(Token* token, ParserContext* context) { + if (match_TagLine(context, token)) { + build(context, token); + return 2; + } + if (match_FeatureLine(context, token)) { + end_rule(context, Rule_Tags); + build(context, token); + return 3; + } + if (match_Comment(context, token)) { + build(context, token); + return 2; + } + if (match_Empty(context, token)) { + build(context, token); + return 2; + } + + /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 2;} +/* GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 */ +static int match_token_at_3(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_FeatureHeader); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Empty(context, token)) { + build(context, token); + return 3; + } + if (match_Comment(context, token)) { + build(context, token); + return 5; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Background); + build(context, token); + return 6; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return 4; + } + + /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 3;} +/* GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 */ +static int match_token_at_4(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return 5; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Background); + build(context, token); + return 6; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + build(context, token); + return 4; + } + + /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 4;} +/* GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 */ +static int match_token_at_5(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_FeatureHeader); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + build(context, token); + return 5; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Background); + build(context, token); + return 6; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Empty(context, token)) { + build(context, token); + return 5; + } + + /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 5;} +/* GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 */ +static int match_token_at_6(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Empty(context, token)) { + build(context, token); + return 6; + } + if (match_Comment(context, token)) { + build(context, token); + return 8; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return 9; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return 7; + } + + /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 6;} +/* GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 */ +static int match_token_at_7(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return 8; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_Step); + build(context, token); + return 9; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + build(context, token); + return 7; + } + + /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 7;} +/* GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 */ +static int match_token_at_8(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + build(context, token); + return 8; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return 9; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Empty(context, token)) { + build(context, token); + return 8; + } + + /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 8;} +/* GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 */ +static int match_token_at_9(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_DataTable); + build(context, token); + return 10; + } + if (match_DocStringSeparator(context, token)) { + start_rule(context, Rule_DocString); + build(context, token); + return 49; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 9; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 9; + } + if (match_Empty(context, token)) { + build(context, token); + return 9; + } + + /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 9;} +/* GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 */ +static int match_token_at_10(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + build(context, token); + return 10; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 9; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 10; + } + if (match_Empty(context, token)) { + build(context, token); + return 10; + } + + /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 10;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 */ +static int match_token_at_11(Token* token, ParserContext* context) { + if (match_TagLine(context, token)) { + build(context, token); + return 11; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Tags); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_Comment(context, token)) { + build(context, token); + return 11; + } + if (match_Empty(context, token)) { + build(context, token); + return 11; + } + + /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 11;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 */ +static int match_token_at_12(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Empty(context, token)) { + build(context, token); + return 12; + } + if (match_Comment(context, token)) { + build(context, token); + return 14; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return 15; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return 13; + } + + /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 12;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 */ +static int match_token_at_13(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return 14; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_Step); + build(context, token); + return 15; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + build(context, token); + return 13; + } + + /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 13;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 */ +static int match_token_at_14(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + build(context, token); + return 14; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return 15; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Empty(context, token)) { + build(context, token); + return 14; + } + + /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 14;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 */ +static int match_token_at_15(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_DataTable); + build(context, token); + return 16; + } + if (match_DocStringSeparator(context, token)) { + start_rule(context, Rule_DocString); + build(context, token); + return 47; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 15; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 15; + } + if (match_Empty(context, token)) { + build(context, token); + return 15; + } + + /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 15;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 */ +static int match_token_at_16(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + build(context, token); + return 16; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 15; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 16; + } + if (match_Empty(context, token)) { + build(context, token); + return 16; + } + + /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 16;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 */ +static int match_token_at_17(Token* token, ParserContext* context) { + if (match_TagLine(context, token)) { + build(context, token); + return 17; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Tags); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_Comment(context, token)) { + build(context, token); + return 17; + } + if (match_Empty(context, token)) { + build(context, token); + return 17; + } + + /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 17;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 */ +static int match_token_at_18(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Empty(context, token)) { + build(context, token); + return 18; + } + if (match_Comment(context, token)) { + build(context, token); + return 20; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_ExamplesTable); + build(context, token); + return 21; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return 19; + } + + /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 18;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 */ +static int match_token_at_19(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return 20; + } + if (match_TableRow(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesTable); + build(context, token); + return 21; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + build(context, token); + return 19; + } + + /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 19;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 */ +static int match_token_at_20(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + build(context, token); + return 20; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_ExamplesTable); + build(context, token); + return 21; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Empty(context, token)) { + build(context, token); + return 20; + } + + /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 20;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 */ +static int match_token_at_21(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + build(context, token); + return 21; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 21; + } + if (match_Empty(context, token)) { + build(context, token); + return 21; + } + + /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 21;} +/* GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 */ +static int match_token_at_22(Token* token, ParserContext* context) { + if (match_TagLine(context, token)) { + build(context, token); + return 22; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Tags); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 22; + } + if (match_Empty(context, token)) { + build(context, token); + return 22; + } + + /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 22;} +/* GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 */ +static int match_token_at_23(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Empty(context, token)) { + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 25; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Background); + build(context, token); + return 26; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return 24; + } + + /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 23;} +/* GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 */ +static int match_token_at_24(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return 25; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Background); + build(context, token); + return 26; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + build(context, token); + return 24; + } + + /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 24;} +/* GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 */ +static int match_token_at_25(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + build(context, token); + return 25; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Background); + build(context, token); + return 26; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Empty(context, token)) { + build(context, token); + return 25; + } + + /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 25;} +/* GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 */ +static int match_token_at_26(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Empty(context, token)) { + build(context, token); + return 26; + } + if (match_Comment(context, token)) { + build(context, token); + return 28; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return 29; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return 27; + } + + /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 26;} +/* GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 */ +static int match_token_at_27(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return 28; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_Step); + build(context, token); + return 29; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + build(context, token); + return 27; + } + + /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 27;} +/* GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 */ +static int match_token_at_28(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + build(context, token); + return 28; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return 29; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Empty(context, token)) { + build(context, token); + return 28; + } + + /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 28;} +/* GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 */ +static int match_token_at_29(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_DataTable); + build(context, token); + return 30; + } + if (match_DocStringSeparator(context, token)) { + start_rule(context, Rule_DocString); + build(context, token); + return 45; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 29; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 29; + } + if (match_Empty(context, token)) { + build(context, token); + return 29; + } + + /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 29;} +/* GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 */ +static int match_token_at_30(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + build(context, token); + return 30; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 29; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 30; + } + if (match_Empty(context, token)) { + build(context, token); + return 30; + } + + /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 30;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 */ +static int match_token_at_31(Token* token, ParserContext* context) { + if (match_TagLine(context, token)) { + build(context, token); + return 31; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Tags); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_Comment(context, token)) { + build(context, token); + return 31; + } + if (match_Empty(context, token)) { + build(context, token); + return 31; + } + + /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 31;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 */ +static int match_token_at_32(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Empty(context, token)) { + build(context, token); + return 32; + } + if (match_Comment(context, token)) { + build(context, token); + return 34; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return 35; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return 33; + } + + /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 32;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 */ +static int match_token_at_33(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return 34; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_Step); + build(context, token); + return 35; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + build(context, token); + return 33; + } + + /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 33;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 */ +static int match_token_at_34(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + build(context, token); + return 34; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return 35; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Empty(context, token)) { + build(context, token); + return 34; + } + + /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 34;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 */ +static int match_token_at_35(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_DataTable); + build(context, token); + return 36; + } + if (match_DocStringSeparator(context, token)) { + start_rule(context, Rule_DocString); + build(context, token); + return 43; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 35; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 35; + } + if (match_Empty(context, token)) { + build(context, token); + return 35; + } + + /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 35;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 */ +static int match_token_at_36(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + build(context, token); + return 36; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 35; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 36; + } + if (match_Empty(context, token)) { + build(context, token); + return 36; + } + + /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 36;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 */ +static int match_token_at_37(Token* token, ParserContext* context) { + if (match_TagLine(context, token)) { + build(context, token); + return 37; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Tags); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_Comment(context, token)) { + build(context, token); + return 37; + } + if (match_Empty(context, token)) { + build(context, token); + return 37; + } + + /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 37;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 */ +static int match_token_at_38(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Empty(context, token)) { + build(context, token); + return 38; + } + if (match_Comment(context, token)) { + build(context, token); + return 40; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_ExamplesTable); + build(context, token); + return 41; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return 39; + } + + /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 38;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 */ +static int match_token_at_39(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return 40; + } + if (match_TableRow(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesTable); + build(context, token); + return 41; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Other(context, token)) { + build(context, token); + return 39; + } + + /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 39;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 */ +static int match_token_at_40(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_Comment(context, token)) { + build(context, token); + return 40; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_ExamplesTable); + build(context, token); + return 41; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Empty(context, token)) { + build(context, token); + return 40; + } + + /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 40;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 */ +static int match_token_at_41(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_TableRow(context, token)) { + build(context, token); + return 41; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 41; + } + if (match_Empty(context, token)) { + build(context, token); + return 41; + } + + /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 41;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 */ +static int match_token_at_43(Token* token, ParserContext* context) { + if (match_DocStringSeparator(context, token)) { + build(context, token); + return 44; + } + if (match_Other(context, token)) { + build(context, token); + return 43; + } + + /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = L"#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 43;} +/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 */ +static int match_token_at_44(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 35; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 37; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 38; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 44; + } + if (match_Empty(context, token)) { + build(context, token); + return 44; + } + + /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 44;} +/* GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 */ +static int match_token_at_45(Token* token, ParserContext* context) { + if (match_DocStringSeparator(context, token)) { + build(context, token); + return 46; + } + if (match_Other(context, token)) { + build(context, token); + return 45; + } + + /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = L"#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 45;} +/* GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 */ +static int match_token_at_46(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 29; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 31; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 32; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 46; + } + if (match_Empty(context, token)) { + build(context, token); + return 46; + } + + /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 46;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 */ +static int match_token_at_47(Token* token, ParserContext* context) { + if (match_DocStringSeparator(context, token)) { + build(context, token); + return 48; + } + if (match_Other(context, token)) { + build(context, token); + return 47; + } + + /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = L"#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 47;} +/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 */ +static int match_token_at_48(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 15; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 17; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return 18; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 48; + } + if (match_Empty(context, token)) { + build(context, token); + return 48; + } + + /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 48;} +/* GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 */ +static int match_token_at_49(Token* token, ParserContext* context) { + if (match_DocStringSeparator(context, token)) { + build(context, token); + return 50; + } + if (match_Other(context, token)) { + build(context, token); + return 49; + } + + /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = L"#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 49;} +/* GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 */ +static int match_token_at_50(Token* token, ParserContext* context) { + if (match_EOF(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return 42; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return 9; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return 11; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return 22; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return 12; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return 23; + } + if (match_Comment(context, token)) { + build(context, token); + return 50; + } + if (match_Empty(context, token)) { + build(context, token); + return 50; + } + + /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 50;} +static int match_token(int state, Token* token, ParserContext* context) { + switch (state) { + case 0: + return match_token_at_0(token, context); + case 1: + return match_token_at_1(token, context); + case 2: + return match_token_at_2(token, context); + case 3: + return match_token_at_3(token, context); + case 4: + return match_token_at_4(token, context); + case 5: + return match_token_at_5(token, context); + case 6: + return match_token_at_6(token, context); + case 7: + return match_token_at_7(token, context); + case 8: + return match_token_at_8(token, context); + case 9: + return match_token_at_9(token, context); + case 10: + return match_token_at_10(token, context); + case 11: + return match_token_at_11(token, context); + case 12: + return match_token_at_12(token, context); + case 13: + return match_token_at_13(token, context); + case 14: + return match_token_at_14(token, context); + case 15: + return match_token_at_15(token, context); + case 16: + return match_token_at_16(token, context); + case 17: + return match_token_at_17(token, context); + case 18: + return match_token_at_18(token, context); + case 19: + return match_token_at_19(token, context); + case 20: + return match_token_at_20(token, context); + case 21: + return match_token_at_21(token, context); + case 22: + return match_token_at_22(token, context); + case 23: + return match_token_at_23(token, context); + case 24: + return match_token_at_24(token, context); + case 25: + return match_token_at_25(token, context); + case 26: + return match_token_at_26(token, context); + case 27: + return match_token_at_27(token, context); + case 28: + return match_token_at_28(token, context); + case 29: + return match_token_at_29(token, context); + case 30: + return match_token_at_30(token, context); + case 31: + return match_token_at_31(token, context); + case 32: + return match_token_at_32(token, context); + case 33: + return match_token_at_33(token, context); + case 34: + return match_token_at_34(token, context); + case 35: + return match_token_at_35(token, context); + case 36: + return match_token_at_36(token, context); + case 37: + return match_token_at_37(token, context); + case 38: + return match_token_at_38(token, context); + case 39: + return match_token_at_39(token, context); + case 40: + return match_token_at_40(token, context); + case 41: + return match_token_at_41(token, context); + case 43: + return match_token_at_43(token, context); + case 44: + return match_token_at_44(token, context); + case 45: + return match_token_at_45(token, context); + case 46: + return match_token_at_46(token, context); + case 47: + return match_token_at_47(token, context); + case 48: + return match_token_at_48(token, context); + case 49: + return match_token_at_49(token, context); + case 50: + return match_token_at_50(token, context); + default: + ErrorList_add_invalid_operation_error(context->errors, state); + ErrorList_jump_to_global_rescue_env(context->errors); + return -1; + } +} + +} diff --git a/cpp/src/gherkin/token_scanner.cpp b/cpp/src/gherkin/token_scanner.cpp index 00013642a..fd46db0c3 100644 --- a/cpp/src/gherkin/token_scanner.cpp +++ b/cpp/src/gherkin/token_scanner.cpp @@ -3,16 +3,22 @@ namespace gherkin { token_scanner::token_scanner(const std::string& text) -: ip_(std::make_unique(text)) -{} +{ reset(text); } token_scanner::token_scanner(const file& file) -: ip_(std::make_unique(file.path)) -{} +{ reset(file); } token_scanner::~token_scanner() {} +void +token_scanner::reset(const std::string& text) +{ reset(std::make_unique(text)); } + +void +token_scanner::reset(const file& file) +{ reset(std::make_unique(file.path)); } + token token_scanner::read() { @@ -28,6 +34,13 @@ token_scanner::read() return Gherkin::Token->new(line => $line_token, location => $location); } +void +token_scanner::reset(input_ptr& ip) +{ + ip_ = std::move(ip); + line_ = 0; +} + next_line_result token_scanner::next_line() { From 216c5937404bb8e2ce8dbb083885be727019df1f Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sun, 30 Apr 2023 18:47:36 +0200 Subject: [PATCH 03/76] chore: more implementation --- cpp/Makefile | 23 +- cpp/gherkin-cpp-rule-type.razor | 15 + cpp/gherkin-cpp.razor | 174 +- cpp/include/gherkin/ast_builder.hpp | 13 + cpp/include/gherkin/parser.hpp | 12 +- cpp/include/gherkin/parser_context.hpp | 20 + cpp/include/gherkin/rule_type.hpp | 44 + cpp/include/gherkin/token.hpp | 13 +- cpp/include/gherkin/token_scanner.hpp | 12 +- cpp/src/gherkin/parser.cpp | 3266 +++++++++++------------- cpp/src/gherkin/parser_context.cpp | 24 + cpp/src/gherkin/token.cpp | 4 +- cpp/src/gherkin/token_scanner.cpp | 14 +- 13 files changed, 1764 insertions(+), 1870 deletions(-) create mode 100644 cpp/gherkin-cpp-rule-type.razor create mode 100644 cpp/include/gherkin/parser_context.hpp create mode 100644 cpp/include/gherkin/rule_type.hpp create mode 100644 cpp/src/gherkin/parser_context.cpp diff --git a/cpp/Makefile b/cpp/Makefile index 1ff5c0977..221882b94 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -1,10 +1,10 @@ SHELL := /usr/bin/env bash GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json -GHERKIN_I18N = src/gherkin/i18n.cpp -GHERKIN_PARSER = src/gherkin/parser.cpp -GHERKIN_RAZOR = gherkin-cpp.razor - +GHERKIN_GENERATED = \ + include/gherkin/rule_type.hpp \ + src/gherkin/parser.cpp \ + src/gherkin/i18n.cpp GHERKIN = bin/gherkin GHERKIN_GENERATE_TOKENS = bin/gherkin-generate-tokens @@ -19,10 +19,14 @@ ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BA .DEFAULT_GOAL = help +define berp-generate-parser = +berp -g ../gherkin.berp -t $< -o $@ --noBOM +endef + help: ## Show this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -generate: $(GHERKIN_PARSER) $(GHERKIN_I18N) ## Generate gherkin parser files +generate: $(GHERKIN_GENERATED) ## Generate gherkin parser files clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files rm -f $(GHERKIN_PARSER) $(GHERKIN_I18N) @@ -44,10 +48,13 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac .built: $(SOURCE_FILES) touch $@ -$(GHERKIN_PARSER): $(GHERKIN_RAZOR) ../gherkin.berp - berp -g ../gherkin.berp -t $< -o $@ --noBOM +include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp + $(berp-generate-parser) + +src/gherkin/parser.cpp: gherkin-cpp.razor ../gherkin.berp + $(berp-generate-parser) -$(GHERKIN_I18N): $(GHERKIN_LANGUAGES_JSON) +src/gherkin/i18n.cpp: $(GHERKIN_LANGUAGES_JSON) jq -f gherkin-i18n.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens diff --git a/cpp/gherkin-cpp-rule-type.razor b/cpp/gherkin-cpp-rule-type.razor new file mode 100644 index 000000000..16c28d0dc --- /dev/null +++ b/cpp/gherkin-cpp-rule-type.razor @@ -0,0 +1,15 @@ +// This file is generated. Do not edit! Edit gherkin-cpp-rule-type.razor instead. +#pragma once + +namespace gherkin { + +enum class rule_type +{ + None = 0, + @foreach(var rule in Model.RuleSet.Where(r => !r.TempRule)) + { @rule.Name.Replace("#", ""), +} + Count +}; + +} diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index ddcb38db0..c30f55402 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -1,4 +1,4 @@ -@using Berp; +@using Berp; @helper CallProduction(ProductionRule production) { switch(production.Type) @@ -36,19 +36,12 @@ {match_@(tokenType)(context, token)} // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. #include +#include #include -//#include +#include namespace gherkin { -enum class rule_type { - None = 0, - @foreach(var rule in Model.RuleSet.Where(r => !r.TempRule)) - { @rule.Name.Replace("#", ""), -} - Count -}; - parser::parser(const parser_info& pi) : pi_{pi} {} @@ -56,7 +49,164 @@ parser::parser(const parser_info& pi) int parser::parse(const file& file) { - ts_.reset(file); + ast_builder_.reset(); + token_scanner_.reset(); + token_matcher_.reset(); + + parser_context context{ + .token_scanner = token_scanner_, + .token_matcher = token_matcher_ + }; + +@{ + var rname = Model.RuleSet.StartRule.Name.Replace("#", ""); +} + start_rule(context, rule_type::@rname); + + std::size_t state = 0; + + while (true) { + auto token = read_token(context); + state = match_token(state, token, context); + + if (token.is_eof()) { + break; + } + } + + end_rule(context, rule_type::@rname); + + if (context.has_errors()) { + // TODO: thow coumpound error + } - return 0; + return get_result(); } + +void +parser::match_token(parser_context& context, token& token) +{ + +} + +token +parser::read_token(parser_context& context) +{ + token t; + + if (context.has_token()) { + t = context.pop_token()); + } else { + t = context.token_scanner.read(); + } + + return t; +} + +void +parser::handle_ast_error(parser_context& context) +{} + +@foreach(var rule in Model.RuleSet.TokenRules) +{ + +parser::match_@(rule.Name.Replace("#", ""))(parser_context& context, token& token) +{ + @if (rule.Name != "#EOF") + { + @:if token.eof(): + @: return False + } + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_@(rule.Name.Replace("#", "")) + ); +} + +} + +parser::match_token(parser_context& context, token& token) +{ + state_map = { + @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) + { + @: @state.Id: self.match_token_at_@(state.Id), + } + } + if state in state_map: + return state_map[state](token, context) + else: + raise RuntimeError("Unknown state: " + str(state)) +} + +@foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) +{ +// @Raw(state.Comment) +std::size_t +match_token_at_@(state.Id)(parser& parser, token& token, parser_context& context) +{ + @foreach(var transition in state.Transitions) + { + @:if @MatchToken(transition.TokenType) + if (transition.LookAheadHint != null) + { + @:if lookahead_@(transition.LookAheadHint.Id)(context, token) + } + foreach(var production in transition.Productions) + { + @CallProduction(production) + } + @:return @transition.TargetState + } + + @HandleParserError(state.Transitions.Select(t => "#" + t.TokenType.ToString()).Distinct(), state) +} + +} + +@foreach(var lookAheadHint in Model.RuleSet.LookAheadHints) +{ + + def lookahead_@(lookAheadHint.Id)(self, context, currentToken): + currentToken.detach + token = None + queue = [] + match = False + while True: + token = self.read_token(context) + token.detach + queue.append(token) + + if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {self.@MatchToken(tokenType) or }False): + match = True + break + + if not (@foreach(var tokenType in lookAheadHint.Skip) {self.@MatchToken(tokenType) or }False): + break + + context.token_queue.extend(queue) + + return match +} + + # private + + def handle_ast_error(self, context, argument, action): + self.handle_external_error(context, True, argument, action) + + def handle_external_error(self, context, default_value, argument, action): + if self.stop_at_first_error: + return action(argument) + + try: + return action(argument) + except CompositeParserException as e: + for error in e.errors: + self.add_error(context, error) + except ParserException as e: + self.add_error(context, e) + return default_value + diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 34796cfd0..395945a9d 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -1,10 +1,23 @@ #pragma once +#include + namespace gherkin { class ast_builder { +public: + ast_builder(); + virtual ~ast_builder(); +private: }; +using ast_builder_ptr = std::unique_ptr; + +template +ast_builder_ptr +new_ast_builder(Args&&... args) +{ return std::make_unique(std::forward(args)...); } + } diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index fab03e2be..e6d51d58b 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,13 +1,15 @@ #pragma once #include +#include #include +#include +#include namespace gherkin { struct parser_info { - ast_builer& builder; std::string language = "en"; }; @@ -17,11 +19,15 @@ class parser parser(const parser_info& pi); virtual ~parser(); - v + int parse(const file& file); private: + void start_rule(parser_context& ctx, ) + parser_info pi_; - token_scanner ts_; + ast_builder ast_builder_; + token_scanner token_scanner_; + token_matcher token_matcher_; }; } diff --git a/cpp/include/gherkin/parser_context.hpp b/cpp/include/gherkin/parser_context.hpp new file mode 100644 index 000000000..c0d8d5ae1 --- /dev/null +++ b/cpp/include/gherkin/parser_context.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include + +namespace gherkin { + +struct parser_context +{ + token_scanner& token_scanner; + token_matcher& token_matcher; + token_queue token_queue; + strings errors; + + bool has_token() const; + bool has_errors() const; +}; + +} diff --git a/cpp/include/gherkin/rule_type.hpp b/cpp/include/gherkin/rule_type.hpp new file mode 100644 index 000000000..1311ac751 --- /dev/null +++ b/cpp/include/gherkin/rule_type.hpp @@ -0,0 +1,44 @@ +// This file is generated. Do not edit! Edit gherkin-cpp-rule-type.razor instead. +#pragma once + +namespace gherkin { + +enum class rule_type +{ + None = 0, + EOF, + Empty, + Comment, + TagLine, + FeatureLine, + RuleLine, + BackgroundLine, + ScenarioLine, + ExamplesLine, + StepLine, + DocStringSeparator, + TableRow, + Language, + Other, + GherkinDocument, + Feature, + FeatureHeader, + Rule, + RuleHeader, + Background, + ScenarioDefinition, + Scenario, + ExamplesDefinition, + Examples, + ExamplesTable, + Step, + StepArg, + DataTable, + DocString, + Tags, + DescriptionHelper, + Description, + Count +}; + +} diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index 6a72261e6..3198d7159 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -2,25 +2,22 @@ #include #include +#include #include namespace gherkin { -struct token { +struct token +{ line line; std::size_t location: - std::string type; - std::string keyword; - std::string keyword_type; - std::string indent; - std::string items; - std::string text; - std::string gherkin_dialect; bool is_eof() const; std::string_view value() const; }; +using token_queue = std::deque; + } diff --git a/cpp/include/gherkin/token_scanner.hpp b/cpp/include/gherkin/token_scanner.hpp index fcc58dc5b..5507e21f7 100644 --- a/cpp/include/gherkin/token_scanner.hpp +++ b/cpp/include/gherkin/token_scanner.hpp @@ -24,11 +24,6 @@ class token_scanner virtual ~token_scanner(); - void reset(const std::string& text); - void reset(const file& file); - - token_scanner(const file& file); - token read(); private: @@ -44,4 +39,11 @@ class token_scanner input_ptr ip_; }; +using token_scanner_ptr = std::unique_ptr; + +template +token_scanner_ptr +new_token_scanner(Args&&... args) +{ return std::make_unique(std::forward(args)...); } + } diff --git a/cpp/src/gherkin/parser.cpp b/cpp/src/gherkin/parser.cpp index 42027d9e1..d717f33fd 100644 --- a/cpp/src/gherkin/parser.cpp +++ b/cpp/src/gherkin/parser.cpp @@ -1,361 +1,344 @@ // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. #include +#include #include -//#include +#include namespace gherkin { -enum class rule_type { - None = 0, - EOF, - Empty, - Comment, - TagLine, - FeatureLine, - RuleLine, - BackgroundLine, - ScenarioLine, - ExamplesLine, - StepLine, - DocStringSeparator, - TableRow, - Language, - Other, - GherkinDocument, - Feature, - FeatureHeader, - Rule, - RuleHeader, - Background, - ScenarioDefinition, - Scenario, - ExamplesDefinition, - Examples, - ExamplesTable, - Step, - StepArg, - DataTable, - DocString, - Tags, - DescriptionHelper, - Description, - Count -}; - -struct ParserContext { - bool stop_at_first_error; - TokenScanner* token_scanner; - TokenMatcher* token_matcher; - Builder* builder; - TokenQueue* token_queue; - ErrorList* errors; -} ParserContext; - -struct Parser { - ParserContext* parser_context; - Builder* builder; - ErrorList* errors; -}; - -static Token* read_token(ParserContext* context); - -static void start_rule(ParserContext* context, RuleType rule_type); - -static void end_rule(ParserContext* context, RuleType rule_type); - -static int match_token(int state, Token* token, ParserContext* context); - -ParserContext* ParserContext_new(TokenScanner* token_scanner, TokenMatcher* token_matcher, Builder* builder, TokenQueue* token_queue, ErrorList* errors) { - ParserContext* parser_context = (ParserContext*)malloc(sizeof(ParserContext)); - parser_context->stop_at_first_error = false; - parser_context->token_scanner = token_scanner; - parser_context->token_matcher = token_matcher; - parser_context->builder = builder; - parser_context->token_queue = token_queue; - parser_context->errors = errors; - return parser_context; -} +parser::parser(const parser_info& pi) +: pi_{pi} +{} -void ParserContext_delete(ParserContext* parser_context) { - free((void*)parser_context); -} +int +parser::parse(const file& file) +{ + ast_builder_.reset(); + token_scanner_.reset(); + token_matcher_.reset(); -Parser* Parser_new(Builder* builder) { - Parser* parser = (Parser*)malloc(sizeof(Parser)); - parser->parser_context = 0; - parser->builder = builder; - parser->errors = ErrorList_new(); - return parser; -} + parser_context context{ + .token_scanner = token_scanner_, + .token_matcher = token_matcher_ + }; -void Parser_delete(Parser* parser) { - if (parser->errors) { - ErrorList_delete(parser->errors); - } - if (parser->parser_context) { - ParserContext_delete(parser->parser_context); - } - free((void*)parser); -} + start_rule(context, rule_type::GherkinDocument); + + std::size_t state = 0; -int Parser_parse(Parser* parser, TokenMatcher* token_matcher, TokenScanner* token_scanner) { - parser->builder->reset(parser->builder); - parser->builder->set_error_context(parser->builder, parser->errors); - token_matcher->reset(token_matcher); - token_matcher->errors = parser->errors; - TokenQueue* token_queue = TokenQueue_new(); - ParserContext* context = ParserContext_new(token_scanner, token_matcher, parser->builder, token_queue, parser->errors); - - int val = 0; - jmp_buf env; - val = setjmp(env); - ErrorList_set_global_rescue_env(parser->errors, &env); - - if (val == 0) { - start_rule(context, Rule_GherkinDocument); - int state = 0; - bool token_is_eof; - Token* token = 0; - do { - token = read_token(context); - token_is_eof = Token_is_eof(token); - state = match_token(state, token, context); - } while (!token_is_eof); - - end_rule(context, Rule_GherkinDocument); + while (true) { + auto token = read_token(context); + state = match_token(state, token, context); + + if (token.is_eof()) { + break; + } } - int result_code = ErrorList_is_empty(context->errors) ? 0 : 1; + end_rule(context, rule_type::GherkinDocument); - ParserContext_delete(context); - TokenQueue_delete(token_queue); - return result_code; -} -bool Parser_has_more_errors(Parser* parser) { - return ErrorList_has_more_errors(parser->errors); -} + if (context.has_errors()) { + // TODO: thow coumpound error + } -Error* Parser_next_error(Parser* parser) { - return ErrorList_next_error(parser->errors); + return get_result(); } -static Token* read_token(ParserContext* context) { - if (!TokenQueue_is_empty(context->token_queue)) - return TokenQueue_remove(context->token_queue); - else - return context->token_scanner->read(context->token_scanner); -} +void +parser::match_token(parser_context& context, token& token) +{ -static void build(ParserContext* context, Token* token) { - context->builder->build(context->builder, token); } -static void handle_ast_error(ParserContext* context, RuleType rule_type, rule_function action) { - if (context->stop_at_first_error) { - action(context->builder, rule_type); - return; - } +token +parser::read_token(parser_context& context) +{ + token t; - jmp_buf env; - int val = setjmp(env); - ErrorList_set_local_rescue_env(context->errors, &env); - if (val == 0) { - action(context->builder, rule_type); + if (context.has_token()) { + t = context.pop_token()); + } else { + t = context.token_scanner.read(); } -} -static void start_rule(ParserContext* context, RuleType rule_type) { - handle_ast_error(context, rule_type, context->builder->start_rule); + return t; } -static void end_rule(ParserContext* context, RuleType rule_type) { - handle_ast_error(context, rule_type, context->builder->end_rule); -} +void +parser::handle_ast_error(parser_context& context) +{} -static bool handle_external_error(ParserContext* context, Token* token, match_function action) { - if (context->stop_at_first_error) { - return action(context->token_matcher, token); - } - jmp_buf env; - int val = setjmp(env); - ErrorList_set_local_rescue_env(context->errors, &env); - if (val == 0) { - return action(context->token_matcher, token); - } - return false; +parser::match_EOF(parser_context& context, token& token) +{ + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_EOF + ); } - -static bool match_EOF(ParserContext* context, Token* token) { - return handle_external_error(context, token, context->token_matcher->match_EOF); -} -static bool match_Empty(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_Empty); -} -static bool match_Comment(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_Comment); -} -static bool match_TagLine(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - bool match_result = handle_external_error(context, token, context->token_matcher->match_TagLine); - if (match_result) { - bool tag_error = ErrorList_check_token_tags_for_whitespace(context->errors, token); - if (tag_error && context->stop_at_first_error) { - ErrorList_jump_to_global_rescue_env(context->errors); - } - } - return match_result; -} -static bool match_FeatureLine(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_FeatureLine); -} -static bool match_RuleLine(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_RuleLine); -} -static bool match_BackgroundLine(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_BackgroundLine); +parser::match_Empty(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_Empty + ); } -static bool match_ScenarioLine(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_ScenarioLine); -} -static bool match_ExamplesLine(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_ExamplesLine); -} -static bool match_StepLine(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_StepLine); -} -static bool match_DocStringSeparator(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_DocStringSeparator); -} -static bool match_TableRow(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_TableRow); + +parser::match_Comment(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_Comment + ); } -static bool match_Language(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_Language); + +parser::match_TagLine(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_TagLine + ); } -static bool match_Other(ParserContext* context, Token* token) { - if (token->matched_type == Token_EOF) { - return false; - }; - return handle_external_error(context, token, context->token_matcher->match_Other); + +parser::match_FeatureLine(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_FeatureLine + ); } -static bool lookahead_0(ParserContext* context) { - Token* token = 0; - TokenQueue* queue = TokenQueue_new(); - bool match = false; - while (true) { - token = read_token(context); - TokenQueue_add(queue, token); +parser::match_RuleLine(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_RuleLine + ); +} - if (match_ScenarioLine(context, token) || false) { - match = true; - break; - } +parser::match_BackgroundLine(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_BackgroundLine + ); +} - if (!(match_Empty(context, token) || match_Comment(context, token) || match_TagLine(context, token) || false)) { - break; - } - } +parser::match_ScenarioLine(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_ScenarioLine + ); +} - TokenQueue_extend(context->token_queue, queue); +parser::match_ExamplesLine(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_ExamplesLine + ); +} - return match; +parser::match_StepLine(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_StepLine + ); } -static bool lookahead_1(ParserContext* context) { - Token* token = 0; - TokenQueue* queue = TokenQueue_new(); - bool match = false; - while (true) { - token = read_token(context); - TokenQueue_add(queue, token); +parser::match_DocStringSeparator(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_DocStringSeparator + ); +} - if (match_ExamplesLine(context, token) || false) { - match = true; - break; - } +parser::match_TableRow(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_TableRow + ); +} - if (!(match_Empty(context, token) || match_Comment(context, token) || match_TagLine(context, token) || false)) { - break; - } - } +parser::match_Language(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_Language + ); +} - TokenQueue_extend(context->token_queue, queue); +parser::match_Other(parser_context& context, token& token) +{ + if token.eof(): + return False + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_Other + ); +} - return match; +parser::match_token(parser_context& context, token& token) +{ + state_map = { + 0: self.match_token_at_0, + 1: self.match_token_at_1, + 2: self.match_token_at_2, + 3: self.match_token_at_3, + 4: self.match_token_at_4, + 5: self.match_token_at_5, + 6: self.match_token_at_6, + 7: self.match_token_at_7, + 8: self.match_token_at_8, + 9: self.match_token_at_9, + 10: self.match_token_at_10, + 11: self.match_token_at_11, + 12: self.match_token_at_12, + 13: self.match_token_at_13, + 14: self.match_token_at_14, + 15: self.match_token_at_15, + 16: self.match_token_at_16, + 17: self.match_token_at_17, + 18: self.match_token_at_18, + 19: self.match_token_at_19, + 20: self.match_token_at_20, + 21: self.match_token_at_21, + 22: self.match_token_at_22, + 23: self.match_token_at_23, + 24: self.match_token_at_24, + 25: self.match_token_at_25, + 26: self.match_token_at_26, + 27: self.match_token_at_27, + 28: self.match_token_at_28, + 29: self.match_token_at_29, + 30: self.match_token_at_30, + 31: self.match_token_at_31, + 32: self.match_token_at_32, + 33: self.match_token_at_33, + 34: self.match_token_at_34, + 35: self.match_token_at_35, + 36: self.match_token_at_36, + 37: self.match_token_at_37, + 38: self.match_token_at_38, + 39: self.match_token_at_39, + 40: self.match_token_at_40, + 41: self.match_token_at_41, + 43: self.match_token_at_43, + 44: self.match_token_at_44, + 45: self.match_token_at_45, + 46: self.match_token_at_46, + 47: self.match_token_at_47, + 48: self.match_token_at_48, + 49: self.match_token_at_49, + 50: self.match_token_at_50, + } + if state in state_map: + return state_map[state](token, context) + else: + raise RuntimeError("Unknown state: " + str(state)) } -/* Start */ -static int match_token_at_0(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { +// Start +parser::match_token_at_0(token& token, parser_context& context) +{ + if self.match_EOF(context, token): build(context, token); - return 42; - } - if (match_Language(context, token)) { + return 42 + if self.match_Language(context, token): start_rule(context, Rule_Feature); start_rule(context, Rule_FeatureHeader); build(context, token); - return 1; - } - if (match_TagLine(context, token)) { + return 1 + if self.match_TagLine(context, token): start_rule(context, Rule_Feature); start_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Tags); build(context, token); - return 2; - } - if (match_FeatureLine(context, token)) { + return 2 + if self.match_FeatureLine(context, token): start_rule(context, Rule_Feature); start_rule(context, Rule_FeatureHeader); build(context, token); - return 3; - } - if (match_Comment(context, token)) { + return 3 + if self.match_Comment(context, token): build(context, token); - return 0; - } - if (match_Empty(context, token)) { + return 0 + if self.match_Empty(context, token): build(context, token); - return 0; - } + return 0 + /* "State: 0 - Start" */ std::string expected_tokens = L"#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; @@ -373,25 +356,24 @@ static int match_token_at_0(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 0;} -/* GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 */ -static int match_token_at_1(Token* token, ParserContext* context) { - if (match_TagLine(context, token)) { + +// GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 +parser::match_token_at_1(token& token, parser_context& context) +{ + if self.match_TagLine(context, token): start_rule(context, Rule_Tags); build(context, token); - return 2; - } - if (match_FeatureLine(context, token)) { + return 2 + if self.match_FeatureLine(context, token): build(context, token); - return 3; - } - if (match_Comment(context, token)) { + return 3 + if self.match_Comment(context, token): build(context, token); - return 1; - } - if (match_Empty(context, token)) { + return 1 + if self.match_Empty(context, token): build(context, token); - return 1; - } + return 1 + /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; @@ -409,25 +391,24 @@ static int match_token_at_1(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 1;} -/* GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 */ -static int match_token_at_2(Token* token, ParserContext* context) { - if (match_TagLine(context, token)) { + +// GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 +parser::match_token_at_2(token& token, parser_context& context) +{ + if self.match_TagLine(context, token): build(context, token); - return 2; - } - if (match_FeatureLine(context, token)) { + return 2 + if self.match_FeatureLine(context, token): end_rule(context, Rule_Tags); build(context, token); - return 3; - } - if (match_Comment(context, token)) { + return 3 + if self.match_Comment(context, token): build(context, token); - return 2; - } - if (match_Empty(context, token)) { + return 2 + if self.match_Empty(context, token): build(context, token); - return 2; - } + return 2 + /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; @@ -445,64 +426,57 @@ static int match_token_at_2(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 2;} -/* GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 */ -static int match_token_at_3(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 +parser::match_token_at_3(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_FeatureHeader); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Empty(context, token)) { + return 42 + if self.match_Empty(context, token): build(context, token); - return 3; - } - if (match_Comment(context, token)) { + return 3 + if self.match_Comment(context, token): build(context, token); - return 5; - } - if (match_BackgroundLine(context, token)) { + return 5 + if self.match_BackgroundLine(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Background); build(context, token); - return 6; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 6 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): start_rule(context, Rule_Description); build(context, token); - return 4; - } + return 4 + /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; @@ -520,66 +494,60 @@ static int match_token_at_3(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 3;} -/* GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 */ -static int match_token_at_4(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 +parser::match_token_at_4(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): end_rule(context, Rule_Description); build(context, token); - return 5; - } - if (match_BackgroundLine(context, token)) { + return 5 + if self.match_BackgroundLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Background); build(context, token); - return 6; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 6 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): build(context, token); - return 4; - } + return 4 + /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; @@ -597,59 +565,53 @@ static int match_token_at_4(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 4;} -/* GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 */ -static int match_token_at_5(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 +parser::match_token_at_5(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_FeatureHeader); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): build(context, token); - return 5; - } - if (match_BackgroundLine(context, token)) { + return 5 + if self.match_BackgroundLine(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Background); build(context, token); - return 6; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 6 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Empty(context, token)) { + return 23 + if self.match_Empty(context, token): build(context, token); - return 5; - } + return 5 + /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; @@ -667,63 +629,56 @@ static int match_token_at_5(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 5;} -/* GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 */ -static int match_token_at_6(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 +parser::match_token_at_6(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Empty(context, token)) { + return 42 + if self.match_Empty(context, token): build(context, token); - return 6; - } - if (match_Comment(context, token)) { + return 6 + if self.match_Comment(context, token): build(context, token); - return 8; - } - if (match_StepLine(context, token)) { + return 8 + if self.match_StepLine(context, token): start_rule(context, Rule_Step); build(context, token); - return 9; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 9 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): start_rule(context, Rule_Description); build(context, token); - return 7; - } + return 7 + /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; @@ -741,65 +696,59 @@ static int match_token_at_6(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 6;} -/* GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 */ -static int match_token_at_7(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 +parser::match_token_at_7(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): end_rule(context, Rule_Description); build(context, token); - return 8; - } - if (match_StepLine(context, token)) { + return 8 + if self.match_StepLine(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_Step); build(context, token); - return 9; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 9 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): build(context, token); - return 7; - } + return 7 + /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; @@ -817,58 +766,52 @@ static int match_token_at_7(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 7;} -/* GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 */ -static int match_token_at_8(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 +parser::match_token_at_8(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): build(context, token); - return 8; - } - if (match_StepLine(context, token)) { + return 8 + if self.match_StepLine(context, token): start_rule(context, Rule_Step); build(context, token); - return 9; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 9 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Empty(context, token)) { + return 23 + if self.match_Empty(context, token): build(context, token); - return 8; - } + return 8 + /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; @@ -886,74 +829,66 @@ static int match_token_at_8(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 8;} -/* GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 */ -static int match_token_at_9(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 +parser::match_token_at_9(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): start_rule(context, Rule_DataTable); build(context, token); - return 10; - } - if (match_DocStringSeparator(context, token)) { + return 10 + if self.match_DocStringSeparator(context, token): start_rule(context, Rule_DocString); build(context, token); - return 49; - } - if (match_StepLine(context, token)) { + return 49 + if self.match_StepLine(context, token): end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 9; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 9 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 9; - } - if (match_Empty(context, token)) { + return 9 + if self.match_Empty(context, token): build(context, token); - return 9; - } + return 9 + /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -971,39 +906,36 @@ static int match_token_at_9(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 9;} -/* GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 */ -static int match_token_at_10(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +parser::match_token_at_10(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): build(context, token); - return 10; - } - if (match_StepLine(context, token)) { + return 10 + if self.match_StepLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 9; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 9 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -1011,34 +943,30 @@ static int match_token_at_10(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 10; - } - if (match_Empty(context, token)) { + return 10 + if self.match_Empty(context, token): build(context, token); - return 10; - } + return 10 + /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -1056,26 +984,25 @@ static int match_token_at_10(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 10;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 */ -static int match_token_at_11(Token* token, ParserContext* context) { - if (match_TagLine(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 +parser::match_token_at_11(token& token, parser_context& context) +{ + if self.match_TagLine(context, token): build(context, token); - return 11; - } - if (match_ScenarioLine(context, token)) { + return 11 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Tags); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_Comment(context, token)) { + return 12 + if self.match_Comment(context, token): build(context, token); - return 11; - } - if (match_Empty(context, token)) { + return 11 + if self.match_Empty(context, token): build(context, token); - return 11; - } + return 11 + /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; @@ -1093,82 +1020,72 @@ static int match_token_at_11(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 11;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 */ -static int match_token_at_12(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 +parser::match_token_at_12(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Empty(context, token)) { + return 42 + if self.match_Empty(context, token): build(context, token); - return 12; - } - if (match_Comment(context, token)) { + return 12 + if self.match_Comment(context, token): build(context, token); - return 14; - } - if (match_StepLine(context, token)) { + return 14 + if self.match_StepLine(context, token): start_rule(context, Rule_Step); build(context, token); - return 15; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 15 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): start_rule(context, Rule_Description); build(context, token); - return 13; - } + return 13 + /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; @@ -1186,48 +1103,43 @@ static int match_token_at_12(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 12;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 */ -static int match_token_at_13(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 +parser::match_token_at_13(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): end_rule(context, Rule_Description); build(context, token); - return 14; - } - if (match_StepLine(context, token)) { + return 14 + if self.match_StepLine(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_Step); build(context, token); - return 15; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 15 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1235,37 +1147,33 @@ static int match_token_at_13(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): build(context, token); - return 13; - } + return 13 + /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; @@ -1283,77 +1191,68 @@ static int match_token_at_13(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 13;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 */ -static int match_token_at_14(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 +parser::match_token_at_14(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): build(context, token); - return 14; - } - if (match_StepLine(context, token)) { + return 14 + if self.match_StepLine(context, token): start_rule(context, Rule_Step); build(context, token); - return 15; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 15 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Empty(context, token)) { + return 23 + if self.match_Empty(context, token): build(context, token); - return 14; - } + return 14 + /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; @@ -1371,53 +1270,47 @@ static int match_token_at_14(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 14;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 */ -static int match_token_at_15(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 +parser::match_token_at_15(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): start_rule(context, Rule_DataTable); build(context, token); - return 16; - } - if (match_DocStringSeparator(context, token)) { + return 16 + if self.match_DocStringSeparator(context, token): start_rule(context, Rule_DocString); build(context, token); - return 47; - } - if (match_StepLine(context, token)) { + return 47 + if self.match_StepLine(context, token): end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 15; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 15 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1425,41 +1318,36 @@ static int match_token_at_15(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 15; - } - if (match_Empty(context, token)) { + return 15 + if self.match_Empty(context, token): build(context, token); - return 15; - } + return 15 + /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -1477,40 +1365,37 @@ static int match_token_at_15(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 15;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 */ -static int match_token_at_16(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +parser::match_token_at_16(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): build(context, token); - return 16; - } - if (match_StepLine(context, token)) { + return 16 + if self.match_StepLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 15; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 15 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1518,10 +1403,8 @@ static int match_token_at_16(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1530,17 +1413,15 @@ static int match_token_at_16(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1548,9 +1429,8 @@ static int match_token_at_16(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1558,16 +1438,14 @@ static int match_token_at_16(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 16; - } - if (match_Empty(context, token)) { + return 16 + if self.match_Empty(context, token): build(context, token); - return 16; - } + return 16 + /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -1585,26 +1463,25 @@ static int match_token_at_16(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 16;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 */ -static int match_token_at_17(Token* token, ParserContext* context) { - if (match_TagLine(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 +parser::match_token_at_17(token& token, parser_context& context) +{ + if self.match_TagLine(context, token): build(context, token); - return 17; - } - if (match_ExamplesLine(context, token)) { + return 17 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Tags); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_Comment(context, token)) { + return 18 + if self.match_Comment(context, token): build(context, token); - return 17; - } - if (match_Empty(context, token)) { + return 17 + if self.match_Empty(context, token): build(context, token); - return 17; - } + return 17 + /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; @@ -1622,42 +1499,38 @@ static int match_token_at_17(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 17;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 */ -static int match_token_at_18(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 +parser::match_token_at_18(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Empty(context, token)) { + return 42 + if self.match_Empty(context, token): build(context, token); - return 18; - } - if (match_Comment(context, token)) { + return 18 + if self.match_Comment(context, token): build(context, token); - return 20; - } - if (match_TableRow(context, token)) { + return 20 + if self.match_TableRow(context, token): start_rule(context, Rule_ExamplesTable); build(context, token); - return 21; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 21 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1665,10 +1538,8 @@ static int match_token_at_18(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1677,17 +1548,15 @@ static int match_token_at_18(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1695,9 +1564,8 @@ static int match_token_at_18(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1705,13 +1573,12 @@ static int match_token_at_18(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): start_rule(context, Rule_Description); build(context, token); - return 19; - } + return 19 + /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; @@ -1729,9 +1596,11 @@ static int match_token_at_18(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 18;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 */ -static int match_token_at_19(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 +parser::match_token_at_19(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1739,32 +1608,27 @@ static int match_token_at_19(Token* token, ParserContext* context) { end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): end_rule(context, Rule_Description); build(context, token); - return 20; - } - if (match_TableRow(context, token)) { + return 20 + if self.match_TableRow(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesTable); build(context, token); - return 21; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 21 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1773,10 +1637,8 @@ static int match_token_at_19(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1786,18 +1648,16 @@ static int match_token_at_19(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1806,9 +1666,8 @@ static int match_token_at_19(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1817,12 +1676,11 @@ static int match_token_at_19(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): build(context, token); - return 19; - } + return 19 + /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; @@ -1840,38 +1698,35 @@ static int match_token_at_19(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 19;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 */ -static int match_token_at_20(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 +parser::match_token_at_20(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): build(context, token); - return 20; - } - if (match_TableRow(context, token)) { + return 20 + if self.match_TableRow(context, token): start_rule(context, Rule_ExamplesTable); build(context, token); - return 21; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 21 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1879,10 +1734,8 @@ static int match_token_at_20(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1891,17 +1744,15 @@ static int match_token_at_20(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1909,9 +1760,8 @@ static int match_token_at_20(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1919,12 +1769,11 @@ static int match_token_at_20(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Empty(context, token)) { + return 23 + if self.match_Empty(context, token): build(context, token); - return 20; - } + return 20 + /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; @@ -1942,9 +1791,11 @@ static int match_token_at_20(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 20;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 */ -static int match_token_at_21(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 +parser::match_token_at_21(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1952,25 +1803,21 @@ static int match_token_at_21(Token* token, ParserContext* context) { end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): build(context, token); - return 21; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 21 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1979,10 +1826,8 @@ static int match_token_at_21(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1992,18 +1837,16 @@ static int match_token_at_21(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -2012,9 +1855,8 @@ static int match_token_at_21(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -2023,16 +1865,14 @@ static int match_token_at_21(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 21; - } - if (match_Empty(context, token)) { + return 21 + if self.match_Empty(context, token): build(context, token); - return 21; - } + return 21 + /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -2050,25 +1890,24 @@ static int match_token_at_21(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 21;} -/* GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 */ -static int match_token_at_22(Token* token, ParserContext* context) { - if (match_TagLine(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 +parser::match_token_at_22(token& token, parser_context& context) +{ + if self.match_TagLine(context, token): build(context, token); - return 22; - } - if (match_RuleLine(context, token)) { + return 22 + if self.match_RuleLine(context, token): end_rule(context, Rule_Tags); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 22; - } - if (match_Empty(context, token)) { + return 22 + if self.match_Empty(context, token): build(context, token); - return 22; - } + return 22 + /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ std::string expected_tokens = L"#TagLine, #RuleLine, #Comment, #Empty"; @@ -2086,67 +1925,60 @@ static int match_token_at_22(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 22;} -/* GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 */ -static int match_token_at_23(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 +parser::match_token_at_23(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Empty(context, token)) { + return 42 + if self.match_Empty(context, token): build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 25; - } - if (match_BackgroundLine(context, token)) { + return 25 + if self.match_BackgroundLine(context, token): end_rule(context, Rule_RuleHeader); start_rule(context, Rule_Background); build(context, token); - return 26; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 26 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): start_rule(context, Rule_Description); build(context, token); - return 24; - } + return 24 + /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; @@ -2164,39 +1996,36 @@ static int match_token_at_23(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 23;} -/* GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 */ -static int match_token_at_24(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 +parser::match_token_at_24(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): end_rule(context, Rule_Description); build(context, token); - return 25; - } - if (match_BackgroundLine(context, token)) { + return 25 + if self.match_BackgroundLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); start_rule(context, Rule_Background); build(context, token); - return 26; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 26 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); @@ -2204,29 +2033,26 @@ static int match_token_at_24(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): build(context, token); - return 24; - } + return 24 + /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; @@ -2244,62 +2070,56 @@ static int match_token_at_24(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 24;} -/* GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 */ -static int match_token_at_25(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 +parser::match_token_at_25(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): build(context, token); - return 25; - } - if (match_BackgroundLine(context, token)) { + return 25 + if self.match_BackgroundLine(context, token): end_rule(context, Rule_RuleHeader); start_rule(context, Rule_Background); build(context, token); - return 26; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 26 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Empty(context, token)) { + return 23 + if self.match_Empty(context, token): build(context, token); - return 25; - } + return 25 + /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; @@ -2317,66 +2137,59 @@ static int match_token_at_25(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 25;} -/* GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 */ -static int match_token_at_26(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 +parser::match_token_at_26(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Background); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Empty(context, token)) { + return 42 + if self.match_Empty(context, token): build(context, token); - return 26; - } - if (match_Comment(context, token)) { + return 26 + if self.match_Comment(context, token): build(context, token); - return 28; - } - if (match_StepLine(context, token)) { + return 28 + if self.match_StepLine(context, token): start_rule(context, Rule_Step); build(context, token); - return 29; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 29 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): start_rule(context, Rule_Description); build(context, token); - return 27; - } + return 27 + /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; @@ -2394,38 +2207,35 @@ static int match_token_at_26(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 26;} -/* GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 */ -static int match_token_at_27(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 +parser::match_token_at_27(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): end_rule(context, Rule_Description); build(context, token); - return 28; - } - if (match_StepLine(context, token)) { + return 28 + if self.match_StepLine(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_Step); build(context, token); - return 29; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 29 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); @@ -2433,29 +2243,26 @@ static int match_token_at_27(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): build(context, token); - return 27; - } + return 27 + /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; @@ -2473,61 +2280,55 @@ static int match_token_at_27(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 27;} -/* GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 */ -static int match_token_at_28(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 +parser::match_token_at_28(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Background); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): build(context, token); - return 28; - } - if (match_StepLine(context, token)) { + return 28 + if self.match_StepLine(context, token): start_rule(context, Rule_Step); build(context, token); - return 29; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 29 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Empty(context, token)) { + return 23 + if self.match_Empty(context, token): build(context, token); - return 28; - } + return 28 + /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; @@ -2545,43 +2346,39 @@ static int match_token_at_28(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 28;} -/* GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 */ -static int match_token_at_29(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 +parser::match_token_at_29(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): start_rule(context, Rule_DataTable); build(context, token); - return 30; - } - if (match_DocStringSeparator(context, token)) { + return 30 + if self.match_DocStringSeparator(context, token): start_rule(context, Rule_DocString); build(context, token); - return 45; - } - if (match_StepLine(context, token)) { + return 45 + if self.match_StepLine(context, token): end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 29; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 29 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); @@ -2589,33 +2386,29 @@ static int match_token_at_29(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 29; - } - if (match_Empty(context, token)) { + return 29 + if self.match_Empty(context, token): build(context, token); - return 29; - } + return 29 + /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -2633,40 +2426,37 @@ static int match_token_at_29(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 29;} -/* GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 */ -static int match_token_at_30(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +parser::match_token_at_30(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): build(context, token); - return 30; - } - if (match_StepLine(context, token)) { + return 30 + if self.match_StepLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 29; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 29 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -2675,18 +2465,16 @@ static int match_token_at_30(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -2694,16 +2482,14 @@ static int match_token_at_30(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 30; - } - if (match_Empty(context, token)) { + return 30 + if self.match_Empty(context, token): build(context, token); - return 30; - } + return 30 + /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -2721,26 +2507,25 @@ static int match_token_at_30(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 30;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 */ -static int match_token_at_31(Token* token, ParserContext* context) { - if (match_TagLine(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 +parser::match_token_at_31(token& token, parser_context& context) +{ + if self.match_TagLine(context, token): build(context, token); - return 31; - } - if (match_ScenarioLine(context, token)) { + return 31 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Tags); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_Comment(context, token)) { + return 32 + if self.match_Comment(context, token): build(context, token); - return 31; - } - if (match_Empty(context, token)) { + return 31 + if self.match_Empty(context, token): build(context, token); - return 31; - } + return 31 + /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; @@ -2758,48 +2543,42 @@ static int match_token_at_31(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 31;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 */ -static int match_token_at_32(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 +parser::match_token_at_32(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Empty(context, token)) { + return 42 + if self.match_Empty(context, token): build(context, token); - return 32; - } - if (match_Comment(context, token)) { + return 32 + if self.match_Comment(context, token): build(context, token); - return 34; - } - if (match_StepLine(context, token)) { + return 34 + if self.match_StepLine(context, token): start_rule(context, Rule_Step); build(context, token); - return 35; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 35 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); @@ -2807,36 +2586,32 @@ static int match_token_at_32(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): start_rule(context, Rule_Description); build(context, token); - return 33; - } + return 33 + /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; @@ -2854,49 +2629,44 @@ static int match_token_at_32(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 32;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 */ -static int match_token_at_33(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 +parser::match_token_at_33(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): end_rule(context, Rule_Description); build(context, token); - return 34; - } - if (match_StepLine(context, token)) { + return 34 + if self.match_StepLine(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_Step); build(context, token); - return 35; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 35 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -2905,25 +2675,22 @@ static int match_token_at_33(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -2931,12 +2698,11 @@ static int match_token_at_33(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): build(context, token); - return 33; - } + return 33 + /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; @@ -2954,44 +2720,39 @@ static int match_token_at_33(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 33;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 */ -static int match_token_at_34(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 +parser::match_token_at_34(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): build(context, token); - return 34; - } - if (match_StepLine(context, token)) { + return 34 + if self.match_StepLine(context, token): start_rule(context, Rule_Step); build(context, token); - return 35; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 35 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); @@ -2999,35 +2760,31 @@ static int match_token_at_34(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Empty(context, token)) { + return 23 + if self.match_Empty(context, token): build(context, token); - return 34; - } + return 34 + /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; @@ -3045,54 +2802,48 @@ static int match_token_at_34(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 34;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 */ -static int match_token_at_35(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 +parser::match_token_at_35(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): start_rule(context, Rule_DataTable); build(context, token); - return 36; - } - if (match_DocStringSeparator(context, token)) { + return 36 + if self.match_DocStringSeparator(context, token): start_rule(context, Rule_DocString); build(context, token); - return 43; - } - if (match_StepLine(context, token)) { + return 43 + if self.match_StepLine(context, token): end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 35; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 35 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3101,25 +2852,22 @@ static int match_token_at_35(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3127,16 +2875,14 @@ static int match_token_at_35(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 35; - } - if (match_Empty(context, token)) { + return 35 + if self.match_Empty(context, token): build(context, token); - return 35; - } + return 35 + /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -3154,9 +2900,11 @@ static int match_token_at_35(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 35;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 */ -static int match_token_at_36(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +parser::match_token_at_36(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3164,31 +2912,26 @@ static int match_token_at_36(Token* token, ParserContext* context) { end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): build(context, token); - return 36; - } - if (match_StepLine(context, token)) { + return 36 + if self.match_StepLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 35; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 35 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3196,10 +2939,8 @@ static int match_token_at_36(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3209,17 +2950,15 @@ static int match_token_at_36(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3227,9 +2966,8 @@ static int match_token_at_36(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3238,16 +2976,14 @@ static int match_token_at_36(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 36; - } - if (match_Empty(context, token)) { + return 36 + if self.match_Empty(context, token): build(context, token); - return 36; - } + return 36 + /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -3265,26 +3001,25 @@ static int match_token_at_36(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 36;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 */ -static int match_token_at_37(Token* token, ParserContext* context) { - if (match_TagLine(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 +parser::match_token_at_37(token& token, parser_context& context) +{ + if self.match_TagLine(context, token): build(context, token); - return 37; - } - if (match_ExamplesLine(context, token)) { + return 37 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Tags); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_Comment(context, token)) { + return 38 + if self.match_Comment(context, token): build(context, token); - return 37; - } - if (match_Empty(context, token)) { + return 37 + if self.match_Empty(context, token): build(context, token); - return 37; - } + return 37 + /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; @@ -3302,9 +3037,11 @@ static int match_token_at_37(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 37;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 */ -static int match_token_at_38(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 +parser::match_token_at_38(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3312,33 +3049,27 @@ static int match_token_at_38(Token* token, ParserContext* context) { end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Empty(context, token)) { + return 42 + if self.match_Empty(context, token): build(context, token); - return 38; - } - if (match_Comment(context, token)) { + return 38 + if self.match_Comment(context, token): build(context, token); - return 40; - } - if (match_TableRow(context, token)) { + return 40 + if self.match_TableRow(context, token): start_rule(context, Rule_ExamplesTable); build(context, token); - return 41; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 41 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3346,10 +3077,8 @@ static int match_token_at_38(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3359,17 +3088,15 @@ static int match_token_at_38(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3377,9 +3104,8 @@ static int match_token_at_38(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3388,13 +3114,12 @@ static int match_token_at_38(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): start_rule(context, Rule_Description); build(context, token); - return 39; - } + return 39 + /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; @@ -3412,9 +3137,11 @@ static int match_token_at_38(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 38;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 */ -static int match_token_at_39(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 +parser::match_token_at_39(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3423,32 +3150,27 @@ static int match_token_at_39(Token* token, ParserContext* context) { end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): end_rule(context, Rule_Description); build(context, token); - return 40; - } - if (match_TableRow(context, token)) { + return 40 + if self.match_TableRow(context, token): end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesTable); build(context, token); - return 41; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 41 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3457,10 +3179,8 @@ static int match_token_at_39(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3471,18 +3191,16 @@ static int match_token_at_39(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3491,9 +3209,8 @@ static int match_token_at_39(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3503,12 +3220,11 @@ static int match_token_at_39(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Other(context, token)) { + return 23 + if self.match_Other(context, token): build(context, token); - return 39; - } + return 39 + /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; @@ -3526,9 +3242,11 @@ static int match_token_at_39(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 39;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 */ -static int match_token_at_40(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 +parser::match_token_at_40(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3536,29 +3254,24 @@ static int match_token_at_40(Token* token, ParserContext* context) { end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_Comment(context, token)) { + return 42 + if self.match_Comment(context, token): build(context, token); - return 40; - } - if (match_TableRow(context, token)) { + return 40 + if self.match_TableRow(context, token): start_rule(context, Rule_ExamplesTable); build(context, token); - return 41; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 41 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3566,10 +3279,8 @@ static int match_token_at_40(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3579,17 +3290,15 @@ static int match_token_at_40(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3597,9 +3306,8 @@ static int match_token_at_40(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3608,12 +3316,11 @@ static int match_token_at_40(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Empty(context, token)) { + return 23 + if self.match_Empty(context, token): build(context, token); - return 40; - } + return 40 + /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; @@ -3631,9 +3338,11 @@ static int match_token_at_40(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 40;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 */ -static int match_token_at_41(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 +parser::match_token_at_41(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3642,25 +3351,21 @@ static int match_token_at_41(Token* token, ParserContext* context) { end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_TableRow(context, token)) { + return 42 + if self.match_TableRow(context, token): build(context, token); - return 41; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 41 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3669,10 +3374,8 @@ static int match_token_at_41(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3683,18 +3386,16 @@ static int match_token_at_41(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3703,9 +3404,8 @@ static int match_token_at_41(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3715,16 +3415,14 @@ static int match_token_at_41(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 41; - } - if (match_Empty(context, token)) { + return 41 + if self.match_Empty(context, token): build(context, token); - return 41; - } + return 41 + /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -3742,16 +3440,17 @@ static int match_token_at_41(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 41;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 */ -static int match_token_at_43(Token* token, ParserContext* context) { - if (match_DocStringSeparator(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +parser::match_token_at_43(token& token, parser_context& context) +{ + if self.match_DocStringSeparator(context, token): build(context, token); - return 44; - } - if (match_Other(context, token)) { + return 44 + if self.match_Other(context, token): build(context, token); - return 43; - } + return 43 + /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ std::string expected_tokens = L"#DocStringSeparator, #Other"; @@ -3769,9 +3468,11 @@ static int match_token_at_43(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 43;} -/* GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 */ -static int match_token_at_44(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +parser::match_token_at_44(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3779,27 +3480,23 @@ static int match_token_at_44(Token* token, ParserContext* context) { end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_StepLine(context, token)) { + return 42 + if self.match_StepLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 35; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 35 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 37; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 37 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3807,10 +3504,8 @@ static int match_token_at_44(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3820,17 +3515,15 @@ static int match_token_at_44(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 38; - } - if (match_ScenarioLine(context, token)) { + return 38 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3838,9 +3531,8 @@ static int match_token_at_44(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3849,16 +3541,14 @@ static int match_token_at_44(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 44; - } - if (match_Empty(context, token)) { + return 44 + if self.match_Empty(context, token): build(context, token); - return 44; - } + return 44 + /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -3876,16 +3566,17 @@ static int match_token_at_44(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 44;} -/* GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 */ -static int match_token_at_45(Token* token, ParserContext* context) { - if (match_DocStringSeparator(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +parser::match_token_at_45(token& token, parser_context& context) +{ + if self.match_DocStringSeparator(context, token): build(context, token); - return 46; - } - if (match_Other(context, token)) { + return 46 + if self.match_Other(context, token): build(context, token); - return 45; - } + return 45 + /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ std::string expected_tokens = L"#DocStringSeparator, #Other"; @@ -3903,36 +3594,34 @@ static int match_token_at_45(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 45;} -/* GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 */ -static int match_token_at_46(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +parser::match_token_at_46(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_StepLine(context, token)) { + return 42 + if self.match_StepLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 29; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 29 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 31; - } - } - if (match_TagLine(context, token)) { + return 31 + if self.match_TagLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -3941,18 +3630,16 @@ static int match_token_at_46(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 32; - } - if (match_RuleLine(context, token)) { + return 32 + if self.match_RuleLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -3960,16 +3647,14 @@ static int match_token_at_46(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 46; - } - if (match_Empty(context, token)) { + return 46 + if self.match_Empty(context, token): build(context, token); - return 46; - } + return 46 + /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -3987,16 +3672,17 @@ static int match_token_at_46(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 46;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 */ -static int match_token_at_47(Token* token, ParserContext* context) { - if (match_DocStringSeparator(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +parser::match_token_at_47(token& token, parser_context& context) +{ + if self.match_DocStringSeparator(context, token): build(context, token); - return 48; - } - if (match_Other(context, token)) { + return 48 + if self.match_Other(context, token): build(context, token); - return 47; - } + return 47 + /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ std::string expected_tokens = L"#DocStringSeparator, #Other"; @@ -4014,36 +3700,34 @@ static int match_token_at_47(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 47;} -/* GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 */ -static int match_token_at_48(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +parser::match_token_at_48(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_StepLine(context, token)) { + return 42 + if self.match_StepLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 15; - } - if (match_TagLine(context, token)) { - if (lookahead_1(context)) { + return 15 + if self.match_TagLine(context, token): + if self.lookahead_1(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); build(context, token); - return 17; - } - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 17 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4051,10 +3735,8 @@ static int match_token_at_48(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4063,17 +3745,15 @@ static int match_token_at_48(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ExamplesLine(context, token)) { + return 22 + if self.match_ExamplesLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); - return 18; - } - if (match_ScenarioLine(context, token)) { + return 18 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4081,9 +3761,8 @@ static int match_token_at_48(Token* token, ParserContext* context) { start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4091,16 +3770,14 @@ static int match_token_at_48(Token* token, ParserContext* context) { start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 48; - } - if (match_Empty(context, token)) { + return 48 + if self.match_Empty(context, token): build(context, token); - return 48; - } + return 48 + /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -4118,16 +3795,17 @@ static int match_token_at_48(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 48;} -/* GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 */ -static int match_token_at_49(Token* token, ParserContext* context) { - if (match_DocStringSeparator(context, token)) { + +// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +parser::match_token_at_49(token& token, parser_context& context) +{ + if self.match_DocStringSeparator(context, token): build(context, token); - return 50; - } - if (match_Other(context, token)) { + return 50 + if self.match_Other(context, token): build(context, token); - return 49; - } + return 49 + /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ std::string expected_tokens = L"#DocStringSeparator, #Other"; @@ -4145,35 +3823,33 @@ static int match_token_at_49(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 49;} -/* GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 */ -static int match_token_at_50(Token* token, ParserContext* context) { - if (match_EOF(context, token)) { + +// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +parser::match_token_at_50(token& token, parser_context& context) +{ + if self.match_EOF(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); - return 42; - } - if (match_StepLine(context, token)) { + return 42 + if self.match_StepLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); - return 9; - } - if (match_TagLine(context, token)) { - if (lookahead_0(context)) { + return 9 + if self.match_TagLine(context, token): + if self.lookahead_0(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Tags); build(context, token); - return 11; - } - } - if (match_TagLine(context, token)) { + return 11 + if self.match_TagLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4181,34 +3857,30 @@ static int match_token_at_50(Token* token, ParserContext* context) { start_rule(context, Rule_RuleHeader); start_rule(context, Rule_Tags); build(context, token); - return 22; - } - if (match_ScenarioLine(context, token)) { + return 22 + if self.match_ScenarioLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); - return 12; - } - if (match_RuleLine(context, token)) { + return 12 + if self.match_RuleLine(context, token): end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); - return 23; - } - if (match_Comment(context, token)) { + return 23 + if self.match_Comment(context, token): build(context, token); - return 50; - } - if (match_Empty(context, token)) { + return 50 + if self.match_Empty(context, token): build(context, token); - return 50; - } + return 50 + /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; @@ -4226,113 +3898,63 @@ static int match_token_at_50(Token* token, ParserContext* context) { add_error(error, token, expected_tokens); return 50;} -static int match_token(int state, Token* token, ParserContext* context) { - switch (state) { - case 0: - return match_token_at_0(token, context); - case 1: - return match_token_at_1(token, context); - case 2: - return match_token_at_2(token, context); - case 3: - return match_token_at_3(token, context); - case 4: - return match_token_at_4(token, context); - case 5: - return match_token_at_5(token, context); - case 6: - return match_token_at_6(token, context); - case 7: - return match_token_at_7(token, context); - case 8: - return match_token_at_8(token, context); - case 9: - return match_token_at_9(token, context); - case 10: - return match_token_at_10(token, context); - case 11: - return match_token_at_11(token, context); - case 12: - return match_token_at_12(token, context); - case 13: - return match_token_at_13(token, context); - case 14: - return match_token_at_14(token, context); - case 15: - return match_token_at_15(token, context); - case 16: - return match_token_at_16(token, context); - case 17: - return match_token_at_17(token, context); - case 18: - return match_token_at_18(token, context); - case 19: - return match_token_at_19(token, context); - case 20: - return match_token_at_20(token, context); - case 21: - return match_token_at_21(token, context); - case 22: - return match_token_at_22(token, context); - case 23: - return match_token_at_23(token, context); - case 24: - return match_token_at_24(token, context); - case 25: - return match_token_at_25(token, context); - case 26: - return match_token_at_26(token, context); - case 27: - return match_token_at_27(token, context); - case 28: - return match_token_at_28(token, context); - case 29: - return match_token_at_29(token, context); - case 30: - return match_token_at_30(token, context); - case 31: - return match_token_at_31(token, context); - case 32: - return match_token_at_32(token, context); - case 33: - return match_token_at_33(token, context); - case 34: - return match_token_at_34(token, context); - case 35: - return match_token_at_35(token, context); - case 36: - return match_token_at_36(token, context); - case 37: - return match_token_at_37(token, context); - case 38: - return match_token_at_38(token, context); - case 39: - return match_token_at_39(token, context); - case 40: - return match_token_at_40(token, context); - case 41: - return match_token_at_41(token, context); - case 43: - return match_token_at_43(token, context); - case 44: - return match_token_at_44(token, context); - case 45: - return match_token_at_45(token, context); - case 46: - return match_token_at_46(token, context); - case 47: - return match_token_at_47(token, context); - case 48: - return match_token_at_48(token, context); - case 49: - return match_token_at_49(token, context); - case 50: - return match_token_at_50(token, context); - default: - ErrorList_add_invalid_operation_error(context->errors, state); - ErrorList_jump_to_global_rescue_env(context->errors); - return -1; - } -} -} + + def lookahead_0(self, context, currentToken): + currentToken.detach + token = None + queue = [] + match = False + while True: + token = self.read_token(context) + token.detach + queue.append(token) + + if (self.match_ScenarioLine(context, token) or False): + match = True + break + + if not (self.match_Empty(context, token) or self.match_Comment(context, token) or self.match_TagLine(context, token) or False): + break + + context.token_queue.extend(queue) + + return match + def lookahead_1(self, context, currentToken): + currentToken.detach + token = None + queue = [] + match = False + while True: + token = self.read_token(context) + token.detach + queue.append(token) + + if (self.match_ExamplesLine(context, token) or False): + match = True + break + + if not (self.match_Empty(context, token) or self.match_Comment(context, token) or self.match_TagLine(context, token) or False): + break + + context.token_queue.extend(queue) + + return match + # private + + def handle_ast_error(self, context, argument, action): + self.handle_external_error(context, True, argument, action) + + def handle_external_error(self, context, default_value, argument, action): + if self.stop_at_first_error: + return action(argument) + + try: + return action(argument) + except CompositeParserException as e: + for error in e.errors: + self.add_error(context, error) + except ParserException as e: + self.add_error(context, e) + return default_value + diff --git a/cpp/src/gherkin/parser_context.cpp b/cpp/src/gherkin/parser_context.cpp new file mode 100644 index 000000000..2b21790c0 --- /dev/null +++ b/cpp/src/gherkin/parser_context.cpp @@ -0,0 +1,24 @@ +#pragma once + +#include + +namespace gherkin { + +bool +parser_context::has_token() const +{ return !token_queue.empty(); } + +token +parser_context::pop_token() +{ + auto t = std::move(token_queue.front()); + token_queue.pop_front(); + + return t; +} + +bool +parser_context::has_errors() const +{ return !errors.empty(); } + +} diff --git a/cpp/src/gherkin/token.cpp b/cpp/src/gherkin/token.cpp index bc060dabc..e73dbd426 100644 --- a/cpp/src/gherkin/token.cpp +++ b/cpp/src/gherkin/token.cpp @@ -4,10 +4,10 @@ namespace gherkin { bool token::is_eof() const -{ return line.empty(); } +{ return line.text.empty(); } std::string_view token::value() const -{ return line.text(); } +{ return line.text; } } diff --git a/cpp/src/gherkin/token_scanner.cpp b/cpp/src/gherkin/token_scanner.cpp index fd46db0c3..797ab355b 100644 --- a/cpp/src/gherkin/token_scanner.cpp +++ b/cpp/src/gherkin/token_scanner.cpp @@ -3,22 +3,16 @@ namespace gherkin { token_scanner::token_scanner(const std::string& text) -{ reset(text); } +: ip_(std::make_unique(text)) +{} token_scanner::token_scanner(const file& file) -{ reset(file); } +: ip_(std::make_unique(file.path)) +{} token_scanner::~token_scanner() {} -void -token_scanner::reset(const std::string& text) -{ reset(std::make_unique(text)); } - -void -token_scanner::reset(const file& file) -{ reset(std::make_unique(file.path)); } - token token_scanner::read() { From 09de7e111fdd05cecf53e6ee547db6b2bbe3626a Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 1 May 2023 18:46:40 +0200 Subject: [PATCH 04/76] feat: CMake build --- cpp/.gitignore | 1 + cpp/CMakeLists.txt | 28 + cpp/Makefile | 10 +- cpp/gherkin-cpp-rule-type.razor | 24 +- cpp/gherkin-cpp.razor | 157 +- cpp/include/gherkin/ast_builder.hpp | 2 + cpp/include/gherkin/parser.hpp | 24 +- cpp/include/gherkin/parser_context.hpp | 13 +- cpp/include/gherkin/rule_type.hpp | 68 +- cpp/include/gherkin/token.hpp | 6 +- cpp/include/gherkin/token_matcher.hpp | 10 + cpp/include/gherkin/token_queue.hpp | 0 cpp/include/gherkin/token_scanner.hpp | 4 +- cpp/src/gherkin/parser.cpp | 3960 --------------- cpp/src/lib/gherkin/CMakeLists.txt | 41 + cpp/src/{ => lib}/gherkin/i18n.cpp | 0 cpp/src/lib/gherkin/parser.cpp | 4540 ++++++++++++++++++ cpp/src/{ => lib}/gherkin/parser_context.cpp | 8 +- cpp/src/{ => lib}/gherkin/token.cpp | 4 + cpp/src/{ => lib}/gherkin/token_scanner.cpp | 0 20 files changed, 4826 insertions(+), 4074 deletions(-) create mode 100644 cpp/.gitignore create mode 100644 cpp/CMakeLists.txt create mode 100644 cpp/include/gherkin/token_matcher.hpp create mode 100644 cpp/include/gherkin/token_queue.hpp delete mode 100644 cpp/src/gherkin/parser.cpp create mode 100644 cpp/src/lib/gherkin/CMakeLists.txt rename cpp/src/{ => lib}/gherkin/i18n.cpp (100%) create mode 100644 cpp/src/lib/gherkin/parser.cpp rename cpp/src/{ => lib}/gherkin/parser_context.cpp (67%) rename cpp/src/{ => lib}/gherkin/token.cpp (87%) rename cpp/src/{ => lib}/gherkin/token_scanner.cpp (100%) diff --git a/cpp/.gitignore b/cpp/.gitignore new file mode 100644 index 000000000..567609b12 --- /dev/null +++ b/cpp/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt new file mode 100644 index 000000000..088fae0d0 --- /dev/null +++ b/cpp/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(gherkin-cpp VERSION 1.0.0 LANGUAGES C CXX) + +include(GNUInstallDirs) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +add_subdirectory(src/lib/gherkin) + +install( + TARGETS + gherkin-cpp_library + EXPORT gherkin-cpp-config + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install( + EXPORT gherkin-cpp-config + FILE gherkin-cpp-config.cmake + NAMESPACE gherkin-cpp:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gherkin-cpp +) diff --git a/cpp/Makefile b/cpp/Makefile index 221882b94..e435605cc 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -3,8 +3,8 @@ SHELL := /usr/bin/env bash GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json GHERKIN_GENERATED = \ include/gherkin/rule_type.hpp \ - src/gherkin/parser.cpp \ - src/gherkin/i18n.cpp + src/lib/gherkin/parser.cpp \ + src/lib/gherkin/i18n.cpp GHERKIN = bin/gherkin GHERKIN_GENERATE_TOKENS = bin/gherkin-generate-tokens @@ -29,7 +29,7 @@ help: ## Show this help generate: $(GHERKIN_GENERATED) ## Generate gherkin parser files clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files - rm -f $(GHERKIN_PARSER) $(GHERKIN_I18N) + rm -f $(GHERKIN_GENERATED) copy-gherkin-languages: $(GHERKIN_LANGUAGES_JSON) ## Copy gherkin-languages.json and/or generate derived files echo "Nothing to do" @@ -51,10 +51,10 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) -src/gherkin/parser.cpp: gherkin-cpp.razor ../gherkin.berp +src/lib/gherkin/parser.cpp: gherkin-cpp.razor ../gherkin.berp $(berp-generate-parser) -src/gherkin/i18n.cpp: $(GHERKIN_LANGUAGES_JSON) +src/lib/gherkin/i18n.cpp: $(GHERKIN_LANGUAGES_JSON) jq -f gherkin-i18n.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens diff --git a/cpp/gherkin-cpp-rule-type.razor b/cpp/gherkin-cpp-rule-type.razor index 16c28d0dc..ba2ddb820 100644 --- a/cpp/gherkin-cpp-rule-type.razor +++ b/cpp/gherkin-cpp-rule-type.razor @@ -1,15 +1,33 @@ // This file is generated. Do not edit! Edit gherkin-cpp-rule-type.razor instead. +@using Berp; +@functions { +public static string ToSnakeCase(string str) +{ + return + string.Concat( + str.Select( + (x, i) => i > 0 && char.IsUpper(x) + ? "_" + x + : x.ToString() + ) + ).ToLower(); +} + +public static string NameOf(Rule rule) +{ return ToSnakeCase(rule.Name.Replace("#", "")); } + +} #pragma once namespace gherkin { enum class rule_type { - None = 0, + none = 0, @foreach(var rule in Model.RuleSet.Where(r => !r.TempRule)) - { @rule.Name.Replace("#", ""), + { @NameOf(rule), } - Count + count }; } diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index c30f55402..aff9cd35a 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -1,4 +1,20 @@ @using Berp; +@functions { +public static string ToSnakeCase(string str) +{ + return + string.Concat( + str.Select( + (x, i) => i > 0 && char.IsUpper(x) + ? "_" + x + : x.ToString() + ) + ).ToLower(); +} + +public static string NameOf(Rule rule) +{ return ToSnakeCase(rule.Name.Replace("#", "")); } +} @helper CallProduction(ProductionRule production) { switch(production.Type) @@ -46,7 +62,7 @@ parser::parser(const parser_info& pi) : pi_{pi} {} -int +std::size_t parser::parse(const file& file) { ast_builder_.reset(); @@ -58,10 +74,7 @@ parser::parse(const file& file) .token_matcher = token_matcher_ }; -@{ - var rname = Model.RuleSet.StartRule.Name.Replace("#", ""); -} - start_rule(context, rule_type::@rname); + start_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); std::size_t state = 0; @@ -74,7 +87,7 @@ parser::parse(const file& file) } } - end_rule(context, rule_type::@rname); + end_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); if (context.has_errors()) { // TODO: thow coumpound error @@ -83,10 +96,10 @@ parser::parse(const file& file) return get_result(); } -void -parser::match_token(parser_context& context, token& token) +std::size_t +parser::match_token(std::size_t state, token& token, parser_context& context) { - + return state; } token @@ -95,7 +108,7 @@ parser::read_token(parser_context& context) token t; if (context.has_token()) { - t = context.pop_token()); + t = context.pop_token(); } else { t = context.token_scanner.read(); } @@ -103,26 +116,35 @@ parser::read_token(parser_context& context) return t; } +std::size_t +parser::get_result() const +{ return 0; } + +namespace detail { + void -parser::handle_ast_error(parser_context& context) +handle_ast_error(parser_context& context) {} @foreach(var rule in Model.RuleSet.TokenRules) { -parser::match_@(rule.Name.Replace("#", ""))(parser_context& context, token& token) +bool +match_@(NameOf(rule))(parser_context& context, token& token) { @if (rule.Name != "#EOF") { - @:if token.eof(): - @: return False + @:if (token.eof()) { + @: return false; + @:} + @: } return handle_external_error( context, false, token, - context.token_matcher.match_@(rule.Name.Replace("#", "")) + context.token_matcher.match_@(NameOf(rule)) ); } @@ -148,18 +170,25 @@ parser::match_token(parser_context& context, token& token) std::size_t match_token_at_@(state.Id)(parser& parser, token& token, parser_context& context) { +@{var indent = "";} @foreach(var transition in state.Transitions) { - @:if @MatchToken(transition.TokenType) + @:if (@MatchToken(transition.TokenType)) { + if (transition.LookAheadHint != null) + { + @:if (lookahead_@(transition.LookAheadHint.Id)(context, token)) { + indent = " "; + } + foreach(var production in transition.Productions) + { + @indent@CallProduction(production) + } + @:@(indent)return transition.TargetState; if (transition.LookAheadHint != null) { - @:if lookahead_@(transition.LookAheadHint.Id)(context, token) + @:} } - foreach(var production in transition.Productions) - { - @CallProduction(production) - } - @:return @transition.TargetState + @:} } @HandleParserError(state.Transitions.Select(t => "#" + t.TokenType.ToString()).Distinct(), state) @@ -170,43 +199,57 @@ match_token_at_@(state.Id)(parser& parser, token& token, parser_context& context @foreach(var lookAheadHint in Model.RuleSet.LookAheadHints) { - def lookahead_@(lookAheadHint.Id)(self, context, currentToken): - currentToken.detach - token = None - queue = [] - match = False - while True: - token = self.read_token(context) - token.detach - queue.append(token) - - if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {self.@MatchToken(tokenType) or }False): - match = True - break - - if not (@foreach(var tokenType in lookAheadHint.Skip) {self.@MatchToken(tokenType) or }False): - break - - context.token_queue.extend(queue) - - return match -} +bool +lookahead_@(lookAheadHint.Id)(parser_context& context, token& current_token) +{ + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach() + queue.push_back(token); + + if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {s@MatchToken(tokenType) || }false) { + match = true; + break; + } + + if not (@foreach(var tokenType in lookAheadHint.Skip) {@MatchToken(tokenType) || }false) { + break; + } - # private + context.push_tokens(queue); - def handle_ast_error(self, context, argument, action): - self.handle_external_error(context, True, argument, action) + return match; +} +} - def handle_external_error(self, context, default_value, argument, action): - if self.stop_at_first_error: - return action(argument) +void +handle_ast_error(parser_context& context, token& token, match_function action) +{ handle_external_error(context, true, token, action); } + +bool +handle_external_error( + parser_context& context, + bool default_value, + token& token, + match_function action +) +{ + if (context.stop_at_first_error) { + return action(token); + } + + try { + return action(token); + } catch (const std::exception& e) { + add_error(context, e); + } - try: - return action(argument) - except CompositeParserException as e: - for error in e.errors: - self.add_error(context, error) - except ParserException as e: - self.add_error(context, e) - return default_value + return default_value; +} +} // namespace detail diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 395945a9d..395eeccb8 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -10,6 +10,8 @@ class ast_builder ast_builder(); virtual ~ast_builder(); + void reset(); + private: }; diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index e6d51d58b..7f318e29b 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,13 +1,18 @@ #pragma once +#include + #include -#include -#include +#include +#include #include #include namespace gherkin { +using match_function = std::function; +using match_functions = std::unordered_map; + struct parser_info { std::string language = "en"; @@ -19,10 +24,21 @@ class parser parser(const parser_info& pi); virtual ~parser(); - int parse(const file& file); + std::size_t parse(const file& file); private: - void start_rule(parser_context& ctx, ) + void start_rule(parser_context& ctx, rule_type r); + void end_rule(parser_context& ctx, rule_type r); + + std::size_t get_result() const; + + std::size_t match_token( + std::size_t state, + token& token, + parser_context& context + ); + + token read_token(parser_context& context); parser_info pi_; ast_builder ast_builder_; diff --git a/cpp/include/gherkin/parser_context.hpp b/cpp/include/gherkin/parser_context.hpp index c0d8d5ae1..d7865258e 100644 --- a/cpp/include/gherkin/parser_context.hpp +++ b/cpp/include/gherkin/parser_context.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -8,12 +9,16 @@ namespace gherkin { struct parser_context { - token_scanner& token_scanner; - token_matcher& token_matcher; - token_queue token_queue; - strings errors; + gherkin::token_scanner& token_scanner; + gherkin::token_matcher& token_matcher; + gherkin::token_queue token_queue; + gherkin::strings errors; bool has_token() const; + + gherkin::token pop_token(); + void push_tokens(const gherkin::token_queue& queue); + bool has_errors() const; }; diff --git a/cpp/include/gherkin/rule_type.hpp b/cpp/include/gherkin/rule_type.hpp index 1311ac751..4b66c50d1 100644 --- a/cpp/include/gherkin/rule_type.hpp +++ b/cpp/include/gherkin/rule_type.hpp @@ -5,40 +5,40 @@ namespace gherkin { enum class rule_type { - None = 0, - EOF, - Empty, - Comment, - TagLine, - FeatureLine, - RuleLine, - BackgroundLine, - ScenarioLine, - ExamplesLine, - StepLine, - DocStringSeparator, - TableRow, - Language, - Other, - GherkinDocument, - Feature, - FeatureHeader, - Rule, - RuleHeader, - Background, - ScenarioDefinition, - Scenario, - ExamplesDefinition, - Examples, - ExamplesTable, - Step, - StepArg, - DataTable, - DocString, - Tags, - DescriptionHelper, - Description, - Count + none = 0, + e_o_f, + empty, + comment, + tag_line, + feature_line, + rule_line, + background_line, + scenario_line, + examples_line, + step_line, + doc_string_separator, + table_row, + language, + other, + gherkin_document, + feature, + feature_header, + rule, + rule_header, + background, + scenario_definition, + scenario, + examples_definition, + examples, + examples_table, + step, + step_arg, + data_table, + doc_string, + tags, + description_helper, + description, + count }; } diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index 3198d7159..c62b03feb 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -10,11 +10,13 @@ namespace gherkin { struct token { - line line; - std::size_t location: + gherkin::line line; + std::size_t location; bool is_eof() const; + void detach(); + std::string_view value() const; }; diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp new file mode 100644 index 000000000..4b8da7601 --- /dev/null +++ b/cpp/include/gherkin/token_matcher.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace gherkin { + +struct token_matcher +{ + void reset(); +}; + +} diff --git a/cpp/include/gherkin/token_queue.hpp b/cpp/include/gherkin/token_queue.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/cpp/include/gherkin/token_scanner.hpp b/cpp/include/gherkin/token_scanner.hpp index 5507e21f7..8a81c2b7a 100644 --- a/cpp/include/gherkin/token_scanner.hpp +++ b/cpp/include/gherkin/token_scanner.hpp @@ -24,11 +24,11 @@ class token_scanner virtual ~token_scanner(); + void reset(); + token read(); private: - void reset(); - next_line_result next_line(); std::istream& input(); diff --git a/cpp/src/gherkin/parser.cpp b/cpp/src/gherkin/parser.cpp deleted file mode 100644 index d717f33fd..000000000 --- a/cpp/src/gherkin/parser.cpp +++ /dev/null @@ -1,3960 +0,0 @@ -// This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. -#include -#include -#include -#include - -namespace gherkin { - -parser::parser(const parser_info& pi) -: pi_{pi} -{} - -int -parser::parse(const file& file) -{ - ast_builder_.reset(); - token_scanner_.reset(); - token_matcher_.reset(); - - parser_context context{ - .token_scanner = token_scanner_, - .token_matcher = token_matcher_ - }; - - start_rule(context, rule_type::GherkinDocument); - - std::size_t state = 0; - - while (true) { - auto token = read_token(context); - state = match_token(state, token, context); - - if (token.is_eof()) { - break; - } - } - - end_rule(context, rule_type::GherkinDocument); - - if (context.has_errors()) { - // TODO: thow coumpound error - } - - return get_result(); -} - -void -parser::match_token(parser_context& context, token& token) -{ - -} - -token -parser::read_token(parser_context& context) -{ - token t; - - if (context.has_token()) { - t = context.pop_token()); - } else { - t = context.token_scanner.read(); - } - - return t; -} - -void -parser::handle_ast_error(parser_context& context) -{} - - -parser::match_EOF(parser_context& context, token& token) -{ - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_EOF - ); -} - -parser::match_Empty(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_Empty - ); -} - -parser::match_Comment(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_Comment - ); -} - -parser::match_TagLine(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_TagLine - ); -} - -parser::match_FeatureLine(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_FeatureLine - ); -} - -parser::match_RuleLine(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_RuleLine - ); -} - -parser::match_BackgroundLine(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_BackgroundLine - ); -} - -parser::match_ScenarioLine(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_ScenarioLine - ); -} - -parser::match_ExamplesLine(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_ExamplesLine - ); -} - -parser::match_StepLine(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_StepLine - ); -} - -parser::match_DocStringSeparator(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_DocStringSeparator - ); -} - -parser::match_TableRow(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_TableRow - ); -} - -parser::match_Language(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_Language - ); -} - -parser::match_Other(parser_context& context, token& token) -{ - if token.eof(): - return False - return - handle_external_error( - context, - false, - token, - context.token_matcher.match_Other - ); -} - -parser::match_token(parser_context& context, token& token) -{ - state_map = { - 0: self.match_token_at_0, - 1: self.match_token_at_1, - 2: self.match_token_at_2, - 3: self.match_token_at_3, - 4: self.match_token_at_4, - 5: self.match_token_at_5, - 6: self.match_token_at_6, - 7: self.match_token_at_7, - 8: self.match_token_at_8, - 9: self.match_token_at_9, - 10: self.match_token_at_10, - 11: self.match_token_at_11, - 12: self.match_token_at_12, - 13: self.match_token_at_13, - 14: self.match_token_at_14, - 15: self.match_token_at_15, - 16: self.match_token_at_16, - 17: self.match_token_at_17, - 18: self.match_token_at_18, - 19: self.match_token_at_19, - 20: self.match_token_at_20, - 21: self.match_token_at_21, - 22: self.match_token_at_22, - 23: self.match_token_at_23, - 24: self.match_token_at_24, - 25: self.match_token_at_25, - 26: self.match_token_at_26, - 27: self.match_token_at_27, - 28: self.match_token_at_28, - 29: self.match_token_at_29, - 30: self.match_token_at_30, - 31: self.match_token_at_31, - 32: self.match_token_at_32, - 33: self.match_token_at_33, - 34: self.match_token_at_34, - 35: self.match_token_at_35, - 36: self.match_token_at_36, - 37: self.match_token_at_37, - 38: self.match_token_at_38, - 39: self.match_token_at_39, - 40: self.match_token_at_40, - 41: self.match_token_at_41, - 43: self.match_token_at_43, - 44: self.match_token_at_44, - 45: self.match_token_at_45, - 46: self.match_token_at_46, - 47: self.match_token_at_47, - 48: self.match_token_at_48, - 49: self.match_token_at_49, - 50: self.match_token_at_50, - } - if state in state_map: - return state_map[state](token, context) - else: - raise RuntimeError("Unknown state: " + str(state)) -} - - -// Start -parser::match_token_at_0(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - build(context, token); - return 42 - if self.match_Language(context, token): - start_rule(context, Rule_Feature); - start_rule(context, Rule_FeatureHeader); - build(context, token); - return 1 - if self.match_TagLine(context, token): - start_rule(context, Rule_Feature); - start_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 2 - if self.match_FeatureLine(context, token): - start_rule(context, Rule_Feature); - start_rule(context, Rule_FeatureHeader); - build(context, token); - return 3 - if self.match_Comment(context, token): - build(context, token); - return 0 - if self.match_Empty(context, token): - build(context, token); - return 0 - - - /* "State: 0 - Start" */ - std::string expected_tokens = L"#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 0;} - -// GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 -parser::match_token_at_1(token& token, parser_context& context) -{ - if self.match_TagLine(context, token): - start_rule(context, Rule_Tags); - build(context, token); - return 2 - if self.match_FeatureLine(context, token): - build(context, token); - return 3 - if self.match_Comment(context, token): - build(context, token); - return 1 - if self.match_Empty(context, token): - build(context, token); - return 1 - - - /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ - std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 1;} - -// GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 -parser::match_token_at_2(token& token, parser_context& context) -{ - if self.match_TagLine(context, token): - build(context, token); - return 2 - if self.match_FeatureLine(context, token): - end_rule(context, Rule_Tags); - build(context, token); - return 3 - if self.match_Comment(context, token): - build(context, token); - return 2 - if self.match_Empty(context, token): - build(context, token); - return 2 - - - /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 2;} - -// GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 -parser::match_token_at_3(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_FeatureHeader); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Empty(context, token): - build(context, token); - return 3 - if self.match_Comment(context, token): - build(context, token); - return 5 - if self.match_BackgroundLine(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Background); - build(context, token); - return 6 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - start_rule(context, Rule_Description); - build(context, token); - return 4 - - - /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 3;} - -// GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 -parser::match_token_at_4(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - end_rule(context, Rule_Description); - build(context, token); - return 5 - if self.match_BackgroundLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Background); - build(context, token); - return 6 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - build(context, token); - return 4 - - - /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 4;} - -// GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 -parser::match_token_at_5(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_FeatureHeader); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - build(context, token); - return 5 - if self.match_BackgroundLine(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Background); - build(context, token); - return 6 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Empty(context, token): - build(context, token); - return 5 - - - /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 5;} - -// GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 -parser::match_token_at_6(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Empty(context, token): - build(context, token); - return 6 - if self.match_Comment(context, token): - build(context, token); - return 8 - if self.match_StepLine(context, token): - start_rule(context, Rule_Step); - build(context, token); - return 9 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - start_rule(context, Rule_Description); - build(context, token); - return 7 - - - /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 6;} - -// GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 -parser::match_token_at_7(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - end_rule(context, Rule_Description); - build(context, token); - return 8 - if self.match_StepLine(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_Step); - build(context, token); - return 9 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - build(context, token); - return 7 - - - /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 7;} - -// GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 -parser::match_token_at_8(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - build(context, token); - return 8 - if self.match_StepLine(context, token): - start_rule(context, Rule_Step); - build(context, token); - return 9 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Empty(context, token): - build(context, token); - return 8 - - - /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 8;} - -// GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 -parser::match_token_at_9(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - start_rule(context, Rule_DataTable); - build(context, token); - return 10 - if self.match_DocStringSeparator(context, token): - start_rule(context, Rule_DocString); - build(context, token); - return 49 - if self.match_StepLine(context, token): - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 9 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 9 - if self.match_Empty(context, token): - build(context, token); - return 9 - - - /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 9;} - -// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 -parser::match_token_at_10(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - build(context, token); - return 10 - if self.match_StepLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 9 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 10 - if self.match_Empty(context, token): - build(context, token); - return 10 - - - /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 10;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 -parser::match_token_at_11(token& token, parser_context& context) -{ - if self.match_TagLine(context, token): - build(context, token); - return 11 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Tags); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_Comment(context, token): - build(context, token); - return 11 - if self.match_Empty(context, token): - build(context, token); - return 11 - - - /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 11;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 -parser::match_token_at_12(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Empty(context, token): - build(context, token); - return 12 - if self.match_Comment(context, token): - build(context, token); - return 14 - if self.match_StepLine(context, token): - start_rule(context, Rule_Step); - build(context, token); - return 15 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - start_rule(context, Rule_Description); - build(context, token); - return 13 - - - /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 12;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 -parser::match_token_at_13(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - end_rule(context, Rule_Description); - build(context, token); - return 14 - if self.match_StepLine(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_Step); - build(context, token); - return 15 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - build(context, token); - return 13 - - - /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 13;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 -parser::match_token_at_14(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - build(context, token); - return 14 - if self.match_StepLine(context, token): - start_rule(context, Rule_Step); - build(context, token); - return 15 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Empty(context, token): - build(context, token); - return 14 - - - /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 14;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 -parser::match_token_at_15(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - start_rule(context, Rule_DataTable); - build(context, token); - return 16 - if self.match_DocStringSeparator(context, token): - start_rule(context, Rule_DocString); - build(context, token); - return 47 - if self.match_StepLine(context, token): - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 15 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 15 - if self.match_Empty(context, token): - build(context, token); - return 15 - - - /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 15;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 -parser::match_token_at_16(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - build(context, token); - return 16 - if self.match_StepLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 15 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 16 - if self.match_Empty(context, token): - build(context, token); - return 16 - - - /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 16;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 -parser::match_token_at_17(token& token, parser_context& context) -{ - if self.match_TagLine(context, token): - build(context, token); - return 17 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Tags); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_Comment(context, token): - build(context, token); - return 17 - if self.match_Empty(context, token): - build(context, token); - return 17 - - - /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 17;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 -parser::match_token_at_18(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Empty(context, token): - build(context, token); - return 18 - if self.match_Comment(context, token): - build(context, token); - return 20 - if self.match_TableRow(context, token): - start_rule(context, Rule_ExamplesTable); - build(context, token); - return 21 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - start_rule(context, Rule_Description); - build(context, token); - return 19 - - - /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 18;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 -parser::match_token_at_19(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - end_rule(context, Rule_Description); - build(context, token); - return 20 - if self.match_TableRow(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesTable); - build(context, token); - return 21 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - build(context, token); - return 19 - - - /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 19;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 -parser::match_token_at_20(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - build(context, token); - return 20 - if self.match_TableRow(context, token): - start_rule(context, Rule_ExamplesTable); - build(context, token); - return 21 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Empty(context, token): - build(context, token); - return 20 - - - /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 20;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 -parser::match_token_at_21(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - build(context, token); - return 21 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 21 - if self.match_Empty(context, token): - build(context, token); - return 21 - - - /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 21;} - -// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 -parser::match_token_at_22(token& token, parser_context& context) -{ - if self.match_TagLine(context, token): - build(context, token); - return 22 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Tags); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 22 - if self.match_Empty(context, token): - build(context, token); - return 22 - - - /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 22;} - -// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 -parser::match_token_at_23(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Empty(context, token): - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 25 - if self.match_BackgroundLine(context, token): - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Background); - build(context, token); - return 26 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - start_rule(context, Rule_Description); - build(context, token); - return 24 - - - /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 23;} - -// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 -parser::match_token_at_24(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - end_rule(context, Rule_Description); - build(context, token); - return 25 - if self.match_BackgroundLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Background); - build(context, token); - return 26 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - build(context, token); - return 24 - - - /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 24;} - -// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 -parser::match_token_at_25(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - build(context, token); - return 25 - if self.match_BackgroundLine(context, token): - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Background); - build(context, token); - return 26 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Empty(context, token): - build(context, token); - return 25 - - - /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 25;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 -parser::match_token_at_26(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Empty(context, token): - build(context, token); - return 26 - if self.match_Comment(context, token): - build(context, token); - return 28 - if self.match_StepLine(context, token): - start_rule(context, Rule_Step); - build(context, token); - return 29 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - start_rule(context, Rule_Description); - build(context, token); - return 27 - - - /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 26;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 -parser::match_token_at_27(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - end_rule(context, Rule_Description); - build(context, token); - return 28 - if self.match_StepLine(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_Step); - build(context, token); - return 29 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - build(context, token); - return 27 - - - /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 27;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 -parser::match_token_at_28(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - build(context, token); - return 28 - if self.match_StepLine(context, token): - start_rule(context, Rule_Step); - build(context, token); - return 29 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Empty(context, token): - build(context, token); - return 28 - - - /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 28;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 -parser::match_token_at_29(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - start_rule(context, Rule_DataTable); - build(context, token); - return 30 - if self.match_DocStringSeparator(context, token): - start_rule(context, Rule_DocString); - build(context, token); - return 45 - if self.match_StepLine(context, token): - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 29 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 29 - if self.match_Empty(context, token): - build(context, token); - return 29 - - - /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 29;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 -parser::match_token_at_30(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - build(context, token); - return 30 - if self.match_StepLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 29 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 30 - if self.match_Empty(context, token): - build(context, token); - return 30 - - - /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 30;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 -parser::match_token_at_31(token& token, parser_context& context) -{ - if self.match_TagLine(context, token): - build(context, token); - return 31 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Tags); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_Comment(context, token): - build(context, token); - return 31 - if self.match_Empty(context, token): - build(context, token); - return 31 - - - /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 31;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 -parser::match_token_at_32(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Empty(context, token): - build(context, token); - return 32 - if self.match_Comment(context, token): - build(context, token); - return 34 - if self.match_StepLine(context, token): - start_rule(context, Rule_Step); - build(context, token); - return 35 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - start_rule(context, Rule_Description); - build(context, token); - return 33 - - - /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 32;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 -parser::match_token_at_33(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - end_rule(context, Rule_Description); - build(context, token); - return 34 - if self.match_StepLine(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_Step); - build(context, token); - return 35 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - build(context, token); - return 33 - - - /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 33;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 -parser::match_token_at_34(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - build(context, token); - return 34 - if self.match_StepLine(context, token): - start_rule(context, Rule_Step); - build(context, token); - return 35 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Empty(context, token): - build(context, token); - return 34 - - - /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 34;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 -parser::match_token_at_35(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - start_rule(context, Rule_DataTable); - build(context, token); - return 36 - if self.match_DocStringSeparator(context, token): - start_rule(context, Rule_DocString); - build(context, token); - return 43 - if self.match_StepLine(context, token): - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 35 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 35 - if self.match_Empty(context, token): - build(context, token); - return 35 - - - /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 35;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 -parser::match_token_at_36(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - build(context, token); - return 36 - if self.match_StepLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 35 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 36 - if self.match_Empty(context, token): - build(context, token); - return 36 - - - /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 36;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 -parser::match_token_at_37(token& token, parser_context& context) -{ - if self.match_TagLine(context, token): - build(context, token); - return 37 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Tags); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_Comment(context, token): - build(context, token); - return 37 - if self.match_Empty(context, token): - build(context, token); - return 37 - - - /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 37;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 -parser::match_token_at_38(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Empty(context, token): - build(context, token); - return 38 - if self.match_Comment(context, token): - build(context, token); - return 40 - if self.match_TableRow(context, token): - start_rule(context, Rule_ExamplesTable); - build(context, token); - return 41 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - start_rule(context, Rule_Description); - build(context, token); - return 39 - - - /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 38;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 -parser::match_token_at_39(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - end_rule(context, Rule_Description); - build(context, token); - return 40 - if self.match_TableRow(context, token): - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesTable); - build(context, token); - return 41 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Other(context, token): - build(context, token); - return 39 - - - /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 39;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 -parser::match_token_at_40(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_Comment(context, token): - build(context, token); - return 40 - if self.match_TableRow(context, token): - start_rule(context, Rule_ExamplesTable); - build(context, token); - return 41 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Empty(context, token): - build(context, token); - return 40 - - - /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 40;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 -parser::match_token_at_41(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_TableRow(context, token): - build(context, token); - return 41 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 41 - if self.match_Empty(context, token): - build(context, token); - return 41 - - - /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 41;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 -parser::match_token_at_43(token& token, parser_context& context) -{ - if self.match_DocStringSeparator(context, token): - build(context, token); - return 44 - if self.match_Other(context, token): - build(context, token); - return 43 - - - /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = L"#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 43;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 -parser::match_token_at_44(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_StepLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 35 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 37 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 38 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 44 - if self.match_Empty(context, token): - build(context, token); - return 44 - - - /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 44;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 -parser::match_token_at_45(token& token, parser_context& context) -{ - if self.match_DocStringSeparator(context, token): - build(context, token); - return 46 - if self.match_Other(context, token): - build(context, token); - return 45 - - - /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = L"#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 45;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 -parser::match_token_at_46(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_StepLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 29 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 31 - if self.match_TagLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 32 - if self.match_RuleLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 46 - if self.match_Empty(context, token): - build(context, token); - return 46 - - - /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 46;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 -parser::match_token_at_47(token& token, parser_context& context) -{ - if self.match_DocStringSeparator(context, token): - build(context, token); - return 48 - if self.match_Other(context, token): - build(context, token); - return 47 - - - /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = L"#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 47;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 -parser::match_token_at_48(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_StepLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 15 - if self.match_TagLine(context, token): - if self.lookahead_1(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 17 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ExamplesLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); - build(context, token); - return 18 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 48 - if self.match_Empty(context, token): - build(context, token); - return 48 - - - /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 48;} - -// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 -parser::match_token_at_49(token& token, parser_context& context) -{ - if self.match_DocStringSeparator(context, token): - build(context, token); - return 50 - if self.match_Other(context, token): - build(context, token); - return 49 - - - /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = L"#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 49;} - -// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 -parser::match_token_at_50(token& token, parser_context& context) -{ - if self.match_EOF(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); - build(context, token); - return 42 - if self.match_StepLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); - build(context, token); - return 9 - if self.match_TagLine(context, token): - if self.lookahead_0(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return 11 - if self.match_TagLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return 22 - if self.match_ScenarioLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); - build(context, token); - return 12 - if self.match_RuleLine(context, token): - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - build(context, token); - return 23 - if self.match_Comment(context, token): - build(context, token); - return 50 - if self.match_Empty(context, token): - build(context, token); - return 50 - - - /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); - } - - add_error(error, token, expected_tokens); - - return 50;} - - - def lookahead_0(self, context, currentToken): - currentToken.detach - token = None - queue = [] - match = False - while True: - token = self.read_token(context) - token.detach - queue.append(token) - - if (self.match_ScenarioLine(context, token) or False): - match = True - break - - if not (self.match_Empty(context, token) or self.match_Comment(context, token) or self.match_TagLine(context, token) or False): - break - - context.token_queue.extend(queue) - - return match - def lookahead_1(self, context, currentToken): - currentToken.detach - token = None - queue = [] - match = False - while True: - token = self.read_token(context) - token.detach - queue.append(token) - - if (self.match_ExamplesLine(context, token) or False): - match = True - break - - if not (self.match_Empty(context, token) or self.match_Comment(context, token) or self.match_TagLine(context, token) or False): - break - - context.token_queue.extend(queue) - - return match - # private - - def handle_ast_error(self, context, argument, action): - self.handle_external_error(context, True, argument, action) - - def handle_external_error(self, context, default_value, argument, action): - if self.stop_at_first_error: - return action(argument) - - try: - return action(argument) - except CompositeParserException as e: - for error in e.errors: - self.add_error(context, error) - except ParserException as e: - self.add_error(context, e) - return default_value - diff --git a/cpp/src/lib/gherkin/CMakeLists.txt b/cpp/src/lib/gherkin/CMakeLists.txt new file mode 100644 index 000000000..f85bfde71 --- /dev/null +++ b/cpp/src/lib/gherkin/CMakeLists.txt @@ -0,0 +1,41 @@ +add_library(gherkin-cpp_library) +add_library(weezu::gherkin-cpp ALIAS gherkin-cpp_library) + +set(INC_DIR "${CMAKE_SOURCE_DIR}/include") + +target_sources( + gherkin-cpp_library + PRIVATE + ${INC_DIR}/gherkin/ast_builder.hpp + ${INC_DIR}/gherkin/file.hpp + ${INC_DIR}/gherkin/i18n.hpp + ${INC_DIR}/gherkin/line.hpp + ${INC_DIR}/gherkin/location.hpp + ${INC_DIR}/gherkin/parser_context.hpp + ${INC_DIR}/gherkin/parser.hpp + ${INC_DIR}/gherkin/rule_type.hpp + ${INC_DIR}/gherkin/token.hpp + ${INC_DIR}/gherkin/token_scanner.hpp + ${INC_DIR}/gherkin/types.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/i18n.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/parser_context.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/token.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/token_scanner.cpp +) + +target_include_directories( + gherkin-cpp_library + PUBLIC + $ + $ + PRIVATE + ${INC_DIR} +) + +set_target_properties( + gherkin-cpp_library + PROPERTIES + OUTPUT_NAME gherkin-cpp +) + diff --git a/cpp/src/gherkin/i18n.cpp b/cpp/src/lib/gherkin/i18n.cpp similarity index 100% rename from cpp/src/gherkin/i18n.cpp rename to cpp/src/lib/gherkin/i18n.cpp diff --git a/cpp/src/lib/gherkin/parser.cpp b/cpp/src/lib/gherkin/parser.cpp new file mode 100644 index 000000000..82e8ae1de --- /dev/null +++ b/cpp/src/lib/gherkin/parser.cpp @@ -0,0 +1,4540 @@ +// This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. +#include +#include +#include +#include + +namespace gherkin { + +parser::parser(const parser_info& pi) +: pi_{pi} +{} + +std::size_t +parser::parse(const file& file) +{ + ast_builder_.reset(); + token_scanner_.reset(); + token_matcher_.reset(); + + parser_context context{ + .token_scanner = token_scanner_, + .token_matcher = token_matcher_ + }; + + start_rule(context, rule_type::gherkin_document); + + std::size_t state = 0; + + while (true) { + auto token = read_token(context); + state = match_token(state, token, context); + + if (token.is_eof()) { + break; + } + } + + end_rule(context, rule_type::gherkin_document); + + if (context.has_errors()) { + // TODO: thow coumpound error + } + + return get_result(); +} + +std::size_t +parser::match_token(std::size_t state, token& token, parser_context& context) +{ + return state; +} + +token +parser::read_token(parser_context& context) +{ + token t; + + if (context.has_token()) { + t = context.pop_token(); + } else { + t = context.token_scanner.read(); + } + + return t; +} + +std::size_t +parser::get_result() const +{ return 0; } + +namespace detail { + +void +handle_ast_error(parser_context& context) +{} + + +bool +match_e_o_f(parser_context& context, token& token) +{ + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_e_o_f + ); +} + +bool +match_empty(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_empty + ); +} + +bool +match_comment(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_comment + ); +} + +bool +match_tag_line(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_tag_line + ); +} + +bool +match_feature_line(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_feature_line + ); +} + +bool +match_rule_line(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_rule_line + ); +} + +bool +match_background_line(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_background_line + ); +} + +bool +match_scenario_line(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_scenario_line + ); +} + +bool +match_examples_line(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_examples_line + ); +} + +bool +match_step_line(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_step_line + ); +} + +bool +match_doc_string_separator(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_doc_string_separator + ); +} + +bool +match_table_row(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_table_row + ); +} + +bool +match_language(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_language + ); +} + +bool +match_other(parser_context& context, token& token) +{ + if (token.eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + context.token_matcher.match_other + ); +} + +parser::match_token(parser_context& context, token& token) +{ + state_map = { + 0: self.match_token_at_0, + 1: self.match_token_at_1, + 2: self.match_token_at_2, + 3: self.match_token_at_3, + 4: self.match_token_at_4, + 5: self.match_token_at_5, + 6: self.match_token_at_6, + 7: self.match_token_at_7, + 8: self.match_token_at_8, + 9: self.match_token_at_9, + 10: self.match_token_at_10, + 11: self.match_token_at_11, + 12: self.match_token_at_12, + 13: self.match_token_at_13, + 14: self.match_token_at_14, + 15: self.match_token_at_15, + 16: self.match_token_at_16, + 17: self.match_token_at_17, + 18: self.match_token_at_18, + 19: self.match_token_at_19, + 20: self.match_token_at_20, + 21: self.match_token_at_21, + 22: self.match_token_at_22, + 23: self.match_token_at_23, + 24: self.match_token_at_24, + 25: self.match_token_at_25, + 26: self.match_token_at_26, + 27: self.match_token_at_27, + 28: self.match_token_at_28, + 29: self.match_token_at_29, + 30: self.match_token_at_30, + 31: self.match_token_at_31, + 32: self.match_token_at_32, + 33: self.match_token_at_33, + 34: self.match_token_at_34, + 35: self.match_token_at_35, + 36: self.match_token_at_36, + 37: self.match_token_at_37, + 38: self.match_token_at_38, + 39: self.match_token_at_39, + 40: self.match_token_at_40, + 41: self.match_token_at_41, + 43: self.match_token_at_43, + 44: self.match_token_at_44, + 45: self.match_token_at_45, + 46: self.match_token_at_46, + 47: self.match_token_at_47, + 48: self.match_token_at_48, + 49: self.match_token_at_49, + 50: self.match_token_at_50, + } + if state in state_map: + return state_map[state](token, context) + else: + raise RuntimeError("Unknown state: " + str(state)) +} + + +// Start +std::size_t +match_token_at_0(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Language(context, token)) { + start_rule(context, Rule_Feature); + start_rule(context, Rule_FeatureHeader); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + start_rule(context, Rule_Feature); + start_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_FeatureLine(context, token)) { + start_rule(context, Rule_Feature); + start_rule(context, Rule_FeatureHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 0 - Start" */ + std::string expected_tokens = L"#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 0;} + +// GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 +std::size_t +match_token_at_1(parser& parser, token& token, parser_context& context) +{ + if (match_TagLine(context, token)) { + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_FeatureLine(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ + std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 1;} + +// GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 +std::size_t +match_token_at_2(parser& parser, token& token, parser_context& context) +{ + if (match_TagLine(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_FeatureLine(context, token)) { + end_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 2;} + +// GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 +std::size_t +match_token_at_3(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_FeatureHeader); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Background); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + + + /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 3;} + +// GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 +std::size_t +match_token_at_4(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Background); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 4;} + +// GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 +std::size_t +match_token_at_5(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_FeatureHeader); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Background); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_FeatureHeader); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 5;} + +// GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 +std::size_t +match_token_at_6(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + + + /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 6;} + +// GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 +std::size_t +match_token_at_7(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 7;} + +// GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 +std::size_t +match_token_at_8(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 8;} + +// GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 +std::size_t +match_token_at_9(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_DataTable); + build(context, token); + return transition.TargetState; + } + if (match_DocStringSeparator(context, token)) { + start_rule(context, Rule_DocString); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 9;} + +// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +std::size_t +match_token_at_10(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 10;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 +std::size_t +match_token_at_11(parser& parser, token& token, parser_context& context) +{ + if (match_TagLine(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Tags); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 11;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 +std::size_t +match_token_at_12(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + + + /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 12;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 +std::size_t +match_token_at_13(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 13;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 +std::size_t +match_token_at_14(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 14;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 +std::size_t +match_token_at_15(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_DataTable); + build(context, token); + return transition.TargetState; + } + if (match_DocStringSeparator(context, token)) { + start_rule(context, Rule_DocString); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 15;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +std::size_t +match_token_at_16(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 16;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 +std::size_t +match_token_at_17(parser& parser, token& token, parser_context& context) +{ + if (match_TagLine(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Tags); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 17;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 +std::size_t +match_token_at_18(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_ExamplesTable); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + + + /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 18;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 +std::size_t +match_token_at_19(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesTable); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 19;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 +std::size_t +match_token_at_20(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_ExamplesTable); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 20;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 +std::size_t +match_token_at_21(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 21;} + +// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 +std::size_t +match_token_at_22(parser& parser, token& token, parser_context& context) +{ + if (match_TagLine(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 22;} + +// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 +std::size_t +match_token_at_23(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Background); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + + + /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 23;} + +// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 +std::size_t +match_token_at_24(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Background); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 24;} + +// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 +std::size_t +match_token_at_25(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_BackgroundLine(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Background); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_RuleHeader); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_RuleHeader); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 25;} + +// GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 +std::size_t +match_token_at_26(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + + + /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 26;} + +// GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 +std::size_t +match_token_at_27(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 27;} + +// GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 +std::size_t +match_token_at_28(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 28;} + +// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 +std::size_t +match_token_at_29(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_DataTable); + build(context, token); + return transition.TargetState; + } + if (match_DocStringSeparator(context, token)) { + start_rule(context, Rule_DocString); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 29;} + +// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +std::size_t +match_token_at_30(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 30;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 +std::size_t +match_token_at_31(parser& parser, token& token, parser_context& context) +{ + if (match_TagLine(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Tags); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 31;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 +std::size_t +match_token_at_32(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + + + /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 32;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 +std::size_t +match_token_at_33(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 33;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 +std::size_t +match_token_at_34(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 34;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 +std::size_t +match_token_at_35(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_DataTable); + build(context, token); + return transition.TargetState; + } + if (match_DocStringSeparator(context, token)) { + start_rule(context, Rule_DocString); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 35;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +std::size_t +match_token_at_36(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DataTable); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 36;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 +std::size_t +match_token_at_37(parser& parser, token& token, parser_context& context) +{ + if (match_TagLine(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Tags); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 37;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 +std::size_t +match_token_at_38(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_ExamplesTable); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + start_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + + + /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 38;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 +std::size_t +match_token_at_39(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + end_rule(context, Rule_Description); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + end_rule(context, Rule_Description); + start_rule(context, Rule_ExamplesTable); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Description); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 39;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 +std::size_t +match_token_at_40(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + start_rule(context, Rule_ExamplesTable); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 40;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 +std::size_t +match_token_at_41(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_TableRow(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_ExamplesTable); + end_rule(context, Rule_Examples); + end_rule(context, Rule_ExamplesDefinition); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 41;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +std::size_t +match_token_at_43(parser& parser, token& token, parser_context& context) +{ + if (match_DocStringSeparator(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = L"#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 43;} + +// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +std::size_t +match_token_at_44(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 44;} + +// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +std::size_t +match_token_at_45(parser& parser, token& token, parser_context& context) +{ + if (match_DocStringSeparator(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = L"#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 45;} + +// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +std::size_t +match_token_at_46(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Rule); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 46;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +std::size_t +match_token_at_47(parser& parser, token& token, parser_context& context) +{ + if (match_DocStringSeparator(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = L"#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 47;} + +// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +std::size_t +match_token_at_48(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ExamplesLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_ExamplesDefinition); + start_rule(context, Rule_Examples); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Scenario); + end_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 48;} + +// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +std::size_t +match_token_at_49(parser& parser, token& token, parser_context& context) +{ + if (match_DocStringSeparator(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Other(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = L"#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 49;} + +// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +std::size_t +match_token_at_50(parser& parser, token& token, parser_context& context) +{ + if (match_EOF(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + end_rule(context, Rule_Feature); + build(context, token); + return transition.TargetState; + } + if (match_StepLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + start_rule(context, Rule_Step); + build(context, token); + return transition.TargetState; + } + if (match_TagLine(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + } + if (match_TagLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + start_rule(context, Rule_Tags); + build(context, token); + return transition.TargetState; + } + if (match_ScenarioLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_ScenarioDefinition); + start_rule(context, Rule_Scenario); + build(context, token); + return transition.TargetState; + } + if (match_RuleLine(context, token)) { + end_rule(context, Rule_DocString); + end_rule(context, Rule_Step); + end_rule(context, Rule_Background); + start_rule(context, Rule_Rule); + start_rule(context, Rule_RuleHeader); + build(context, token); + return transition.TargetState; + } + if (match_Comment(context, token)) { + build(context, token); + return transition.TargetState; + } + if (match_Empty(context, token)) { + build(context, token); + return transition.TargetState; + } + + + /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (stop_at_first_error()) { + throw_error(error, token, expected_tokens); + } + + add_error(error, token, expected_tokens); + + return 50;} + + +bool +lookahead_0(parser_context& context, token& current_token) +{ + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach() + queue.push_back(token); + + if (smatch_ScenarioLine(context, token) || false) { + match = true; + break; + } + + if not (match_Empty(context, token) || match_Comment(context, token) || match_TagLine(context, token) || false) { + break; + } + + context.push_tokens(queue); + + return match; +} +bool +lookahead_1(parser_context& context, token& current_token) +{ + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach() + queue.push_back(token); + + if (smatch_ExamplesLine(context, token) || false) { + match = true; + break; + } + + if not (match_Empty(context, token) || match_Comment(context, token) || match_TagLine(context, token) || false) { + break; + } + + context.push_tokens(queue); + + return match; +} +void +handle_ast_error(parser_context& context, token& token, match_function action) +{ handle_external_error(context, true, token, action); } + +bool +handle_external_error( + parser_context& context, + bool default_value, + token& token, + match_function action +) +{ + if (context.stop_at_first_error) { + return action(token); + } + + try { + return action(token); + } catch (const std::exception& e) { + add_error(context, e); + } + + return default_value; +} + +} // namespace detail diff --git a/cpp/src/gherkin/parser_context.cpp b/cpp/src/lib/gherkin/parser_context.cpp similarity index 67% rename from cpp/src/gherkin/parser_context.cpp rename to cpp/src/lib/gherkin/parser_context.cpp index 2b21790c0..997de0852 100644 --- a/cpp/src/gherkin/parser_context.cpp +++ b/cpp/src/lib/gherkin/parser_context.cpp @@ -1,5 +1,3 @@ -#pragma once - #include namespace gherkin { @@ -8,7 +6,7 @@ bool parser_context::has_token() const { return !token_queue.empty(); } -token +gherkin::token parser_context::pop_token() { auto t = std::move(token_queue.front()); @@ -17,6 +15,10 @@ parser_context::pop_token() return t; } +void +parser_context::push_tokens(const gherkin::token_queue& queue) +{ token_queue.insert(token_queue.end(), queue.begin(), queue.end()); } + bool parser_context::has_errors() const { return !errors.empty(); } diff --git a/cpp/src/gherkin/token.cpp b/cpp/src/lib/gherkin/token.cpp similarity index 87% rename from cpp/src/gherkin/token.cpp rename to cpp/src/lib/gherkin/token.cpp index e73dbd426..4a54dca88 100644 --- a/cpp/src/gherkin/token.cpp +++ b/cpp/src/lib/gherkin/token.cpp @@ -6,6 +6,10 @@ bool token::is_eof() const { return line.text.empty(); } +void +token::detach() +{} + std::string_view token::value() const { return line.text; } diff --git a/cpp/src/gherkin/token_scanner.cpp b/cpp/src/lib/gherkin/token_scanner.cpp similarity index 100% rename from cpp/src/gherkin/token_scanner.cpp rename to cpp/src/lib/gherkin/token_scanner.cpp From 7cad6139ed38b18ee7935ddc88d5e85eb5723d66 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 2 May 2023 12:03:31 +0200 Subject: [PATCH 05/76] chore: cleanup up a bit --- cpp/gherkin-cpp.razor | 168 ++-- cpp/include/gherkin/ast_builder.hpp | 4 + cpp/include/gherkin/parser.hpp | 29 +- cpp/include/gherkin/parser_context.hpp | 25 - cpp/include/gherkin/token_matcher.hpp | 30 +- cpp/include/gherkin/token_queue.hpp | 0 cpp/src/lib/gherkin/CMakeLists.txt | 5 +- cpp/src/lib/gherkin/ast_builder.cpp | 19 + cpp/src/lib/gherkin/parser.cpp | 1108 ++++++++++++------------ cpp/src/lib/gherkin/parser_context.cpp | 26 - cpp/src/lib/gherkin/token_matcher.cpp | 75 ++ 11 files changed, 809 insertions(+), 680 deletions(-) delete mode 100644 cpp/include/gherkin/parser_context.hpp delete mode 100644 cpp/include/gherkin/token_queue.hpp create mode 100644 cpp/src/lib/gherkin/ast_builder.cpp delete mode 100644 cpp/src/lib/gherkin/parser_context.cpp create mode 100644 cpp/src/lib/gherkin/token_matcher.cpp diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index aff9cd35a..d41fe343c 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -49,15 +49,92 @@ public static string NameOf(Rule rule) return @state.Id;} @helper MatchToken(TokenType tokenType) -{match_@(tokenType)(context, token)} +{match_@(ToSnakeCase(tokenType.Name))(context, token)} // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. +#include + #include -#include -#include +#include #include +#include namespace gherkin { +struct parser_context +{ + ast_builder& builder; + token_scanner& scanner; + token_matcher& matcher; + token_queue queue; + strings errors; + bool stop_at_first_error = false; + + bool has_token() const + { return !queue.empty(); } + + token pop_token() + { + auto t = std::move(queue.front()); + queue.pop_front(); + + return t; + } + + void push_tokens(const token_queue& q) + { queue.insert(queue.end(), q.begin(), q.end()); } + + bool has_errors() const + { return !errors.empty(); } + + void add_error(const std::string& e) + { errors.push_back(e); } + + void add_error(const std::exception& e) + { add_error(e.what()); } +}; + +using match_function = std::function; +using match_functions = std::unordered_map; + +static token read_token(parser_context& context); + +static void start_rule(parser_context& context, rule_type rule_type); + +static void end_rule(parser_context& context, rule_type rule_type); + +static int match_token(int state, token& token, parser_context& context); + +template +bool +handle_external_error( + parser_context& context, + bool default_value, + Argument&& argument, + Action&& action +) +{ + if (context.stop_at_first_error) { + return action(argument); + } + + try { + return action(argument); + } catch (const std::exception& e) { + context.add_error(e); + } + + return default_value; +} + +template +void +handle_ast_error( + parser_context& context, + Argument&& argument, + Action&& action +) +{ handle_external_error(context, true, argument, action); } + parser::parser(const parser_info& pi) : pi_{pi} {} @@ -65,13 +142,14 @@ parser::parser(const parser_info& pi) std::size_t parser::parse(const file& file) { - ast_builder_.reset(); - token_scanner_.reset(); - token_matcher_.reset(); + builder_.reset(); + scanner_.reset(); + matcher_.reset(); parser_context context{ - .token_scanner = token_scanner_, - .token_matcher = token_matcher_ + .builder = builder_, + .scanner = scanner_, + .matcher = matcher_ }; start_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); @@ -93,39 +171,31 @@ parser::parse(const file& file) // TODO: thow coumpound error } - return get_result(); -} - -std::size_t -parser::match_token(std::size_t state, token& token, parser_context& context) -{ - return state; + return 0; } +static token -parser::read_token(parser_context& context) +read_token(parser_context& context) { token t; if (context.has_token()) { t = context.pop_token(); } else { - t = context.token_scanner.read(); + t = context.scanner.read(); } return t; } -std::size_t -parser::get_result() const -{ return 0; } +static +void +build(parser_context& context, token& token) +{ context.builder.build(token); } namespace detail { -void -handle_ast_error(parser_context& context) -{} - @foreach(var rule in Model.RuleSet.TokenRules) { @@ -134,7 +204,7 @@ match_@(NameOf(rule))(parser_context& context, token& token) { @if (rule.Name != "#EOF") { - @:if (token.eof()) { + @:if (token.is_eof()) { @: return false; @:} @: @@ -144,26 +214,14 @@ match_@(NameOf(rule))(parser_context& context, token& token) context, false, token, - context.token_matcher.match_@(NameOf(rule)) + [&context](auto& t) { + return context.matcher.match_@(NameOf(rule))(t); + } ); } } -parser::match_token(parser_context& context, token& token) -{ - state_map = { - @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) - { - @: @state.Id: self.match_token_at_@(state.Id), - } - } - if state in state_map: - return state_map[state](token, context) - else: - raise RuntimeError("Unknown state: " + str(state)) -} - @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) { // @Raw(state.Comment) @@ -227,29 +285,17 @@ lookahead_@(lookAheadHint.Id)(parser_context& context, token& current_token) } } -void -handle_ast_error(parser_context& context, token& token, match_function action) -{ handle_external_error(context, true, token, action); } +} // namespace detail -bool -handle_external_error( - parser_context& context, - bool default_value, - token& token, - match_function action -) +std::size_t +parser::match_token(std::size_t state, token& token, parser_context& context) { - if (context.stop_at_first_error) { - return action(token); - } + using match_function = int (parser::*)(token&, parser_context&); + using match_functions = std::unordered_map; - try { - return action(token); - } catch (const std::exception& e) { - add_error(context, e); - } + static const match_functions = { + { 0, &parser::} + }; - return default_value; + return state; } - -} // namespace detail diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 395eeccb8..f3d1b69db 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -2,6 +2,8 @@ #include +#include + namespace gherkin { class ast_builder @@ -12,6 +14,8 @@ class ast_builder void reset(); + void build(token& token); + private: }; diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index 7f318e29b..1c42f0313 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,18 +1,12 @@ #pragma once -#include - #include -#include -#include -#include +#include +#include #include namespace gherkin { -using match_function = std::function; -using match_functions = std::unordered_map; - struct parser_info { std::string language = "en"; @@ -27,23 +21,10 @@ class parser std::size_t parse(const file& file); private: - void start_rule(parser_context& ctx, rule_type r); - void end_rule(parser_context& ctx, rule_type r); - - std::size_t get_result() const; - - std::size_t match_token( - std::size_t state, - token& token, - parser_context& context - ); - - token read_token(parser_context& context); - parser_info pi_; - ast_builder ast_builder_; - token_scanner token_scanner_; - token_matcher token_matcher_; + ast_builder builder_; + token_scanner scanner_; + token_matcher matcher_; }; } diff --git a/cpp/include/gherkin/parser_context.hpp b/cpp/include/gherkin/parser_context.hpp deleted file mode 100644 index d7865258e..000000000 --- a/cpp/include/gherkin/parser_context.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace gherkin { - -struct parser_context -{ - gherkin::token_scanner& token_scanner; - gherkin::token_matcher& token_matcher; - gherkin::token_queue token_queue; - gherkin::strings errors; - - bool has_token() const; - - gherkin::token pop_token(); - void push_tokens(const gherkin::token_queue& queue); - - bool has_errors() const; -}; - -} diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index 4b8da7601..9b7410de5 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -2,9 +2,37 @@ namespace gherkin { -struct token_matcher +struct token_matcher_info { + std::string dialect = "en"; +}; + +class token_matcher +{ +public: + token_matcher(const token_matcher_info& tmi = {}); + virtual ~token_matcher(); + void reset(); + + bool match_feature_line(token& token); + bool match_rule_line(token& token); + bool match_scenario_line(token& token); + bool match_background_line(token& token); + bool match_examples_line(token& token); + bool match_language(token& token); + bool match_tag_line(token& token); + bool match_title_line(token& token); + bool match_e_o_f(token& token); + bool match_empty(token& token); + bool match_comment(token& token); + bool match_other(token& token); + bool match_step_line(token& token); + bool match_doc_string_separator(token& token); + bool match_table_row(token& token); + +private: + token_matcher_info tmi_; }; } diff --git a/cpp/include/gherkin/token_queue.hpp b/cpp/include/gherkin/token_queue.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/cpp/src/lib/gherkin/CMakeLists.txt b/cpp/src/lib/gherkin/CMakeLists.txt index f85bfde71..6c60c8800 100644 --- a/cpp/src/lib/gherkin/CMakeLists.txt +++ b/cpp/src/lib/gherkin/CMakeLists.txt @@ -11,16 +11,17 @@ target_sources( ${INC_DIR}/gherkin/i18n.hpp ${INC_DIR}/gherkin/line.hpp ${INC_DIR}/gherkin/location.hpp - ${INC_DIR}/gherkin/parser_context.hpp ${INC_DIR}/gherkin/parser.hpp ${INC_DIR}/gherkin/rule_type.hpp ${INC_DIR}/gherkin/token.hpp + ${INC_DIR}/gherkin/token_matcher.hpp ${INC_DIR}/gherkin/token_scanner.hpp ${INC_DIR}/gherkin/types.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/ast_builder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/i18n.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/parser_context.cpp ${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/token.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/token_matcher.cpp ${CMAKE_CURRENT_SOURCE_DIR}/token_scanner.cpp ) diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp new file mode 100644 index 000000000..bdff65457 --- /dev/null +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -0,0 +1,19 @@ +#include + +namespace gherkin { + +ast_builder::ast_builder() +{} + +ast_builder::~ast_builder() +{} + +void +ast_builder::reset() +{} + +void +build(token& token) +{} + +} diff --git a/cpp/src/lib/gherkin/parser.cpp b/cpp/src/lib/gherkin/parser.cpp index 82e8ae1de..e7906156e 100644 --- a/cpp/src/lib/gherkin/parser.cpp +++ b/cpp/src/lib/gherkin/parser.cpp @@ -1,11 +1,88 @@ // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. +#include + #include -#include -#include +#include #include +#include namespace gherkin { +struct parser_context +{ + ast_builder& builder; + token_scanner& scanner; + token_matcher& matcher; + token_queue queue; + strings errors; + bool stop_at_first_error = false; + + bool has_token() const + { return !queue.empty(); } + + token pop_token() + { + auto t = std::move(queue.front()); + queue.pop_front(); + + return t; + } + + void push_tokens(const token_queue& q) + { queue.insert(queue.end(), q.begin(), q.end()); } + + bool has_errors() const + { return !errors.empty(); } + + void add_error(const std::string& e) + { errors.push_back(e); } + + void add_error(const std::exception& e) + { add_error(e.what()); } +}; + +using match_function = std::function; +using match_functions = std::unordered_map; + +static token read_token(parser_context& context); + +static void start_rule(parser_context& context, rule_type rule_type); + +static void end_rule(parser_context& context, rule_type rule_type); + +static int match_token(int state, token& token, parser_context& context); + +template +bool +handle_external_error( + parser_context& context, + bool default_value, + Argument&& argument, + Action&& action +) +{ + if (context.stop_at_first_error) { + return action(argument); + } + + try { + return action(argument); + } catch (const std::exception& e) { + context.add_error(e); + } + + return default_value; +} + +template +void +handle_ast_error( + parser_context& context, + Argument&& argument, + Action&& action +) +{ handle_external_error(context, true, argument, action); } + parser::parser(const parser_info& pi) : pi_{pi} {} @@ -13,13 +90,14 @@ parser::parser(const parser_info& pi) std::size_t parser::parse(const file& file) { - ast_builder_.reset(); - token_scanner_.reset(); - token_matcher_.reset(); + builder_.reset(); + scanner_.reset(); + matcher_.reset(); parser_context context{ - .token_scanner = token_scanner_, - .token_matcher = token_matcher_ + .builder = builder_, + .scanner = scanner_, + .matcher = matcher_ }; start_rule(context, rule_type::gherkin_document); @@ -41,39 +119,31 @@ parser::parse(const file& file) // TODO: thow coumpound error } - return get_result(); -} - -std::size_t -parser::match_token(std::size_t state, token& token, parser_context& context) -{ - return state; + return 0; } +static token -parser::read_token(parser_context& context) +read_token(parser_context& context) { token t; if (context.has_token()) { t = context.pop_token(); } else { - t = context.token_scanner.read(); + t = context.scanner.read(); } return t; } -std::size_t -parser::get_result() const -{ return 0; } +static +void +build(parser_context& context, token& token) +{ context.builder.build(token); } namespace detail { -void -handle_ast_error(parser_context& context) -{} - bool match_e_o_f(parser_context& context, token& token) @@ -83,14 +153,16 @@ match_e_o_f(parser_context& context, token& token) context, false, token, - context.token_matcher.match_e_o_f + [&context](auto& t) { + return context.matcher.match_e_o_f(t); + } ); } bool match_empty(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -99,14 +171,16 @@ match_empty(parser_context& context, token& token) context, false, token, - context.token_matcher.match_empty + [&context](auto& t) { + return context.matcher.match_empty(t); + } ); } bool match_comment(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -115,14 +189,16 @@ match_comment(parser_context& context, token& token) context, false, token, - context.token_matcher.match_comment + [&context](auto& t) { + return context.matcher.match_comment(t); + } ); } bool match_tag_line(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -131,14 +207,16 @@ match_tag_line(parser_context& context, token& token) context, false, token, - context.token_matcher.match_tag_line + [&context](auto& t) { + return context.matcher.match_tag_line(t); + } ); } bool match_feature_line(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -147,14 +225,16 @@ match_feature_line(parser_context& context, token& token) context, false, token, - context.token_matcher.match_feature_line + [&context](auto& t) { + return context.matcher.match_feature_line(t); + } ); } bool match_rule_line(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -163,14 +243,16 @@ match_rule_line(parser_context& context, token& token) context, false, token, - context.token_matcher.match_rule_line + [&context](auto& t) { + return context.matcher.match_rule_line(t); + } ); } bool match_background_line(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -179,14 +261,16 @@ match_background_line(parser_context& context, token& token) context, false, token, - context.token_matcher.match_background_line + [&context](auto& t) { + return context.matcher.match_background_line(t); + } ); } bool match_scenario_line(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -195,14 +279,16 @@ match_scenario_line(parser_context& context, token& token) context, false, token, - context.token_matcher.match_scenario_line + [&context](auto& t) { + return context.matcher.match_scenario_line(t); + } ); } bool match_examples_line(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -211,14 +297,16 @@ match_examples_line(parser_context& context, token& token) context, false, token, - context.token_matcher.match_examples_line + [&context](auto& t) { + return context.matcher.match_examples_line(t); + } ); } bool match_step_line(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -227,14 +315,16 @@ match_step_line(parser_context& context, token& token) context, false, token, - context.token_matcher.match_step_line + [&context](auto& t) { + return context.matcher.match_step_line(t); + } ); } bool match_doc_string_separator(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -243,14 +333,16 @@ match_doc_string_separator(parser_context& context, token& token) context, false, token, - context.token_matcher.match_doc_string_separator + [&context](auto& t) { + return context.matcher.match_doc_string_separator(t); + } ); } bool match_table_row(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -259,14 +351,16 @@ match_table_row(parser_context& context, token& token) context, false, token, - context.token_matcher.match_table_row + [&context](auto& t) { + return context.matcher.match_table_row(t); + } ); } bool match_language(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -275,14 +369,16 @@ match_language(parser_context& context, token& token) context, false, token, - context.token_matcher.match_language + [&context](auto& t) { + return context.matcher.match_language(t); + } ); } bool match_other(parser_context& context, token& token) { - if (token.eof()) { + if (token.is_eof()) { return false; } @@ -291,103 +387,45 @@ match_other(parser_context& context, token& token) context, false, token, - context.token_matcher.match_other + [&context](auto& t) { + return context.matcher.match_other(t); + } ); } -parser::match_token(parser_context& context, token& token) -{ - state_map = { - 0: self.match_token_at_0, - 1: self.match_token_at_1, - 2: self.match_token_at_2, - 3: self.match_token_at_3, - 4: self.match_token_at_4, - 5: self.match_token_at_5, - 6: self.match_token_at_6, - 7: self.match_token_at_7, - 8: self.match_token_at_8, - 9: self.match_token_at_9, - 10: self.match_token_at_10, - 11: self.match_token_at_11, - 12: self.match_token_at_12, - 13: self.match_token_at_13, - 14: self.match_token_at_14, - 15: self.match_token_at_15, - 16: self.match_token_at_16, - 17: self.match_token_at_17, - 18: self.match_token_at_18, - 19: self.match_token_at_19, - 20: self.match_token_at_20, - 21: self.match_token_at_21, - 22: self.match_token_at_22, - 23: self.match_token_at_23, - 24: self.match_token_at_24, - 25: self.match_token_at_25, - 26: self.match_token_at_26, - 27: self.match_token_at_27, - 28: self.match_token_at_28, - 29: self.match_token_at_29, - 30: self.match_token_at_30, - 31: self.match_token_at_31, - 32: self.match_token_at_32, - 33: self.match_token_at_33, - 34: self.match_token_at_34, - 35: self.match_token_at_35, - 36: self.match_token_at_36, - 37: self.match_token_at_37, - 38: self.match_token_at_38, - 39: self.match_token_at_39, - 40: self.match_token_at_40, - 41: self.match_token_at_41, - 43: self.match_token_at_43, - 44: self.match_token_at_44, - 45: self.match_token_at_45, - 46: self.match_token_at_46, - 47: self.match_token_at_47, - 48: self.match_token_at_48, - 49: self.match_token_at_49, - 50: self.match_token_at_50, - } - if state in state_map: - return state_map[state](token, context) - else: - raise RuntimeError("Unknown state: " + str(state)) -} - // Start std::size_t match_token_at_0(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { build(context, token); return transition.TargetState; } - if (match_Language(context, token)) { + if (match_language(context, token)) { start_rule(context, Rule_Feature); start_rule(context, Rule_FeatureHeader); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { start_rule(context, Rule_Feature); start_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Tags); build(context, token); return transition.TargetState; } - if (match_FeatureLine(context, token)) { + if (match_feature_line(context, token)) { start_rule(context, Rule_Feature); start_rule(context, Rule_FeatureHeader); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -414,20 +452,20 @@ match_token_at_0(parser& parser, token& token, parser_context& context) std::size_t match_token_at_1(parser& parser, token& token, parser_context& context) { - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { start_rule(context, Rule_Tags); build(context, token); return transition.TargetState; } - if (match_FeatureLine(context, token)) { + if (match_feature_line(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -454,20 +492,20 @@ match_token_at_1(parser& parser, token& token, parser_context& context) std::size_t match_token_at_2(parser& parser, token& token, parser_context& context) { - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { build(context, token); return transition.TargetState; } - if (match_FeatureLine(context, token)) { + if (match_feature_line(context, token)) { end_rule(context, Rule_Tags); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -494,27 +532,27 @@ match_token_at_2(parser& parser, token& token, parser_context& context) std::size_t match_token_at_3(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_FeatureHeader); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_BackgroundLine(context, token)) { + if (match_background_line(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Background); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); @@ -523,7 +561,7 @@ match_token_at_3(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); @@ -531,21 +569,21 @@ match_token_at_3(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { start_rule(context, Rule_Description); build(context, token); return transition.TargetState; @@ -573,26 +611,26 @@ match_token_at_3(parser& parser, token& token, parser_context& context) std::size_t match_token_at_4(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { end_rule(context, Rule_Description); build(context, token); return transition.TargetState; } - if (match_BackgroundLine(context, token)) { + if (match_background_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Background); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); @@ -602,7 +640,7 @@ match_token_at_4(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); @@ -611,7 +649,7 @@ match_token_at_4(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); @@ -619,7 +657,7 @@ match_token_at_4(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); @@ -627,7 +665,7 @@ match_token_at_4(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -654,23 +692,23 @@ match_token_at_4(parser& parser, token& token, parser_context& context) std::size_t match_token_at_5(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_FeatureHeader); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_BackgroundLine(context, token)) { + if (match_background_line(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Background); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); @@ -679,7 +717,7 @@ match_token_at_5(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); @@ -687,21 +725,21 @@ match_token_at_5(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_FeatureHeader); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -728,26 +766,26 @@ match_token_at_5(parser& parser, token& token, parser_context& context) std::size_t match_token_at_6(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); @@ -756,7 +794,7 @@ match_token_at_6(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); @@ -764,21 +802,21 @@ match_token_at_6(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { start_rule(context, Rule_Description); build(context, token); return transition.TargetState; @@ -806,25 +844,25 @@ match_token_at_6(parser& parser, token& token, parser_context& context) std::size_t match_token_at_7(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { end_rule(context, Rule_Description); build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); @@ -834,7 +872,7 @@ match_token_at_7(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); @@ -843,7 +881,7 @@ match_token_at_7(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); @@ -851,7 +889,7 @@ match_token_at_7(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); @@ -859,7 +897,7 @@ match_token_at_7(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -886,22 +924,22 @@ match_token_at_7(parser& parser, token& token, parser_context& context) std::size_t match_token_at_8(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); @@ -910,7 +948,7 @@ match_token_at_8(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); @@ -918,21 +956,21 @@ match_token_at_8(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_Rule); start_rule(context, Rule_RuleHeader); build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -959,30 +997,30 @@ match_token_at_8(parser& parser, token& token, parser_context& context) std::size_t match_token_at_9(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { start_rule(context, Rule_DataTable); build(context, token); return transition.TargetState; } - if (match_DocStringSeparator(context, token)) { + if (match_doc_string_separator(context, token)) { start_rule(context, Rule_DocString); build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -992,7 +1030,7 @@ match_token_at_9(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); @@ -1001,7 +1039,7 @@ match_token_at_9(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); @@ -1009,7 +1047,7 @@ match_token_at_9(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_Rule); @@ -1017,11 +1055,11 @@ match_token_at_9(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -1048,7 +1086,7 @@ match_token_at_9(parser& parser, token& token, parser_context& context) std::size_t match_token_at_10(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -1056,18 +1094,18 @@ match_token_at_10(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); @@ -1078,7 +1116,7 @@ match_token_at_10(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -1088,7 +1126,7 @@ match_token_at_10(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -1097,7 +1135,7 @@ match_token_at_10(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -1106,11 +1144,11 @@ match_token_at_10(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -1137,21 +1175,21 @@ match_token_at_10(parser& parser, token& token, parser_context& context) std::size_t match_token_at_11(parser& parser, token& token, parser_context& context) { - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Tags); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -1178,27 +1216,27 @@ match_token_at_11(parser& parser, token& token, parser_context& context) std::size_t match_token_at_12(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); @@ -1206,7 +1244,7 @@ match_token_at_12(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1216,7 +1254,7 @@ match_token_at_12(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); @@ -1225,13 +1263,13 @@ match_token_at_12(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); @@ -1239,7 +1277,7 @@ match_token_at_12(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); @@ -1247,7 +1285,7 @@ match_token_at_12(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { start_rule(context, Rule_Description); build(context, token); return transition.TargetState; @@ -1275,7 +1313,7 @@ match_token_at_12(parser& parser, token& token, parser_context& context) std::size_t match_token_at_13(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1283,18 +1321,18 @@ match_token_at_13(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { end_rule(context, Rule_Description); build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesDefinition); @@ -1303,7 +1341,7 @@ match_token_at_13(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); @@ -1314,7 +1352,7 @@ match_token_at_13(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1324,14 +1362,14 @@ match_token_at_13(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1340,7 +1378,7 @@ match_token_at_13(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1349,7 +1387,7 @@ match_token_at_13(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -1376,23 +1414,23 @@ match_token_at_13(parser& parser, token& token, parser_context& context) std::size_t match_token_at_14(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); @@ -1400,7 +1438,7 @@ match_token_at_14(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1410,7 +1448,7 @@ match_token_at_14(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); @@ -1419,13 +1457,13 @@ match_token_at_14(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); @@ -1433,7 +1471,7 @@ match_token_at_14(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Rule); @@ -1441,7 +1479,7 @@ match_token_at_14(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -1468,7 +1506,7 @@ match_token_at_14(parser& parser, token& token, parser_context& context) std::size_t match_token_at_15(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1476,23 +1514,23 @@ match_token_at_15(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { start_rule(context, Rule_DataTable); build(context, token); return transition.TargetState; } - if (match_DocStringSeparator(context, token)) { + if (match_doc_string_separator(context, token)) { start_rule(context, Rule_DocString); build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); @@ -1501,7 +1539,7 @@ match_token_at_15(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1512,7 +1550,7 @@ match_token_at_15(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1522,14 +1560,14 @@ match_token_at_15(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1538,7 +1576,7 @@ match_token_at_15(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -1547,11 +1585,11 @@ match_token_at_15(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -1578,7 +1616,7 @@ match_token_at_15(parser& parser, token& token, parser_context& context) std::size_t match_token_at_16(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1587,18 +1625,18 @@ match_token_at_16(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); @@ -1608,7 +1646,7 @@ match_token_at_16(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); @@ -1620,7 +1658,7 @@ match_token_at_16(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1631,7 +1669,7 @@ match_token_at_16(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); @@ -1639,7 +1677,7 @@ match_token_at_16(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1649,7 +1687,7 @@ match_token_at_16(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -1659,11 +1697,11 @@ match_token_at_16(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -1690,21 +1728,21 @@ match_token_at_16(parser& parser, token& token, parser_context& context) std::size_t match_token_at_17(parser& parser, token& token, parser_context& context) { - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Tags); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -1731,7 +1769,7 @@ match_token_at_17(parser& parser, token& token, parser_context& context) std::size_t match_token_at_18(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1740,20 +1778,20 @@ match_token_at_18(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { start_rule(context, Rule_ExamplesTable); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1763,7 +1801,7 @@ match_token_at_18(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1775,7 +1813,7 @@ match_token_at_18(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1786,7 +1824,7 @@ match_token_at_18(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); @@ -1794,7 +1832,7 @@ match_token_at_18(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1804,7 +1842,7 @@ match_token_at_18(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1814,7 +1852,7 @@ match_token_at_18(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { start_rule(context, Rule_Description); build(context, token); return transition.TargetState; @@ -1842,7 +1880,7 @@ match_token_at_18(parser& parser, token& token, parser_context& context) std::size_t match_token_at_19(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1852,18 +1890,18 @@ match_token_at_19(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { end_rule(context, Rule_Description); build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesTable); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); @@ -1874,7 +1912,7 @@ match_token_at_19(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); @@ -1887,7 +1925,7 @@ match_token_at_19(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1899,7 +1937,7 @@ match_token_at_19(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1908,7 +1946,7 @@ match_token_at_19(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1919,7 +1957,7 @@ match_token_at_19(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1930,7 +1968,7 @@ match_token_at_19(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -1957,7 +1995,7 @@ match_token_at_19(parser& parser, token& token, parser_context& context) std::size_t match_token_at_20(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -1966,16 +2004,16 @@ match_token_at_20(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { start_rule(context, Rule_ExamplesTable); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1985,7 +2023,7 @@ match_token_at_20(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -1997,7 +2035,7 @@ match_token_at_20(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -2008,7 +2046,7 @@ match_token_at_20(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); @@ -2016,7 +2054,7 @@ match_token_at_20(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -2026,7 +2064,7 @@ match_token_at_20(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -2036,7 +2074,7 @@ match_token_at_20(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -2063,7 +2101,7 @@ match_token_at_20(parser& parser, token& token, parser_context& context) std::size_t match_token_at_21(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -2073,11 +2111,11 @@ match_token_at_21(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); @@ -2088,7 +2126,7 @@ match_token_at_21(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); @@ -2101,7 +2139,7 @@ match_token_at_21(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -2113,7 +2151,7 @@ match_token_at_21(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -2122,7 +2160,7 @@ match_token_at_21(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -2133,7 +2171,7 @@ match_token_at_21(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -2144,11 +2182,11 @@ match_token_at_21(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -2175,20 +2213,20 @@ match_token_at_21(parser& parser, token& token, parser_context& context) std::size_t match_token_at_22(parser& parser, token& token, parser_context& context) { - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Tags); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -2215,28 +2253,28 @@ match_token_at_22(parser& parser, token& token, parser_context& context) std::size_t match_token_at_23(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_BackgroundLine(context, token)) { + if (match_background_line(context, token)) { end_rule(context, Rule_RuleHeader); start_rule(context, Rule_Background); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); @@ -2245,7 +2283,7 @@ match_token_at_23(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); @@ -2254,14 +2292,14 @@ match_token_at_23(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); @@ -2269,7 +2307,7 @@ match_token_at_23(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { start_rule(context, Rule_Description); build(context, token); return transition.TargetState; @@ -2297,7 +2335,7 @@ match_token_at_23(parser& parser, token& token, parser_context& context) std::size_t match_token_at_24(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); @@ -2305,19 +2343,19 @@ match_token_at_24(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { end_rule(context, Rule_Description); build(context, token); return transition.TargetState; } - if (match_BackgroundLine(context, token)) { + if (match_background_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); start_rule(context, Rule_Background); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); @@ -2327,7 +2365,7 @@ match_token_at_24(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); @@ -2337,7 +2375,7 @@ match_token_at_24(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); @@ -2345,7 +2383,7 @@ match_token_at_24(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); @@ -2354,7 +2392,7 @@ match_token_at_24(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -2381,24 +2419,24 @@ match_token_at_24(parser& parser, token& token, parser_context& context) std::size_t match_token_at_25(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_BackgroundLine(context, token)) { + if (match_background_line(context, token)) { end_rule(context, Rule_RuleHeader); start_rule(context, Rule_Background); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); @@ -2407,7 +2445,7 @@ match_token_at_25(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); @@ -2416,14 +2454,14 @@ match_token_at_25(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_RuleHeader); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_RuleHeader); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); @@ -2431,7 +2469,7 @@ match_token_at_25(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -2458,27 +2496,27 @@ match_token_at_25(parser& parser, token& token, parser_context& context) std::size_t match_token_at_26(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Background); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); @@ -2487,7 +2525,7 @@ match_token_at_26(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); @@ -2496,14 +2534,14 @@ match_token_at_26(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); @@ -2511,7 +2549,7 @@ match_token_at_26(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { start_rule(context, Rule_Description); build(context, token); return transition.TargetState; @@ -2539,7 +2577,7 @@ match_token_at_26(parser& parser, token& token, parser_context& context) std::size_t match_token_at_27(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); @@ -2547,18 +2585,18 @@ match_token_at_27(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { end_rule(context, Rule_Description); build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); @@ -2568,7 +2606,7 @@ match_token_at_27(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); @@ -2578,7 +2616,7 @@ match_token_at_27(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); @@ -2586,7 +2624,7 @@ match_token_at_27(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); @@ -2595,7 +2633,7 @@ match_token_at_27(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -2622,23 +2660,23 @@ match_token_at_27(parser& parser, token& token, parser_context& context) std::size_t match_token_at_28(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Background); end_rule(context, Rule_Rule); end_rule(context, Rule_Feature); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); @@ -2647,7 +2685,7 @@ match_token_at_28(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); @@ -2656,14 +2694,14 @@ match_token_at_28(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Background); end_rule(context, Rule_Rule); start_rule(context, Rule_Rule); @@ -2671,7 +2709,7 @@ match_token_at_28(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -2698,7 +2736,7 @@ match_token_at_28(parser& parser, token& token, parser_context& context) std::size_t match_token_at_29(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); @@ -2706,23 +2744,23 @@ match_token_at_29(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { start_rule(context, Rule_DataTable); build(context, token); return transition.TargetState; } - if (match_DocStringSeparator(context, token)) { + if (match_doc_string_separator(context, token)) { start_rule(context, Rule_DocString); build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -2732,7 +2770,7 @@ match_token_at_29(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); @@ -2742,7 +2780,7 @@ match_token_at_29(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); start_rule(context, Rule_ScenarioDefinition); @@ -2750,7 +2788,7 @@ match_token_at_29(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Background); end_rule(context, Rule_Rule); @@ -2759,11 +2797,11 @@ match_token_at_29(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -2790,7 +2828,7 @@ match_token_at_29(parser& parser, token& token, parser_context& context) std::size_t match_token_at_30(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -2799,18 +2837,18 @@ match_token_at_30(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); @@ -2821,7 +2859,7 @@ match_token_at_30(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -2832,7 +2870,7 @@ match_token_at_30(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -2841,7 +2879,7 @@ match_token_at_30(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -2851,11 +2889,11 @@ match_token_at_30(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -2882,21 +2920,21 @@ match_token_at_30(parser& parser, token& token, parser_context& context) std::size_t match_token_at_31(parser& parser, token& token, parser_context& context) { - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Tags); start_rule(context, Rule_Scenario); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -2923,7 +2961,7 @@ match_token_at_31(parser& parser, token& token, parser_context& context) std::size_t match_token_at_32(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); @@ -2931,20 +2969,20 @@ match_token_at_32(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); @@ -2952,7 +2990,7 @@ match_token_at_32(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -2962,7 +3000,7 @@ match_token_at_32(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); @@ -2972,13 +3010,13 @@ match_token_at_32(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); @@ -2986,7 +3024,7 @@ match_token_at_32(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); @@ -2995,7 +3033,7 @@ match_token_at_32(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { start_rule(context, Rule_Description); build(context, token); return transition.TargetState; @@ -3023,7 +3061,7 @@ match_token_at_32(parser& parser, token& token, parser_context& context) std::size_t match_token_at_33(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3032,18 +3070,18 @@ match_token_at_33(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { end_rule(context, Rule_Description); build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesDefinition); @@ -3052,7 +3090,7 @@ match_token_at_33(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); @@ -3063,7 +3101,7 @@ match_token_at_33(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3074,14 +3112,14 @@ match_token_at_33(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3090,7 +3128,7 @@ match_token_at_33(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3100,7 +3138,7 @@ match_token_at_33(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -3127,7 +3165,7 @@ match_token_at_33(parser& parser, token& token, parser_context& context) std::size_t match_token_at_34(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); @@ -3135,16 +3173,16 @@ match_token_at_34(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Tags); @@ -3152,7 +3190,7 @@ match_token_at_34(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3162,7 +3200,7 @@ match_token_at_34(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); @@ -3172,13 +3210,13 @@ match_token_at_34(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); start_rule(context, Rule_ScenarioDefinition); @@ -3186,7 +3224,7 @@ match_token_at_34(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); end_rule(context, Rule_Rule); @@ -3195,7 +3233,7 @@ match_token_at_34(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -3222,7 +3260,7 @@ match_token_at_34(parser& parser, token& token, parser_context& context) std::size_t match_token_at_35(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3231,23 +3269,23 @@ match_token_at_35(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { start_rule(context, Rule_DataTable); build(context, token); return transition.TargetState; } - if (match_DocStringSeparator(context, token)) { + if (match_doc_string_separator(context, token)) { start_rule(context, Rule_DocString); build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); @@ -3256,7 +3294,7 @@ match_token_at_35(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3267,7 +3305,7 @@ match_token_at_35(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3278,14 +3316,14 @@ match_token_at_35(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3294,7 +3332,7 @@ match_token_at_35(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); end_rule(context, Rule_ScenarioDefinition); @@ -3304,11 +3342,11 @@ match_token_at_35(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -3335,7 +3373,7 @@ match_token_at_35(parser& parser, token& token, parser_context& context) std::size_t match_token_at_36(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3345,18 +3383,18 @@ match_token_at_36(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); @@ -3366,7 +3404,7 @@ match_token_at_36(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); @@ -3378,7 +3416,7 @@ match_token_at_36(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3390,7 +3428,7 @@ match_token_at_36(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); @@ -3398,7 +3436,7 @@ match_token_at_36(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3408,7 +3446,7 @@ match_token_at_36(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_DataTable); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3419,11 +3457,11 @@ match_token_at_36(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -3450,21 +3488,21 @@ match_token_at_36(parser& parser, token& token, parser_context& context) std::size_t match_token_at_37(parser& parser, token& token, parser_context& context) { - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Tags); start_rule(context, Rule_Examples); build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -3491,7 +3529,7 @@ match_token_at_37(parser& parser, token& token, parser_context& context) std::size_t match_token_at_38(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3501,20 +3539,20 @@ match_token_at_38(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { start_rule(context, Rule_ExamplesTable); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3524,7 +3562,7 @@ match_token_at_38(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3536,7 +3574,7 @@ match_token_at_38(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3548,7 +3586,7 @@ match_token_at_38(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); @@ -3556,7 +3594,7 @@ match_token_at_38(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3566,7 +3604,7 @@ match_token_at_38(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3577,7 +3615,7 @@ match_token_at_38(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { start_rule(context, Rule_Description); build(context, token); return transition.TargetState; @@ -3605,7 +3643,7 @@ match_token_at_38(parser& parser, token& token, parser_context& context) std::size_t match_token_at_39(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3616,18 +3654,18 @@ match_token_at_39(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { end_rule(context, Rule_Description); build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { end_rule(context, Rule_Description); start_rule(context, Rule_ExamplesTable); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); @@ -3638,7 +3676,7 @@ match_token_at_39(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); @@ -3651,7 +3689,7 @@ match_token_at_39(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3664,7 +3702,7 @@ match_token_at_39(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3673,7 +3711,7 @@ match_token_at_39(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3684,7 +3722,7 @@ match_token_at_39(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Description); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3696,7 +3734,7 @@ match_token_at_39(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -3723,7 +3761,7 @@ match_token_at_39(parser& parser, token& token, parser_context& context) std::size_t match_token_at_40(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3733,16 +3771,16 @@ match_token_at_40(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { start_rule(context, Rule_ExamplesTable); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3752,7 +3790,7 @@ match_token_at_40(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3764,7 +3802,7 @@ match_token_at_40(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3776,7 +3814,7 @@ match_token_at_40(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); start_rule(context, Rule_ExamplesDefinition); @@ -3784,7 +3822,7 @@ match_token_at_40(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3794,7 +3832,7 @@ match_token_at_40(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); end_rule(context, Rule_Scenario); @@ -3805,7 +3843,7 @@ match_token_at_40(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -3832,7 +3870,7 @@ match_token_at_40(parser& parser, token& token, parser_context& context) std::size_t match_token_at_41(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3843,11 +3881,11 @@ match_token_at_41(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_TableRow(context, token)) { + if (match_table_row(context, token)) { build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); @@ -3858,7 +3896,7 @@ match_token_at_41(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); @@ -3871,7 +3909,7 @@ match_token_at_41(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3884,7 +3922,7 @@ match_token_at_41(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3893,7 +3931,7 @@ match_token_at_41(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3904,7 +3942,7 @@ match_token_at_41(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_ExamplesTable); end_rule(context, Rule_Examples); end_rule(context, Rule_ExamplesDefinition); @@ -3916,11 +3954,11 @@ match_token_at_41(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -3947,11 +3985,11 @@ match_token_at_41(parser& parser, token& token, parser_context& context) std::size_t match_token_at_43(parser& parser, token& token, parser_context& context) { - if (match_DocStringSeparator(context, token)) { + if (match_doc_string_separator(context, token)) { build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -3978,7 +4016,7 @@ match_token_at_43(parser& parser, token& token, parser_context& context) std::size_t match_token_at_44(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -3988,14 +4026,14 @@ match_token_at_44(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); @@ -4005,7 +4043,7 @@ match_token_at_44(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); @@ -4017,7 +4055,7 @@ match_token_at_44(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4029,7 +4067,7 @@ match_token_at_44(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); @@ -4037,7 +4075,7 @@ match_token_at_44(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4047,7 +4085,7 @@ match_token_at_44(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4058,11 +4096,11 @@ match_token_at_44(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -4089,11 +4127,11 @@ match_token_at_44(parser& parser, token& token, parser_context& context) std::size_t match_token_at_45(parser& parser, token& token, parser_context& context) { - if (match_DocStringSeparator(context, token)) { + if (match_doc_string_separator(context, token)) { build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -4120,7 +4158,7 @@ match_token_at_45(parser& parser, token& token, parser_context& context) std::size_t match_token_at_46(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4129,14 +4167,14 @@ match_token_at_46(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); @@ -4147,7 +4185,7 @@ match_token_at_46(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4158,7 +4196,7 @@ match_token_at_46(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4167,7 +4205,7 @@ match_token_at_46(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4177,11 +4215,11 @@ match_token_at_46(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -4208,11 +4246,11 @@ match_token_at_46(parser& parser, token& token, parser_context& context) std::size_t match_token_at_47(parser& parser, token& token, parser_context& context) { - if (match_DocStringSeparator(context, token)) { + if (match_doc_string_separator(context, token)) { build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -4239,7 +4277,7 @@ match_token_at_47(parser& parser, token& token, parser_context& context) std::size_t match_token_at_48(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4248,14 +4286,14 @@ match_token_at_48(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); @@ -4265,7 +4303,7 @@ match_token_at_48(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); @@ -4277,7 +4315,7 @@ match_token_at_48(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4288,7 +4326,7 @@ match_token_at_48(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ExamplesLine(context, token)) { + if (match_examples_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_ExamplesDefinition); @@ -4296,7 +4334,7 @@ match_token_at_48(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4306,7 +4344,7 @@ match_token_at_48(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Scenario); @@ -4316,11 +4354,11 @@ match_token_at_48(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -4347,11 +4385,11 @@ match_token_at_48(parser& parser, token& token, parser_context& context) std::size_t match_token_at_49(parser& parser, token& token, parser_context& context) { - if (match_DocStringSeparator(context, token)) { + if (match_doc_string_separator(context, token)) { build(context, token); return transition.TargetState; } - if (match_Other(context, token)) { + if (match_other(context, token)) { build(context, token); return transition.TargetState; } @@ -4378,7 +4416,7 @@ match_token_at_49(parser& parser, token& token, parser_context& context) std::size_t match_token_at_50(parser& parser, token& token, parser_context& context) { - if (match_EOF(context, token)) { + if (match_e_o_f(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4386,14 +4424,14 @@ match_token_at_50(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_StepLine(context, token)) { + if (match_step_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); start_rule(context, Rule_Step); build(context, token); return transition.TargetState; } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); @@ -4404,7 +4442,7 @@ match_token_at_50(parser& parser, token& token, parser_context& context) return transition.TargetState; } } - if (match_TagLine(context, token)) { + if (match_tag_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4414,7 +4452,7 @@ match_token_at_50(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_ScenarioLine(context, token)) { + if (match_scenario_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4423,7 +4461,7 @@ match_token_at_50(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_RuleLine(context, token)) { + if (match_rule_line(context, token)) { end_rule(context, Rule_DocString); end_rule(context, Rule_Step); end_rule(context, Rule_Background); @@ -4432,11 +4470,11 @@ match_token_at_50(parser& parser, token& token, parser_context& context) build(context, token); return transition.TargetState; } - if (match_Comment(context, token)) { + if (match_comment(context, token)) { build(context, token); return transition.TargetState; } - if (match_Empty(context, token)) { + if (match_empty(context, token)) { build(context, token); return transition.TargetState; } @@ -4473,12 +4511,12 @@ lookahead_0(parser_context& context, token& current_token) token.detach() queue.push_back(token); - if (smatch_ScenarioLine(context, token) || false) { + if (smatch_scenario_line(context, token) || false) { match = true; break; } - if not (match_Empty(context, token) || match_Comment(context, token) || match_TagLine(context, token) || false) { + if not (match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false) { break; } @@ -4499,12 +4537,12 @@ lookahead_1(parser_context& context, token& current_token) token.detach() queue.push_back(token); - if (smatch_ExamplesLine(context, token) || false) { + if (smatch_examples_line(context, token) || false) { match = true; break; } - if not (match_Empty(context, token) || match_Comment(context, token) || match_TagLine(context, token) || false) { + if not (match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false) { break; } @@ -4512,29 +4550,17 @@ lookahead_1(parser_context& context, token& current_token) return match; } -void -handle_ast_error(parser_context& context, token& token, match_function action) -{ handle_external_error(context, true, token, action); } +} // namespace detail -bool -handle_external_error( - parser_context& context, - bool default_value, - token& token, - match_function action -) +std::size_t +parser::match_token(std::size_t state, token& token, parser_context& context) { - if (context.stop_at_first_error) { - return action(token); - } + using match_function = int (parser::*)(token&, parser_context&); + using match_functions = std::unordered_map; - try { - return action(token); - } catch (const std::exception& e) { - add_error(context, e); - } + static const match_functions = { + { 0, &parser::} + }; - return default_value; + return state; } - -} // namespace detail diff --git a/cpp/src/lib/gherkin/parser_context.cpp b/cpp/src/lib/gherkin/parser_context.cpp deleted file mode 100644 index 997de0852..000000000 --- a/cpp/src/lib/gherkin/parser_context.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include - -namespace gherkin { - -bool -parser_context::has_token() const -{ return !token_queue.empty(); } - -gherkin::token -parser_context::pop_token() -{ - auto t = std::move(token_queue.front()); - token_queue.pop_front(); - - return t; -} - -void -parser_context::push_tokens(const gherkin::token_queue& queue) -{ token_queue.insert(token_queue.end(), queue.begin(), queue.end()); } - -bool -parser_context::has_errors() const -{ return !errors.empty(); } - -} diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp new file mode 100644 index 000000000..efa4941d8 --- /dev/null +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -0,0 +1,75 @@ +#include + +namespace gherkin { + +token_matcher::token_matcher(const token_matcher_info& tmi = {}) +: tmi_(tmi) +{} + +token_matcher::~token_matcher() +{} + +token_matcher::reset() +{} + +bool +token_matcher::match_feature_line(token& token) +{ return true; } + +bool +token_matcher::match_rule_line(token& token) +{ return true; } + +bool +token_matcher::match_scenario_line(token& token) +{ return true; } + +bool +token_matcher::match_background_line(token& token) +{ return true; } + +bool +token_matcher::match_examples_line(token& token) +{ return true; } + +bool +token_matcher::match_language(token& token) +{ return true; } + +bool +token_matcher::match_tag_line(token& token) +{ return true; } + +bool +token_matcher::match_title_line(token& token) +{ return true; } + +bool +token_matcher::match_e_o_f(token& token) +{ return true; } + +bool +token_matcher::match_empty(token& token) +{ return true; } + +bool +token_matcher::match_comment(token& token) +{ return true; } + +bool +token_matcher::match_other(token& token) +{ return true; } + +bool +token_matcher::match_step_line(token& token) +{ return true; } + +bool +token_matcher::match_doc_string_separator(token& token) +{ return true; } + +bool +token_matcher::match_table_row(token& token) +{ return true; } + + } From c10fb71c53660a98fcd310a7d6b7c48eb945708f Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 2 May 2023 16:17:04 +0200 Subject: [PATCH 06/76] chore: compile ok --- cpp/gherkin-cpp.razor | 178 +- cpp/include/gherkin/ast_builder.hpp | 3 + cpp/include/gherkin/token_matcher.hpp | 4 + cpp/src/lib/gherkin/parser.cpp | 4130 +++++++++++++------------ cpp/src/lib/gherkin/token_matcher.cpp | 3 +- cpp/src/lib/gherkin/token_scanner.cpp | 17 +- 6 files changed, 2298 insertions(+), 2037 deletions(-) diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index d41fe343c..e8d7702ed 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -17,13 +17,15 @@ public static string NameOf(Rule rule) } @helper CallProduction(ProductionRule production) { + var rname = ToSnakeCase(production.RuleName); + switch(production.Type) { case ProductionRuleType.Start: - @: start_rule(context, Rule_@production.RuleName); + @: start_rule(context, rule_type::@rname); break; case ProductionRuleType.End: - @: end_rule(context, Rule_@production.RuleName); + @: end_rule(context, rule_type::@rname); break; case ProductionRuleType.Process: @: build(context, token); @@ -33,7 +35,7 @@ public static string NameOf(Rule rule) @helper HandleParserError(IEnumerable expectedTokens, State state) { /* "State: @state.Id - @Raw(state.Comment)" */ - std::string expected_tokens = L"@Raw(string.Join(", ", expectedTokens))"; + std::string expected_tokens = "@Raw(string.Join(", ", expectedTokens))"; auto error = token.is_eof() @@ -41,11 +43,11 @@ public static string NameOf(Rule rule) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return @state.Id;} @helper MatchToken(TokenType tokenType) @@ -80,6 +82,9 @@ struct parser_context return t; } + token read_token() + { return has_token() ? pop_token() : scanner.read(); } + void push_tokens(const token_queue& q) { queue.insert(queue.end(), q.begin(), q.end()); } @@ -93,16 +98,24 @@ struct parser_context { add_error(e.what()); } }; +enum class error_type +{ + unexpected_eof, + unexpected_token +}; + using match_function = std::function; using match_functions = std::unordered_map; -static token read_token(parser_context& context); - static void start_rule(parser_context& context, rule_type rule_type); static void end_rule(parser_context& context, rule_type rule_type); -static int match_token(int state, token& token, parser_context& context); +static std::size_t match_token( + std::size_t state, + token& token, + parser_context& context +); template bool @@ -113,12 +126,24 @@ handle_external_error( Action&& action ) { + using ret_type = decltype(action(argument)); + if (context.stop_at_first_error) { - return action(argument); + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } } try { - return action(argument); + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } } catch (const std::exception& e) { context.add_error(e); } @@ -157,7 +182,7 @@ parser::parse(const file& file) std::size_t state = 0; while (true) { - auto token = read_token(context); + auto token = context.read_token(); state = match_token(state, token, context); if (token.is_eof()) { @@ -175,30 +200,42 @@ parser::parse(const file& file) } static -token -read_token(parser_context& context) -{ - token t; - - if (context.has_token()) { - t = context.pop_token(); - } else { - t = context.scanner.read(); - } +void +build(parser_context& context, token& token) +{ context.builder.build(token); } - return t; +static +void +start_rule(parser_context& context, rule_type rule_type) +{ + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.start_rule(rtype); + } + ); } static void -build(parser_context& context, token& token) -{ context.builder.build(token); } +end_rule(parser_context& context, rule_type rule_type) +{ + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.end_rule(rtype); + } + ); +} namespace detail { @foreach(var rule in Model.RuleSet.TokenRules) { +static bool match_@(NameOf(rule))(parser_context& context, token& token) { @@ -222,11 +259,46 @@ match_@(NameOf(rule))(parser_context& context, token& token) } +@foreach(var lookAheadHint in Model.RuleSet.LookAheadHints) +{ + +static +bool +lookahead_@(lookAheadHint.Id)(parser_context& context, token& current_token) +{ + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach(); + queue.push_back(token); + + if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {@MatchToken(tokenType) || }false) { + match = true; + break; + } + + if (!(@foreach(var tokenType in lookAheadHint.Skip) {@MatchToken(tokenType) || }false)) { + break; + } + } + + context.push_tokens(queue); + + return match; +} + +} + @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) { // @Raw(state.Comment) +static std::size_t -match_token_at_@(state.Id)(parser& parser, token& token, parser_context& context) +match_token_at_@(state.Id)(token& token, parser_context& context) { @{var indent = "";} @foreach(var transition in state.Transitions) @@ -241,7 +313,7 @@ match_token_at_@(state.Id)(parser& parser, token& token, parser_context& context { @indent@CallProduction(production) } - @:@(indent)return transition.TargetState; + @:@(indent)return @transition.TargetState; if (transition.LookAheadHint != null) { @:} @@ -254,48 +326,22 @@ match_token_at_@(state.Id)(parser& parser, token& token, parser_context& context } -@foreach(var lookAheadHint in Model.RuleSet.LookAheadHints) -{ - -bool -lookahead_@(lookAheadHint.Id)(parser_context& context, token& current_token) -{ - current_token.detach(); - token token; - token_queue queue; - bool match = false; - - while (true) { - token = context.read_token(); - token.detach() - queue.push_back(token); - - if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {s@MatchToken(tokenType) || }false) { - match = true; - break; - } - - if not (@foreach(var tokenType in lookAheadHint.Skip) {@MatchToken(tokenType) || }false) { - break; - } - - context.push_tokens(queue); - - return match; -} -} - } // namespace detail +static std::size_t -parser::match_token(std::size_t state, token& token, parser_context& context) +match_token(std::size_t state, token& token, parser_context& context) { - using match_function = int (parser::*)(token&, parser_context&); - using match_functions = std::unordered_map; - - static const match_functions = { - { 0, &parser::} - }; + switch (state) { + @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) + { + @:case @state.Id: + @:return detail::match_token_at_@(state.Id)(token, context); + } + default: + context.add_error("invalid operation: " + std::to_string(state)); + return -1; + } +} - return state; } diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index f3d1b69db..87df07376 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace gherkin { @@ -15,6 +16,8 @@ class ast_builder void reset(); void build(token& token); + void start_rule(rule_type rule_type); + void end_rule(rule_type rule_type); private: }; diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index 9b7410de5..24b8096fe 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -1,5 +1,9 @@ #pragma once +#include + +#include + namespace gherkin { struct token_matcher_info diff --git a/cpp/src/lib/gherkin/parser.cpp b/cpp/src/lib/gherkin/parser.cpp index e7906156e..5afc71bb6 100644 --- a/cpp/src/lib/gherkin/parser.cpp +++ b/cpp/src/lib/gherkin/parser.cpp @@ -28,6 +28,9 @@ struct parser_context return t; } + token read_token() + { return has_token() ? pop_token() : scanner.read(); } + void push_tokens(const token_queue& q) { queue.insert(queue.end(), q.begin(), q.end()); } @@ -41,16 +44,24 @@ struct parser_context { add_error(e.what()); } }; +enum class error_type +{ + unexpected_eof, + unexpected_token +}; + using match_function = std::function; using match_functions = std::unordered_map; -static token read_token(parser_context& context); - static void start_rule(parser_context& context, rule_type rule_type); static void end_rule(parser_context& context, rule_type rule_type); -static int match_token(int state, token& token, parser_context& context); +static std::size_t match_token( + std::size_t state, + token& token, + parser_context& context +); template bool @@ -61,12 +72,24 @@ handle_external_error( Action&& action ) { + using ret_type = decltype(action(argument)); + if (context.stop_at_first_error) { - return action(argument); + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } } try { - return action(argument); + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } } catch (const std::exception& e) { context.add_error(e); } @@ -105,7 +128,7 @@ parser::parse(const file& file) std::size_t state = 0; while (true) { - auto token = read_token(context); + auto token = context.read_token(); state = match_token(state, token, context); if (token.is_eof()) { @@ -123,28 +146,40 @@ parser::parse(const file& file) } static -token -read_token(parser_context& context) -{ - token t; - - if (context.has_token()) { - t = context.pop_token(); - } else { - t = context.scanner.read(); - } +void +build(parser_context& context, token& token) +{ context.builder.build(token); } - return t; +static +void +start_rule(parser_context& context, rule_type rule_type) +{ + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.start_rule(rtype); + } + ); } static void -build(parser_context& context, token& token) -{ context.builder.build(token); } +end_rule(parser_context& context, rule_type rule_type) +{ + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.end_rule(rtype); + } + ); +} namespace detail { +static bool match_e_o_f(parser_context& context, token& token) { @@ -159,6 +194,7 @@ match_e_o_f(parser_context& context, token& token) ); } +static bool match_empty(parser_context& context, token& token) { @@ -177,6 +213,7 @@ match_empty(parser_context& context, token& token) ); } +static bool match_comment(parser_context& context, token& token) { @@ -195,6 +232,7 @@ match_comment(parser_context& context, token& token) ); } +static bool match_tag_line(parser_context& context, token& token) { @@ -213,6 +251,7 @@ match_tag_line(parser_context& context, token& token) ); } +static bool match_feature_line(parser_context& context, token& token) { @@ -231,6 +270,7 @@ match_feature_line(parser_context& context, token& token) ); } +static bool match_rule_line(parser_context& context, token& token) { @@ -249,6 +289,7 @@ match_rule_line(parser_context& context, token& token) ); } +static bool match_background_line(parser_context& context, token& token) { @@ -267,6 +308,7 @@ match_background_line(parser_context& context, token& token) ); } +static bool match_scenario_line(parser_context& context, token& token) { @@ -285,6 +327,7 @@ match_scenario_line(parser_context& context, token& token) ); } +static bool match_examples_line(parser_context& context, token& token) { @@ -303,6 +346,7 @@ match_examples_line(parser_context& context, token& token) ); } +static bool match_step_line(parser_context& context, token& token) { @@ -321,6 +365,7 @@ match_step_line(parser_context& context, token& token) ); } +static bool match_doc_string_separator(parser_context& context, token& token) { @@ -339,6 +384,7 @@ match_doc_string_separator(parser_context& context, token& token) ); } +static bool match_table_row(parser_context& context, token& token) { @@ -357,6 +403,7 @@ match_table_row(parser_context& context, token& token) ); } +static bool match_language(parser_context& context, token& token) { @@ -375,6 +422,7 @@ match_language(parser_context& context, token& token) ); } +static bool match_other(parser_context& context, token& token) { @@ -394,45 +442,105 @@ match_other(parser_context& context, token& token) } +static +bool +lookahead_0(parser_context& context, token& current_token) +{ + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach(); + queue.push_back(token); + + if (match_scenario_line(context, token) || false) { + match = true; + break; + } + + if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { + break; + } + } + + context.push_tokens(queue); + + return match; +} + +static +bool +lookahead_1(parser_context& context, token& current_token) +{ + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach(); + queue.push_back(token); + + if (match_examples_line(context, token) || false) { + match = true; + break; + } + + if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { + break; + } + } + + context.push_tokens(queue); + + return match; +} + + // Start +static std::size_t -match_token_at_0(parser& parser, token& token, parser_context& context) +match_token_at_0(token& token, parser_context& context) { if (match_e_o_f(context, token)) { build(context, token); - return transition.TargetState; + return 42; } if (match_language(context, token)) { - start_rule(context, Rule_Feature); - start_rule(context, Rule_FeatureHeader); + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); build(context, token); - return transition.TargetState; + return 1; } if (match_tag_line(context, token)) { - start_rule(context, Rule_Feature); - start_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Tags); + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 2; } if (match_feature_line(context, token)) { - start_rule(context, Rule_Feature); - start_rule(context, Rule_FeatureHeader); + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); build(context, token); - return transition.TargetState; + return 3; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 0; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 0; } /* "State: 0 - Start" */ - std::string expected_tokens = L"#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; auto error = token.is_eof() @@ -440,39 +548,40 @@ match_token_at_0(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 0;} // GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 +static std::size_t -match_token_at_1(parser& parser, token& token, parser_context& context) +match_token_at_1(token& token, parser_context& context) { if (match_tag_line(context, token)) { - start_rule(context, Rule_Tags); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 2; } if (match_feature_line(context, token)) { build(context, token); - return transition.TargetState; + return 3; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 1; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 1; } /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ - std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; + std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; auto error = token.is_eof() @@ -480,39 +589,40 @@ match_token_at_1(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 1;} // GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 +static std::size_t -match_token_at_2(parser& parser, token& token, parser_context& context) +match_token_at_2(token& token, parser_context& context) { if (match_tag_line(context, token)) { build(context, token); - return transition.TargetState; + return 2; } if (match_feature_line(context, token)) { - end_rule(context, Rule_Tags); + end_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 3; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 2; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 2; } /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #FeatureLine, #Comment, #Empty"; + std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; auto error = token.is_eof() @@ -520,78 +630,79 @@ match_token_at_2(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 2;} // GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 +static std::size_t -match_token_at_3(parser& parser, token& token, parser_context& context) +match_token_at_3(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_FeatureHeader); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 3; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 5; } if (match_background_line(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Background); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); build(context, token); - return transition.TargetState; + return 6; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { - start_rule(context, Rule_Description); + start_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 4; } /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -599,80 +710,81 @@ match_token_at_3(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 3;} // GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 +static std::size_t -match_token_at_4(parser& parser, token& token, parser_context& context) +match_token_at_4(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { - end_rule(context, Rule_Description); + end_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 5; } if (match_background_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Background); + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); build(context, token); - return transition.TargetState; + return 6; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 4; } /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -680,73 +792,74 @@ match_token_at_4(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 4;} // GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 +static std::size_t -match_token_at_5(parser& parser, token& token, parser_context& context) +match_token_at_5(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_FeatureHeader); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 5; } if (match_background_line(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Background); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); build(context, token); - return transition.TargetState; + return 6; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_FeatureHeader); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 5; } /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; auto error = token.is_eof() @@ -754,77 +867,78 @@ match_token_at_5(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 5;} // GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 +static std::size_t -match_token_at_6(parser& parser, token& token, parser_context& context) +match_token_at_6(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 6; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 8; } if (match_step_line(context, token)) { - start_rule(context, Rule_Step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 9; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { - start_rule(context, Rule_Description); + start_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 7; } /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -832,79 +946,80 @@ match_token_at_6(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 6;} // GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 +static std::size_t -match_token_at_7(parser& parser, token& token, parser_context& context) +match_token_at_7(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { - end_rule(context, Rule_Description); + end_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 8; } if (match_step_line(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_Step); + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 9; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 7; } /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -912,72 +1027,73 @@ match_token_at_7(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 7;} // GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 +static std::size_t -match_token_at_8(parser& parser, token& token, parser_context& context) +match_token_at_8(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 8; } if (match_step_line(context, token)) { - start_rule(context, Rule_Step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 9; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 8; } /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; auto error = token.is_eof() @@ -985,88 +1101,89 @@ match_token_at_8(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 8;} // GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 +static std::size_t -match_token_at_9(parser& parser, token& token, parser_context& context) +match_token_at_9(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { - start_rule(context, Rule_DataTable); + start_rule(context, rule_type::data_table); build(context, token); - return transition.TargetState; + return 10; } if (match_doc_string_separator(context, token)) { - start_rule(context, Rule_DocString); + start_rule(context, rule_type::doc_string); build(context, token); - return transition.TargetState; + return 49; } if (match_step_line(context, token)) { - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 9; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 9; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 9; } /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -1074,88 +1191,89 @@ match_token_at_9(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 9;} // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +static std::size_t -match_token_at_10(parser& parser, token& token, parser_context& context) +match_token_at_10(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { build(context, token); - return transition.TargetState; + return 10; } if (match_step_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 9; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 10; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 10; } /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -1163,40 +1281,41 @@ match_token_at_10(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 10;} // GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 +static std::size_t -match_token_at_11(parser& parser, token& token, parser_context& context) +match_token_at_11(token& token, parser_context& context) { if (match_tag_line(context, token)) { build(context, token); - return transition.TargetState; + return 11; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Tags); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::tags); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 11; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 11; } /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; + std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; auto error = token.is_eof() @@ -1204,96 +1323,97 @@ match_token_at_11(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 11;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 +static std::size_t -match_token_at_12(parser& parser, token& token, parser_context& context) +match_token_at_12(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 12; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 14; } if (match_step_line(context, token)) { - start_rule(context, Rule_Step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 15; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { - start_rule(context, Rule_Description); + start_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 13; } /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -1301,100 +1421,101 @@ match_token_at_12(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 12;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 +static std::size_t -match_token_at_13(parser& parser, token& token, parser_context& context) +match_token_at_13(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { - end_rule(context, Rule_Description); + end_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 14; } if (match_step_line(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_Step); + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 15; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 13; } /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -1402,91 +1523,92 @@ match_token_at_13(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 13;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 +static std::size_t -match_token_at_14(parser& parser, token& token, parser_context& context) +match_token_at_14(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 14; } if (match_step_line(context, token)) { - start_rule(context, Rule_Step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 15; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 14; } /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; auto error = token.is_eof() @@ -1494,109 +1616,110 @@ match_token_at_14(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 14;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 +static std::size_t -match_token_at_15(parser& parser, token& token, parser_context& context) +match_token_at_15(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { - start_rule(context, Rule_DataTable); + start_rule(context, rule_type::data_table); build(context, token); - return transition.TargetState; + return 16; } if (match_doc_string_separator(context, token)) { - start_rule(context, Rule_DocString); + start_rule(context, rule_type::doc_string); build(context, token); - return transition.TargetState; + return 47; } if (match_step_line(context, token)) { - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 15; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 15; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 15; } /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -1604,111 +1727,112 @@ match_token_at_15(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 15;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +static std::size_t -match_token_at_16(parser& parser, token& token, parser_context& context) +match_token_at_16(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { build(context, token); - return transition.TargetState; + return 16; } if (match_step_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 15; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 16; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 16; } /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -1716,40 +1840,41 @@ match_token_at_16(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 16;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 +static std::size_t -match_token_at_17(parser& parser, token& token, parser_context& context) +match_token_at_17(token& token, parser_context& context) { if (match_tag_line(context, token)) { build(context, token); - return transition.TargetState; + return 17; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Tags); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::tags); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 17; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 17; } /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; + std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; auto error = token.is_eof() @@ -1757,110 +1882,111 @@ match_token_at_17(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 17;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 +static std::size_t -match_token_at_18(parser& parser, token& token, parser_context& context) +match_token_at_18(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 18; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 20; } if (match_table_row(context, token)) { - start_rule(context, Rule_ExamplesTable); + start_rule(context, rule_type::examples_table); build(context, token); - return transition.TargetState; + return 21; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { - start_rule(context, Rule_Description); + start_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 19; } /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -1868,114 +1994,115 @@ match_token_at_18(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 18;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 +static std::size_t -match_token_at_19(parser& parser, token& token, parser_context& context) +match_token_at_19(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { - end_rule(context, Rule_Description); + end_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 20; } if (match_table_row(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesTable); + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_table); build(context, token); - return transition.TargetState; + return 21; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 19; } /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -1983,105 +2110,106 @@ match_token_at_19(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 19;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 +static std::size_t -match_token_at_20(parser& parser, token& token, parser_context& context) +match_token_at_20(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 20; } if (match_table_row(context, token)) { - start_rule(context, Rule_ExamplesTable); + start_rule(context, rule_type::examples_table); build(context, token); - return transition.TargetState; + return 21; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 20; } /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; auto error = token.is_eof() @@ -2089,111 +2217,112 @@ match_token_at_20(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 20;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 +static std::size_t -match_token_at_21(parser& parser, token& token, parser_context& context) +match_token_at_21(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { build(context, token); - return transition.TargetState; + return 21; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 21; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 21; } /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -2201,39 +2330,40 @@ match_token_at_21(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 21;} // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 +static std::size_t -match_token_at_22(parser& parser, token& token, parser_context& context) +match_token_at_22(token& token, parser_context& context) { if (match_tag_line(context, token)) { build(context, token); - return transition.TargetState; + return 22; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Tags); + end_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 22; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 22; } /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#TagLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -2241,81 +2371,82 @@ match_token_at_22(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 22;} // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 +static std::size_t -match_token_at_23(parser& parser, token& token, parser_context& context) +match_token_at_23(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 25; } if (match_background_line(context, token)) { - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Background); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); build(context, token); - return transition.TargetState; + return 26; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { - start_rule(context, Rule_Description); + start_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 24; } /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -2323,83 +2454,84 @@ match_token_at_23(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 23;} // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 +static std::size_t -match_token_at_24(parser& parser, token& token, parser_context& context) +match_token_at_24(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { - end_rule(context, Rule_Description); + end_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 25; } if (match_background_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Background); + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); build(context, token); - return transition.TargetState; + return 26; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 24; } /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -2407,76 +2539,77 @@ match_token_at_24(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 24;} // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 +static std::size_t -match_token_at_25(parser& parser, token& token, parser_context& context) +match_token_at_25(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 25; } if (match_background_line(context, token)) { - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Background); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); build(context, token); - return transition.TargetState; + return 26; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_RuleHeader); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_RuleHeader); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 25; } /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; auto error = token.is_eof() @@ -2484,80 +2617,81 @@ match_token_at_25(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 25;} // GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 +static std::size_t -match_token_at_26(parser& parser, token& token, parser_context& context) +match_token_at_26(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 26; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 28; } if (match_step_line(context, token)) { - start_rule(context, Rule_Step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 29; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { - start_rule(context, Rule_Description); + start_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 27; } /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -2565,82 +2699,83 @@ match_token_at_26(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 26;} // GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 +static std::size_t -match_token_at_27(parser& parser, token& token, parser_context& context) +match_token_at_27(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { - end_rule(context, Rule_Description); + end_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 28; } if (match_step_line(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_Step); + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 29; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 27; } /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -2648,75 +2783,76 @@ match_token_at_27(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 27;} // GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 +static std::size_t -match_token_at_28(parser& parser, token& token, parser_context& context) +match_token_at_28(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 28; } if (match_step_line(context, token)) { - start_rule(context, Rule_Step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 29; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 28; } /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; auto error = token.is_eof() @@ -2724,91 +2860,92 @@ match_token_at_28(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 28;} // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 +static std::size_t -match_token_at_29(parser& parser, token& token, parser_context& context) +match_token_at_29(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { - start_rule(context, Rule_DataTable); + start_rule(context, rule_type::data_table); build(context, token); - return transition.TargetState; + return 30; } if (match_doc_string_separator(context, token)) { - start_rule(context, Rule_DocString); + start_rule(context, rule_type::doc_string); build(context, token); - return transition.TargetState; + return 45; } if (match_step_line(context, token)) { - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 29; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 29; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 29; } /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -2816,91 +2953,92 @@ match_token_at_29(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 29;} // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +static std::size_t -match_token_at_30(parser& parser, token& token, parser_context& context) +match_token_at_30(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { build(context, token); - return transition.TargetState; + return 30; } if (match_step_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 29; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 30; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 30; } /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -2908,40 +3046,41 @@ match_token_at_30(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 30;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 +static std::size_t -match_token_at_31(parser& parser, token& token, parser_context& context) +match_token_at_31(token& token, parser_context& context) { if (match_tag_line(context, token)) { build(context, token); - return transition.TargetState; + return 31; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Tags); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::tags); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 31; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 31; } /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #ScenarioLine, #Comment, #Empty"; + std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; auto error = token.is_eof() @@ -2949,99 +3088,100 @@ match_token_at_31(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 31;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 +static std::size_t -match_token_at_32(parser& parser, token& token, parser_context& context) +match_token_at_32(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 32; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 34; } if (match_step_line(context, token)) { - start_rule(context, Rule_Step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 35; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { - start_rule(context, Rule_Description); + start_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 33; } /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -3049,103 +3189,104 @@ match_token_at_32(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 32;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 +static std::size_t -match_token_at_33(parser& parser, token& token, parser_context& context) +match_token_at_33(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { - end_rule(context, Rule_Description); + end_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 34; } if (match_step_line(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_Step); + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 35; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 33; } /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -3153,94 +3294,95 @@ match_token_at_33(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 33;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 +static std::size_t -match_token_at_34(parser& parser, token& token, parser_context& context) +match_token_at_34(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 34; } if (match_step_line(context, token)) { - start_rule(context, Rule_Step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 35; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 34; } /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; auto error = token.is_eof() @@ -3248,112 +3390,113 @@ match_token_at_34(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 34;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 +static std::size_t -match_token_at_35(parser& parser, token& token, parser_context& context) +match_token_at_35(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { - start_rule(context, Rule_DataTable); + start_rule(context, rule_type::data_table); build(context, token); - return transition.TargetState; + return 36; } if (match_doc_string_separator(context, token)) { - start_rule(context, Rule_DocString); + start_rule(context, rule_type::doc_string); build(context, token); - return transition.TargetState; + return 43; } if (match_step_line(context, token)) { - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 35; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 35; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 35; } /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -3361,114 +3504,115 @@ match_token_at_35(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 35;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 +static std::size_t -match_token_at_36(parser& parser, token& token, parser_context& context) +match_token_at_36(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { build(context, token); - return transition.TargetState; + return 36; } if (match_step_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 35; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_DataTable); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 36; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 36; } /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -3476,40 +3620,41 @@ match_token_at_36(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 36;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 +static std::size_t -match_token_at_37(parser& parser, token& token, parser_context& context) +match_token_at_37(token& token, parser_context& context) { if (match_tag_line(context, token)) { build(context, token); - return transition.TargetState; + return 37; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Tags); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::tags); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 37; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 37; } /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = L"#TagLine, #ExamplesLine, #Comment, #Empty"; + std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; auto error = token.is_eof() @@ -3517,113 +3662,114 @@ match_token_at_37(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 37;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 +static std::size_t -match_token_at_38(parser& parser, token& token, parser_context& context) +match_token_at_38(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 38; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 40; } if (match_table_row(context, token)) { - start_rule(context, Rule_ExamplesTable); + start_rule(context, rule_type::examples_table); build(context, token); - return transition.TargetState; + return 41; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { - start_rule(context, Rule_Description); + start_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 39; } /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ - std::string expected_tokens = L"#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -3631,117 +3777,118 @@ match_token_at_38(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 38;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 +static std::size_t -match_token_at_39(parser& parser, token& token, parser_context& context) +match_token_at_39(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { - end_rule(context, Rule_Description); + end_rule(context, rule_type::description); build(context, token); - return transition.TargetState; + return 40; } if (match_table_row(context, token)) { - end_rule(context, Rule_Description); - start_rule(context, Rule_ExamplesTable); + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_table); build(context, token); - return transition.TargetState; + return 41; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Description); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 39; } /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = token.is_eof() @@ -3749,108 +3896,109 @@ match_token_at_39(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 39;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 +static std::size_t -match_token_at_40(parser& parser, token& token, parser_context& context) +match_token_at_40(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 40; } if (match_table_row(context, token)) { - start_rule(context, Rule_ExamplesTable); + start_rule(context, rule_type::examples_table); build(context, token); - return transition.TargetState; + return 41; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 40; } /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = L"#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; auto error = token.is_eof() @@ -3858,114 +4006,115 @@ match_token_at_40(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 40;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 +static std::size_t -match_token_at_41(parser& parser, token& token, parser_context& context) +match_token_at_41(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_table_row(context, token)) { build(context, token); - return transition.TargetState; + return 41; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_ExamplesTable); - end_rule(context, Rule_Examples); - end_rule(context, Rule_ExamplesDefinition); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 41; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 41; } /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ - std::string expected_tokens = L"#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -3973,30 +4122,31 @@ match_token_at_41(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 41;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +static std::size_t -match_token_at_43(parser& parser, token& token, parser_context& context) +match_token_at_43(token& token, parser_context& context) { if (match_doc_string_separator(context, token)) { build(context, token); - return transition.TargetState; + return 44; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 43; } /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = L"#DocStringSeparator, #Other"; + std::string expected_tokens = "#DocStringSeparator, #Other"; auto error = token.is_eof() @@ -4004,110 +4154,111 @@ match_token_at_43(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 43;} // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +static std::size_t -match_token_at_44(parser& parser, token& token, parser_context& context) +match_token_at_44(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_step_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 35; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 37; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 38; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 44; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 44; } /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -4115,30 +4266,31 @@ match_token_at_44(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 44;} // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +static std::size_t -match_token_at_45(parser& parser, token& token, parser_context& context) +match_token_at_45(token& token, parser_context& context) { if (match_doc_string_separator(context, token)) { build(context, token); - return transition.TargetState; + return 46; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 45; } /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = L"#DocStringSeparator, #Other"; + std::string expected_tokens = "#DocStringSeparator, #Other"; auto error = token.is_eof() @@ -4146,87 +4298,88 @@ match_token_at_45(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 45;} // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +static std::size_t -match_token_at_46(parser& parser, token& token, parser_context& context) +match_token_at_46(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_step_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 29; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 31; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 32; } if (match_rule_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Rule); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 46; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 46; } /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -4234,30 +4387,31 @@ match_token_at_46(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 46;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +static std::size_t -match_token_at_47(parser& parser, token& token, parser_context& context) +match_token_at_47(token& token, parser_context& context) { if (match_doc_string_separator(context, token)) { build(context, token); - return transition.TargetState; + return 48; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 47; } /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = L"#DocStringSeparator, #Other"; + std::string expected_tokens = "#DocStringSeparator, #Other"; auto error = token.is_eof() @@ -4265,107 +4419,108 @@ match_token_at_47(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 47;} // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +static std::size_t -match_token_at_48(parser& parser, token& token, parser_context& context) +match_token_at_48(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_step_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 15; } if (match_tag_line(context, token)) { if (lookahead_1(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 17; } } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); - build(context, token); - return transition.TargetState; + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_examples_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_ExamplesDefinition); - start_rule(context, Rule_Examples); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); build(context, token); - return transition.TargetState; + return 18; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Scenario); - end_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 48; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 48; } /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -4373,30 +4528,31 @@ match_token_at_48(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 48;} // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 +static std::size_t -match_token_at_49(parser& parser, token& token, parser_context& context) +match_token_at_49(token& token, parser_context& context) { if (match_doc_string_separator(context, token)) { build(context, token); - return transition.TargetState; + return 50; } if (match_other(context, token)) { build(context, token); - return transition.TargetState; + return 49; } /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = L"#DocStringSeparator, #Other"; + std::string expected_tokens = "#DocStringSeparator, #Other"; auto error = token.is_eof() @@ -4404,84 +4560,85 @@ match_token_at_49(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 49;} // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 +static std::size_t -match_token_at_50(parser& parser, token& token, parser_context& context) +match_token_at_50(token& token, parser_context& context) { if (match_e_o_f(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - end_rule(context, Rule_Feature); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); build(context, token); - return transition.TargetState; + return 42; } if (match_step_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - start_rule(context, Rule_Step); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); build(context, token); - return transition.TargetState; + return 9; } if (match_tag_line(context, token)) { if (lookahead_0(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 11; } } if (match_tag_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); - start_rule(context, Rule_Tags); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); build(context, token); - return transition.TargetState; + return 22; } if (match_scenario_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_ScenarioDefinition); - start_rule(context, Rule_Scenario); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); build(context, token); - return transition.TargetState; + return 12; } if (match_rule_line(context, token)) { - end_rule(context, Rule_DocString); - end_rule(context, Rule_Step); - end_rule(context, Rule_Background); - start_rule(context, Rule_Rule); - start_rule(context, Rule_RuleHeader); + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); build(context, token); - return transition.TargetState; + return 23; } if (match_comment(context, token)) { build(context, token); - return transition.TargetState; + return 50; } if (match_empty(context, token)) { build(context, token); - return transition.TargetState; + return 50; } /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = L"#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = token.is_eof() @@ -4489,78 +4646,125 @@ match_token_at_50(parser& parser, token& token, parser_context& context) : error_type::unexpected_token ; - if (stop_at_first_error()) { - throw_error(error, token, expected_tokens); + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); } - add_error(error, token, expected_tokens); + context.add_error(expected_tokens); return 50;} - -bool -lookahead_0(parser_context& context, token& current_token) -{ - current_token.detach(); - token token; - token_queue queue; - bool match = false; - - while (true) { - token = context.read_token(); - token.detach() - queue.push_back(token); - - if (smatch_scenario_line(context, token) || false) { - match = true; - break; - } - - if not (match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false) { - break; - } - - context.push_tokens(queue); - - return match; -} -bool -lookahead_1(parser_context& context, token& current_token) -{ - current_token.detach(); - token token; - token_queue queue; - bool match = false; - - while (true) { - token = context.read_token(); - token.detach() - queue.push_back(token); - - if (smatch_examples_line(context, token) || false) { - match = true; - break; - } - - if not (match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false) { - break; - } - - context.push_tokens(queue); - - return match; -} } // namespace detail +static std::size_t -parser::match_token(std::size_t state, token& token, parser_context& context) +match_token(std::size_t state, token& token, parser_context& context) { - using match_function = int (parser::*)(token&, parser_context&); - using match_functions = std::unordered_map; - - static const match_functions = { - { 0, &parser::} - }; + switch (state) { + case 0: + return detail::match_token_at_0(token, context); + case 1: + return detail::match_token_at_1(token, context); + case 2: + return detail::match_token_at_2(token, context); + case 3: + return detail::match_token_at_3(token, context); + case 4: + return detail::match_token_at_4(token, context); + case 5: + return detail::match_token_at_5(token, context); + case 6: + return detail::match_token_at_6(token, context); + case 7: + return detail::match_token_at_7(token, context); + case 8: + return detail::match_token_at_8(token, context); + case 9: + return detail::match_token_at_9(token, context); + case 10: + return detail::match_token_at_10(token, context); + case 11: + return detail::match_token_at_11(token, context); + case 12: + return detail::match_token_at_12(token, context); + case 13: + return detail::match_token_at_13(token, context); + case 14: + return detail::match_token_at_14(token, context); + case 15: + return detail::match_token_at_15(token, context); + case 16: + return detail::match_token_at_16(token, context); + case 17: + return detail::match_token_at_17(token, context); + case 18: + return detail::match_token_at_18(token, context); + case 19: + return detail::match_token_at_19(token, context); + case 20: + return detail::match_token_at_20(token, context); + case 21: + return detail::match_token_at_21(token, context); + case 22: + return detail::match_token_at_22(token, context); + case 23: + return detail::match_token_at_23(token, context); + case 24: + return detail::match_token_at_24(token, context); + case 25: + return detail::match_token_at_25(token, context); + case 26: + return detail::match_token_at_26(token, context); + case 27: + return detail::match_token_at_27(token, context); + case 28: + return detail::match_token_at_28(token, context); + case 29: + return detail::match_token_at_29(token, context); + case 30: + return detail::match_token_at_30(token, context); + case 31: + return detail::match_token_at_31(token, context); + case 32: + return detail::match_token_at_32(token, context); + case 33: + return detail::match_token_at_33(token, context); + case 34: + return detail::match_token_at_34(token, context); + case 35: + return detail::match_token_at_35(token, context); + case 36: + return detail::match_token_at_36(token, context); + case 37: + return detail::match_token_at_37(token, context); + case 38: + return detail::match_token_at_38(token, context); + case 39: + return detail::match_token_at_39(token, context); + case 40: + return detail::match_token_at_40(token, context); + case 41: + return detail::match_token_at_41(token, context); + case 43: + return detail::match_token_at_43(token, context); + case 44: + return detail::match_token_at_44(token, context); + case 45: + return detail::match_token_at_45(token, context); + case 46: + return detail::match_token_at_46(token, context); + case 47: + return detail::match_token_at_47(token, context); + case 48: + return detail::match_token_at_48(token, context); + case 49: + return detail::match_token_at_49(token, context); + case 50: + return detail::match_token_at_50(token, context); + default: + context.add_error("invalid operation: " + std::to_string(state)); + return -1; + } +} - return state; } diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index efa4941d8..4686f995e 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -2,13 +2,14 @@ namespace gherkin { -token_matcher::token_matcher(const token_matcher_info& tmi = {}) +token_matcher::token_matcher(const token_matcher_info& tmi) : tmi_(tmi) {} token_matcher::~token_matcher() {} +void token_matcher::reset() {} diff --git a/cpp/src/lib/gherkin/token_scanner.cpp b/cpp/src/lib/gherkin/token_scanner.cpp index 797ab355b..dcc2ee4a4 100644 --- a/cpp/src/lib/gherkin/token_scanner.cpp +++ b/cpp/src/lib/gherkin/token_scanner.cpp @@ -1,13 +1,16 @@ +#include +#include + #include namespace gherkin { token_scanner::token_scanner(const std::string& text) -: ip_(std::make_unique(text)) +: ip_{std::make_unique(text)} {} token_scanner::token_scanner(const file& file) -: ip_(std::make_unique(file.path)) +: ip_{std::make_unique(file.path)} {} token_scanner::~token_scanner() @@ -18,20 +21,20 @@ token_scanner::read() { auto r = next_line(); - if (r.has_line) { + /*if (r.has_line) { $line =~ s/\r$//; # \n as well as \r\n are considered lines separators $line_token = Gherkin::Line->new( { line_text => $line, line_number => $line_number } ); } - return Gherkin::Token->new(line => $line_token, location => $location); + return Gherkin::Token->new(line => $line_token, location => $location);*/ + return {}; } void -token_scanner::reset(input_ptr& ip) +token_scanner::reset() { - ip_ = std::move(ip); line_ = 0; } @@ -44,7 +47,7 @@ token_scanner::next_line() return r; } - input >> r.text; + input() >> r.text; line_++; r.has_line = !r.text.empty(); From 3922ccd543a97b90c887a1bd21c3cbf21d9e8b86 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 2 May 2023 18:10:32 +0200 Subject: [PATCH 07/76] chore: more implementation --- cpp/Makefile | 6 +- ...kin-i18n.cpp.jq => gherkin-dialect.cpp.jq} | 2 +- cpp/include/gherkin/{i18n.hpp => dialect.hpp} | 2 +- cpp/include/gherkin/items.hpp | 15 +++++ cpp/include/gherkin/line.hpp | 32 ++++++++-- cpp/include/gherkin/token_matcher.hpp | 10 ++- cpp/include/gherkin/utils.hpp | 16 +++++ cpp/src/lib/gherkin/CMakeLists.txt | 7 ++- cpp/src/lib/gherkin/{i18n.cpp => dialect.cpp} | 2 +- cpp/src/lib/gherkin/line.cpp | 62 +++++++++++++++++++ cpp/src/lib/gherkin/token.cpp | 4 +- cpp/src/lib/gherkin/token_matcher.cpp | 37 ++++++++--- cpp/src/lib/gherkin/token_scanner.cpp | 15 ++--- cpp/src/lib/gherkin/utils.cpp | 33 ++++++++++ 14 files changed, 208 insertions(+), 35 deletions(-) rename cpp/{gherkin-i18n.cpp.jq => gherkin-dialect.cpp.jq} (96%) rename cpp/include/gherkin/{i18n.hpp => dialect.hpp} (96%) create mode 100644 cpp/include/gherkin/items.hpp create mode 100644 cpp/include/gherkin/utils.hpp rename cpp/src/lib/gherkin/{i18n.cpp => dialect.cpp} (99%) create mode 100644 cpp/src/lib/gherkin/line.cpp create mode 100644 cpp/src/lib/gherkin/utils.cpp diff --git a/cpp/Makefile b/cpp/Makefile index e435605cc..8109e1278 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -4,7 +4,7 @@ GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json GHERKIN_GENERATED = \ include/gherkin/rule_type.hpp \ src/lib/gherkin/parser.cpp \ - src/lib/gherkin/i18n.cpp + src/lib/gherkin/dialect.cpp GHERKIN = bin/gherkin GHERKIN_GENERATE_TOKENS = bin/gherkin-generate-tokens @@ -54,8 +54,8 @@ include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp src/lib/gherkin/parser.cpp: gherkin-cpp.razor ../gherkin.berp $(berp-generate-parser) -src/lib/gherkin/i18n.cpp: $(GHERKIN_LANGUAGES_JSON) - jq -f gherkin-i18n.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ +src/lib/gherkin/dialect.cpp: $(GHERKIN_LANGUAGES_JSON) + jq -f gherkin-dialect.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens mkdir -p $(@D) diff --git a/cpp/gherkin-i18n.cpp.jq b/cpp/gherkin-dialect.cpp.jq similarity index 96% rename from cpp/gherkin-i18n.cpp.jq rename to cpp/gherkin-dialect.cpp.jq index 36e42c065..7fca7432c 100644 --- a/cpp/gherkin-i18n.cpp.jq +++ b/cpp/gherkin-dialect.cpp.jq @@ -1,6 +1,6 @@ . as $root | [ - "#include \n\n", + "#include \n\n", "namespace gherkin {\n\n", "const keywords_map&\n", "keywords(const std::string_view& language)\n", diff --git a/cpp/include/gherkin/i18n.hpp b/cpp/include/gherkin/dialect.hpp similarity index 96% rename from cpp/include/gherkin/i18n.hpp rename to cpp/include/gherkin/dialect.hpp index b922b7c54..e9a5e1800 100644 --- a/cpp/include/gherkin/i18n.hpp +++ b/cpp/include/gherkin/dialect.hpp @@ -1,4 +1,4 @@ -#pragma once + #pragma once #include diff --git a/cpp/include/gherkin/items.hpp b/cpp/include/gherkin/items.hpp new file mode 100644 index 000000000..c884bc755 --- /dev/null +++ b/cpp/include/gherkin/items.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace gherkin { + +struct item +{ + std::string column; + std::string text; +}; + +using items = std::vector; + +} diff --git a/cpp/include/gherkin/line.hpp b/cpp/include/gherkin/line.hpp index 6273bc615..96c2ef8b3 100644 --- a/cpp/include/gherkin/line.hpp +++ b/cpp/include/gherkin/line.hpp @@ -3,14 +3,36 @@ #include #include +#include +#include + namespace gherkin { -struct line +class line { - std::string text; - std::size_t number; - std::size_t indent; - std::string trimmed_text; +public: + line(); + line(const std::string& line_text, std::size_t line_number); + + std::string_view get_rest_trimmed(std::size_t length) const; + std::string_view get_line_text( + std::size_t indent_to_remove=std::string::npos + ) const; + + bool is_empty() const; + + bool startswith(std::string_view prefix) const; + bool startswith_title_keyword(std::string_view keyword) const; + + items table_cells() const; + + items tags() const; + +private: + std::string line_text_; + std::size_t line_number_ = 0; + std::size_t indent_ = 0; + std::string trimmed_line_text_; }; } diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index 24b8096fe..ca4bd372d 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace gherkin { @@ -26,7 +27,6 @@ class token_matcher bool match_examples_line(token& token); bool match_language(token& token); bool match_tag_line(token& token); - bool match_title_line(token& token); bool match_e_o_f(token& token); bool match_empty(token& token); bool match_comment(token& token); @@ -36,6 +36,14 @@ class token_matcher bool match_table_row(token& token); private: + bool match_title_line( + token& token, + std::string_view text, + string_views keywords + ); + + const string_views& keywords(std::string_view kw) const; + token_matcher_info tmi_; }; diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp new file mode 100644 index 000000000..3ba737f68 --- /dev/null +++ b/cpp/include/gherkin/utils.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace gherkin { + +std::string_view +lstrip(std::string_view in); + +std::string_view +rstrip(std::string_view in); + +std::string_view +strip(std::string_view in); + +} diff --git a/cpp/src/lib/gherkin/CMakeLists.txt b/cpp/src/lib/gherkin/CMakeLists.txt index 6c60c8800..2589c4747 100644 --- a/cpp/src/lib/gherkin/CMakeLists.txt +++ b/cpp/src/lib/gherkin/CMakeLists.txt @@ -8,7 +8,8 @@ target_sources( PRIVATE ${INC_DIR}/gherkin/ast_builder.hpp ${INC_DIR}/gherkin/file.hpp - ${INC_DIR}/gherkin/i18n.hpp + ${INC_DIR}/gherkin/dialect.hpp + ${INC_DIR}/gherkin/items.hpp ${INC_DIR}/gherkin/line.hpp ${INC_DIR}/gherkin/location.hpp ${INC_DIR}/gherkin/parser.hpp @@ -16,13 +17,15 @@ target_sources( ${INC_DIR}/gherkin/token.hpp ${INC_DIR}/gherkin/token_matcher.hpp ${INC_DIR}/gherkin/token_scanner.hpp + ${INC_DIR}/gherkin/utils.hpp ${INC_DIR}/gherkin/types.hpp ${CMAKE_CURRENT_SOURCE_DIR}/ast_builder.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/i18n.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dialect.cpp ${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/token.cpp ${CMAKE_CURRENT_SOURCE_DIR}/token_matcher.cpp ${CMAKE_CURRENT_SOURCE_DIR}/token_scanner.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp ) target_include_directories( diff --git a/cpp/src/lib/gherkin/i18n.cpp b/cpp/src/lib/gherkin/dialect.cpp similarity index 99% rename from cpp/src/lib/gherkin/i18n.cpp rename to cpp/src/lib/gherkin/dialect.cpp index 0284f54b4..23ab31ea9 100644 --- a/cpp/src/lib/gherkin/i18n.cpp +++ b/cpp/src/lib/gherkin/dialect.cpp @@ -1,4 +1,4 @@ -#include +#include namespace gherkin { diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp new file mode 100644 index 000000000..9d0da3f0c --- /dev/null +++ b/cpp/src/lib/gherkin/line.cpp @@ -0,0 +1,62 @@ +#include +#include + +namespace gherkin { + +line::line() +{} + +line::line(const std::string& line_text, std::size_t line_number) +: line_text_(line_text), +line_number_(line_number), +trimmed_line_text_(lstrip(line_text_)), +indent_(line_text_.size() - trimmed_line_text_.size()) +{} + +std::string_view +line::get_rest_trimmed(std::size_t length) const +{ + auto pos = std::min(length, trimmed_line_text_.size()); + + return strip(trimmed_line_text_.substr(pos)); +} + +std::string_view +line::get_line_text(std::size_t indent_to_remove) const +{ + if (indent_to_remove == std::string::npos || indent_to_remove > indent_) { + return trimmed_line_text_; + } else { + return line_text_.substr(indent_to_remove); + } +} + +bool +line::is_empty() const +{ return trimmed_line_text_.empty(); } + +bool +line::startswith(std::string_view prefix) const +{ return trimmed_line_text_.startswith(prefix); } + +bool +line::startswith_title_keyword(std::string_view keyword) const +{ return trimmed_line_text_.startswith(keyword + ":"); } + +items +line::table_cells() const +{ + items items; + + return items; +} + +items +line::tags() const +{ + items items; + + return items; +} + +} diff --git a/cpp/src/lib/gherkin/token.cpp b/cpp/src/lib/gherkin/token.cpp index 4a54dca88..d17db45d5 100644 --- a/cpp/src/lib/gherkin/token.cpp +++ b/cpp/src/lib/gherkin/token.cpp @@ -4,7 +4,7 @@ namespace gherkin { bool token::is_eof() const -{ return line.text.empty(); } +{ return line.is_empty(); } void token::detach() @@ -12,6 +12,6 @@ token::detach() std::string_view token::value() const -{ return line.text; } +{ return is_eof() ? "EOF" : line.get_line_text(); } } diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 4686f995e..43326bc8f 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -1,4 +1,5 @@ #include +#include namespace gherkin { @@ -15,23 +16,35 @@ token_matcher::reset() bool token_matcher::match_feature_line(token& token) -{ return true; } +{ return match_title_line(token, "FeatureLine", keywords("feature")); } bool token_matcher::match_rule_line(token& token) -{ return true; } +{ return match_title_line(token, "RuleLine", keywords("rule")); } bool token_matcher::match_scenario_line(token& token) -{ return true; } +{ + return + match_title_line(token, "ScenarioLine", keywords("scenario")) + || + match_title_line(token, "ScenarioLine", keywords("scenarioOutline")) + ; +} bool token_matcher::match_background_line(token& token) -{ return true; } +{ return match_title_line(token, "BackgroundLine", keywords("background")); } bool token_matcher::match_examples_line(token& token) -{ return true; } +{ return match_title_line(token, "ExamplesLine", keywords("examples")); } + +bool +token_matcher::match_table_row(token& token) +{ + return true; +} bool token_matcher::match_language(token& token) @@ -42,7 +55,11 @@ token_matcher::match_tag_line(token& token) { return true; } bool -token_matcher::match_title_line(token& token) +token_matcher::match_title_line( + token& token, + std::string_view text, + string_views keywords +) { return true; } bool @@ -69,8 +86,8 @@ bool token_matcher::match_doc_string_separator(token& token) { return true; } -bool -token_matcher::match_table_row(token& token) -{ return true; } +const string_views& +token_matcher::keywords(std::string_view kw) const +{ return gherkin::keywords(tmi_.dialect, kw); } - } +} diff --git a/cpp/src/lib/gherkin/token_scanner.cpp b/cpp/src/lib/gherkin/token_scanner.cpp index dcc2ee4a4..04c0fbdfb 100644 --- a/cpp/src/lib/gherkin/token_scanner.cpp +++ b/cpp/src/lib/gherkin/token_scanner.cpp @@ -21,15 +21,12 @@ token_scanner::read() { auto r = next_line(); - /*if (r.has_line) { - $line =~ s/\r$//; # \n as well as \r\n are considered lines separators - $line_token = - Gherkin::Line->new( - { line_text => $line, line_number => $line_number } - ); - } - return Gherkin::Token->new(line => $line_token, location => $location);*/ - return {}; + line_++; + + return token{ + .line = gherkin::line(r.text, line_), + .location = line_ + }; } void diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp new file mode 100644 index 000000000..402ad600e --- /dev/null +++ b/cpp/src/lib/gherkin/utils.cpp @@ -0,0 +1,33 @@ +#include + +namespace gherkin { + +std::string_view +lstrip(std::string_view in) +{ + auto it = in.begin(); + auto end = in.end(); + + while (it != end && *it != ' ') + ++it; + + return {it, end}; +} + +std::string_view +rstrip(std::string_view in) +{ + auto it = in.rbegin(); + auto end = in.rend(); + + while (it != end && *it != ' ') + ++it; + + return {end.base(), it.base()}; +} + +std::string_view +strip(std::string_view in) +{ return lstrip(rstrip(in)); } + +} From e710ebe8e9950e848f4fb56710cabdabddc928aa Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 4 May 2023 11:32:18 +0200 Subject: [PATCH 08/76] chore: added rudimentary source dependency installer --- cpp/.gitignore | 1 + cpp/cmake/toolchains/ext.cmake | 20 ++++ cpp/deps.txt | 1 + cpp/scripts/build-ext | 120 +++++++++++++++++++++++ cpp/scripts/build-externals | 172 +++++++++++++++++++++++++++++++++ 5 files changed, 314 insertions(+) create mode 100644 cpp/cmake/toolchains/ext.cmake create mode 100644 cpp/deps.txt create mode 100755 cpp/scripts/build-ext create mode 100755 cpp/scripts/build-externals diff --git a/cpp/.gitignore b/cpp/.gitignore index 567609b12..89528ceaf 100644 --- a/cpp/.gitignore +++ b/cpp/.gitignore @@ -1 +1,2 @@ +ext/ build/ diff --git a/cpp/cmake/toolchains/ext.cmake b/cpp/cmake/toolchains/ext.cmake new file mode 100644 index 000000000..1a6c2812b --- /dev/null +++ b/cpp/cmake/toolchains/ext.cmake @@ -0,0 +1,20 @@ +# +# CMake toolchain to be used when building external libraries +# + +set(CMAKE_FIND_ROOT_PATH "${CMAKE_INSTALL_PREFIX}") +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# use, i.e. don't skip the full RPATH for the build tree +set(CMAKE_SKIP_BUILD_RPATH FALSE) + +# when building, don't use the install RPATH already +# (but later on when installing) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + +# add the automatically determined parts of the RPATH +# which point to directories outside the build tree to the install RPATH +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) diff --git a/cpp/deps.txt b/cpp/deps.txt new file mode 100644 index 000000000..0a6b587c8 --- /dev/null +++ b/cpp/deps.txt @@ -0,0 +1 @@ +https://github.com/chybz/cucumber-messages/archive/refs/heads/feature/cpp.zip --src-dir=cpp diff --git a/cpp/scripts/build-ext b/cpp/scripts/build-ext new file mode 100755 index 000000000..cdccc298f --- /dev/null +++ b/cpp/scripts/build-ext @@ -0,0 +1,120 @@ +#!/usr/bin/env bash + +set -e + +ME=$(basename $0) +MYDIR=$(cd $(dirname $0)/.. && pwd) + +############################################################################### +# +# Minimal checks +# +############################################################################### +[ -z "$1" ] && echo "$ME: missing directory" && exit 1 +[ ! -d "$1" ] && echo "$ME: invalid directory: $1" && exit 1 + +SRCDIR="$1" +shift + +while ((${#1})); do + case "$1" in + --src-dir=*) + SUBDIR="${1##--src-dir=}" + SRCDIR="$SRCDIR/$SUBDIR" + shift + ;; + *) + break + ;; + esac +done + +############################################################################### +# +# Compiler setup +# +############################################################################### +BUILDROOT=$MYDIR/build/root +CC= +CFLAGS= +CXX= +CXXFLAGS=$CFLAGS +CPATH=$BUILDROOT/include +LIBRARY_PATH=$BUILDROOT/lib +LD_LIBRARY_PATH=$BUILDROOT/lib +PKG_CONFIG_PATH=$LIBRARY_PATH/pkgconfig + +#CCACHE=$(which ccache || true) + +# if [ -n "$CCACHE" ]; then +# CC="$CCACHE $CC" +# CXX="$CCACHE $CXX" +# fi + +export CC CFLAGS CXX CXXFLAGS CPATH LIBRARY_PATH LD_LIBRARY_PATH + +############################################################################### +# +# Parallel compilation setup +# +############################################################################### +MAKEARGS= +CMAKEARGS= + +if [ -n "$NPROCS" ]; then + CMAKEARGS="--parallel $NPROCS" + MAKEARGS="-j$NPROCS" +fi + +############################################################################### +# +# Project build +# +############################################################################### +PROJECT=$(basename $SRCDIR) +BUILDDIR=$MYDIR/build/$PROJECT + +mkdir -p $LIBRARY_PATH +rm -rf $BUILDDIR && mkdir -p $BUILDDIR + +if [ -f $SRCDIR/CMakeLists.txt ]; then + cmake \ + -DCMAKE_PREFIX_PATH=$BUILDROOT \ + -DCMAKE_INSTALL_PREFIX=$BUILDROOT \ + -DCMAKE_TOOLCHAIN_FILE=$MYDIR/cmake/toolchains/ext.cmake \ + -S $SRCDIR -B $BUILDDIR \ + "$@" + cmake --build $BUILDDIR $CMAKEARGS + cmake --install $BUILDDIR +elif [ -f $SRCDIR/meson.build ]; then + cd $BUILDDIR + meson \ + --prefix=$BUILDROOT \ + --pkg-config-path=$BUILDROOT \ + --cmake-prefix-path=$BUILDROOT \ + "$@" \ + . $SRCDIR + meson install +elif [ -x $SRCDIR/configure ]; then + cd $BUILDDIR + $SRCDIR/configure \ + --prefix=$BUILDROOT \ + --enable-shared \ + "$@" + make $MAKEARGS + make install +elif [ -x $SRCDIR/config ]; then + cd $BUILDDIR + $SRCDIR/config --prefix=$BUILDROOT "$@" + make $MAKEARGS + make install +elif [ -f $SRCDIR/Makefile ]; then + cd $SRCDIR + make $MAKEARGS + make prefix=$BUILDROOT install +else + echo "$ME: don't know how to build $SRCDIR" + exit 1 +fi + +rm -rf $BUILDDIR diff --git a/cpp/scripts/build-externals b/cpp/scripts/build-externals new file mode 100755 index 000000000..42ef6a786 --- /dev/null +++ b/cpp/scripts/build-externals @@ -0,0 +1,172 @@ +#!/usr/bin/env bash + +############################################################################### +# +# Barebones dependency installer +# +############################################################################### +set -e +trap "exit 1" TERM + +ME=$(basename $0) +MYDIR=$(cd $(dirname $0)/.. && pwd) +MYPID=$$ + +BUILDER=$MYDIR/scripts/build-ext + +EXTDIR=$MYDIR/ext +DLFILE=$EXTDIR/.downloaded +INSTFILE=$EXTDIR/.installed +TMPDIR=$EXTDIR/tmp +ARCDIR=$EXTDIR/archives + +function error() { + echo "$@" >&2 + kill -TERM $MYPID + exit 1 +} + +function clean_tmp() { + rm -rf $TMPDIR && mkdir -p $TMPDIR +} + +function get_unique() { + local WHERE=$1 + local TYPE=$2 + + local COUNT=$(find $WHERE -mindepth 1 -maxdepth 1 -type $TYPE | wc -l) + + [ "$COUNT" -ne "1" ] && error "no unique entry of type $TYPE in $WHERE" + + local ENTRY=$(find $WHERE -mindepth 1 -maxdepth 1 -type $TYPE) + + echo $ENTRY +} + +function get_md5() { + local WHAT=$1 + local MD5 + + case $(uname -s) in + Darwin) + MD5=$(md5 -qs "$WHAT") + ;; + *) + MD5=$(echo -n "$WHAT" | md5sum | cut -d ' ' -f 1) + ;; + esac + + echo $MD5 +} + +function download() { + local PKG=$1 + + local MD5=$(get_md5 "$PKG") + local ARCHIVE=$(grep $MD5 $DLFILE | cut -d ' ' -f 2) + + if [ -z "$ARCHIVE" ]; then + clean_tmp + + (cd $TMPDIR && curl -LJO $PKG) + + mkdir -p $ARCDIR + + ARCHIVE=$(get_unique $TMPDIR f) + + mv $ARCHIVE $ARCDIR + + ARCHIVE=$(basename $ARCHIVE) + echo "$MD5 $ARCHIVE" >> $DLFILE + fi + + echo $ARCHIVE +} + +function extract() { + local ARCHIVE=$1 + + local ARCFILE=$ARCDIR/$ARCHIVE + local TAROPTS + + case $(uname -s) in + Darwin) + TAROPTS=xf + ;; + *) + TAROPTS=xaf + ;; + esac + + clean_tmp + + if [[ "$ARCFILE" =~ \.zip$ ]]; then + (cd $TMPDIR && unzip -q $ARCFILE) + elif [[ "$ARCFILE" =~ \.tar\.(gz|bz2|xz)$ ]]; then + (cd $TMPDIR && tar $TAROPTS $ARCFILE) + else + error "unhandled archive format $ARCHIVE" + fi + + DIR=$(get_unique $TMPDIR d) + + echo $DIR +} + +function build() { + local URL=$1 + shift + + local ARCHIVE=$(download $URL) + local INSTALLED=$(grep $ARCHIVE $INSTFILE) + + if [ -z "$INSTALLED" ]; then + local DEPDIR=$(extract $ARCHIVE) + + echo "building from $URL" + + $BUILDER $DEPDIR "$@" + + echo $ARCHIVE >> $INSTFILE + else + echo "skipping already installed $ARCHIVE from $URL" + fi +} + +function build_list() { + local EXTFILE=$1 + local -a SPEC=() + + while read LINE; do + [[ "$LINE" =~ ^([[:space:]]*(#.*)?)?$ ]] && continue + + build $LINE + done < $EXTFILE +} + +mkdir -p $EXTDIR +touch $DLFILE $INSTFILE + +[ -z "$1" ] && echo "usage: $ME FILE|URL" && exit 1 + +WHAT=$1 +shift + +if [ -f $WHAT ]; then + # Assume a dependency list file + if [ -n "$1" ]; then + # Short keyword to easily select something in the list file + LINE=$(grep "$1" $WHAT) + + if [ -n "$LINE" ]; then + build $LINE + fi + else + build_list $WHAT + fi +else + # Assume a URL + build $WHAT "$@" +fi + +exit 0 From ef0e6c0b54b805e6d8b676a05e3e8fbbfc2fb3b5 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 4 May 2023 12:54:42 +0200 Subject: [PATCH 09/76] chore: added external dependency support --- cpp/.gitignore | 2 ++ cpp/CMakeLists.txt | 5 ++++- cpp/Makefile | 28 +++++++++++++++++++++++++--- cpp/scripts/build-ext | 2 ++ cpp/src/lib/gherkin/CMakeLists.txt | 26 +++++++++++++++++++------- 5 files changed, 52 insertions(+), 11 deletions(-) diff --git a/cpp/.gitignore b/cpp/.gitignore index 89528ceaf..38926f72f 100644 --- a/cpp/.gitignore +++ b/cpp/.gitignore @@ -1,2 +1,4 @@ ext/ build/ +.built +.configured diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 088fae0d0..800ed18e8 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -9,12 +9,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +find_package(cucumber-messages CONFIG REQUIRED) + add_subdirectory(src/lib/gherkin) install( TARGETS - gherkin-cpp_library + gherkin-cpp EXPORT gherkin-cpp-config + FILE_SET gherkin_cpp_headers RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/cpp/Makefile b/cpp/Makefile index 8109e1278..a7d30e9bf 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -17,6 +17,9 @@ PICKLES = $(patsubst ../testdata/%,acceptance/testdata/%.pickles.ndjson,$(G SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GOOD_FEATURE_FILES)) ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES)) +HERE = $(shell pwd) +CMAKE_BUILDROOT=$(HERE)/build/root + .DEFAULT_GOAL = help define berp-generate-parser = @@ -38,15 +41,34 @@ clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files rm -f $(GHERKIN_LANGUAGES_JSON) clean: ## Remove all build artifacts and files generated by the acceptance tests - rm -f .built + rm -f build .built .configured rm -rf acceptance +clean-deps: + rm -rf ext build/src build/root + +install-deps: + ./scripts/build-externals deps.txt + .DELETE_ON_ERROR: acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference -.built: $(SOURCE_FILES) - touch $@ +.built: $(SOURCE_FILES) .configured + cmake \ + --build build/gherkin \ + --parallel \ + && touch $@ + +.configured: + mkdir -p build/gherkin + cmake \ + -DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \ + -DCMAKE_INSTALL_PREFIX=$(CMAKE_BUILDROOT) \ + -S . \ + -B build/gherkin \ + --toolchain cmake/toolchains/ext.cmake \ + && touch $@ include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) diff --git a/cpp/scripts/build-ext b/cpp/scripts/build-ext index cdccc298f..b3595953e 100755 --- a/cpp/scripts/build-ext +++ b/cpp/scripts/build-ext @@ -64,6 +64,8 @@ CMAKEARGS= if [ -n "$NPROCS" ]; then CMAKEARGS="--parallel $NPROCS" MAKEARGS="-j$NPROCS" +else + CMAKEARGS="--parallel" fi ############################################################################### diff --git a/cpp/src/lib/gherkin/CMakeLists.txt b/cpp/src/lib/gherkin/CMakeLists.txt index 2589c4747..a7834fb62 100644 --- a/cpp/src/lib/gherkin/CMakeLists.txt +++ b/cpp/src/lib/gherkin/CMakeLists.txt @@ -1,11 +1,16 @@ -add_library(gherkin-cpp_library) -add_library(weezu::gherkin-cpp ALIAS gherkin-cpp_library) +add_library(gherkin-cpp) +add_library(gherkin::gherkin-cpp ALIAS gherkin-cpp) set(INC_DIR "${CMAKE_SOURCE_DIR}/include") target_sources( - gherkin-cpp_library - PRIVATE + gherkin-cpp + PUBLIC + FILE_SET + "gherkin_cpp_headers" + TYPE HEADERS + BASE_DIRS ${INC_DIR} + FILES ${INC_DIR}/gherkin/ast_builder.hpp ${INC_DIR}/gherkin/file.hpp ${INC_DIR}/gherkin/dialect.hpp @@ -19,6 +24,7 @@ target_sources( ${INC_DIR}/gherkin/token_scanner.hpp ${INC_DIR}/gherkin/utils.hpp ${INC_DIR}/gherkin/types.hpp + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ast_builder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dialect.cpp ${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp @@ -29,16 +35,22 @@ target_sources( ) target_include_directories( - gherkin-cpp_library + gherkin-cpp PUBLIC $ $ PRIVATE - ${INC_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries( + gherkin-cpp + PRIVATE + cucumber::cucumber-messages ) set_target_properties( - gherkin-cpp_library + gherkin-cpp PROPERTIES OUTPUT_NAME gherkin-cpp ) From eb83391c492a5226e6f0db07b653f52769e8d813 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 4 May 2023 18:05:28 +0200 Subject: [PATCH 10/76] chore: more token_matcher implementation --- cpp/include/gherkin/dialect.hpp | 21 ++++++ cpp/include/gherkin/items.hpp | 2 +- cpp/include/gherkin/line.hpp | 10 +++ cpp/include/gherkin/token.hpp | 7 ++ cpp/include/gherkin/token_matcher.hpp | 25 +++++++ cpp/include/gherkin/utils.hpp | 6 +- cpp/src/lib/gherkin/dialect.cpp | 33 ++++++++- cpp/src/lib/gherkin/line.cpp | 89 +++++++++++++++++++++++++ cpp/src/lib/gherkin/token_matcher.cpp | 96 ++++++++++++++++++++++++++- cpp/src/lib/gherkin/utils.cpp | 22 +++--- 10 files changed, 296 insertions(+), 15 deletions(-) diff --git a/cpp/include/gherkin/dialect.hpp b/cpp/include/gherkin/dialect.hpp index e9a5e1800..a3d3461b0 100644 --- a/cpp/include/gherkin/dialect.hpp +++ b/cpp/include/gherkin/dialect.hpp @@ -7,10 +7,31 @@ namespace gherkin { using keywords_map = std::unordered_map; using keywords_maps = std::unordered_map; +struct dialect +{ + const string_views& feature_keywords; + const string_views& rule_keywords; + const string_views& scenario_keywords; + const string_views& scenario_outline_keywords; + const string_views& background_keywords; + const string_views& examples_keywords; + const string_views& given_keywords; + const string_views& when_keywords; + const string_views& then_keywords; + const string_views& and_keywords; + const string_views& but_keywords; +}; + const keywords_map& keywords(const std::string_view& language); const string_views& keywords(const std::string_view& language, const std::string_view& kw); +string_views +keywords(const std::string_view& language, const string_views& kws); + +dialect +get_dialect(const std::string_view& language); + } diff --git a/cpp/include/gherkin/items.hpp b/cpp/include/gherkin/items.hpp index c884bc755..9f4351a77 100644 --- a/cpp/include/gherkin/items.hpp +++ b/cpp/include/gherkin/items.hpp @@ -6,7 +6,7 @@ namespace gherkin { struct item { - std::string column; + std::size_t column = 0; std::string text; }; diff --git a/cpp/include/gherkin/line.hpp b/cpp/include/gherkin/line.hpp index 96c2ef8b3..ea88f36a2 100644 --- a/cpp/include/gherkin/line.hpp +++ b/cpp/include/gherkin/line.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -29,6 +30,15 @@ class line items tags() const; private: + using split_table_cell_function = std::function< + void(std::string_view cell, std::size_t col) + >; + + void split_table_cells( + const std::string& row, + split_table_cell_function f + ) const; + std::string line_text_; std::size_t line_number_ = 0; std::size_t indent_ = 0; diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index c62b03feb..1261a2fc8 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace gherkin { @@ -12,6 +13,12 @@ struct token { gherkin::line line; std::size_t location; + std::string matched_type; + std::string matched_keyword; + std::string matched_keyword_type; + std::size_t indent = 0; + gherkin::items items; + std::string matched_gherkin_dialect; bool is_eof() const; diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index ca4bd372d..bf32dad36 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -2,6 +2,7 @@ #include +#include #include #include @@ -12,6 +13,8 @@ struct token_matcher_info std::string dialect = "en"; }; +using keyword_types_map = std::unordered_map; + class token_matcher { public: @@ -42,9 +45,31 @@ class token_matcher string_views keywords ); + struct token_info + { + std::string text; + std::string keyword; + std::string keyword_type; + std::size_t indent; + gherkin::items items; + }; + + void set_token_matched( + token& token, + std::string_view text, + const token_info& ti = {} + ); + const string_views& keywords(std::string_view kw) const; + std::string_view keyword_type(std::string_view keyword) const; + + void change_dialect(const std::string& dialect_name); + token_matcher_info tmi_; + + std::string dialect_name_; + keyword_types_map keyword_types_; }; } diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index 3ba737f68..62738c728 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -5,12 +5,12 @@ namespace gherkin { std::string_view -lstrip(std::string_view in); +lstrip(std::string_view in, std::string_view chars = " "); std::string_view -rstrip(std::string_view in); +rstrip(std::string_view in, std::string_view chars = " "); std::string_view -strip(std::string_view in); +strip(std::string_view in, std::string_view chars = " "); } diff --git a/cpp/src/lib/gherkin/dialect.cpp b/cpp/src/lib/gherkin/dialect.cpp index 23ab31ea9..13ad487b1 100644 --- a/cpp/src/lib/gherkin/dialect.cpp +++ b/cpp/src/lib/gherkin/dialect.cpp @@ -1276,8 +1276,39 @@ keywords(const std::string_view& language) } const string_views& -keyword(const std::string_view& language, const std::string_view& kw) +keywords(const std::string_view& language, const std::string_view& kw) { return keywords(language).at(kw); } +string_views +keywords(const std::string_view& language, const string_views& kws) +{ + string_views svs; + + for (const auto& kw : kws) { + auto ksvs = keywords(language, kw); + svs.insert(svs.end(), ksvs.begin(), ksvs.end()); + } + + return svs; +} + +dialect +get_dialect(const std::string_view& language) +{ + return { + .feature_keywords = keywords(language, "feature"), + .rule_keywords = keywords(language, "rule"), + .scenario_keywords = keywords(language, "scenario"), + .scenario_outline_keywords = keywords(language, "scenarioOutline"), + .background_keywords = keywords(language, "background"), + .examples_keywords = keywords(language, "examples"), + .given_keywords = keywords(language, "given"), + .when_keywords = keywords(language, "when"), + .then_keywords = keywords(language, "then"), + .and_keywords = keywords(language, "and"), + .but_keywords = keywords(language, "but") + }; +} + } diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index 9d0da3f0c..15666a2b8 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -1,8 +1,19 @@ +#include + #include #include namespace gherkin { +using unescape_pair = std::pair +using unescapes = std::vector; + +static const unescapes = { + { "\\\\", "\\" }, + { "\\|", "|" }, + { "\\n", "\n" } +}; + line::line() {} @@ -48,6 +59,34 @@ line::table_cells() const { items items; + split_table_cells( + strip(trimmed_line_text_), + [&](const auto& cell, auto col) { + auto stripped_cell = lstrip(cell); + auto cell_indent = cell.size() - stripped_cell.size(); + stripped_cell = rstrip(stripped_cell); + + item i{ + .column = col + indent_ + cell_indent, + .text{stripped_cell} + }; + + for (const auto& p : unescapes) { + while (true) { + auto it = i.text.find(p.first); + + if (it = std::string::npos) { + break;; + } + + i.text.replace(it, p.first.size(), p.second); + } + } + + items.emplace_back(std::move(i)); + } + ); + return items; } @@ -59,4 +98,54 @@ line::tags() const return items; } +void +line::split_table_cells( + const std::string& row, + split_table_cell_function f +) const +{ + std::size_t col = 0; + std::size_t start_col = col + 1; + std::string cell; + bool first_cell = true; + auto it = row.begin(); + auto end = row.end(); + auto next_ch = [](auto& it, const auto& end) { + return it != end ? *it++ : 0 + }; + + while (true) { + auto ch = next_ch(it, end); + ++col; + + if (ch == '|') { + if (first_cell) { + first_cell = false; + } else { + f(cell, col); + } + + cell.clear(); + start_col = col + 1; + } else if (ch == '\\') { + ch = next_ch(it, end); + ++col; + + if (ch == 'n') { + cell += ch; + } else { + if (ch != '|' && ch != '\\') { + cell += '\\'; + } + + cell += ch; + } + } else if (ch) { + cell += ch; + } else { + break; + } + } +} + } diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 43326bc8f..191f2be02 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -5,7 +5,9 @@ namespace gherkin { token_matcher::token_matcher(const token_matcher_info& tmi) : tmi_(tmi) -{} +{ + change_dialect(tmi.dialect); +} token_matcher::~token_matcher() {} @@ -43,6 +45,14 @@ token_matcher::match_examples_line(token& token) bool token_matcher::match_table_row(token& token) { + if (!token.line.startswith("|")) { + return false; + } + + set_token_matched( + token, "TableRow", { .items = token.line.table_cells() } + ); + return true; } @@ -80,14 +90,96 @@ token_matcher::match_other(token& token) bool token_matcher::match_step_line(token& token) -{ return true; } +{ + string_views kws = { "given", "when", "then", "and", "but" }; + auto keywords = gherkin::keywords(dialect_name_, kws); + + for (const auto& keyword : keywords) { + if (!token.line.startswith(keyword)) { + continue; + } + + auto title = token.line.get_rest_trimmed(keyword.size()); + + + return true; + } + + return false; +} bool token_matcher::match_doc_string_separator(token& token) { return true; } +void +token_matcher::set_token_matched( + token& token, + std::string_view text, + token_matched_info& tmi +) +{ + token.matched_type = tmi.matched_type; + token.matched_text.assign(rstrip(tmi.text, "\r\n")); + token.matched_keyword = tmi.matched_keyword; + + if (tmi.indent) { + token.matched_indent = tmi.indent; + } else { + token.matched_indent = token.line.indent; + } + token.matched_items = std::move(tmi.items); + token.mathed_gherkin_dialect = dialect_name; +} + const string_views& token_matcher::keywords(std::string_view kw) const { return gherkin::keywords(tmi_.dialect, kw); } +std::string_view +token_matcher::keyword_type(std::string_view keyword) const +{ + auto it = keyword_types_.find(keyword); + + if (it != keyword_types_.end()) { + const auto& kws = it->second; + + if (!kws.empty()) { + return kws[0]; + } + } + + return "Unknown"; +} + +void +token_matcher::change_dialect(const std::string& dialect_name) +{ + dialect_name_ = dialect_name; + + d = get_dialect(dialect_name_); + + keyword_types_.clear(); + + for (const auto& keyword : d.given_keywords) { + keyword_types_[keyword].push_back("Context"); + } + + for (const auto& keyword : d.when_keywords) { + keyword_types_[keyword].push_back("Action"); + } + + for (const auto& keyword : d.then_keywords) { + keyword_types_[keyword].push_back("Outcome"); + } + + for (const auto& keyword : d.and_keywords) { + keyword_types_[keyword].push_back("Conjunction"); + } + + for (const auto& keyword : d.but_keywords) { + keyword_types_[keyword].push_back("Conjunction"); + } +} + } diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index 402ad600e..9869acec1 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -3,31 +3,37 @@ namespace gherkin { std::string_view -lstrip(std::string_view in) +lstrip(std::string_view in, std::string_view chars) { auto it = in.begin(); auto end = in.end(); - while (it != end && *it != ' ') - ++it; + for (auto c: chars) { + while (it != end && *it == c) { + ++it; + } + } return {it, end}; } std::string_view -rstrip(std::string_view in) +rstrip(std::string_view in, std::string_view chars) { auto it = in.rbegin(); auto end = in.rend(); - while (it != end && *it != ' ') - ++it; + for (auto c: chars) { + while (it != end && *it == c) { + ++it; + } + } return {end.base(), it.base()}; } std::string_view -strip(std::string_view in) -{ return lstrip(rstrip(in)); } +strip(std::string_view in, std::string_view chars) +{ return lstrip(rstrip(in, chars), chars); } } From 56c224514be04fce9c52e44286ec8318374a4ac4 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 5 May 2023 09:03:12 +0200 Subject: [PATCH 11/76] chore: ast --- cpp/include/gherkin/ast_node.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cpp/include/gherkin/ast_node.hpp diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp new file mode 100644 index 000000000..acc1b25bd --- /dev/null +++ b/cpp/include/gherkin/ast_node.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace gherkin { + +class ast_node +{ +public: + ast_node(rule_type rule_type); + virtual ast_node(); + +private: + rule_type rule_type_; +}; + +} From bf1e962bea5cecf1be93e3dadf7f33c63c903f3f Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 5 May 2023 11:26:48 +0200 Subject: [PATCH 12/76] chore: added some utilities --- cpp/Makefile | 13 ++- cpp/include/gherkin/demangle.hpp | 24 ++++ cpp/include/gherkin/items.hpp | 2 +- cpp/include/gherkin/line.hpp | 8 +- cpp/include/gherkin/log.hpp | 82 ++++++++++++++ cpp/include/gherkin/regex.hpp | 152 ++++++++++++++++++++++++++ cpp/include/gherkin/token.hpp | 5 +- cpp/src/lib/gherkin/CMakeLists.txt | 26 +---- cpp/src/lib/gherkin/demangle.cpp | 27 +++++ cpp/src/lib/gherkin/line.cpp | 30 +++-- cpp/src/lib/gherkin/token_matcher.cpp | 85 +++++++++++--- 11 files changed, 400 insertions(+), 54 deletions(-) create mode 100644 cpp/include/gherkin/demangle.hpp create mode 100644 cpp/include/gherkin/log.hpp create mode 100644 cpp/include/gherkin/regex.hpp create mode 100644 cpp/src/lib/gherkin/demangle.cpp diff --git a/cpp/Makefile b/cpp/Makefile index a7d30e9bf..6444e7da0 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -17,8 +17,13 @@ PICKLES = $(patsubst ../testdata/%,acceptance/testdata/%.pickles.ndjson,$(G SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GOOD_FEATURE_FILES)) ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES)) +SRC_FILES = \ + $(shell find include -name "*.[ch]*") \ + $(shell find src -name "*.[ch]*") + HERE = $(shell pwd) -CMAKE_BUILDROOT=$(HERE)/build/root +CMAKE_BUILDROOT = $(HERE)/build/root +CMAKELISTS = $(shell find src -name CMakeLists.txt) .DEFAULT_GOAL = help @@ -54,14 +59,14 @@ install-deps: acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference -.built: $(SOURCE_FILES) .configured +.built: $(SRC_FILES) .configured cmake \ --build build/gherkin \ --parallel \ && touch $@ -.configured: - mkdir -p build/gherkin +.configured: $(CMAKELISTS) + rm -rf build/gherkin && mkdir -p build/gherkin cmake \ -DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \ -DCMAKE_INSTALL_PREFIX=$(CMAKE_BUILDROOT) \ diff --git a/cpp/include/gherkin/demangle.hpp b/cpp/include/gherkin/demangle.hpp new file mode 100644 index 000000000..d6f2b2f6c --- /dev/null +++ b/cpp/include/gherkin/demangle.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +namespace gherkin { + +namespace detail { + +auto +demangle(std::string&& name) +-> std::unique_ptr; + +} + +template +auto declname() +{ return detail::demangle(typeid(T).name()); } + +template +auto declname(T&& v) +{ return declname(); } + +} diff --git a/cpp/include/gherkin/items.hpp b/cpp/include/gherkin/items.hpp index 9f4351a77..8b01b5144 100644 --- a/cpp/include/gherkin/items.hpp +++ b/cpp/include/gherkin/items.hpp @@ -6,7 +6,7 @@ namespace gherkin { struct item { - std::size_t column = 0; + std::size_t column; std::string text; }; diff --git a/cpp/include/gherkin/line.hpp b/cpp/include/gherkin/line.hpp index ea88f36a2..c3011fc8a 100644 --- a/cpp/include/gherkin/line.hpp +++ b/cpp/include/gherkin/line.hpp @@ -20,10 +20,14 @@ class line std::size_t indent_to_remove=std::string::npos ) const; + std::string_view line_text() const; + + std::size_t indent() const; + bool is_empty() const; bool startswith(std::string_view prefix) const; - bool startswith_title_keyword(std::string_view keyword) const; + bool startswith_title_keyword(const std::string& keyword) const; items table_cells() const; @@ -35,7 +39,7 @@ class line >; void split_table_cells( - const std::string& row, + std::string_view row, split_table_cell_function f ) const; diff --git a/cpp/include/gherkin/log.hpp b/cpp/include/gherkin/log.hpp new file mode 100644 index 000000000..fa0a0670b --- /dev/null +++ b/cpp/include/gherkin/log.hpp @@ -0,0 +1,82 @@ +#pragma once + +#include +#include +#include + +namespace gherkin { + +template +std::string +log_string(Args&&... args) +{ + std::ostringstream oss; + + (oss << ... << args); + + return oss.str(); +} + +template +void +log(Args&&... args) +{ std::cout << log_string(std::forward(args)...) << std::endl; } + +template +void +warn(Args&&... args) +{ log("W: ", std::forward(args)...); } + +template +void +error(Args&&... args) +{ log("E: ", std::forward(args)...); } + +template +void +die(Args&&... args) +{ throw std::runtime_error(log_string(std::forward(args)...)); } + +template +void +die_if(bool cond, Args&&... args) +{ + if (!cond) { + return; + } + + die(std::forward(args)...); +} + +template +void +die_unless(bool cond, Args&&... args) +{ die_if(!cond, std::forward(args)...); } + +template +void +sysdie(Args&&... args) +{ + auto err = errno; + auto econd = std::system_category().default_error_condition(err); + + die(std::forward(args)..., ": ", econd.message()); +} + +template +void +sysdie_if(bool cond, Args&&... args) +{ + if (!cond) { + return; + } + + sysdie(std::forward(args)...); +} + +template +void +sysdie_unless(bool cond, Args&&... args) +{ sysdie_if(!cond, std::forward(args)...); } + +} diff --git a/cpp/include/gherkin/regex.hpp b/cpp/include/gherkin/regex.hpp new file mode 100644 index 000000000..9f37ce636 --- /dev/null +++ b/cpp/include/gherkin/regex.hpp @@ -0,0 +1,152 @@ +#pragma once + +#include +#include + +#include +#include +#include +#include + +namespace gherkin { + +struct regex_result +{ + bool match = false; + string_views matches; +}; + +namespace detail { + +struct null_arg{}; + +template +std::string_view +extract_submatch(const SubMatch& sm, Arg&& a) +{ + std::string_view sv{sm.first, sm.second}; + + if constexpr ( + std::is_same_v + || + std::is_same_v + ) { + a.assign(sv); + } else if constexpr ( + std::is_integral_v + || + std::is_floating_point_v + ) { + auto [p, ec] = std::from_chars(sv.begin(), sv.end(), a); + + die_unless( + ec == std::errc(), + "failed to convert \"", + sv, + "\" to ", + declname(a) + ); + } else if constexpr (!std::is_same_v) { + die("unsupported argument: ", declname(a)); + } + + return sv; +} + +template +void +check_match_args(MatchResult&& m) +{ + if constexpr (N > 0) { + auto expected = m.size() - 1; + + die_unless( + N == expected, + "incorrect match args: ", + "expected ", expected, + ", got ", N + ); + } +} + +template +void +extract_submatches(MatchResult&& m, Args&&... args) +{ + constexpr auto nargs = sizeof...(args); + + check_match_args(m); + + auto mit = m.begin(); + + if constexpr (nargs > 0) { + (extract_submatch(*++mit, std::forward(args)), ...); + } +} + +template +void +extract_submatches(MatchResult&& m, string_views& vs) +{ + auto mit = m.begin(); + + while (++mit != m.end()) { + vs.push_back(std::string_view{mit->first, mit->second}); + } +} + +} // namespace detail + +template +bool +full_match( + const std::string_view& e, + const std::regex& re, + Args&&... args +) +{ + std::cmatch m; + + bool match = std::regex_match(e.begin(), e.end(), m, re); + + if (match) { + detail::extract_submatches(m, std::forward(args)...); + } + + return match; +} + +template +bool +full_match( + const std::string_view& e, + const std::string_view& pat, + Args&&... args +) +{ + std::regex re(pat.data(), pat.size()); + + return full_match(e, re, std::forward(args)...); +} + +template +bool +partial_match( + const std::string_view& e, + const std::string_view& pat, + Args&&... args +) +{ + std::cmatch m; + std::regex re(pat.data(), pat.size()); + + bool match = std::regex_search(e.begin(), e.end(), m, re); + + if (match) { + detail::extract_submatches(m, std::forward(args)...); + } + + return match; +} + +} diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index 1261a2fc8..a2a91e8db 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -16,8 +16,9 @@ struct token std::string matched_type; std::string matched_keyword; std::string matched_keyword_type; - std::size_t indent = 0; - gherkin::items items; + std::size_t matched_indent = 0; + gherkin::items matched_items; + std::string matched_text; std::string matched_gherkin_dialect; bool is_eof() const; diff --git a/cpp/src/lib/gherkin/CMakeLists.txt b/cpp/src/lib/gherkin/CMakeLists.txt index a7834fb62..e5c9489b2 100644 --- a/cpp/src/lib/gherkin/CMakeLists.txt +++ b/cpp/src/lib/gherkin/CMakeLists.txt @@ -3,6 +3,10 @@ add_library(gherkin::gherkin-cpp ALIAS gherkin-cpp) set(INC_DIR "${CMAKE_SOURCE_DIR}/include") +# We prefer it that way... +file(GLOB_RECURSE GHERKIN_CPP_HEADERS ${INC_DIR}/*.[ch]pp) +file(GLOB_RECURSE GHERKIN_CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.[ch]pp) + target_sources( gherkin-cpp PUBLIC @@ -11,27 +15,9 @@ target_sources( TYPE HEADERS BASE_DIRS ${INC_DIR} FILES - ${INC_DIR}/gherkin/ast_builder.hpp - ${INC_DIR}/gherkin/file.hpp - ${INC_DIR}/gherkin/dialect.hpp - ${INC_DIR}/gherkin/items.hpp - ${INC_DIR}/gherkin/line.hpp - ${INC_DIR}/gherkin/location.hpp - ${INC_DIR}/gherkin/parser.hpp - ${INC_DIR}/gherkin/rule_type.hpp - ${INC_DIR}/gherkin/token.hpp - ${INC_DIR}/gherkin/token_matcher.hpp - ${INC_DIR}/gherkin/token_scanner.hpp - ${INC_DIR}/gherkin/utils.hpp - ${INC_DIR}/gherkin/types.hpp + ${GHERKIN_CPP_HEADERS} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/ast_builder.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/dialect.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/token.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/token_matcher.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/token_scanner.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp + ${GHERKIN_CPP_SOURCES} ) target_include_directories( diff --git a/cpp/src/lib/gherkin/demangle.cpp b/cpp/src/lib/gherkin/demangle.cpp new file mode 100644 index 000000000..c87ff22bc --- /dev/null +++ b/cpp/src/lib/gherkin/demangle.cpp @@ -0,0 +1,27 @@ +// https://gist.github.com/bwoods/bbc6bd26b73fa37e94ac + +#include // gcc and clang… +#include + +#include + +namespace gherkin { + +namespace detail { + +auto +demangle(std::string&& name) +-> std::unique_ptr +{ + int status = 0; + + return + { + abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), + [] (char * p) { ::free(p); } + }; +} + +} // namespace detail + +} diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index 15666a2b8..df70064be 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -1,14 +1,14 @@ -#include +#include #include #include namespace gherkin { -using unescape_pair = std::pair +using unescape_pair = std::pair; using unescapes = std::vector; -static const unescapes = { +static const unescapes line_unescapes = { { "\\\\", "\\" }, { "\\|", "|" }, { "\\n", "\n" } @@ -42,17 +42,25 @@ line::get_line_text(std::size_t indent_to_remove) const } } +std::string_view +line::line_text() const +{ return line_text_; } + +std::size_t +line::indent() const +{ return indent_; } + bool line::is_empty() const { return trimmed_line_text_.empty(); } bool line::startswith(std::string_view prefix) const -{ return trimmed_line_text_.startswith(prefix); } +{ return trimmed_line_text_.starts_with(prefix); } bool -line::startswith_title_keyword(std::string_view keyword) const -{ return trimmed_line_text_.startswith(keyword + ":"); } +line::startswith_title_keyword(const std::string& keyword) const +{ return trimmed_line_text_.starts_with(keyword); } items line::table_cells() const @@ -68,15 +76,15 @@ line::table_cells() const item i{ .column = col + indent_ + cell_indent, - .text{stripped_cell} + .text = std::string(stripped_cell) }; - for (const auto& p : unescapes) { + for (const auto& p : line_unescapes) { while (true) { auto it = i.text.find(p.first); if (it = std::string::npos) { - break;; + break; } i.text.replace(it, p.first.size(), p.second); @@ -100,7 +108,7 @@ line::tags() const void line::split_table_cells( - const std::string& row, + std::string_view row, split_table_cell_function f ) const { @@ -111,7 +119,7 @@ line::split_table_cells( auto it = row.begin(); auto end = row.end(); auto next_ch = [](auto& it, const auto& end) { - return it != end ? *it++ : 0 + return it != end ? *it++ : 0; }; while (true) { diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 191f2be02..a7a19bf6e 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -1,8 +1,15 @@ + #include #include +#include +#include namespace gherkin { +static const std::regex language_re{ + "\\s*#\\s*language\\s*:\\s*([a-zA-Z\\-_]+)\\s*" +}; + token_matcher::token_matcher(const token_matcher_info& tmi) : tmi_(tmi) { @@ -58,11 +65,34 @@ token_matcher::match_table_row(token& token) bool token_matcher::match_language(token& token) -{ return true; } +{ + std::string dialect_name; + + if (!full_match(token.line.line_text(), language_re, dialect_name)) { + return false; + } + + set_token_matched(token, "Language", { .text = dialect_name }); + change_dialect(dialect_name); + + return true; +} bool token_matcher::match_tag_line(token& token) -{ return true; } +{ + if (!token.line.startswith("@")) { + return false; + } + + set_token_matched( + token, "TagLine", { + .items = std::move(token.line.tags()) + } + ); + + return true; +} bool token_matcher::match_title_line( @@ -78,11 +108,31 @@ token_matcher::match_e_o_f(token& token) bool token_matcher::match_empty(token& token) -{ return true; } +{ + if (!token.line.is_empty()) { + return false; + } + + set_token_matched(token, "Empty", { .indent = 0 } ); + + return true; +} bool token_matcher::match_comment(token& token) -{ return true; } +{ + if (!token.line.startswith("#")) { + return false; + } + + set_token_matched( + token, "Comment", { + .text = std::string(token.line.line_text()) + } + ); + + return true; +} bool token_matcher::match_other(token& token) @@ -101,6 +151,13 @@ token_matcher::match_step_line(token& token) auto title = token.line.get_rest_trimmed(keyword.size()); + set_token_matched( + token, "StepLine", { + .text = std::string(title), + .keyword = std::string(keyword), + .keyword_type = std::string(keyword_type(keyword)) + } + ); return true; } @@ -116,20 +173,20 @@ void token_matcher::set_token_matched( token& token, std::string_view text, - token_matched_info& tmi + const token_info& ti ) { - token.matched_type = tmi.matched_type; - token.matched_text.assign(rstrip(tmi.text, "\r\n")); - token.matched_keyword = tmi.matched_keyword; + token.matched_type = ti.keyword_type; + token.matched_text.assign(rstrip(ti.text, "\r\n")); + token.matched_keyword = ti.keyword; - if (tmi.indent) { - token.matched_indent = tmi.indent; + if (ti.indent) { + token.matched_indent = ti.indent; } else { - token.matched_indent = token.line.indent; + token.matched_indent = token.line.indent(); } - token.matched_items = std::move(tmi.items); - token.mathed_gherkin_dialect = dialect_name; + token.matched_items = std::move(ti.items); + token.matched_gherkin_dialect = dialect_name_; } const string_views& @@ -157,7 +214,7 @@ token_matcher::change_dialect(const std::string& dialect_name) { dialect_name_ = dialect_name; - d = get_dialect(dialect_name_); + auto d = get_dialect(dialect_name_); keyword_types_.clear(); From b563dba02c7d1e805cc4701dbbbe35fe4e0ce218 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 5 May 2023 18:46:55 +0200 Subject: [PATCH 13/76] chore: trying to have a clean ast_node construction --- cpp/Makefile | 5 ++ cpp/include/gherkin/ast_builder.hpp | 13 ++- cpp/include/gherkin/ast_node.hpp | 19 ++++- cpp/include/gherkin/messages.hpp | 52 ++++++++++++ cpp/include/gherkin/token_matcher.hpp | 21 +++-- cpp/include/gherkin/utils.hpp | 7 ++ cpp/src/lib/gherkin/ast_builder.cpp | 44 ++++++++++ cpp/src/lib/gherkin/ast_node.cpp | 38 +++++++++ cpp/src/lib/gherkin/line.cpp | 12 +-- cpp/src/lib/gherkin/token_matcher.cpp | 116 +++++++++++++++++++++++--- cpp/src/lib/gherkin/utils.cpp | 20 +++++ 11 files changed, 314 insertions(+), 33 deletions(-) create mode 100644 cpp/include/gherkin/messages.hpp create mode 100644 cpp/src/lib/gherkin/ast_node.cpp diff --git a/cpp/Makefile b/cpp/Makefile index 6444e7da0..6922f6797 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -75,6 +75,11 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac --toolchain cmake/toolchains/ext.cmake \ && touch $@ +clean-configure: + rm -f .configured + +reconfigure: clean-configure .configured + include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 87df07376..4fc5b56a7 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -1,9 +1,11 @@ #pragma once #include +#include #include #include +#include namespace gherkin { @@ -15,11 +17,20 @@ class ast_builder void reset(); - void build(token& token); void start_rule(rule_type rule_type); void end_rule(rule_type rule_type); + void build(token& token); private: + using ast_node_stack = std::stack; + + message transform_node(ast_node& node); + + ast_node pop_node(); + ast_node& current_node(); + const ast_node& current_node() const; + + ast_node_stack stack_; }; using ast_builder_ptr = std::unique_ptr; diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index acc1b25bd..112143f09 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -1,6 +1,8 @@ #pragma once -#include +#include + +#include namespace gherkin { @@ -8,10 +10,23 @@ class ast_node { public: ast_node(rule_type rule_type); - virtual ast_node(); + ast_node(const ast_node& other) = delete; + ast_node(ast_node&& other); + + virtual ~ast_node(); + + ast_node& operator=(const ast_node& other) = delete; + ast_node& operator=(ast_node&& other); + + bool is(rule_type rule_type) const; + + rule_type type() const; + + void add(rule_type rt, message&& m); private: rule_type rule_type_; + messages_map sub_items_; }; } diff --git a/cpp/include/gherkin/messages.hpp b/cpp/include/gherkin/messages.hpp new file mode 100644 index 000000000..f08d8db9b --- /dev/null +++ b/cpp/include/gherkin/messages.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace gherkin { + +using message = std::variant< + cucumber::messages::background, + cucumber::messages::comment, + cucumber::messages::data_table, + cucumber::messages::doc_string, + cucumber::messages::envelope, + cucumber::messages::examples, + cucumber::messages::feature, + cucumber::messages::feature_child, + cucumber::messages::gherkin_document, + cucumber::messages::location, + cucumber::messages::rule, + cucumber::messages::rule_child, + cucumber::messages::scenario, + cucumber::messages::step, + cucumber::messages::table_cell, + cucumber::messages::table_row, + cucumber::messages::tag +>; + +using messages = std::vector; +using messages_map = std::unordered_map; + +} diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index bf32dad36..89d2b9503 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -8,17 +8,12 @@ namespace gherkin { -struct token_matcher_info -{ - std::string dialect = "en"; -}; - using keyword_types_map = std::unordered_map; class token_matcher { public: - token_matcher(const token_matcher_info& tmi = {}); + token_matcher(const std::string& dialect_name = "en"); virtual ~token_matcher(); void reset(); @@ -39,9 +34,15 @@ class token_matcher bool match_table_row(token& token); private: + bool match_doc_string_separator_( + token& token, + std::string_view separator, + bool is_open + ); + bool match_title_line( token& token, - std::string_view text, + std::string_view token_type, string_views keywords ); @@ -56,7 +57,7 @@ class token_matcher void set_token_matched( token& token, - std::string_view text, + std::string_view matched_type, const token_info& ti = {} ); @@ -66,10 +67,12 @@ class token_matcher void change_dialect(const std::string& dialect_name); - token_matcher_info tmi_; + std::string unescape_docstring(const std::string& text) const; std::string dialect_name_; keyword_types_map keyword_types_; + std::string active_doc_string_separator_; + std::size_t indent_to_remove_; }; } diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index 62738c728..b58057590 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include namespace gherkin { @@ -13,4 +14,10 @@ rstrip(std::string_view in, std::string_view chars = " "); std::string_view strip(std::string_view in, std::string_view chars = " "); +void +replace(std::string& s, std::string_view what, std::string_view with); + +std::string +replace(const std::string& s, std::string_view what, std::string_view with); + } diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index bdff65457..1f97ccccb 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -1,3 +1,5 @@ +#include + #include namespace gherkin { @@ -12,8 +14,50 @@ void ast_builder::reset() {} +void +ast_builder::start_rule(rule_type rule_type) +{ stack_.emplace(rule_type); } + +void +ast_builder::end_rule(rule_type rule_type) +{ + auto n = pop_node(); + auto rt = n.type(); + auto p = transform_node(n); + + current_node().add(rt, std::move(p)); +} + void build(token& token) {} +message +ast_builder::transform_node(ast_node& node) +{ + if (node.is(rule_type::step)) { + cucumber::messages::step s{{}, {"titi"}, "toto"}; + } + + return {}; +} + +ast_node +ast_builder::pop_node() +{ + ast_node n = std::move(current_node()); + + stack_.pop(); + + return n; +} + +ast_node& +ast_builder::current_node() +{ return stack_.top(); } + +const ast_node& +ast_builder::current_node() const +{ return stack_.top(); } + } diff --git a/cpp/src/lib/gherkin/ast_node.cpp b/cpp/src/lib/gherkin/ast_node.cpp new file mode 100644 index 000000000..3a70c8adb --- /dev/null +++ b/cpp/src/lib/gherkin/ast_node.cpp @@ -0,0 +1,38 @@ +#include + +namespace gherkin { + +ast_node::ast_node(rule_type rule_type) +: rule_type_(rule_type) +{} + +ast_node::ast_node(ast_node&& other) +: rule_type_(std::move(other.rule_type_)), +sub_items_(std::move(other.sub_items_)) +{} + +ast_node::~ast_node() +{} + +ast_node& +ast_node::operator=(ast_node&& other) +{ + rule_type_ = std::move(other.rule_type_); + sub_items_ = std::move(other.sub_items_); + + return *this; +} + +bool +ast_node::is(rule_type rule_type) const +{ return rule_type_ == rule_type; } + +rule_type +ast_node::type() const +{ return rule_type_; } + +void +ast_node::add(rule_type rt, message&& m) +{ sub_items_[rt].emplace_back(std::move(m)); } + +} diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index df70064be..ea2fe9bdf 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -60,7 +60,7 @@ line::startswith(std::string_view prefix) const bool line::startswith_title_keyword(const std::string& keyword) const -{ return trimmed_line_text_.starts_with(keyword); } +{ return trimmed_line_text_.starts_with(keyword + ":"); } items line::table_cells() const @@ -80,15 +80,7 @@ line::table_cells() const }; for (const auto& p : line_unescapes) { - while (true) { - auto it = i.text.find(p.first); - - if (it = std::string::npos) { - break; - } - - i.text.replace(it, p.first.size(), p.second); - } + replace(i.text, p.first, p.second); } items.emplace_back(std::move(i)); diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index a7a19bf6e..0c052d781 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -10,10 +10,9 @@ static const std::regex language_re{ "\\s*#\\s*language\\s*:\\s*([a-zA-Z\\-_]+)\\s*" }; -token_matcher::token_matcher(const token_matcher_info& tmi) -: tmi_(tmi) +token_matcher::token_matcher(const std::string& dialect_name) { - change_dialect(tmi.dialect); + change_dialect(dialect_name); } token_matcher::~token_matcher() @@ -21,7 +20,10 @@ token_matcher::~token_matcher() void token_matcher::reset() -{} +{ + indent_to_remove_ = 0; + active_doc_string_separator_.clear(); +} bool token_matcher::match_feature_line(token& token) @@ -97,10 +99,32 @@ token_matcher::match_tag_line(token& token) bool token_matcher::match_title_line( token& token, - std::string_view text, + std::string_view token_type, string_views keywords ) -{ return true; } +{ + for (const auto& keyword : keywords) { + std::string k(keyword); + + if (!token.line.startswith_title_keyword(k)) { + continue; + } + + auto ksize = k.size() + 1; // keyword ends with ':' + auto title = token.line.get_rest_trimmed(ksize); + + set_token_matched( + token, token_type, { + .text = std::string(title), + .keyword = k + } + ); + + return true; + } + + return false; +} bool token_matcher::match_e_o_f(token& token) @@ -136,7 +160,18 @@ token_matcher::match_comment(token& token) bool token_matcher::match_other(token& token) -{ return true; } +{ + std::string text = std::string(token.line.get_line_text(indent_to_remove_)); + + set_token_matched( + token, "Other", { + .text = unescape_docstring(text), + .indent = 0 + } + ); + + return true; +} bool token_matcher::match_step_line(token& token) @@ -167,18 +202,63 @@ token_matcher::match_step_line(token& token) bool token_matcher::match_doc_string_separator(token& token) -{ return true; } +{ + if (active_doc_string_separator_.empty()) { + return + match_doc_string_separator_(token, "\"\"\"", true) + || + match_doc_string_separator_(token, "```", true); + } + + return + match_doc_string_separator_( + token, active_doc_string_separator_, true + ); +} + +bool +token_matcher::match_doc_string_separator_( + token& token, + std::string_view separator, + bool is_open +) +{ + if (!token.line.startswith(separator)) { + return false; + } + + std::string content_type; + + if (is_open) { + content_type = token.line.get_rest_trimmed(separator.size()); + active_doc_string_separator_ = separator; + indent_to_remove_ = token.line.indent(); + } else { + active_doc_string_separator_.clear(); + indent_to_remove_ = 0; + } + + set_token_matched( + token, "DocStringSeparator", { + .text = content_type, + .keyword = std::string(separator) + } + ); + + return true; +} void token_matcher::set_token_matched( token& token, - std::string_view text, + std::string_view matched_type, const token_info& ti ) { - token.matched_type = ti.keyword_type; + token.matched_type = matched_type; token.matched_text.assign(rstrip(ti.text, "\r\n")); token.matched_keyword = ti.keyword; + token.matched_keyword_type = ti.keyword_type; if (ti.indent) { token.matched_indent = ti.indent; @@ -191,7 +271,7 @@ token_matcher::set_token_matched( const string_views& token_matcher::keywords(std::string_view kw) const -{ return gherkin::keywords(tmi_.dialect, kw); } +{ return gherkin::keywords(dialect_name_, kw); } std::string_view token_matcher::keyword_type(std::string_view keyword) const @@ -239,4 +319,18 @@ token_matcher::change_dialect(const std::string& dialect_name) } } +std::string +token_matcher::unescape_docstring(const std::string& text) const +{ + std::string u = text; + + if (active_doc_string_separator_ == "\"\"\"") { + replace(u, "\\\"\\\"\\\"", "\"\"\""); + } else if (active_doc_string_separator_ == "```") { + replace(u, "\\`\\`\\`", "```"); + } + + return u; +} + } diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index 9869acec1..2dab69ab9 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -36,4 +36,24 @@ std::string_view strip(std::string_view in, std::string_view chars) { return lstrip(rstrip(in, chars), chars); } +void +replace(std::string& s, std::string_view what, std::string_view with) +{ + std::string::size_type pos; + + while ((pos = s.find(what)) != std::string::npos) { + s.replace(pos, what.size(), with); + } +} + +std::string +replace(const std::string& s, std::string_view what, std::string_view with) +{ + std::string t = s; + + replace(t, what, with); + + return t; +} + } From ba9be9e6b8c55e1443ac78b32b8a0b1fe44876dc Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sat, 6 May 2023 17:02:26 +0200 Subject: [PATCH 14/76] chore: integrated types from cucumber::messages library --- cpp/include/gherkin/ast_builder.hpp | 11 ++- cpp/include/gherkin/ast_node.hpp | 13 ++- cpp/include/gherkin/location.hpp | 11 +++ .../gherkin/{messages.hpp => node_item.hpp} | 11 ++- cpp/include/gherkin/token.hpp | 12 ++- cpp/include/gherkin/token_matcher.hpp | 15 ++-- cpp/src/lib/gherkin/ast_builder.cpp | 27 ++++++- cpp/src/lib/gherkin/ast_node.cpp | 40 ++++++++- cpp/src/lib/gherkin/token_matcher.cpp | 81 +++++++++++++------ 9 files changed, 177 insertions(+), 44 deletions(-) rename cpp/include/gherkin/{messages.hpp => node_item.hpp} (86%) diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 4fc5b56a7..eeb466b0a 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -24,13 +24,22 @@ class ast_builder private: using ast_node_stack = std::stack; - message transform_node(ast_node& node); + std::string next_id(); + + node_item transform_node(ast_node& node); + + cucumber::messages::location get_location( + const token& token, + std::size_t column = 0 + ) const; ast_node pop_node(); ast_node& current_node(); const ast_node& current_node() const; + std::size_t id_counter_ = 0; ast_node_stack stack_; + std::string uri_; }; using ast_builder_ptr = std::unique_ptr; diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 112143f09..984ab62db 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -2,7 +2,7 @@ #include -#include +#include namespace gherkin { @@ -22,11 +22,18 @@ class ast_node rule_type type() const; - void add(rule_type rt, message&& m); + void add(rule_type rule_type, node_item&& m); + + const node_item& get_single(rule_type rule_type) const; + const node_items& get_items(rule_type rule_type) const; + const token& get_token(rule_type rule_type) const; + const node_items& get_tokens(rule_type rule_type) const; private: rule_type rule_type_; - messages_map sub_items_; + node_items_map sub_items_; + node_item empty_node_item_; + node_items empty_node_items_; }; } diff --git a/cpp/include/gherkin/location.hpp b/cpp/include/gherkin/location.hpp index e69de29bb..3835e26b5 100644 --- a/cpp/include/gherkin/location.hpp +++ b/cpp/include/gherkin/location.hpp @@ -0,0 +1,11 @@ +#pragma once + +namespace gherkin { + +struct location +{ + std::size_t line; + std::size_t column; +}; + +} diff --git a/cpp/include/gherkin/messages.hpp b/cpp/include/gherkin/node_item.hpp similarity index 86% rename from cpp/include/gherkin/messages.hpp rename to cpp/include/gherkin/node_item.hpp index f08d8db9b..c2dd67cf9 100644 --- a/cpp/include/gherkin/messages.hpp +++ b/cpp/include/gherkin/node_item.hpp @@ -23,10 +23,11 @@ #include #include +#include namespace gherkin { -using message = std::variant< +using node_item = std::variant< cucumber::messages::background, cucumber::messages::comment, cucumber::messages::data_table, @@ -43,10 +44,12 @@ using message = std::variant< cucumber::messages::step, cucumber::messages::table_cell, cucumber::messages::table_row, - cucumber::messages::tag + cucumber::messages::tag, + token, + tokens >; -using messages = std::vector; -using messages_map = std::unordered_map; +using node_items = std::vector; +using node_items_map = std::unordered_map; } diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index a2a91e8db..47bdddd0c 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -3,23 +3,28 @@ #include #include #include +#include + +#include #include +#include #include +#include namespace gherkin { struct token { gherkin::line line; - std::size_t location; - std::string matched_type; + rule_type matched_type; std::string matched_keyword; - std::string matched_keyword_type; + cucumber::messages::step_keyword_type matched_keyword_type; std::size_t matched_indent = 0; gherkin::items matched_items; std::string matched_text; std::string matched_gherkin_dialect; + gherkin::location location; bool is_eof() const; @@ -28,6 +33,7 @@ struct token std::string_view value() const; }; +using tokens = std::vector; using token_queue = std::deque; } diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index 89d2b9503..2e068c605 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -2,13 +2,17 @@ #include +#include + #include #include #include +#include namespace gherkin { -using keyword_types_map = std::unordered_map; +using keyword_types = std::vector; +using keyword_types_map = std::unordered_map; class token_matcher { @@ -42,7 +46,7 @@ class token_matcher bool match_title_line( token& token, - std::string_view token_type, + rule_type token_type, string_views keywords ); @@ -50,20 +54,21 @@ class token_matcher { std::string text; std::string keyword; - std::string keyword_type; + cucumber::messages::step_keyword_type keyword_type; std::size_t indent; gherkin::items items; }; void set_token_matched( token& token, - std::string_view matched_type, + rule_type matched_type, const token_info& ti = {} ); const string_views& keywords(std::string_view kw) const; - std::string_view keyword_type(std::string_view keyword) const; + cucumber::messages::step_keyword_type + keyword_type(std::string_view keyword) const; void change_dialect(const std::string& dialect_name); diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 1f97ccccb..bd9272ed6 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -32,16 +32,39 @@ void build(token& token) {} -message +std::string +ast_builder::next_id() +{ return std::to_string(id_counter_++); } + +node_item ast_builder::transform_node(ast_node& node) { if (node.is(rule_type::step)) { - cucumber::messages::step s{{}, {"titi"}, "toto"}; + const auto& step_line = node.get_token(rule_type::step_line); + const auto& data_table = node.get_single(rule_type::data_table); + const auto& doc_string = node.get_single(rule_type::doc_string); + + cucumber::messages::step s{ + .location = get_location(step_line), + .keyword = step_line.matched_keyword, + .keyword_type = step_line.matched_keyword_type, + .text = step_line.matched_text, + .id = next_id() + }; } return {}; } +cucumber::messages::location +ast_builder::get_location( + const token& token, + std::size_t column +) const +{ + return {}; +} + ast_node ast_builder::pop_node() { diff --git a/cpp/src/lib/gherkin/ast_node.cpp b/cpp/src/lib/gherkin/ast_node.cpp index 3a70c8adb..5b714a750 100644 --- a/cpp/src/lib/gherkin/ast_node.cpp +++ b/cpp/src/lib/gherkin/ast_node.cpp @@ -32,7 +32,43 @@ ast_node::type() const { return rule_type_; } void -ast_node::add(rule_type rt, message&& m) -{ sub_items_[rt].emplace_back(std::move(m)); } +ast_node::add(rule_type rt, node_item&& n) +{ sub_items_[rt].emplace_back(std::move(n)); } + +const node_item& +ast_node::get_single(rule_type rule_type) const +{ + auto it = sub_items_.find(rule_type); + + if (it != sub_items_.end()) { + const auto& msgs = it->second; + + if (!msgs.empty()) { + return msgs.front(); + } + } + + return empty_node_item_; +} + +const node_items& +ast_node::get_items(rule_type rule_type) const +{ + auto it = sub_items_.find(rule_type); + + return + it != sub_items_.end() + ? it->second + : empty_node_items_ + ; +} + +const token& +ast_node::get_token(rule_type rule_type) const +{ return std::get(get_single(rule_type)); } + +const node_items& +ast_node::get_tokens(rule_type rule_type) const +{ return get_items(rule_type); } } diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 0c052d781..2a3fd59da 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -27,29 +27,52 @@ token_matcher::reset() bool token_matcher::match_feature_line(token& token) -{ return match_title_line(token, "FeatureLine", keywords("feature")); } +{ + return + match_title_line( + token, + rule_type::feature_line, + keywords("feature") + ); +} bool token_matcher::match_rule_line(token& token) -{ return match_title_line(token, "RuleLine", keywords("rule")); } +{ return match_title_line(token, rule_type::rule_line, keywords("rule")); } bool token_matcher::match_scenario_line(token& token) { + auto rt = rule_type::scenario_line; + return - match_title_line(token, "ScenarioLine", keywords("scenario")) + match_title_line(token, rt, keywords("scenario")) || - match_title_line(token, "ScenarioLine", keywords("scenarioOutline")) + match_title_line(token, rt, keywords("scenarioOutline")) ; } bool token_matcher::match_background_line(token& token) -{ return match_title_line(token, "BackgroundLine", keywords("background")); } +{ + return + match_title_line( + token, + rule_type::background_line, + keywords("background") + ); +} bool token_matcher::match_examples_line(token& token) -{ return match_title_line(token, "ExamplesLine", keywords("examples")); } +{ + return + match_title_line( + token, + rule_type::examples_line, + keywords("examples") + ); +} bool token_matcher::match_table_row(token& token) @@ -59,7 +82,7 @@ token_matcher::match_table_row(token& token) } set_token_matched( - token, "TableRow", { .items = token.line.table_cells() } + token, rule_type::table_row, { .items = token.line.table_cells() } ); return true; @@ -74,7 +97,7 @@ token_matcher::match_language(token& token) return false; } - set_token_matched(token, "Language", { .text = dialect_name }); + set_token_matched(token, rule_type::language, { .text = dialect_name }); change_dialect(dialect_name); return true; @@ -88,7 +111,7 @@ token_matcher::match_tag_line(token& token) } set_token_matched( - token, "TagLine", { + token, rule_type::tag_line, { .items = std::move(token.line.tags()) } ); @@ -99,7 +122,7 @@ token_matcher::match_tag_line(token& token) bool token_matcher::match_title_line( token& token, - std::string_view token_type, + rule_type token_type, string_views keywords ) { @@ -137,7 +160,7 @@ token_matcher::match_empty(token& token) return false; } - set_token_matched(token, "Empty", { .indent = 0 } ); + set_token_matched(token, rule_type::empty, { .indent = 0 } ); return true; } @@ -150,7 +173,7 @@ token_matcher::match_comment(token& token) } set_token_matched( - token, "Comment", { + token, rule_type::comment, { .text = std::string(token.line.line_text()) } ); @@ -164,7 +187,7 @@ token_matcher::match_other(token& token) std::string text = std::string(token.line.get_line_text(indent_to_remove_)); set_token_matched( - token, "Other", { + token, rule_type::other, { .text = unescape_docstring(text), .indent = 0 } @@ -187,10 +210,10 @@ token_matcher::match_step_line(token& token) auto title = token.line.get_rest_trimmed(keyword.size()); set_token_matched( - token, "StepLine", { + token, rule_type::step_line, { .text = std::string(title), .keyword = std::string(keyword), - .keyword_type = std::string(keyword_type(keyword)) + .keyword_type = keyword_type(keyword) } ); @@ -239,7 +262,7 @@ token_matcher::match_doc_string_separator_( } set_token_matched( - token, "DocStringSeparator", { + token, rule_type::doc_string_separator, { .text = content_type, .keyword = std::string(separator) } @@ -251,7 +274,7 @@ token_matcher::match_doc_string_separator_( void token_matcher::set_token_matched( token& token, - std::string_view matched_type, + rule_type matched_type, const token_info& ti ) { @@ -273,7 +296,7 @@ const string_views& token_matcher::keywords(std::string_view kw) const { return gherkin::keywords(dialect_name_, kw); } -std::string_view +cucumber::messages::step_keyword_type token_matcher::keyword_type(std::string_view keyword) const { auto it = keyword_types_.find(keyword); @@ -286,7 +309,7 @@ token_matcher::keyword_type(std::string_view keyword) const } } - return "Unknown"; + return cucumber::messages::step_keyword_type::UNKNOWN; } void @@ -299,23 +322,33 @@ token_matcher::change_dialect(const std::string& dialect_name) keyword_types_.clear(); for (const auto& keyword : d.given_keywords) { - keyword_types_[keyword].push_back("Context"); + keyword_types_[keyword].push_back( + cucumber::messages::step_keyword_type::CONTEXT + ); } for (const auto& keyword : d.when_keywords) { - keyword_types_[keyword].push_back("Action"); + keyword_types_[keyword].push_back( + cucumber::messages::step_keyword_type::ACTION + ); } for (const auto& keyword : d.then_keywords) { - keyword_types_[keyword].push_back("Outcome"); + keyword_types_[keyword].push_back( + cucumber::messages::step_keyword_type::OUTCOME + ); } for (const auto& keyword : d.and_keywords) { - keyword_types_[keyword].push_back("Conjunction"); + keyword_types_[keyword].push_back( + cucumber::messages::step_keyword_type::CONJUNCTION + ); } for (const auto& keyword : d.but_keywords) { - keyword_types_[keyword].push_back("Conjunction"); + keyword_types_[keyword].push_back( + cucumber::messages::step_keyword_type::CONJUNCTION + ); } } From 1e73ad6770090c718beb859a3d38953c070431c2 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sat, 6 May 2023 18:32:01 +0200 Subject: [PATCH 15/76] chore: trying different ast_node sub item management --- cpp/include/gherkin/ast_node.hpp | 31 ++++++++++++++++----- cpp/include/gherkin/node_item.hpp | 42 ++++++++++++++++------------- cpp/src/lib/gherkin/ast_builder.cpp | 8 +++--- cpp/src/lib/gherkin/ast_node.cpp | 36 ------------------------- 4 files changed, 53 insertions(+), 64 deletions(-) diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 984ab62db..16a894fcd 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include @@ -24,16 +26,33 @@ class ast_node void add(rule_type rule_type, node_item&& m); - const node_item& get_single(rule_type rule_type) const; - const node_items& get_items(rule_type rule_type) const; - const token& get_token(rule_type rule_type) const; - const node_items& get_tokens(rule_type rule_type) const; + template + auto get_single(rule_type rule_type) + { + using ptr_type = std::unique_ptr; + using ret_type = std::optional>; + ret_type r; + + auto it = sub_items_.find(rule_type); + + if (it != sub_items_.end()) { + auto& items = it->second; + + if (!items.empty()) { + auto& p = std::get(items.front()); + r = std::ref(*p); + } + } + + return r; + } + + auto get_token(rule_type rule_type) + { return get_single(rule_type); } private: rule_type rule_type_; node_items_map sub_items_; - node_item empty_node_item_; - node_items empty_node_items_; }; } diff --git a/cpp/include/gherkin/node_item.hpp b/cpp/include/gherkin/node_item.hpp index c2dd67cf9..9589c2af3 100644 --- a/cpp/include/gherkin/node_item.hpp +++ b/cpp/include/gherkin/node_item.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -27,26 +28,29 @@ namespace gherkin { +struct null_node_item {}; + using node_item = std::variant< - cucumber::messages::background, - cucumber::messages::comment, - cucumber::messages::data_table, - cucumber::messages::doc_string, - cucumber::messages::envelope, - cucumber::messages::examples, - cucumber::messages::feature, - cucumber::messages::feature_child, - cucumber::messages::gherkin_document, - cucumber::messages::location, - cucumber::messages::rule, - cucumber::messages::rule_child, - cucumber::messages::scenario, - cucumber::messages::step, - cucumber::messages::table_cell, - cucumber::messages::table_row, - cucumber::messages::tag, - token, - tokens + null_node_item, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr, + std::unique_ptr >; using node_items = std::vector; diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index bd9272ed6..a615f48b5 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -40,9 +40,11 @@ node_item ast_builder::transform_node(ast_node& node) { if (node.is(rule_type::step)) { - const auto& step_line = node.get_token(rule_type::step_line); - const auto& data_table = node.get_single(rule_type::data_table); - const auto& doc_string = node.get_single(rule_type::doc_string); + auto step_line = node.get_token(rule_type::step_line); + auto data_table = node.get_single( + rule_type::data_table + ); + //auto doc_string = node.get_single(rule_type::doc_string); cucumber::messages::step s{ .location = get_location(step_line), diff --git a/cpp/src/lib/gherkin/ast_node.cpp b/cpp/src/lib/gherkin/ast_node.cpp index 5b714a750..02ecfa521 100644 --- a/cpp/src/lib/gherkin/ast_node.cpp +++ b/cpp/src/lib/gherkin/ast_node.cpp @@ -35,40 +35,4 @@ void ast_node::add(rule_type rt, node_item&& n) { sub_items_[rt].emplace_back(std::move(n)); } -const node_item& -ast_node::get_single(rule_type rule_type) const -{ - auto it = sub_items_.find(rule_type); - - if (it != sub_items_.end()) { - const auto& msgs = it->second; - - if (!msgs.empty()) { - return msgs.front(); - } - } - - return empty_node_item_; -} - -const node_items& -ast_node::get_items(rule_type rule_type) const -{ - auto it = sub_items_.find(rule_type); - - return - it != sub_items_.end() - ? it->second - : empty_node_items_ - ; -} - -const token& -ast_node::get_token(rule_type rule_type) const -{ return std::get(get_single(rule_type)); } - -const node_items& -ast_node::get_tokens(rule_type rule_type) const -{ return get_items(rule_type); } - } From 9def3c8363c01fe5f51e8037d5debe2616e10774 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sun, 7 May 2023 18:43:27 +0200 Subject: [PATCH 16/76] chore: more ast_builder implementation --- cpp/include/gherkin/ast_builder.hpp | 10 ++- cpp/include/gherkin/ast_node.hpp | 42 ++++++++-- cpp/include/gherkin/container_helpers.hpp | 45 +++++++++++ cpp/include/gherkin/join_utils.hpp | 98 +++++++++++++++++++++++ cpp/include/gherkin/node_item.hpp | 11 +++ cpp/src/lib/gherkin/ast_builder.cpp | 78 ++++++++++++++++-- 6 files changed, 268 insertions(+), 16 deletions(-) create mode 100644 cpp/include/gherkin/container_helpers.hpp create mode 100644 cpp/include/gherkin/join_utils.hpp diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index eeb466b0a..85d7286ed 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -9,6 +10,10 @@ namespace gherkin { +namespace cms = cucumber::messages; +using table_rows = std::vector; +using table_cells = std::vector; + class ast_builder { public: @@ -28,11 +33,14 @@ class ast_builder node_item transform_node(ast_node& node); - cucumber::messages::location get_location( + cms::location get_location( const token& token, std::size_t column = 0 ) const; + table_rows get_table_rows(ast_node& node); + table_cells get_table_cells(const token& token); + ast_node pop_node(); ast_node& current_node(); const ast_node& current_node() const; diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 16a894fcd..e1f046472 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -24,14 +24,22 @@ class ast_node rule_type type() const; - void add(rule_type rule_type, node_item&& m); + void add(rule_type rule_type, node_item&& n); + + template + void add(rule_type rule_type, T&& v) + { + auto n = make_node_item(std::move(v)); + + add(n); + } template auto get_single(rule_type rule_type) { - using ptr_type = std::unique_ptr; - using ret_type = std::optional>; - ret_type r; + using type = std::remove_reference_t; + using ptr_type = std::unique_ptr; + type* ret = nullptr; auto it = sub_items_.find(rule_type); @@ -40,15 +48,33 @@ class ast_node if (!items.empty()) { auto& p = std::get(items.front()); - r = std::ref(*p); + ret = p.get(); } } - return r; + return ret; } - auto get_token(rule_type rule_type) - { return get_single(rule_type); } + token& get_token(rule_type rule_type) + { return *get_single(rule_type); } + + tokens& get_tokens(rule_type rule_type) + { return *get_single(rule_type); } + + token& get_first_token(rule_type rule_type) + { return get_tokens(rule_type).front(); } + + template + void set_from_single(rule_type rule_type, T&& v) + { + using type = std::remove_reference_t; + + auto p = get_single(rule_type); + + if (p) { + v = *p; + } + } private: rule_type rule_type_; diff --git a/cpp/include/gherkin/container_helpers.hpp b/cpp/include/gherkin/container_helpers.hpp new file mode 100644 index 000000000..feceb9dd9 --- /dev/null +++ b/cpp/include/gherkin/container_helpers.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include +#include +#include + +namespace gherkin { + +template +struct is_vector : public std::false_type{}; + +template +struct is_vector> : public std::true_type{}; + +template +using is_vector_t = typename is_vector::type; + +template +constexpr bool is_vector_v = is_vector::value; + +template +struct is_set : public std::false_type{}; + +template +struct is_set> : public std::true_type{}; + +template +using is_set_t = typename is_set::type; + +template +constexpr bool is_set_v = is_set::value; + +template +struct is_unordered_set : public std::false_type{}; + +template +struct is_unordered_set> : public std::true_type{}; + +template +using is_unordered_set_t = typename is_unordered_set::type; + +template +constexpr bool is_unordered_set_v = is_unordered_set::value; + +} diff --git a/cpp/include/gherkin/join_utils.hpp b/cpp/include/gherkin/join_utils.hpp new file mode 100644 index 000000000..ca6148ae4 --- /dev/null +++ b/cpp/include/gherkin/join_utils.hpp @@ -0,0 +1,98 @@ +#pragma once + +#include +#include + +#include + +namespace gherkin { + +namespace detail { + +template +std::size_t +join_container_impl( + std::ostream& os, + const std::string& sep, + const Container& c +) +{ + if (!c.empty()) { + auto it = c.begin(); + + os << *it; + + while (++it != c.end()) { + os << sep << *it; + } + } + + return c.size(); +} + +} // namespace detail + +template +struct is_joinable_container +{ + using type = std::conditional_t< + is_vector_v + || is_set_v + || is_unordered_set_v, + std::true_type, + std::false_type + >; + + static constexpr type::value_type value = type::value; +}; + +template +using is_joinable_container_t = typename is_joinable_container::type; + +template +constexpr bool is_joinable_container_v = is_joinable_container::value; + +template +void +join_item_impl( + std::ostream& os, + const std::string& sep, + Args&&... args +) +{ + std::size_t prev_count = 0; + + auto join_arg = [&](auto&& arg) { + using type = std::decay_t; + + if constexpr (is_joinable_container_v) { + if (prev_count && !arg.empty()) { + os << sep; + } + + prev_count += detail::join_container_impl(os, sep, arg); + } else { + if (prev_count) { + os << sep; + } + + os << arg; + ++prev_count; + } + }; + + (join_arg(std::forward(args)), ...); +} + +template +std::string +join(const std::string& sep, Args&&... args) +{ + std::ostringstream oss; + + join_item_impl(oss, sep, std::forward(args)...); + + return oss.str(); +} + +} diff --git a/cpp/include/gherkin/node_item.hpp b/cpp/include/gherkin/node_item.hpp index 9589c2af3..89a6355f5 100644 --- a/cpp/include/gherkin/node_item.hpp +++ b/cpp/include/gherkin/node_item.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -56,4 +57,14 @@ using node_item = std::variant< using node_items = std::vector; using node_items_map = std::unordered_map; +template +node_item +make_node_item(T&& v) +{ + using type = std::remove_reference_t; + auto p = std::make_unique(std::move(v)); + + return node_item(std::move(p)); +} + } diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index a615f48b5..4191b3be8 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -1,6 +1,7 @@ #include #include +#include namespace gherkin { @@ -40,25 +41,53 @@ node_item ast_builder::transform_node(ast_node& node) { if (node.is(rule_type::step)) { - auto step_line = node.get_token(rule_type::step_line); - auto data_table = node.get_single( - rule_type::data_table - ); - //auto doc_string = node.get_single(rule_type::doc_string); + auto& step_line = node.get_token(rule_type::step_line); - cucumber::messages::step s{ + cms::step s{ .location = get_location(step_line), .keyword = step_line.matched_keyword, .keyword_type = step_line.matched_keyword_type, .text = step_line.matched_text, .id = next_id() }; + + node.set_from_single(rule_type::doc_string, s.doc_string); + node.set_from_single(rule_type::data_table, s.data_table); + + return make_node_item(s); + } else if (node.is(rule_type::doc_string)) { + auto& separator_token = + node.get_first_token(rule_type::doc_string_separator); + + string_views svs; + + for (const auto& t : node.get_tokens(rule_type::other)) { + svs.push_back(t.matched_text); + } + + cms::doc_string ds{ + .location = get_location(separator_token), + .media_type = separator_token.matched_text, + .content = join("\n", svs), + .delimiter = separator_token.matched_keyword + }; + + return make_node_item(ds); + } else if (node.is(rule_type::data_table)) { + auto rows = get_table_rows(node); + + cms::data_table dt{ + .location = rows.front().location, + .rows = std::move(rows) + }; + + return make_node_item(dt); } return {}; } -cucumber::messages::location +cms::location ast_builder::get_location( const token& token, std::size_t column @@ -67,6 +96,41 @@ ast_builder::get_location( return {}; } +table_rows +ast_builder::get_table_rows(ast_node& node) +{ + table_rows rows; + + for (const auto& t : node.get_tokens(rule_type::table_row)) { + cms::table_row row{ + .location = get_location(t), + .cells = get_table_cells(t), + .id = next_id() + }; + + rows.emplace_back(std::move(row)); + } + + return rows; +} + +table_cells +ast_builder::get_table_cells(const token& token) +{ + table_cells cells; + + for (const auto& i : token.matched_items) { + cms::table_cell cell{ + .location = get_location(token, i.column), + .value = i.text + }; + + cells.emplace_back(std::move(cell)); + } + + return cells; +} + ast_node ast_builder::pop_node() { From 3ddd1596fc88bbf490241db8f8385fb0b12313c3 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 8 May 2023 18:28:12 +0200 Subject: [PATCH 17/76] chore: cleaned ast_node tree implementation --- cpp/include/gherkin/ast_builder.hpp | 15 ++- cpp/include/gherkin/ast_node.hpp | 128 +++++++++++++++------- cpp/include/gherkin/node_item.hpp | 70 ------------ cpp/src/lib/gherkin/ast_builder.cpp | 161 ++++++++++++++++++++++------ cpp/src/lib/gherkin/ast_node.cpp | 4 - 5 files changed, 232 insertions(+), 146 deletions(-) delete mode 100644 cpp/include/gherkin/node_item.hpp diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 85d7286ed..bc00dfc5f 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -11,6 +11,7 @@ namespace gherkin { namespace cms = cucumber::messages; + using table_rows = std::vector; using table_cells = std::vector; @@ -31,7 +32,19 @@ class ast_builder std::string next_id(); - node_item transform_node(ast_node& node); + ast_node transform_node(ast_node& node); + + cms::step make_step(ast_node& node); + cms::doc_string make_doc_string(ast_node& node); + cms::data_table make_data_table(ast_node& node); + cms::background make_background(ast_node& node); + cms::scenario make_scenario_definition(ast_node& node); + cms::examples make_examples_definition(ast_node& node); + table_rows make_examples_table(ast_node& node); + std::string make_description(ast_node& node); + cms::feature make_feature(ast_node& node); + cms::rule make_rule(ast_node& node); + cms::gherkin_document make_gherkin_document(ast_node& node); cms::location get_location( const token& token, diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index e1f046472..9cb55df10 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -1,13 +1,64 @@ #pragma once +#include +#include +#include +#include #include -#include -#include - -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include namespace gherkin { +class ast_node; + +using ast_nodes = std::vector; + +using ast_node_data = std::variant< + ast_nodes, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + std::vector, + strings, + tokens +>; + +using ast_node_items = std::unordered_map; + class ast_node { public: @@ -24,61 +75,64 @@ class ast_node rule_type type() const; - void add(rule_type rule_type, node_item&& n); - template void add(rule_type rule_type, T&& v) { - auto n = make_node_item(std::move(v)); - - add(n); } - template - auto get_single(rule_type rule_type) + tokens& get_tokens(rule_type rule_type) + { return std::get(sub_items_[rule_type]); } + + token& get_token(rule_type rule_type) + { return get_tokens(rule_type).front(); } + + template + void visit(rule_type rule_type, Callable cb) { using type = std::remove_reference_t; - using ptr_type = std::unique_ptr; - type* ret = nullptr; + using vtype = std::vector; auto it = sub_items_.find(rule_type); - if (it != sub_items_.end()) { - auto& items = it->second; - - if (!items.empty()) { - auto& p = std::get(items.front()); - ret = p.get(); - } + if (it == sub_items_.end()) { + return; } - return ret; - } + auto& items = std::get(it->second); - token& get_token(rule_type rule_type) - { return *get_single(rule_type); } - - tokens& get_tokens(rule_type rule_type) - { return *get_single(rule_type); } - - token& get_first_token(rule_type rule_type) - { return get_tokens(rule_type).front(); } + if (!items.empty()) { + cb(items); + } + } template void set_from_single(rule_type rule_type, T&& v) { - using type = std::remove_reference_t; - - auto p = get_single(rule_type); + visit( + rule_type, + [&](auto& items) { + v = items.front(); + } + ); + } - if (p) { - v = *p; - } + template + void set_from_items(rule_type rule_type, std::vector& vs) + { + visit( + rule_type, + [&](auto& items) { + std::copy( + items.begin(), items.end(), + std::back_inserter(vs) + ); + } + ); } private: rule_type rule_type_; - node_items_map sub_items_; + ast_node_items sub_items_; }; } diff --git a/cpp/include/gherkin/node_item.hpp b/cpp/include/gherkin/node_item.hpp deleted file mode 100644 index 89a6355f5..000000000 --- a/cpp/include/gherkin/node_item.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace gherkin { - -struct null_node_item {}; - -using node_item = std::variant< - null_node_item, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr, - std::unique_ptr ->; - -using node_items = std::vector; -using node_items_map = std::unordered_map; - -template -node_item -make_node_item(T&& v) -{ - using type = std::remove_reference_t; - auto p = std::make_unique(std::move(v)); - - return node_item(std::move(p)); -} - -} diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 4191b3be8..5749b6128 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -37,53 +37,146 @@ std::string ast_builder::next_id() { return std::to_string(id_counter_++); } -node_item +ast_node ast_builder::transform_node(ast_node& node) { if (node.is(rule_type::step)) { - auto& step_line = node.get_token(rule_type::step_line); - - cms::step s{ - .location = get_location(step_line), - .keyword = step_line.matched_keyword, - .keyword_type = step_line.matched_keyword_type, - .text = step_line.matched_text, - .id = next_id() - }; + make_step(node); + } else if (node.is(rule_type::doc_string)) { + make_doc_string(node); + } else if (node.is(rule_type::data_table)) { + make_data_table(node); + } else if (node.is(rule_type::background)) { + make_background(node); + } else if (node.is(rule_type::scenario_definition)) { + make_scenario_definition(node); + } else if (node.is(rule_type::examples_definition)) { + make_examples_definition(node); + } else if (node.is(rule_type::examples_table)) { + make_examples_table(node); + } else if (node.is(rule_type::description)) { + make_description(node); + } else if (node.is(rule_type::feature)) { + make_feature(node); + } else if (node.is(rule_type::rule)) { + make_rule(node); + } else if (node.is(rule_type::gherkin_document)) { + make_gherkin_document(node); + } - node.set_from_single(rule_type::doc_string, s.doc_string); - node.set_from_single(rule_type::data_table, s.data_table); + return ast_node(rule_type::none); +} - return make_node_item(s); - } else if (node.is(rule_type::doc_string)) { - auto& separator_token = - node.get_first_token(rule_type::doc_string_separator); +cms::step +ast_builder::make_step(ast_node& node) +{ + auto& step_line = node.get_token(rule_type::step_line); - string_views svs; + cms::step s{ + .location = get_location(step_line), + .keyword = step_line.matched_keyword, + .keyword_type = step_line.matched_keyword_type, + .text = step_line.matched_text, + .id = next_id() + }; - for (const auto& t : node.get_tokens(rule_type::other)) { - svs.push_back(t.matched_text); - } + node.set_from_single(rule_type::doc_string, s.doc_string); + node.set_from_single(rule_type::data_table, s.data_table); - cms::doc_string ds{ - .location = get_location(separator_token), - .media_type = separator_token.matched_text, - .content = join("\n", svs), - .delimiter = separator_token.matched_keyword - }; + return s; +} - return make_node_item(ds); - } else if (node.is(rule_type::data_table)) { - auto rows = get_table_rows(node); +cms::doc_string +ast_builder::make_doc_string(ast_node& node) +{ + auto& separator_token = node.get_token(rule_type::doc_string_separator); - cms::data_table dt{ - .location = rows.front().location, - .rows = std::move(rows) - }; + string_views svs; - return make_node_item(dt); + for (const auto& t : node.get_tokens(rule_type::other)) { + svs.push_back(t.matched_text); } + cms::doc_string ds{ + .location = get_location(separator_token), + .media_type = separator_token.matched_text, + .content = join("\n", svs), + .delimiter = separator_token.matched_keyword + }; + + return ds; +} + +cms::data_table +ast_builder::make_data_table(ast_node& node) +{ + auto rows = get_table_rows(node); + + cms::data_table dt{ + .location = rows.front().location, + .rows = std::move(rows) + }; + + return dt; +} + +cms::background +ast_builder::make_background(ast_node& node) +{ + auto& background_line = node.get_token(rule_type::background_line); + + cms::background b{ + .location = get_location(background_line), + .keyword = background_line.matched_keyword, + .name = background_line.matched_text, + .id = next_id() + }; + + node.set_from_single(rule_type::description, b.description); + node.set_from_items(rule_type::step, b.steps); + + return b; +} + +cms::scenario +ast_builder::make_scenario_definition(ast_node& node) +{ + return {}; +} + +cms::examples +ast_builder::make_examples_definition(ast_node& node) +{ + return {}; +} + +table_rows +ast_builder::make_examples_table(ast_node& node) +{ + return {}; +} + +std::string +ast_builder::make_description(ast_node& node) +{ + return {}; +} + +cms::feature +ast_builder::make_feature(ast_node& node) +{ + return {}; +} + +cms::rule +ast_builder::make_rule(ast_node& node) +{ + return {}; +} + +cms::gherkin_document +ast_builder::make_gherkin_document(ast_node& node) +{ return {}; } diff --git a/cpp/src/lib/gherkin/ast_node.cpp b/cpp/src/lib/gherkin/ast_node.cpp index 02ecfa521..58cdceca0 100644 --- a/cpp/src/lib/gherkin/ast_node.cpp +++ b/cpp/src/lib/gherkin/ast_node.cpp @@ -31,8 +31,4 @@ rule_type ast_node::type() const { return rule_type_; } -void -ast_node::add(rule_type rt, node_item&& n) -{ sub_items_[rt].emplace_back(std::move(n)); } - } From 6eec05471149ed58dd55595815b4a3bd189e7097 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 9 May 2023 15:40:52 +0200 Subject: [PATCH 18/76] chore: most of ast_builder done --- cpp/include/gherkin/ast_builder.hpp | 4 ++ cpp/include/gherkin/ast_node.hpp | 41 ++++++++--- cpp/src/lib/gherkin/ast_builder.cpp | 104 +++++++++++++++++++++++++--- 3 files changed, 129 insertions(+), 20 deletions(-) diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index bc00dfc5f..f120c115d 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -14,6 +14,8 @@ namespace cms = cucumber::messages; using table_rows = std::vector; using table_cells = std::vector; +using tags = std::vector; +using comments = std::vector; class ast_builder { @@ -53,6 +55,7 @@ class ast_builder table_rows get_table_rows(ast_node& node); table_cells get_table_cells(const token& token); + tags get_tags(ast_node& node); ast_node pop_node(); ast_node& current_node(); @@ -61,6 +64,7 @@ class ast_builder std::size_t id_counter_ = 0; ast_node_stack stack_; std::string uri_; + comments comments_; }; using ast_builder_ptr = std::unique_ptr; diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 9cb55df10..d62916f54 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -80,14 +80,27 @@ class ast_node { } - tokens& get_tokens(rule_type rule_type) - { return std::get(sub_items_[rule_type]); } + template + auto& get_items(rule_type rule_type) + { + using type = std::remove_reference_t; + using vtype = std::vector; + + return std::get(sub_items_[rule_type]); + } + + template + auto& get_single(rule_type rule_type) + { return get_items(rule_type).front(); } - token& get_token(rule_type rule_type) - { return get_tokens(rule_type).front(); } + auto& get_tokens(rule_type rule_type) + { return get_items(rule_type); } + + auto& get_token(rule_type rule_type) + { return get_single(rule_type); } template - void visit(rule_type rule_type, Callable cb) + void visit_items(rule_type rule_type, Callable cb) { using type = std::remove_reference_t; using vtype = std::vector; @@ -105,21 +118,27 @@ class ast_node } } - template - void set_from_single(rule_type rule_type, T&& v) + template + void visit_item(rule_type rule_type, Callable cb) { - visit( + visit_items( rule_type, - [&](auto& items) { - v = items.front(); + [&cb](auto& items) { + if (!items.empty()) { + cb(items.front()); + } } ); } + template + void set_from_single(rule_type rule_type, T&& v) + { visit_item(rule_type, [&](auto& item) { v = item; } ); } + template void set_from_items(rule_type rule_type, std::vector& vs) { - visit( + visit_items( rule_type, [&](auto& items) { std::copy( diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 5749b6128..2ce86ee57 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -141,43 +141,102 @@ ast_builder::make_background(ast_node& node) cms::scenario ast_builder::make_scenario_definition(ast_node& node) { - return {}; + auto& scenario_node = node.get_single(rule_type::scenario); + auto& scenario_line = scenario_node.get_token(rule_type::scenario_line); + + cms::scenario s{ + .location = get_location(scenario_line), + .tags = get_tags(node), + .keyword = scenario_line.matched_keyword, + .name = scenario_line.matched_text, + .id = next_id() + }; + + scenario_node.set_from_single(rule_type::description, s.description); + scenario_node.set_from_items(rule_type::step, s.steps); + scenario_node.set_from_items(rule_type::examples_definition, s.examples); + + return s; } cms::examples ast_builder::make_examples_definition(ast_node& node) { - return {}; + auto& examples_node = node.get_single(rule_type::examples); + auto& examples_line = examples_node.get_token(rule_type::examples_line); + + cms::examples es{ + .location = get_location(examples_line), + .tags = get_tags(node), + .keyword = examples_line.matched_keyword, + .name = examples_line.matched_text, + .id = next_id() + }; + + examples_node.set_from_single(rule_type::description, es.description); + + return es; } table_rows ast_builder::make_examples_table(ast_node& node) -{ - return {}; -} +{ return get_table_rows(node); } std::string ast_builder::make_description(ast_node& node) { - return {}; + return "FIXME"; } cms::feature ast_builder::make_feature(ast_node& node) { - return {}; + auto& header = node.get_single(rule_type::feature_header); + auto& feature_line = header.get_token(rule_type::feature_line); + + cms::feature f{ + .location = get_location(feature_line), + .tags = get_tags(header), + .keyword = feature_line.matched_keyword, + .name = feature_line.matched_text + }; + + header.set_from_single(rule_type::description, f.description); + + return f; } cms::rule ast_builder::make_rule(ast_node& node) { - return {}; + auto& header = node.get_single(rule_type::rule_header); + auto& rule_line = header.get_token(rule_type::rule_line); + + cms::rule r{ + .location = get_location(rule_line), + .tags = get_tags(header), + .keyword = rule_line.matched_keyword, + .name = rule_line.matched_text, + .id = next_id() + }; + + header.set_from_single(rule_type::description, r.description); + + return r; } cms::gherkin_document ast_builder::make_gherkin_document(ast_node& node) { - return {}; + auto& feature = node.get_single(rule_type::feature); + + cms::gherkin_document gd{ + .uri = uri_, + .feature = feature, + .comments = comments_ + }; + + return gd; } cms::location @@ -224,6 +283,33 @@ ast_builder::get_table_cells(const token& token) return cells; } +tags +ast_builder::get_tags(ast_node& node) +{ + tags ts; + + node.visit_item( + rule_type::tags, + [&](auto& tags_node) { + auto& tokens = tags_node.get_tokens(rule_type::tag_line); + + for (auto& token : tokens) { + for (auto& tag_item : token.matched_items) { + cms::tag t{ + .location = get_location(token, tag_item.column), + .name = tag_item.text, + .id = next_id() + }; + + ts.emplace_back(std::move(t)); + } + } + } + ); + + return ts; +} + ast_node ast_builder::pop_node() { From 0cce844ec049759b7d6dfc9b8f51ab581c816a62 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 9 May 2023 18:21:02 +0200 Subject: [PATCH 19/76] chore: adding binaries --- cpp/src/bin/gherkin/gherkin.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 cpp/src/bin/gherkin/gherkin.cpp diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp new file mode 100644 index 000000000..02b12289b --- /dev/null +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -0,0 +1,15 @@ +#include + +#include + +struct options +{ + bool print_source_events; + bool print_ast_events; + bool print_pickle_events; +}; + +int main(int ac, char** av) +{ + return 0; +} From d9e56819abc10146d7734c74d54a1dbe9359a7a9 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Wed, 10 May 2023 18:50:21 +0200 Subject: [PATCH 20/76] chore: bug fixes and gearing towards testing --- cpp/CMakeLists.txt | 3 +- cpp/cmake/toolchains/ext.cmake | 5 ++ cpp/gherkin-cpp.razor | 11 +++- cpp/include/gherkin/ast_builder.hpp | 4 +- cpp/include/gherkin/ast_node.hpp | 41 +++++++++++- cpp/include/gherkin/parser.hpp | 8 ++- cpp/include/gherkin/token.hpp | 1 + cpp/include/gherkin/token_scanner.hpp | 4 +- cpp/src/bin/gherkin/CMakeLists.txt | 26 ++++++++ cpp/src/bin/gherkin/gherkin.cpp | 6 ++ cpp/src/lib/gherkin/CMakeLists.txt | 2 +- cpp/src/lib/gherkin/ast_builder.cpp | 93 +++++++++++++++++---------- cpp/src/lib/gherkin/dialect.cpp | 2 +- cpp/src/lib/gherkin/line.cpp | 15 +++-- cpp/src/lib/gherkin/parser.cpp | 11 +++- cpp/src/lib/gherkin/token.cpp | 2 +- cpp/src/lib/gherkin/token_matcher.cpp | 10 ++- cpp/src/lib/gherkin/token_scanner.cpp | 34 +++++++--- 18 files changed, 215 insertions(+), 63 deletions(-) create mode 100644 cpp/src/bin/gherkin/CMakeLists.txt diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 800ed18e8..ade033887 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -12,10 +12,11 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) find_package(cucumber-messages CONFIG REQUIRED) add_subdirectory(src/lib/gherkin) +add_subdirectory(src/bin/gherkin) install( TARGETS - gherkin-cpp + gherkin-cpp gherkin-bin EXPORT gherkin-cpp-config FILE_SET gherkin_cpp_headers RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/cpp/cmake/toolchains/ext.cmake b/cpp/cmake/toolchains/ext.cmake index 1a6c2812b..62c07e58e 100644 --- a/cpp/cmake/toolchains/ext.cmake +++ b/cpp/cmake/toolchains/ext.cmake @@ -18,3 +18,8 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +if(DEFINED ENV{GHERKIN_DEBUG}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fsanitize=address") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fsanitize=address") +endif() diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index e8d7702ed..72d4b11ae 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -164,7 +164,10 @@ parser::parser(const parser_info& pi) : pi_{pi} {} -std::size_t +parser::~parser() +{} + +const cms::gherkin_document& parser::parse(const file& file) { builder_.reset(); @@ -196,9 +199,13 @@ parser::parse(const file& file) // TODO: thow coumpound error } - return 0; + return get_result(); } +const cms::gherkin_document& +parser::get_result() const +{ return builder_.get_result(); } + static void build(parser_context& context, token& token) diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index f120c115d..588616d1b 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -29,12 +29,14 @@ class ast_builder void end_rule(rule_type rule_type); void build(token& token); + const cms::gherkin_document& get_result() const; + private: using ast_node_stack = std::stack; std::string next_id(); - ast_node transform_node(ast_node& node); + void transform_node(ast_node& from, ast_node& to); cms::step make_step(ast_node& node); cms::doc_string make_doc_string(ast_node& node); diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index d62916f54..963588cb9 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -62,7 +62,7 @@ using ast_node_items = std::unordered_map; class ast_node { public: - ast_node(rule_type rule_type); + ast_node(rule_type rule_type = rule_type::none); ast_node(const ast_node& other) = delete; ast_node(ast_node&& other); @@ -75,9 +75,35 @@ class ast_node rule_type type() const; + template + void add(rule_type rule_type, std::vector&& vs) + { + using type = std::remove_reference_t; + using vtype = std::vector; + + auto& data = sub_items_[rule_type]; + + if (!std::holds_alternative(data)) { + data = vs; + } else { + auto& vdata = std::get(data); + vdata.insert(vdata.end(), vs.begin(), vs.end()); + } + } + template void add(rule_type rule_type, T&& v) { + using type = std::remove_reference_t; + using vtype = std::vector; + + auto& data = sub_items_[rule_type]; + + if (!std::holds_alternative(data)) { + data = vtype{}; + } + + std::get(data).emplace_back(std::move(v)); } template @@ -89,10 +115,23 @@ class ast_node return std::get(sub_items_[rule_type]); } + template + auto& get_items(rule_type rule_type) const + { + using type = std::remove_reference_t; + using vtype = std::vector; + + return std::get(sub_items_.at(rule_type)); + } + template auto& get_single(rule_type rule_type) { return get_items(rule_type).front(); } + template + auto& get_single(rule_type rule_type) const + { return get_items(rule_type).front(); } + auto& get_tokens(rule_type rule_type) { return get_items(rule_type); } diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index 1c42f0313..55f43e562 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include @@ -15,10 +17,12 @@ struct parser_info class parser { public: - parser(const parser_info& pi); + parser(const parser_info& pi = {}); virtual ~parser(); - std::size_t parse(const file& file); + const cms::gherkin_document& parse(const file& file); + + const cms::gherkin_document& get_result() const; private: parser_info pi_; diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index 47bdddd0c..82ce40e81 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -16,6 +16,7 @@ namespace gherkin { struct token { + bool eof = false; gherkin::line line; rule_type matched_type; std::string matched_keyword; diff --git a/cpp/include/gherkin/token_scanner.hpp b/cpp/include/gherkin/token_scanner.hpp index 8a81c2b7a..5c3e26592 100644 --- a/cpp/include/gherkin/token_scanner.hpp +++ b/cpp/include/gherkin/token_scanner.hpp @@ -11,7 +11,7 @@ namespace gherkin { struct next_line_result { - bool has_line = false; + bool eof = true; std::string text; }; @@ -25,6 +25,8 @@ class token_scanner virtual ~token_scanner(); void reset(); + void reset(const std::string& text); + void reset(const file& file); token read(); diff --git a/cpp/src/bin/gherkin/CMakeLists.txt b/cpp/src/bin/gherkin/CMakeLists.txt new file mode 100644 index 000000000..a20251a90 --- /dev/null +++ b/cpp/src/bin/gherkin/CMakeLists.txt @@ -0,0 +1,26 @@ +add_executable(gherkin-bin) + +target_sources( + gherkin-bin + PRIVATE + ${CMAKE_SOURCE_DIR}/src/bin/gherkin/gherkin.cpp +) + +target_include_directories( + gherkin-bin + PRIVATE + ${CMAKE_SOURCE_DIR}/ + ${CMAKE_SOURCE_DIR}/src/bin/gherkin +) + +target_link_libraries( + gherkin-bin + PUBLIC + gherkin-cpp +) + +set_target_properties( + gherkin-bin + PROPERTIES + OUTPUT_NAME gherkin +) diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 02b12289b..7cda3f606 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -11,5 +11,11 @@ struct options int main(int ac, char** av) { + gherkin::parser p; + + const auto& d = p.parse(gherkin::file{ av[1] }); + + std::cout << d.to_json() << std::endl; + return 0; } diff --git a/cpp/src/lib/gherkin/CMakeLists.txt b/cpp/src/lib/gherkin/CMakeLists.txt index e5c9489b2..437219e36 100644 --- a/cpp/src/lib/gherkin/CMakeLists.txt +++ b/cpp/src/lib/gherkin/CMakeLists.txt @@ -31,7 +31,7 @@ target_include_directories( target_link_libraries( gherkin-cpp - PRIVATE + PUBLIC cucumber::cucumber-messages ) diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 2ce86ee57..6358548dd 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -1,3 +1,5 @@ +#include + #include #include @@ -6,14 +8,19 @@ namespace gherkin { ast_builder::ast_builder() -{} +{ + reset(); +} ast_builder::~ast_builder() {} void ast_builder::reset() -{} +{ + stack_ = {}; + stack_.emplace(rule_type::none); +} void ast_builder::start_rule(rule_type rule_type) @@ -24,47 +31,64 @@ ast_builder::end_rule(rule_type rule_type) { auto n = pop_node(); auto rt = n.type(); - auto p = transform_node(n); - current_node().add(rt, std::move(p)); + transform_node(n, current_node()); } void -build(token& token) -{} +ast_builder::build(token& token) +{ + if (token.matched_type == rule_type::comment) { + cms::comment c{ + .location = get_location(token), + .text = token.matched_text + }; + + comments_.emplace_back(std::move(c)); + } else { + current_node().add(token.matched_type, std::move(token)); + } +} + +const cms::gherkin_document& +ast_builder::get_result() const +{ + return + current_node().get_single( + rule_type::gherkin_document + ); +}; std::string ast_builder::next_id() { return std::to_string(id_counter_++); } -ast_node -ast_builder::transform_node(ast_node& node) +void +ast_builder::transform_node(ast_node& from, ast_node& to) { - if (node.is(rule_type::step)) { - make_step(node); - } else if (node.is(rule_type::doc_string)) { - make_doc_string(node); - } else if (node.is(rule_type::data_table)) { - make_data_table(node); - } else if (node.is(rule_type::background)) { - make_background(node); - } else if (node.is(rule_type::scenario_definition)) { - make_scenario_definition(node); - } else if (node.is(rule_type::examples_definition)) { - make_examples_definition(node); - } else if (node.is(rule_type::examples_table)) { - make_examples_table(node); - } else if (node.is(rule_type::description)) { - make_description(node); - } else if (node.is(rule_type::feature)) { - make_feature(node); - } else if (node.is(rule_type::rule)) { - make_rule(node); - } else if (node.is(rule_type::gherkin_document)) { - make_gherkin_document(node); + if (from.is(rule_type::step)) { + to.add(from.type(), make_step(from)); + } else if (from.is(rule_type::doc_string)) { + to.add(from.type(), make_doc_string(from)); + } else if (from.is(rule_type::data_table)) { + to.add(from.type(), make_data_table(from)); + } else if (from.is(rule_type::background)) { + to.add(from.type(), make_background(from)); + } else if (from.is(rule_type::scenario_definition)) { + to.add(from.type(), make_scenario_definition(from)); + } else if (from.is(rule_type::examples_definition)) { + to.add(from.type(), make_examples_definition(from)); + } else if (from.is(rule_type::examples_table)) { + to.add(from.type(), make_examples_table(from)); + } else if (from.is(rule_type::description)) { + to.add(from.type(), make_description(from)); + } else if (from.is(rule_type::feature)) { + to.add(from.type(), make_feature(from)); + } else if (from.is(rule_type::rule)) { + to.add(from.type(), make_rule(from)); + } else if (from.is(rule_type::gherkin_document)) { + to.add(from.type(), make_gherkin_document(from)); } - - return ast_node(rule_type::none); } cms::step @@ -228,14 +252,13 @@ ast_builder::make_rule(ast_node& node) cms::gherkin_document ast_builder::make_gherkin_document(ast_node& node) { - auto& feature = node.get_single(rule_type::feature); - cms::gherkin_document gd{ .uri = uri_, - .feature = feature, .comments = comments_ }; + node.set_from_single(rule_type::feature, gd.feature); + return gd; } diff --git a/cpp/src/lib/gherkin/dialect.cpp b/cpp/src/lib/gherkin/dialect.cpp index 13ad487b1..eae058714 100644 --- a/cpp/src/lib/gherkin/dialect.cpp +++ b/cpp/src/lib/gherkin/dialect.cpp @@ -5,7 +5,7 @@ namespace gherkin { const keywords_map& keywords(const std::string_view& language) { - const keywords_maps kwms = { + static const keywords_maps kwms = { { "af", { diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index ea2fe9bdf..bca5f5642 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -20,25 +20,30 @@ line::line() line::line(const std::string& line_text, std::size_t line_number) : line_text_(line_text), line_number_(line_number), -trimmed_line_text_(lstrip(line_text_)), -indent_(line_text_.size() - trimmed_line_text_.size()) -{} +trimmed_line_text_(lstrip(line_text_)) +{ + indent_ = line_text_.size() - trimmed_line_text_.size(); +} std::string_view line::get_rest_trimmed(std::size_t length) const { auto pos = std::min(length, trimmed_line_text_.size()); + std::string_view sv = trimmed_line_text_; - return strip(trimmed_line_text_.substr(pos)); + return strip(sv.substr(pos)); } std::string_view line::get_line_text(std::size_t indent_to_remove) const { + std::string_view sv; + if (indent_to_remove == std::string::npos || indent_to_remove > indent_) { return trimmed_line_text_; } else { - return line_text_.substr(indent_to_remove); + sv = line_text_; + return sv.substr(indent_to_remove); } } diff --git a/cpp/src/lib/gherkin/parser.cpp b/cpp/src/lib/gherkin/parser.cpp index 5afc71bb6..71342e996 100644 --- a/cpp/src/lib/gherkin/parser.cpp +++ b/cpp/src/lib/gherkin/parser.cpp @@ -110,7 +110,10 @@ parser::parser(const parser_info& pi) : pi_{pi} {} -std::size_t +parser::~parser() +{} + +const cms::gherkin_document& parser::parse(const file& file) { builder_.reset(); @@ -142,9 +145,13 @@ parser::parse(const file& file) // TODO: thow coumpound error } - return 0; + return get_result(); } +const cms::gherkin_document& +parser::get_result() const +{ return builder_.get_result(); } + static void build(parser_context& context, token& token) diff --git a/cpp/src/lib/gherkin/token.cpp b/cpp/src/lib/gherkin/token.cpp index d17db45d5..8efd28137 100644 --- a/cpp/src/lib/gherkin/token.cpp +++ b/cpp/src/lib/gherkin/token.cpp @@ -4,7 +4,7 @@ namespace gherkin { bool token::is_eof() const -{ return line.is_empty(); } +{ return eof; } void token::detach() diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 2a3fd59da..08c7e9f90 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -151,7 +151,15 @@ token_matcher::match_title_line( bool token_matcher::match_e_o_f(token& token) -{ return true; } +{ + if (!token.eof) { + return false; + } + + set_token_matched(token, rule_type::e_o_f); + + return true; +} bool token_matcher::match_empty(token& token) diff --git a/cpp/src/lib/gherkin/token_scanner.cpp b/cpp/src/lib/gherkin/token_scanner.cpp index 04c0fbdfb..50d32a3ea 100644 --- a/cpp/src/lib/gherkin/token_scanner.cpp +++ b/cpp/src/lib/gherkin/token_scanner.cpp @@ -5,13 +5,14 @@ namespace gherkin { -token_scanner::token_scanner(const std::string& text) -: ip_{std::make_unique(text)} +token_scanner::token_scanner() {} +token_scanner::token_scanner(const std::string& text) +{ reset(text); } + token_scanner::token_scanner(const file& file) -: ip_{std::make_unique(file.path)} -{} +{ reset(file); } token_scanner::~token_scanner() {} @@ -24,6 +25,7 @@ token_scanner::read() line_++; return token{ + .eof = r.eof, .line = gherkin::line(r.text, line_), .location = line_ }; @@ -35,21 +37,35 @@ token_scanner::reset() line_ = 0; } +void +token_scanner::reset(const std::string& text) +{ + reset(); + ip_ = std::make_unique(text); +} + +void +token_scanner::reset(const file& file) +{ + reset(); + ip_ = std::make_unique(file.path); +} + + next_line_result token_scanner::next_line() { next_line_result r; - if (ip_) { + if (!ip_) { return r; } - input() >> r.text; - line_++; + std::getline(input(), r.text); - r.has_line = !r.text.empty(); + r.eof = input().eof(); - if (!r.has_line) { + if (r.eof) { ip_.reset(); } From 06bb4c032543f6df998d53d6628a9aaf50282891 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 11 May 2023 18:18:15 +0200 Subject: [PATCH 21/76] chore: cleaned node visitation --- cpp/include/gherkin/ast_builder.hpp | 5 +- cpp/include/gherkin/ast_node.hpp | 89 ++++--- cpp/src/lib/gherkin/ast_builder.cpp | 348 ++++++++++++++++++---------- 3 files changed, 284 insertions(+), 158 deletions(-) diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 588616d1b..1f84dae6b 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -55,9 +55,9 @@ class ast_builder std::size_t column = 0 ) const; - table_rows get_table_rows(ast_node& node); + table_rows get_table_rows(const ast_node& node); table_cells get_table_cells(const token& token); - tags get_tags(ast_node& node); + tags get_tags(const ast_node& node); ast_node pop_node(); ast_node& current_node(); @@ -67,6 +67,7 @@ class ast_builder ast_node_stack stack_; std::string uri_; comments comments_; + cms::gherkin_document doc_; }; using ast_builder_ptr = std::unique_ptr; diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 963588cb9..51f0848c5 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include @@ -106,40 +108,8 @@ class ast_node std::get(data).emplace_back(std::move(v)); } - template - auto& get_items(rule_type rule_type) - { - using type = std::remove_reference_t; - using vtype = std::vector; - - return std::get(sub_items_[rule_type]); - } - - template - auto& get_items(rule_type rule_type) const - { - using type = std::remove_reference_t; - using vtype = std::vector; - - return std::get(sub_items_.at(rule_type)); - } - - template - auto& get_single(rule_type rule_type) - { return get_items(rule_type).front(); } - - template - auto& get_single(rule_type rule_type) const - { return get_items(rule_type).front(); } - - auto& get_tokens(rule_type rule_type) - { return get_items(rule_type); } - - auto& get_token(rule_type rule_type) - { return get_single(rule_type); } - template - void visit_items(rule_type rule_type, Callable cb) + void visit_items(rule_type rule_type, Callable cb) const { using type = std::remove_reference_t; using vtype = std::vector; @@ -158,7 +128,7 @@ class ast_node } template - void visit_item(rule_type rule_type, Callable cb) + void visit_item(rule_type rule_type, Callable cb) const { visit_items( rule_type, @@ -170,12 +140,59 @@ class ast_node ); } + template + void visit_tokens(rule_type rule_type, Callable cb) const + { visit_items(rule_type, cb); } + + template + void visit_token(rule_type rule_type, Callable cb) const + { visit_item(rule_type, cb); } + + template + auto get_items(rule_type rule_type) const + { + using type = std::remove_reference_t; + using vtype = std::vector; + using ret_type = const vtype*; + + ret_type r = nullptr; + + visit_items( + rule_type, + [&r](auto& items) { r = std::addressof(items); } + ); + + return r; + } + + template + auto get_single(rule_type rule_type) const + { + using type = std::remove_reference_t; + using ret_type = const type*; + + ret_type r = nullptr; + + visit_item( + rule_type, + [&r](auto& item) { r = std::addressof(item); } + ); + + return r; + } + + auto get_tokens(rule_type rule_type) const + { return get_items(rule_type); } + + auto get_token(rule_type rule_type) const + { return get_single(rule_type); } + template - void set_from_single(rule_type rule_type, T&& v) + void set(rule_type rule_type, T& v) const { visit_item(rule_type, [&](auto& item) { v = item; } ); } template - void set_from_items(rule_type rule_type, std::vector& vs) + void set(rule_type rule_type, std::vector& vs) const { visit_items( rule_type, diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 6358548dd..03c27e072 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -53,10 +53,11 @@ ast_builder::build(token& token) const cms::gherkin_document& ast_builder::get_result() const { - return - current_node().get_single( - rule_type::gherkin_document - ); + auto dp = current_node().get_single( + rule_type::gherkin_document + ); + + return dp ? *dp : doc_; }; std::string @@ -94,41 +95,52 @@ ast_builder::transform_node(ast_node& from, ast_node& to) cms::step ast_builder::make_step(ast_node& node) { - auto& step_line = node.get_token(rule_type::step_line); - - cms::step s{ - .location = get_location(step_line), - .keyword = step_line.matched_keyword, - .keyword_type = step_line.matched_keyword_type, - .text = step_line.matched_text, - .id = next_id() - }; + cms::step m; + + node.visit_token( + rule_type::step_line, + [&](auto& step_line) { + m.location = get_location(step_line); + m.keyword = step_line.matched_keyword; + m.keyword_type = step_line.matched_keyword_type; + m.text = step_line.matched_text; + m.id = next_id(); + } + ); - node.set_from_single(rule_type::doc_string, s.doc_string); - node.set_from_single(rule_type::data_table, s.data_table); + node.set(rule_type::doc_string, m.doc_string); + node.set(rule_type::data_table, m.data_table); - return s; + return m; } cms::doc_string ast_builder::make_doc_string(ast_node& node) { - auto& separator_token = node.get_token(rule_type::doc_string_separator); - - string_views svs; - - for (const auto& t : node.get_tokens(rule_type::other)) { - svs.push_back(t.matched_text); - } + cms::doc_string m; + + node.visit_token( + rule_type::doc_string_separator, + [&](auto& separator_token) { + string_views svs; + + node.visit_tokens( + rule_type::other, + [&](auto& line_tokens) { + for (const auto& t : line_tokens) { + svs.push_back(t.matched_text); + } + } + ); - cms::doc_string ds{ - .location = get_location(separator_token), - .media_type = separator_token.matched_text, - .content = join("\n", svs), - .delimiter = separator_token.matched_keyword - }; + m.location = get_location(separator_token); + m.media_type = separator_token.matched_text; + m.content = join("\n", svs); + m.delimiter = separator_token.matched_keyword; + } + ); - return ds; + return m; } cms::data_table @@ -136,70 +148,106 @@ ast_builder::make_data_table(ast_node& node) { auto rows = get_table_rows(node); - cms::data_table dt{ - .location = rows.front().location, + cms::data_table m{ .rows = std::move(rows) }; - return dt; + if (!m.rows.empty()) { + m.location = rows.front().location; + } + + return m; } cms::background ast_builder::make_background(ast_node& node) { - auto& background_line = node.get_token(rule_type::background_line); - - cms::background b{ - .location = get_location(background_line), - .keyword = background_line.matched_keyword, - .name = background_line.matched_text, - .id = next_id() - }; + cms::background m; + + node.visit_token( + rule_type::background_line, + [&](auto& background_line) { + m.location = get_location(background_line); + m.keyword = background_line.matched_keyword; + m.name = background_line.matched_text; + m.id = next_id(); + } + ); - node.set_from_single(rule_type::description, b.description); - node.set_from_items(rule_type::step, b.steps); + node.set(rule_type::description, m.description); + node.set(rule_type::step, m.steps); - return b; + return m; } cms::scenario ast_builder::make_scenario_definition(ast_node& node) { - auto& scenario_node = node.get_single(rule_type::scenario); - auto& scenario_line = scenario_node.get_token(rule_type::scenario_line); - - cms::scenario s{ - .location = get_location(scenario_line), - .tags = get_tags(node), - .keyword = scenario_line.matched_keyword, - .name = scenario_line.matched_text, - .id = next_id() - }; + cms::scenario m; - scenario_node.set_from_single(rule_type::description, s.description); - scenario_node.set_from_items(rule_type::step, s.steps); - scenario_node.set_from_items(rule_type::examples_definition, s.examples); + node.visit_item( + rule_type::scenario, + [&](auto& scenario_node) { + scenario_node.visit_token( + rule_type::scenario_line, + [&](auto& scenario_line) { + m.location = get_location(scenario_line); + m.tags = get_tags(node); + m.keyword = scenario_line.matched_keyword; + m.name = scenario_line.matched_text; + m.id = next_id(); + } + ); - return s; + scenario_node.set(rule_type::description, m.description); + scenario_node.set(rule_type::step, m.steps); + scenario_node.set(rule_type::examples_definition, m.examples); + } + ); + + return m; } cms::examples ast_builder::make_examples_definition(ast_node& node) { - auto& examples_node = node.get_single(rule_type::examples); - auto& examples_line = examples_node.get_token(rule_type::examples_line); - - cms::examples es{ - .location = get_location(examples_line), - .tags = get_tags(node), - .keyword = examples_line.matched_keyword, - .name = examples_line.matched_text, - .id = next_id() - }; + cms::examples m; - examples_node.set_from_single(rule_type::description, es.description); + node.visit_item( + rule_type::examples, + [&](auto& examples_node) { + examples_node.visit_token( + rule_type::examples_line, + [&](auto& examples_line) { + m.location = get_location(examples_line); + m.tags = get_tags(node); + m.keyword = examples_line.matched_keyword; + m.name = examples_line.matched_text; + m.id = next_id(); + } + ); + + examples_node.set(rule_type::description, m.description); + + examples_node.template visit_items( + rule_type::examples_table, + [&](auto& rows) { + if (rows.size() > 0) { + m.table_header = rows.front(); + } + + if (rows.size() > 1) { + std::copy( + rows.begin() + 1, rows.end(), + std::back_inserter(m.table_body) + ); + } + } + ); + } + ); - return es; + return m; } table_rows @@ -215,38 +263,93 @@ ast_builder::make_description(ast_node& node) cms::feature ast_builder::make_feature(ast_node& node) { - auto& header = node.get_single(rule_type::feature_header); - auto& feature_line = header.get_token(rule_type::feature_line); - - cms::feature f{ - .location = get_location(feature_line), - .tags = get_tags(header), - .keyword = feature_line.matched_keyword, - .name = feature_line.matched_text - }; + cms::feature m; + + node.visit_item( + rule_type::feature_header, + [&](auto& header) { + header.visit_token( + rule_type::feature_line, + [&](auto& feature_line) { + m.location = get_location(feature_line); + m.tags = get_tags(header); + m.keyword = feature_line.matched_keyword; + m.name = feature_line.matched_text; + } + ); + + header.set(rule_type::description, m.description); + } + ); + + node.visit_item( + rule_type::background, + [&](auto& item) { + m.children.emplace_back(cms::feature_child{.background = item}); + } + ); + + node.visit_items( + rule_type::scenario_definition, + [&](auto& items) { + for (auto& item : items) { + m.children.emplace_back(cms::feature_child{.scenario = item}); + } + } + ); - header.set_from_single(rule_type::description, f.description); + node.visit_items( + rule_type::rule, + [&](auto& items) { + for (auto& item : items) { + m.children.emplace_back(cms::feature_child{.rule = item}); + } + } + ); - return f; + return m; } cms::rule ast_builder::make_rule(ast_node& node) { - auto& header = node.get_single(rule_type::rule_header); - auto& rule_line = header.get_token(rule_type::rule_line); - - cms::rule r{ - .location = get_location(rule_line), - .tags = get_tags(header), - .keyword = rule_line.matched_keyword, - .name = rule_line.matched_text, - .id = next_id() - }; + cms::rule m; - header.set_from_single(rule_type::description, r.description); + node.visit_item( + rule_type::rule_header, + [&](auto& header) { + header.visit_token( + rule_type::rule_line, + [&](auto& rule_line) { + m.location = get_location(rule_line); + m.tags = get_tags(header); + m.keyword = rule_line.matched_keyword; + m.name = rule_line.matched_text; + m.id = next_id(); + } + ); + + header.set(rule_type::description, m.description); + } + ); - return r; + node.visit_item( + rule_type::background, + [&](auto& item) { + m.children.emplace_back(cms::rule_child{.background = item}); + } + ); + + node.visit_items( + rule_type::scenario_definition, + [&](auto& items) { + for (auto& item : items) { + m.children.emplace_back(cms::rule_child{.scenario = item}); + } + } + ); + + return m; } cms::gherkin_document @@ -257,7 +360,7 @@ ast_builder::make_gherkin_document(ast_node& node) .comments = comments_ }; - node.set_from_single(rule_type::feature, gd.feature); + node.set(rule_type::feature, gd.feature); return gd; } @@ -272,19 +375,23 @@ ast_builder::get_location( } table_rows -ast_builder::get_table_rows(ast_node& node) +ast_builder::get_table_rows(const ast_node& node) { table_rows rows; - for (const auto& t : node.get_tokens(rule_type::table_row)) { - cms::table_row row{ - .location = get_location(t), - .cells = get_table_cells(t), - .id = next_id() - }; + node.visit_tokens( + rule_type::table_row, + [&](auto& tokens) { + for (const auto& t : tokens) { + rows.emplace_back(cms::table_row{ + .location = get_location(t), + .cells = get_table_cells(t), + .id = next_id() + }); - rows.emplace_back(std::move(row)); - } + } + } + ); return rows; } @@ -295,38 +402,39 @@ ast_builder::get_table_cells(const token& token) table_cells cells; for (const auto& i : token.matched_items) { - cms::table_cell cell{ + cells.emplace_back(cms::table_cell{ .location = get_location(token, i.column), .value = i.text - }; - - cells.emplace_back(std::move(cell)); + }); } return cells; } tags -ast_builder::get_tags(ast_node& node) +ast_builder::get_tags(const ast_node& node) { tags ts; node.visit_item( rule_type::tags, [&](auto& tags_node) { - auto& tokens = tags_node.get_tokens(rule_type::tag_line); - - for (auto& token : tokens) { - for (auto& tag_item : token.matched_items) { - cms::tag t{ - .location = get_location(token, tag_item.column), - .name = tag_item.text, - .id = next_id() - }; - - ts.emplace_back(std::move(t)); + tags_node.visit_tokens( + rule_type::tag_line, + [&](auto& tokens) { + for (auto& token : tokens) { + for (auto& tag_item : token.matched_items) { + cms::tag t{ + .location = get_location(token, tag_item.column), + .name = tag_item.text, + .id = next_id() + }; + + ts.emplace_back(std::move(t)); + } + } } - } + ); } ); From 4ba35279113c085c15c6f1be400047ac8543250f Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 12 May 2023 19:49:03 +0200 Subject: [PATCH 22/76] chore: cleaned optional implementation --- cpp/include/gherkin/ast_node.hpp | 97 ++++++++++++++++++----------- cpp/include/gherkin/type_traits.hpp | 38 +++++++++++ cpp/src/lib/gherkin/ast_builder.cpp | 14 ++--- cpp/src/lib/gherkin/parser.cpp | 2 +- 4 files changed, 107 insertions(+), 44 deletions(-) create mode 100644 cpp/include/gherkin/type_traits.hpp diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 51f0848c5..e11d44565 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -29,6 +29,7 @@ #include #include +#include namespace gherkin { @@ -61,6 +62,32 @@ using ast_node_data = std::variant< using ast_node_items = std::unordered_map; +template +auto& +init_and_get(V& v) +{ + if (!std::holds_alternative(v)) { + v = T{}; + } + + return std::get(v); +} + +template +auto& +get_vdata(rule_type rule_type, ast_node_items& items) +{ + auto& data = items[rule_type]; + + if constexpr (is_container_v) { + return init_and_get(data); + } else { + using vtype = std::vector; + + return init_and_get(data); + } +} + class ast_node { public: @@ -78,36 +105,19 @@ class ast_node rule_type type() const; template - void add(rule_type rule_type, std::vector&& vs) + void add(rule_type rule_type, T&& v) { - using type = std::remove_reference_t; - using vtype = std::vector; + using type = std::remove_cvref_t; - auto& data = sub_items_[rule_type]; + auto& vdata = get_vdata(rule_type, sub_items_); - if (!std::holds_alternative(data)) { - data = vs; + if constexpr (is_container_v) { + vdata.insert(vdata.end(), v.begin(), v.end()); } else { - auto& vdata = std::get(data); - vdata.insert(vdata.end(), vs.begin(), vs.end()); + vdata.emplace_back(std::move(v)); } } - template - void add(rule_type rule_type, T&& v) - { - using type = std::remove_reference_t; - using vtype = std::vector; - - auto& data = sub_items_[rule_type]; - - if (!std::holds_alternative(data)) { - data = vtype{}; - } - - std::get(data).emplace_back(std::move(v)); - } - template void visit_items(rule_type rule_type, Callable cb) const { @@ -187,22 +197,37 @@ class ast_node auto get_token(rule_type rule_type) const { return get_single(rule_type); } - template - void set(rule_type rule_type, T& v) const - { visit_item(rule_type, [&](auto& item) { v = item; } ); } + template + void set_value(rule_type rule_type, T& v) const + { + + } + + template + void set_value(rule_type rule_type, Callable&& cb) const + { + + if constexpr (is_container_v) { + using value_type = typename T::value_type; + + visit_items(rule_type, cb); + } else { + visit_item(rule_type, cb); + } + } template - void set(rule_type rule_type, std::vector& vs) const + void set(rule_type rule_type, T& v) const { - visit_items( - rule_type, - [&](auto& items) { - std::copy( - items.begin(), items.end(), - std::back_inserter(vs) - ); - } - ); + auto cb = [&](auto& val) { v = val; }; + + if constexpr (is_container_v) { + using value_type = typename T::value_type; + + set_value(rule_type, cb); + } else { + set_value(rule_type, cb); + } } private: diff --git a/cpp/include/gherkin/type_traits.hpp b/cpp/include/gherkin/type_traits.hpp new file mode 100644 index 000000000..34bf5667d --- /dev/null +++ b/cpp/include/gherkin/type_traits.hpp @@ -0,0 +1,38 @@ +#include + +namespace gherkin { + +namespace detail { + +template < + template class Container, + template class Other, + typename T +> +std::is_same, Other> +test_is_container(Other*); + +template < + template class Container, + typename T +> +std::false_type test_is_container(T*); + +} // namespace detail + +template < + template class C, + typename T +> +using is_container = decltype( + detail::test_is_container(static_cast(nullptr)) +); + +template < + template class C, + typename T +> +inline +constexpr bool is_container_v = is_container::value; + +} diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 03c27e072..f3e8bc961 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -95,7 +95,7 @@ ast_builder::transform_node(ast_node& from, ast_node& to) cms::step ast_builder::make_step(ast_node& node) { - cms::step m; + cms::step m{}; node.visit_token( rule_type::step_line, @@ -117,7 +117,7 @@ ast_builder::make_step(ast_node& node) cms::doc_string ast_builder::make_doc_string(ast_node& node) { - cms::doc_string m; + cms::doc_string m{}; node.visit_token( rule_type::doc_string_separator, @@ -162,7 +162,7 @@ ast_builder::make_data_table(ast_node& node) cms::background ast_builder::make_background(ast_node& node) { - cms::background m; + cms::background m{}; node.visit_token( rule_type::background_line, @@ -183,7 +183,7 @@ ast_builder::make_background(ast_node& node) cms::scenario ast_builder::make_scenario_definition(ast_node& node) { - cms::scenario m; + cms::scenario m{}; node.visit_item( rule_type::scenario, @@ -211,7 +211,7 @@ ast_builder::make_scenario_definition(ast_node& node) cms::examples ast_builder::make_examples_definition(ast_node& node) { - cms::examples m; + cms::examples m{}; node.visit_item( rule_type::examples, @@ -263,7 +263,7 @@ ast_builder::make_description(ast_node& node) cms::feature ast_builder::make_feature(ast_node& node) { - cms::feature m; + cms::feature m{}; node.visit_item( rule_type::feature_header, @@ -313,7 +313,7 @@ ast_builder::make_feature(ast_node& node) cms::rule ast_builder::make_rule(ast_node& node) { - cms::rule m; + cms::rule m{}; node.visit_item( rule_type::rule_header, diff --git a/cpp/src/lib/gherkin/parser.cpp b/cpp/src/lib/gherkin/parser.cpp index 71342e996..23d008e3f 100644 --- a/cpp/src/lib/gherkin/parser.cpp +++ b/cpp/src/lib/gherkin/parser.cpp @@ -117,7 +117,7 @@ const cms::gherkin_document& parser::parse(const file& file) { builder_.reset(); - scanner_.reset(); + scanner_.reset(file); matcher_.reset(); parser_context context{ From 94dacede95c1083358b895f894fe5df35da71f69 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sun, 14 May 2023 19:52:48 +0200 Subject: [PATCH 23/76] chore: refactoring ast_node --- cpp/include/gherkin/ast_builder.hpp | 2 + cpp/include/gherkin/ast_node.hpp | 215 +++++---------- cpp/include/gherkin/utils.hpp | 16 ++ cpp/src/lib/gherkin/ast_builder.cpp | 405 ++++++++++++++-------------- 4 files changed, 277 insertions(+), 361 deletions(-) diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 1f84dae6b..c66156bbf 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -4,6 +4,8 @@ #include #include +#include + #include #include #include diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index e11d44565..f4f9363f4 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -1,31 +1,11 @@ #pragma once -#include +#include #include #include #include -#include -#include #include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include @@ -33,61 +13,6 @@ namespace gherkin { -class ast_node; - -using ast_nodes = std::vector; - -using ast_node_data = std::variant< - ast_nodes, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - std::vector, - strings, - tokens ->; - -using ast_node_items = std::unordered_map; - -template -auto& -init_and_get(V& v) -{ - if (!std::holds_alternative(v)) { - v = T{}; - } - - return std::get(v); -} - -template -auto& -get_vdata(rule_type rule_type, ast_node_items& items) -{ - auto& data = items[rule_type]; - - if constexpr (is_container_v) { - return init_and_get(data); - } else { - using vtype = std::vector; - - return init_and_get(data); - } -} - class ast_node { public: @@ -107,70 +32,38 @@ class ast_node template void add(rule_type rule_type, T&& v) { - using type = std::remove_cvref_t; + using value_type = std::remove_cvref_t; + using vector_type = std::vector; - auto& vdata = get_vdata(rule_type, sub_items_); + auto& a = sub_items_[rule_type]; - if constexpr (is_container_v) { - vdata.insert(vdata.end(), v.begin(), v.end()); - } else { - vdata.emplace_back(std::move(v)); + if (!a.has_value()) { + a = vector_type{}; } + + auto& vs = std::any_cast(a); + vs.emplace_back(std::move(v)); } - template - void visit_items(rule_type rule_type, Callable cb) const + template + auto get_items(rule_type rule_type) const { - using type = std::remove_reference_t; - using vtype = std::vector; + using value_type = std::remove_cvref_t; + using vector_type = std::vector; + using view_type = std::ranges::ref_view; + using ret_type = std::optional; auto it = sub_items_.find(rule_type); - if (it == sub_items_.end()) { - return; - } + ret_type r; - auto& items = std::get(it->second); + if (it != sub_items_.end()) { + auto& vs = std::any_cast(it->second); - if (!items.empty()) { - cb(items); - } - } - - template - void visit_item(rule_type rule_type, Callable cb) const - { - visit_items( - rule_type, - [&cb](auto& items) { - if (!items.empty()) { - cb(items.front()); - } + if (!vs.empty()) { + r = std::views::all(vs); } - ); - } - - template - void visit_tokens(rule_type rule_type, Callable cb) const - { visit_items(rule_type, cb); } - - template - void visit_token(rule_type rule_type, Callable cb) const - { visit_item(rule_type, cb); } - - template - auto get_items(rule_type rule_type) const - { - using type = std::remove_reference_t; - using vtype = std::vector; - using ret_type = const vtype*; - - ret_type r = nullptr; - - visit_items( - rule_type, - [&r](auto& items) { r = std::addressof(items); } - ); + } return r; } @@ -178,61 +71,73 @@ class ast_node template auto get_single(rule_type rule_type) const { - using type = std::remove_reference_t; - using ret_type = const type*; + using value_type = std::remove_cvref_t; + using ref_type = std::reference_wrapper; + using ret_type = std::optional; - ret_type r = nullptr; + auto opt_items = get_items(rule_type); + ret_type r; - visit_item( - rule_type, - [&r](auto& item) { r = std::addressof(item); } - ); + if (opt_items) { + auto& items = *opt_items; + r = std::cref(items[0]); + } return r; } auto get_tokens(rule_type rule_type) const - { return get_items(rule_type); } + { return *get_items(rule_type); } - auto get_token(rule_type rule_type) const - { return get_single(rule_type); } + const auto& get_token(rule_type rule_type) const + { return get_single(rule_type)->get(); } - template - void set_value(rule_type rule_type, T& v) const + template + void set_value(rule_type rule_type, V& v) const { + using type = std::remove_cvref_t; - } + if constexpr (is_container_v) { + using value_type = typename type::value_type; + using vector_type = std::vector; - template - void set_value(rule_type rule_type, Callable&& cb) const - { + auto opt_items = get_items(rule_type); - if constexpr (is_container_v) { - using value_type = typename T::value_type; + if (opt_items) { + auto& items = *opt_items; - visit_items(rule_type, cb); + for (const auto& i : items) { + v.emplace_back(i); + } + } } else { - visit_item(rule_type, cb); + auto item = get_single(rule_type); + + if (item) { + v = item->get(); + } } } template void set(rule_type rule_type, T& v) const { - auto cb = [&](auto& val) { v = val; }; + using type = std::remove_cvref_t; - if constexpr (is_container_v) { - using value_type = typename T::value_type; + if constexpr (is_container_v) { + using value_type = typename type::value_type; - set_value(rule_type, cb); + set_value(rule_type, v); } else { - set_value(rule_type, cb); + set_value(rule_type, v); } } private: + using sub_items = std::unordered_map; + rule_type rule_type_; - ast_node_items sub_items_; + sub_items sub_items_; }; } diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index b58057590..1bd35cf84 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -20,4 +20,20 @@ replace(std::string& s, std::string_view what, std::string_view with); std::string replace(const std::string& s, std::string_view what, std::string_view with); +template +struct reverse +{ + reverse(C& c) + : c_(c) + {} + + auto begin() + { return c_.rbegin(); } + + auto end() + { return c_.rend(); } + + C& c_; +}; + } diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index f3e8bc961..a166851b6 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -4,6 +4,7 @@ #include #include +#include namespace gherkin { @@ -57,7 +58,7 @@ ast_builder::get_result() const rule_type::gherkin_document ); - return dp ? *dp : doc_; + return dp ? (*dp).get() : doc_; }; std::string @@ -95,18 +96,15 @@ ast_builder::transform_node(ast_node& from, ast_node& to) cms::step ast_builder::make_step(ast_node& node) { - cms::step m{}; - - node.visit_token( - rule_type::step_line, - [&](auto& step_line) { - m.location = get_location(step_line); - m.keyword = step_line.matched_keyword; - m.keyword_type = step_line.matched_keyword_type; - m.text = step_line.matched_text; - m.id = next_id(); - } - ); + auto& step_line = node.get_token(rule_type::step_line); + + cms::step m{ + .location = get_location(step_line), + .keyword = step_line.matched_keyword, + .keyword_type = step_line.matched_keyword_type, + .text = step_line.matched_text, + .id = next_id() + }; node.set(rule_type::doc_string, m.doc_string); node.set(rule_type::data_table, m.data_table); @@ -117,28 +115,29 @@ ast_builder::make_step(ast_node& node) cms::doc_string ast_builder::make_doc_string(ast_node& node) { - cms::doc_string m{}; - - node.visit_token( - rule_type::doc_string_separator, - [&](auto& separator_token) { - string_views svs; - - node.visit_tokens( - rule_type::other, - [&](auto& line_tokens) { - for (const auto& t : line_tokens) { - svs.push_back(t.matched_text); - } - } - ); - - m.location = get_location(separator_token); - m.media_type = separator_token.matched_text; - m.content = join("\n", svs); - m.delimiter = separator_token.matched_keyword; - } - ); + auto& separator_token = + node.get_tokens(rule_type::doc_string_separator)[0]; + + string_views svs; + + auto toks = + node.get_tokens(rule_type::other) + | std::views::transform([](const auto& t) { + return std::string_view(t.matched_text); + }); + + for (const auto& t : toks) { + svs.emplace_back(t); + } + + auto content = join("\n", svs); + + cms::doc_string m{ + .location = get_location(separator_token), + .media_type = separator_token.matched_text, + .content = content, + .delimiter = separator_token.matched_keyword + }; return m; } @@ -162,17 +161,14 @@ ast_builder::make_data_table(ast_node& node) cms::background ast_builder::make_background(ast_node& node) { - cms::background m{}; - - node.visit_token( - rule_type::background_line, - [&](auto& background_line) { - m.location = get_location(background_line); - m.keyword = background_line.matched_keyword; - m.name = background_line.matched_text; - m.id = next_id(); - } - ); + auto& background_line = node.get_token(rule_type::background_line); + + cms::background m{ + .location = get_location(background_line), + .keyword = background_line.matched_keyword, + .name = background_line.matched_text, + .id = next_id() + }; node.set(rule_type::description, m.description); node.set(rule_type::step, m.steps); @@ -183,27 +179,21 @@ ast_builder::make_background(ast_node& node) cms::scenario ast_builder::make_scenario_definition(ast_node& node) { - cms::scenario m{}; - - node.visit_item( - rule_type::scenario, - [&](auto& scenario_node) { - scenario_node.visit_token( - rule_type::scenario_line, - [&](auto& scenario_line) { - m.location = get_location(scenario_line); - m.tags = get_tags(node); - m.keyword = scenario_line.matched_keyword; - m.name = scenario_line.matched_text; - m.id = next_id(); - } - ); - - scenario_node.set(rule_type::description, m.description); - scenario_node.set(rule_type::step, m.steps); - scenario_node.set(rule_type::examples_definition, m.examples); - } - ); + auto opt = node.get_single(rule_type::scenario); + auto& scenario_node = opt->get(); + auto& scenario_line = scenario_node.get_token(rule_type::scenario_line); + + cms::scenario m{ + .location = get_location(scenario_line), + .tags = get_tags(node), + .keyword = scenario_line.matched_keyword, + .name = scenario_line.matched_text, + .id = next_id() + }; + + scenario_node.set(rule_type::description, m.description); + scenario_node.set(rule_type::step, m.steps); + scenario_node.set(rule_type::examples_definition, m.examples); return m; } @@ -211,41 +201,33 @@ ast_builder::make_scenario_definition(ast_node& node) cms::examples ast_builder::make_examples_definition(ast_node& node) { - cms::examples m{}; - - node.visit_item( - rule_type::examples, - [&](auto& examples_node) { - examples_node.visit_token( - rule_type::examples_line, - [&](auto& examples_line) { - m.location = get_location(examples_line); - m.tags = get_tags(node); - m.keyword = examples_line.matched_keyword; - m.name = examples_line.matched_text; - m.id = next_id(); - } - ); - - examples_node.set(rule_type::description, m.description); - - examples_node.template visit_items( - rule_type::examples_table, - [&](auto& rows) { - if (rows.size() > 0) { - m.table_header = rows.front(); - } - - if (rows.size() > 1) { - std::copy( - rows.begin() + 1, rows.end(), - std::back_inserter(m.table_body) - ); - } - } - ); + auto opt = node.get_single(rule_type::examples); + auto& examples_node = opt->get(); + auto& examples_line = examples_node.get_token(rule_type::examples_line); + + cms::examples m{ + .location = get_location(examples_line), + .tags = get_tags(node), + .keyword = examples_line.matched_keyword, + .name = examples_line.matched_text, + .id = next_id() + }; + + auto opt_table = + examples_node.get_single(rule_type::examples_table); + + if (opt_table) { + auto rows = get_table_rows(opt_table->get()); + + m.table_header = rows.front(); + + if (rows.size() > 1) { + std::copy( + rows.begin() + 1, rows.end(), + std::back_inserter(m.table_body) + ); } - ); + } return m; } @@ -257,55 +239,73 @@ ast_builder::make_examples_table(ast_node& node) std::string ast_builder::make_description(ast_node& node) { - return "FIXME"; + std::regex only_spaces("\\s*"); + + auto no_spaces = [&](const auto& t) { + return !full_match(t.matched_text, only_spaces); + }; + + string_views svs; + + auto toks = + node.get_tokens(rule_type::other) + | std::views::reverse + | std::views::filter(no_spaces) + | std::views::transform([](const auto& t) { + return std::string_view(t.matched_text); + }) + ; + + for (const auto& t : toks) { + svs.emplace_back(t); + } + + return join("\n", svs); } cms::feature ast_builder::make_feature(ast_node& node) { - cms::feature m{}; - - node.visit_item( - rule_type::feature_header, - [&](auto& header) { - header.visit_token( - rule_type::feature_line, - [&](auto& feature_line) { - m.location = get_location(feature_line); - m.tags = get_tags(header); - m.keyword = feature_line.matched_keyword; - m.name = feature_line.matched_text; - } - ); - - header.set(rule_type::description, m.description); - } - ); + auto opt_header = node.get_single(rule_type::feature_header); + auto& header = opt_header->get(); - node.visit_item( - rule_type::background, - [&](auto& item) { - m.children.emplace_back(cms::feature_child{.background = item}); - } - ); + auto opt_feature_line = node.get_single(rule_type::feature_line); + auto& feature_line = opt_feature_line->get(); - node.visit_items( - rule_type::scenario_definition, - [&](auto& items) { - for (auto& item : items) { - m.children.emplace_back(cms::feature_child{.scenario = item}); - } + cms::feature m{ + .location = get_location(feature_line), + .tags = get_tags(header), + .keyword = feature_line.matched_keyword, + .name = feature_line.matched_text + }; + + header.set(rule_type::description, m.description); + + auto opt_background = + node.get_single(rule_type::background); + + if (opt_background) { + m.children.emplace_back(cms::feature_child{ + .background = opt_background->get() + }); + } + + auto opt_scenarios = + node.get_items(rule_type::scenario_definition); + + if (opt_scenarios) { + for (auto& scenario : *opt_scenarios) { + m.children.emplace_back(cms::feature_child{.scenario = scenario}); } - ); + } - node.visit_items( - rule_type::rule, - [&](auto& items) { - for (auto& item : items) { - m.children.emplace_back(cms::feature_child{.rule = item}); - } + auto opt_rules = node.get_items(rule_type::rule); + + if (opt_rules) { + for (auto& rule : *opt_rules) { + m.children.emplace_back(cms::feature_child{.rule = rule}); } - ); + } return m; } @@ -313,41 +313,39 @@ ast_builder::make_feature(ast_node& node) cms::rule ast_builder::make_rule(ast_node& node) { - cms::rule m{}; - - node.visit_item( - rule_type::rule_header, - [&](auto& header) { - header.visit_token( - rule_type::rule_line, - [&](auto& rule_line) { - m.location = get_location(rule_line); - m.tags = get_tags(header); - m.keyword = rule_line.matched_keyword; - m.name = rule_line.matched_text; - m.id = next_id(); - } - ); - - header.set(rule_type::description, m.description); - } - ); + auto opt_header = node.get_single(rule_type::rule_header); + auto& header = opt_header->get(); + + auto opt_rule_line = node.get_single(rule_type::rule_line); + auto& rule_line = opt_rule_line->get(); + + cms::rule m{ + .location = get_location(rule_line), + .tags = get_tags(header), + .keyword = rule_line.matched_keyword, + .name = rule_line.matched_text, + .id = next_id() + }; - node.visit_item( - rule_type::background, - [&](auto& item) { - m.children.emplace_back(cms::rule_child{.background = item}); - } - ); + header.set(rule_type::description, m.description); - node.visit_items( - rule_type::scenario_definition, - [&](auto& items) { - for (auto& item : items) { - m.children.emplace_back(cms::rule_child{.scenario = item}); - } + auto opt_background = + node.get_single(rule_type::background); + + if (opt_background) { + m.children.emplace_back(cms::rule_child{ + .background = opt_background->get() + }); + } + + auto opt_scenarios = + node.get_items(rule_type::scenario_definition); + + if (opt_scenarios) { + for (auto& scenario : *opt_scenarios) { + m.children.emplace_back(cms::rule_child{.scenario = scenario}); } - ); + } return m; } @@ -371,7 +369,12 @@ ast_builder::get_location( std::size_t column ) const { - return {}; + cms::location m{ + .line = token.location.line, + .column = column == 0 ? token.location.column : column + }; + + return m; } table_rows @@ -379,19 +382,13 @@ ast_builder::get_table_rows(const ast_node& node) { table_rows rows; - node.visit_tokens( - rule_type::table_row, - [&](auto& tokens) { - for (const auto& t : tokens) { - rows.emplace_back(cms::table_row{ - .location = get_location(t), - .cells = get_table_cells(t), - .id = next_id() - }); - - } - } - ); + for (const auto& token : node.get_tokens(rule_type::table_row)) { + rows.emplace_back(cms::table_row{ + .location = get_location(token), + .cells = get_table_cells(token), + .id = next_id() + }); + } return rows; } @@ -416,27 +413,23 @@ ast_builder::get_tags(const ast_node& node) { tags ts; - node.visit_item( - rule_type::tags, - [&](auto& tags_node) { - tags_node.visit_tokens( - rule_type::tag_line, - [&](auto& tokens) { - for (auto& token : tokens) { - for (auto& tag_item : token.matched_items) { - cms::tag t{ - .location = get_location(token, tag_item.column), - .name = tag_item.text, - .id = next_id() - }; - - ts.emplace_back(std::move(t)); - } - } - } - ); + auto opt_tags = node.get_single(rule_type::tags); + + if (opt_tags) { + auto& tags_node = opt_tags->get(); + + for (const auto& token : tags_node.get_tokens(rule_type::tag_line)) { + for (auto& tag_item : token.matched_items) { + cms::tag t{ + .location = get_location(token, tag_item.column), + .name = tag_item.text, + .id = next_id() + }; + + ts.emplace_back(std::move(t)); + } } - ); + } return ts; } From dfb58f88af3529166846f4fb996f739dd2a3cadb Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 15 May 2023 10:31:11 +0200 Subject: [PATCH 24/76] chore: properly reset scanner --- cpp/gherkin-cpp.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index 72d4b11ae..7160a4d21 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -171,7 +171,7 @@ const cms::gherkin_document& parser::parse(const file& file) { builder_.reset(); - scanner_.reset(); + scanner_.reset(file); matcher_.reset(); parser_context context{ From 32db8e8cea2ac21d052648604f111e602dd23003 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 15 May 2023 16:13:26 +0200 Subject: [PATCH 25/76] fixed parser workflow --- cpp/Makefile | 4 + cpp/cmake/toolchains/ext.cmake | 8 +- cpp/gherkin-cpp-rule-type.razor | 15 ++++ cpp/include/gherkin/ast_builder.hpp | 2 +- cpp/include/gherkin/ast_node.hpp | 110 +++++++++++++++++----------- cpp/include/gherkin/rule_type.hpp | 15 ++++ cpp/src/lib/gherkin/ast_builder.cpp | 87 ++++++++++------------ cpp/src/lib/gherkin/ast_node.cpp | 14 ++++ cpp/src/lib/gherkin/rule_type.cpp | 49 +++++++++++++ 9 files changed, 213 insertions(+), 91 deletions(-) create mode 100644 cpp/src/lib/gherkin/rule_type.cpp diff --git a/cpp/Makefile b/cpp/Makefile index 6922f6797..b84d56ed8 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -80,11 +80,15 @@ clean-configure: reconfigure: clean-configure .configured +rebuild: reconfigure .built + include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) + rm -f .configured src/lib/gherkin/parser.cpp: gherkin-cpp.razor ../gherkin.berp $(berp-generate-parser) + rm -f .configured src/lib/gherkin/dialect.cpp: $(GHERKIN_LANGUAGES_JSON) jq -f gherkin-dialect.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ diff --git a/cpp/cmake/toolchains/ext.cmake b/cpp/cmake/toolchains/ext.cmake index 62c07e58e..d7a716f42 100644 --- a/cpp/cmake/toolchains/ext.cmake +++ b/cpp/cmake/toolchains/ext.cmake @@ -1,7 +1,6 @@ # # CMake toolchain to be used when building external libraries # - set(CMAKE_FIND_ROOT_PATH "${CMAKE_INSTALL_PREFIX}") set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) @@ -19,6 +18,13 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +find_program(CCACHE ccache) + +if(CCACHE) + set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE}") + set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE}") +endif() + if(DEFINED ENV{GHERKIN_DEBUG}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fsanitize=address") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fsanitize=address") diff --git a/cpp/gherkin-cpp-rule-type.razor b/cpp/gherkin-cpp-rule-type.razor index ba2ddb820..648631543 100644 --- a/cpp/gherkin-cpp-rule-type.razor +++ b/cpp/gherkin-cpp-rule-type.razor @@ -19,6 +19,9 @@ public static string NameOf(Rule rule) } #pragma once +#include +#include + namespace gherkin { enum class rule_type @@ -30,4 +33,16 @@ enum class rule_type count }; +std::string_view +to_string(rule_type r); + +inline +std::ostream& +operator<<(std::ostream& os, rule_type r) +{ + os << to_string(r); + + return os; +} + } diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index c66156bbf..4c245ce83 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -29,7 +29,7 @@ class ast_builder void start_rule(rule_type rule_type); void end_rule(rule_type rule_type); - void build(token& token); + void build(const token& token); const cms::gherkin_document& get_result() const; diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index f4f9363f4..89147ef1a 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include #include #include @@ -13,16 +15,50 @@ namespace gherkin { +template +struct sub_node +{ + using type = std::remove_cvref_t; + using vector_type = std::vector; + using ptr_type = std::shared_ptr; + + sub_node(std::any& sub_item) + : ref_(sub_item) + { + if (!ref_.has_value()) { + ref_ = make(); + } + } + + static + auto make() + { return std::make_shared(); } + + auto& cast() + { return std::any_cast(ref_); } + + auto get_ptr() + { return cast().get(); } + + auto& get() + { return *cast(); } + + void emplace_back(const T& v) + { get().emplace_back(v); } + + std::any& ref_; +}; + class ast_node { public: ast_node(rule_type rule_type = rule_type::none); - ast_node(const ast_node& other) = delete; + ast_node(const ast_node& other); ast_node(ast_node&& other); virtual ~ast_node(); - ast_node& operator=(const ast_node& other) = delete; + ast_node& operator=(const ast_node& other); ast_node& operator=(ast_node&& other); bool is(rule_type rule_type) const; @@ -30,67 +66,55 @@ class ast_node rule_type type() const; template - void add(rule_type rule_type, T&& v) + void add(rule_type rule_type, const T& v) { - using value_type = std::remove_cvref_t; - using vector_type = std::vector; - - auto& a = sub_items_[rule_type]; - - if (!a.has_value()) { - a = vector_type{}; - } + sub_node sn(sub_items_[rule_type]); - auto& vs = std::any_cast(a); - vs.emplace_back(std::move(v)); + sn.emplace_back(v); } template - auto get_items(rule_type rule_type) const + auto get_items( + rule_type rule_type, + const std::vector* default_result = nullptr + ) const { - using value_type = std::remove_cvref_t; - using vector_type = std::vector; - using view_type = std::ranges::ref_view; - using ret_type = std::optional; + using stype = sub_node; + using ret_type = const typename stype::vector_type*; - auto it = sub_items_.find(rule_type); + ret_type ret = default_result; - ret_type r; + auto it = sub_items_.find(rule_type); if (it != sub_items_.end()) { - auto& vs = std::any_cast(it->second); + stype sn(const_cast(it->second)); - if (!vs.empty()) { - r = std::views::all(vs); - } + ret = sn.get_ptr(); } - return r; + return ret; } template - auto get_single(rule_type rule_type) const + const T* get_single( + rule_type rule_type, + const T* default_result = nullptr + ) const { - using value_type = std::remove_cvref_t; - using ref_type = std::reference_wrapper; - using ret_type = std::optional; - - auto opt_items = get_items(rule_type); - ret_type r; + auto items = get_items(rule_type); - if (opt_items) { - auto& items = *opt_items; - r = std::cref(items[0]); + if (items && !items->empty()) { + return std::addressof(items->at(0)); } - return r; + return default_result; } - auto get_tokens(rule_type rule_type) const - { return *get_items(rule_type); } + const auto& get_tokens(rule_type rule_type) const + { return *get_items(rule_type, &empty_tokens_); } const auto& get_token(rule_type rule_type) const - { return get_single(rule_type)->get(); } + { return *get_single(rule_type, &null_token_); } template void set_value(rule_type rule_type, V& v) const @@ -111,10 +135,10 @@ class ast_node } } } else { - auto item = get_single(rule_type); + auto pitem = get_single(rule_type); - if (item) { - v = item->get(); + if (pitem) { + v = *pitem; } } } @@ -138,6 +162,8 @@ class ast_node rule_type rule_type_; sub_items sub_items_; + token null_token_; + std::vector empty_tokens_; }; } diff --git a/cpp/include/gherkin/rule_type.hpp b/cpp/include/gherkin/rule_type.hpp index 4b66c50d1..2a56400c3 100644 --- a/cpp/include/gherkin/rule_type.hpp +++ b/cpp/include/gherkin/rule_type.hpp @@ -1,6 +1,9 @@ // This file is generated. Do not edit! Edit gherkin-cpp-rule-type.razor instead. #pragma once +#include +#include + namespace gherkin { enum class rule_type @@ -41,4 +44,16 @@ enum class rule_type count }; +std::string_view +to_string(rule_type r); + +inline +std::ostream& +operator<<(std::ostream& os, rule_type r) +{ + os << to_string(r); + + return os; +} + } diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index a166851b6..9282b4988 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -37,7 +37,7 @@ ast_builder::end_rule(rule_type rule_type) } void -ast_builder::build(token& token) +ast_builder::build(const token& token) { if (token.matched_type == rule_type::comment) { cms::comment c{ @@ -47,7 +47,7 @@ ast_builder::build(token& token) comments_.emplace_back(std::move(c)); } else { - current_node().add(token.matched_type, std::move(token)); + current_node().add(token.matched_type, token); } } @@ -58,7 +58,7 @@ ast_builder::get_result() const rule_type::gherkin_document ); - return dp ? (*dp).get() : doc_; + return dp ? *dp : doc_; }; std::string @@ -90,6 +90,8 @@ ast_builder::transform_node(ast_node& from, ast_node& to) to.add(from.type(), make_rule(from)); } else if (from.is(rule_type::gherkin_document)) { to.add(from.type(), make_gherkin_document(from)); + } else { + to.add(from.type(), from); } } @@ -115,8 +117,8 @@ ast_builder::make_step(ast_node& node) cms::doc_string ast_builder::make_doc_string(ast_node& node) { - auto& separator_token = - node.get_tokens(rule_type::doc_string_separator)[0]; + auto& tokens = node.get_tokens(rule_type::doc_string_separator); + auto& separator_token = tokens[0]; string_views svs; @@ -179,8 +181,8 @@ ast_builder::make_background(ast_node& node) cms::scenario ast_builder::make_scenario_definition(ast_node& node) { - auto opt = node.get_single(rule_type::scenario); - auto& scenario_node = opt->get(); + auto pnode = node.get_single(rule_type::scenario); + auto& scenario_node = *pnode; auto& scenario_line = scenario_node.get_token(rule_type::scenario_line); cms::scenario m{ @@ -201,8 +203,8 @@ ast_builder::make_scenario_definition(ast_node& node) cms::examples ast_builder::make_examples_definition(ast_node& node) { - auto opt = node.get_single(rule_type::examples); - auto& examples_node = opt->get(); + auto pnode = node.get_single(rule_type::examples); + auto& examples_node = *pnode; auto& examples_line = examples_node.get_token(rule_type::examples_line); cms::examples m{ @@ -213,11 +215,10 @@ ast_builder::make_examples_definition(ast_node& node) .id = next_id() }; - auto opt_table = - examples_node.get_single(rule_type::examples_table); + auto table = examples_node.get_single(rule_type::examples_table); - if (opt_table) { - auto rows = get_table_rows(opt_table->get()); + if (table) { + auto rows = get_table_rows(*table); m.table_header = rows.front(); @@ -266,11 +267,11 @@ ast_builder::make_description(ast_node& node) cms::feature ast_builder::make_feature(ast_node& node) { - auto opt_header = node.get_single(rule_type::feature_header); - auto& header = opt_header->get(); + auto pnode = node.get_single(rule_type::feature_header); + auto& header = *pnode; - auto opt_feature_line = node.get_single(rule_type::feature_line); - auto& feature_line = opt_feature_line->get(); + auto ptoken = header.get_single(rule_type::feature_line); + auto& feature_line = *ptoken; cms::feature m{ .location = get_location(feature_line), @@ -281,28 +282,24 @@ ast_builder::make_feature(ast_node& node) header.set(rule_type::description, m.description); - auto opt_background = - node.get_single(rule_type::background); + auto pb = node.get_single(rule_type::background); - if (opt_background) { - m.children.emplace_back(cms::feature_child{ - .background = opt_background->get() - }); + if (pb) { + m.children.emplace_back(cms::feature_child{ .background = *pb }); } - auto opt_scenarios = - node.get_items(rule_type::scenario_definition); + auto ps = node.get_items(rule_type::scenario_definition); - if (opt_scenarios) { - for (auto& scenario : *opt_scenarios) { + if (ps) { + for (auto& scenario : *ps) { m.children.emplace_back(cms::feature_child{.scenario = scenario}); } } - auto opt_rules = node.get_items(rule_type::rule); + auto pr = node.get_items(rule_type::rule); - if (opt_rules) { - for (auto& rule : *opt_rules) { + if (pr) { + for (auto& rule : *pr) { m.children.emplace_back(cms::feature_child{.rule = rule}); } } @@ -313,11 +310,11 @@ ast_builder::make_feature(ast_node& node) cms::rule ast_builder::make_rule(ast_node& node) { - auto opt_header = node.get_single(rule_type::rule_header); - auto& header = opt_header->get(); + auto pnode = node.get_single(rule_type::rule_header); + auto& header = *pnode; - auto opt_rule_line = node.get_single(rule_type::rule_line); - auto& rule_line = opt_rule_line->get(); + auto ptoken = header.get_single(rule_type::rule_line); + auto& rule_line = *ptoken; cms::rule m{ .location = get_location(rule_line), @@ -329,20 +326,16 @@ ast_builder::make_rule(ast_node& node) header.set(rule_type::description, m.description); - auto opt_background = - node.get_single(rule_type::background); + auto pb = node.get_single(rule_type::background); - if (opt_background) { - m.children.emplace_back(cms::rule_child{ - .background = opt_background->get() - }); + if (pb) { + m.children.emplace_back(cms::rule_child{ .background = *pb }); } - auto opt_scenarios = - node.get_items(rule_type::scenario_definition); + auto ps = node.get_items(rule_type::scenario_definition); - if (opt_scenarios) { - for (auto& scenario : *opt_scenarios) { + if (ps) { + for (auto& scenario : *ps) { m.children.emplace_back(cms::rule_child{.scenario = scenario}); } } @@ -413,10 +406,10 @@ ast_builder::get_tags(const ast_node& node) { tags ts; - auto opt_tags = node.get_single(rule_type::tags); + auto pnode = node.get_single(rule_type::tags); - if (opt_tags) { - auto& tags_node = opt_tags->get(); + if (pnode) { + auto& tags_node = *pnode; for (const auto& token : tags_node.get_tokens(rule_type::tag_line)) { for (auto& tag_item : token.matched_items) { diff --git a/cpp/src/lib/gherkin/ast_node.cpp b/cpp/src/lib/gherkin/ast_node.cpp index 58cdceca0..4511958d8 100644 --- a/cpp/src/lib/gherkin/ast_node.cpp +++ b/cpp/src/lib/gherkin/ast_node.cpp @@ -6,6 +6,11 @@ ast_node::ast_node(rule_type rule_type) : rule_type_(rule_type) {} +ast_node::ast_node(const ast_node& other) +: rule_type_(other.rule_type_), +sub_items_(other.sub_items_) +{} + ast_node::ast_node(ast_node&& other) : rule_type_(std::move(other.rule_type_)), sub_items_(std::move(other.sub_items_)) @@ -14,6 +19,15 @@ sub_items_(std::move(other.sub_items_)) ast_node::~ast_node() {} +ast_node& +ast_node::operator=(const ast_node& other) +{ + rule_type_ = other.rule_type_; + sub_items_ = other.sub_items_; + + return *this; +} + ast_node& ast_node::operator=(ast_node&& other) { diff --git a/cpp/src/lib/gherkin/rule_type.cpp b/cpp/src/lib/gherkin/rule_type.cpp new file mode 100644 index 000000000..02b33f82c --- /dev/null +++ b/cpp/src/lib/gherkin/rule_type.cpp @@ -0,0 +1,49 @@ +#include + +#include + +namespace gherkin { + +std::string_view +to_string(rule_type r) +{ + static const std::unordered_map rmap = { + { rule_type::none, "none" }, + { rule_type::e_o_f, "e_o_f" }, + { rule_type::empty, "empty" }, + { rule_type::comment, "comment" }, + { rule_type::tag_line, "tag_line" }, + { rule_type::feature_line, "feature_line" }, + { rule_type::rule_line, "rule_line" }, + { rule_type::background_line, "background_line" }, + { rule_type::scenario_line, "scenario_line" }, + { rule_type::examples_line, "examples_line" }, + { rule_type::step_line, "step_line" }, + { rule_type::doc_string_separator, "doc_string_separator" }, + { rule_type::table_row, "table_row" }, + { rule_type::language, "language" }, + { rule_type::other, "other" }, + { rule_type::gherkin_document, "gherkin_document" }, + { rule_type::feature, "feature" }, + { rule_type::feature_header, "feature_header" }, + { rule_type::rule, "rule" }, + { rule_type::rule_header, "rule_header" }, + { rule_type::background, "background" }, + { rule_type::scenario_definition, "scenario_definition" }, + { rule_type::scenario, "scenario" }, + { rule_type::examples_definition, "examples_definition" }, + { rule_type::examples, "examples" }, + { rule_type::examples_table, "examples_table" }, + { rule_type::step, "step" }, + { rule_type::step_arg, "step_arg" }, + { rule_type::data_table, "data_table" }, + { rule_type::doc_string, "doc_string" }, + { rule_type::tags, "tags" }, + { rule_type::description_helper, "description_helper" }, + { rule_type::description, "description" } + }; + + return rmap.at(r); +} + +} From 0e9e74bb9b46bda9c44fb3f55a35948f864bad6e Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 15 May 2023 18:58:56 +0200 Subject: [PATCH 26/76] chore: improving parser interface --- cpp/include/gherkin/ast_builder.hpp | 2 +- cpp/include/gherkin/line.hpp | 2 +- cpp/include/gherkin/parser.hpp | 5 ++++- cpp/src/lib/gherkin/ast_builder.cpp | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 4c245ce83..f8ce3e403 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -25,7 +25,7 @@ class ast_builder ast_builder(); virtual ~ast_builder(); - void reset(); + void reset(const std::string& uri = ""); void start_rule(rule_type rule_type); void end_rule(rule_type rule_type); diff --git a/cpp/include/gherkin/line.hpp b/cpp/include/gherkin/line.hpp index c3011fc8a..54ff2706c 100644 --- a/cpp/include/gherkin/line.hpp +++ b/cpp/include/gherkin/line.hpp @@ -17,7 +17,7 @@ class line std::string_view get_rest_trimmed(std::size_t length) const; std::string_view get_line_text( - std::size_t indent_to_remove=std::string::npos + std::size_t indent_to_remove = std::string::npos ) const; std::string_view line_text() const; diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index 55f43e562..e445012a5 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -9,6 +9,8 @@ namespace gherkin { +namespace cms = cucumber::messages; + struct parser_info { std::string language = "en"; @@ -20,6 +22,7 @@ class parser parser(const parser_info& pi = {}); virtual ~parser(); + const cms::gherkin_document& parse(const cms::source& source); const cms::gherkin_document& parse(const file& file); const cms::gherkin_document& get_result() const; diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 9282b4988..5a8b222f3 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -17,10 +17,12 @@ ast_builder::~ast_builder() {} void -ast_builder::reset() +ast_builder::reset(const std::string& uri) { stack_ = {}; stack_.emplace(rule_type::none); + comments_.clear(); + uri_ = uri; } void From 195943e4f8d80ebe15231b515919b2bf32c608c5 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 16 May 2023 11:57:25 +0200 Subject: [PATCH 27/76] chore: cleaned implementation with parser_base base class --- cpp/gherkin-cpp.razor | 17 +--------- cpp/include/gherkin/parser.hpp | 31 +++--------------- cpp/include/gherkin/parser_base.hpp | 42 +++++++++++++++++++++++++ cpp/include/gherkin/utils.hpp | 3 ++ cpp/src/bin/gherkin/gherkin.cpp | 1 + cpp/src/lib/gherkin/parser.cpp | 17 +--------- cpp/src/lib/gherkin/parser_base.cpp | 49 +++++++++++++++++++++++++++++ cpp/src/lib/gherkin/utils.cpp | 23 ++++++++++++++ 8 files changed, 125 insertions(+), 58 deletions(-) create mode 100644 cpp/include/gherkin/parser_base.hpp create mode 100644 cpp/src/lib/gherkin/parser_base.cpp diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index 7160a4d21..1f96fb6a2 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -160,20 +160,9 @@ handle_ast_error( ) { handle_external_error(context, true, argument, action); } -parser::parser(const parser_info& pi) -: pi_{pi} -{} - -parser::~parser() -{} - const cms::gherkin_document& -parser::parse(const file& file) +parser::parse(const cms::source& source) { - builder_.reset(); - scanner_.reset(file); - matcher_.reset(); - parser_context context{ .builder = builder_, .scanner = scanner_, @@ -202,10 +191,6 @@ parser::parse(const file& file) return get_result(); } -const cms::gherkin_document& -parser::get_result() const -{ return builder_.get_result(); } - static void build(parser_context& context, token& token) diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index e445012a5..c0df87c1e 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,37 +1,16 @@ #pragma once -#include - -#include -#include -#include -#include +#include namespace gherkin { -namespace cms = cucumber::messages; - -struct parser_info -{ - std::string language = "en"; -}; - -class parser +class parser : public parser_base { public: - parser(const parser_info& pi = {}); - virtual ~parser(); - - const cms::gherkin_document& parse(const cms::source& source); - const cms::gherkin_document& parse(const file& file); - - const cms::gherkin_document& get_result() const; + using parser_base::parser_base; + using parser_base::parse; -private: - parser_info pi_; - ast_builder builder_; - token_scanner scanner_; - token_matcher matcher_; + const cms::gherkin_document& parse(const cms::source& source) override; }; } diff --git a/cpp/include/gherkin/parser_base.hpp b/cpp/include/gherkin/parser_base.hpp new file mode 100644 index 000000000..31718f03d --- /dev/null +++ b/cpp/include/gherkin/parser_base.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include + +#include +#include +#include +#include + +namespace gherkin { + +namespace cms = cucumber::messages; + +struct parser_info +{ + std::string language = "en"; +}; + +class parser_base +{ +public: + parser_base(const parser_info& pi = {}); + virtual ~parser_base(); + + const cms::gherkin_document& parse(const std::string& data); + const cms::gherkin_document& parse(const gherkin::file& file); + + // Concrete implementation in derived classes + virtual const cms::gherkin_document& parse(const cms::source& source) = 0; + + const cms::gherkin_document& get_result() const; + +protected: + void reset(const cms::source& source); + + parser_info pi_; + ast_builder builder_; + token_scanner scanner_; + token_matcher matcher_; +}; + +} diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index 1bd35cf84..cca0157b3 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -20,6 +20,9 @@ replace(std::string& s, std::string_view what, std::string_view with); std::string replace(const std::string& s, std::string_view what, std::string_view with); +std::string +slurp(const std::string& path); + template struct reverse { diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 7cda3f606..53ba2842f 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -1,6 +1,7 @@ #include #include +#include struct options { diff --git a/cpp/src/lib/gherkin/parser.cpp b/cpp/src/lib/gherkin/parser.cpp index 23d008e3f..c5fc1037c 100644 --- a/cpp/src/lib/gherkin/parser.cpp +++ b/cpp/src/lib/gherkin/parser.cpp @@ -106,20 +106,9 @@ handle_ast_error( ) { handle_external_error(context, true, argument, action); } -parser::parser(const parser_info& pi) -: pi_{pi} -{} - -parser::~parser() -{} - const cms::gherkin_document& -parser::parse(const file& file) +parser::parse(const cms::source& source) { - builder_.reset(); - scanner_.reset(file); - matcher_.reset(); - parser_context context{ .builder = builder_, .scanner = scanner_, @@ -148,10 +137,6 @@ parser::parse(const file& file) return get_result(); } -const cms::gherkin_document& -parser::get_result() const -{ return builder_.get_result(); } - static void build(parser_context& context, token& token) diff --git a/cpp/src/lib/gherkin/parser_base.cpp b/cpp/src/lib/gherkin/parser_base.cpp new file mode 100644 index 000000000..0f22ba0e2 --- /dev/null +++ b/cpp/src/lib/gherkin/parser_base.cpp @@ -0,0 +1,49 @@ +#include + +#include + +namespace gherkin { + +parser_base::parser_base(const parser_info& pi) +: pi_(pi) +{} + +parser_base::~parser_base() +{} + +const cms::gherkin_document& +parser_base::parse(const std::string& data) +{ + cms::source s{ .data = data }; + + reset(s); + + return parse(s); +} + +const cms::gherkin_document& +parser_base::parse(const gherkin::file& file) +{ + cms::source s{ + .uri = file.path, + .data = slurp(file.path) + }; + + reset(s); + + return parse(s); +} + +void +parser_base::reset(const cms::source& source) +{ + builder_.reset(source.uri); + scanner_.reset(source.data); + matcher_.reset(); +} + +const cms::gherkin_document& +parser_base::get_result() const +{ return builder_.get_result(); } + +} diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index 2dab69ab9..1722b944c 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -1,3 +1,6 @@ +#include +#include + #include namespace gherkin { @@ -56,4 +59,24 @@ replace(const std::string& s, std::string_view what, std::string_view with) return t; } +std::string +slurp(const std::string& path) +{ + namespace fs = std::filesystem; + + std::string bytes; + std::ifstream ifs(path, std::ios::binary); + + if (ifs.is_open()) { + auto fsize = fs::file_size(fs::path{ path }); + + bytes.resize(fsize); + + ifs.read(bytes.data(), fsize); + ifs.close(); + } + + return bytes; +} + } From 284c1589c590a37ab6c2069efae8dd1c369fd1dd Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 16 May 2023 18:32:01 +0200 Subject: [PATCH 28/76] chore: implementing pickles compiler --- cpp/include/gherkin/parser_base.hpp | 17 ++- cpp/include/gherkin/parser_info.hpp | 15 +++ cpp/include/gherkin/pickles/compiler.hpp | 62 +++++++++ cpp/src/bin/gherkin/gherkin.cpp | 59 ++++++++- cpp/src/lib/gherkin/parser_base.cpp | 43 ++++--- cpp/src/lib/gherkin/pickles/compiler.cpp | 154 +++++++++++++++++++++++ 6 files changed, 319 insertions(+), 31 deletions(-) create mode 100644 cpp/include/gherkin/parser_info.hpp create mode 100644 cpp/include/gherkin/pickles/compiler.hpp create mode 100644 cpp/src/lib/gherkin/pickles/compiler.cpp diff --git a/cpp/include/gherkin/parser_base.hpp b/cpp/include/gherkin/parser_base.hpp index 31718f03d..9f2667656 100644 --- a/cpp/include/gherkin/parser_base.hpp +++ b/cpp/include/gherkin/parser_base.hpp @@ -6,32 +6,29 @@ #include #include #include +#include namespace gherkin { namespace cms = cucumber::messages; -struct parser_info -{ - std::string language = "en"; -}; - class parser_base { public: parser_base(const parser_info& pi = {}); virtual ~parser_base(); - const cms::gherkin_document& parse(const std::string& data); - const cms::gherkin_document& parse(const gherkin::file& file); - - // Concrete implementation in derived classes - virtual const cms::gherkin_document& parse(const cms::source& source) = 0; + void parse(const std::string& data); + void parse(const gherkin::file& file); const cms::gherkin_document& get_result() const; protected: void reset(const cms::source& source); + void parse_from_source(const cms::source& source); + + // Concrete implementation in derived classes + virtual const cms::gherkin_document& parse(const cms::source& source) = 0; parser_info pi_; ast_builder builder_; diff --git a/cpp/include/gherkin/parser_info.hpp b/cpp/include/gherkin/parser_info.hpp new file mode 100644 index 000000000..014d53752 --- /dev/null +++ b/cpp/include/gherkin/parser_info.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace gherkin { + +struct parser_info +{ + std::string language = "en"; + bool source_events = true; + bool ast_events = true; + bool pickle_events = true; +}; + +} diff --git a/cpp/include/gherkin/pickles/compiler.hpp b/cpp/include/gherkin/pickles/compiler.hpp new file mode 100644 index 000000000..dcdcbb86d --- /dev/null +++ b/cpp/include/gherkin/pickles/compiler.hpp @@ -0,0 +1,62 @@ +#pragma once + +#include + +#include + +namespace gherkin::pickles { + +namespace cms = cucumber::messages; + +using pickles = std::vector; +using steps = std::vector; +using tags = std::vector; +using table_cells = std::vector; + +class compiler +{ +public: + compiler(); + virtual ~compiler(); + + pickles compile(const cms::gherkin_document& d); + +private: + void compile_feature(pickles& pickles, const cms::feature& f); + + void compile_rule( + pickles& pickles, + const cms::rule& r, + const tags& parent_tags, + const steps& background_steps + ); + + void compile_scenario( + pickles& pickles, + const cms::scenario& s, + const tags& parent_tags, + const steps& background_steps + ); + + void compile_scenario_outline( + pickles& pickles, + const cms::scenario& s, + const tags& parent_tags, + const steps& background_steps + ); + + cms::pickle_step make_pickle_step( + const cms::step& step, + const table_cells& variable_cells, + const cms::table_row* value_row_ptr, + cms::step_keyword_type keyword_type + ); + + std::string interpolate( + const std::string& name, + const table_cells& variable_cells, + const table_cells& value_cells + ); +}; + +} diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 53ba2842f..2b203119d 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -1,22 +1,69 @@ #include +#include #include +#include #include struct options { - bool print_source_events; - bool print_ast_events; - bool print_pickle_events; + bool exit = false; + int exit_code = 0; + int last_arg = 0; + gherkin::parser_info pi; }; +options +parse_options(int ac, char** av) +{ + options opts; + + for (opts.last_arg = 1; opts.last_arg < ac; ++opts.last_arg) { + std::string_view arg(av[opts.last_arg]); + + if (arg == "--no-source") { + opts.pi.source_events = false; + } else if (arg == "--no-ast") { + opts.pi.ast_events = false; + } else if (arg == "--no-pickles") { + opts.pi.pickle_events = false; + } else if (arg.starts_with('-')) { + if (arg != "-h" && arg != "--help") { + std::cout << "Unknown option: " << arg << std::endl; + opts.exit_code = 1; + } + + std::cout + << "Usage: gherkin [options] FILE...\n" + << " -h, --help You're looking at it.\n" + << " --no-ast Do not emit Ast events.\n" + << " --no-pickles Do not emit Pickle events.\n" + << " --no-source Do not emit Source events." + << std::endl + ; + + opts.exit = true; + } else { + break; + } + } + + return opts; +} + int main(int ac, char** av) { - gherkin::parser p; + auto opts = parse_options(ac, av); + + if (opts.exit) { + return opts.exit_code; + } - const auto& d = p.parse(gherkin::file{ av[1] }); + gherkin::parser p(opts.pi); - std::cout << d.to_json() << std::endl; + for ( ; opts.last_arg < ac; ++opts.last_arg) { + p.parse(gherkin::file{ av[opts.last_arg] }); + } return 0; } diff --git a/cpp/src/lib/gherkin/parser_base.cpp b/cpp/src/lib/gherkin/parser_base.cpp index 0f22ba0e2..1128105e1 100644 --- a/cpp/src/lib/gherkin/parser_base.cpp +++ b/cpp/src/lib/gherkin/parser_base.cpp @@ -11,27 +11,17 @@ parser_base::parser_base(const parser_info& pi) parser_base::~parser_base() {} -const cms::gherkin_document& +void parser_base::parse(const std::string& data) -{ - cms::source s{ .data = data }; - - reset(s); - - return parse(s); -} +{ parse_from_source({ .data = data }); } -const cms::gherkin_document& +void parser_base::parse(const gherkin::file& file) { - cms::source s{ + parse_from_source({ .uri = file.path, .data = slurp(file.path) - }; - - reset(s); - - return parse(s); + }); } void @@ -42,6 +32,29 @@ parser_base::reset(const cms::source& source) matcher_.reset(); } +void +parser_base::parse_from_source(const cms::source& source) +{ + if (pi_.source_events) { + + } + + if (pi_.ast_events || pi_.pickle_events) { + reset(source); + + const auto& ast_msg = parse(source); + + if (pi_.ast_events) { + + } + + if (pi_.pickle_events) { + // pickles compiler + } + } + +} + const cms::gherkin_document& parser_base::get_result() const { return builder_.get_result(); } diff --git a/cpp/src/lib/gherkin/pickles/compiler.cpp b/cpp/src/lib/gherkin/pickles/compiler.cpp new file mode 100644 index 000000000..46c190528 --- /dev/null +++ b/cpp/src/lib/gherkin/pickles/compiler.cpp @@ -0,0 +1,154 @@ +#include +#include + +namespace gherkin::pickles { + +template +void +append(Vector& to, const Vector& from) +{ to.insert(to.end(), from.begin(), from.end()); } + +compiler::compiler() +{} + +compiler::~compiler() +{} + +pickles +compiler::compile(const cms::gherkin_document& d) +{ + pickles pickles; + + if (d.feature) { + compile_feature(pickles, d.feature.value()); + } + + return pickles; +} + +void +compiler::compile_feature(pickles& pickles, const cms::feature& f) +{ + auto tags = f.tags; + steps background_steps; + + for (const auto& child : f.children) { + if (child.background) { + append(background_steps, child.background->steps); + } else if (child.rule) { + compile_rule( + pickles, + *child.rule, + tags, + background_steps + ); + } + } +} + +void +compiler::compile_rule( + pickles& pickles, + const cms::rule& r, + const tags& parent_tags, + const steps& background_steps +) +{ + auto steps = background_steps; + auto tags = parent_tags; + + append(tags, r.tags); + + for (const auto& child : r.children) { + if (child.background) { + append(steps, child.background->steps); + } else if (child.scenario) { + const auto& scenario = *child.scenario; + + if (scenario.examples.empty()) { + compile_scenario( + pickles, + scenario, + tags, + steps + ); + } else { + compile_scenario_outline( + pickles, + scenario, + tags, + steps + ); + } + } + } +} + +void +compiler::compile_scenario( + pickles& pickles, + const cms::scenario& s, + const tags& parent_tags, + const steps& background_steps +) +{ + steps steps; + + if (!s.steps.empty()) { + auto ssteps = background_steps; + + append(ssteps, s.steps); + + auto last_keyword_type = cms::step_keyword_type::UNKNOWN; + + for (const auto& step : ssteps) { + if (step.keyword_type) { + if (*step.keyword_type != cms::step_keyword_type::CONJUNCTION) { + last_keyword_type = *step.keyword_type; + } + } + + //steps.push_back() + } + } +} + +cms::pickle_step +compiler::make_pickle_step( + const cms::step& step, + const table_cells& variable_cells, + const cms::table_row* value_row_ptr, + cms::step_keyword_type keyword_type +) +{ + const auto& value_cells = + value_row_ptr + ? value_row_ptr->cells + : table_cells() + ; + + auto step_text = interpolate(step.text, variable_cells, value_cells); +} + +std::string +compiler::interpolate( + const std::string& name, + const table_cells& variable_cells, + const table_cells& value_cells +) +{ + auto iname = name; + std::size_t col = 0; + std::string header; + + for (const auto& variable_cell : variable_cells) { + const auto& value_cell = value_cells[col++]; + header = "<" + variable_cell.value + ">"; + + replace(iname, header, value_cell.value); + } + + return iname; +} + +} From a1ceef7878ae61fc44e2fc1f716110c2f8e18d89 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Wed, 17 May 2023 10:57:56 +0200 Subject: [PATCH 29/76] chore: pickle compiler --- cpp/include/gherkin/data.hpp | 15 + cpp/include/gherkin/msg_types.hpp | 19 ++ cpp/include/gherkin/parser_base.hpp | 7 +- cpp/include/gherkin/pickle_compiler.hpp | 93 ++++++ cpp/include/gherkin/pickles/compiler.hpp | 62 ---- cpp/src/lib/gherkin/parser_base.cpp | 20 +- cpp/src/lib/gherkin/pickle_compiler.cpp | 403 +++++++++++++++++++++++ cpp/src/lib/gherkin/pickles/compiler.cpp | 154 --------- 8 files changed, 547 insertions(+), 226 deletions(-) create mode 100644 cpp/include/gherkin/data.hpp create mode 100644 cpp/include/gherkin/msg_types.hpp create mode 100644 cpp/include/gherkin/pickle_compiler.hpp delete mode 100644 cpp/include/gherkin/pickles/compiler.hpp create mode 100644 cpp/src/lib/gherkin/pickle_compiler.cpp delete mode 100644 cpp/src/lib/gherkin/pickles/compiler.cpp diff --git a/cpp/include/gherkin/data.hpp b/cpp/include/gherkin/data.hpp new file mode 100644 index 000000000..6364b7e1a --- /dev/null +++ b/cpp/include/gherkin/data.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +#include + +namespace gherkin { + +struct data +{ + cms::gherkin_document document; + gherkin::pickles pickles; +}; + +} diff --git a/cpp/include/gherkin/msg_types.hpp b/cpp/include/gherkin/msg_types.hpp new file mode 100644 index 000000000..419aa2376 --- /dev/null +++ b/cpp/include/gherkin/msg_types.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +#include + +namespace gherkin { + +namespace cms = cucumber::messages; + +using pickles = std::vector; +using pickle_steps = std::vector; +using pickle_tags = std::vector; +using pickle_table_cells = std::vector; +using steps = std::vector; +using tags = std::vector; +using table_cells = std::vector; + +} diff --git a/cpp/include/gherkin/parser_base.hpp b/cpp/include/gherkin/parser_base.hpp index 9f2667656..5107a7f80 100644 --- a/cpp/include/gherkin/parser_base.hpp +++ b/cpp/include/gherkin/parser_base.hpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace gherkin { @@ -18,14 +19,14 @@ class parser_base parser_base(const parser_info& pi = {}); virtual ~parser_base(); - void parse(const std::string& data); - void parse(const gherkin::file& file); + data parse(const std::string& data); + data parse(const gherkin::file& file); const cms::gherkin_document& get_result() const; protected: void reset(const cms::source& source); - void parse_from_source(const cms::source& source); + data parse_from_source(const cms::source& source); // Concrete implementation in derived classes virtual const cms::gherkin_document& parse(const cms::source& source) = 0; diff --git a/cpp/include/gherkin/pickle_compiler.hpp b/cpp/include/gherkin/pickle_compiler.hpp new file mode 100644 index 000000000..76eba4e1b --- /dev/null +++ b/cpp/include/gherkin/pickle_compiler.hpp @@ -0,0 +1,93 @@ +#pragma once + +#include + +#include +#include + +namespace gherkin { + +class pickle_compiler +{ +public: + pickle_compiler(); + virtual ~pickle_compiler(); + + pickles compile( + const cms::gherkin_document& d, + const std::string& uri + ); + +private: + void compile_feature( + pickles& pickles, + const cms::feature& f, + const std::string& language, + const std::string& uri + ); + + void compile_rule( + pickles& pickles, + const cms::rule& r, + const tags& parent_tags, + const steps& background_steps, + const std::string& language, + const std::string& uri + ); + + void compile_scenario( + pickles& pickles, + const cms::scenario& s, + const tags& parent_tags, + const steps& background_steps, + const std::string& language, + const std::string& uri + ); + + void compile_scenario_outline( + pickles& pickles, + const cms::scenario& s, + const tags& parent_tags, + const steps& background_steps, + const std::string& language, + const std::string& uri + ); + + cms::pickle_table make_pickle_table( + const cms::data_table& dt, + const table_cells& variable_cells, + const table_cells& value_cells + ); + + cms::pickle_doc_string make_pickle_doc_string( + const cms::doc_string& ds, + const table_cells& variable_cells, + const table_cells& value_cells + ); + + cms::pickle_step make_pickle_step( + const cms::step& step, + const table_cells& variable_cells, + const cms::table_row* value_row_ptr, + cms::step_keyword_type keyword_type + ); + + cms::pickle_step make_pickle_step( + const cms::step& step, + cms::step_keyword_type keyword_type + ); + + pickle_tags make_pickle_tags(const tags& tags); + + std::string interpolate( + const std::string& name, + const table_cells& variable_cells, + const table_cells& value_cells + ); + + std::string next_id(); + + std::size_t id_counter_ = 0; +}; + +} diff --git a/cpp/include/gherkin/pickles/compiler.hpp b/cpp/include/gherkin/pickles/compiler.hpp deleted file mode 100644 index dcdcbb86d..000000000 --- a/cpp/include/gherkin/pickles/compiler.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#include - -#include - -namespace gherkin::pickles { - -namespace cms = cucumber::messages; - -using pickles = std::vector; -using steps = std::vector; -using tags = std::vector; -using table_cells = std::vector; - -class compiler -{ -public: - compiler(); - virtual ~compiler(); - - pickles compile(const cms::gherkin_document& d); - -private: - void compile_feature(pickles& pickles, const cms::feature& f); - - void compile_rule( - pickles& pickles, - const cms::rule& r, - const tags& parent_tags, - const steps& background_steps - ); - - void compile_scenario( - pickles& pickles, - const cms::scenario& s, - const tags& parent_tags, - const steps& background_steps - ); - - void compile_scenario_outline( - pickles& pickles, - const cms::scenario& s, - const tags& parent_tags, - const steps& background_steps - ); - - cms::pickle_step make_pickle_step( - const cms::step& step, - const table_cells& variable_cells, - const cms::table_row* value_row_ptr, - cms::step_keyword_type keyword_type - ); - - std::string interpolate( - const std::string& name, - const table_cells& variable_cells, - const table_cells& value_cells - ); -}; - -} diff --git a/cpp/src/lib/gherkin/parser_base.cpp b/cpp/src/lib/gherkin/parser_base.cpp index 1128105e1..b4443ed3e 100644 --- a/cpp/src/lib/gherkin/parser_base.cpp +++ b/cpp/src/lib/gherkin/parser_base.cpp @@ -1,6 +1,7 @@ #include #include +#include namespace gherkin { @@ -11,14 +12,14 @@ parser_base::parser_base(const parser_info& pi) parser_base::~parser_base() {} -void +data parser_base::parse(const std::string& data) -{ parse_from_source({ .data = data }); } +{ return parse_from_source({ .data = data }); } -void +data parser_base::parse(const gherkin::file& file) { - parse_from_source({ + return parse_from_source({ .uri = file.path, .data = slurp(file.path) }); @@ -32,9 +33,11 @@ parser_base::reset(const cms::source& source) matcher_.reset(); } -void +data parser_base::parse_from_source(const cms::source& source) { + data data; + if (pi_.source_events) { } @@ -42,17 +45,20 @@ parser_base::parse_from_source(const cms::source& source) if (pi_.ast_events || pi_.pickle_events) { reset(source); - const auto& ast_msg = parse(source); + data.document = parse(source); if (pi_.ast_events) { } if (pi_.pickle_events) { - // pickles compiler + gherkin::pickle_compiler c; + + data.pickles = c.compile(data.document, source.uri); } } + return data; } const cms::gherkin_document& diff --git a/cpp/src/lib/gherkin/pickle_compiler.cpp b/cpp/src/lib/gherkin/pickle_compiler.cpp new file mode 100644 index 000000000..745556a5a --- /dev/null +++ b/cpp/src/lib/gherkin/pickle_compiler.cpp @@ -0,0 +1,403 @@ +#include +#include + +namespace gherkin { + +cms::pickle_step_type +to_pickle_step_type(cms::step_keyword_type keyword_type) +{ + using step_map_type = std::unordered_map< + cms::step_keyword_type, + cms::pickle_step_type + >; + + static const step_map_type smap = { + { cms::step_keyword_type::UNKNOWN, cms::pickle_step_type::UNKNOWN }, + { cms::step_keyword_type::CONTEXT, cms::pickle_step_type::CONTEXT }, + { cms::step_keyword_type::ACTION, cms::pickle_step_type::ACTION }, + { cms::step_keyword_type::OUTCOME, cms::pickle_step_type::OUTCOME } + }; + + return smap.at(keyword_type); +} + +template +void +append(Vector& to, const Vector& from) +{ to.insert(to.end(), from.begin(), from.end()); } + +pickle_compiler::pickle_compiler() +{} + +pickle_compiler::~pickle_compiler() +{} + +pickles +pickle_compiler::compile( + const cms::gherkin_document& d, + const std::string& uri +) +{ + pickles pickles; + + if (d.feature) { + compile_feature(pickles, *d.feature, d.feature->language, uri); + } + + return pickles; +} + +void +pickle_compiler::compile_feature( + pickles& pickles, + const cms::feature& f, + const std::string& language, + const std::string& uri +) +{ + auto tags = f.tags; + steps background_steps; + + for (const auto& child : f.children) { + if (child.background) { + append(background_steps, child.background->steps); + } else if (child.rule) { + compile_rule( + pickles, + *child.rule, + tags, + background_steps, + language, + uri + ); + } else if (child.scenario) { + const auto& scenario = *child.scenario; + + if (scenario.examples.empty()) { + compile_scenario( + pickles, + scenario, + tags, + background_steps, + language, + uri + ); + } else { + compile_scenario_outline( + pickles, + scenario, + tags, + background_steps, + language, + uri + ); + } + } + } +} + +void +pickle_compiler::compile_rule( + pickles& pickles, + const cms::rule& r, + const tags& parent_tags, + const steps& background_steps, + const std::string& language, + const std::string& uri +) +{ + auto steps = background_steps; + auto tags = parent_tags; + + append(tags, r.tags); + + for (const auto& child : r.children) { + if (child.background) { + append(steps, child.background->steps); + } else if (child.scenario) { + const auto& scenario = *child.scenario; + + if (scenario.examples.empty()) { + compile_scenario( + pickles, + scenario, + tags, + steps, + language, + uri + ); + } else { + compile_scenario_outline( + pickles, + scenario, + tags, + steps, + language, + uri + ); + } + } + } +} + +void +pickle_compiler::compile_scenario( + pickles& pickles, + const cms::scenario& s, + const tags& parent_tags, + const steps& background_steps, + const std::string& language, + const std::string& uri +) +{ + auto conj = cms::step_keyword_type::CONJUNCTION; + pickle_steps steps; + + if (!s.steps.empty()) { + auto ssteps = background_steps; + + append(ssteps, s.steps); + + auto last_keyword_type = cms::step_keyword_type::UNKNOWN; + + for (const auto& step : ssteps) { + if (step.keyword_type && *step.keyword_type != conj) { + last_keyword_type = *step.keyword_type; + } + + steps.push_back(make_pickle_step(step, last_keyword_type)); + } + } + + auto tags = parent_tags; + + append(tags, s.tags); + + strings source_ids = { s.id }; + + cms::pickle p{ + .id = next_id(), + .uri = uri, + .name = s.name, + .language = language, + .steps = steps, + .tags = make_pickle_tags(tags), + .ast_node_ids = source_ids + }; + + pickles.emplace_back(std::move(p)); +} + +void +pickle_compiler::compile_scenario_outline( + pickles& pickles, + const cms::scenario& s, + const tags& parent_tags, + const steps& background_steps, + const std::string& language, + const std::string& uri +) +{ + auto conj = cms::step_keyword_type::CONJUNCTION; + + for (const auto& es : s.examples) { + if (!es.table_header) { + continue; + } + + const auto& variable_cells = es.table_header->cells; + + for (const auto& values_row : es.table_body) { + const auto& value_cells = values_row.cells; + + pickle_steps steps; + auto last_keyword_type = cms::step_keyword_type::UNKNOWN; + + if (!s.steps.empty()) { + for (const auto& step : background_steps) { + if (step.keyword_type && *step.keyword_type != conj) { + last_keyword_type = *step.keyword_type; + } + + steps.push_back(make_pickle_step(step, last_keyword_type)); + } + } + + auto tags = parent_tags; + + append(tags, s.tags); + append(tags, es.tags); + + for (const auto& step : s.steps) { + if (step.keyword_type && *step.keyword_type != conj) { + last_keyword_type = *step.keyword_type; + } + + steps.push_back(make_pickle_step(step, last_keyword_type)); + } + + strings source_ids = { s.id, values_row.id }; + + cms::pickle p{ + .id = next_id(), + .uri = uri, + .name = interpolate(s.name, variable_cells, value_cells), + .language = language, + .steps = steps, + .tags = make_pickle_tags(tags), + .ast_node_ids = source_ids + }; + + pickles.emplace_back(std::move(p)); + } + } +} + +cms::pickle_step +pickle_compiler::make_pickle_step( + const cms::step& step, + const table_cells& variable_cells, + const cms::table_row* value_row_ptr, + cms::step_keyword_type keyword_type +) +{ + const auto& value_cells = + value_row_ptr + ? value_row_ptr->cells + : table_cells() + ; + + cms::pickle_step ps{ + .ast_node_ids = { step.id }, + .type = to_pickle_step_type(keyword_type), + .text = interpolate(step.text, variable_cells, value_cells) + }; + + if (step.data_table) { + ps.argument = cms::pickle_step_argument{ + .data_table = make_pickle_table( + *step.data_table, + variable_cells, + value_cells + ) + }; + } else if (step.doc_string) { + ps.argument = cms::pickle_step_argument{ + .doc_string = make_pickle_doc_string( + *step.doc_string, + variable_cells, + value_cells + ) + }; + } + + if (value_row_ptr) { + ps.ast_node_ids.push_back(value_row_ptr->id); + } + + return ps; +} + +cms::pickle_table +pickle_compiler::make_pickle_table( + const cms::data_table& dt, + const table_cells& variable_cells, + const table_cells& value_cells +) +{ + cms::pickle_table t; + + for (const auto& row : dt.rows) { + pickle_table_cells cells; + + for (const auto& cell : row.cells) { + cells.emplace_back(cms::pickle_table_cell{ + .value = interpolate( + cell.value, + variable_cells, + value_cells + ) + }); + } + + t.rows.emplace_back(std::move(cells)); + } + + return t; +} + +cms::pickle_doc_string +pickle_compiler::make_pickle_doc_string( + const cms::doc_string& ds, + const table_cells& variable_cells, + const table_cells& value_cells +) +{ + cms::pickle_doc_string pds{ + .content = interpolate(ds.content, variable_cells, value_cells) + }; + + if (ds.media_type) { + pds.media_type = interpolate( + *ds.media_type, + variable_cells, + value_cells + ); + } + + return pds; +} + +cms::pickle_step +pickle_compiler::make_pickle_step( + const cms::step& step, + cms::step_keyword_type keyword_type +) +{ return make_pickle_step(step, {}, nullptr, keyword_type); } + +pickle_tags +pickle_compiler::make_pickle_tags(const tags& tags) +{ + pickle_tags ptags; + + std::transform( + tags.cbegin(), tags.cend(), + std::back_inserter(ptags), + [](const auto& t) { + return + cms::pickle_tag{ + .name = t.name, + .ast_node_id = t.id + }; + } + ); + + return ptags; +} + +std::string +pickle_compiler::interpolate( + const std::string& name, + const table_cells& variable_cells, + const table_cells& value_cells +) +{ + auto iname = name; + std::size_t col = 0; + std::string header; + + for (const auto& variable_cell : variable_cells) { + const auto& value_cell = value_cells[col++]; + header = "<" + variable_cell.value + ">"; + + replace(iname, header, value_cell.value); + } + + return iname; +} + +std::string +pickle_compiler::next_id() +{ return std::to_string(id_counter_++); } + +} diff --git a/cpp/src/lib/gherkin/pickles/compiler.cpp b/cpp/src/lib/gherkin/pickles/compiler.cpp deleted file mode 100644 index 46c190528..000000000 --- a/cpp/src/lib/gherkin/pickles/compiler.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include -#include - -namespace gherkin::pickles { - -template -void -append(Vector& to, const Vector& from) -{ to.insert(to.end(), from.begin(), from.end()); } - -compiler::compiler() -{} - -compiler::~compiler() -{} - -pickles -compiler::compile(const cms::gherkin_document& d) -{ - pickles pickles; - - if (d.feature) { - compile_feature(pickles, d.feature.value()); - } - - return pickles; -} - -void -compiler::compile_feature(pickles& pickles, const cms::feature& f) -{ - auto tags = f.tags; - steps background_steps; - - for (const auto& child : f.children) { - if (child.background) { - append(background_steps, child.background->steps); - } else if (child.rule) { - compile_rule( - pickles, - *child.rule, - tags, - background_steps - ); - } - } -} - -void -compiler::compile_rule( - pickles& pickles, - const cms::rule& r, - const tags& parent_tags, - const steps& background_steps -) -{ - auto steps = background_steps; - auto tags = parent_tags; - - append(tags, r.tags); - - for (const auto& child : r.children) { - if (child.background) { - append(steps, child.background->steps); - } else if (child.scenario) { - const auto& scenario = *child.scenario; - - if (scenario.examples.empty()) { - compile_scenario( - pickles, - scenario, - tags, - steps - ); - } else { - compile_scenario_outline( - pickles, - scenario, - tags, - steps - ); - } - } - } -} - -void -compiler::compile_scenario( - pickles& pickles, - const cms::scenario& s, - const tags& parent_tags, - const steps& background_steps -) -{ - steps steps; - - if (!s.steps.empty()) { - auto ssteps = background_steps; - - append(ssteps, s.steps); - - auto last_keyword_type = cms::step_keyword_type::UNKNOWN; - - for (const auto& step : ssteps) { - if (step.keyword_type) { - if (*step.keyword_type != cms::step_keyword_type::CONJUNCTION) { - last_keyword_type = *step.keyword_type; - } - } - - //steps.push_back() - } - } -} - -cms::pickle_step -compiler::make_pickle_step( - const cms::step& step, - const table_cells& variable_cells, - const cms::table_row* value_row_ptr, - cms::step_keyword_type keyword_type -) -{ - const auto& value_cells = - value_row_ptr - ? value_row_ptr->cells - : table_cells() - ; - - auto step_text = interpolate(step.text, variable_cells, value_cells); -} - -std::string -compiler::interpolate( - const std::string& name, - const table_cells& variable_cells, - const table_cells& value_cells -) -{ - auto iname = name; - std::size_t col = 0; - std::string header; - - for (const auto& variable_cell : variable_cells) { - const auto& value_cell = value_cells[col++]; - header = "<" + variable_cell.value + ">"; - - replace(iname, header, value_cell.value); - } - - return iname; -} - -} From 06fa08c1e566d7eadc85def057d48cda6e53febb Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 18 May 2023 18:31:36 +0200 Subject: [PATCH 30/76] chore: refactored parser hierarchy --- cpp/CMakeLists.txt | 6 +- cpp/Makefile | 4 +- cpp/gherkin-cpp.razor | 397 +- cpp/include/gherkin/ast_builder.hpp | 5 +- cpp/include/gherkin/basic_parser.hpp | 4568 +++++++++++++++++++++++ cpp/include/gherkin/builder.hpp | 44 + cpp/include/gherkin/data.hpp | 15 - cpp/include/gherkin/msg_types.hpp | 1 + cpp/include/gherkin/parser.hpp | 39 +- cpp/include/gherkin/parser_base.hpp | 57 +- cpp/include/gherkin/parser_context.hpp | 48 + cpp/include/gherkin/parser_info.hpp | 10 +- cpp/include/gherkin/token_scanner.hpp | 6 +- cpp/src/bin/gherkin/gherkin.cpp | 10 +- cpp/src/lib/gherkin/CMakeLists.txt | 8 +- cpp/src/lib/gherkin/ast_builder.cpp | 8 +- cpp/src/lib/gherkin/parser.cpp | 4762 ------------------------ cpp/src/lib/gherkin/parser_base.cpp | 68 - cpp/src/lib/gherkin/token_scanner.cpp | 8 +- 19 files changed, 4934 insertions(+), 5130 deletions(-) create mode 100644 cpp/include/gherkin/basic_parser.hpp create mode 100644 cpp/include/gherkin/builder.hpp delete mode 100644 cpp/include/gherkin/data.hpp create mode 100644 cpp/include/gherkin/parser_context.hpp delete mode 100644 cpp/src/lib/gherkin/parser.cpp delete mode 100644 cpp/src/lib/gherkin/parser_base.cpp diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ade033887..f8b7da6b4 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -18,12 +18,16 @@ install( TARGETS gherkin-cpp gherkin-bin EXPORT gherkin-cpp-config - FILE_SET gherkin_cpp_headers RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) +install( + DIRECTORY "${CMAKE_SOURCE_DIR}/include/" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gherkin +) + install( EXPORT gherkin-cpp-config FILE gherkin-cpp-config.cmake diff --git a/cpp/Makefile b/cpp/Makefile index b84d56ed8..fd0a5c140 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -3,7 +3,7 @@ SHELL := /usr/bin/env bash GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json GHERKIN_GENERATED = \ include/gherkin/rule_type.hpp \ - src/lib/gherkin/parser.cpp \ + include/gherkin/basic_parser.hpp \ src/lib/gherkin/dialect.cpp GHERKIN = bin/gherkin GHERKIN_GENERATE_TOKENS = bin/gherkin-generate-tokens @@ -86,7 +86,7 @@ include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) rm -f .configured -src/lib/gherkin/parser.cpp: gherkin-cpp.razor ../gherkin.berp +include/gherkin/basic_parser.hpp: gherkin-cpp.razor ../gherkin.berp $(berp-generate-parser) rm -f .configured diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index 1f96fb6a2..b4e98aad9 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -34,306 +34,239 @@ public static string NameOf(Rule rule) } @helper HandleParserError(IEnumerable expectedTokens, State state) { - /* "State: @state.Id - @Raw(state.Comment)" */ - std::string expected_tokens = "@Raw(string.Join(", ", expectedTokens))"; + /* "State: @state.Id - @Raw(state.Comment)" */ + std::string expected_tokens = "@Raw(string.Join(", ", expectedTokens))"; - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } - context.add_error(expected_tokens); + context.add_error(expected_tokens); - return @state.Id;} + return @state.Id; +} @helper MatchToken(TokenType tokenType) {match_@(ToSnakeCase(tokenType.Name))(context, token)} // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. -#include - -#include -#include +#include #include -#include namespace gherkin { -struct parser_context -{ - ast_builder& builder; - token_scanner& scanner; - token_matcher& matcher; - token_queue queue; - strings errors; - bool stop_at_first_error = false; - - bool has_token() const - { return !queue.empty(); } - - token pop_token() - { - auto t = std::move(queue.front()); - queue.pop_front(); - - return t; - } - - token read_token() - { return has_token() ? pop_token() : scanner.read(); } - - void push_tokens(const token_queue& q) - { queue.insert(queue.end(), q.begin(), q.end()); } - - bool has_errors() const - { return !errors.empty(); } - - void add_error(const std::string& e) - { errors.push_back(e); } - - void add_error(const std::exception& e) - { add_error(e.what()); } -}; - enum class error_type { unexpected_eof, unexpected_token }; -using match_function = std::function; -using match_functions = std::unordered_map; - -static void start_rule(parser_context& context, rule_type rule_type); - -static void end_rule(parser_context& context, rule_type rule_type); - -static std::size_t match_token( - std::size_t state, - token& token, - parser_context& context -); - -template -bool -handle_external_error( - parser_context& context, - bool default_value, - Argument&& argument, - Action&& action -) +template < + typename Builder = ast_builder, + typename Scanner = token_scanner, + typename Matcher = token_matcher +> +class basic_parser : public parser_base { - using ret_type = decltype(action(argument)); - - if (context.stop_at_first_error) { - if constexpr (std::is_same_v) { - action(argument); - return default_value; - } else { - return action(argument); - } - } +public: + using parent = parser_base; + using parent::parser_base; + using context_type = typename parent::context_type; - try { - if constexpr (std::is_same_v) { - action(argument); - return default_value; - } else { - return action(argument); - } - } catch (const std::exception& e) { - context.add_error(e); - } +protected: + void parse(context_type& context) override + { + start_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); - return default_value; -} + std::size_t state = 0; -template -void -handle_ast_error( - parser_context& context, - Argument&& argument, - Action&& action -) -{ handle_external_error(context, true, argument, action); } - -const cms::gherkin_document& -parser::parse(const cms::source& source) -{ - parser_context context{ - .builder = builder_, - .scanner = scanner_, - .matcher = matcher_ - }; + while (true) { + auto token = context.read_token(); + state = match_token(state, token, context); - start_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); - - std::size_t state = 0; + if (token.is_eof()) { + break; + } + } - while (true) { - auto token = context.read_token(); - state = match_token(state, token, context); + end_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); - if (token.is_eof()) { - break; + if (context.has_errors()) { + // TODO: thow coumpound error } } - end_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); + void build(context_type& context, token& token) + { context.builder.build(token); } - if (context.has_errors()) { - // TODO: thow coumpound error + void start_rule(context_type& context, rule_type rule_type) + { + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.start_rule(rtype); + } + ); } - return get_result(); -} - -static -void -build(parser_context& context, token& token) -{ context.builder.build(token); } + void end_rule(context_type& context, rule_type rule_type) + { + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.end_rule(rtype); + } + ); + } -static -void -start_rule(parser_context& context, rule_type rule_type) -{ - handle_ast_error( - context, - rule_type, - [&context](auto rtype) { - context.builder.start_rule(rtype); + template + bool handle_external_error( + context_type& context, + bool default_value, + Argument&& argument, + Action&& action + ) + { + using ret_type = decltype(action(argument)); + + if (context.stop_at_first_error) { + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } } - ); -} -static -void -end_rule(parser_context& context, rule_type rule_type) -{ - handle_ast_error( - context, - rule_type, - [&context](auto rtype) { - context.builder.end_rule(rtype); + try { + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } + } catch (const std::exception& e) { + context.add_error(e); } - ); -} -namespace detail { + return default_value; + } + + template + void handle_ast_error( + context_type& context, + Argument&& argument, + Action&& action + ) + { handle_external_error(context, true, argument, action); } @foreach(var rule in Model.RuleSet.TokenRules) { -static -bool -match_@(NameOf(rule))(parser_context& context, token& token) -{ + bool match_@(NameOf(rule))(context_type& context, token& token) + { @if (rule.Name != "#EOF") { - @:if (token.is_eof()) { - @: return false; - @:} - @: + @:if (token.is_eof()) { + @: return false; + @:} + @: + } + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_@(NameOf(rule))(t); + } + ); } - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_@(NameOf(rule))(t); - } - ); -} } @foreach(var lookAheadHint in Model.RuleSet.LookAheadHints) { -static -bool -lookahead_@(lookAheadHint.Id)(parser_context& context, token& current_token) -{ - current_token.detach(); - token token; - token_queue queue; - bool match = false; - - while (true) { - token = context.read_token(); - token.detach(); - queue.push_back(token); - - if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {@MatchToken(tokenType) || }false) { - match = true; - break; - } + bool lookahead_@(lookAheadHint.Id)(context_type& context, token& current_token) + { + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach(); + queue.push_back(token); + + if (@foreach(var tokenType in lookAheadHint.ExpectedTokens) {@MatchToken(tokenType) || }false) { + match = true; + break; + } - if (!(@foreach(var tokenType in lookAheadHint.Skip) {@MatchToken(tokenType) || }false)) { - break; + if (!(@foreach(var tokenType in lookAheadHint.Skip) {@MatchToken(tokenType) || }false)) { + break; + } } - } - context.push_tokens(queue); + context.push_tokens(queue); - return match; -} + return match; + } } @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) { -// @Raw(state.Comment) -static -std::size_t -match_token_at_@(state.Id)(token& token, parser_context& context) -{ -@{var indent = "";} + // @Raw(state.Comment) + std::size_t match_token_at_@(state.Id)(token& token, context_type& context) + { +@{var indent = " ";} @foreach(var transition in state.Transitions) { - @:if (@MatchToken(transition.TokenType)) { - if (transition.LookAheadHint != null) - { - @:if (lookahead_@(transition.LookAheadHint.Id)(context, token)) { - indent = " "; - } - foreach(var production in transition.Productions) - { - @indent@CallProduction(production) - } + @:if (@MatchToken(transition.TokenType)) { + if (transition.LookAheadHint != null) + { + @:if (lookahead_@(transition.LookAheadHint.Id)(context, token)) { + indent = " "; + } + foreach(var production in transition.Productions) + { + @indent@CallProduction(production) + } @:@(indent)return @transition.TargetState; - if (transition.LookAheadHint != null) - { + if (transition.LookAheadHint != null) + { + indent = " "; + @:} + } @:} - } - @:} } - - @HandleParserError(state.Transitions.Select(t => "#" + t.TokenType.ToString()).Distinct(), state) -} + @HandleParserError(state.Transitions.Select(t => "#" + t.TokenType.ToString()).Distinct(), state) + } } -} // namespace detail - -static -std::size_t -match_token(std::size_t state, token& token, parser_context& context) -{ - switch (state) { + std::size_t match_token(std::size_t state, token& token, context_type& context) + { + switch (state) { @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) { - @:case @state.Id: - @:return detail::match_token_at_@(state.Id)(token, context); + @:case @state.Id: + @:return match_token_at_@(state.Id)(token, context); } - default: - context.add_error("invalid operation: " + std::to_string(state)); - return -1; + default: + context.add_error("invalid operation: " + std::to_string(state)); + return -1; + } } -} +}; } diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index f8ce3e403..ab319252d 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -25,7 +26,7 @@ class ast_builder ast_builder(); virtual ~ast_builder(); - void reset(const std::string& uri = ""); + void reset(std::string_view uri); void start_rule(rule_type rule_type); void end_rule(rule_type rule_type); @@ -67,7 +68,7 @@ class ast_builder std::size_t id_counter_ = 0; ast_node_stack stack_; - std::string uri_; + std::string_view uri_; comments comments_; cms::gherkin_document doc_; }; diff --git a/cpp/include/gherkin/basic_parser.hpp b/cpp/include/gherkin/basic_parser.hpp new file mode 100644 index 000000000..77a9356a9 --- /dev/null +++ b/cpp/include/gherkin/basic_parser.hpp @@ -0,0 +1,4568 @@ +// This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. +#include +#include + +namespace gherkin { + +enum class error_type +{ + unexpected_eof, + unexpected_token +}; + +template < + typename Builder = ast_builder, + typename Scanner = token_scanner, + typename Matcher = token_matcher +> +class basic_parser : public parser_base +{ +public: + using parent = parser_base; + using parent::parser_base; + using context_type = typename parent::context_type; + +protected: + void parse(context_type& context) override + { + start_rule(context, rule_type::gherkin_document); + + std::size_t state = 0; + + while (true) { + auto token = context.read_token(); + state = match_token(state, token, context); + + if (token.is_eof()) { + break; + } + } + + end_rule(context, rule_type::gherkin_document); + + if (context.has_errors()) { + // TODO: thow coumpound error + } + } + + void build(context_type& context, token& token) + { context.builder.build(token); } + + void start_rule(context_type& context, rule_type rule_type) + { + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.start_rule(rtype); + } + ); + } + + void end_rule(context_type& context, rule_type rule_type) + { + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.end_rule(rtype); + } + ); + } + + template + bool handle_external_error( + context_type& context, + bool default_value, + Argument&& argument, + Action&& action + ) + { + using ret_type = decltype(action(argument)); + + if (context.stop_at_first_error) { + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } + } + + try { + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } + } catch (const std::exception& e) { + context.add_error(e); + } + + return default_value; + } + + template + void handle_ast_error( + context_type& context, + Argument&& argument, + Action&& action + ) + { handle_external_error(context, true, argument, action); } + + + bool match_e_o_f(context_type& context, token& token) + { + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_e_o_f(t); + } + ); + } + + bool match_empty(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_empty(t); + } + ); + } + + bool match_comment(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_comment(t); + } + ); + } + + bool match_tag_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_tag_line(t); + } + ); + } + + bool match_feature_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_feature_line(t); + } + ); + } + + bool match_rule_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_rule_line(t); + } + ); + } + + bool match_background_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_background_line(t); + } + ); + } + + bool match_scenario_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_scenario_line(t); + } + ); + } + + bool match_examples_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_examples_line(t); + } + ); + } + + bool match_step_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_step_line(t); + } + ); + } + + bool match_doc_string_separator(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_doc_string_separator(t); + } + ); + } + + bool match_table_row(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_table_row(t); + } + ); + } + + bool match_language(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_language(t); + } + ); + } + + bool match_other(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_other(t); + } + ); + } + + + bool lookahead_0(context_type& context, token& current_token) + { + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach(); + queue.push_back(token); + + if (match_scenario_line(context, token) || false) { + match = true; + break; + } + + if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { + break; + } + } + + context.push_tokens(queue); + + return match; + } + + bool lookahead_1(context_type& context, token& current_token) + { + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach(); + queue.push_back(token); + + if (match_examples_line(context, token) || false) { + match = true; + break; + } + + if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { + break; + } + } + + context.push_tokens(queue); + + return match; + } + + + // Start + std::size_t match_token_at_0(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + build(context, token); + return 42; + } + if (match_language(context, token)) { + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); + build(context, token); + return 1; + } + if (match_tag_line(context, token)) { + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); + start_rule(context, rule_type::tags); + build(context, token); + return 2; + } + if (match_feature_line(context, token)) { + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); + build(context, token); + return 3; + } + if (match_comment(context, token)) { + build(context, token); + return 0; + } + if (match_empty(context, token)) { + build(context, token); + return 0; + } + + /* "State: 0 - Start" */ + std::string expected_tokens = "#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 0; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 + std::size_t match_token_at_1(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + start_rule(context, rule_type::tags); + build(context, token); + return 2; + } + if (match_feature_line(context, token)) { + build(context, token); + return 3; + } + if (match_comment(context, token)) { + build(context, token); + return 1; + } + if (match_empty(context, token)) { + build(context, token); + return 1; + } + + /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ + std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 1; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 + std::size_t match_token_at_2(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 2; + } + if (match_feature_line(context, token)) { + end_rule(context, rule_type::tags); + build(context, token); + return 3; + } + if (match_comment(context, token)) { + build(context, token); + return 2; + } + if (match_empty(context, token)) { + build(context, token); + return 2; + } + + /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 2; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 + std::size_t match_token_at_3(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 3; + } + if (match_comment(context, token)) { + build(context, token); + return 5; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); + build(context, token); + return 6; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 4; + } + + /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 3; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_4(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 5; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); + build(context, token); + return 6; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 4; + } + + /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 4; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_5(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 5; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); + build(context, token); + return 6; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 5; + } + + /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 5; + } + + // GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 + std::size_t match_token_at_6(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 6; + } + if (match_comment(context, token)) { + build(context, token); + return 8; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 7; + } + + /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 6; + } + + // GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_7(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 8; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 7; + } + + /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 7; + } + + // GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_8(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 8; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 8; + } + + /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 8; + } + + // GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 + std::size_t match_token_at_9(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::data_table); + build(context, token); + return 10; + } + if (match_doc_string_separator(context, token)) { + start_rule(context, rule_type::doc_string); + build(context, token); + return 49; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 9; + } + if (match_empty(context, token)) { + build(context, token); + return 9; + } + + /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 9; + } + + // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 + std::size_t match_token_at_10(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 10; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 10; + } + if (match_empty(context, token)) { + build(context, token); + return 10; + } + + /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 10; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 + std::size_t match_token_at_11(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 11; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::tags); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_comment(context, token)) { + build(context, token); + return 11; + } + if (match_empty(context, token)) { + build(context, token); + return 11; + } + + /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 11; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 + std::size_t match_token_at_12(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 12; + } + if (match_comment(context, token)) { + build(context, token); + return 14; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 13; + } + + /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 12; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_13(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 14; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 13; + } + + /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 13; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_14(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 14; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 14; + } + + /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 14; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 + std::size_t match_token_at_15(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::data_table); + build(context, token); + return 16; + } + if (match_doc_string_separator(context, token)) { + start_rule(context, rule_type::doc_string); + build(context, token); + return 47; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 15; + } + if (match_empty(context, token)) { + build(context, token); + return 15; + } + + /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 15; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 + std::size_t match_token_at_16(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 16; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 16; + } + if (match_empty(context, token)) { + build(context, token); + return 16; + } + + /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 16; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 + std::size_t match_token_at_17(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 17; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::tags); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_comment(context, token)) { + build(context, token); + return 17; + } + if (match_empty(context, token)) { + build(context, token); + return 17; + } + + /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 17; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 + std::size_t match_token_at_18(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 18; + } + if (match_comment(context, token)) { + build(context, token); + return 20; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::examples_table); + build(context, token); + return 21; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 19; + } + + /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 18; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_19(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 20; + } + if (match_table_row(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_table); + build(context, token); + return 21; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 19; + } + + /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 19; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_20(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 20; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::examples_table); + build(context, token); + return 21; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 20; + } + + /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 20; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 + std::size_t match_token_at_21(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 21; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 21; + } + if (match_empty(context, token)) { + build(context, token); + return 21; + } + + /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 21; + } + + // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 + std::size_t match_token_at_22(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 22; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::tags); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 22; + } + if (match_empty(context, token)) { + build(context, token); + return 22; + } + + /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 22; + } + + // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 + std::size_t match_token_at_23(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 25; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); + build(context, token); + return 26; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 24; + } + + /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 23; + } + + // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_24(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 25; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); + build(context, token); + return 26; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 24; + } + + /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 24; + } + + // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_25(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 25; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); + build(context, token); + return 26; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 25; + } + + /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 25; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 + std::size_t match_token_at_26(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 26; + } + if (match_comment(context, token)) { + build(context, token); + return 28; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 27; + } + + /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 26; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_27(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 28; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 27; + } + + /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 27; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_28(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 28; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 28; + } + + /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 28; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 + std::size_t match_token_at_29(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::data_table); + build(context, token); + return 30; + } + if (match_doc_string_separator(context, token)) { + start_rule(context, rule_type::doc_string); + build(context, token); + return 45; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 29; + } + if (match_empty(context, token)) { + build(context, token); + return 29; + } + + /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 29; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 + std::size_t match_token_at_30(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 30; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 30; + } + if (match_empty(context, token)) { + build(context, token); + return 30; + } + + /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 30; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 + std::size_t match_token_at_31(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 31; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::tags); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_comment(context, token)) { + build(context, token); + return 31; + } + if (match_empty(context, token)) { + build(context, token); + return 31; + } + + /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 31; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 + std::size_t match_token_at_32(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 32; + } + if (match_comment(context, token)) { + build(context, token); + return 34; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 33; + } + + /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 32; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_33(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 34; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 33; + } + + /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 33; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_34(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 34; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 34; + } + + /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 34; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 + std::size_t match_token_at_35(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::data_table); + build(context, token); + return 36; + } + if (match_doc_string_separator(context, token)) { + start_rule(context, rule_type::doc_string); + build(context, token); + return 43; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 35; + } + if (match_empty(context, token)) { + build(context, token); + return 35; + } + + /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 35; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 + std::size_t match_token_at_36(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 36; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 36; + } + if (match_empty(context, token)) { + build(context, token); + return 36; + } + + /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 36; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 + std::size_t match_token_at_37(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 37; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::tags); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_comment(context, token)) { + build(context, token); + return 37; + } + if (match_empty(context, token)) { + build(context, token); + return 37; + } + + /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 37; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 + std::size_t match_token_at_38(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 38; + } + if (match_comment(context, token)) { + build(context, token); + return 40; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::examples_table); + build(context, token); + return 41; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 39; + } + + /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 38; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_39(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 40; + } + if (match_table_row(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_table); + build(context, token); + return 41; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 39; + } + + /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 39; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_40(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 40; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::examples_table); + build(context, token); + return 41; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 40; + } + + /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 40; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 + std::size_t match_token_at_41(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 41; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 41; + } + if (match_empty(context, token)) { + build(context, token); + return 41; + } + + /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 41; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 + std::size_t match_token_at_43(token& token, context_type& context) + { + if (match_doc_string_separator(context, token)) { + build(context, token); + return 44; + } + if (match_other(context, token)) { + build(context, token); + return 43; + } + + /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = "#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 43; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 + std::size_t match_token_at_44(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 44; + } + if (match_empty(context, token)) { + build(context, token); + return 44; + } + + /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 44; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 + std::size_t match_token_at_45(token& token, context_type& context) + { + if (match_doc_string_separator(context, token)) { + build(context, token); + return 46; + } + if (match_other(context, token)) { + build(context, token); + return 45; + } + + /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = "#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 45; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 + std::size_t match_token_at_46(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 46; + } + if (match_empty(context, token)) { + build(context, token); + return 46; + } + + /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 46; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 + std::size_t match_token_at_47(token& token, context_type& context) + { + if (match_doc_string_separator(context, token)) { + build(context, token); + return 48; + } + if (match_other(context, token)) { + build(context, token); + return 47; + } + + /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = "#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 47; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 + std::size_t match_token_at_48(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 48; + } + if (match_empty(context, token)) { + build(context, token); + return 48; + } + + /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 48; + } + + // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 + std::size_t match_token_at_49(token& token, context_type& context) + { + if (match_doc_string_separator(context, token)) { + build(context, token); + return 50; + } + if (match_other(context, token)) { + build(context, token); + return 49; + } + + /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = "#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 49; + } + + // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 + std::size_t match_token_at_50(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 50; + } + if (match_empty(context, token)) { + build(context, token); + return 50; + } + + /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? error_type::unexpected_eof + : error_type::unexpected_token + ; + + if (context.stop_at_first_error) { + //throw_error(error, token, expected_tokens); + } + + context.add_error(expected_tokens); + + return 50; + } + + std::size_t match_token(std::size_t state, token& token, context_type& context) + { + switch (state) { + case 0: + return match_token_at_0(token, context); + case 1: + return match_token_at_1(token, context); + case 2: + return match_token_at_2(token, context); + case 3: + return match_token_at_3(token, context); + case 4: + return match_token_at_4(token, context); + case 5: + return match_token_at_5(token, context); + case 6: + return match_token_at_6(token, context); + case 7: + return match_token_at_7(token, context); + case 8: + return match_token_at_8(token, context); + case 9: + return match_token_at_9(token, context); + case 10: + return match_token_at_10(token, context); + case 11: + return match_token_at_11(token, context); + case 12: + return match_token_at_12(token, context); + case 13: + return match_token_at_13(token, context); + case 14: + return match_token_at_14(token, context); + case 15: + return match_token_at_15(token, context); + case 16: + return match_token_at_16(token, context); + case 17: + return match_token_at_17(token, context); + case 18: + return match_token_at_18(token, context); + case 19: + return match_token_at_19(token, context); + case 20: + return match_token_at_20(token, context); + case 21: + return match_token_at_21(token, context); + case 22: + return match_token_at_22(token, context); + case 23: + return match_token_at_23(token, context); + case 24: + return match_token_at_24(token, context); + case 25: + return match_token_at_25(token, context); + case 26: + return match_token_at_26(token, context); + case 27: + return match_token_at_27(token, context); + case 28: + return match_token_at_28(token, context); + case 29: + return match_token_at_29(token, context); + case 30: + return match_token_at_30(token, context); + case 31: + return match_token_at_31(token, context); + case 32: + return match_token_at_32(token, context); + case 33: + return match_token_at_33(token, context); + case 34: + return match_token_at_34(token, context); + case 35: + return match_token_at_35(token, context); + case 36: + return match_token_at_36(token, context); + case 37: + return match_token_at_37(token, context); + case 38: + return match_token_at_38(token, context); + case 39: + return match_token_at_39(token, context); + case 40: + return match_token_at_40(token, context); + case 41: + return match_token_at_41(token, context); + case 43: + return match_token_at_43(token, context); + case 44: + return match_token_at_44(token, context); + case 45: + return match_token_at_45(token, context); + case 46: + return match_token_at_46(token, context); + case 47: + return match_token_at_47(token, context); + case 48: + return match_token_at_48(token, context); + case 49: + return match_token_at_49(token, context); + case 50: + return match_token_at_50(token, context); + default: + context.add_error("invalid operation: " + std::to_string(state)); + return -1; + } + } +}; + +} diff --git a/cpp/include/gherkin/builder.hpp b/cpp/include/gherkin/builder.hpp new file mode 100644 index 000000000..cba657c00 --- /dev/null +++ b/cpp/include/gherkin/builder.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include +#include + +#include +#include + +namespace gherkin { + +template +struct builder +{ + using result_type = T; + + virtual void reset(const std::string& uri = "") + {} + + virtual void start_rule(rule_type rule_type) + {} + + virtual void end_rule(rule_type rule_type) + {} + + virtual void build(const token& token) + {} + + result_type get_result() const + { return {}; } +}; + +template +using builder_ptr = std::unique_ptr>; + +template < + typename Builder, + typename T, + typename... Args +> +builder_ptr +new_builder(Args&&... args) +{ return std::make_unique(std::forward(args)...); } + +} diff --git a/cpp/include/gherkin/data.hpp b/cpp/include/gherkin/data.hpp deleted file mode 100644 index 6364b7e1a..000000000 --- a/cpp/include/gherkin/data.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -#include - -namespace gherkin { - -struct data -{ - cms::gherkin_document document; - gherkin::pickles pickles; -}; - -} diff --git a/cpp/include/gherkin/msg_types.hpp b/cpp/include/gherkin/msg_types.hpp index 419aa2376..0e755ce3b 100644 --- a/cpp/include/gherkin/msg_types.hpp +++ b/cpp/include/gherkin/msg_types.hpp @@ -15,5 +15,6 @@ using pickle_table_cells = std::vector; using steps = std::vector; using tags = std::vector; using table_cells = std::vector; +using envelopes = std::vector; } diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index c0df87c1e..c02505036 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,16 +1,41 @@ -#pragma once - -#include +#include +#include +#include +#include namespace gherkin { -class parser : public parser_base +template < + typename Builder = ast_builder +> +class parser : public basic_parser { public: - using parser_base::parser_base; - using parser_base::parse; + using parent = basic_parser; + using parent::basic_parser; + using result_type = typename parent::result_type; + + envelopes parse(const file& file) + { + return + parse(cms::source{ + .uri = file.path, + .data = slurp(file.path) + }); + } - const cms::gherkin_document& parse(const cms::source& source) override; + // TODO: add more of these with proper move semantics... + result_type parse(const std::string& uri, const std::string& data) + { + return + parse(cms::source{ + .uri = uri, + .data = data + }); + } + +private: }; + } diff --git a/cpp/include/gherkin/parser_base.hpp b/cpp/include/gherkin/parser_base.hpp index 5107a7f80..155d1162d 100644 --- a/cpp/include/gherkin/parser_base.hpp +++ b/cpp/include/gherkin/parser_base.hpp @@ -1,40 +1,69 @@ #pragma once +#include + #include #include #include #include -#include #include -#include +#include namespace gherkin { namespace cms = cucumber::messages; +template < + typename Builder = ast_builder, + typename Scanner = token_scanner, + typename Matcher = token_matcher +> class parser_base { public: - parser_base(const parser_info& pi = {}); - virtual ~parser_base(); + using result_type = typename Builder::result_type; + using context_type = parser_context; - data parse(const std::string& data); - data parse(const gherkin::file& file); + parser_base(const parser_info& pi = {}) + : pi_{pi} + {} - const cms::gherkin_document& get_result() const; + virtual ~parser_base() + {} protected: - void reset(const cms::source& source); - data parse_from_source(const cms::source& source); + void reset(std::string_view uri, std::string_view data) + { + builder_.reset(uri); + scanner_.reset(data); + matcher_.reset(); + } + + result_type parse(std::string_view uri, std::string_view data) + { + reset(uri, data); + + context_type context{ + .builder = builder_, + .scanner = scanner_, + .matcher = matcher_ + }; + + parse(context); + + return get_result(); + } + + result_type get_result() const + { return builder_.get_result(); } - // Concrete implementation in derived classes - virtual const cms::gherkin_document& parse(const cms::source& source) = 0; + virtual void parse(context_type& context) = 0; parser_info pi_; - ast_builder builder_; - token_scanner scanner_; - token_matcher matcher_; + Builder builder_; + Scanner scanner_; + Matcher matcher_; }; } diff --git a/cpp/include/gherkin/parser_context.hpp b/cpp/include/gherkin/parser_context.hpp new file mode 100644 index 000000000..ccb10e1b3 --- /dev/null +++ b/cpp/include/gherkin/parser_context.hpp @@ -0,0 +1,48 @@ +#include +#include + +namespace gherkin { + +template < + typename Builder, + typename Scanner, + typename Matcher +> +struct parser_context +{ + Builder& builder; + Scanner& scanner; + Matcher& matcher; + + token_queue queue; + strings errors; + bool stop_at_first_error = false; + + bool has_token() const + { return !queue.empty(); } + + token pop_token() + { + auto t = std::move(queue.front()); + queue.pop_front(); + + return t; + } + + token read_token() + { return has_token() ? pop_token() : scanner.read(); } + + void push_tokens(const token_queue& q) + { queue.insert(queue.end(), q.begin(), q.end()); } + + bool has_errors() const + { return !errors.empty(); } + + void add_error(const std::string& e) + { errors.push_back(e); } + + void add_error(const std::exception& e) + { add_error(e.what()); } +}; + +} diff --git a/cpp/include/gherkin/parser_info.hpp b/cpp/include/gherkin/parser_info.hpp index 014d53752..685564bf4 100644 --- a/cpp/include/gherkin/parser_info.hpp +++ b/cpp/include/gherkin/parser_info.hpp @@ -1,15 +1,19 @@ #pragma once #include +#include namespace gherkin { +using id_generator_func = std::function; + struct parser_info { std::string language = "en"; - bool source_events = true; - bool ast_events = true; - bool pickle_events = true; + bool include_source = true; + bool include_ast = true; + bool include_pickles = true; + id_generator_func id_generator; }; } diff --git a/cpp/include/gherkin/token_scanner.hpp b/cpp/include/gherkin/token_scanner.hpp index 5c3e26592..514f0fa1d 100644 --- a/cpp/include/gherkin/token_scanner.hpp +++ b/cpp/include/gherkin/token_scanner.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -19,13 +19,13 @@ class token_scanner { public: token_scanner(); - token_scanner(const std::string& text); + token_scanner(std::string_view data); token_scanner(const file& file); virtual ~token_scanner(); void reset(); - void reset(const std::string& text); + void reset(std::string_view data); void reset(const file& file); token read(); diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 2b203119d..bf2a7ce3b 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -22,11 +22,11 @@ parse_options(int ac, char** av) std::string_view arg(av[opts.last_arg]); if (arg == "--no-source") { - opts.pi.source_events = false; + opts.pi.include_source = false; } else if (arg == "--no-ast") { - opts.pi.ast_events = false; + opts.pi.include_ast = false; } else if (arg == "--no-pickles") { - opts.pi.pickle_events = false; + opts.pi.include_pickles = false; } else if (arg.starts_with('-')) { if (arg != "-h" && arg != "--help") { std::cout << "Unknown option: " << arg << std::endl; @@ -59,11 +59,11 @@ int main(int ac, char** av) return opts.exit_code; } - gherkin::parser p(opts.pi); + /*gherkin::parser p(opts.pi); for ( ; opts.last_arg < ac; ++opts.last_arg) { p.parse(gherkin::file{ av[opts.last_arg] }); - } + }*/ return 0; } diff --git a/cpp/src/lib/gherkin/CMakeLists.txt b/cpp/src/lib/gherkin/CMakeLists.txt index 437219e36..a25d9d98a 100644 --- a/cpp/src/lib/gherkin/CMakeLists.txt +++ b/cpp/src/lib/gherkin/CMakeLists.txt @@ -9,14 +9,8 @@ file(GLOB_RECURSE GHERKIN_CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.[ch]pp) target_sources( gherkin-cpp - PUBLIC - FILE_SET - "gherkin_cpp_headers" - TYPE HEADERS - BASE_DIRS ${INC_DIR} - FILES - ${GHERKIN_CPP_HEADERS} PRIVATE + ${GHERKIN_CPP_HEADERS} ${GHERKIN_CPP_SOURCES} ) diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 5a8b222f3..fa4a29e06 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -9,15 +9,13 @@ namespace gherkin { ast_builder::ast_builder() -{ - reset(); -} +{} ast_builder::~ast_builder() {} void -ast_builder::reset(const std::string& uri) +ast_builder::reset(std::string_view uri) { stack_ = {}; stack_.emplace(rule_type::none); @@ -349,7 +347,7 @@ cms::gherkin_document ast_builder::make_gherkin_document(ast_node& node) { cms::gherkin_document gd{ - .uri = uri_, + .uri = std::string(uri_), .comments = comments_ }; diff --git a/cpp/src/lib/gherkin/parser.cpp b/cpp/src/lib/gherkin/parser.cpp deleted file mode 100644 index c5fc1037c..000000000 --- a/cpp/src/lib/gherkin/parser.cpp +++ /dev/null @@ -1,4762 +0,0 @@ -// This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. -#include - -#include -#include -#include -#include - -namespace gherkin { - -struct parser_context -{ - ast_builder& builder; - token_scanner& scanner; - token_matcher& matcher; - token_queue queue; - strings errors; - bool stop_at_first_error = false; - - bool has_token() const - { return !queue.empty(); } - - token pop_token() - { - auto t = std::move(queue.front()); - queue.pop_front(); - - return t; - } - - token read_token() - { return has_token() ? pop_token() : scanner.read(); } - - void push_tokens(const token_queue& q) - { queue.insert(queue.end(), q.begin(), q.end()); } - - bool has_errors() const - { return !errors.empty(); } - - void add_error(const std::string& e) - { errors.push_back(e); } - - void add_error(const std::exception& e) - { add_error(e.what()); } -}; - -enum class error_type -{ - unexpected_eof, - unexpected_token -}; - -using match_function = std::function; -using match_functions = std::unordered_map; - -static void start_rule(parser_context& context, rule_type rule_type); - -static void end_rule(parser_context& context, rule_type rule_type); - -static std::size_t match_token( - std::size_t state, - token& token, - parser_context& context -); - -template -bool -handle_external_error( - parser_context& context, - bool default_value, - Argument&& argument, - Action&& action -) -{ - using ret_type = decltype(action(argument)); - - if (context.stop_at_first_error) { - if constexpr (std::is_same_v) { - action(argument); - return default_value; - } else { - return action(argument); - } - } - - try { - if constexpr (std::is_same_v) { - action(argument); - return default_value; - } else { - return action(argument); - } - } catch (const std::exception& e) { - context.add_error(e); - } - - return default_value; -} - -template -void -handle_ast_error( - parser_context& context, - Argument&& argument, - Action&& action -) -{ handle_external_error(context, true, argument, action); } - -const cms::gherkin_document& -parser::parse(const cms::source& source) -{ - parser_context context{ - .builder = builder_, - .scanner = scanner_, - .matcher = matcher_ - }; - - start_rule(context, rule_type::gherkin_document); - - std::size_t state = 0; - - while (true) { - auto token = context.read_token(); - state = match_token(state, token, context); - - if (token.is_eof()) { - break; - } - } - - end_rule(context, rule_type::gherkin_document); - - if (context.has_errors()) { - // TODO: thow coumpound error - } - - return get_result(); -} - -static -void -build(parser_context& context, token& token) -{ context.builder.build(token); } - -static -void -start_rule(parser_context& context, rule_type rule_type) -{ - handle_ast_error( - context, - rule_type, - [&context](auto rtype) { - context.builder.start_rule(rtype); - } - ); -} - -static -void -end_rule(parser_context& context, rule_type rule_type) -{ - handle_ast_error( - context, - rule_type, - [&context](auto rtype) { - context.builder.end_rule(rtype); - } - ); -} - -namespace detail { - - -static -bool -match_e_o_f(parser_context& context, token& token) -{ - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_e_o_f(t); - } - ); -} - -static -bool -match_empty(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_empty(t); - } - ); -} - -static -bool -match_comment(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_comment(t); - } - ); -} - -static -bool -match_tag_line(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_tag_line(t); - } - ); -} - -static -bool -match_feature_line(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_feature_line(t); - } - ); -} - -static -bool -match_rule_line(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_rule_line(t); - } - ); -} - -static -bool -match_background_line(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_background_line(t); - } - ); -} - -static -bool -match_scenario_line(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_scenario_line(t); - } - ); -} - -static -bool -match_examples_line(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_examples_line(t); - } - ); -} - -static -bool -match_step_line(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_step_line(t); - } - ); -} - -static -bool -match_doc_string_separator(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_doc_string_separator(t); - } - ); -} - -static -bool -match_table_row(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_table_row(t); - } - ); -} - -static -bool -match_language(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_language(t); - } - ); -} - -static -bool -match_other(parser_context& context, token& token) -{ - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_other(t); - } - ); -} - - -static -bool -lookahead_0(parser_context& context, token& current_token) -{ - current_token.detach(); - token token; - token_queue queue; - bool match = false; - - while (true) { - token = context.read_token(); - token.detach(); - queue.push_back(token); - - if (match_scenario_line(context, token) || false) { - match = true; - break; - } - - if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { - break; - } - } - - context.push_tokens(queue); - - return match; -} - -static -bool -lookahead_1(parser_context& context, token& current_token) -{ - current_token.detach(); - token token; - token_queue queue; - bool match = false; - - while (true) { - token = context.read_token(); - token.detach(); - queue.push_back(token); - - if (match_examples_line(context, token) || false) { - match = true; - break; - } - - if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { - break; - } - } - - context.push_tokens(queue); - - return match; -} - - -// Start -static -std::size_t -match_token_at_0(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - build(context, token); - return 42; - } - if (match_language(context, token)) { - start_rule(context, rule_type::feature); - start_rule(context, rule_type::feature_header); - build(context, token); - return 1; - } - if (match_tag_line(context, token)) { - start_rule(context, rule_type::feature); - start_rule(context, rule_type::feature_header); - start_rule(context, rule_type::tags); - build(context, token); - return 2; - } - if (match_feature_line(context, token)) { - start_rule(context, rule_type::feature); - start_rule(context, rule_type::feature_header); - build(context, token); - return 3; - } - if (match_comment(context, token)) { - build(context, token); - return 0; - } - if (match_empty(context, token)) { - build(context, token); - return 0; - } - - - /* "State: 0 - Start" */ - std::string expected_tokens = "#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 0;} - -// GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 -static -std::size_t -match_token_at_1(token& token, parser_context& context) -{ - if (match_tag_line(context, token)) { - start_rule(context, rule_type::tags); - build(context, token); - return 2; - } - if (match_feature_line(context, token)) { - build(context, token); - return 3; - } - if (match_comment(context, token)) { - build(context, token); - return 1; - } - if (match_empty(context, token)) { - build(context, token); - return 1; - } - - - /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ - std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 1;} - -// GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 -static -std::size_t -match_token_at_2(token& token, parser_context& context) -{ - if (match_tag_line(context, token)) { - build(context, token); - return 2; - } - if (match_feature_line(context, token)) { - end_rule(context, rule_type::tags); - build(context, token); - return 3; - } - if (match_comment(context, token)) { - build(context, token); - return 2; - } - if (match_empty(context, token)) { - build(context, token); - return 2; - } - - - /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 2;} - -// GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 -static -std::size_t -match_token_at_3(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::feature_header); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 3; - } - if (match_comment(context, token)) { - build(context, token); - return 5; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::background); - build(context, token); - return 6; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 4; - } - - - /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 3;} - -// GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 -static -std::size_t -match_token_at_4(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 5; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::background); - build(context, token); - return 6; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 4; - } - - - /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 4;} - -// GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 -static -std::size_t -match_token_at_5(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::feature_header); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 5; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::background); - build(context, token); - return 6; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 5; - } - - - /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 5;} - -// GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 -static -std::size_t -match_token_at_6(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 6; - } - if (match_comment(context, token)) { - build(context, token); - return 8; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 7; - } - - - /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 6;} - -// GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 -static -std::size_t -match_token_at_7(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 8; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 7; - } - - - /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 7;} - -// GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 -static -std::size_t -match_token_at_8(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 8; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 8; - } - - - /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 8;} - -// GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 -static -std::size_t -match_token_at_9(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::data_table); - build(context, token); - return 10; - } - if (match_doc_string_separator(context, token)) { - start_rule(context, rule_type::doc_string); - build(context, token); - return 49; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 9; - } - if (match_empty(context, token)) { - build(context, token); - return 9; - } - - - /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ - std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 9;} - -// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 -static -std::size_t -match_token_at_10(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 10; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 10; - } - if (match_empty(context, token)) { - build(context, token); - return 10; - } - - - /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 10;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 -static -std::size_t -match_token_at_11(token& token, parser_context& context) -{ - if (match_tag_line(context, token)) { - build(context, token); - return 11; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::tags); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_comment(context, token)) { - build(context, token); - return 11; - } - if (match_empty(context, token)) { - build(context, token); - return 11; - } - - - /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 11;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 -static -std::size_t -match_token_at_12(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 12; - } - if (match_comment(context, token)) { - build(context, token); - return 14; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 13; - } - - - /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 12;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 -static -std::size_t -match_token_at_13(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 14; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 13; - } - - - /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 13;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 -static -std::size_t -match_token_at_14(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 14; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 14; - } - - - /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 14;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 -static -std::size_t -match_token_at_15(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::data_table); - build(context, token); - return 16; - } - if (match_doc_string_separator(context, token)) { - start_rule(context, rule_type::doc_string); - build(context, token); - return 47; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 15; - } - if (match_empty(context, token)) { - build(context, token); - return 15; - } - - - /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ - std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 15;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 -static -std::size_t -match_token_at_16(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 16; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 16; - } - if (match_empty(context, token)) { - build(context, token); - return 16; - } - - - /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 16;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 -static -std::size_t -match_token_at_17(token& token, parser_context& context) -{ - if (match_tag_line(context, token)) { - build(context, token); - return 17; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::tags); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_comment(context, token)) { - build(context, token); - return 17; - } - if (match_empty(context, token)) { - build(context, token); - return 17; - } - - - /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 17;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 -static -std::size_t -match_token_at_18(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 18; - } - if (match_comment(context, token)) { - build(context, token); - return 20; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::examples_table); - build(context, token); - return 21; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 19; - } - - - /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 18;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 -static -std::size_t -match_token_at_19(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 20; - } - if (match_table_row(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_table); - build(context, token); - return 21; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 19; - } - - - /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 19;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 -static -std::size_t -match_token_at_20(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 20; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::examples_table); - build(context, token); - return 21; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 20; - } - - - /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 20;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 -static -std::size_t -match_token_at_21(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 21; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 21; - } - if (match_empty(context, token)) { - build(context, token); - return 21; - } - - - /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 21;} - -// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 -static -std::size_t -match_token_at_22(token& token, parser_context& context) -{ - if (match_tag_line(context, token)) { - build(context, token); - return 22; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::tags); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 22; - } - if (match_empty(context, token)) { - build(context, token); - return 22; - } - - - /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 22;} - -// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 -static -std::size_t -match_token_at_23(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 25; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::background); - build(context, token); - return 26; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 24; - } - - - /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 23;} - -// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 -static -std::size_t -match_token_at_24(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 25; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::background); - build(context, token); - return 26; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 24; - } - - - /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 24;} - -// GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 -static -std::size_t -match_token_at_25(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 25; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::background); - build(context, token); - return 26; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 25; - } - - - /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 25;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 -static -std::size_t -match_token_at_26(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 26; - } - if (match_comment(context, token)) { - build(context, token); - return 28; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 27; - } - - - /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 26;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 -static -std::size_t -match_token_at_27(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 28; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 27; - } - - - /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 27;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 -static -std::size_t -match_token_at_28(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 28; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 28; - } - - - /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 28;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 -static -std::size_t -match_token_at_29(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::data_table); - build(context, token); - return 30; - } - if (match_doc_string_separator(context, token)) { - start_rule(context, rule_type::doc_string); - build(context, token); - return 45; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 29; - } - if (match_empty(context, token)) { - build(context, token); - return 29; - } - - - /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ - std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 29;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 -static -std::size_t -match_token_at_30(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 30; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 30; - } - if (match_empty(context, token)) { - build(context, token); - return 30; - } - - - /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 30;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 -static -std::size_t -match_token_at_31(token& token, parser_context& context) -{ - if (match_tag_line(context, token)) { - build(context, token); - return 31; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::tags); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_comment(context, token)) { - build(context, token); - return 31; - } - if (match_empty(context, token)) { - build(context, token); - return 31; - } - - - /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 31;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 -static -std::size_t -match_token_at_32(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 32; - } - if (match_comment(context, token)) { - build(context, token); - return 34; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 33; - } - - - /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 32;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 -static -std::size_t -match_token_at_33(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 34; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 33; - } - - - /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 33;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 -static -std::size_t -match_token_at_34(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 34; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 34; - } - - - /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 34;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 -static -std::size_t -match_token_at_35(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::data_table); - build(context, token); - return 36; - } - if (match_doc_string_separator(context, token)) { - start_rule(context, rule_type::doc_string); - build(context, token); - return 43; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 35; - } - if (match_empty(context, token)) { - build(context, token); - return 35; - } - - - /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ - std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 35;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 -static -std::size_t -match_token_at_36(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 36; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 36; - } - if (match_empty(context, token)) { - build(context, token); - return 36; - } - - - /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 36;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 -static -std::size_t -match_token_at_37(token& token, parser_context& context) -{ - if (match_tag_line(context, token)) { - build(context, token); - return 37; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::tags); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_comment(context, token)) { - build(context, token); - return 37; - } - if (match_empty(context, token)) { - build(context, token); - return 37; - } - - - /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 37;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 -static -std::size_t -match_token_at_38(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 38; - } - if (match_comment(context, token)) { - build(context, token); - return 40; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::examples_table); - build(context, token); - return 41; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 39; - } - - - /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 38;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 -static -std::size_t -match_token_at_39(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 40; - } - if (match_table_row(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_table); - build(context, token); - return 41; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 39; - } - - - /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 39;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 -static -std::size_t -match_token_at_40(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 40; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::examples_table); - build(context, token); - return 41; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 40; - } - - - /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 40;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 -static -std::size_t -match_token_at_41(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 41; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 41; - } - if (match_empty(context, token)) { - build(context, token); - return 41; - } - - - /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 41;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 -static -std::size_t -match_token_at_43(token& token, parser_context& context) -{ - if (match_doc_string_separator(context, token)) { - build(context, token); - return 44; - } - if (match_other(context, token)) { - build(context, token); - return 43; - } - - - /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = "#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 43;} - -// GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 -static -std::size_t -match_token_at_44(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 44; - } - if (match_empty(context, token)) { - build(context, token); - return 44; - } - - - /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 44;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 -static -std::size_t -match_token_at_45(token& token, parser_context& context) -{ - if (match_doc_string_separator(context, token)) { - build(context, token); - return 46; - } - if (match_other(context, token)) { - build(context, token); - return 45; - } - - - /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = "#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 45;} - -// GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 -static -std::size_t -match_token_at_46(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 46; - } - if (match_empty(context, token)) { - build(context, token); - return 46; - } - - - /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 46;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 -static -std::size_t -match_token_at_47(token& token, parser_context& context) -{ - if (match_doc_string_separator(context, token)) { - build(context, token); - return 48; - } - if (match_other(context, token)) { - build(context, token); - return 47; - } - - - /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = "#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 47;} - -// GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 -static -std::size_t -match_token_at_48(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 48; - } - if (match_empty(context, token)) { - build(context, token); - return 48; - } - - - /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 48;} - -// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 -static -std::size_t -match_token_at_49(token& token, parser_context& context) -{ - if (match_doc_string_separator(context, token)) { - build(context, token); - return 50; - } - if (match_other(context, token)) { - build(context, token); - return 49; - } - - - /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = "#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 49;} - -// GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 -static -std::size_t -match_token_at_50(token& token, parser_context& context) -{ - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 50; - } - if (match_empty(context, token)) { - build(context, token); - return 50; - } - - - /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token - ; - - if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); - } - - context.add_error(expected_tokens); - - return 50;} - -} // namespace detail - -static -std::size_t -match_token(std::size_t state, token& token, parser_context& context) -{ - switch (state) { - case 0: - return detail::match_token_at_0(token, context); - case 1: - return detail::match_token_at_1(token, context); - case 2: - return detail::match_token_at_2(token, context); - case 3: - return detail::match_token_at_3(token, context); - case 4: - return detail::match_token_at_4(token, context); - case 5: - return detail::match_token_at_5(token, context); - case 6: - return detail::match_token_at_6(token, context); - case 7: - return detail::match_token_at_7(token, context); - case 8: - return detail::match_token_at_8(token, context); - case 9: - return detail::match_token_at_9(token, context); - case 10: - return detail::match_token_at_10(token, context); - case 11: - return detail::match_token_at_11(token, context); - case 12: - return detail::match_token_at_12(token, context); - case 13: - return detail::match_token_at_13(token, context); - case 14: - return detail::match_token_at_14(token, context); - case 15: - return detail::match_token_at_15(token, context); - case 16: - return detail::match_token_at_16(token, context); - case 17: - return detail::match_token_at_17(token, context); - case 18: - return detail::match_token_at_18(token, context); - case 19: - return detail::match_token_at_19(token, context); - case 20: - return detail::match_token_at_20(token, context); - case 21: - return detail::match_token_at_21(token, context); - case 22: - return detail::match_token_at_22(token, context); - case 23: - return detail::match_token_at_23(token, context); - case 24: - return detail::match_token_at_24(token, context); - case 25: - return detail::match_token_at_25(token, context); - case 26: - return detail::match_token_at_26(token, context); - case 27: - return detail::match_token_at_27(token, context); - case 28: - return detail::match_token_at_28(token, context); - case 29: - return detail::match_token_at_29(token, context); - case 30: - return detail::match_token_at_30(token, context); - case 31: - return detail::match_token_at_31(token, context); - case 32: - return detail::match_token_at_32(token, context); - case 33: - return detail::match_token_at_33(token, context); - case 34: - return detail::match_token_at_34(token, context); - case 35: - return detail::match_token_at_35(token, context); - case 36: - return detail::match_token_at_36(token, context); - case 37: - return detail::match_token_at_37(token, context); - case 38: - return detail::match_token_at_38(token, context); - case 39: - return detail::match_token_at_39(token, context); - case 40: - return detail::match_token_at_40(token, context); - case 41: - return detail::match_token_at_41(token, context); - case 43: - return detail::match_token_at_43(token, context); - case 44: - return detail::match_token_at_44(token, context); - case 45: - return detail::match_token_at_45(token, context); - case 46: - return detail::match_token_at_46(token, context); - case 47: - return detail::match_token_at_47(token, context); - case 48: - return detail::match_token_at_48(token, context); - case 49: - return detail::match_token_at_49(token, context); - case 50: - return detail::match_token_at_50(token, context); - default: - context.add_error("invalid operation: " + std::to_string(state)); - return -1; - } -} - -} diff --git a/cpp/src/lib/gherkin/parser_base.cpp b/cpp/src/lib/gherkin/parser_base.cpp deleted file mode 100644 index b4443ed3e..000000000 --- a/cpp/src/lib/gherkin/parser_base.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include - -#include -#include - -namespace gherkin { - -parser_base::parser_base(const parser_info& pi) -: pi_(pi) -{} - -parser_base::~parser_base() -{} - -data -parser_base::parse(const std::string& data) -{ return parse_from_source({ .data = data }); } - -data -parser_base::parse(const gherkin::file& file) -{ - return parse_from_source({ - .uri = file.path, - .data = slurp(file.path) - }); -} - -void -parser_base::reset(const cms::source& source) -{ - builder_.reset(source.uri); - scanner_.reset(source.data); - matcher_.reset(); -} - -data -parser_base::parse_from_source(const cms::source& source) -{ - data data; - - if (pi_.source_events) { - - } - - if (pi_.ast_events || pi_.pickle_events) { - reset(source); - - data.document = parse(source); - - if (pi_.ast_events) { - - } - - if (pi_.pickle_events) { - gherkin::pickle_compiler c; - - data.pickles = c.compile(data.document, source.uri); - } - } - - return data; -} - -const cms::gherkin_document& -parser_base::get_result() const -{ return builder_.get_result(); } - -} diff --git a/cpp/src/lib/gherkin/token_scanner.cpp b/cpp/src/lib/gherkin/token_scanner.cpp index 50d32a3ea..2a8310db9 100644 --- a/cpp/src/lib/gherkin/token_scanner.cpp +++ b/cpp/src/lib/gherkin/token_scanner.cpp @@ -8,8 +8,8 @@ namespace gherkin { token_scanner::token_scanner() {} -token_scanner::token_scanner(const std::string& text) -{ reset(text); } +token_scanner::token_scanner(std::string_view data) +{ reset(data); } token_scanner::token_scanner(const file& file) { reset(file); } @@ -38,10 +38,10 @@ token_scanner::reset() } void -token_scanner::reset(const std::string& text) +token_scanner::reset(std::string_view data) { reset(); - ip_ = std::make_unique(text); + ip_ = std::make_unique(std::string(data)); } void From eaac12b136fda814ebe98e8c085123dffb358247 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 22 May 2023 19:05:50 +0200 Subject: [PATCH 31/76] chore: first feature tokens ok --- cpp/.gitignore | 2 + cpp/CMakeLists.txt | 5 +- cpp/Makefile | 7 +- cpp/cmake/toolchains/ext.cmake | 13 - cpp/gherkin-dialect.cpp.jq | 9 +- cpp/include/gherkin/ast_builder.hpp | 2 + cpp/include/gherkin/basic_parser.hpp | 4 +- cpp/include/gherkin/dialect.hpp | 9 - cpp/include/gherkin/keywords.hpp | 14 + cpp/include/gherkin/parser.hpp | 19 +- cpp/include/gherkin/parser_info.hpp | 6 + cpp/include/gherkin/regex.hpp | 13 + .../gherkin/token_formatter_builder.hpp | 40 + .../gherkin-generate-tokens/CMakeLists.txt | 26 + .../gherkin-generate-tokens.cpp | 25 + cpp/src/bin/gherkin/gherkin.cpp | 4 +- cpp/src/lib/gherkin/dialect.cpp | 827 +++++++++--------- cpp/src/lib/gherkin/keywords.cpp | 40 + cpp/src/lib/gherkin/line.cpp | 25 +- cpp/src/lib/gherkin/regex.cpp | 52 ++ cpp/src/lib/gherkin/rule_type.cpp | 66 +- .../lib/gherkin/token_formatter_builder.cpp | 78 ++ cpp/src/lib/gherkin/token_matcher.cpp | 4 +- cpp/src/lib/gherkin/token_scanner.cpp | 4 +- 24 files changed, 776 insertions(+), 518 deletions(-) create mode 100644 cpp/include/gherkin/keywords.hpp create mode 100644 cpp/include/gherkin/token_formatter_builder.hpp create mode 100644 cpp/src/bin/gherkin-generate-tokens/CMakeLists.txt create mode 100644 cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp create mode 100644 cpp/src/lib/gherkin/keywords.cpp create mode 100644 cpp/src/lib/gherkin/regex.cpp create mode 100644 cpp/src/lib/gherkin/token_formatter_builder.cpp diff --git a/cpp/.gitignore b/cpp/.gitignore index 38926f72f..d1e3352ae 100644 --- a/cpp/.gitignore +++ b/cpp/.gitignore @@ -1,4 +1,6 @@ ext/ build/ +acceptance/ +stage/ .built .configured diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index f8b7da6b4..754d6224a 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -13,10 +13,13 @@ find_package(cucumber-messages CONFIG REQUIRED) add_subdirectory(src/lib/gherkin) add_subdirectory(src/bin/gherkin) +add_subdirectory(src/bin/gherkin-generate-tokens) install( TARGETS - gherkin-cpp gherkin-bin + gherkin-cpp + gherkin-bin + gherkin-generate-tokens-bin EXPORT gherkin-cpp-config RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/cpp/Makefile b/cpp/Makefile index fd0a5c140..e07300bb8 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -5,8 +5,8 @@ GHERKIN_GENERATED = \ include/gherkin/rule_type.hpp \ include/gherkin/basic_parser.hpp \ src/lib/gherkin/dialect.cpp -GHERKIN = bin/gherkin -GHERKIN_GENERATE_TOKENS = bin/gherkin-generate-tokens +GHERKIN = stage/bin/gherkin +GHERKIN_GENERATE_TOKENS = stage/bin/gherkin-generate-tokens GOOD_FEATURE_FILES = $(shell find ../testdata/good -name "*.feature") BAD_FEATURE_FILES = $(shell find ../testdata/bad -name "*.feature") @@ -64,12 +64,13 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac --build build/gherkin \ --parallel \ && touch $@ + cmake --install build/gherkin .configured: $(CMAKELISTS) rm -rf build/gherkin && mkdir -p build/gherkin cmake \ -DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \ - -DCMAKE_INSTALL_PREFIX=$(CMAKE_BUILDROOT) \ + -DCMAKE_INSTALL_PREFIX=$(HERE)/stage \ -S . \ -B build/gherkin \ --toolchain cmake/toolchains/ext.cmake \ diff --git a/cpp/cmake/toolchains/ext.cmake b/cpp/cmake/toolchains/ext.cmake index d7a716f42..192b99b97 100644 --- a/cpp/cmake/toolchains/ext.cmake +++ b/cpp/cmake/toolchains/ext.cmake @@ -1,23 +1,10 @@ # # CMake toolchain to be used when building external libraries # -set(CMAKE_FIND_ROOT_PATH "${CMAKE_INSTALL_PREFIX}") -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # use, i.e. don't skip the full RPATH for the build tree set(CMAKE_SKIP_BUILD_RPATH FALSE) -# when building, don't use the install RPATH already -# (but later on when installing) -set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - -# add the automatically determined parts of the RPATH -# which point to directories outside the build tree to the install RPATH -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - find_program(CCACHE ccache) if(CCACHE) diff --git a/cpp/gherkin-dialect.cpp.jq b/cpp/gherkin-dialect.cpp.jq index 7fca7432c..73151cc16 100644 --- a/cpp/gherkin-dialect.cpp.jq +++ b/cpp/gherkin-dialect.cpp.jq @@ -5,7 +5,7 @@ "const keywords_map&\n", "keywords(const std::string_view& language)\n", "{\n", - " const keywords_maps kwms = {\n", + " static const keywords_maps kwms = {\n", " ", ( [ @@ -23,9 +23,7 @@ [ "{ \"", .key, "\", { ", ( - [.value[] | - sub("^[[:space:]]+"; "") | sub("[[:space:]]+$"; "") | - [@json] | add] | join(", ") + [.value[] | [@json] | add] | join(", ") ), " } }" ] | add @@ -38,8 +36,5 @@ "\n };\n\n", " return kwms.at(language);\n", "}\n\n", - "const string_views&\n", - "keyword(const std::string_view& language, const std::string_view& kw)\n", - "{ return keywords(language).at(kw); }\n\n", "}\n" ] | add diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index ab319252d..797220568 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -23,6 +23,8 @@ using comments = std::vector; class ast_builder { public: + using result_type = cms::gherkin_document; + ast_builder(); virtual ~ast_builder(); diff --git a/cpp/include/gherkin/basic_parser.hpp b/cpp/include/gherkin/basic_parser.hpp index 77a9356a9..0a177a4cf 100644 --- a/cpp/include/gherkin/basic_parser.hpp +++ b/cpp/include/gherkin/basic_parser.hpp @@ -19,10 +19,12 @@ class basic_parser : public parser_base { public: using parent = parser_base; - using parent::parser_base; + using parent::parent; using context_type = typename parent::context_type; protected: + using parent::parse; + void parse(context_type& context) override { start_rule(context, rule_type::gherkin_document); diff --git a/cpp/include/gherkin/dialect.hpp b/cpp/include/gherkin/dialect.hpp index a3d3461b0..6a7d30c90 100644 --- a/cpp/include/gherkin/dialect.hpp +++ b/cpp/include/gherkin/dialect.hpp @@ -25,13 +25,4 @@ struct dialect const keywords_map& keywords(const std::string_view& language); -const string_views& -keywords(const std::string_view& language, const std::string_view& kw); - -string_views -keywords(const std::string_view& language, const string_views& kws); - -dialect -get_dialect(const std::string_view& language); - } diff --git a/cpp/include/gherkin/keywords.hpp b/cpp/include/gherkin/keywords.hpp new file mode 100644 index 000000000..13a011d32 --- /dev/null +++ b/cpp/include/gherkin/keywords.hpp @@ -0,0 +1,14 @@ +#include + +namespace gherkin { + +const string_views& +keywords(const std::string_view& language, const std::string_view& kw); + +string_views +keywords(const std::string_view& language, const string_views& kws); + +dialect +get_dialect(const std::string_view& language); + +} diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index c02505036..e1b7faf06 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -12,10 +12,13 @@ class parser : public basic_parser { public: using parent = basic_parser; - using parent::basic_parser; using result_type = typename parent::result_type; - envelopes parse(const file& file) + parser(const parser_info& pi = {}) + : parent(pi) + {} + + result_type parse(const file& file) { return parse(cms::source{ @@ -24,18 +27,10 @@ class parser : public basic_parser }); } - // TODO: add more of these with proper move semantics... - result_type parse(const std::string& uri, const std::string& data) - { - return - parse(cms::source{ - .uri = uri, - .data = data - }); - } + result_type parse(const cms::source& source) + { return parent::parse(source.uri, source.data); } private: }; - } diff --git a/cpp/include/gherkin/parser_info.hpp b/cpp/include/gherkin/parser_info.hpp index 685564bf4..d9be23f71 100644 --- a/cpp/include/gherkin/parser_info.hpp +++ b/cpp/include/gherkin/parser_info.hpp @@ -2,11 +2,16 @@ #include #include +#include namespace gherkin { using id_generator_func = std::function; +using json = nlohmann::json; + +using json_cb = std::function; + struct parser_info { std::string language = "en"; @@ -14,6 +19,7 @@ struct parser_info bool include_ast = true; bool include_pickles = true; id_generator_func id_generator; + json_cb sink; }; } diff --git a/cpp/include/gherkin/regex.hpp b/cpp/include/gherkin/regex.hpp index 9f37ce636..85743a0e6 100644 --- a/cpp/include/gherkin/regex.hpp +++ b/cpp/include/gherkin/regex.hpp @@ -16,6 +16,19 @@ struct regex_result string_views matches; }; +void +split( + const std::string& re, + const std::string& expr, + strings& list +); + +strings +split(const std::string& re, const std::string& expr); + +std::string +subst(const std::string& s, const std::string& re, const std::string& what); + namespace detail { struct null_arg{}; diff --git a/cpp/include/gherkin/token_formatter_builder.hpp b/cpp/include/gherkin/token_formatter_builder.hpp new file mode 100644 index 000000000..d72402b42 --- /dev/null +++ b/cpp/include/gherkin/token_formatter_builder.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include + +#include +#include +#include + +namespace gherkin { + +namespace cms = cucumber::messages; + +using table_rows = std::vector; +using table_cells = std::vector; +using tags = std::vector; +using comments = std::vector; + +class token_formatter_builder +{ +public: + using result_type = strings; + + token_formatter_builder(); + virtual ~token_formatter_builder(); + + void reset(std::string_view uri); + + void start_rule(rule_type rule_type); + void end_rule(rule_type rule_type); + void build(const token& token); + + strings get_result() const; + +private: + std::string format_token(const token& token); + + strings formatted_tokens_; +}; + +} diff --git a/cpp/src/bin/gherkin-generate-tokens/CMakeLists.txt b/cpp/src/bin/gherkin-generate-tokens/CMakeLists.txt new file mode 100644 index 000000000..8060f2dcb --- /dev/null +++ b/cpp/src/bin/gherkin-generate-tokens/CMakeLists.txt @@ -0,0 +1,26 @@ +add_executable(gherkin-generate-tokens-bin) + +target_sources( + gherkin-generate-tokens-bin + PRIVATE + ${CMAKE_SOURCE_DIR}/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp +) + +target_include_directories( + gherkin-generate-tokens-bin + PRIVATE + ${CMAKE_SOURCE_DIR}/ + ${CMAKE_SOURCE_DIR}/src/bin/gherkin-generate-tokens +) + +target_link_libraries( + gherkin-generate-tokens-bin + PUBLIC + gherkin-cpp +) + +set_target_properties( + gherkin-generate-tokens-bin + PROPERTIES + OUTPUT_NAME gherkin-generate-tokens +) diff --git a/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp b/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp new file mode 100644 index 000000000..925433bf1 --- /dev/null +++ b/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp @@ -0,0 +1,25 @@ +#include +#include + +#include +#include +#include +#include + +int main(int ac, char** av) +{ + using builder = gherkin::token_formatter_builder; + using parser = gherkin::parser; + + parser p; + + for (std::size_t i = 1; i < ac; ++i) { + auto ss = p.parse(gherkin::file{ av[i] }); + + std::cout << gherkin::join("\n", ss); + } + + std::cout << std::endl; + + return 0; +} diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index bf2a7ce3b..262996fb7 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -59,11 +59,11 @@ int main(int ac, char** av) return opts.exit_code; } - /*gherkin::parser p(opts.pi); + gherkin::parser p{opts.pi}; for ( ; opts.last_arg < ac; ++opts.last_arg) { p.parse(gherkin::file{ av[opts.last_arg] }); - }*/ + } return 0; } diff --git a/cpp/src/lib/gherkin/dialect.cpp b/cpp/src/lib/gherkin/dialect.cpp index eae058714..7331937bf 100644 --- a/cpp/src/lib/gherkin/dialect.cpp +++ b/cpp/src/lib/gherkin/dialect.cpp @@ -9,1265 +9,1265 @@ keywords(const std::string_view& language) { "af", { - { "and", { "*", "En" } }, + { "and", { "* ", "En " } }, { "background", { "Agtergrond" } }, - { "but", { "*", "Maar" } }, + { "but", { "* ", "Maar " } }, { "examples", { "Voorbeelde" } }, { "feature", { "Funksie", "Besigheid Behoefte", "Vermoë" } }, - { "given", { "*", "Gegewe" } }, + { "given", { "* ", "Gegewe " } }, { "rule", { "Regel" } }, { "scenario", { "Voorbeeld", "Situasie" } }, { "scenarioOutline", { "Situasie Uiteensetting" } }, - { "then", { "*", "Dan" } }, - { "when", { "*", "Wanneer" } } + { "then", { "* ", "Dan " } }, + { "when", { "* ", "Wanneer " } } } }, { "am", { - { "and", { "*", "Եվ" } }, + { "and", { "* ", "Եվ " } }, { "background", { "Կոնտեքստ" } }, - { "but", { "*", "Բայց" } }, + { "but", { "* ", "Բայց " } }, { "examples", { "Օրինակներ" } }, { "feature", { "Ֆունկցիոնալություն", "Հատկություն" } }, - { "given", { "*", "Դիցուք" } }, + { "given", { "* ", "Դիցուք " } }, { "rule", { "Rule" } }, { "scenario", { "Օրինակ", "Սցենար" } }, { "scenarioOutline", { "Սցենարի կառուցվացքը" } }, - { "then", { "*", "Ապա" } }, - { "when", { "*", "Եթե", "Երբ" } } + { "then", { "* ", "Ապա " } }, + { "when", { "* ", "Եթե ", "Երբ " } } } }, { "an", { - { "and", { "*", "Y", "E" } }, + { "and", { "* ", "Y ", "E " } }, { "background", { "Antecedents" } }, - { "but", { "*", "Pero" } }, + { "but", { "* ", "Pero " } }, { "examples", { "Eixemplos" } }, { "feature", { "Caracteristica" } }, - { "given", { "*", "Dau", "Dada", "Daus", "Dadas" } }, + { "given", { "* ", "Dau ", "Dada ", "Daus ", "Dadas " } }, { "rule", { "Rule" } }, { "scenario", { "Eixemplo", "Caso" } }, { "scenarioOutline", { "Esquema del caso" } }, - { "then", { "*", "Alavez", "Allora", "Antonces" } }, - { "when", { "*", "Cuan" } } + { "then", { "* ", "Alavez ", "Allora ", "Antonces " } }, + { "when", { "* ", "Cuan " } } } }, { "ar", { - { "and", { "*", "و" } }, + { "and", { "* ", "و " } }, { "background", { "الخلفية" } }, - { "but", { "*", "لكن" } }, + { "but", { "* ", "لكن " } }, { "examples", { "امثلة" } }, { "feature", { "خاصية" } }, - { "given", { "*", "بفرض" } }, + { "given", { "* ", "بفرض " } }, { "rule", { "Rule" } }, { "scenario", { "مثال", "سيناريو" } }, { "scenarioOutline", { "سيناريو مخطط" } }, - { "then", { "*", "اذاً", "ثم" } }, - { "when", { "*", "متى", "عندما" } } + { "then", { "* ", "اذاً ", "ثم " } }, + { "when", { "* ", "متى ", "عندما " } } } }, { "ast", { - { "and", { "*", "Y", "Ya" } }, + { "and", { "* ", "Y ", "Ya " } }, { "background", { "Antecedentes" } }, - { "but", { "*", "Peru" } }, + { "but", { "* ", "Peru " } }, { "examples", { "Exemplos" } }, { "feature", { "Carauterística" } }, - { "given", { "*", "Dáu", "Dada", "Daos", "Daes" } }, + { "given", { "* ", "Dáu ", "Dada ", "Daos ", "Daes " } }, { "rule", { "Rule" } }, { "scenario", { "Exemplo", "Casu" } }, { "scenarioOutline", { "Esbozu del casu" } }, - { "then", { "*", "Entós" } }, - { "when", { "*", "Cuando" } } + { "then", { "* ", "Entós " } }, + { "when", { "* ", "Cuando " } } } }, { "az", { - { "and", { "*", "Və", "Həm" } }, + { "and", { "* ", "Və ", "Həm " } }, { "background", { "Keçmiş", "Kontekst" } }, - { "but", { "*", "Amma", "Ancaq" } }, + { "but", { "* ", "Amma ", "Ancaq " } }, { "examples", { "Nümunələr" } }, { "feature", { "Özəllik" } }, - { "given", { "*", "Tutaq ki", "Verilir" } }, + { "given", { "* ", "Tutaq ki ", "Verilir " } }, { "rule", { "Rule" } }, { "scenario", { "Nümunə", "Ssenari" } }, { "scenarioOutline", { "Ssenarinin strukturu" } }, - { "then", { "*", "O halda" } }, - { "when", { "*", "Əgər", "Nə vaxt ki" } } + { "then", { "* ", "O halda " } }, + { "when", { "* ", "Əgər ", "Nə vaxt ki " } } } }, { "be", { - { "and", { "*", "I", "Ды", "Таксама" } }, + { "and", { "* ", "I ", "Ды ", "Таксама " } }, { "background", { "Кантэкст" } }, - { "but", { "*", "Але", "Інакш" } }, + { "but", { "* ", "Але ", "Інакш " } }, { "examples", { "Прыклады" } }, { "feature", { "Функцыянальнасць", "Фіча" } }, - { "given", { "*", "Няхай", "Дадзена" } }, + { "given", { "* ", "Няхай ", "Дадзена " } }, { "rule", { "Правілы" } }, { "scenario", { "Сцэнарый", "Cцэнар" } }, { "scenarioOutline", { "Шаблон сцэнарыя", "Узор сцэнара" } }, - { "then", { "*", "Тады" } }, - { "when", { "*", "Калі" } } + { "then", { "* ", "Тады " } }, + { "when", { "* ", "Калі " } } } }, { "bg", { - { "and", { "*", "И" } }, + { "and", { "* ", "И " } }, { "background", { "Предистория" } }, - { "but", { "*", "Но" } }, + { "but", { "* ", "Но " } }, { "examples", { "Примери" } }, { "feature", { "Функционалност" } }, - { "given", { "*", "Дадено" } }, + { "given", { "* ", "Дадено " } }, { "rule", { "Правило" } }, { "scenario", { "Пример", "Сценарий" } }, { "scenarioOutline", { "Рамка на сценарий" } }, - { "then", { "*", "То" } }, - { "when", { "*", "Когато" } } + { "then", { "* ", "То " } }, + { "when", { "* ", "Когато " } } } }, { "bm", { - { "and", { "*", "Dan" } }, + { "and", { "* ", "Dan " } }, { "background", { "Latar Belakang" } }, - { "but", { "*", "Tetapi", "Tapi" } }, + { "but", { "* ", "Tetapi ", "Tapi " } }, { "examples", { "Contoh" } }, { "feature", { "Fungsi" } }, - { "given", { "*", "Diberi", "Bagi" } }, + { "given", { "* ", "Diberi ", "Bagi " } }, { "rule", { "Rule" } }, { "scenario", { "Senario", "Situasi", "Keadaan" } }, { "scenarioOutline", { "Kerangka Senario", "Kerangka Situasi", "Kerangka Keadaan", "Garis Panduan Senario" } }, - { "then", { "*", "Maka", "Kemudian" } }, - { "when", { "*", "Apabila" } } + { "then", { "* ", "Maka ", "Kemudian " } }, + { "when", { "* ", "Apabila " } } } }, { "bs", { - { "and", { "*", "I", "A" } }, + { "and", { "* ", "I ", "A " } }, { "background", { "Pozadina" } }, - { "but", { "*", "Ali" } }, + { "but", { "* ", "Ali " } }, { "examples", { "Primjeri" } }, { "feature", { "Karakteristika" } }, - { "given", { "*", "Dato" } }, + { "given", { "* ", "Dato " } }, { "rule", { "Rule" } }, { "scenario", { "Primjer", "Scenariju", "Scenario" } }, { "scenarioOutline", { "Scenariju-obris", "Scenario-outline" } }, - { "then", { "*", "Zatim" } }, - { "when", { "*", "Kada" } } + { "then", { "* ", "Zatim " } }, + { "when", { "* ", "Kada " } } } }, { "ca", { - { "and", { "*", "I" } }, + { "and", { "* ", "I " } }, { "background", { "Rerefons", "Antecedents" } }, - { "but", { "*", "Però" } }, + { "but", { "* ", "Però " } }, { "examples", { "Exemples" } }, { "feature", { "Característica", "Funcionalitat" } }, - { "given", { "*", "Donat", "Donada", "Atès", "Atesa" } }, + { "given", { "* ", "Donat ", "Donada ", "Atès ", "Atesa " } }, { "rule", { "Rule" } }, { "scenario", { "Exemple", "Escenari" } }, { "scenarioOutline", { "Esquema de l'escenari" } }, - { "then", { "*", "Aleshores", "Cal" } }, - { "when", { "*", "Quan" } } + { "then", { "* ", "Aleshores ", "Cal " } }, + { "when", { "* ", "Quan " } } } }, { "cs", { - { "and", { "*", "A také", "A" } }, + { "and", { "* ", "A také ", "A " } }, { "background", { "Pozadí", "Kontext" } }, - { "but", { "*", "Ale" } }, + { "but", { "* ", "Ale " } }, { "examples", { "Příklady" } }, { "feature", { "Požadavek" } }, - { "given", { "*", "Pokud", "Za předpokladu" } }, + { "given", { "* ", "Pokud ", "Za předpokladu " } }, { "rule", { "Pravidlo" } }, { "scenario", { "Příklad", "Scénář" } }, { "scenarioOutline", { "Náčrt Scénáře", "Osnova scénáře" } }, - { "then", { "*", "Pak" } }, - { "when", { "*", "Když" } } + { "then", { "* ", "Pak " } }, + { "when", { "* ", "Když " } } } }, { "cy_GB", { - { "and", { "*", "A" } }, + { "and", { "* ", "A " } }, { "background", { "Cefndir" } }, - { "but", { "*", "Ond" } }, + { "but", { "* ", "Ond " } }, { "examples", { "Enghreifftiau" } }, { "feature", { "Arwedd" } }, - { "given", { "*", "Anrhegedig a" } }, + { "given", { "* ", "Anrhegedig a " } }, { "rule", { "Rule" } }, { "scenario", { "Enghraifft", "Scenario" } }, { "scenarioOutline", { "Scenario Amlinellol" } }, - { "then", { "*", "Yna" } }, - { "when", { "*", "Pryd" } } + { "then", { "* ", "Yna " } }, + { "when", { "* ", "Pryd " } } } }, { "da", { - { "and", { "*", "Og" } }, + { "and", { "* ", "Og " } }, { "background", { "Baggrund" } }, - { "but", { "*", "Men" } }, + { "but", { "* ", "Men " } }, { "examples", { "Eksempler" } }, { "feature", { "Egenskab" } }, - { "given", { "*", "Givet" } }, + { "given", { "* ", "Givet " } }, { "rule", { "Rule" } }, { "scenario", { "Eksempel", "Scenarie" } }, { "scenarioOutline", { "Abstrakt Scenario" } }, - { "then", { "*", "Så" } }, - { "when", { "*", "Når" } } + { "then", { "* ", "Så " } }, + { "when", { "* ", "Når " } } } }, { "de", { - { "and", { "*", "Und" } }, + { "and", { "* ", "Und " } }, { "background", { "Grundlage", "Hintergrund", "Voraussetzungen", "Vorbedingungen" } }, - { "but", { "*", "Aber" } }, + { "but", { "* ", "Aber " } }, { "examples", { "Beispiele" } }, { "feature", { "Funktionalität", "Funktion" } }, - { "given", { "*", "Angenommen", "Gegeben sei", "Gegeben seien" } }, + { "given", { "* ", "Angenommen ", "Gegeben sei ", "Gegeben seien " } }, { "rule", { "Rule", "Regel" } }, { "scenario", { "Beispiel", "Szenario" } }, { "scenarioOutline", { "Szenariogrundriss", "Szenarien" } }, - { "then", { "*", "Dann" } }, - { "when", { "*", "Wenn" } } + { "then", { "* ", "Dann " } }, + { "when", { "* ", "Wenn " } } } }, { "el", { - { "and", { "*", "Και" } }, + { "and", { "* ", "Και " } }, { "background", { "Υπόβαθρο" } }, - { "but", { "*", "Αλλά" } }, + { "but", { "* ", "Αλλά " } }, { "examples", { "Παραδείγματα", "Σενάρια" } }, { "feature", { "Δυνατότητα", "Λειτουργία" } }, - { "given", { "*", "Δεδομένου" } }, + { "given", { "* ", "Δεδομένου " } }, { "rule", { "Rule" } }, { "scenario", { "Παράδειγμα", "Σενάριο" } }, { "scenarioOutline", { "Περιγραφή Σεναρίου", "Περίγραμμα Σεναρίου" } }, - { "then", { "*", "Τότε" } }, - { "when", { "*", "Όταν" } } + { "then", { "* ", "Τότε " } }, + { "when", { "* ", "Όταν " } } } }, { "em", { - { "and", { "*", "😂" } }, + { "and", { "* ", "😂" } }, { "background", { "💤" } }, - { "but", { "*", "😔" } }, + { "but", { "* ", "😔" } }, { "examples", { "📓" } }, { "feature", { "📚" } }, - { "given", { "*", "😐" } }, + { "given", { "* ", "😐" } }, { "rule", { "Rule" } }, { "scenario", { "🥒", "📕" } }, { "scenarioOutline", { "📖" } }, - { "then", { "*", "🙏" } }, - { "when", { "*", "🎬" } } + { "then", { "* ", "🙏" } }, + { "when", { "* ", "🎬" } } } }, { "en", { - { "and", { "*", "And" } }, + { "and", { "* ", "And " } }, { "background", { "Background" } }, - { "but", { "*", "But" } }, + { "but", { "* ", "But " } }, { "examples", { "Examples", "Scenarios" } }, { "feature", { "Feature", "Business Need", "Ability" } }, - { "given", { "*", "Given" } }, + { "given", { "* ", "Given " } }, { "rule", { "Rule" } }, { "scenario", { "Example", "Scenario" } }, { "scenarioOutline", { "Scenario Outline", "Scenario Template" } }, - { "then", { "*", "Then" } }, - { "when", { "*", "When" } } + { "then", { "* ", "Then " } }, + { "when", { "* ", "When " } } } }, { "en_Scouse", { - { "and", { "*", "An" } }, + { "and", { "* ", "An " } }, { "background", { "Dis is what went down" } }, - { "but", { "*", "Buh" } }, + { "but", { "* ", "Buh " } }, { "examples", { "Examples" } }, { "feature", { "Feature" } }, - { "given", { "*", "Givun", "Youse know when youse got" } }, + { "given", { "* ", "Givun ", "Youse know when youse got " } }, { "rule", { "Rule" } }, { "scenario", { "The thing of it is" } }, { "scenarioOutline", { "Wharrimean is" } }, - { "then", { "*", "Dun", "Den youse gotta" } }, - { "when", { "*", "Wun", "Youse know like when" } } + { "then", { "* ", "Dun ", "Den youse gotta " } }, + { "when", { "* ", "Wun ", "Youse know like when " } } } }, { "en_au", { - { "and", { "*", "Too right" } }, + { "and", { "* ", "Too right " } }, { "background", { "First off" } }, - { "but", { "*", "Yeah nah" } }, + { "but", { "* ", "Yeah nah " } }, { "examples", { "You'll wanna" } }, { "feature", { "Pretty much" } }, - { "given", { "*", "Y'know" } }, + { "given", { "* ", "Y'know " } }, { "rule", { "Rule" } }, { "scenario", { "Awww, look mate" } }, { "scenarioOutline", { "Reckon it's like" } }, - { "then", { "*", "But at the end of the day I reckon" } }, - { "when", { "*", "It's just unbelievable" } } + { "then", { "* ", "But at the end of the day I reckon " } }, + { "when", { "* ", "It's just unbelievable " } } } }, { "en_lol", { - { "and", { "*", "AN" } }, + { "and", { "* ", "AN " } }, { "background", { "B4" } }, - { "but", { "*", "BUT" } }, + { "but", { "* ", "BUT " } }, { "examples", { "EXAMPLZ" } }, { "feature", { "OH HAI" } }, - { "given", { "*", "I CAN HAZ" } }, + { "given", { "* ", "I CAN HAZ " } }, { "rule", { "Rule" } }, { "scenario", { "MISHUN" } }, { "scenarioOutline", { "MISHUN SRSLY" } }, - { "then", { "*", "DEN" } }, - { "when", { "*", "WEN" } } + { "then", { "* ", "DEN " } }, + { "when", { "* ", "WEN " } } } }, { "en_old", { - { "and", { "*", "Ond", "7" } }, + { "and", { "* ", "Ond ", "7 " } }, { "background", { "Aer", "Ær" } }, - { "but", { "*", "Ac" } }, + { "but", { "* ", "Ac " } }, { "examples", { "Se the", "Se þe", "Se ðe" } }, { "feature", { "Hwaet", "Hwæt" } }, - { "given", { "*", "Thurh", "Þurh", "Ðurh" } }, + { "given", { "* ", "Thurh ", "Þurh ", "Ðurh " } }, { "rule", { "Rule" } }, { "scenario", { "Swa" } }, { "scenarioOutline", { "Swa hwaer swa", "Swa hwær swa" } }, - { "then", { "*", "Tha", "Þa", "Ða", "Tha the", "Þa þe", "Ða ðe" } }, - { "when", { "*", "Bæþsealf", "Bæþsealfa", "Bæþsealfe", "Ciricæw", "Ciricæwe", "Ciricæwa" } } + { "then", { "* ", "Tha ", "Þa ", "Ða ", "Tha the ", "Þa þe ", "Ða ðe " } }, + { "when", { "* ", "Bæþsealf ", "Bæþsealfa ", "Bæþsealfe ", "Ciricæw ", "Ciricæwe ", "Ciricæwa " } } } }, { "en_pirate", { - { "and", { "*", "Aye" } }, + { "and", { "* ", "Aye " } }, { "background", { "Yo-ho-ho" } }, - { "but", { "*", "Avast!" } }, + { "but", { "* ", "Avast! " } }, { "examples", { "Dead men tell no tales" } }, { "feature", { "Ahoy matey!" } }, - { "given", { "*", "Gangway!" } }, + { "given", { "* ", "Gangway! " } }, { "rule", { "Rule" } }, { "scenario", { "Heave to" } }, { "scenarioOutline", { "Shiver me timbers" } }, - { "then", { "*", "Let go and haul" } }, - { "when", { "*", "Blimey!" } } + { "then", { "* ", "Let go and haul " } }, + { "when", { "* ", "Blimey! " } } } }, { "en_tx", { - { "and", { "Come hell or high water" } }, + { "and", { "Come hell or high water " } }, { "background", { "Lemme tell y'all a story" } }, - { "but", { "Well now hold on, I'll you what" } }, + { "but", { "Well now hold on, I'll you what " } }, { "examples", { "Now that's a story longer than a cattle drive in July" } }, { "feature", { "This ain’t my first rodeo", "All gussied up" } }, - { "given", { "Fixin' to", "All git out" } }, - { "rule", { "Rule" } }, + { "given", { "Fixin' to ", "All git out " } }, + { "rule", { "Rule " } }, { "scenario", { "All hat and no cattle" } }, { "scenarioOutline", { "Serious as a snake bite", "Busy as a hound in flea season" } }, - { "then", { "There’s no tree but bears some fruit" } }, - { "when", { "Quick out of the chute" } } + { "then", { "There’s no tree but bears some fruit " } }, + { "when", { "Quick out of the chute " } } } }, { "eo", { - { "and", { "*", "Kaj" } }, + { "and", { "* ", "Kaj " } }, { "background", { "Fono" } }, - { "but", { "*", "Sed" } }, + { "but", { "* ", "Sed " } }, { "examples", { "Ekzemploj" } }, { "feature", { "Trajto" } }, - { "given", { "*", "Donitaĵo", "Komence" } }, + { "given", { "* ", "Donitaĵo ", "Komence " } }, { "rule", { "Rule" } }, { "scenario", { "Ekzemplo", "Scenaro", "Kazo" } }, { "scenarioOutline", { "Konturo de la scenaro", "Skizo", "Kazo-skizo" } }, - { "then", { "*", "Do" } }, - { "when", { "*", "Se" } } + { "then", { "* ", "Do " } }, + { "when", { "* ", "Se " } } } }, { "es", { - { "and", { "*", "Y", "E" } }, + { "and", { "* ", "Y ", "E " } }, { "background", { "Antecedentes" } }, - { "but", { "*", "Pero" } }, + { "but", { "* ", "Pero " } }, { "examples", { "Ejemplos" } }, { "feature", { "Característica", "Necesidad del negocio", "Requisito" } }, - { "given", { "*", "Dado", "Dada", "Dados", "Dadas" } }, + { "given", { "* ", "Dado ", "Dada ", "Dados ", "Dadas " } }, { "rule", { "Regla", "Regla de negocio" } }, { "scenario", { "Ejemplo", "Escenario" } }, { "scenarioOutline", { "Esquema del escenario" } }, - { "then", { "*", "Entonces" } }, - { "when", { "*", "Cuando" } } + { "then", { "* ", "Entonces " } }, + { "when", { "* ", "Cuando " } } } }, { "et", { - { "and", { "*", "Ja" } }, + { "and", { "* ", "Ja " } }, { "background", { "Taust" } }, - { "but", { "*", "Kuid" } }, + { "but", { "* ", "Kuid " } }, { "examples", { "Juhtumid" } }, { "feature", { "Omadus" } }, - { "given", { "*", "Eeldades" } }, + { "given", { "* ", "Eeldades " } }, { "rule", { "Reegel" } }, { "scenario", { "Juhtum", "Stsenaarium" } }, { "scenarioOutline", { "Raamjuhtum", "Raamstsenaarium" } }, - { "then", { "*", "Siis" } }, - { "when", { "*", "Kui" } } + { "then", { "* ", "Siis " } }, + { "when", { "* ", "Kui " } } } }, { "fa", { - { "and", { "*", "و" } }, + { "and", { "* ", "و " } }, { "background", { "زمینه" } }, - { "but", { "*", "اما" } }, + { "but", { "* ", "اما " } }, { "examples", { "نمونه ها" } }, { "feature", { "وِیژگی" } }, - { "given", { "*", "با فرض" } }, + { "given", { "* ", "با فرض " } }, { "rule", { "Rule" } }, { "scenario", { "مثال", "سناریو" } }, { "scenarioOutline", { "الگوی سناریو" } }, - { "then", { "*", "آنگاه" } }, - { "when", { "*", "هنگامی" } } + { "then", { "* ", "آنگاه " } }, + { "when", { "* ", "هنگامی " } } } }, { "fi", { - { "and", { "*", "Ja" } }, + { "and", { "* ", "Ja " } }, { "background", { "Tausta" } }, - { "but", { "*", "Mutta" } }, + { "but", { "* ", "Mutta " } }, { "examples", { "Tapaukset" } }, { "feature", { "Ominaisuus" } }, - { "given", { "*", "Oletetaan" } }, + { "given", { "* ", "Oletetaan " } }, { "rule", { "Rule" } }, { "scenario", { "Tapaus" } }, { "scenarioOutline", { "Tapausaihio" } }, - { "then", { "*", "Niin" } }, - { "when", { "*", "Kun" } } + { "then", { "* ", "Niin " } }, + { "when", { "* ", "Kun " } } } }, { "fr", { - { "and", { "*", "Et que", "Et qu'", "Et" } }, + { "and", { "* ", "Et que ", "Et qu'", "Et " } }, { "background", { "Contexte" } }, - { "but", { "*", "Mais que", "Mais qu'", "Mais" } }, + { "but", { "* ", "Mais que ", "Mais qu'", "Mais " } }, { "examples", { "Exemples" } }, { "feature", { "Fonctionnalité" } }, - { "given", { "*", "Soit", "Sachant que", "Sachant qu'", "Sachant", "Etant donné que", "Etant donné qu'", "Etant donné", "Etant donnée", "Etant donnés", "Etant données", "Étant donné que", "Étant donné qu'", "Étant donné", "Étant donnée", "Étant donnés", "Étant données" } }, + { "given", { "* ", "Soit ", "Sachant que ", "Sachant qu'", "Sachant ", "Etant donné que ", "Etant donné qu'", "Etant donné ", "Etant donnée ", "Etant donnés ", "Etant données ", "Étant donné que ", "Étant donné qu'", "Étant donné ", "Étant donnée ", "Étant donnés ", "Étant données " } }, { "rule", { "Règle" } }, { "scenario", { "Exemple", "Scénario" } }, { "scenarioOutline", { "Plan du scénario", "Plan du Scénario" } }, - { "then", { "*", "Alors", "Donc" } }, - { "when", { "*", "Quand", "Lorsque", "Lorsqu'" } } + { "then", { "* ", "Alors ", "Donc " } }, + { "when", { "* ", "Quand ", "Lorsque ", "Lorsqu'" } } } }, { "ga", { - { "and", { "*", "Agus" } }, + { "and", { "* ", "Agus" } }, { "background", { "Cúlra" } }, - { "but", { "*", "Ach" } }, + { "but", { "* ", "Ach" } }, { "examples", { "Samplaí" } }, { "feature", { "Gné" } }, - { "given", { "*", "Cuir i gcás go", "Cuir i gcás nach", "Cuir i gcás gur", "Cuir i gcás nár" } }, + { "given", { "* ", "Cuir i gcás go", "Cuir i gcás nach", "Cuir i gcás gur", "Cuir i gcás nár" } }, { "rule", { "Rule" } }, { "scenario", { "Sampla", "Cás" } }, { "scenarioOutline", { "Cás Achomair" } }, - { "then", { "*", "Ansin" } }, - { "when", { "*", "Nuair a", "Nuair nach", "Nuair ba", "Nuair nár" } } + { "then", { "* ", "Ansin" } }, + { "when", { "* ", "Nuair a", "Nuair nach", "Nuair ba", "Nuair nár" } } } }, { "gj", { - { "and", { "*", "અને" } }, + { "and", { "* ", "અને " } }, { "background", { "બેકગ્રાઉન્ડ" } }, - { "but", { "*", "પણ" } }, + { "but", { "* ", "પણ " } }, { "examples", { "ઉદાહરણો" } }, { "feature", { "લક્ષણ", "વ્યાપાર જરૂર", "ક્ષમતા" } }, - { "given", { "*", "આપેલ છે" } }, + { "given", { "* ", "આપેલ છે " } }, { "rule", { "Rule" } }, { "scenario", { "ઉદાહરણ", "સ્થિતિ" } }, { "scenarioOutline", { "પરિદ્દશ્ય રૂપરેખા", "પરિદ્દશ્ય ઢાંચો" } }, - { "then", { "*", "પછી" } }, - { "when", { "*", "ક્યારે" } } + { "then", { "* ", "પછી " } }, + { "when", { "* ", "ક્યારે " } } } }, { "gl", { - { "and", { "*", "E" } }, + { "and", { "* ", "E " } }, { "background", { "Contexto" } }, - { "but", { "*", "Mais", "Pero" } }, + { "but", { "* ", "Mais ", "Pero " } }, { "examples", { "Exemplos" } }, { "feature", { "Característica" } }, - { "given", { "*", "Dado", "Dada", "Dados", "Dadas" } }, + { "given", { "* ", "Dado ", "Dada ", "Dados ", "Dadas " } }, { "rule", { "Rule" } }, { "scenario", { "Exemplo", "Escenario" } }, { "scenarioOutline", { "Esbozo do escenario" } }, - { "then", { "*", "Entón", "Logo" } }, - { "when", { "*", "Cando" } } + { "then", { "* ", "Entón ", "Logo " } }, + { "when", { "* ", "Cando " } } } }, { "he", { - { "and", { "*", "וגם" } }, + { "and", { "* ", "וגם " } }, { "background", { "רקע" } }, - { "but", { "*", "אבל" } }, + { "but", { "* ", "אבל " } }, { "examples", { "דוגמאות" } }, { "feature", { "תכונה" } }, - { "given", { "*", "בהינתן" } }, + { "given", { "* ", "בהינתן " } }, { "rule", { "כלל" } }, { "scenario", { "דוגמא", "תרחיש" } }, { "scenarioOutline", { "תבנית תרחיש" } }, - { "then", { "*", "אז", "אזי" } }, - { "when", { "*", "כאשר" } } + { "then", { "* ", "אז ", "אזי " } }, + { "when", { "* ", "כאשר " } } } }, { "hi", { - { "and", { "*", "और", "तथा" } }, + { "and", { "* ", "और ", "तथा " } }, { "background", { "पृष्ठभूमि" } }, - { "but", { "*", "पर", "परन्तु", "किन्तु" } }, + { "but", { "* ", "पर ", "परन्तु ", "किन्तु " } }, { "examples", { "उदाहरण" } }, { "feature", { "रूप लेख" } }, - { "given", { "*", "अगर", "यदि", "चूंकि" } }, + { "given", { "* ", "अगर ", "यदि ", "चूंकि " } }, { "rule", { "नियम" } }, { "scenario", { "परिदृश्य" } }, { "scenarioOutline", { "परिदृश्य रूपरेखा" } }, - { "then", { "*", "तब", "तदा" } }, - { "when", { "*", "जब", "कदा" } } + { "then", { "* ", "तब ", "तदा " } }, + { "when", { "* ", "जब ", "कदा " } } } }, { "hr", { - { "and", { "*", "I" } }, + { "and", { "* ", "I " } }, { "background", { "Pozadina" } }, - { "but", { "*", "Ali" } }, + { "but", { "* ", "Ali " } }, { "examples", { "Primjeri", "Scenariji" } }, { "feature", { "Osobina", "Mogućnost", "Mogucnost" } }, - { "given", { "*", "Zadan", "Zadani", "Zadano", "Ukoliko" } }, + { "given", { "* ", "Zadan ", "Zadani ", "Zadano ", "Ukoliko " } }, { "rule", { "Rule" } }, { "scenario", { "Primjer", "Scenarij" } }, { "scenarioOutline", { "Skica", "Koncept" } }, - { "then", { "*", "Onda" } }, - { "when", { "*", "Kada", "Kad" } } + { "then", { "* ", "Onda " } }, + { "when", { "* ", "Kada ", "Kad " } } } }, { "ht", { - { "and", { "*", "Ak", "Epi", "E" } }, + { "and", { "* ", "Ak ", "Epi ", "E " } }, { "background", { "Kontèks", "Istorik" } }, - { "but", { "*", "Men" } }, + { "but", { "* ", "Men " } }, { "examples", { "Egzanp" } }, { "feature", { "Karakteristik", "Mak", "Fonksyonalite" } }, - { "given", { "*", "Sipoze", "Sipoze ke", "Sipoze Ke" } }, + { "given", { "* ", "Sipoze ", "Sipoze ke ", "Sipoze Ke " } }, { "rule", { "Rule" } }, { "scenario", { "Senaryo" } }, { "scenarioOutline", { "Plan senaryo", "Plan Senaryo", "Senaryo deskripsyon", "Senaryo Deskripsyon", "Dyagram senaryo", "Dyagram Senaryo" } }, - { "then", { "*", "Lè sa a", "Le sa a" } }, - { "when", { "*", "Lè", "Le" } } + { "then", { "* ", "Lè sa a ", "Le sa a " } }, + { "when", { "* ", "Lè ", "Le " } } } }, { "hu", { - { "and", { "*", "És" } }, + { "and", { "* ", "És " } }, { "background", { "Háttér" } }, - { "but", { "*", "De" } }, + { "but", { "* ", "De " } }, { "examples", { "Példák" } }, { "feature", { "Jellemző" } }, - { "given", { "*", "Amennyiben", "Adott" } }, + { "given", { "* ", "Amennyiben ", "Adott " } }, { "rule", { "Szabály" } }, { "scenario", { "Példa", "Forgatókönyv" } }, { "scenarioOutline", { "Forgatókönyv vázlat" } }, - { "then", { "*", "Akkor" } }, - { "when", { "*", "Majd", "Ha", "Amikor" } } + { "then", { "* ", "Akkor " } }, + { "when", { "* ", "Majd ", "Ha ", "Amikor " } } } }, { "id", { - { "and", { "*", "Dan" } }, + { "and", { "* ", "Dan " } }, { "background", { "Dasar", "Latar Belakang" } }, - { "but", { "*", "Tapi", "Tetapi" } }, + { "but", { "* ", "Tapi ", "Tetapi " } }, { "examples", { "Contoh", "Misal" } }, { "feature", { "Fitur" } }, - { "given", { "*", "Dengan", "Diketahui", "Diasumsikan", "Bila", "Jika" } }, + { "given", { "* ", "Dengan ", "Diketahui ", "Diasumsikan ", "Bila ", "Jika " } }, { "rule", { "Rule", "Aturan" } }, { "scenario", { "Skenario" } }, { "scenarioOutline", { "Skenario konsep", "Garis-Besar Skenario" } }, - { "then", { "*", "Maka", "Kemudian" } }, - { "when", { "*", "Ketika" } } + { "then", { "* ", "Maka ", "Kemudian " } }, + { "when", { "* ", "Ketika " } } } }, { "is", { - { "and", { "*", "Og" } }, + { "and", { "* ", "Og " } }, { "background", { "Bakgrunnur" } }, - { "but", { "*", "En" } }, + { "but", { "* ", "En " } }, { "examples", { "Dæmi", "Atburðarásir" } }, { "feature", { "Eiginleiki" } }, - { "given", { "*", "Ef" } }, + { "given", { "* ", "Ef " } }, { "rule", { "Rule" } }, { "scenario", { "Atburðarás" } }, { "scenarioOutline", { "Lýsing Atburðarásar", "Lýsing Dæma" } }, - { "then", { "*", "Þá" } }, - { "when", { "*", "Þegar" } } + { "then", { "* ", "Þá " } }, + { "when", { "* ", "Þegar " } } } }, { "it", { - { "and", { "*", "E" } }, + { "and", { "* ", "E " } }, { "background", { "Contesto" } }, - { "but", { "*", "Ma" } }, + { "but", { "* ", "Ma " } }, { "examples", { "Esempi" } }, { "feature", { "Funzionalità", "Esigenza di Business", "Abilità" } }, - { "given", { "*", "Dato", "Data", "Dati", "Date" } }, + { "given", { "* ", "Dato ", "Data ", "Dati ", "Date " } }, { "rule", { "Regola" } }, { "scenario", { "Esempio", "Scenario" } }, { "scenarioOutline", { "Schema dello scenario" } }, - { "then", { "*", "Allora" } }, - { "when", { "*", "Quando" } } + { "then", { "* ", "Allora " } }, + { "when", { "* ", "Quando " } } } }, { "ja", { - { "and", { "*", "且つ", "かつ" } }, + { "and", { "* ", "且つ", "かつ" } }, { "background", { "背景" } }, - { "but", { "*", "然し", "しかし", "但し", "ただし" } }, + { "but", { "* ", "然し", "しかし", "但し", "ただし" } }, { "examples", { "例", "サンプル" } }, { "feature", { "フィーチャ", "機能" } }, - { "given", { "*", "前提" } }, + { "given", { "* ", "前提" } }, { "rule", { "ルール" } }, { "scenario", { "シナリオ" } }, { "scenarioOutline", { "シナリオアウトライン", "シナリオテンプレート", "テンプレ", "シナリオテンプレ" } }, - { "then", { "*", "ならば" } }, - { "when", { "*", "もし" } } + { "then", { "* ", "ならば" } }, + { "when", { "* ", "もし" } } } }, { "jv", { - { "and", { "*", "Lan" } }, + { "and", { "* ", "Lan " } }, { "background", { "Dasar" } }, - { "but", { "*", "Tapi", "Nanging", "Ananging" } }, + { "but", { "* ", "Tapi ", "Nanging ", "Ananging " } }, { "examples", { "Conto", "Contone" } }, { "feature", { "Fitur" } }, - { "given", { "*", "Nalika", "Nalikaning" } }, + { "given", { "* ", "Nalika ", "Nalikaning " } }, { "rule", { "Rule" } }, { "scenario", { "Skenario" } }, { "scenarioOutline", { "Konsep skenario" } }, - { "then", { "*", "Njuk", "Banjur" } }, - { "when", { "*", "Manawa", "Menawa" } } + { "then", { "* ", "Njuk ", "Banjur " } }, + { "when", { "* ", "Manawa ", "Menawa " } } } }, { "ka", { - { "and", { "*", "და", "ასევე" } }, + { "and", { "* ", "და ", "ასევე " } }, { "background", { "კონტექსტი" } }, - { "but", { "*", "მაგრამ", "თუმცა" } }, + { "but", { "* ", "მაგრამ ", "თუმცა " } }, { "examples", { "მაგალითები" } }, { "feature", { "თვისება", "მოთხოვნა" } }, - { "given", { "*", "მოცემული", "მოცემულია", "ვთქვათ" } }, + { "given", { "* ", "მოცემული ", "მოცემულია ", "ვთქვათ " } }, { "rule", { "წესი" } }, { "scenario", { "მაგალითად", "მაგალითი", "მაგ", "სცენარი" } }, { "scenarioOutline", { "სცენარის ნიმუში", "სცენარის შაბლონი", "ნიმუში", "შაბლონი" } }, - { "then", { "*", "მაშინ" } }, - { "when", { "*", "როდესაც", "როცა", "როგორც კი", "თუ" } } + { "then", { "* ", "მაშინ " } }, + { "when", { "* ", "როდესაც ", "როცა ", "როგორც კი ", "თუ " } } } }, { "kn", { - { "and", { "*", "ಮತ್ತು" } }, + { "and", { "* ", "ಮತ್ತು " } }, { "background", { "ಹಿನ್ನೆಲೆ" } }, - { "but", { "*", "ಆದರೆ" } }, + { "but", { "* ", "ಆದರೆ " } }, { "examples", { "ಉದಾಹರಣೆಗಳು" } }, { "feature", { "ಹೆಚ್ಚಳ" } }, - { "given", { "*", "ನೀಡಿದ" } }, + { "given", { "* ", "ನೀಡಿದ " } }, { "rule", { "Rule" } }, { "scenario", { "ಉದಾಹರಣೆ", "ಕಥಾಸಾರಾಂಶ" } }, { "scenarioOutline", { "ವಿವರಣೆ" } }, - { "then", { "*", "ನಂತರ" } }, - { "when", { "*", "ಸ್ಥಿತಿಯನ್ನು" } } + { "then", { "* ", "ನಂತರ " } }, + { "when", { "* ", "ಸ್ಥಿತಿಯನ್ನು " } } } }, { "ko", { - { "and", { "*", "그리고" } }, + { "and", { "* ", "그리고" } }, { "background", { "배경" } }, - { "but", { "*", "하지만", "단" } }, + { "but", { "* ", "하지만", "단" } }, { "examples", { "예" } }, { "feature", { "기능" } }, - { "given", { "*", "조건", "먼저" } }, + { "given", { "* ", "조건", "먼저" } }, { "rule", { "Rule" } }, { "scenario", { "시나리오" } }, { "scenarioOutline", { "시나리오 개요" } }, - { "then", { "*", "그러면" } }, - { "when", { "*", "만일", "만약" } } + { "then", { "* ", "그러면" } }, + { "when", { "* ", "만일", "만약" } } } }, { "lt", { - { "and", { "*", "Ir" } }, + { "and", { "* ", "Ir " } }, { "background", { "Kontekstas" } }, - { "but", { "*", "Bet" } }, + { "but", { "* ", "Bet " } }, { "examples", { "Pavyzdžiai", "Scenarijai", "Variantai" } }, { "feature", { "Savybė" } }, - { "given", { "*", "Duota" } }, + { "given", { "* ", "Duota " } }, { "rule", { "Rule" } }, { "scenario", { "Pavyzdys", "Scenarijus" } }, { "scenarioOutline", { "Scenarijaus šablonas" } }, - { "then", { "*", "Tada" } }, - { "when", { "*", "Kai" } } + { "then", { "* ", "Tada " } }, + { "when", { "* ", "Kai " } } } }, { "lu", { - { "and", { "*", "an", "a" } }, + { "and", { "* ", "an ", "a " } }, { "background", { "Hannergrond" } }, - { "but", { "*", "awer", "mä" } }, + { "but", { "* ", "awer ", "mä " } }, { "examples", { "Beispiller" } }, { "feature", { "Funktionalitéit" } }, - { "given", { "*", "ugeholl" } }, + { "given", { "* ", "ugeholl " } }, { "rule", { "Rule" } }, { "scenario", { "Beispill", "Szenario" } }, { "scenarioOutline", { "Plang vum Szenario" } }, - { "then", { "*", "dann" } }, - { "when", { "*", "wann" } } + { "then", { "* ", "dann " } }, + { "when", { "* ", "wann " } } } }, { "lv", { - { "and", { "*", "Un" } }, + { "and", { "* ", "Un " } }, { "background", { "Konteksts", "Situācija" } }, - { "but", { "*", "Bet" } }, + { "but", { "* ", "Bet " } }, { "examples", { "Piemēri", "Paraugs" } }, { "feature", { "Funkcionalitāte", "Fīča" } }, - { "given", { "*", "Kad" } }, + { "given", { "* ", "Kad " } }, { "rule", { "Rule" } }, { "scenario", { "Piemērs", "Scenārijs" } }, { "scenarioOutline", { "Scenārijs pēc parauga" } }, - { "then", { "*", "Tad" } }, - { "when", { "*", "Ja" } } + { "then", { "* ", "Tad " } }, + { "when", { "* ", "Ja " } } } }, { "mk_Cyrl", { - { "and", { "*", "И" } }, + { "and", { "* ", "И " } }, { "background", { "Контекст", "Содржина" } }, - { "but", { "*", "Но" } }, + { "but", { "* ", "Но " } }, { "examples", { "Примери", "Сценарија" } }, { "feature", { "Функционалност", "Бизнис потреба", "Можност" } }, - { "given", { "*", "Дадено", "Дадена" } }, + { "given", { "* ", "Дадено ", "Дадена " } }, { "rule", { "Rule" } }, { "scenario", { "Пример", "Сценарио", "На пример" } }, { "scenarioOutline", { "Преглед на сценарија", "Скица", "Концепт" } }, - { "then", { "*", "Тогаш" } }, - { "when", { "*", "Кога" } } + { "then", { "* ", "Тогаш " } }, + { "when", { "* ", "Кога " } } } }, { "mk_Latn", { - { "and", { "*", "I" } }, + { "and", { "* ", "I " } }, { "background", { "Kontekst", "Sodrzhina" } }, - { "but", { "*", "No" } }, + { "but", { "* ", "No " } }, { "examples", { "Primeri", "Scenaria" } }, { "feature", { "Funkcionalnost", "Biznis potreba", "Mozhnost" } }, - { "given", { "*", "Dadeno", "Dadena" } }, + { "given", { "* ", "Dadeno ", "Dadena " } }, { "rule", { "Rule" } }, { "scenario", { "Scenario", "Na primer" } }, { "scenarioOutline", { "Pregled na scenarija", "Skica", "Koncept" } }, - { "then", { "*", "Togash" } }, - { "when", { "*", "Koga" } } + { "then", { "* ", "Togash " } }, + { "when", { "* ", "Koga " } } } }, { "mn", { - { "and", { "*", "Мөн", "Тэгээд" } }, + { "and", { "* ", "Мөн ", "Тэгээд " } }, { "background", { "Агуулга" } }, - { "but", { "*", "Гэхдээ", "Харин" } }, + { "but", { "* ", "Гэхдээ ", "Харин " } }, { "examples", { "Тухайлбал" } }, { "feature", { "Функц", "Функционал" } }, - { "given", { "*", "Өгөгдсөн нь", "Анх" } }, + { "given", { "* ", "Өгөгдсөн нь ", "Анх " } }, { "rule", { "Rule" } }, { "scenario", { "Сценар" } }, { "scenarioOutline", { "Сценарын төлөвлөгөө" } }, - { "then", { "*", "Тэгэхэд", "Үүний дараа" } }, - { "when", { "*", "Хэрэв" } } + { "then", { "* ", "Тэгэхэд ", "Үүний дараа " } }, + { "when", { "* ", "Хэрэв " } } } }, { "ne", { - { "and", { "*", "र", "अनि" } }, + { "and", { "* ", "र ", "अनि " } }, { "background", { "पृष्ठभूमी" } }, - { "but", { "*", "तर" } }, + { "but", { "* ", "तर " } }, { "examples", { "उदाहरण", "उदाहरणहरु" } }, { "feature", { "सुविधा", "विशेषता" } }, - { "given", { "*", "दिइएको", "दिएको", "यदि" } }, + { "given", { "* ", "दिइएको ", "दिएको ", "यदि " } }, { "rule", { "नियम" } }, { "scenario", { "परिदृश्य" } }, { "scenarioOutline", { "परिदृश्य रूपरेखा" } }, - { "then", { "*", "त्यसपछि", "अनी" } }, - { "when", { "*", "जब" } } + { "then", { "* ", "त्यसपछि ", "अनी " } }, + { "when", { "* ", "जब " } } } }, { "nl", { - { "and", { "*", "En" } }, + { "and", { "* ", "En " } }, { "background", { "Achtergrond" } }, - { "but", { "*", "Maar" } }, + { "but", { "* ", "Maar " } }, { "examples", { "Voorbeelden" } }, { "feature", { "Functionaliteit" } }, - { "given", { "*", "Gegeven", "Stel" } }, + { "given", { "* ", "Gegeven ", "Stel " } }, { "rule", { "Rule" } }, { "scenario", { "Voorbeeld", "Scenario" } }, { "scenarioOutline", { "Abstract Scenario" } }, - { "then", { "*", "Dan" } }, - { "when", { "*", "Als", "Wanneer" } } + { "then", { "* ", "Dan " } }, + { "when", { "* ", "Als ", "Wanneer " } } } }, { "no", { - { "and", { "*", "Og" } }, + { "and", { "* ", "Og " } }, { "background", { "Bakgrunn" } }, - { "but", { "*", "Men" } }, + { "but", { "* ", "Men " } }, { "examples", { "Eksempler" } }, { "feature", { "Egenskap" } }, - { "given", { "*", "Gitt" } }, + { "given", { "* ", "Gitt " } }, { "rule", { "Regel" } }, { "scenario", { "Eksempel", "Scenario" } }, { "scenarioOutline", { "Scenariomal", "Abstrakt Scenario" } }, - { "then", { "*", "Så" } }, - { "when", { "*", "Når" } } + { "then", { "* ", "Så " } }, + { "when", { "* ", "Når " } } } }, { "pa", { - { "and", { "*", "ਅਤੇ" } }, + { "and", { "* ", "ਅਤੇ " } }, { "background", { "ਪਿਛੋਕੜ" } }, - { "but", { "*", "ਪਰ" } }, + { "but", { "* ", "ਪਰ " } }, { "examples", { "ਉਦਾਹਰਨਾਂ" } }, { "feature", { "ਖਾਸੀਅਤ", "ਮੁਹਾਂਦਰਾ", "ਨਕਸ਼ ਨੁਹਾਰ" } }, - { "given", { "*", "ਜੇਕਰ", "ਜਿਵੇਂ ਕਿ" } }, + { "given", { "* ", "ਜੇਕਰ ", "ਜਿਵੇਂ ਕਿ " } }, { "rule", { "Rule" } }, { "scenario", { "ਉਦਾਹਰਨ", "ਪਟਕਥਾ" } }, { "scenarioOutline", { "ਪਟਕਥਾ ਢਾਂਚਾ", "ਪਟਕਥਾ ਰੂਪ ਰੇਖਾ" } }, - { "then", { "*", "ਤਦ" } }, - { "when", { "*", "ਜਦੋਂ" } } + { "then", { "* ", "ਤਦ " } }, + { "when", { "* ", "ਜਦੋਂ " } } } }, { "pl", { - { "and", { "*", "Oraz", "I" } }, + { "and", { "* ", "Oraz ", "I " } }, { "background", { "Założenia" } }, - { "but", { "*", "Ale" } }, + { "but", { "* ", "Ale " } }, { "examples", { "Przykłady" } }, { "feature", { "Właściwość", "Funkcja", "Aspekt", "Potrzeba biznesowa" } }, - { "given", { "*", "Zakładając", "Mając", "Zakładając, że" } }, + { "given", { "* ", "Zakładając ", "Mając ", "Zakładając, że " } }, { "rule", { "Zasada", "Reguła" } }, { "scenario", { "Przykład", "Scenariusz" } }, { "scenarioOutline", { "Szablon scenariusza" } }, - { "then", { "*", "Wtedy" } }, - { "when", { "*", "Jeżeli", "Jeśli", "Gdy", "Kiedy" } } + { "then", { "* ", "Wtedy " } }, + { "when", { "* ", "Jeżeli ", "Jeśli ", "Gdy ", "Kiedy " } } } }, { "pt", { - { "and", { "*", "E" } }, + { "and", { "* ", "E " } }, { "background", { "Contexto", "Cenário de Fundo", "Cenario de Fundo", "Fundo" } }, - { "but", { "*", "Mas" } }, + { "but", { "* ", "Mas " } }, { "examples", { "Exemplos", "Cenários", "Cenarios" } }, { "feature", { "Funcionalidade", "Característica", "Caracteristica" } }, - { "given", { "*", "Dado", "Dada", "Dados", "Dadas" } }, + { "given", { "* ", "Dado ", "Dada ", "Dados ", "Dadas " } }, { "rule", { "Regra" } }, { "scenario", { "Exemplo", "Cenário", "Cenario" } }, { "scenarioOutline", { "Esquema do Cenário", "Esquema do Cenario", "Delineação do Cenário", "Delineacao do Cenario" } }, - { "then", { "*", "Então", "Entao" } }, - { "when", { "*", "Quando" } } + { "then", { "* ", "Então ", "Entao " } }, + { "when", { "* ", "Quando " } } } }, { "ro", { - { "and", { "*", "Si", "Și", "Şi" } }, + { "and", { "* ", "Si ", "Și ", "Şi " } }, { "background", { "Context" } }, - { "but", { "*", "Dar" } }, + { "but", { "* ", "Dar " } }, { "examples", { "Exemple" } }, { "feature", { "Functionalitate", "Funcționalitate", "Funcţionalitate" } }, - { "given", { "*", "Date fiind", "Dat fiind", "Dată fiind", "Dati fiind", "Dați fiind", "Daţi fiind" } }, + { "given", { "* ", "Date fiind ", "Dat fiind ", "Dată fiind", "Dati fiind ", "Dați fiind ", "Daţi fiind " } }, { "rule", { "Rule" } }, { "scenario", { "Exemplu", "Scenariu" } }, { "scenarioOutline", { "Structura scenariu", "Structură scenariu" } }, - { "then", { "*", "Atunci" } }, - { "when", { "*", "Cand", "Când" } } + { "then", { "* ", "Atunci " } }, + { "when", { "* ", "Cand ", "Când " } } } }, { "ru", { - { "and", { "*", "И", "К тому же", "Также" } }, + { "and", { "* ", "И ", "К тому же ", "Также " } }, { "background", { "Предыстория", "Контекст" } }, - { "but", { "*", "Но", "А", "Иначе" } }, + { "but", { "* ", "Но ", "А ", "Иначе " } }, { "examples", { "Примеры" } }, { "feature", { "Функция", "Функциональность", "Функционал", "Свойство", "Фича" } }, - { "given", { "*", "Допустим", "Дано", "Пусть" } }, + { "given", { "* ", "Допустим ", "Дано ", "Пусть " } }, { "rule", { "Правило" } }, { "scenario", { "Пример", "Сценарий" } }, { "scenarioOutline", { "Структура сценария", "Шаблон сценария" } }, - { "then", { "*", "То", "Затем", "Тогда" } }, - { "when", { "*", "Когда", "Если" } } + { "then", { "* ", "То ", "Затем ", "Тогда " } }, + { "when", { "* ", "Когда ", "Если " } } } }, { "sk", { - { "and", { "*", "A", "A tiež", "A taktiež", "A zároveň" } }, + { "and", { "* ", "A ", "A tiež ", "A taktiež ", "A zároveň " } }, { "background", { "Pozadie" } }, - { "but", { "*", "Ale" } }, + { "but", { "* ", "Ale " } }, { "examples", { "Príklady" } }, { "feature", { "Požiadavka", "Funkcia", "Vlastnosť" } }, - { "given", { "*", "Pokiaľ", "Za predpokladu" } }, + { "given", { "* ", "Pokiaľ ", "Za predpokladu " } }, { "rule", { "Rule" } }, { "scenario", { "Príklad", "Scenár" } }, { "scenarioOutline", { "Náčrt Scenáru", "Náčrt Scenára", "Osnova Scenára" } }, - { "then", { "*", "Tak", "Potom" } }, - { "when", { "*", "Keď", "Ak" } } + { "then", { "* ", "Tak ", "Potom " } }, + { "when", { "* ", "Keď ", "Ak " } } } }, { "sl", { - { "and", { "In", "Ter" } }, + { "and", { "In ", "Ter " } }, { "background", { "Kontekst", "Osnova", "Ozadje" } }, - { "but", { "Toda", "Ampak", "Vendar" } }, + { "but", { "Toda ", "Ampak ", "Vendar " } }, { "examples", { "Primeri", "Scenariji" } }, { "feature", { "Funkcionalnost", "Funkcija", "Možnosti", "Moznosti", "Lastnost", "Značilnost" } }, - { "given", { "Dano", "Podano", "Zaradi", "Privzeto" } }, + { "given", { "Dano ", "Podano ", "Zaradi ", "Privzeto " } }, { "rule", { "Rule" } }, { "scenario", { "Primer", "Scenarij" } }, { "scenarioOutline", { "Struktura scenarija", "Skica", "Koncept", "Oris scenarija", "Osnutek" } }, - { "then", { "Nato", "Potem", "Takrat" } }, - { "when", { "Ko", "Ce", "Če", "Kadar" } } + { "then", { "Nato ", "Potem ", "Takrat " } }, + { "when", { "Ko ", "Ce ", "Če ", "Kadar " } } } }, { "sr_Cyrl", { - { "and", { "*", "И" } }, + { "and", { "* ", "И " } }, { "background", { "Контекст", "Основа", "Позадина" } }, - { "but", { "*", "Али" } }, + { "but", { "* ", "Али " } }, { "examples", { "Примери", "Сценарији" } }, { "feature", { "Функционалност", "Могућност", "Особина" } }, - { "given", { "*", "За дато", "За дате", "За дати" } }, + { "given", { "* ", "За дато ", "За дате ", "За дати " } }, { "rule", { "Правило" } }, { "scenario", { "Пример", "Сценарио", "Пример" } }, { "scenarioOutline", { "Структура сценарија", "Скица", "Концепт" } }, - { "then", { "*", "Онда" } }, - { "when", { "*", "Када", "Кад" } } + { "then", { "* ", "Онда " } }, + { "when", { "* ", "Када ", "Кад " } } } }, { "sr_Latn", { - { "and", { "*", "I" } }, + { "and", { "* ", "I " } }, { "background", { "Kontekst", "Osnova", "Pozadina" } }, - { "but", { "*", "Ali" } }, + { "but", { "* ", "Ali " } }, { "examples", { "Primeri", "Scenariji" } }, { "feature", { "Funkcionalnost", "Mogućnost", "Mogucnost", "Osobina" } }, - { "given", { "*", "Za dato", "Za date", "Za dati" } }, + { "given", { "* ", "Za dato ", "Za date ", "Za dati " } }, { "rule", { "Pravilo" } }, { "scenario", { "Scenario", "Primer" } }, { "scenarioOutline", { "Struktura scenarija", "Skica", "Koncept" } }, - { "then", { "*", "Onda" } }, - { "when", { "*", "Kada", "Kad" } } + { "then", { "* ", "Onda " } }, + { "when", { "* ", "Kada ", "Kad " } } } }, { "sv", { - { "and", { "*", "Och" } }, + { "and", { "* ", "Och " } }, { "background", { "Bakgrund" } }, - { "but", { "*", "Men" } }, + { "but", { "* ", "Men " } }, { "examples", { "Exempel" } }, { "feature", { "Egenskap" } }, - { "given", { "*", "Givet" } }, + { "given", { "* ", "Givet " } }, { "rule", { "Regel" } }, { "scenario", { "Scenario" } }, { "scenarioOutline", { "Abstrakt Scenario", "Scenariomall" } }, - { "then", { "*", "Så" } }, - { "when", { "*", "När" } } + { "then", { "* ", "Så " } }, + { "when", { "* ", "När " } } } }, { "ta", { - { "and", { "*", "மேலும்", "மற்றும்" } }, + { "and", { "* ", "மேலும் ", "மற்றும் " } }, { "background", { "பின்னணி" } }, - { "but", { "*", "ஆனால்" } }, + { "but", { "* ", "ஆனால் " } }, { "examples", { "எடுத்துக்காட்டுகள்", "காட்சிகள்", "நிலைமைகளில்" } }, { "feature", { "அம்சம்", "வணிக தேவை", "திறன்" } }, - { "given", { "*", "கொடுக்கப்பட்ட" } }, + { "given", { "* ", "கொடுக்கப்பட்ட " } }, { "rule", { "Rule" } }, { "scenario", { "உதாரணமாக", "காட்சி" } }, { "scenarioOutline", { "காட்சி சுருக்கம்", "காட்சி வார்ப்புரு" } }, - { "then", { "*", "அப்பொழுது" } }, - { "when", { "*", "எப்போது" } } + { "then", { "* ", "அப்பொழுது " } }, + { "when", { "* ", "எப்போது " } } } }, { "th", { - { "and", { "*", "และ" } }, + { "and", { "* ", "และ " } }, { "background", { "แนวคิด" } }, - { "but", { "*", "แต่" } }, + { "but", { "* ", "แต่ " } }, { "examples", { "ชุดของตัวอย่าง", "ชุดของเหตุการณ์" } }, { "feature", { "โครงหลัก", "ความต้องการทางธุรกิจ", "ความสามารถ" } }, - { "given", { "*", "กำหนดให้" } }, + { "given", { "* ", "กำหนดให้ " } }, { "rule", { "Rule" } }, { "scenario", { "เหตุการณ์" } }, { "scenarioOutline", { "สรุปเหตุการณ์", "โครงสร้างของเหตุการณ์" } }, - { "then", { "*", "ดังนั้น" } }, - { "when", { "*", "เมื่อ" } } + { "then", { "* ", "ดังนั้น " } }, + { "when", { "* ", "เมื่อ " } } } }, { "te", { - { "and", { "*", "మరియు" } }, + { "and", { "* ", "మరియు " } }, { "background", { "నేపథ్యం" } }, - { "but", { "*", "కాని" } }, + { "but", { "* ", "కాని " } }, { "examples", { "ఉదాహరణలు" } }, { "feature", { "గుణము" } }, - { "given", { "*", "చెప్పబడినది" } }, + { "given", { "* ", "చెప్పబడినది " } }, { "rule", { "Rule" } }, { "scenario", { "ఉదాహరణ", "సన్నివేశం" } }, { "scenarioOutline", { "కథనం" } }, - { "then", { "*", "అప్పుడు" } }, - { "when", { "*", "ఈ పరిస్థితిలో" } } + { "then", { "* ", "అప్పుడు " } }, + { "when", { "* ", "ఈ పరిస్థితిలో " } } } }, { "tlh", { - { "and", { "*", "'ej", "latlh" } }, + { "and", { "* ", "'ej ", "latlh " } }, { "background", { "mo'" } }, - { "but", { "*", "'ach", "'a" } }, + { "but", { "* ", "'ach ", "'a " } }, { "examples", { "ghantoH", "lutmey" } }, { "feature", { "Qap", "Qu'meH 'ut", "perbogh", "poQbogh malja'", "laH" } }, - { "given", { "*", "ghu' noblu'", "DaH ghu' bejlu'" } }, + { "given", { "* ", "ghu' noblu' ", "DaH ghu' bejlu' " } }, { "rule", { "Rule" } }, { "scenario", { "lut" } }, { "scenarioOutline", { "lut chovnatlh" } }, - { "then", { "*", "vaj" } }, - { "when", { "*", "qaSDI'" } } + { "then", { "* ", "vaj " } }, + { "when", { "* ", "qaSDI' " } } } }, { "tr", { - { "and", { "*", "Ve" } }, + { "and", { "* ", "Ve " } }, { "background", { "Geçmiş" } }, - { "but", { "*", "Fakat", "Ama" } }, + { "but", { "* ", "Fakat ", "Ama " } }, { "examples", { "Örnekler" } }, { "feature", { "Özellik" } }, - { "given", { "*", "Diyelim ki" } }, + { "given", { "* ", "Diyelim ki " } }, { "rule", { "Kural" } }, { "scenario", { "Örnek", "Senaryo" } }, { "scenarioOutline", { "Senaryo taslağı" } }, - { "then", { "*", "O zaman" } }, - { "when", { "*", "Eğer ki" } } + { "then", { "* ", "O zaman " } }, + { "when", { "* ", "Eğer ki " } } } }, { "tt", { - { "and", { "*", "Һәм", "Вә" } }, + { "and", { "* ", "Һәм ", "Вә " } }, { "background", { "Кереш" } }, - { "but", { "*", "Ләкин", "Әмма" } }, + { "but", { "* ", "Ләкин ", "Әмма " } }, { "examples", { "Үрнәкләр", "Мисаллар" } }, { "feature", { "Мөмкинлек", "Үзенчәлеклелек" } }, - { "given", { "*", "Әйтик" } }, + { "given", { "* ", "Әйтик " } }, { "rule", { "Rule" } }, { "scenario", { "Сценарий" } }, { "scenarioOutline", { "Сценарийның төзелеше" } }, - { "then", { "*", "Нәтиҗәдә" } }, - { "when", { "*", "Әгәр" } } + { "then", { "* ", "Нәтиҗәдә " } }, + { "when", { "* ", "Әгәр " } } } }, { "uk", { - { "and", { "*", "І", "А також", "Та" } }, + { "and", { "* ", "І ", "А також ", "Та " } }, { "background", { "Передумова" } }, - { "but", { "*", "Але" } }, + { "but", { "* ", "Але " } }, { "examples", { "Приклади" } }, { "feature", { "Функціонал" } }, - { "given", { "*", "Припустимо", "Припустимо, що", "Нехай", "Дано" } }, + { "given", { "* ", "Припустимо ", "Припустимо, що ", "Нехай ", "Дано " } }, { "rule", { "Rule" } }, { "scenario", { "Приклад", "Сценарій" } }, { "scenarioOutline", { "Структура сценарію" } }, - { "then", { "*", "То", "Тоді" } }, - { "when", { "*", "Якщо", "Коли" } } + { "then", { "* ", "То ", "Тоді " } }, + { "when", { "* ", "Якщо ", "Коли " } } } }, { "ur", { - { "and", { "*", "اور" } }, + { "and", { "* ", "اور " } }, { "background", { "پس منظر" } }, - { "but", { "*", "لیکن" } }, + { "but", { "* ", "لیکن " } }, { "examples", { "مثالیں" } }, { "feature", { "صلاحیت", "کاروبار کی ضرورت", "خصوصیت" } }, - { "given", { "*", "اگر", "بالفرض", "فرض کیا" } }, + { "given", { "* ", "اگر ", "بالفرض ", "فرض کیا " } }, { "rule", { "Rule" } }, { "scenario", { "منظرنامہ" } }, { "scenarioOutline", { "منظر نامے کا خاکہ" } }, - { "then", { "*", "پھر", "تب" } }, - { "when", { "*", "جب" } } + { "then", { "* ", "پھر ", "تب " } }, + { "when", { "* ", "جب " } } } }, { "uz", { - { "and", { "*", "Ва" } }, + { "and", { "* ", "Ва " } }, { "background", { "Тарих" } }, - { "but", { "*", "Лекин", "Бирок", "Аммо" } }, + { "but", { "* ", "Лекин ", "Бирок ", "Аммо " } }, { "examples", { "Мисоллар" } }, { "feature", { "Функционал" } }, - { "given", { "*", "Belgilangan" } }, + { "given", { "* ", "Belgilangan " } }, { "rule", { "Rule" } }, { "scenario", { "Сценарий" } }, { "scenarioOutline", { "Сценарий структураси" } }, - { "then", { "*", "Унда" } }, - { "when", { "*", "Агар" } } + { "then", { "* ", "Унда " } }, + { "when", { "* ", "Агар " } } } }, { "vi", { - { "and", { "*", "Và" } }, + { "and", { "* ", "Và " } }, { "background", { "Bối cảnh" } }, - { "but", { "*", "Nhưng" } }, + { "but", { "* ", "Nhưng " } }, { "examples", { "Dữ liệu" } }, { "feature", { "Tính năng" } }, - { "given", { "*", "Biết", "Cho" } }, + { "given", { "* ", "Biết ", "Cho " } }, { "rule", { "Rule" } }, { "scenario", { "Tình huống", "Kịch bản" } }, { "scenarioOutline", { "Khung tình huống", "Khung kịch bản" } }, - { "then", { "*", "Thì" } }, - { "when", { "*", "Khi" } } + { "then", { "* ", "Thì " } }, + { "when", { "* ", "Khi " } } } }, { "zh_CN", { - { "and", { "*", "而且", "并且", "同时" } }, + { "and", { "* ", "而且", "并且", "同时" } }, { "background", { "背景" } }, - { "but", { "*", "但是" } }, + { "but", { "* ", "但是" } }, { "examples", { "例子" } }, { "feature", { "功能" } }, - { "given", { "*", "假如", "假设", "假定" } }, + { "given", { "* ", "假如", "假设", "假定" } }, { "rule", { "Rule", "规则" } }, { "scenario", { "场景", "剧本" } }, { "scenarioOutline", { "场景大纲", "剧本大纲" } }, - { "then", { "*", "那么" } }, - { "when", { "*", "当" } } + { "then", { "* ", "那么" } }, + { "when", { "* ", "当" } } } }, { "zh_TW", { - { "and", { "*", "而且", "並且", "同時" } }, + { "and", { "* ", "而且", "並且", "同時" } }, { "background", { "背景" } }, - { "but", { "*", "但是" } }, + { "but", { "* ", "但是" } }, { "examples", { "例子" } }, { "feature", { "功能" } }, - { "given", { "*", "假如", "假設", "假定" } }, + { "given", { "* ", "假如", "假設", "假定" } }, { "rule", { "Rule" } }, { "scenario", { "場景", "劇本" } }, { "scenarioOutline", { "場景大綱", "劇本大綱" } }, - { "then", { "*", "那麼" } }, - { "when", { "*", "當" } } + { "then", { "* ", "那麼" } }, + { "when", { "* ", "當" } } } }, { "mr", { - { "and", { "*", "आणि", "तसेच" } }, + { "and", { "* ", "आणि ", "तसेच " } }, { "background", { "पार्श्वभूमी" } }, - { "but", { "*", "पण", "परंतु" } }, + { "but", { "* ", "पण ", "परंतु " } }, { "examples", { "उदाहरण" } }, { "feature", { "वैशिष्ट्य", "सुविधा" } }, - { "given", { "*", "जर", "दिलेल्या प्रमाणे" } }, + { "given", { "* ", "जर", "दिलेल्या प्रमाणे " } }, { "rule", { "नियम" } }, { "scenario", { "परिदृश्य" } }, { "scenarioOutline", { "परिदृश्य रूपरेखा" } }, - { "then", { "*", "मग", "तेव्हा" } }, - { "when", { "*", "जेव्हा" } } + { "then", { "* ", "मग ", "तेव्हा " } }, + { "when", { "* ", "जेव्हा " } } } }, { "amh", { - { "and", { "*", "እና" } }, + { "and", { "* ", "እና " } }, { "background", { "ቅድመ ሁኔታ", "መነሻ", "መነሻ ሀሳብ" } }, - { "but", { "*", "ግን" } }, + { "but", { "* ", "ግን " } }, { "examples", { "ምሳሌዎች", "ሁናቴዎች" } }, { "feature", { "ስራ", "የተፈለገው ስራ", "የሚፈለገው ድርጊት" } }, - { "given", { "*", "የተሰጠ" } }, + { "given", { "* ", "የተሰጠ " } }, { "rule", { "ህግ" } }, { "scenario", { "ምሳሌ", "ሁናቴ" } }, { "scenarioOutline", { "ሁናቴ ዝርዝር", "ሁናቴ አብነት" } }, - { "then", { "*", "ከዚያ" } }, - { "when", { "*", "መቼ" } } + { "then", { "* ", "ከዚያ " } }, + { "when", { "* ", "መቼ " } } } } }; @@ -1275,40 +1275,5 @@ keywords(const std::string_view& language) return kwms.at(language); } -const string_views& -keywords(const std::string_view& language, const std::string_view& kw) -{ return keywords(language).at(kw); } - -string_views -keywords(const std::string_view& language, const string_views& kws) -{ - string_views svs; - - for (const auto& kw : kws) { - auto ksvs = keywords(language, kw); - svs.insert(svs.end(), ksvs.begin(), ksvs.end()); - } - - return svs; -} - -dialect -get_dialect(const std::string_view& language) -{ - return { - .feature_keywords = keywords(language, "feature"), - .rule_keywords = keywords(language, "rule"), - .scenario_keywords = keywords(language, "scenario"), - .scenario_outline_keywords = keywords(language, "scenarioOutline"), - .background_keywords = keywords(language, "background"), - .examples_keywords = keywords(language, "examples"), - .given_keywords = keywords(language, "given"), - .when_keywords = keywords(language, "when"), - .then_keywords = keywords(language, "then"), - .and_keywords = keywords(language, "and"), - .but_keywords = keywords(language, "but") - }; -} - } diff --git a/cpp/src/lib/gherkin/keywords.cpp b/cpp/src/lib/gherkin/keywords.cpp new file mode 100644 index 000000000..f35720da4 --- /dev/null +++ b/cpp/src/lib/gherkin/keywords.cpp @@ -0,0 +1,40 @@ +#include + +namespace gherkin { + +const string_views& +keywords(const std::string_view& language, const std::string_view& kw) +{ return keywords(language).at(kw); } + +string_views +keywords(const std::string_view& language, const string_views& kws) +{ + string_views svs; + + for (const auto& kw : kws) { + auto ksvs = keywords(language, kw); + svs.insert(svs.end(), ksvs.begin(), ksvs.end()); + } + + return svs; +} + +dialect +get_dialect(const std::string_view& language) +{ + return { + .feature_keywords = keywords(language, "feature"), + .rule_keywords = keywords(language, "rule"), + .scenario_keywords = keywords(language, "scenario"), + .scenario_outline_keywords = keywords(language, "scenarioOutline"), + .background_keywords = keywords(language, "background"), + .examples_keywords = keywords(language, "examples"), + .given_keywords = keywords(language, "given"), + .when_keywords = keywords(language, "when"), + .then_keywords = keywords(language, "then"), + .and_keywords = keywords(language, "and"), + .but_keywords = keywords(language, "but") + }; +} + +} diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index bca5f5642..a10b0af38 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace gherkin { @@ -98,9 +99,25 @@ line::table_cells() const items line::tags() const { - items items; + items tags; - return items; + auto column = indent_ + 1; + auto items_line = subst(trimmed_line_text_, "\\s+(?:#.*)?$", ""); + auto items = split("@", items_line); + + for (std::size_t i = 1; i < items.size(); ++i) { + auto original_item = items[i]; + auto sitem = strip(items[i]); + + tags.emplace_back(item{ + .column = column, + .text = "@" + std::string(sitem) + }); + + column += original_item.size() + 1; + } + + return tags; } void @@ -127,7 +144,7 @@ line::split_table_cells( if (first_cell) { first_cell = false; } else { - f(cell, col); + f(cell, start_col); } cell.clear(); @@ -137,7 +154,7 @@ line::split_table_cells( ++col; if (ch == 'n') { - cell += ch; + cell += '\n'; } else { if (ch != '|' && ch != '\\') { cell += '\\'; diff --git a/cpp/src/lib/gherkin/regex.cpp b/cpp/src/lib/gherkin/regex.cpp new file mode 100644 index 000000000..80f99df9e --- /dev/null +++ b/cpp/src/lib/gherkin/regex.cpp @@ -0,0 +1,52 @@ +#include + +namespace gherkin { + +void +split(const std::string& re, const std::string& expr, strings& list) +{ + list.clear(); + + if (expr.empty()) { + return; + } + + std::regex delim(re); + + auto cur = std::sregex_token_iterator( + expr.begin(), expr.end(), + delim, + -1 + ); + auto end = std::sregex_token_iterator(); + + for( ; cur != end; ++cur ) { + list.push_back(*cur); + } + + if (list.empty() && expr.size() > 0) { + list.push_back(expr); + } +} + +strings +split(const std::string& re, const std::string& expr) +{ + strings list; + + split(re, expr, list); + + return list; +} + +std::string +subst(const std::string& s, const std::string& re, const std::string& what) +{ + return std::regex_replace( + s, + std::regex(re), + what + ); +} + +} diff --git a/cpp/src/lib/gherkin/rule_type.cpp b/cpp/src/lib/gherkin/rule_type.cpp index 02b33f82c..8f306f79d 100644 --- a/cpp/src/lib/gherkin/rule_type.cpp +++ b/cpp/src/lib/gherkin/rule_type.cpp @@ -8,39 +8,39 @@ std::string_view to_string(rule_type r) { static const std::unordered_map rmap = { - { rule_type::none, "none" }, - { rule_type::e_o_f, "e_o_f" }, - { rule_type::empty, "empty" }, - { rule_type::comment, "comment" }, - { rule_type::tag_line, "tag_line" }, - { rule_type::feature_line, "feature_line" }, - { rule_type::rule_line, "rule_line" }, - { rule_type::background_line, "background_line" }, - { rule_type::scenario_line, "scenario_line" }, - { rule_type::examples_line, "examples_line" }, - { rule_type::step_line, "step_line" }, - { rule_type::doc_string_separator, "doc_string_separator" }, - { rule_type::table_row, "table_row" }, - { rule_type::language, "language" }, - { rule_type::other, "other" }, - { rule_type::gherkin_document, "gherkin_document" }, - { rule_type::feature, "feature" }, - { rule_type::feature_header, "feature_header" }, - { rule_type::rule, "rule" }, - { rule_type::rule_header, "rule_header" }, - { rule_type::background, "background" }, - { rule_type::scenario_definition, "scenario_definition" }, - { rule_type::scenario, "scenario" }, - { rule_type::examples_definition, "examples_definition" }, - { rule_type::examples, "examples" }, - { rule_type::examples_table, "examples_table" }, - { rule_type::step, "step" }, - { rule_type::step_arg, "step_arg" }, - { rule_type::data_table, "data_table" }, - { rule_type::doc_string, "doc_string" }, - { rule_type::tags, "tags" }, - { rule_type::description_helper, "description_helper" }, - { rule_type::description, "description" } + { rule_type::none, "None" }, + { rule_type::e_o_f, "EOF" }, + { rule_type::empty, "Empty" }, + { rule_type::comment, "Ccomment" }, + { rule_type::tag_line, "TagLine" }, + { rule_type::feature_line, "FeatureLine" }, + { rule_type::rule_line, "RuleLine" }, + { rule_type::background_line, "BackgroundLine" }, + { rule_type::scenario_line, "ScenarioLine" }, + { rule_type::examples_line, "ExamplesLine" }, + { rule_type::step_line, "StepLine" }, + { rule_type::doc_string_separator, "DocStringSeparator" }, + { rule_type::table_row, "TableRow" }, + { rule_type::language, "Language" }, + { rule_type::other, "Other" }, + { rule_type::gherkin_document, "GherkinDocument" }, + { rule_type::feature, "Feature" }, + { rule_type::feature_header, "FeatureHeader" }, + { rule_type::rule, "Rule" }, + { rule_type::rule_header, "RuleHeader" }, + { rule_type::background, "Background" }, + { rule_type::scenario_definition, "ScenarioDefinition" }, + { rule_type::scenario, "Scenario" }, + { rule_type::examples_definition, "ExamplesDefinition" }, + { rule_type::examples, "Examples" }, + { rule_type::examples_table, "ExamplesTable" }, + { rule_type::step, "Step" }, + { rule_type::step_arg, "StepArg" }, + { rule_type::data_table, "DataTable" }, + { rule_type::doc_string, "DocString" }, + { rule_type::tags, "Tags" }, + { rule_type::description_helper, "DescriptionHelper" }, + { rule_type::description, "Description" } }; return rmap.at(r); diff --git a/cpp/src/lib/gherkin/token_formatter_builder.cpp b/cpp/src/lib/gherkin/token_formatter_builder.cpp new file mode 100644 index 000000000..7432dc7b1 --- /dev/null +++ b/cpp/src/lib/gherkin/token_formatter_builder.cpp @@ -0,0 +1,78 @@ +#include + +#include +#include + +namespace gherkin { + +token_formatter_builder::token_formatter_builder() +{} + +token_formatter_builder::~token_formatter_builder() +{} + +void +token_formatter_builder::reset(std::string_view uri) +{ + formatted_tokens_.clear(); +} + +void +token_formatter_builder::start_rule(rule_type rule_type) +{} + +void +token_formatter_builder::end_rule(rule_type rule_type) +{} + +void +token_formatter_builder::build(const token& token) +{ formatted_tokens_.emplace_back(format_token(token)); } + +strings +token_formatter_builder::get_result() const +{ return formatted_tokens_; } + +std::string +token_formatter_builder::format_token(const token& token) +{ + if (token.is_eof()) { + return "EOF"; + } + + std::ostringstream oss; + + oss + << "(" << token.location.line << ":" << token.location.column << ")" + << token.matched_type << ":" + ; + + if (!token.matched_keyword.empty()) { + oss << "("; + + if (token.matched_keyword_type != cms::step_keyword_type::UNKNOWN) { + oss << token.matched_keyword_type; + } + + oss + << ")" + << token.matched_keyword + ; + } + + oss << "/" << token.matched_text << "/"; + + if (!token.matched_items.empty()) { + strings items; + + for (const auto& i : token.matched_items) { + items.emplace_back(std::to_string(i.column) + ":" + i.text); + } + + oss << join(",", items); + } + + return oss.str(); +} + +} diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 08c7e9f90..7bdbe68f6 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -296,7 +296,9 @@ token_matcher::set_token_matched( } else { token.matched_indent = token.line.indent(); } + token.matched_items = std::move(ti.items); + token.location.column = token.matched_indent + 1; token.matched_gherkin_dialect = dialect_name_; } diff --git a/cpp/src/lib/gherkin/token_scanner.cpp b/cpp/src/lib/gherkin/token_scanner.cpp index 2a8310db9..66961bf39 100644 --- a/cpp/src/lib/gherkin/token_scanner.cpp +++ b/cpp/src/lib/gherkin/token_scanner.cpp @@ -27,7 +27,9 @@ token_scanner::read() return token{ .eof = r.eof, .line = gherkin::line(r.text, line_), - .location = line_ + .location = { + .line = line_ + } }; } From eb19c8001d6f8b30db9fd34c20675b33e39ad0ec Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 23 May 2023 15:53:43 +0200 Subject: [PATCH 32/76] chore: token_matcher and formatter fixes --- cpp/gherkin-cpp.razor | 4 +++- cpp/include/gherkin/token.hpp | 7 +++++-- cpp/include/gherkin/token_matcher.hpp | 9 +++++---- cpp/src/lib/gherkin/ast_builder.cpp | 14 +++++++------- .../lib/gherkin/token_formatter_builder.cpp | 15 ++++++++------- cpp/src/lib/gherkin/token_matcher.cpp | 19 ++++++++++++++----- 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index b4e98aad9..0ac5b1da7 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -74,10 +74,12 @@ class basic_parser : public parser_base { public: using parent = parser_base; - using parent::parser_base; + using parent::parent; using context_type = typename parent::context_type; protected: + using parent::parse; + void parse(context_type& context) override { start_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index 82ce40e81..9b99fbd14 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -14,13 +15,15 @@ namespace gherkin { +namespace cms = cucumber::messages; + struct token { bool eof = false; gherkin::line line; rule_type matched_type; - std::string matched_keyword; - cucumber::messages::step_keyword_type matched_keyword_type; + std::optional matched_keyword; + std::optional matched_keyword_type; std::size_t matched_indent = 0; gherkin::items matched_items; std::string matched_text; diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index 2e068c605..161e68ecf 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include @@ -52,10 +53,10 @@ class token_matcher struct token_info { - std::string text; - std::string keyword; - cucumber::messages::step_keyword_type keyword_type; - std::size_t indent; + std::optional text; + std::optional keyword; + std::optional keyword_type; + std::optional indent; gherkin::items items; }; diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index fa4a29e06..6840baca0 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -102,7 +102,7 @@ ast_builder::make_step(ast_node& node) cms::step m{ .location = get_location(step_line), - .keyword = step_line.matched_keyword, + .keyword = step_line.matched_keyword.value_or(""), .keyword_type = step_line.matched_keyword_type, .text = step_line.matched_text, .id = next_id() @@ -138,7 +138,7 @@ ast_builder::make_doc_string(ast_node& node) .location = get_location(separator_token), .media_type = separator_token.matched_text, .content = content, - .delimiter = separator_token.matched_keyword + .delimiter = separator_token.matched_keyword.value_or("") }; return m; @@ -167,7 +167,7 @@ ast_builder::make_background(ast_node& node) cms::background m{ .location = get_location(background_line), - .keyword = background_line.matched_keyword, + .keyword = background_line.matched_keyword.value_or(""), .name = background_line.matched_text, .id = next_id() }; @@ -188,7 +188,7 @@ ast_builder::make_scenario_definition(ast_node& node) cms::scenario m{ .location = get_location(scenario_line), .tags = get_tags(node), - .keyword = scenario_line.matched_keyword, + .keyword = scenario_line.matched_keyword.value_or(""), .name = scenario_line.matched_text, .id = next_id() }; @@ -210,7 +210,7 @@ ast_builder::make_examples_definition(ast_node& node) cms::examples m{ .location = get_location(examples_line), .tags = get_tags(node), - .keyword = examples_line.matched_keyword, + .keyword = examples_line.matched_keyword.value_or(""), .name = examples_line.matched_text, .id = next_id() }; @@ -276,7 +276,7 @@ ast_builder::make_feature(ast_node& node) cms::feature m{ .location = get_location(feature_line), .tags = get_tags(header), - .keyword = feature_line.matched_keyword, + .keyword = feature_line.matched_keyword.value_or(""), .name = feature_line.matched_text }; @@ -319,7 +319,7 @@ ast_builder::make_rule(ast_node& node) cms::rule m{ .location = get_location(rule_line), .tags = get_tags(header), - .keyword = rule_line.matched_keyword, + .keyword = rule_line.matched_keyword.value_or(""), .name = rule_line.matched_text, .id = next_id() }; diff --git a/cpp/src/lib/gherkin/token_formatter_builder.cpp b/cpp/src/lib/gherkin/token_formatter_builder.cpp index 7432dc7b1..f8f580ada 100644 --- a/cpp/src/lib/gherkin/token_formatter_builder.cpp +++ b/cpp/src/lib/gherkin/token_formatter_builder.cpp @@ -47,17 +47,18 @@ token_formatter_builder::format_token(const token& token) << token.matched_type << ":" ; - if (!token.matched_keyword.empty()) { + if (token.matched_keyword) { + if (token.matched_keyword_type == cms::step_keyword_type::UNKNOWN) { + std::clog << "YALLAH" << std::endl; + } + oss << "("; - if (token.matched_keyword_type != cms::step_keyword_type::UNKNOWN) { - oss << token.matched_keyword_type; + if (token.matched_keyword_type) { + oss << *token.matched_keyword_type; } - oss - << ")" - << token.matched_keyword - ; + oss << ")" << token.matched_keyword.value(); } oss << "/" << token.matched_text << "/"; diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 7bdbe68f6..b7d2333af 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -287,12 +287,21 @@ token_matcher::set_token_matched( ) { token.matched_type = matched_type; - token.matched_text.assign(rstrip(ti.text, "\r\n")); - token.matched_keyword = ti.keyword; - token.matched_keyword_type = ti.keyword_type; + + if (ti.text) { + token.matched_text.assign(rstrip(*ti.text, "\r\n")); + } + + if (ti.keyword) { + token.matched_keyword = *ti.keyword; + } + + if (ti.keyword_type) { + token.matched_keyword_type = *ti.keyword_type; + } if (ti.indent) { - token.matched_indent = ti.indent; + token.matched_indent = *ti.indent; } else { token.matched_indent = token.line.indent(); } @@ -314,7 +323,7 @@ token_matcher::keyword_type(std::string_view keyword) const if (it != keyword_types_.end()) { const auto& kws = it->second; - if (!kws.empty()) { + if (kws.size() == 1) { return kws[0]; } } From 87223a643d4ea2d351a1542f9a254b161c376f65 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 23 May 2023 16:38:28 +0200 Subject: [PATCH 33/76] chore: regex and language detection fixes --- cpp/include/gherkin/regex.hpp | 28 ++++++++++++++++----------- cpp/src/lib/gherkin/line.cpp | 2 +- cpp/src/lib/gherkin/token_matcher.cpp | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/cpp/include/gherkin/regex.hpp b/cpp/include/gherkin/regex.hpp index 85743a0e6..61a0030d4 100644 --- a/cpp/include/gherkin/regex.hpp +++ b/cpp/include/gherkin/regex.hpp @@ -37,19 +37,25 @@ template std::string_view extract_submatch(const SubMatch& sm, Arg&& a) { - std::string_view sv{sm.first, sm.second}; + using arg_type = std::remove_cvref_t; - if constexpr ( - std::is_same_v + constexpr bool is_string = + std::is_same_v || - std::is_same_v - ) { - a.assign(sv); - } else if constexpr ( - std::is_integral_v + std::is_same_v + ; + + constexpr bool is_number = + std::is_integral_v || - std::is_floating_point_v - ) { + std::is_floating_point_v + ; + + std::string_view sv{sm.first, sm.second}; + + if constexpr (is_string) { + a.assign(sv); + } else if constexpr (is_number) { auto [p, ec] = std::from_chars(sv.begin(), sv.end(), a); die_unless( @@ -59,7 +65,7 @@ extract_submatch(const SubMatch& sm, Arg&& a) "\" to ", declname(a) ); - } else if constexpr (!std::is_same_v) { + } else if constexpr (!std::is_same_v) { die("unsupported argument: ", declname(a)); } diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index a10b0af38..401551169 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -136,7 +136,7 @@ line::split_table_cells( return it != end ? *it++ : 0; }; - while (true) { + while (col < row.size()) { auto ch = next_ch(it, end); ++col; diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index b7d2333af..503adfad7 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -7,7 +7,7 @@ namespace gherkin { static const std::regex language_re{ - "\\s*#\\s*language\\s*:\\s*([a-zA-Z\\-_]+)\\s*" + "^\\s*#\\s*language\\s*:\\s*([a-zA-Z\\-_]+)\\s*$" }; token_matcher::token_matcher(const std::string& dialect_name) From 2c790dc8877583d216c20b9aab7e6eedb8c6bc44 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 23 May 2023 17:25:23 +0200 Subject: [PATCH 34/76] fix: proper eof condition --- cpp/src/lib/gherkin/line.cpp | 2 -- cpp/src/lib/gherkin/token_scanner.cpp | 17 +++++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index 401551169..b1044397f 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -164,8 +164,6 @@ line::split_table_cells( } } else if (ch) { cell += ch; - } else { - break; } } } diff --git a/cpp/src/lib/gherkin/token_scanner.cpp b/cpp/src/lib/gherkin/token_scanner.cpp index 66961bf39..75970fd2e 100644 --- a/cpp/src/lib/gherkin/token_scanner.cpp +++ b/cpp/src/lib/gherkin/token_scanner.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -59,16 +60,12 @@ token_scanner::next_line() { next_line_result r; - if (!ip_) { - return r; - } - - std::getline(input(), r.text); - - r.eof = input().eof(); - - if (r.eof) { - ip_.reset(); + if (ip_) { + if (!input().eof()) { + r.eof = !std::getline(input(), r.text); + } else { + ip_.reset(); + } } return r; From d926768d3eccbd452e9c1670d69840aec88b0909 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 23 May 2023 18:06:56 +0200 Subject: [PATCH 35/76] chore: fixed stupid string_view overwrite --- cpp/src/lib/gherkin/token_formatter_builder.cpp | 4 ---- cpp/src/lib/gherkin/token_matcher.cpp | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cpp/src/lib/gherkin/token_formatter_builder.cpp b/cpp/src/lib/gherkin/token_formatter_builder.cpp index f8f580ada..ee54c07b9 100644 --- a/cpp/src/lib/gherkin/token_formatter_builder.cpp +++ b/cpp/src/lib/gherkin/token_formatter_builder.cpp @@ -48,10 +48,6 @@ token_formatter_builder::format_token(const token& token) ; if (token.matched_keyword) { - if (token.matched_keyword_type == cms::step_keyword_type::UNKNOWN) { - std::clog << "YALLAH" << std::endl; - } - oss << "("; if (token.matched_keyword_type) { diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 503adfad7..f41789250 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -243,7 +243,7 @@ token_matcher::match_doc_string_separator(token& token) return match_doc_string_separator_( - token, active_doc_string_separator_, true + token, active_doc_string_separator_, false ); } @@ -259,10 +259,11 @@ token_matcher::match_doc_string_separator_( } std::string content_type; + std::string tseparator = std::string(separator); if (is_open) { content_type = token.line.get_rest_trimmed(separator.size()); - active_doc_string_separator_ = separator; + active_doc_string_separator_ = tseparator; indent_to_remove_ = token.line.indent(); } else { active_doc_string_separator_.clear(); @@ -272,7 +273,7 @@ token_matcher::match_doc_string_separator_( set_token_matched( token, rule_type::doc_string_separator, { .text = content_type, - .keyword = std::string(separator) + .keyword = tseparator } ); From cb6ba14d7354bdc6736eb899f409b54504b940f7 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 23 May 2023 18:46:32 +0200 Subject: [PATCH 36/76] chore: handling utf8 string size --- cpp/include/gherkin/utils.hpp | 3 +++ cpp/src/lib/gherkin/rule_type.cpp | 2 +- cpp/src/lib/gherkin/token_matcher.cpp | 3 ++- cpp/src/lib/gherkin/utils.cpp | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index cca0157b3..e3c74d901 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -5,6 +5,9 @@ namespace gherkin { +std::size_t +utf8_size(std::string_view s); + std::string_view lstrip(std::string_view in, std::string_view chars = " "); diff --git a/cpp/src/lib/gherkin/rule_type.cpp b/cpp/src/lib/gherkin/rule_type.cpp index 8f306f79d..4b7233414 100644 --- a/cpp/src/lib/gherkin/rule_type.cpp +++ b/cpp/src/lib/gherkin/rule_type.cpp @@ -11,7 +11,7 @@ to_string(rule_type r) { rule_type::none, "None" }, { rule_type::e_o_f, "EOF" }, { rule_type::empty, "Empty" }, - { rule_type::comment, "Ccomment" }, + { rule_type::comment, "Comment" }, { rule_type::tag_line, "TagLine" }, { rule_type::feature_line, "FeatureLine" }, { rule_type::rule_line, "RuleLine" }, diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index f41789250..6a197c1dd 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -182,7 +182,8 @@ token_matcher::match_comment(token& token) set_token_matched( token, rule_type::comment, { - .text = std::string(token.line.line_text()) + .text = std::string(token.line.get_line_text(0)), + .indent = 0 } ); diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index 1722b944c..932767e2a 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -5,6 +5,21 @@ namespace gherkin { +std::size_t +utf8_size(std::string_view s) +{ + std::size_t size = s.size(); + std::size_t count = 0; + std::size_t u = 0; + + while(u < size) { + u += mblen(s[u], size - u); + ++count; + } + + return count; +} + std::string_view lstrip(std::string_view in, std::string_view chars) { From 2d42bfb7a6f262da15d48ac73b11bee8b86103b8 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Wed, 24 May 2023 17:16:21 +0200 Subject: [PATCH 37/76] chore: handling multibyte string code points length --- cpp/Makefile | 2 +- cpp/gherkin-dialect.cpp.jq | 3 +- cpp/include/dbj/meta_converter.hpp | 87 +++++++++++++++++ cpp/include/gherkin/line.hpp | 11 --- cpp/include/gherkin/regex.hpp | 52 ++++++---- cpp/include/gherkin/utils.hpp | 131 +++++++++++++++++++++++--- cpp/src/lib/gherkin/dialect.cpp | 26 ++--- cpp/src/lib/gherkin/line.cpp | 114 +++++++++++----------- cpp/src/lib/gherkin/token_matcher.cpp | 10 +- cpp/src/lib/gherkin/utils.cpp | 71 -------------- 10 files changed, 320 insertions(+), 187 deletions(-) create mode 100644 cpp/include/dbj/meta_converter.hpp diff --git a/cpp/Makefile b/cpp/Makefile index e07300bb8..2ff9c24d4 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -91,7 +91,7 @@ include/gherkin/basic_parser.hpp: gherkin-cpp.razor ../gherkin.berp $(berp-generate-parser) rm -f .configured -src/lib/gherkin/dialect.cpp: $(GHERKIN_LANGUAGES_JSON) +src/lib/gherkin/dialect.cpp: $(GHERKIN_LANGUAGES_JSON) gherkin-dialect.cpp.jq jq -f gherkin-dialect.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens diff --git a/cpp/gherkin-dialect.cpp.jq b/cpp/gherkin-dialect.cpp.jq index 73151cc16..34a6b4a6d 100644 --- a/cpp/gherkin-dialect.cpp.jq +++ b/cpp/gherkin-dialect.cpp.jq @@ -9,8 +9,7 @@ " ", ( [ - to_entries[] | .key as $lang_orig | - (.key | split("-") | join("_")) as $lang | .value | + to_entries[] | .key as $lang | .value | [ ("{\n \"",$lang,"\",\n {\n"), (" "), diff --git a/cpp/include/dbj/meta_converter.hpp b/cpp/include/dbj/meta_converter.hpp new file mode 100644 index 000000000..f17117dfd --- /dev/null +++ b/cpp/include/dbj/meta_converter.hpp @@ -0,0 +1,87 @@ +/* +Transform any std string or string view +into any of the 4 std string types, +(c) 2018-2022 by dbj at dbj dot org +https://dbj.org/license_dbj or CC BY SA 4.0 +*/ +#include +#include +#include +#include +#include +#include +#include + +namespace dbj { + +template< typename C > struct is_char +: std::integral_constant::value || +std::is_same::value || +std::is_same::value || +std::is_same::value || +std::is_same::value> +{}; + +// inspired by https://nlitsme.github.io/2019/10/c-type_tests/ +struct not_this_one {}; // Tag type for detecting which begin/ end are being selected + +// Import begin/ end from std here so they are considered +// alongside the fallback (...) overloads in this namespace +using std::begin; +using std::end; + +not_this_one begin( ... ); +not_this_one end( ... ); + +template +struct is_range { + constexpr + static const bool value = + !std::is_same())), not_this_one>::value && + !std::is_same())), not_this_one>::value; +}; + +template +constexpr inline bool is_range_v = dbj::is_range::value ; + +namespace inner { +// (c) 2018 - 2021 by dbj.org, +// Disclaimer, Terms and Conditions: +// https://dbj.org/dbj_license +// +template < typename return_type > +struct meta_converter final +{ +template + return_type operator () (T arg) +{ +if constexpr (dbj::is_range_v) { + static_assert ( + // arg must have this typedef + dbj::is_char< typename T::value_type >{}(), + "can not transform ranges not made of std char types" + ); + return { arg.begin(), arg.end() }; + } +else { + using actual_type + = std::remove_cv_t< std::remove_pointer_t >; +return this->operator()( + std::basic_string{ arg } +); + } + } +}; // meta_converter +} // inner +// all the types required / implicit instantiations +using char_range_to_string + = inner::meta_converter; +using wchar_range_to_string + = inner::meta_converter; +using u16char_range_to_string + = inner::meta_converter; +using u32char_range_to_string + = inner::meta_converter; + +} // dbj diff --git a/cpp/include/gherkin/line.hpp b/cpp/include/gherkin/line.hpp index 54ff2706c..6605fdf88 100644 --- a/cpp/include/gherkin/line.hpp +++ b/cpp/include/gherkin/line.hpp @@ -1,8 +1,6 @@ #pragma once -#include #include -#include #include #include @@ -34,15 +32,6 @@ class line items tags() const; private: - using split_table_cell_function = std::function< - void(std::string_view cell, std::size_t col) - >; - - void split_table_cells( - std::string_view row, - split_table_cell_function f - ) const; - std::string line_text_; std::size_t line_number_ = 0; std::size_t indent_ = 0; diff --git a/cpp/include/gherkin/regex.hpp b/cpp/include/gherkin/regex.hpp index 61a0030d4..6b1d5c018 100644 --- a/cpp/include/gherkin/regex.hpp +++ b/cpp/include/gherkin/regex.hpp @@ -33,16 +33,17 @@ namespace detail { struct null_arg{}; -template -std::string_view +template +auto extract_submatch(const SubMatch& sm, Arg&& a) { using arg_type = std::remove_cvref_t; + using sv_type = std::basic_string_view; constexpr bool is_string = - std::is_same_v + std::is_same_v> || - std::is_same_v + std::is_same_v> ; constexpr bool is_number = @@ -51,7 +52,7 @@ extract_submatch(const SubMatch& sm, Arg&& a) std::is_floating_point_v ; - std::string_view sv{sm.first, sm.second}; + sv_type sv{sm.first, sm.second}; if constexpr (is_string) { a.assign(sv); @@ -88,7 +89,7 @@ check_match_args(MatchResult&& m) } } -template +template void extract_submatches(MatchResult&& m, Args&&... args) { @@ -99,13 +100,19 @@ extract_submatches(MatchResult&& m, Args&&... args) auto mit = m.begin(); if constexpr (nargs > 0) { - (extract_submatch(*++mit, std::forward(args)), ...); + (extract_submatch(*++mit, std::forward(args)), ...); } } -template +template < + typename CharT, + typename MatchResult +> void -extract_submatches(MatchResult&& m, string_views& vs) +extract_submatches( + MatchResult&& m, + std::vector>& vs +) { auto mit = m.begin(); @@ -116,11 +123,11 @@ extract_submatches(MatchResult&& m, string_views& vs) } // namespace detail -template +template bool full_match( - const std::string_view& e, - const std::regex& re, + std::basic_string_view e, + const std::basic_regex& re, Args&&... args ) { @@ -129,30 +136,35 @@ full_match( bool match = std::regex_match(e.begin(), e.end(), m, re); if (match) { - detail::extract_submatches(m, std::forward(args)...); + detail::extract_submatches(m, std::forward(args)...); } return match; } -template +template bool full_match( - const std::string_view& e, - const std::string_view& pat, + std::basic_string_view e, + std::basic_string_view pat, Args&&... args ) { - std::regex re(pat.data(), pat.size()); + std::basic_regex re(pat.data(), pat.size()); return full_match(e, re, std::forward(args)...); } -template +template +bool +full_match(const std::basic_string& e, Args&&... args) +{ return full_match(e, std::forward(args)...); } + +template bool partial_match( - const std::string_view& e, - const std::string_view& pat, + std::basic_string_view e, + std::basic_string_view pat, Args&&... args ) { diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index e3c74d901..7f6398635 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -5,26 +5,131 @@ namespace gherkin { -std::size_t -utf8_size(std::string_view s); +std::string +slurp(const std::string& path); + +namespace detail { + +void +strip(auto& it, auto end, auto chars) +{ + while (it != end) { + std::size_t count = 0; + + for (auto c: chars) { + count += *it == c; + } + + if (count == 0) { + break; + } + + ++it; + } +} + +} // namespace detail + +template +std::basic_string_view +lstrip( + std::basic_string_view in, + std::basic_string_view chars = " " +) +{ + auto it = in.begin(); + auto end = in.end(); + + detail::strip(it, end, chars); + + return {it, end}; +} -std::string_view -lstrip(std::string_view in, std::string_view chars = " "); +template +std::basic_string_view +lstrip( + const std::basic_string& in, + std::basic_string_view chars = " " +) +{ return lstrip(std::basic_string_view{in.data(), in.size()}, chars); } -std::string_view -rstrip(std::string_view in, std::string_view chars = " "); +template +std::basic_string_view +rstrip( + std::basic_string_view in, + std::basic_string_view chars = " " +) +{ + auto it = in.rbegin(); + auto end = in.rend(); + + detail::strip(it, end, chars); + + return {end.base(), it.base()}; +} -std::string_view -strip(std::string_view in, std::string_view chars = " "); +template +std::basic_string_view +rstrip( + const std::basic_string& in, + std::basic_string_view chars = " " +) +{ return rstrip(std::basic_string_view{in.data(), in.size()}, chars); } +template +std::basic_string_view +strip( + std::basic_string_view in, + std::basic_string_view chars = " " +) +{ return lstrip(rstrip(in, chars), chars); } + +template +std::basic_string_view +strip( + const std::basic_string& in, + std::basic_string_view chars = " " +) +{ return strip(std::basic_string_view{in.data(), in.size()}, chars); } + +template void -replace(std::string& s, std::string_view what, std::string_view with); +replace( + std::basic_string& s, + std::basic_string_view what, + std::basic_string_view with +) +{ + std::string::size_type pos; -std::string -replace(const std::string& s, std::string_view what, std::string_view with); + while ((pos = s.find(what)) != std::basic_string::npos) { + s.replace(pos, what.size(), with); + } +} -std::string -slurp(const std::string& path); +template +std::basic_string +replace( + const std::basic_string& s, + std::basic_string_view what, + std::basic_string_view with +) +{ + std::basic_string t = s; + + replace(t, what, with); + + return t; +} + +template +std::basic_string +replace( + const std::basic_string& s, + const std::basic_string& what, + const std::basic_string& with +) +{ return replace(s, what, with); } template struct reverse diff --git a/cpp/src/lib/gherkin/dialect.cpp b/cpp/src/lib/gherkin/dialect.cpp index 7331937bf..2a2dd7c97 100644 --- a/cpp/src/lib/gherkin/dialect.cpp +++ b/cpp/src/lib/gherkin/dialect.cpp @@ -199,7 +199,7 @@ keywords(const std::string_view& language) } }, { - "cy_GB", + "cy-GB", { { "and", { "* ", "A " } }, { "background", { "Cefndir" } }, @@ -295,7 +295,7 @@ keywords(const std::string_view& language) } }, { - "en_Scouse", + "en-Scouse", { { "and", { "* ", "An " } }, { "background", { "Dis is what went down" } }, @@ -311,7 +311,7 @@ keywords(const std::string_view& language) } }, { - "en_au", + "en-au", { { "and", { "* ", "Too right " } }, { "background", { "First off" } }, @@ -327,7 +327,7 @@ keywords(const std::string_view& language) } }, { - "en_lol", + "en-lol", { { "and", { "* ", "AN " } }, { "background", { "B4" } }, @@ -343,7 +343,7 @@ keywords(const std::string_view& language) } }, { - "en_old", + "en-old", { { "and", { "* ", "Ond ", "7 " } }, { "background", { "Aer", "Ær" } }, @@ -359,7 +359,7 @@ keywords(const std::string_view& language) } }, { - "en_pirate", + "en-pirate", { { "and", { "* ", "Aye " } }, { "background", { "Yo-ho-ho" } }, @@ -375,7 +375,7 @@ keywords(const std::string_view& language) } }, { - "en_tx", + "en-tx", { { "and", { "Come hell or high water " } }, { "background", { "Lemme tell y'all a story" } }, @@ -791,7 +791,7 @@ keywords(const std::string_view& language) } }, { - "mk_Cyrl", + "mk-Cyrl", { { "and", { "* ", "И " } }, { "background", { "Контекст", "Содржина" } }, @@ -807,7 +807,7 @@ keywords(const std::string_view& language) } }, { - "mk_Latn", + "mk-Latn", { { "and", { "* ", "I " } }, { "background", { "Kontekst", "Sodrzhina" } }, @@ -999,7 +999,7 @@ keywords(const std::string_view& language) } }, { - "sr_Cyrl", + "sr-Cyrl", { { "and", { "* ", "И " } }, { "background", { "Контекст", "Основа", "Позадина" } }, @@ -1015,7 +1015,7 @@ keywords(const std::string_view& language) } }, { - "sr_Latn", + "sr-Latn", { { "and", { "* ", "I " } }, { "background", { "Kontekst", "Osnova", "Pozadina" } }, @@ -1207,7 +1207,7 @@ keywords(const std::string_view& language) } }, { - "zh_CN", + "zh-CN", { { "and", { "* ", "而且", "并且", "同时" } }, { "background", { "背景" } }, @@ -1223,7 +1223,7 @@ keywords(const std::string_view& language) } }, { - "zh_TW", + "zh-TW", { { "and", { "* ", "而且", "並且", "同時" } }, { "background", { "背景" } }, diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index b1044397f..b363bec3b 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -1,4 +1,7 @@ #include +#include + +#include #include #include @@ -6,7 +9,7 @@ namespace gherkin { -using unescape_pair = std::pair; +using unescape_pair = std::pair; using unescapes = std::vector; static const unescapes line_unescapes = { @@ -15,6 +18,56 @@ static const unescapes line_unescapes = { { "\\n", "\n" } }; +template +void +split_table_cells(std::string_view row, Callabble&& cell_cb) +{ + dbj::wchar_range_to_string to_wstring{}; + + auto wrow = to_wstring(row); + + std::size_t col = 0; + std::size_t start_col = col + 1; + std::wstring cell; + bool first_cell = true; + auto it = wrow.begin(); + auto end = wrow.end(); + auto next_ch = [](auto& it, const auto& end) { + return it != end ? *it++ : 0; + }; + + while (col < wrow.size()) { + auto ch = next_ch(it, end); + ++col; + + if (ch == '|') { + if (first_cell) { + first_cell = false; + } else { + cell_cb(cell, start_col); + } + + cell.clear(); + start_col = col + 1; + } else if (ch == '\\') { + ch = next_ch(it, end); + ++col; + + if (ch == 'n') { + cell += '\n'; + } else { + if (ch != '|' && ch != '\\') { + cell += '\\'; + } + + cell += ch; + } + } else if (ch) { + cell += ch; + } + } +} + line::line() {} @@ -72,21 +125,24 @@ items line::table_cells() const { items items; + dbj::char_range_to_string to_string{}; split_table_cells( strip(trimmed_line_text_), [&](const auto& cell, auto col) { - auto stripped_cell = lstrip(cell); + using namespace std::literals; + + auto stripped_cell = lstrip(cell, L" "sv); auto cell_indent = cell.size() - stripped_cell.size(); - stripped_cell = rstrip(stripped_cell); + stripped_cell = rstrip(stripped_cell, L" "sv); item i{ .column = col + indent_ + cell_indent, - .text = std::string(stripped_cell) + .text = to_string(stripped_cell) }; for (const auto& p : line_unescapes) { - replace(i.text, p.first, p.second); + std::regex_replace(i.text, std::regex(p.first), p.second); } items.emplace_back(std::move(i)); @@ -120,52 +176,4 @@ line::tags() const return tags; } -void -line::split_table_cells( - std::string_view row, - split_table_cell_function f -) const -{ - std::size_t col = 0; - std::size_t start_col = col + 1; - std::string cell; - bool first_cell = true; - auto it = row.begin(); - auto end = row.end(); - auto next_ch = [](auto& it, const auto& end) { - return it != end ? *it++ : 0; - }; - - while (col < row.size()) { - auto ch = next_ch(it, end); - ++col; - - if (ch == '|') { - if (first_cell) { - first_cell = false; - } else { - f(cell, start_col); - } - - cell.clear(); - start_col = col + 1; - } else if (ch == '\\') { - ch = next_ch(it, end); - ++col; - - if (ch == 'n') { - cell += '\n'; - } else { - if (ch != '|' && ch != '\\') { - cell += '\\'; - } - - cell += ch; - } - } else if (ch) { - cell += ch; - } - } -} - } diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 6a197c1dd..d81340305 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -288,10 +288,12 @@ token_matcher::set_token_matched( const token_info& ti ) { + using namespace std::literals; + token.matched_type = matched_type; if (ti.text) { - token.matched_text.assign(rstrip(*ti.text, "\r\n")); + token.matched_text.assign(rstrip(*ti.text, "\r\n"sv)); } if (ti.keyword) { @@ -376,12 +378,14 @@ token_matcher::change_dialect(const std::string& dialect_name) std::string token_matcher::unescape_docstring(const std::string& text) const { + using namespace std::literals; + std::string u = text; if (active_doc_string_separator_ == "\"\"\"") { - replace(u, "\\\"\\\"\\\"", "\"\"\""); + replace(u, "\\\"\\\"\\\""sv, "\"\"\""sv); } else if (active_doc_string_separator_ == "```") { - replace(u, "\\`\\`\\`", "```"); + replace(u, "\\`\\`\\`"sv, "```"sv); } return u; diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index 932767e2a..cdb430044 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -1,79 +1,8 @@ #include #include -#include - namespace gherkin { -std::size_t -utf8_size(std::string_view s) -{ - std::size_t size = s.size(); - std::size_t count = 0; - std::size_t u = 0; - - while(u < size) { - u += mblen(s[u], size - u); - ++count; - } - - return count; -} - -std::string_view -lstrip(std::string_view in, std::string_view chars) -{ - auto it = in.begin(); - auto end = in.end(); - - for (auto c: chars) { - while (it != end && *it == c) { - ++it; - } - } - - return {it, end}; -} - -std::string_view -rstrip(std::string_view in, std::string_view chars) -{ - auto it = in.rbegin(); - auto end = in.rend(); - - for (auto c: chars) { - while (it != end && *it == c) { - ++it; - } - } - - return {end.base(), it.base()}; -} - -std::string_view -strip(std::string_view in, std::string_view chars) -{ return lstrip(rstrip(in, chars), chars); } - -void -replace(std::string& s, std::string_view what, std::string_view with) -{ - std::string::size_type pos; - - while ((pos = s.find(what)) != std::string::npos) { - s.replace(pos, what.size(), with); - } -} - -std::string -replace(const std::string& s, std::string_view what, std::string_view with) -{ - std::string t = s; - - replace(t, what, with); - - return t; -} - std::string slurp(const std::string& path) { From 8d1cff9cc0ac876e1e5a9429e84997222238884b Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Wed, 24 May 2023 19:34:53 +0200 Subject: [PATCH 38/76] chore: fixing mutlibyte handling --- cpp/include/gherkin/utils.hpp | 12 ++++++++---- cpp/src/lib/gherkin/line.cpp | 27 ++++++++++++++++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index 7f6398635..67aeccdc5 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace gherkin { @@ -10,8 +11,9 @@ slurp(const std::string& path); namespace detail { -void -strip(auto& it, auto end, auto chars) +template +auto +strip(auto it, auto end, std::basic_string_view chars) { while (it != end) { std::size_t count = 0; @@ -26,6 +28,8 @@ strip(auto& it, auto end, auto chars) ++it; } + + return it; } } // namespace detail @@ -40,7 +44,7 @@ lstrip( auto it = in.begin(); auto end = in.end(); - detail::strip(it, end, chars); + it = detail::strip(it, end, chars); return {it, end}; } @@ -63,7 +67,7 @@ rstrip( auto it = in.rbegin(); auto end = in.rend(); - detail::strip(it, end, chars); + it = detail::strip(it, end, chars); return {end.base(), it.base()}; } diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index b363bec3b..8e77b5021 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -20,11 +20,13 @@ static const unescapes line_unescapes = { template void -split_table_cells(std::string_view row, Callabble&& cell_cb) +split_table_cells(std::string_view svrow, Callabble&& cell_cb) { dbj::wchar_range_to_string to_wstring{}; - auto wrow = to_wstring(row); + auto wrow = to_wstring(svrow); + wrow = std::regex_replace(wrow, std::wregex(L"^\\s+"), std::wstring{}); + wrow = std::regex_replace(wrow, std::wregex(L"\\s+$"), std::wstring{}); std::size_t col = 0; std::size_t start_col = col + 1; @@ -73,9 +75,12 @@ line::line() line::line(const std::string& line_text, std::size_t line_number) : line_text_(line_text), -line_number_(line_number), -trimmed_line_text_(lstrip(line_text_)) +line_number_(line_number) { + trimmed_line_text_ = std::regex_replace( + line_text_, std::regex("^\\s+"), std::string{} + ); + indent_ = line_text_.size() - trimmed_line_text_.size(); } @@ -126,15 +131,23 @@ line::table_cells() const { items items; dbj::char_range_to_string to_string{}; + dbj::wchar_range_to_string to_wstring{}; + + auto spaces = to_wstring("[ \t\v\f\r\u0085\u00A0]*"); + std::wstring lspaces = L"^"; lspaces += spaces; + std::wregex lstrip(lspaces); + std::wstring rspaces = spaces; rspaces += L"$"; + std::wregex rstrip(rspaces); + std::wstring empty{}; split_table_cells( - strip(trimmed_line_text_), + trimmed_line_text_, [&](const auto& cell, auto col) { using namespace std::literals; - auto stripped_cell = lstrip(cell, L" "sv); + auto stripped_cell = std::regex_replace(cell, lstrip, empty); auto cell_indent = cell.size() - stripped_cell.size(); - stripped_cell = rstrip(stripped_cell, L" "sv); + stripped_cell = std::regex_replace(stripped_cell, rstrip, empty); item i{ .column = col + indent_ + cell_indent, From 3678767ada028d49507f1e70776c6878b8369560 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 25 May 2023 18:08:16 +0200 Subject: [PATCH 39/76] fixing utf8 --- cpp/include/gherkin/utils.hpp | 3 +++ cpp/src/lib/gherkin/line.cpp | 7 +++++++ cpp/src/lib/gherkin/utils.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index 67aeccdc5..8e95f15e9 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -6,6 +6,9 @@ namespace gherkin { +std::size_t +unicode_size(std::string_view s); + std::string slurp(const std::string& path); diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index 8e77b5021..e9f85bff5 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -140,6 +140,13 @@ line::table_cells() const std::wregex rstrip(rspaces); std::wstring empty{}; + { + auto toto = trimmed_line_text_; + auto totos = unicode_size(toto); + + std::clog << "YALLAH" << std::endl; + } + split_table_cells( trimmed_line_text_, [&](const auto& cell, auto col) { diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index cdb430044..9a0f7b291 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -1,8 +1,34 @@ +#include +#include +#include + #include #include +#include namespace gherkin { +std::size_t +unicode_size(std::string_view s) +{ + std::mblen(nullptr, 0); // reset the conversion state + + std::size_t result = 0; + const char* ptr = s.data(); + + for (const char* const end = ptr + s.size(); ptr < end; ++result) { + const int next = std::mblen(ptr, end - ptr); + + if (next == -1) { + throw std::runtime_error("strlen_mb(): conversion error"); + } + + ptr += next; + } + + return result; +} + std::string slurp(const std::string& path) { From 33de48158b9f3c1135617c7d87cf1803f9044a65 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 26 May 2023 15:52:40 +0200 Subject: [PATCH 40/76] chore: codepoint and comment carriage return fixes --- cpp/include/dbj/meta_converter.hpp | 87 --------------- cpp/include/gherkin/line.hpp | 4 +- cpp/include/gherkin/regex.hpp | 5 +- cpp/include/gherkin/utils.hpp | 141 ++++-------------------- cpp/src/lib/gherkin/line.cpp | 69 +++++------- cpp/src/lib/gherkin/pickle_compiler.cpp | 3 +- cpp/src/lib/gherkin/regex.cpp | 4 + cpp/src/lib/gherkin/token_matcher.cpp | 19 ++-- cpp/src/lib/gherkin/utils.cpp | 86 ++++++++++++--- 9 files changed, 142 insertions(+), 276 deletions(-) delete mode 100644 cpp/include/dbj/meta_converter.hpp diff --git a/cpp/include/dbj/meta_converter.hpp b/cpp/include/dbj/meta_converter.hpp deleted file mode 100644 index f17117dfd..000000000 --- a/cpp/include/dbj/meta_converter.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -Transform any std string or string view -into any of the 4 std string types, -(c) 2018-2022 by dbj at dbj dot org -https://dbj.org/license_dbj or CC BY SA 4.0 -*/ -#include -#include -#include -#include -#include -#include -#include - -namespace dbj { - -template< typename C > struct is_char -: std::integral_constant::value || -std::is_same::value || -std::is_same::value || -std::is_same::value || -std::is_same::value> -{}; - -// inspired by https://nlitsme.github.io/2019/10/c-type_tests/ -struct not_this_one {}; // Tag type for detecting which begin/ end are being selected - -// Import begin/ end from std here so they are considered -// alongside the fallback (...) overloads in this namespace -using std::begin; -using std::end; - -not_this_one begin( ... ); -not_this_one end( ... ); - -template -struct is_range { - constexpr - static const bool value = - !std::is_same())), not_this_one>::value && - !std::is_same())), not_this_one>::value; -}; - -template -constexpr inline bool is_range_v = dbj::is_range::value ; - -namespace inner { -// (c) 2018 - 2021 by dbj.org, -// Disclaimer, Terms and Conditions: -// https://dbj.org/dbj_license -// -template < typename return_type > -struct meta_converter final -{ -template - return_type operator () (T arg) -{ -if constexpr (dbj::is_range_v) { - static_assert ( - // arg must have this typedef - dbj::is_char< typename T::value_type >{}(), - "can not transform ranges not made of std char types" - ); - return { arg.begin(), arg.end() }; - } -else { - using actual_type - = std::remove_cv_t< std::remove_pointer_t >; -return this->operator()( - std::basic_string{ arg } -); - } - } -}; // meta_converter -} // inner -// all the types required / implicit instantiations -using char_range_to_string - = inner::meta_converter; -using wchar_range_to_string - = inner::meta_converter; -using u16char_range_to_string - = inner::meta_converter; -using u32char_range_to_string - = inner::meta_converter; - -} // dbj diff --git a/cpp/include/gherkin/line.hpp b/cpp/include/gherkin/line.hpp index 6605fdf88..727129b63 100644 --- a/cpp/include/gherkin/line.hpp +++ b/cpp/include/gherkin/line.hpp @@ -13,7 +13,9 @@ class line line(); line(const std::string& line_text, std::size_t line_number); - std::string_view get_rest_trimmed(std::size_t length) const; + std::string get_rest_trimmed(std::size_t length) const; + std::string get_keyword_trimmed(std::string_view kw) const; + std::string_view get_line_text( std::size_t indent_to_remove = std::string::npos ) const; diff --git a/cpp/include/gherkin/regex.hpp b/cpp/include/gherkin/regex.hpp index 6b1d5c018..7310fd481 100644 --- a/cpp/include/gherkin/regex.hpp +++ b/cpp/include/gherkin/regex.hpp @@ -27,7 +27,10 @@ strings split(const std::string& re, const std::string& expr); std::string -subst(const std::string& s, const std::string& re, const std::string& what); +subst(const std::string& s, const std::string& re, const std::string& what = {}); + +void +subst(std::string& s, const std::string& re, const std::string& what = {}); namespace detail { diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index 8e95f15e9..ec03db76a 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -6,137 +6,38 @@ namespace gherkin { +std::string_view +spaces_pattern(); + +std::string_view +spaces_no_nl_pattern(); + std::size_t -unicode_size(std::string_view s); +codepoint_count(std::string_view s); std::string slurp(const std::string& path); -namespace detail { - -template -auto -strip(auto it, auto end, std::basic_string_view chars) +struct strip_pattern { - while (it != end) { - std::size_t count = 0; - - for (auto c: chars) { - count += *it == c; - } - - if (count == 0) { - break; - } - - ++it; - } - - return it; -} + std::string_view prefix; + std::string_view chars; + std::string_view suffix; -} // namespace detail - -template -std::basic_string_view -lstrip( - std::basic_string_view in, - std::basic_string_view chars = " " -) -{ - auto it = in.begin(); - auto end = in.end(); - - it = detail::strip(it, end, chars); - - return {it, end}; -} - -template -std::basic_string_view -lstrip( - const std::basic_string& in, - std::basic_string_view chars = " " -) -{ return lstrip(std::basic_string_view{in.data(), in.size()}, chars); } - -template -std::basic_string_view -rstrip( - std::basic_string_view in, - std::basic_string_view chars = " " -) -{ - auto it = in.rbegin(); - auto end = in.rend(); - - it = detail::strip(it, end, chars); - - return {end.base(), it.base()}; -} - -template -std::basic_string_view -rstrip( - const std::basic_string& in, - std::basic_string_view chars = " " -) -{ return rstrip(std::basic_string_view{in.data(), in.size()}, chars); } - -template -std::basic_string_view -strip( - std::basic_string_view in, - std::basic_string_view chars = " " -) -{ return lstrip(rstrip(in, chars), chars); } - -template -std::basic_string_view -strip( - const std::basic_string& in, - std::basic_string_view chars = " " -) -{ return strip(std::basic_string_view{in.data(), in.size()}, chars); } - -template -void -replace( - std::basic_string& s, - std::basic_string_view what, - std::basic_string_view with -) -{ - std::string::size_type pos; - - while ((pos = s.find(what)) != std::basic_string::npos) { - s.replace(pos, what.size(), with); - } -} + std::string str() const; +}; -template -std::basic_string -replace( - const std::basic_string& s, - std::basic_string_view what, - std::basic_string_view with -) -{ - std::basic_string t = s; +std::string +strip(std::string_view what, const strip_pattern& p); - replace(t, what, with); +std::string +lstrip(std::string_view in, std::string_view chars = spaces_pattern()); - return t; -} +std::string +rstrip(std::string_view in, std::string_view chars = spaces_pattern()); -template -std::basic_string -replace( - const std::basic_string& s, - const std::basic_string& what, - const std::basic_string& with -) -{ return replace(s, what, with); } +std::string +strip(std::string_view in, std::string_view chars = spaces_pattern()); template struct reverse diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index e9f85bff5..df542c847 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -1,8 +1,6 @@ #include #include -#include - #include #include #include @@ -20,25 +18,19 @@ static const unescapes line_unescapes = { template void -split_table_cells(std::string_view svrow, Callabble&& cell_cb) +split_table_cells(std::string_view row, Callabble&& cell_cb) { - dbj::wchar_range_to_string to_wstring{}; - - auto wrow = to_wstring(svrow); - wrow = std::regex_replace(wrow, std::wregex(L"^\\s+"), std::wstring{}); - wrow = std::regex_replace(wrow, std::wregex(L"\\s+$"), std::wstring{}); - std::size_t col = 0; std::size_t start_col = col + 1; - std::wstring cell; + std::string cell; bool first_cell = true; - auto it = wrow.begin(); - auto end = wrow.end(); + auto it = row.begin(); + auto end = row.end(); auto next_ch = [](auto& it, const auto& end) { return it != end ? *it++ : 0; }; - while (col < wrow.size()) { + while (col < row.size()) { auto ch = next_ch(it, end); ++col; @@ -75,22 +67,25 @@ line::line() line::line(const std::string& line_text, std::size_t line_number) : line_text_(line_text), -line_number_(line_number) +line_number_(line_number), +trimmed_line_text_(lstrip(line_text_)) { - trimmed_line_text_ = std::regex_replace( - line_text_, std::regex("^\\s+"), std::string{} - ); - indent_ = line_text_.size() - trimmed_line_text_.size(); } -std::string_view +std::string line::get_rest_trimmed(std::size_t length) const { auto pos = std::min(length, trimmed_line_text_.size()); - std::string_view sv = trimmed_line_text_; - return strip(sv.substr(pos)); + return strip(trimmed_line_text_.substr(pos)); +} + +std::string +line::get_keyword_trimmed(std::string_view kw) const +{ + // Keyword ends with ':' + return get_rest_trimmed(kw.size() + 1); } std::string_view @@ -130,39 +125,27 @@ items line::table_cells() const { items items; - dbj::char_range_to_string to_string{}; - dbj::wchar_range_to_string to_wstring{}; - - auto spaces = to_wstring("[ \t\v\f\r\u0085\u00A0]*"); - std::wstring lspaces = L"^"; lspaces += spaces; - std::wregex lstrip(lspaces); - std::wstring rspaces = spaces; rspaces += L"$"; - std::wregex rstrip(rspaces); - std::wstring empty{}; - - { - auto toto = trimmed_line_text_; - auto totos = unicode_size(toto); - - std::clog << "YALLAH" << std::endl; - } split_table_cells( trimmed_line_text_, [&](const auto& cell, auto col) { using namespace std::literals; - auto stripped_cell = std::regex_replace(cell, lstrip, empty); - auto cell_indent = cell.size() - stripped_cell.size(); - stripped_cell = std::regex_replace(stripped_cell, rstrip, empty); + auto stripped_cell = lstrip(cell, spaces_no_nl_pattern()); + + auto cell_indent = + codepoint_count(cell) + - + codepoint_count(stripped_cell) + ; item i{ .column = col + indent_ + cell_indent, - .text = to_string(stripped_cell) + .text = rstrip(stripped_cell, spaces_no_nl_pattern()) }; for (const auto& p : line_unescapes) { - std::regex_replace(i.text, std::regex(p.first), p.second); + subst(i.text, p.first, p.second); } items.emplace_back(std::move(i)); @@ -187,7 +170,7 @@ line::tags() const tags.emplace_back(item{ .column = column, - .text = "@" + std::string(sitem) + .text = "@" + sitem }); column += original_item.size() + 1; diff --git a/cpp/src/lib/gherkin/pickle_compiler.cpp b/cpp/src/lib/gherkin/pickle_compiler.cpp index 745556a5a..673c1a47c 100644 --- a/cpp/src/lib/gherkin/pickle_compiler.cpp +++ b/cpp/src/lib/gherkin/pickle_compiler.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace gherkin { @@ -390,7 +391,7 @@ pickle_compiler::interpolate( const auto& value_cell = value_cells[col++]; header = "<" + variable_cell.value + ">"; - replace(iname, header, value_cell.value); + subst(iname, header, value_cell.value); } return iname; diff --git a/cpp/src/lib/gherkin/regex.cpp b/cpp/src/lib/gherkin/regex.cpp index 80f99df9e..a71a371c1 100644 --- a/cpp/src/lib/gherkin/regex.cpp +++ b/cpp/src/lib/gherkin/regex.cpp @@ -49,4 +49,8 @@ subst(const std::string& s, const std::string& re, const std::string& what) ); } +void +subst(std::string& s, const std::string& re, const std::string& what) +{ s = subst(static_cast(s), re, what); } + } diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index d81340305..9eed75d5b 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -133,12 +133,9 @@ token_matcher::match_title_line( continue; } - auto ksize = k.size() + 1; // keyword ends with ':' - auto title = token.line.get_rest_trimmed(ksize); - set_token_matched( token, token_type, { - .text = std::string(title), + .text = token.line.get_keyword_trimmed(k), .keyword = k } ); @@ -180,9 +177,13 @@ token_matcher::match_comment(token& token) return false; } + auto comment_text = std::string(token.line.get_line_text(0)); + + subst(comment_text, "[\\r\\n]+$"); + set_token_matched( token, rule_type::comment, { - .text = std::string(token.line.get_line_text(0)), + .text = comment_text, .indent = 0 } ); @@ -220,7 +221,7 @@ token_matcher::match_step_line(token& token) set_token_matched( token, rule_type::step_line, { - .text = std::string(title), + .text = title, .keyword = std::string(keyword), .keyword_type = keyword_type(keyword) } @@ -380,12 +381,12 @@ token_matcher::unescape_docstring(const std::string& text) const { using namespace std::literals; - std::string u = text; + std::string u; if (active_doc_string_separator_ == "\"\"\"") { - replace(u, "\\\"\\\"\\\""sv, "\"\"\""sv); + u = subst(text, "\\\"\\\"\\\"", "\"\"\""); } else if (active_doc_string_separator_ == "```") { - replace(u, "\\`\\`\\`"sv, "```"sv); + u = subst(text, "\\`\\`\\`", "```"); } return u; diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index 9a0f7b291..75643e3ee 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -1,34 +1,92 @@ -#include -#include -#include - +#include +#include #include #include #include +#include + +#include namespace gherkin { +std::string_view +spaces_pattern() +{ return { "[ \\t\\n\\v\\f\\r\\u0085\\u00A0]+" }; } + +std::string_view +spaces_no_nl_pattern() +{ return { "[ \\t\\v\\f\\r\\u0085\\u00A0]+" }; } + std::size_t -unicode_size(std::string_view s) +codepoint_count(std::string_view s) { - std::mblen(nullptr, 0); // reset the conversion state + std::size_t count = 0; + std::mbstate_t mb = std::mbstate_t(); + auto data = s.data(); + auto size = s.size(); - std::size_t result = 0; - const char* ptr = s.data(); + for (std::size_t i = 0; i < size; ) { + int l = std::mbrlen(&data[i], size - i, &mb); - for (const char* const end = ptr + s.size(); ptr < end; ++result) { - const int next = std::mblen(ptr, end - ptr); + if (l == -2) { + // Incomplete character + l = std::mbrlen(&data[i + 1], size - i - 1, &mb); - if (next == -1) { - throw std::runtime_error("strlen_mb(): conversion error"); + if (l > 0) { + count += l; + i += l; + } + } else { + ++count; + ++i; } - - ptr += next; } + return count; +} + +std::string +strip_pattern::str() const +{ + std::string s(prefix.size() + chars.size() + suffix.size(), ' '); + + s = prefix; + s += chars; + s += suffix; + + return s; +} + +std::string +strip(std::string_view what, const strip_pattern& p) +{ + auto pat = p.str(); + std::regex re(pat); + std::string empty; + std::string result; + + std::regex_replace( + std::back_inserter(result), + what.begin(), what.end(), + re, + empty + ); + return result; } +std::string +lstrip(std::string_view in, std::string_view chars) +{ return strip(in, strip_pattern{ .prefix = "^", .chars = chars }); } + +std::string +rstrip(std::string_view in, std::string_view chars) +{ return strip(in, strip_pattern{ .chars = chars, .suffix = "$" }); } + +std::string +strip(std::string_view in, std::string_view chars) +{ return lstrip(rstrip(in, chars), chars); } + std::string slurp(const std::string& path) { From 874fac22e7a14845d6127fbf82fa610110b4e4bd Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 26 May 2023 19:36:14 +0200 Subject: [PATCH 41/76] chore: fixing some more utf8 stuff --- cpp/include/gherkin/utils.hpp | 196 +++++++++++++++++++++++--- cpp/src/lib/gherkin/line.cpp | 12 +- cpp/src/lib/gherkin/token_matcher.cpp | 2 + cpp/src/lib/gherkin/utils.cpp | 88 +++--------- 4 files changed, 204 insertions(+), 94 deletions(-) diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index ec03db76a..718b44662 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -6,38 +6,196 @@ namespace gherkin { -std::string_view -spaces_pattern(); +std::wstring +to_wstring(const std::string& s); -std::string_view -spaces_no_nl_pattern(); +std::string +to_string(const std::wstring& s); -std::size_t -codepoint_count(std::string_view s); +enum class re_pattern +{ + none, + all_spaces, + spaces_no_nl, + bol, + eol +}; + +template +struct re_patterns +{ -std::string -slurp(const std::string& path); + static + auto + convert(std::string_view sv) + { + if constexpr (sizeof(CharT) > sizeof(char)) { + return to_wstring(std::string(sv)); + } + + return std::string(sv); + } + + static + auto get(re_pattern p) + { + using namespace std::literals; + std::string_view sv; + + switch (p) { + case re_pattern::none: + break; + case re_pattern::all_spaces: + sv = "[ \\t\\n\\v\\f\\r\\u0085\\u00A0]+"sv; + break; + case re_pattern::spaces_no_nl: + sv = "[ \\t\\v\\f\\r\\u0085\\u00A0]+"sv; + break; + case re_pattern::bol: + sv = "^"sv; + break; + case re_pattern::eol: + sv = "$"sv; + break; + } + + return convert(sv); + } +}; + +template struct strip_pattern { - std::string_view prefix; - std::string_view chars; - std::string_view suffix; + using s_type = std::basic_string; + using sv_type = std::basic_string_view; + using pats = re_patterns; + + strip_pattern(re_pattern prefix, sv_type chars) + : strip_pattern(prefix, chars, re_pattern::none) + {} + + strip_pattern(sv_type chars, re_pattern suffix) + : strip_pattern(re_pattern::none, chars, suffix) + {} + + strip_pattern(sv_type chars) + : strip_pattern(re_pattern::none, chars, re_pattern::none) + {} + + strip_pattern(re_pattern prefix, sv_type chars, re_pattern suffix) + { + if (prefix != re_pattern::none) { + s_ = pats::get(prefix); + } - std::string str() const; + s_ += chars; + + if (suffix != re_pattern::none) { + s_ += pats::get(suffix); + } + } + + const s_type& str() const + { return s_; } + + s_type s_; }; -std::string -strip(std::string_view what, const strip_pattern& p); +template +std::basic_string_view +as_view(const std::basic_string& s) +{ return { s.data(), s.size() }; } -std::string -lstrip(std::string_view in, std::string_view chars = spaces_pattern()); +std::size_t +codepoint_count(std::string_view s); std::string -rstrip(std::string_view in, std::string_view chars = spaces_pattern()); +slurp(const std::string& path); -std::string -strip(std::string_view in, std::string_view chars = spaces_pattern()); +template +std::basic_string +strip(std::basic_string_view what, const strip_pattern& p) +{ + std::basic_regex re(p.str()); + std::basic_string empty; + std::basic_string result; + + std::regex_replace( + std::back_inserter(result), + what.begin(), what.end(), + re, + empty + ); + + return result; +} + +template +std::basic_string +lstrip( + std::basic_string_view in, + re_pattern p = re_pattern::all_spaces +) +{ + return + strip( + in, + strip_pattern( + re_pattern::bol, + re_patterns::get(p) + ) + ); +} + +template +std::basic_string +lstrip( + const std::basic_string& in, + re_pattern p = re_pattern::all_spaces +) +{ return lstrip(as_view(in), p); } + +template +std::basic_string +rstrip( + std::basic_string_view in, + re_pattern p = re_pattern::all_spaces +) +{ + return + strip( + in, + strip_pattern( + re_patterns::get(p), + re_pattern::eol + ) + ); +} + +template +std::basic_string +rstrip( + const std::basic_string& in, + re_pattern p = re_pattern::all_spaces +) +{ return rstrip(as_view(in), p); } + +template +std::basic_string +strip( + std::basic_string_view in, + re_pattern p = re_pattern::all_spaces +) +{ return lstrip(rstrip(in, p), p); } + +template +std::basic_string +strip( + const std::basic_string& in, + re_pattern p = re_pattern::all_spaces +) +{ return strip(as_view(in), p); } template struct reverse diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index df542c847..a162c73db 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -131,17 +131,13 @@ line::table_cells() const [&](const auto& cell, auto col) { using namespace std::literals; - auto stripped_cell = lstrip(cell, spaces_no_nl_pattern()); - - auto cell_indent = - codepoint_count(cell) - - - codepoint_count(stripped_cell) - ; + auto wcell = to_wstring(cell); + auto stripped_cell = lstrip(wcell, re_pattern::spaces_no_nl); + auto cell_indent = wcell.size() - stripped_cell.size(); item i{ .column = col + indent_ + cell_indent, - .text = rstrip(stripped_cell, spaces_no_nl_pattern()) + .text = to_string(rstrip(stripped_cell, re_pattern::spaces_no_nl)) }; for (const auto& p : line_unescapes) { diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 9eed75d5b..65753b1e5 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -387,6 +387,8 @@ token_matcher::unescape_docstring(const std::string& text) const u = subst(text, "\\\"\\\"\\\"", "\"\"\""); } else if (active_doc_string_separator_ == "```") { u = subst(text, "\\`\\`\\`", "```"); + } else { + u = text; } return u; diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index 75643e3ee..acb7a73b1 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -9,83 +8,38 @@ namespace gherkin { -std::string_view -spaces_pattern() -{ return { "[ \\t\\n\\v\\f\\r\\u0085\\u00A0]+" }; } +template +auto +mb_conv_core(From&& from, Conv&& c) +{ + using result_type = std::remove_cvref_t; -std::string_view -spaces_no_nl_pattern() -{ return { "[ \\t\\v\\f\\r\\u0085\\u00A0]+" }; } + result_type res; + std::mbstate_t state = std::mbstate_t(); + auto from_data = from.data(); -std::size_t -codepoint_count(std::string_view s) -{ - std::size_t count = 0; - std::mbstate_t mb = std::mbstate_t(); - auto data = s.data(); - auto size = s.size(); - - for (std::size_t i = 0; i < size; ) { - int l = std::mbrlen(&data[i], size - i, &mb); - - if (l == -2) { - // Incomplete character - l = std::mbrlen(&data[i + 1], size - i - 1, &mb); - - if (l > 0) { - count += l; - i += l; - } - } else { - ++count; - ++i; - } - } + std::size_t len = c(nullptr, &from_data, 0, &state); - return count; -} + res.resize(len); -std::string -strip_pattern::str() const -{ - std::string s(prefix.size() + chars.size() + suffix.size(), ' '); + auto res_data = res.data(); - s = prefix; - s += chars; - s += suffix; + int rc = c(&res_data[0], &from_data, len, &state); - return s; -} + if (rc < 0) { + res.clear(); + } -std::string -strip(std::string_view what, const strip_pattern& p) -{ - auto pat = p.str(); - std::regex re(pat); - std::string empty; - std::string result; - - std::regex_replace( - std::back_inserter(result), - what.begin(), what.end(), - re, - empty - ); - - return result; + return res; } -std::string -lstrip(std::string_view in, std::string_view chars) -{ return strip(in, strip_pattern{ .prefix = "^", .chars = chars }); } - -std::string -rstrip(std::string_view in, std::string_view chars) -{ return strip(in, strip_pattern{ .chars = chars, .suffix = "$" }); } +std::wstring +to_wstring(const std::string& s) +{ return mb_conv_core(s, std::mbsrtowcs); } std::string -strip(std::string_view in, std::string_view chars) -{ return lstrip(rstrip(in, chars), chars); } +to_string(const std::wstring& s) +{ return mb_conv_core(s, std::wcsrtombs); } std::string slurp(const std::string& path) From 1e1018f7a1b894d30e0bfed93e8b8c90e33144f3 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sat, 27 May 2023 17:00:19 +0200 Subject: [PATCH 42/76] chore: wide-narrow conversion fixes --- cpp/gherkin-cpp.razor | 8 +- cpp/include/gherkin/basic_parser.hpp | 302 ++++++++++++------------- cpp/include/gherkin/parser_context.hpp | 8 + cpp/include/gherkin/utils.hpp | 46 +++- cpp/src/lib/gherkin/line.cpp | 5 +- cpp/src/lib/gherkin/token_matcher.cpp | 6 +- cpp/src/lib/gherkin/utils.cpp | 34 +-- 7 files changed, 209 insertions(+), 200 deletions(-) diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index 0ac5b1da7..26441f42f 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -39,12 +39,12 @@ public static string NameOf(Rule rule) auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -98,7 +98,7 @@ protected: end_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); if (context.has_errors()) { - // TODO: thow coumpound error + context.report_errors(); } } diff --git a/cpp/include/gherkin/basic_parser.hpp b/cpp/include/gherkin/basic_parser.hpp index 0a177a4cf..bfe18e4ba 100644 --- a/cpp/include/gherkin/basic_parser.hpp +++ b/cpp/include/gherkin/basic_parser.hpp @@ -43,7 +43,7 @@ class basic_parser : public parser_base end_rule(context, rule_type::gherkin_document); if (context.has_errors()) { - // TODO: thow coumpound error + context.report_errors(); } } @@ -444,12 +444,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -483,12 +483,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -522,12 +522,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -600,12 +600,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -680,12 +680,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -753,12 +753,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -830,12 +830,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -909,12 +909,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -981,12 +981,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1069,12 +1069,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1157,12 +1157,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1197,12 +1197,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1293,12 +1293,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1393,12 +1393,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1484,12 +1484,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1593,12 +1593,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1704,12 +1704,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1744,12 +1744,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1854,12 +1854,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -1968,12 +1968,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2073,12 +2073,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2184,12 +2184,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2223,12 +2223,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2304,12 +2304,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2387,12 +2387,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2463,12 +2463,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2543,12 +2543,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2625,12 +2625,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2700,12 +2700,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2791,12 +2791,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2882,12 +2882,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -2922,12 +2922,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3021,12 +3021,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3124,12 +3124,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3218,12 +3218,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3330,12 +3330,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3444,12 +3444,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3484,12 +3484,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3597,12 +3597,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3714,12 +3714,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3822,12 +3822,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3936,12 +3936,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -3966,12 +3966,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -4076,12 +4076,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -4106,12 +4106,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -4193,12 +4193,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -4223,12 +4223,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -4330,12 +4330,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -4360,12 +4360,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); @@ -4444,12 +4444,12 @@ class basic_parser : public parser_base auto error = token.is_eof() - ? error_type::unexpected_eof - : error_type::unexpected_token + ? "unexpected eof: " + : "unexpected token: " ; if (context.stop_at_first_error) { - //throw_error(error, token, expected_tokens); + throw std::runtime_error(error + expected_tokens); } context.add_error(expected_tokens); diff --git a/cpp/include/gherkin/parser_context.hpp b/cpp/include/gherkin/parser_context.hpp index ccb10e1b3..2f609b511 100644 --- a/cpp/include/gherkin/parser_context.hpp +++ b/cpp/include/gherkin/parser_context.hpp @@ -1,5 +1,6 @@ #include #include +#include namespace gherkin { @@ -43,6 +44,13 @@ struct parser_context void add_error(const std::exception& e) { add_error(e.what()); } + + void report_errors() const + { + auto es = join("\n", errors); + + throw std::runtime_error("errors:\n" + es); + } }; } diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index 718b44662..cd82f6691 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -1,22 +1,53 @@ #pragma once +#include #include #include #include namespace gherkin { +// utility wrapper to adapt locale-bound facets for wstring/wbuffer convert +template +struct deletable_facet : Facet +{ + template + deletable_facet(Args&&... args) + : Facet(std::forward(args)...) + {} + + ~deletable_facet() + {} +}; + +inline std::wstring -to_wstring(const std::string& s); +to_wide(const std::string& s) +{ + std::wstring_convert,char32_t> cv; + + auto ws = cv.from_bytes(s); + + return {ws.begin(), ws.end()}; +} +inline std::string -to_string(const std::wstring& s); +to_narrow(const std::wstring& ws) +{ + std::wstring_convert,char32_t> cv; + + std::u32string s{ws.begin(), ws.end()}; + + return cv.to_bytes(s); +} enum class re_pattern { none, all_spaces, spaces_no_nl, + crlf, bol, eol }; @@ -24,17 +55,15 @@ enum class re_pattern template struct re_patterns { - - static auto convert(std::string_view sv) { if constexpr (sizeof(CharT) > sizeof(char)) { - return to_wstring(std::string(sv)); + return to_wide(std::string(sv)); + } else { + return std::string(sv); } - - return std::string(sv); } static @@ -52,6 +81,9 @@ struct re_patterns case re_pattern::spaces_no_nl: sv = "[ \\t\\v\\f\\r\\u0085\\u00A0]+"sv; break; + case re_pattern::crlf: + sv = "\\r\\n"sv; + break; case re_pattern::bol: sv = "^"sv; break; diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index a162c73db..c78e7fc32 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -131,13 +131,14 @@ line::table_cells() const [&](const auto& cell, auto col) { using namespace std::literals; - auto wcell = to_wstring(cell); + auto wcell = to_wide(cell); auto stripped_cell = lstrip(wcell, re_pattern::spaces_no_nl); auto cell_indent = wcell.size() - stripped_cell.size(); + stripped_cell = rstrip(stripped_cell, re_pattern::spaces_no_nl); item i{ .column = col + indent_ + cell_indent, - .text = to_string(rstrip(stripped_cell, re_pattern::spaces_no_nl)) + .text = to_narrow(stripped_cell) }; for (const auto& p : line_unescapes) { diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 65753b1e5..6c55ebedb 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -294,7 +294,7 @@ token_matcher::set_token_matched( token.matched_type = matched_type; if (ti.text) { - token.matched_text.assign(rstrip(*ti.text, "\r\n"sv)); + token.matched_text.assign(rstrip(*ti.text, re_pattern::crlf)); } if (ti.keyword) { @@ -384,9 +384,9 @@ token_matcher::unescape_docstring(const std::string& text) const std::string u; if (active_doc_string_separator_ == "\"\"\"") { - u = subst(text, "\\\"\\\"\\\"", "\"\"\""); + u = subst(text, "\\\\\"\\\\\"\\\\\"", "\"\"\""); } else if (active_doc_string_separator_ == "```") { - u = subst(text, "\\`\\`\\`", "```"); + u = subst(text, "\\\\`\\\\`\\\\`", "```"); } else { u = text; } diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index acb7a73b1..ba2512214 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -8,39 +9,6 @@ namespace gherkin { -template -auto -mb_conv_core(From&& from, Conv&& c) -{ - using result_type = std::remove_cvref_t; - - result_type res; - std::mbstate_t state = std::mbstate_t(); - auto from_data = from.data(); - - std::size_t len = c(nullptr, &from_data, 0, &state); - - res.resize(len); - - auto res_data = res.data(); - - int rc = c(&res_data[0], &from_data, len, &state); - - if (rc < 0) { - res.clear(); - } - - return res; -} - -std::wstring -to_wstring(const std::string& s) -{ return mb_conv_core(s, std::mbsrtowcs); } - -std::string -to_string(const std::wstring& s) -{ return mb_conv_core(s, std::wcsrtombs); } - std::string slurp(const std::string& path) { From d3290e1965b8872b7d48913542204c8b390f6045 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sat, 27 May 2023 18:49:19 +0200 Subject: [PATCH 43/76] chore: tokens acceptance OK --- cpp/include/gherkin/utils.hpp | 3 +++ cpp/src/lib/gherkin/line.cpp | 13 +++++++------ cpp/src/lib/gherkin/token_scanner.cpp | 5 ++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index cd82f6691..edaf04563 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -48,6 +48,7 @@ enum class re_pattern all_spaces, spaces_no_nl, crlf, + cr, bol, eol }; @@ -83,6 +84,8 @@ struct re_patterns break; case re_pattern::crlf: sv = "\\r\\n"sv; + case re_pattern::cr: + sv = "\\r"sv; break; case re_pattern::bol: sv = "^"sv; diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index c78e7fc32..5d63bf5a5 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -20,12 +20,14 @@ template void split_table_cells(std::string_view row, Callabble&& cell_cb) { + auto wrow = to_wide(std::string(row)); + std::size_t col = 0; std::size_t start_col = col + 1; - std::string cell; + std::wstring cell; bool first_cell = true; - auto it = row.begin(); - auto end = row.end(); + auto it = wrow.begin(); + auto end = wrow.end(); auto next_ch = [](auto& it, const auto& end) { return it != end ? *it++ : 0; }; @@ -131,9 +133,8 @@ line::table_cells() const [&](const auto& cell, auto col) { using namespace std::literals; - auto wcell = to_wide(cell); - auto stripped_cell = lstrip(wcell, re_pattern::spaces_no_nl); - auto cell_indent = wcell.size() - stripped_cell.size(); + auto stripped_cell = lstrip(cell, re_pattern::spaces_no_nl); + auto cell_indent = cell.size() - stripped_cell.size(); stripped_cell = rstrip(stripped_cell, re_pattern::spaces_no_nl); item i{ diff --git a/cpp/src/lib/gherkin/token_scanner.cpp b/cpp/src/lib/gherkin/token_scanner.cpp index 75970fd2e..de90b59c8 100644 --- a/cpp/src/lib/gherkin/token_scanner.cpp +++ b/cpp/src/lib/gherkin/token_scanner.cpp @@ -3,6 +3,7 @@ #include #include +#include namespace gherkin { @@ -59,10 +60,12 @@ next_line_result token_scanner::next_line() { next_line_result r; + std::string line; if (ip_) { if (!input().eof()) { - r.eof = !std::getline(input(), r.text); + r.eof = !std::getline(input(), line); + r.text = rstrip(line, re_pattern::cr); } else { ip_.reset(); } From e1f1e75cfc7ae789208c976fc8d3765989fd35aa Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Sun, 28 May 2023 19:51:43 +0200 Subject: [PATCH 44/76] chore: improved api, fixed json output --- cpp/Makefile | 4 +- cpp/gherkin-cpp.razor | 5 +- cpp/include/gherkin/app.hpp | 36 + cpp/include/gherkin/basic_parser.hpp | 4570 ---------------- cpp/include/gherkin/cb_types.hpp | 36 + cpp/include/gherkin/parser.hpp | 4571 ++++++++++++++++- cpp/include/gherkin/parser_base.hpp | 21 +- cpp/include/gherkin/parser_info.hpp | 9 - cpp/include/gherkin/pickle_compiler.hpp | 13 +- .../gherkin/pickle_compiler_context.hpp | 22 + cpp/include/gherkin/sink.hpp | 12 + .../gherkin-generate-tokens.cpp | 8 +- cpp/src/bin/gherkin/gherkin.cpp | 37 +- cpp/src/lib/gherkin/app.cpp | 61 + cpp/src/lib/gherkin/ast_builder.cpp | 8 +- cpp/src/lib/gherkin/pickle_compiler.cpp | 39 +- .../lib/gherkin/pickle_compiler_context.cpp | 19 + 17 files changed, 4816 insertions(+), 4655 deletions(-) create mode 100644 cpp/include/gherkin/app.hpp delete mode 100644 cpp/include/gherkin/basic_parser.hpp create mode 100644 cpp/include/gherkin/cb_types.hpp create mode 100644 cpp/include/gherkin/pickle_compiler_context.hpp create mode 100644 cpp/include/gherkin/sink.hpp create mode 100644 cpp/src/lib/gherkin/app.cpp create mode 100644 cpp/src/lib/gherkin/pickle_compiler_context.cpp diff --git a/cpp/Makefile b/cpp/Makefile index 2ff9c24d4..c8bbd05e9 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -3,7 +3,7 @@ SHELL := /usr/bin/env bash GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json GHERKIN_GENERATED = \ include/gherkin/rule_type.hpp \ - include/gherkin/basic_parser.hpp \ + include/gherkin/parser.hpp \ src/lib/gherkin/dialect.cpp GHERKIN = stage/bin/gherkin GHERKIN_GENERATE_TOKENS = stage/bin/gherkin-generate-tokens @@ -87,7 +87,7 @@ include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) rm -f .configured -include/gherkin/basic_parser.hpp: gherkin-cpp.razor ../gherkin.berp +include/gherkin/parser.hpp: gherkin-cpp.razor ../gherkin.berp $(berp-generate-parser) rm -f .configured diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index 26441f42f..b4aec33de 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -70,16 +70,15 @@ template < typename Scanner = token_scanner, typename Matcher = token_matcher > -class basic_parser : public parser_base +class parser : public parser_base { public: using parent = parser_base; using parent::parent; + using parent::parse; using context_type = typename parent::context_type; protected: - using parent::parse; - void parse(context_type& context) override { start_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); diff --git a/cpp/include/gherkin/app.hpp b/cpp/include/gherkin/app.hpp new file mode 100644 index 000000000..026fab3b9 --- /dev/null +++ b/cpp/include/gherkin/app.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include +#include +#include + +namespace gherkin { + +class app +{ +public: + using parser = gherkin::parser<>; + using parser_result = typename parser::result_type; + using callbacks = gherkin::callbacks; + + app(); + virtual ~app(); + + void include_source(bool f); + void include_ast(bool f); + void include_pickles(bool f); + + void parse(const file& f, const callbacks& cbs = {}); + void parse(const cms::envelope& e, const callbacks& cbs = {}); + void parse(const cms::source& s, const callbacks& cbs = {}); + +private: + parser p_; + bool include_source_ = true; + bool include_ast_ = true; + bool include_pickles_ = true; +}; + +} diff --git a/cpp/include/gherkin/basic_parser.hpp b/cpp/include/gherkin/basic_parser.hpp deleted file mode 100644 index bfe18e4ba..000000000 --- a/cpp/include/gherkin/basic_parser.hpp +++ /dev/null @@ -1,4570 +0,0 @@ -// This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. -#include -#include - -namespace gherkin { - -enum class error_type -{ - unexpected_eof, - unexpected_token -}; - -template < - typename Builder = ast_builder, - typename Scanner = token_scanner, - typename Matcher = token_matcher -> -class basic_parser : public parser_base -{ -public: - using parent = parser_base; - using parent::parent; - using context_type = typename parent::context_type; - -protected: - using parent::parse; - - void parse(context_type& context) override - { - start_rule(context, rule_type::gherkin_document); - - std::size_t state = 0; - - while (true) { - auto token = context.read_token(); - state = match_token(state, token, context); - - if (token.is_eof()) { - break; - } - } - - end_rule(context, rule_type::gherkin_document); - - if (context.has_errors()) { - context.report_errors(); - } - } - - void build(context_type& context, token& token) - { context.builder.build(token); } - - void start_rule(context_type& context, rule_type rule_type) - { - handle_ast_error( - context, - rule_type, - [&context](auto rtype) { - context.builder.start_rule(rtype); - } - ); - } - - void end_rule(context_type& context, rule_type rule_type) - { - handle_ast_error( - context, - rule_type, - [&context](auto rtype) { - context.builder.end_rule(rtype); - } - ); - } - - template - bool handle_external_error( - context_type& context, - bool default_value, - Argument&& argument, - Action&& action - ) - { - using ret_type = decltype(action(argument)); - - if (context.stop_at_first_error) { - if constexpr (std::is_same_v) { - action(argument); - return default_value; - } else { - return action(argument); - } - } - - try { - if constexpr (std::is_same_v) { - action(argument); - return default_value; - } else { - return action(argument); - } - } catch (const std::exception& e) { - context.add_error(e); - } - - return default_value; - } - - template - void handle_ast_error( - context_type& context, - Argument&& argument, - Action&& action - ) - { handle_external_error(context, true, argument, action); } - - - bool match_e_o_f(context_type& context, token& token) - { - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_e_o_f(t); - } - ); - } - - bool match_empty(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_empty(t); - } - ); - } - - bool match_comment(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_comment(t); - } - ); - } - - bool match_tag_line(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_tag_line(t); - } - ); - } - - bool match_feature_line(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_feature_line(t); - } - ); - } - - bool match_rule_line(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_rule_line(t); - } - ); - } - - bool match_background_line(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_background_line(t); - } - ); - } - - bool match_scenario_line(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_scenario_line(t); - } - ); - } - - bool match_examples_line(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_examples_line(t); - } - ); - } - - bool match_step_line(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_step_line(t); - } - ); - } - - bool match_doc_string_separator(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_doc_string_separator(t); - } - ); - } - - bool match_table_row(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_table_row(t); - } - ); - } - - bool match_language(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_language(t); - } - ); - } - - bool match_other(context_type& context, token& token) - { - if (token.is_eof()) { - return false; - } - - return - handle_external_error( - context, - false, - token, - [&context](auto& t) { - return context.matcher.match_other(t); - } - ); - } - - - bool lookahead_0(context_type& context, token& current_token) - { - current_token.detach(); - token token; - token_queue queue; - bool match = false; - - while (true) { - token = context.read_token(); - token.detach(); - queue.push_back(token); - - if (match_scenario_line(context, token) || false) { - match = true; - break; - } - - if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { - break; - } - } - - context.push_tokens(queue); - - return match; - } - - bool lookahead_1(context_type& context, token& current_token) - { - current_token.detach(); - token token; - token_queue queue; - bool match = false; - - while (true) { - token = context.read_token(); - token.detach(); - queue.push_back(token); - - if (match_examples_line(context, token) || false) { - match = true; - break; - } - - if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { - break; - } - } - - context.push_tokens(queue); - - return match; - } - - - // Start - std::size_t match_token_at_0(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - build(context, token); - return 42; - } - if (match_language(context, token)) { - start_rule(context, rule_type::feature); - start_rule(context, rule_type::feature_header); - build(context, token); - return 1; - } - if (match_tag_line(context, token)) { - start_rule(context, rule_type::feature); - start_rule(context, rule_type::feature_header); - start_rule(context, rule_type::tags); - build(context, token); - return 2; - } - if (match_feature_line(context, token)) { - start_rule(context, rule_type::feature); - start_rule(context, rule_type::feature_header); - build(context, token); - return 3; - } - if (match_comment(context, token)) { - build(context, token); - return 0; - } - if (match_empty(context, token)) { - build(context, token); - return 0; - } - - /* "State: 0 - Start" */ - std::string expected_tokens = "#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 0; - } - - // GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 - std::size_t match_token_at_1(token& token, context_type& context) - { - if (match_tag_line(context, token)) { - start_rule(context, rule_type::tags); - build(context, token); - return 2; - } - if (match_feature_line(context, token)) { - build(context, token); - return 3; - } - if (match_comment(context, token)) { - build(context, token); - return 1; - } - if (match_empty(context, token)) { - build(context, token); - return 1; - } - - /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ - std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 1; - } - - // GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 - std::size_t match_token_at_2(token& token, context_type& context) - { - if (match_tag_line(context, token)) { - build(context, token); - return 2; - } - if (match_feature_line(context, token)) { - end_rule(context, rule_type::tags); - build(context, token); - return 3; - } - if (match_comment(context, token)) { - build(context, token); - return 2; - } - if (match_empty(context, token)) { - build(context, token); - return 2; - } - - /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 2; - } - - // GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 - std::size_t match_token_at_3(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::feature_header); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 3; - } - if (match_comment(context, token)) { - build(context, token); - return 5; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::background); - build(context, token); - return 6; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 4; - } - - /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 3; - } - - // GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 - std::size_t match_token_at_4(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 5; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::background); - build(context, token); - return 6; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 4; - } - - /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 4; - } - - // GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 - std::size_t match_token_at_5(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::feature_header); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 5; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::background); - build(context, token); - return 6; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::feature_header); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 5; - } - - /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 5; - } - - // GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 - std::size_t match_token_at_6(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 6; - } - if (match_comment(context, token)) { - build(context, token); - return 8; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 7; - } - - /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 6; - } - - // GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 - std::size_t match_token_at_7(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 8; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 7; - } - - /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 7; - } - - // GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 - std::size_t match_token_at_8(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 8; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 8; - } - - /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 8; - } - - // GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 - std::size_t match_token_at_9(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::data_table); - build(context, token); - return 10; - } - if (match_doc_string_separator(context, token)) { - start_rule(context, rule_type::doc_string); - build(context, token); - return 49; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 9; - } - if (match_empty(context, token)) { - build(context, token); - return 9; - } - - /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ - std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 9; - } - - // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 - std::size_t match_token_at_10(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 10; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 10; - } - if (match_empty(context, token)) { - build(context, token); - return 10; - } - - /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 10; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 - std::size_t match_token_at_11(token& token, context_type& context) - { - if (match_tag_line(context, token)) { - build(context, token); - return 11; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::tags); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_comment(context, token)) { - build(context, token); - return 11; - } - if (match_empty(context, token)) { - build(context, token); - return 11; - } - - /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 11; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 - std::size_t match_token_at_12(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 12; - } - if (match_comment(context, token)) { - build(context, token); - return 14; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 13; - } - - /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 12; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 - std::size_t match_token_at_13(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 14; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 13; - } - - /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 13; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 - std::size_t match_token_at_14(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 14; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 14; - } - - /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 14; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 - std::size_t match_token_at_15(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::data_table); - build(context, token); - return 16; - } - if (match_doc_string_separator(context, token)) { - start_rule(context, rule_type::doc_string); - build(context, token); - return 47; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 15; - } - if (match_empty(context, token)) { - build(context, token); - return 15; - } - - /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ - std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 15; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 - std::size_t match_token_at_16(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 16; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 16; - } - if (match_empty(context, token)) { - build(context, token); - return 16; - } - - /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 16; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 - std::size_t match_token_at_17(token& token, context_type& context) - { - if (match_tag_line(context, token)) { - build(context, token); - return 17; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::tags); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_comment(context, token)) { - build(context, token); - return 17; - } - if (match_empty(context, token)) { - build(context, token); - return 17; - } - - /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 17; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 - std::size_t match_token_at_18(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 18; - } - if (match_comment(context, token)) { - build(context, token); - return 20; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::examples_table); - build(context, token); - return 21; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 19; - } - - /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 18; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 - std::size_t match_token_at_19(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 20; - } - if (match_table_row(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_table); - build(context, token); - return 21; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 19; - } - - /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 19; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 - std::size_t match_token_at_20(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 20; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::examples_table); - build(context, token); - return 21; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 20; - } - - /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 20; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 - std::size_t match_token_at_21(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 21; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 21; - } - if (match_empty(context, token)) { - build(context, token); - return 21; - } - - /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 21; - } - - // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 - std::size_t match_token_at_22(token& token, context_type& context) - { - if (match_tag_line(context, token)) { - build(context, token); - return 22; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::tags); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 22; - } - if (match_empty(context, token)) { - build(context, token); - return 22; - } - - /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 22; - } - - // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 - std::size_t match_token_at_23(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 25; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::background); - build(context, token); - return 26; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 24; - } - - /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 23; - } - - // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 - std::size_t match_token_at_24(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 25; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::background); - build(context, token); - return 26; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 24; - } - - /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 24; - } - - // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 - std::size_t match_token_at_25(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 25; - } - if (match_background_line(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::background); - build(context, token); - return 26; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::rule_header); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::rule_header); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 25; - } - - /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 25; - } - - // GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 - std::size_t match_token_at_26(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 26; - } - if (match_comment(context, token)) { - build(context, token); - return 28; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 27; - } - - /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 26; - } - - // GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 - std::size_t match_token_at_27(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 28; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 27; - } - - /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 27; - } - - // GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 - std::size_t match_token_at_28(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 28; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 28; - } - - /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 28; - } - - // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 - std::size_t match_token_at_29(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::data_table); - build(context, token); - return 30; - } - if (match_doc_string_separator(context, token)) { - start_rule(context, rule_type::doc_string); - build(context, token); - return 45; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 29; - } - if (match_empty(context, token)) { - build(context, token); - return 29; - } - - /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ - std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 29; - } - - // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 - std::size_t match_token_at_30(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 30; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 30; - } - if (match_empty(context, token)) { - build(context, token); - return 30; - } - - /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 30; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 - std::size_t match_token_at_31(token& token, context_type& context) - { - if (match_tag_line(context, token)) { - build(context, token); - return 31; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::tags); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_comment(context, token)) { - build(context, token); - return 31; - } - if (match_empty(context, token)) { - build(context, token); - return 31; - } - - /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 31; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 - std::size_t match_token_at_32(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 32; - } - if (match_comment(context, token)) { - build(context, token); - return 34; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 33; - } - - /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 32; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 - std::size_t match_token_at_33(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 34; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 33; - } - - /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 33; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 - std::size_t match_token_at_34(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 34; - } - if (match_step_line(context, token)) { - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 34; - } - - /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 34; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 - std::size_t match_token_at_35(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::data_table); - build(context, token); - return 36; - } - if (match_doc_string_separator(context, token)) { - start_rule(context, rule_type::doc_string); - build(context, token); - return 43; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 35; - } - if (match_empty(context, token)) { - build(context, token); - return 35; - } - - /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ - std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 35; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 - std::size_t match_token_at_36(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 36; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::data_table); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 36; - } - if (match_empty(context, token)) { - build(context, token); - return 36; - } - - /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 36; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 - std::size_t match_token_at_37(token& token, context_type& context) - { - if (match_tag_line(context, token)) { - build(context, token); - return 37; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::tags); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_comment(context, token)) { - build(context, token); - return 37; - } - if (match_empty(context, token)) { - build(context, token); - return 37; - } - - /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ - std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 37; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 - std::size_t match_token_at_38(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_empty(context, token)) { - build(context, token); - return 38; - } - if (match_comment(context, token)) { - build(context, token); - return 40; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::examples_table); - build(context, token); - return 41; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - start_rule(context, rule_type::description); - build(context, token); - return 39; - } - - /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ - std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 38; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 - std::size_t match_token_at_39(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - end_rule(context, rule_type::description); - build(context, token); - return 40; - } - if (match_table_row(context, token)) { - end_rule(context, rule_type::description); - start_rule(context, rule_type::examples_table); - build(context, token); - return 41; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::description); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_other(context, token)) { - build(context, token); - return 39; - } - - /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ - std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 39; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 - std::size_t match_token_at_40(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_comment(context, token)) { - build(context, token); - return 40; - } - if (match_table_row(context, token)) { - start_rule(context, rule_type::examples_table); - build(context, token); - return 41; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_empty(context, token)) { - build(context, token); - return 40; - } - - /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ - std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 40; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 - std::size_t match_token_at_41(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_table_row(context, token)) { - build(context, token); - return 41; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::examples_table); - end_rule(context, rule_type::examples); - end_rule(context, rule_type::examples_definition); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 41; - } - if (match_empty(context, token)) { - build(context, token); - return 41; - } - - /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ - std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 41; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 - std::size_t match_token_at_43(token& token, context_type& context) - { - if (match_doc_string_separator(context, token)) { - build(context, token); - return 44; - } - if (match_other(context, token)) { - build(context, token); - return 43; - } - - /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = "#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 43; - } - - // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 - std::size_t match_token_at_44(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 35; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 37; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 38; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 44; - } - if (match_empty(context, token)) { - build(context, token); - return 44; - } - - /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 44; - } - - // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 - std::size_t match_token_at_45(token& token, context_type& context) - { - if (match_doc_string_separator(context, token)) { - build(context, token); - return 46; - } - if (match_other(context, token)) { - build(context, token); - return 45; - } - - /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = "#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 45; - } - - // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 - std::size_t match_token_at_46(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 29; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 31; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 32; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::rule); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 46; - } - if (match_empty(context, token)) { - build(context, token); - return 46; - } - - /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 46; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 - std::size_t match_token_at_47(token& token, context_type& context) - { - if (match_doc_string_separator(context, token)) { - build(context, token); - return 48; - } - if (match_other(context, token)) { - build(context, token); - return 47; - } - - /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = "#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 47; - } - - // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 - std::size_t match_token_at_48(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 15; - } - if (match_tag_line(context, token)) { - if (lookahead_1(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 17; - } - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_examples_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::examples_definition); - start_rule(context, rule_type::examples); - build(context, token); - return 18; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::scenario); - end_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 48; - } - if (match_empty(context, token)) { - build(context, token); - return 48; - } - - /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 48; - } - - // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 - std::size_t match_token_at_49(token& token, context_type& context) - { - if (match_doc_string_separator(context, token)) { - build(context, token); - return 50; - } - if (match_other(context, token)) { - build(context, token); - return 49; - } - - /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ - std::string expected_tokens = "#DocStringSeparator, #Other"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 49; - } - - // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 - std::size_t match_token_at_50(token& token, context_type& context) - { - if (match_e_o_f(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - end_rule(context, rule_type::feature); - build(context, token); - return 42; - } - if (match_step_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - start_rule(context, rule_type::step); - build(context, token); - return 9; - } - if (match_tag_line(context, token)) { - if (lookahead_0(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::tags); - build(context, token); - return 11; - } - } - if (match_tag_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - start_rule(context, rule_type::tags); - build(context, token); - return 22; - } - if (match_scenario_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::scenario_definition); - start_rule(context, rule_type::scenario); - build(context, token); - return 12; - } - if (match_rule_line(context, token)) { - end_rule(context, rule_type::doc_string); - end_rule(context, rule_type::step); - end_rule(context, rule_type::background); - start_rule(context, rule_type::rule); - start_rule(context, rule_type::rule_header); - build(context, token); - return 23; - } - if (match_comment(context, token)) { - build(context, token); - return 50; - } - if (match_empty(context, token)) { - build(context, token); - return 50; - } - - /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ - std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - - auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " - ; - - if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); - } - - context.add_error(expected_tokens); - - return 50; - } - - std::size_t match_token(std::size_t state, token& token, context_type& context) - { - switch (state) { - case 0: - return match_token_at_0(token, context); - case 1: - return match_token_at_1(token, context); - case 2: - return match_token_at_2(token, context); - case 3: - return match_token_at_3(token, context); - case 4: - return match_token_at_4(token, context); - case 5: - return match_token_at_5(token, context); - case 6: - return match_token_at_6(token, context); - case 7: - return match_token_at_7(token, context); - case 8: - return match_token_at_8(token, context); - case 9: - return match_token_at_9(token, context); - case 10: - return match_token_at_10(token, context); - case 11: - return match_token_at_11(token, context); - case 12: - return match_token_at_12(token, context); - case 13: - return match_token_at_13(token, context); - case 14: - return match_token_at_14(token, context); - case 15: - return match_token_at_15(token, context); - case 16: - return match_token_at_16(token, context); - case 17: - return match_token_at_17(token, context); - case 18: - return match_token_at_18(token, context); - case 19: - return match_token_at_19(token, context); - case 20: - return match_token_at_20(token, context); - case 21: - return match_token_at_21(token, context); - case 22: - return match_token_at_22(token, context); - case 23: - return match_token_at_23(token, context); - case 24: - return match_token_at_24(token, context); - case 25: - return match_token_at_25(token, context); - case 26: - return match_token_at_26(token, context); - case 27: - return match_token_at_27(token, context); - case 28: - return match_token_at_28(token, context); - case 29: - return match_token_at_29(token, context); - case 30: - return match_token_at_30(token, context); - case 31: - return match_token_at_31(token, context); - case 32: - return match_token_at_32(token, context); - case 33: - return match_token_at_33(token, context); - case 34: - return match_token_at_34(token, context); - case 35: - return match_token_at_35(token, context); - case 36: - return match_token_at_36(token, context); - case 37: - return match_token_at_37(token, context); - case 38: - return match_token_at_38(token, context); - case 39: - return match_token_at_39(token, context); - case 40: - return match_token_at_40(token, context); - case 41: - return match_token_at_41(token, context); - case 43: - return match_token_at_43(token, context); - case 44: - return match_token_at_44(token, context); - case 45: - return match_token_at_45(token, context); - case 46: - return match_token_at_46(token, context); - case 47: - return match_token_at_47(token, context); - case 48: - return match_token_at_48(token, context); - case 49: - return match_token_at_49(token, context); - case 50: - return match_token_at_50(token, context); - default: - context.add_error("invalid operation: " + std::to_string(state)); - return -1; - } - } -}; - -} diff --git a/cpp/include/gherkin/cb_types.hpp b/cpp/include/gherkin/cb_types.hpp new file mode 100644 index 000000000..302f52167 --- /dev/null +++ b/cpp/include/gherkin/cb_types.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include + +#include +#include + +namespace gherkin { + +namespace cms = cucumber::messages; + +using source_cb = std::function; +using pickle_cb = std::function; + +template +struct callbacks +{ + using ast_cb = std::function; + + gherkin::source_cb source; + ast_cb ast; + gherkin::pickle_cb pickle; +}; + +template +void +call_cb(Callback& cb, const Msg& m) +{ + if (cb) { + cb(m); + } +} + +} diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index e1b7faf06..e98eaeb25 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,36 +1,4569 @@ -#include -#include -#include -#include +// This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. +#include +#include namespace gherkin { +enum class error_type +{ + unexpected_eof, + unexpected_token +}; + template < - typename Builder = ast_builder + typename Builder = ast_builder, + typename Scanner = token_scanner, + typename Matcher = token_matcher > -class parser : public basic_parser +class parser : public parser_base { public: - using parent = basic_parser; - using result_type = typename parent::result_type; + using parent = parser_base; + using parent::parent; + using parent::parse; + using context_type = typename parent::context_type; + +protected: + void parse(context_type& context) override + { + start_rule(context, rule_type::gherkin_document); + + std::size_t state = 0; + + while (true) { + auto token = context.read_token(); + state = match_token(state, token, context); + + if (token.is_eof()) { + break; + } + } + + end_rule(context, rule_type::gherkin_document); + + if (context.has_errors()) { + context.report_errors(); + } + } + + void build(context_type& context, token& token) + { context.builder.build(token); } + + void start_rule(context_type& context, rule_type rule_type) + { + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.start_rule(rtype); + } + ); + } + + void end_rule(context_type& context, rule_type rule_type) + { + handle_ast_error( + context, + rule_type, + [&context](auto rtype) { + context.builder.end_rule(rtype); + } + ); + } + + template + bool handle_external_error( + context_type& context, + bool default_value, + Argument&& argument, + Action&& action + ) + { + using ret_type = decltype(action(argument)); + + if (context.stop_at_first_error) { + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } + } + + try { + if constexpr (std::is_same_v) { + action(argument); + return default_value; + } else { + return action(argument); + } + } catch (const std::exception& e) { + context.add_error(e); + } + + return default_value; + } + + template + void handle_ast_error( + context_type& context, + Argument&& argument, + Action&& action + ) + { handle_external_error(context, true, argument, action); } + + + bool match_e_o_f(context_type& context, token& token) + { + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_e_o_f(t); + } + ); + } + + bool match_empty(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_empty(t); + } + ); + } + + bool match_comment(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_comment(t); + } + ); + } + + bool match_tag_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_tag_line(t); + } + ); + } + + bool match_feature_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_feature_line(t); + } + ); + } + + bool match_rule_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_rule_line(t); + } + ); + } + + bool match_background_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_background_line(t); + } + ); + } + + bool match_scenario_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_scenario_line(t); + } + ); + } + + bool match_examples_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_examples_line(t); + } + ); + } - parser(const parser_info& pi = {}) - : parent(pi) - {} + bool match_step_line(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_step_line(t); + } + ); + } + + bool match_doc_string_separator(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_doc_string_separator(t); + } + ); + } + + bool match_table_row(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_table_row(t); + } + ); + } + + bool match_language(context_type& context, token& token) + { + if (token.is_eof()) { + return false; + } + + return + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_language(t); + } + ); + } - result_type parse(const file& file) + bool match_other(context_type& context, token& token) { + if (token.is_eof()) { + return false; + } + return - parse(cms::source{ - .uri = file.path, - .data = slurp(file.path) - }); + handle_external_error( + context, + false, + token, + [&context](auto& t) { + return context.matcher.match_other(t); + } + ); + } + + + bool lookahead_0(context_type& context, token& current_token) + { + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach(); + queue.push_back(token); + + if (match_scenario_line(context, token) || false) { + match = true; + break; + } + + if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { + break; + } + } + + context.push_tokens(queue); + + return match; + } + + bool lookahead_1(context_type& context, token& current_token) + { + current_token.detach(); + token token; + token_queue queue; + bool match = false; + + while (true) { + token = context.read_token(); + token.detach(); + queue.push_back(token); + + if (match_examples_line(context, token) || false) { + match = true; + break; + } + + if (!(match_empty(context, token) || match_comment(context, token) || match_tag_line(context, token) || false)) { + break; + } + } + + context.push_tokens(queue); + + return match; + } + + + // Start + std::size_t match_token_at_0(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + build(context, token); + return 42; + } + if (match_language(context, token)) { + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); + build(context, token); + return 1; + } + if (match_tag_line(context, token)) { + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); + start_rule(context, rule_type::tags); + build(context, token); + return 2; + } + if (match_feature_line(context, token)) { + start_rule(context, rule_type::feature); + start_rule(context, rule_type::feature_header); + build(context, token); + return 3; + } + if (match_comment(context, token)) { + build(context, token); + return 0; + } + if (match_empty(context, token)) { + build(context, token); + return 0; + } + + /* "State: 0 - Start" */ + std::string expected_tokens = "#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 0; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 + std::size_t match_token_at_1(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + start_rule(context, rule_type::tags); + build(context, token); + return 2; + } + if (match_feature_line(context, token)) { + build(context, token); + return 3; + } + if (match_comment(context, token)) { + build(context, token); + return 1; + } + if (match_empty(context, token)) { + build(context, token); + return 1; + } + + /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ + std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 1; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 + std::size_t match_token_at_2(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 2; + } + if (match_feature_line(context, token)) { + end_rule(context, rule_type::tags); + build(context, token); + return 3; + } + if (match_comment(context, token)) { + build(context, token); + return 2; + } + if (match_empty(context, token)) { + build(context, token); + return 2; + } + + /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 2; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 + std::size_t match_token_at_3(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 3; + } + if (match_comment(context, token)) { + build(context, token); + return 5; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); + build(context, token); + return 6; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 4; + } + + /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 3; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_4(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 5; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); + build(context, token); + return 6; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 4; + } + + /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 4; + } + + // GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_5(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::feature_header); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 5; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::background); + build(context, token); + return 6; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::feature_header); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 5; + } + + /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 5; + } + + // GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 + std::size_t match_token_at_6(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 6; + } + if (match_comment(context, token)) { + build(context, token); + return 8; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 7; + } + + /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 6; + } + + // GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_7(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 8; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 7; + } + + /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 7; + } + + // GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_8(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 8; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 8; + } + + /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 8; + } + + // GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 + std::size_t match_token_at_9(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::data_table); + build(context, token); + return 10; + } + if (match_doc_string_separator(context, token)) { + start_rule(context, rule_type::doc_string); + build(context, token); + return 49; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 9; + } + if (match_empty(context, token)) { + build(context, token); + return 9; + } + + /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 9; + } + + // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 + std::size_t match_token_at_10(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 10; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 10; + } + if (match_empty(context, token)) { + build(context, token); + return 10; + } + + /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 10; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 + std::size_t match_token_at_11(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 11; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::tags); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_comment(context, token)) { + build(context, token); + return 11; + } + if (match_empty(context, token)) { + build(context, token); + return 11; + } + + /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 11; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 + std::size_t match_token_at_12(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 12; + } + if (match_comment(context, token)) { + build(context, token); + return 14; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 13; + } + + /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 12; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_13(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 14; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 13; + } + + /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 13; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_14(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 14; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 14; + } + + /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 14; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 + std::size_t match_token_at_15(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::data_table); + build(context, token); + return 16; + } + if (match_doc_string_separator(context, token)) { + start_rule(context, rule_type::doc_string); + build(context, token); + return 47; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 15; + } + if (match_empty(context, token)) { + build(context, token); + return 15; + } + + /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 15; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 + std::size_t match_token_at_16(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 16; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 16; + } + if (match_empty(context, token)) { + build(context, token); + return 16; + } + + /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 16; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 + std::size_t match_token_at_17(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 17; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::tags); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_comment(context, token)) { + build(context, token); + return 17; + } + if (match_empty(context, token)) { + build(context, token); + return 17; + } + + /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 17; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 + std::size_t match_token_at_18(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 18; + } + if (match_comment(context, token)) { + build(context, token); + return 20; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::examples_table); + build(context, token); + return 21; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 19; + } + + /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 18; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_19(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 20; + } + if (match_table_row(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_table); + build(context, token); + return 21; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 19; + } + + /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 19; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_20(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 20; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::examples_table); + build(context, token); + return 21; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 20; + } + + /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 20; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 + std::size_t match_token_at_21(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 21; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 21; + } + if (match_empty(context, token)) { + build(context, token); + return 21; + } + + /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 21; + } + + // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 + std::size_t match_token_at_22(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 22; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::tags); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 22; + } + if (match_empty(context, token)) { + build(context, token); + return 22; + } + + /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 22; + } + + // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 + std::size_t match_token_at_23(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 25; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); + build(context, token); + return 26; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 24; + } + + /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 23; + } + + // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_24(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 25; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); + build(context, token); + return 26; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 24; + } + + /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 24; + } + + // GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_25(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 25; + } + if (match_background_line(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::background); + build(context, token); + return 26; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::rule_header); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::rule_header); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 25; + } + + /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 25; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 + std::size_t match_token_at_26(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 26; + } + if (match_comment(context, token)) { + build(context, token); + return 28; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 27; + } + + /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 26; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_27(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 28; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 27; + } + + /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 27; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_28(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 28; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 28; + } + + /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 28; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 + std::size_t match_token_at_29(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::data_table); + build(context, token); + return 30; + } + if (match_doc_string_separator(context, token)) { + start_rule(context, rule_type::doc_string); + build(context, token); + return 45; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 29; + } + if (match_empty(context, token)) { + build(context, token); + return 29; + } + + /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 29; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 + std::size_t match_token_at_30(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 30; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 30; + } + if (match_empty(context, token)) { + build(context, token); + return 30; + } + + /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 30; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 + std::size_t match_token_at_31(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 31; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::tags); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_comment(context, token)) { + build(context, token); + return 31; + } + if (match_empty(context, token)) { + build(context, token); + return 31; + } + + /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 31; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 + std::size_t match_token_at_32(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 32; + } + if (match_comment(context, token)) { + build(context, token); + return 34; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 33; + } + + /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 32; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_33(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 34; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 33; + } + + /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 33; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_34(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 34; + } + if (match_step_line(context, token)) { + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 34; + } + + /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 34; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 + std::size_t match_token_at_35(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::data_table); + build(context, token); + return 36; + } + if (match_doc_string_separator(context, token)) { + start_rule(context, rule_type::doc_string); + build(context, token); + return 43; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 35; + } + if (match_empty(context, token)) { + build(context, token); + return 35; + } + + /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 35; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 + std::size_t match_token_at_36(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 36; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::data_table); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 36; + } + if (match_empty(context, token)) { + build(context, token); + return 36; + } + + /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 36; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 + std::size_t match_token_at_37(token& token, context_type& context) + { + if (match_tag_line(context, token)) { + build(context, token); + return 37; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::tags); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_comment(context, token)) { + build(context, token); + return 37; + } + if (match_empty(context, token)) { + build(context, token); + return 37; + } + + /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 37; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 + std::size_t match_token_at_38(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_empty(context, token)) { + build(context, token); + return 38; + } + if (match_comment(context, token)) { + build(context, token); + return 40; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::examples_table); + build(context, token); + return 41; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + start_rule(context, rule_type::description); + build(context, token); + return 39; + } + + /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 38; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 + std::size_t match_token_at_39(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + end_rule(context, rule_type::description); + build(context, token); + return 40; + } + if (match_table_row(context, token)) { + end_rule(context, rule_type::description); + start_rule(context, rule_type::examples_table); + build(context, token); + return 41; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::description); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_other(context, token)) { + build(context, token); + return 39; + } + + /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 39; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 + std::size_t match_token_at_40(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_comment(context, token)) { + build(context, token); + return 40; + } + if (match_table_row(context, token)) { + start_rule(context, rule_type::examples_table); + build(context, token); + return 41; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_empty(context, token)) { + build(context, token); + return 40; + } + + /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 40; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 + std::size_t match_token_at_41(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_table_row(context, token)) { + build(context, token); + return 41; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::examples_table); + end_rule(context, rule_type::examples); + end_rule(context, rule_type::examples_definition); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 41; + } + if (match_empty(context, token)) { + build(context, token); + return 41; + } + + /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 41; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 + std::size_t match_token_at_43(token& token, context_type& context) + { + if (match_doc_string_separator(context, token)) { + build(context, token); + return 44; + } + if (match_other(context, token)) { + build(context, token); + return 43; + } + + /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = "#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 43; + } + + // GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 + std::size_t match_token_at_44(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 35; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 37; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 38; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 44; + } + if (match_empty(context, token)) { + build(context, token); + return 44; + } + + /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 44; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 + std::size_t match_token_at_45(token& token, context_type& context) + { + if (match_doc_string_separator(context, token)) { + build(context, token); + return 46; + } + if (match_other(context, token)) { + build(context, token); + return 45; + } + + /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = "#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 45; + } + + // GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 + std::size_t match_token_at_46(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 29; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 31; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 32; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::rule); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 46; + } + if (match_empty(context, token)) { + build(context, token); + return 46; + } + + /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 46; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 + std::size_t match_token_at_47(token& token, context_type& context) + { + if (match_doc_string_separator(context, token)) { + build(context, token); + return 48; + } + if (match_other(context, token)) { + build(context, token); + return 47; + } + + /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = "#DocStringSeparator, #Other"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 47; + } + + // GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 + std::size_t match_token_at_48(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 15; + } + if (match_tag_line(context, token)) { + if (lookahead_1(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 17; + } + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_examples_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::examples_definition); + start_rule(context, rule_type::examples); + build(context, token); + return 18; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::scenario); + end_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 48; + } + if (match_empty(context, token)) { + build(context, token); + return 48; + } + + /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 48; } - result_type parse(const cms::source& source) - { return parent::parse(source.uri, source.data); } + // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 + std::size_t match_token_at_49(token& token, context_type& context) + { + if (match_doc_string_separator(context, token)) { + build(context, token); + return 50; + } + if (match_other(context, token)) { + build(context, token); + return 49; + } + + /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string expected_tokens = "#DocStringSeparator, #Other"; -private: + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 49; + } + + // GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 + std::size_t match_token_at_50(token& token, context_type& context) + { + if (match_e_o_f(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + end_rule(context, rule_type::feature); + build(context, token); + return 42; + } + if (match_step_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + start_rule(context, rule_type::step); + build(context, token); + return 9; + } + if (match_tag_line(context, token)) { + if (lookahead_0(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::tags); + build(context, token); + return 11; + } + } + if (match_tag_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + start_rule(context, rule_type::tags); + build(context, token); + return 22; + } + if (match_scenario_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::scenario_definition); + start_rule(context, rule_type::scenario); + build(context, token); + return 12; + } + if (match_rule_line(context, token)) { + end_rule(context, rule_type::doc_string); + end_rule(context, rule_type::step); + end_rule(context, rule_type::background); + start_rule(context, rule_type::rule); + start_rule(context, rule_type::rule_header); + build(context, token); + return 23; + } + if (match_comment(context, token)) { + build(context, token); + return 50; + } + if (match_empty(context, token)) { + build(context, token); + return 50; + } + + /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; + + auto error = + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ; + + if (context.stop_at_first_error) { + throw std::runtime_error(error + expected_tokens); + } + + context.add_error(expected_tokens); + + return 50; + } + + std::size_t match_token(std::size_t state, token& token, context_type& context) + { + switch (state) { + case 0: + return match_token_at_0(token, context); + case 1: + return match_token_at_1(token, context); + case 2: + return match_token_at_2(token, context); + case 3: + return match_token_at_3(token, context); + case 4: + return match_token_at_4(token, context); + case 5: + return match_token_at_5(token, context); + case 6: + return match_token_at_6(token, context); + case 7: + return match_token_at_7(token, context); + case 8: + return match_token_at_8(token, context); + case 9: + return match_token_at_9(token, context); + case 10: + return match_token_at_10(token, context); + case 11: + return match_token_at_11(token, context); + case 12: + return match_token_at_12(token, context); + case 13: + return match_token_at_13(token, context); + case 14: + return match_token_at_14(token, context); + case 15: + return match_token_at_15(token, context); + case 16: + return match_token_at_16(token, context); + case 17: + return match_token_at_17(token, context); + case 18: + return match_token_at_18(token, context); + case 19: + return match_token_at_19(token, context); + case 20: + return match_token_at_20(token, context); + case 21: + return match_token_at_21(token, context); + case 22: + return match_token_at_22(token, context); + case 23: + return match_token_at_23(token, context); + case 24: + return match_token_at_24(token, context); + case 25: + return match_token_at_25(token, context); + case 26: + return match_token_at_26(token, context); + case 27: + return match_token_at_27(token, context); + case 28: + return match_token_at_28(token, context); + case 29: + return match_token_at_29(token, context); + case 30: + return match_token_at_30(token, context); + case 31: + return match_token_at_31(token, context); + case 32: + return match_token_at_32(token, context); + case 33: + return match_token_at_33(token, context); + case 34: + return match_token_at_34(token, context); + case 35: + return match_token_at_35(token, context); + case 36: + return match_token_at_36(token, context); + case 37: + return match_token_at_37(token, context); + case 38: + return match_token_at_38(token, context); + case 39: + return match_token_at_39(token, context); + case 40: + return match_token_at_40(token, context); + case 41: + return match_token_at_41(token, context); + case 43: + return match_token_at_43(token, context); + case 44: + return match_token_at_44(token, context); + case 45: + return match_token_at_45(token, context); + case 46: + return match_token_at_46(token, context); + case 47: + return match_token_at_47(token, context); + case 48: + return match_token_at_48(token, context); + case 49: + return match_token_at_49(token, context); + case 50: + return match_token_at_50(token, context); + default: + context.add_error("invalid operation: " + std::to_string(state)); + return -1; + } + } }; } diff --git a/cpp/include/gherkin/parser_base.hpp b/cpp/include/gherkin/parser_base.hpp index 155d1162d..5feaafebc 100644 --- a/cpp/include/gherkin/parser_base.hpp +++ b/cpp/include/gherkin/parser_base.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #include namespace gherkin { @@ -25,21 +24,12 @@ class parser_base using result_type = typename Builder::result_type; using context_type = parser_context; - parser_base(const parser_info& pi = {}) - : pi_{pi} + parser_base() {} virtual ~parser_base() {} -protected: - void reset(std::string_view uri, std::string_view data) - { - builder_.reset(uri); - scanner_.reset(data); - matcher_.reset(); - } - result_type parse(std::string_view uri, std::string_view data) { reset(uri, data); @@ -55,12 +45,19 @@ class parser_base return get_result(); } +protected: + void reset(std::string_view uri, std::string_view data) + { + builder_.reset(uri); + scanner_.reset(data); + matcher_.reset(); + } + result_type get_result() const { return builder_.get_result(); } virtual void parse(context_type& context) = 0; - parser_info pi_; Builder builder_; Scanner scanner_; Matcher matcher_; diff --git a/cpp/include/gherkin/parser_info.hpp b/cpp/include/gherkin/parser_info.hpp index d9be23f71..0ef64b5b5 100644 --- a/cpp/include/gherkin/parser_info.hpp +++ b/cpp/include/gherkin/parser_info.hpp @@ -2,24 +2,15 @@ #include #include -#include namespace gherkin { using id_generator_func = std::function; -using json = nlohmann::json; - -using json_cb = std::function; - struct parser_info { std::string language = "en"; - bool include_source = true; - bool include_ast = true; - bool include_pickles = true; id_generator_func id_generator; - json_cb sink; }; } diff --git a/cpp/include/gherkin/pickle_compiler.hpp b/cpp/include/gherkin/pickle_compiler.hpp index 76eba4e1b..77d47eabe 100644 --- a/cpp/include/gherkin/pickle_compiler.hpp +++ b/cpp/include/gherkin/pickle_compiler.hpp @@ -4,6 +4,8 @@ #include #include +#include +#include namespace gherkin { @@ -15,19 +17,20 @@ class pickle_compiler pickles compile( const cms::gherkin_document& d, - const std::string& uri + const std::string& uri, + pickle_cb sink = {} ); private: void compile_feature( - pickles& pickles, + pickle_compiler_context& ctx, const cms::feature& f, const std::string& language, const std::string& uri ); void compile_rule( - pickles& pickles, + pickle_compiler_context& ctx, const cms::rule& r, const tags& parent_tags, const steps& background_steps, @@ -36,7 +39,7 @@ class pickle_compiler ); void compile_scenario( - pickles& pickles, + pickle_compiler_context& ctx, const cms::scenario& s, const tags& parent_tags, const steps& background_steps, @@ -45,7 +48,7 @@ class pickle_compiler ); void compile_scenario_outline( - pickles& pickles, + pickle_compiler_context& ctx, const cms::scenario& s, const tags& parent_tags, const steps& background_steps, diff --git a/cpp/include/gherkin/pickle_compiler_context.hpp b/cpp/include/gherkin/pickle_compiler_context.hpp new file mode 100644 index 000000000..2d51e2786 --- /dev/null +++ b/cpp/include/gherkin/pickle_compiler_context.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +#include +#include + +namespace gherkin { + +struct pickle_compiler_context +{ + std::string next_id(); + + void add_pickle(cms::pickle& p); + + pickle_cb sink; + gherkin::pickles pickles; + std::size_t id_counter_ = 0; +}; + +} diff --git a/cpp/include/gherkin/sink.hpp b/cpp/include/gherkin/sink.hpp new file mode 100644 index 000000000..fff214e0e --- /dev/null +++ b/cpp/include/gherkin/sink.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include +#include + +namespace gherkin { + +using json = nlohmann::json; + +using sink_cb = std::function; + +} diff --git a/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp b/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp index 925433bf1..3c265c953 100644 --- a/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp +++ b/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include int main(int ac, char** av) { @@ -14,7 +14,11 @@ int main(int ac, char** av) parser p; for (std::size_t i = 1; i < ac; ++i) { - auto ss = p.parse(gherkin::file{ av[i] }); + std::string file(av[i]); + + auto data = gherkin::slurp(file); + + auto ss = p.parse(file, data); std::cout << gherkin::join("\n", ss); } diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 262996fb7..6cd449a3b 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -1,8 +1,6 @@ #include -#include -#include -#include +#include #include struct options @@ -10,7 +8,9 @@ struct options bool exit = false; int exit_code = 0; int last_arg = 0; - gherkin::parser_info pi; + bool include_source = true; + bool include_ast = true; + bool include_pickles = true; }; options @@ -22,11 +22,11 @@ parse_options(int ac, char** av) std::string_view arg(av[opts.last_arg]); if (arg == "--no-source") { - opts.pi.include_source = false; + opts.include_source = false; } else if (arg == "--no-ast") { - opts.pi.include_ast = false; + opts.include_ast = false; } else if (arg == "--no-pickles") { - opts.pi.include_pickles = false; + opts.include_pickles = false; } else if (arg.starts_with('-')) { if (arg != "-h" && arg != "--help") { std::cout << "Unknown option: " << arg << std::endl; @@ -59,10 +59,29 @@ int main(int ac, char** av) return opts.exit_code; } - gherkin::parser p{opts.pi}; + gherkin::app app; + gherkin::app::callbacks cbs{ + .source = [&](const auto& s) { + std::cout << s.to_json() << std::endl; + }, + .ast = [&](const auto& a) { + nlohmann::json j; + + a.to_json(j["gerkinDocument"]); + + std::cout << j << std::endl; + }, + .pickle = [&](const auto& p) { + std::cout << p.to_json() << std::endl; + } + }; + + app.include_source(opts.include_source); + app.include_ast(opts.include_ast); + app.include_pickles(opts.include_pickles); for ( ; opts.last_arg < ac; ++opts.last_arg) { - p.parse(gherkin::file{ av[opts.last_arg] }); + app.parse(gherkin::file{ av[opts.last_arg] }, cbs); } return 0; diff --git a/cpp/src/lib/gherkin/app.cpp b/cpp/src/lib/gherkin/app.cpp new file mode 100644 index 000000000..bbe5b0f10 --- /dev/null +++ b/cpp/src/lib/gherkin/app.cpp @@ -0,0 +1,61 @@ +#include +#include +#include + +namespace gherkin { + +app::app() +{} + +app::~app() +{} + +void +app::include_source(bool f) +{ include_source_ = f; } + +void +app::include_ast(bool f) +{ include_ast_ = f; } + +void +app::include_pickles(bool f) +{ include_pickles_ = f; } + +void +app::parse(const file& f, const callbacks& cbs) +{ + cms::envelope e; + + e.source = cms::source{ .uri = f.path, .data = slurp(f.path) }; + + parse(e, cbs); +} + +void +app::parse(const cms::envelope& e, const callbacks& cbs) +{ + if (include_source_ && cbs.source) { + cbs.source(*e.source); + } + + parse(*e.source, cbs); +} + +void +app::parse(const cms::source& s, const callbacks& cbs) +{ + auto ast = p_.parse(s.uri, s.data); + + if (include_ast_ && cbs.ast) { + cbs.ast(ast); + } + + if (include_pickles_ && cbs.pickle) { + pickle_compiler pc; + + pc.compile(ast, s.uri, cbs.pickle); + } +} + +} diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 6840baca0..2968333c1 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -215,10 +215,12 @@ ast_builder::make_examples_definition(ast_node& node) .id = next_id() }; - auto table = examples_node.get_single(rule_type::examples_table); + auto prows = examples_node.get_single( + rule_type::examples_table + ); - if (table) { - auto rows = get_table_rows(*table); + if (prows) { + auto& rows = *prows; m.table_header = rows.front(); diff --git a/cpp/src/lib/gherkin/pickle_compiler.cpp b/cpp/src/lib/gherkin/pickle_compiler.cpp index 673c1a47c..d35bf0d81 100644 --- a/cpp/src/lib/gherkin/pickle_compiler.cpp +++ b/cpp/src/lib/gherkin/pickle_compiler.cpp @@ -36,21 +36,22 @@ pickle_compiler::~pickle_compiler() pickles pickle_compiler::compile( const cms::gherkin_document& d, - const std::string& uri + const std::string& uri, + pickle_cb sink ) { - pickles pickles; + pickle_compiler_context ctx{ .sink = sink }; if (d.feature) { - compile_feature(pickles, *d.feature, d.feature->language, uri); + compile_feature(ctx, *d.feature, d.feature->language, uri); } - return pickles; + return ctx.pickles; } void pickle_compiler::compile_feature( - pickles& pickles, + pickle_compiler_context& ctx, const cms::feature& f, const std::string& language, const std::string& uri @@ -64,7 +65,7 @@ pickle_compiler::compile_feature( append(background_steps, child.background->steps); } else if (child.rule) { compile_rule( - pickles, + ctx, *child.rule, tags, background_steps, @@ -76,7 +77,7 @@ pickle_compiler::compile_feature( if (scenario.examples.empty()) { compile_scenario( - pickles, + ctx, scenario, tags, background_steps, @@ -85,7 +86,7 @@ pickle_compiler::compile_feature( ); } else { compile_scenario_outline( - pickles, + ctx, scenario, tags, background_steps, @@ -99,7 +100,7 @@ pickle_compiler::compile_feature( void pickle_compiler::compile_rule( - pickles& pickles, + pickle_compiler_context& ctx, const cms::rule& r, const tags& parent_tags, const steps& background_steps, @@ -120,7 +121,7 @@ pickle_compiler::compile_rule( if (scenario.examples.empty()) { compile_scenario( - pickles, + ctx, scenario, tags, steps, @@ -129,7 +130,7 @@ pickle_compiler::compile_rule( ); } else { compile_scenario_outline( - pickles, + ctx, scenario, tags, steps, @@ -143,7 +144,7 @@ pickle_compiler::compile_rule( void pickle_compiler::compile_scenario( - pickles& pickles, + pickle_compiler_context& ctx, const cms::scenario& s, const tags& parent_tags, const steps& background_steps, @@ -177,7 +178,7 @@ pickle_compiler::compile_scenario( strings source_ids = { s.id }; cms::pickle p{ - .id = next_id(), + .id = ctx.next_id(), .uri = uri, .name = s.name, .language = language, @@ -186,12 +187,12 @@ pickle_compiler::compile_scenario( .ast_node_ids = source_ids }; - pickles.emplace_back(std::move(p)); + ctx.add_pickle(p); } void pickle_compiler::compile_scenario_outline( - pickles& pickles, + pickle_compiler_context& ctx, const cms::scenario& s, const tags& parent_tags, const steps& background_steps, @@ -240,7 +241,7 @@ pickle_compiler::compile_scenario_outline( strings source_ids = { s.id, values_row.id }; cms::pickle p{ - .id = next_id(), + .id = ctx.next_id(), .uri = uri, .name = interpolate(s.name, variable_cells, value_cells), .language = language, @@ -249,7 +250,7 @@ pickle_compiler::compile_scenario_outline( .ast_node_ids = source_ids }; - pickles.emplace_back(std::move(p)); + ctx.add_pickle(p); } } } @@ -397,8 +398,4 @@ pickle_compiler::interpolate( return iname; } -std::string -pickle_compiler::next_id() -{ return std::to_string(id_counter_++); } - } diff --git a/cpp/src/lib/gherkin/pickle_compiler_context.cpp b/cpp/src/lib/gherkin/pickle_compiler_context.cpp new file mode 100644 index 000000000..a30bafef1 --- /dev/null +++ b/cpp/src/lib/gherkin/pickle_compiler_context.cpp @@ -0,0 +1,19 @@ +#include + +namespace gherkin { + +std::string +pickle_compiler_context::next_id() +{ return std::to_string(id_counter_++); } + +void +pickle_compiler_context::add_pickle(cms::pickle& p) +{ + if (sink) { + sink(p); + } + + pickles.emplace_back(std::move(p)); +} + +} From 5879e7515cec1d3973f113fed1e22f0c3c6ca3a7 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 29 May 2023 11:01:05 +0200 Subject: [PATCH 45/76] chore: fixed gherkinDocument root key name and missing feature language --- cpp/src/bin/gherkin/gherkin.cpp | 2 +- cpp/src/lib/gherkin/ast_builder.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 6cd449a3b..c25dd274b 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -67,7 +67,7 @@ int main(int ac, char** av) .ast = [&](const auto& a) { nlohmann::json j; - a.to_json(j["gerkinDocument"]); + a.to_json(j["gherkinDocument"]); std::cout << j << std::endl; }, diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 2968333c1..d40c3639d 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -278,6 +278,7 @@ ast_builder::make_feature(ast_node& node) cms::feature m{ .location = get_location(feature_line), .tags = get_tags(header), + .language = feature_line.matched_gherkin_dialect, .keyword = feature_line.matched_keyword.value_or(""), .name = feature_line.matched_text }; From 441c7fff72412287ce1d578e116bf671d3bbf4a6 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 29 May 2023 11:01:39 +0200 Subject: [PATCH 46/76] chore: added small debug helper --- cpp/scripts/nddiff.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 cpp/scripts/nddiff.sh diff --git a/cpp/scripts/nddiff.sh b/cpp/scripts/nddiff.sh new file mode 100755 index 000000000..1bbbb17be --- /dev/null +++ b/cpp/scripts/nddiff.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +F=$1 +N=$(basename $F) + +stage/bin/gherkin \ + --no-source --no-pickles \ + $F \ + | jq \ + --sort-keys --compact-output "." \ + > acceptance/testdata/good/$N.ast.ndjson + +meld \ + <(jq "." $F.ast.ndjson) \ + <(jq "." acceptance/testdata/good/$N.ast.ndjson) From ee3856f938028c47f5d4e619456a5f3dda09632c Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 29 May 2023 12:12:24 +0200 Subject: [PATCH 47/76] chore: ast json output acceptance ok --- cpp/include/gherkin/regex.hpp | 8 ++++++- cpp/src/lib/gherkin/ast_builder.cpp | 36 +++++++++++++++-------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/cpp/include/gherkin/regex.hpp b/cpp/include/gherkin/regex.hpp index 7310fd481..d7dbea6c2 100644 --- a/cpp/include/gherkin/regex.hpp +++ b/cpp/include/gherkin/regex.hpp @@ -161,7 +161,13 @@ full_match( template bool full_match(const std::basic_string& e, Args&&... args) -{ return full_match(e, std::forward(args)...); } +{ + return + full_match( + std::string_view{ e.data(), e.size() }, + std::forward(args)... + ); +} template bool diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index d40c3639d..399f35c35 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -136,11 +136,14 @@ ast_builder::make_doc_string(ast_node& node) cms::doc_string m{ .location = get_location(separator_token), - .media_type = separator_token.matched_text, .content = content, .delimiter = separator_token.matched_keyword.value_or("") }; + if (!separator_token.matched_text.empty()) { + m.media_type = separator_token.matched_text; + } + return m; } @@ -154,7 +157,7 @@ ast_builder::make_data_table(ast_node& node) }; if (!m.rows.empty()) { - m.location = rows.front().location; + m.location = m.rows.front().location; } return m; @@ -215,6 +218,8 @@ ast_builder::make_examples_definition(ast_node& node) .id = next_id() }; + examples_node.set(rule_type::description, m.description); + auto prows = examples_node.get_single( rule_type::examples_table ); @@ -243,24 +248,21 @@ std::string ast_builder::make_description(ast_node& node) { std::regex only_spaces("\\s*"); - - auto no_spaces = [&](const auto& t) { - return !full_match(t.matched_text, only_spaces); - }; + auto toks = node.get_tokens(rule_type::other); + std::size_t ntoks = toks.size(); + + while ( + ntoks + && + full_match(toks[ntoks - 1].matched_text, only_spaces) + ) { + --ntoks; + } string_views svs; - auto toks = - node.get_tokens(rule_type::other) - | std::views::reverse - | std::views::filter(no_spaces) - | std::views::transform([](const auto& t) { - return std::string_view(t.matched_text); - }) - ; - - for (const auto& t : toks) { - svs.emplace_back(t); + for (std::size_t i = 0; i < ntoks; ++i) { + svs.emplace_back(toks[i].matched_text); } return join("\n", svs); From 6031def39443948bdbf3b6ef2586384339fc5e78 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Mon, 29 May 2023 19:24:06 +0200 Subject: [PATCH 48/76] chore: fixing pickle step interpolation --- cpp/include/gherkin/app.hpp | 2 + cpp/include/gherkin/ast_builder.hpp | 5 ++- cpp/include/gherkin/id_generator.hpp | 37 +++++++++++++++++++ cpp/include/gherkin/parser_base.hpp | 5 +++ cpp/include/gherkin/pickle_compiler.hpp | 5 ++- .../gherkin/pickle_compiler_context.hpp | 2 + .../gherkin/token_formatter_builder.hpp | 4 +- cpp/src/bin/gherkin/gherkin.cpp | 6 ++- cpp/src/lib/gherkin/app.cpp | 4 +- cpp/src/lib/gherkin/ast_builder.cpp | 7 +++- cpp/src/lib/gherkin/id_generator.cpp | 21 +++++++++++ cpp/src/lib/gherkin/pickle_compiler.cpp | 10 ++++- .../lib/gherkin/pickle_compiler_context.cpp | 2 +- .../lib/gherkin/token_formatter_builder.cpp | 3 +- 14 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 cpp/include/gherkin/id_generator.hpp create mode 100644 cpp/src/lib/gherkin/id_generator.cpp diff --git a/cpp/include/gherkin/app.hpp b/cpp/include/gherkin/app.hpp index 026fab3b9..ca7e245b7 100644 --- a/cpp/include/gherkin/app.hpp +++ b/cpp/include/gherkin/app.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace gherkin { @@ -27,6 +28,7 @@ class app void parse(const cms::source& s, const callbacks& cbs = {}); private: + id_generator_ptr idp_; parser p_; bool include_source_ = true; bool include_ast_ = true; diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 797220568..403e62f05 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace gherkin { @@ -26,6 +27,8 @@ class ast_builder using result_type = cms::gherkin_document; ast_builder(); + ast_builder(id_generator_ptr idp); + virtual ~ast_builder(); void reset(std::string_view uri); @@ -68,7 +71,7 @@ class ast_builder ast_node& current_node(); const ast_node& current_node() const; - std::size_t id_counter_ = 0; + id_generator_ptr idp_; ast_node_stack stack_; std::string_view uri_; comments comments_; diff --git a/cpp/include/gherkin/id_generator.hpp b/cpp/include/gherkin/id_generator.hpp new file mode 100644 index 000000000..5e7941d55 --- /dev/null +++ b/cpp/include/gherkin/id_generator.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include +#include + +namespace gherkin { + +class id_generator_base +{ +public: + id_generator_base(); + + virtual ~id_generator_base(); + + virtual std::string next_id() = 0; +}; + +class id_generator : public id_generator_base +{ +public: + id_generator(); + virtual ~id_generator(); + + std::string next_id() override; + +private: + std::size_t id_counter_ = 0; +}; + +using id_generator_ptr = std::shared_ptr; + +template +id_generator_ptr +new_id_generator(Args&&... args) +{ return std::make_shared(std::forward(args)...); } + +} diff --git a/cpp/include/gherkin/parser_base.hpp b/cpp/include/gherkin/parser_base.hpp index 5feaafebc..68afa814a 100644 --- a/cpp/include/gherkin/parser_base.hpp +++ b/cpp/include/gherkin/parser_base.hpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace gherkin { @@ -27,6 +28,10 @@ class parser_base parser_base() {} + parser_base(id_generator_ptr idp) + : builder_(idp) + {} + virtual ~parser_base() {} diff --git a/cpp/include/gherkin/pickle_compiler.hpp b/cpp/include/gherkin/pickle_compiler.hpp index 77d47eabe..03c003db6 100644 --- a/cpp/include/gherkin/pickle_compiler.hpp +++ b/cpp/include/gherkin/pickle_compiler.hpp @@ -6,13 +6,14 @@ #include #include #include +#include namespace gherkin { class pickle_compiler { public: - pickle_compiler(); + pickle_compiler(id_generator_ptr idp); virtual ~pickle_compiler(); pickles compile( @@ -90,7 +91,7 @@ class pickle_compiler std::string next_id(); - std::size_t id_counter_ = 0; + id_generator_ptr idp_; }; } diff --git a/cpp/include/gherkin/pickle_compiler_context.hpp b/cpp/include/gherkin/pickle_compiler_context.hpp index 2d51e2786..7f8600107 100644 --- a/cpp/include/gherkin/pickle_compiler_context.hpp +++ b/cpp/include/gherkin/pickle_compiler_context.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace gherkin { @@ -14,6 +15,7 @@ struct pickle_compiler_context void add_pickle(cms::pickle& p); + id_generator_ptr idp; pickle_cb sink; gherkin::pickles pickles; std::size_t id_counter_ = 0; diff --git a/cpp/include/gherkin/token_formatter_builder.hpp b/cpp/include/gherkin/token_formatter_builder.hpp index d72402b42..db1c50cf8 100644 --- a/cpp/include/gherkin/token_formatter_builder.hpp +++ b/cpp/include/gherkin/token_formatter_builder.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace gherkin { @@ -20,7 +21,7 @@ class token_formatter_builder public: using result_type = strings; - token_formatter_builder(); + token_formatter_builder(id_generator_ptr idp = {}); virtual ~token_formatter_builder(); void reset(std::string_view uri); @@ -34,6 +35,7 @@ class token_formatter_builder private: std::string format_token(const token& token); + id_generator_ptr idp_; strings formatted_tokens_; }; diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index c25dd274b..0b56dd795 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -72,7 +72,11 @@ int main(int ac, char** av) std::cout << j << std::endl; }, .pickle = [&](const auto& p) { - std::cout << p.to_json() << std::endl; + nlohmann::json j; + + p.to_json(j["pickle"]); + + std::cout << j << std::endl; } }; diff --git a/cpp/src/lib/gherkin/app.cpp b/cpp/src/lib/gherkin/app.cpp index bbe5b0f10..0da163551 100644 --- a/cpp/src/lib/gherkin/app.cpp +++ b/cpp/src/lib/gherkin/app.cpp @@ -5,6 +5,8 @@ namespace gherkin { app::app() +: idp_(new_id_generator()), +p_(idp_) {} app::~app() @@ -52,7 +54,7 @@ app::parse(const cms::source& s, const callbacks& cbs) } if (include_pickles_ && cbs.pickle) { - pickle_compiler pc; + pickle_compiler pc(idp_); pc.compile(ast, s.uri, cbs.pickle); } diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 399f35c35..26154457b 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -9,6 +9,11 @@ namespace gherkin { ast_builder::ast_builder() +: ast_builder(new_id_generator()) +{} + +ast_builder::ast_builder(id_generator_ptr idp) +: idp_(idp) {} ast_builder::~ast_builder() @@ -63,7 +68,7 @@ ast_builder::get_result() const std::string ast_builder::next_id() -{ return std::to_string(id_counter_++); } +{ return idp_->next_id(); } void ast_builder::transform_node(ast_node& from, ast_node& to) diff --git a/cpp/src/lib/gherkin/id_generator.cpp b/cpp/src/lib/gherkin/id_generator.cpp new file mode 100644 index 000000000..5cdebc069 --- /dev/null +++ b/cpp/src/lib/gherkin/id_generator.cpp @@ -0,0 +1,21 @@ +#include + +namespace gherkin { + +id_generator_base::id_generator_base() +{} + +id_generator_base::~id_generator_base() +{} + +id_generator::id_generator() +{} + +id_generator::~id_generator() +{} + +std::string +id_generator::next_id() +{ return std::to_string(id_counter_++); } + +} diff --git a/cpp/src/lib/gherkin/pickle_compiler.cpp b/cpp/src/lib/gherkin/pickle_compiler.cpp index d35bf0d81..c6f4e8e12 100644 --- a/cpp/src/lib/gherkin/pickle_compiler.cpp +++ b/cpp/src/lib/gherkin/pickle_compiler.cpp @@ -27,7 +27,8 @@ void append(Vector& to, const Vector& from) { to.insert(to.end(), from.begin(), from.end()); } -pickle_compiler::pickle_compiler() +pickle_compiler::pickle_compiler(id_generator_ptr idp) +: idp_(idp) {} pickle_compiler::~pickle_compiler() @@ -40,7 +41,7 @@ pickle_compiler::compile( pickle_cb sink ) { - pickle_compiler_context ctx{ .sink = sink }; + pickle_compiler_context ctx{ .idp = idp_, .sink = sink }; if (d.feature) { compile_feature(ctx, *d.feature, d.feature->language, uri); @@ -271,6 +272,7 @@ pickle_compiler::make_pickle_step( cms::pickle_step ps{ .ast_node_ids = { step.id }, + .id = next_id(), .type = to_pickle_step_type(keyword_type), .text = interpolate(step.text, variable_cells, value_cells) }; @@ -398,4 +400,8 @@ pickle_compiler::interpolate( return iname; } +std::string +pickle_compiler::next_id() +{ return idp_->next_id(); } + } diff --git a/cpp/src/lib/gherkin/pickle_compiler_context.cpp b/cpp/src/lib/gherkin/pickle_compiler_context.cpp index a30bafef1..a7455ec70 100644 --- a/cpp/src/lib/gherkin/pickle_compiler_context.cpp +++ b/cpp/src/lib/gherkin/pickle_compiler_context.cpp @@ -4,7 +4,7 @@ namespace gherkin { std::string pickle_compiler_context::next_id() -{ return std::to_string(id_counter_++); } +{ return idp->next_id(); } void pickle_compiler_context::add_pickle(cms::pickle& p) diff --git a/cpp/src/lib/gherkin/token_formatter_builder.cpp b/cpp/src/lib/gherkin/token_formatter_builder.cpp index ee54c07b9..438679682 100644 --- a/cpp/src/lib/gherkin/token_formatter_builder.cpp +++ b/cpp/src/lib/gherkin/token_formatter_builder.cpp @@ -5,7 +5,8 @@ namespace gherkin { -token_formatter_builder::token_formatter_builder() +token_formatter_builder::token_formatter_builder(id_generator_ptr idp) +: idp_(idp) {} token_formatter_builder::~token_formatter_builder() From 16999acc0dd7ec67073a803158eef8403a70d24c Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 30 May 2023 13:43:05 +0200 Subject: [PATCH 49/76] chore: fixing error reporting --- cpp/gherkin-cpp.razor | 11 +- cpp/include/gherkin/exceptions.hpp | 97 +++++ cpp/include/gherkin/location.hpp | 13 + cpp/include/gherkin/parser.hpp | 550 +++++++++++++++--------- cpp/include/gherkin/utils.hpp | 6 + cpp/src/lib/gherkin/exceptions.cpp | 146 +++++++ cpp/src/lib/gherkin/location.cpp | 17 + cpp/src/lib/gherkin/pickle_compiler.cpp | 11 +- cpp/src/lib/gherkin/utils.cpp | 20 + 9 files changed, 665 insertions(+), 206 deletions(-) create mode 100644 cpp/include/gherkin/exceptions.hpp create mode 100644 cpp/src/lib/gherkin/exceptions.cpp create mode 100644 cpp/src/lib/gherkin/location.cpp diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index b4aec33de..4f1d9566e 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -38,13 +38,16 @@ public static string NameOf(Rule rule) std::string expected_tokens = "@Raw(string.Join(", ", expectedTokens))"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); diff --git a/cpp/include/gherkin/exceptions.hpp b/cpp/include/gherkin/exceptions.hpp new file mode 100644 index 000000000..faf72cabd --- /dev/null +++ b/cpp/include/gherkin/exceptions.hpp @@ -0,0 +1,97 @@ +#pragma once + +#include +#include + +#include +#include +#include + +namespace gherkin { + +class parser_error : public std::runtime_error +{ +public: + parser_error(const std::string& message, location location); + virtual ~parser_error(); + + std::string make_message( + const std::string& message, + location location + ) const; + +private: + location location_; +}; + +using parser_error_ptr = std::shared_ptr; +using parser_error_ptrs = std::vector; + +template +parser_error_ptr +new_parser_error(Args&&... args) +{ return std::make_shared(std::forward(args)...); } + +using ast_builder_error = parser_error; + +class no_such_language_error : public parser_error +{ +public: + no_such_language_error(const std::string& language, location location); + virtual ~no_such_language_error(); +}; + +class unexpected_token : public parser_error +{ +public: + unexpected_token( + const token& received_token, + const std::string& expected_tokens, + const std::string& state_comment + ); + + virtual ~unexpected_token(); + + std::string make_message( + const token& received_token, + const std::string& expected_tokens + ) const; + +private: + token received_token_; + std::string expected_tokens_; + std::string state_comment_; +}; + +class unexpected_eof : public parser_error +{ +public: + unexpected_eof( + const token& received_token, + const std::string& expected_tokens, + const std::string& state_comment + ); + + virtual ~unexpected_eof(); + + std::string make_message(const std::string& expected_tokens) const; + +private: + std::string expected_tokens_; + std::string state_comment_; +}; + +class composite_parser_error : public parser_error +{ +public: + composite_parser_error(const parser_error_ptrs& ptrs); + + virtual ~composite_parser_error(); + + std::string make_message(const parser_error_ptrs& ptrs) const; + +private: + parser_error_ptrs ptrs_; +}; + +} diff --git a/cpp/include/gherkin/location.hpp b/cpp/include/gherkin/location.hpp index 3835e26b5..f17c60478 100644 --- a/cpp/include/gherkin/location.hpp +++ b/cpp/include/gherkin/location.hpp @@ -1,11 +1,24 @@ #pragma once +#include + namespace gherkin { struct location { std::size_t line; std::size_t column; + + std::string to_string() const; }; +inline +std::ostream& +operator<<(std::ostream& os, const location& l) +{ + os << l.to_string(); + + return os; +} + } diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index e98eaeb25..d245c3fad 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -442,13 +442,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -481,13 +484,16 @@ class parser : public parser_base std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -520,13 +526,16 @@ class parser : public parser_base std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -598,13 +607,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -678,13 +690,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -751,13 +766,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -828,13 +846,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -907,13 +928,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -979,13 +1003,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1067,13 +1094,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1155,13 +1185,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1195,13 +1228,16 @@ class parser : public parser_base std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1291,13 +1327,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1391,13 +1430,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1482,13 +1524,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1591,13 +1636,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1702,13 +1750,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1742,13 +1793,16 @@ class parser : public parser_base std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1852,13 +1906,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -1966,13 +2023,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2071,13 +2131,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2182,13 +2245,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2221,13 +2287,16 @@ class parser : public parser_base std::string expected_tokens = "#TagLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2302,13 +2371,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2385,13 +2457,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2461,13 +2536,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2541,13 +2619,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2623,13 +2704,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2698,13 +2782,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2789,13 +2876,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2880,13 +2970,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -2920,13 +3013,16 @@ class parser : public parser_base std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3019,13 +3115,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3122,13 +3221,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3216,13 +3318,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3328,13 +3433,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3442,13 +3550,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3482,13 +3593,16 @@ class parser : public parser_base std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3595,13 +3709,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3712,13 +3829,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3820,13 +3940,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3934,13 +4057,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -3964,13 +4090,16 @@ class parser : public parser_base std::string expected_tokens = "#DocStringSeparator, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -4074,13 +4203,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -4104,13 +4236,16 @@ class parser : public parser_base std::string expected_tokens = "#DocStringSeparator, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -4191,13 +4326,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -4221,13 +4359,16 @@ class parser : public parser_base std::string expected_tokens = "#DocStringSeparator, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -4328,13 +4469,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -4358,13 +4502,16 @@ class parser : public parser_base std::string expected_tokens = "#DocStringSeparator, #Other"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); @@ -4442,13 +4589,16 @@ class parser : public parser_base std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; auto error = - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + ( + token.is_eof() + ? "unexpected eof: " + : "unexpected token: " + ) + + expected_tokens ; if (context.stop_at_first_error) { - throw std::runtime_error(error + expected_tokens); + //throw parser_error(error + ); } context.add_error(expected_tokens); diff --git a/cpp/include/gherkin/utils.hpp b/cpp/include/gherkin/utils.hpp index edaf04563..a9c53e492 100644 --- a/cpp/include/gherkin/utils.hpp +++ b/cpp/include/gherkin/utils.hpp @@ -148,6 +148,12 @@ codepoint_count(std::string_view s); std::string slurp(const std::string& path); +void +replace(std::string& s, std::string_view what, std::string_view with); + +std::string +replace(const std::string& s, std::string_view what, std::string_view with); + template std::basic_string strip(std::basic_string_view what, const strip_pattern& p) diff --git a/cpp/src/lib/gherkin/exceptions.cpp b/cpp/src/lib/gherkin/exceptions.cpp new file mode 100644 index 000000000..3edb452e0 --- /dev/null +++ b/cpp/src/lib/gherkin/exceptions.cpp @@ -0,0 +1,146 @@ +#include + +#include +#include +#include + +namespace gherkin { + +/////////////////////////////////////////////////////////////////////////////// +// +// parser error +// +/////////////////////////////////////////////////////////////////////////////// +parser_error::parser_error(const std::string& message, location location) +: std::runtime_error(make_message(message, location)) +{} + +parser_error::~parser_error() +{} + +std::string +parser_error::make_message( + const std::string& message, + location location +) const +{ + std::ostringstream oss; + + oss << location << ": " << message; + + return oss.str(); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// no such language error +// +/////////////////////////////////////////////////////////////////////////////// +no_such_language_error::no_such_language_error( + const std::string& language, + location location) +: parser_error("Language not supported: " + language, location) +{} + +no_such_language_error::~no_such_language_error() +{} + +/////////////////////////////////////////////////////////////////////////////// +// +// unexpected token +// +/////////////////////////////////////////////////////////////////////////////// +unexpected_token::unexpected_token( + const token& received_token, + const std::string& expected_tokens, + const std::string& state_comment +) +: parser_error( + make_message(received_token, expected_tokens), + received_token.location +), +received_token_(received_token), +expected_tokens_(expected_tokens), +state_comment_(state_comment) +{} + +unexpected_token::~unexpected_token() +{} + +std::string +unexpected_token::make_message( + const token& received_token, + const std::string& expected_tokens +) const +{ + std::ostringstream oss; + + oss + << "expected: " << expected_tokens + << ", got '" << strip(received_token.value()) << "'" + ; + + return oss.str(); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// unexpected eof +// +/////////////////////////////////////////////////////////////////////////////// +unexpected_eof::unexpected_eof( + const token& received_token, + const std::string& expected_tokens, + const std::string& state_comment +) +: parser_error( + make_message(expected_tokens), + received_token.location +), +expected_tokens_(expected_tokens), +state_comment_(state_comment) +{} + +unexpected_eof::~unexpected_eof() +{} + +std::string +unexpected_eof::make_message(const std::string& expected_tokens) const +{ + std::ostringstream oss; + + oss << "unexpected end of file, expected: " << expected_tokens; + + return oss.str(); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// composite parser error +// +/////////////////////////////////////////////////////////////////////////////// +composite_parser_error::composite_parser_error(const parser_error_ptrs& ptrs) +: parser_error("", {}), +ptrs_(ptrs) +{} + +composite_parser_error::~composite_parser_error() +{} + +std::string +composite_parser_error::make_message(const parser_error_ptrs& ptrs) const +{ + strings errs; + + for (const auto& p : ptrs) { + errs.push_back(p->what()); + } + + std::ostringstream oss; + + oss << "Parser errors:\n" << join("\n", errs); + + return oss.str(); +} + +} diff --git a/cpp/src/lib/gherkin/location.cpp b/cpp/src/lib/gherkin/location.cpp new file mode 100644 index 000000000..8a0776263 --- /dev/null +++ b/cpp/src/lib/gherkin/location.cpp @@ -0,0 +1,17 @@ +#include + +#include + +namespace gherkin { + +std::string +location::to_string() const +{ + std::ostringstream oss; + + oss << "(" << line << ":" << column << ")"; + + return oss.str(); +} + +} diff --git a/cpp/src/lib/gherkin/pickle_compiler.cpp b/cpp/src/lib/gherkin/pickle_compiler.cpp index c6f4e8e12..fe882e055 100644 --- a/cpp/src/lib/gherkin/pickle_compiler.cpp +++ b/cpp/src/lib/gherkin/pickle_compiler.cpp @@ -236,7 +236,14 @@ pickle_compiler::compile_scenario_outline( last_keyword_type = *step.keyword_type; } - steps.push_back(make_pickle_step(step, last_keyword_type)); + steps.push_back( + make_pickle_step( + step, + variable_cells, + std::addressof(values_row), + last_keyword_type + ) + ); } strings source_ids = { s.id, values_row.id }; @@ -394,7 +401,7 @@ pickle_compiler::interpolate( const auto& value_cell = value_cells[col++]; header = "<" + variable_cell.value + ">"; - subst(iname, header, value_cell.value); + replace(iname, header, value_cell.value); } return iname; diff --git a/cpp/src/lib/gherkin/utils.cpp b/cpp/src/lib/gherkin/utils.cpp index ba2512214..3b827a2c5 100644 --- a/cpp/src/lib/gherkin/utils.cpp +++ b/cpp/src/lib/gherkin/utils.cpp @@ -29,4 +29,24 @@ slurp(const std::string& path) return bytes; } +void +replace(std::string& s, std::string_view what, std::string_view with) +{ + std::string::size_type pos; + + while ((pos = s.find(what)) != std::string::npos) { + s.replace(pos, what.size(), with); + } +} + +std::string +replace(const std::string& s, std::string_view what, std::string_view with) +{ + std::string t = s; + + replace(t, what, with); + + return t; +} + } From 0f45c53d9855e620d8d3307d9faec0791624b357 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Tue, 30 May 2023 17:41:52 +0200 Subject: [PATCH 50/76] chore: fixing error reporting --- cpp/gherkin-cpp.razor | 51 +- cpp/gherkin-dialect.cpp.jq | 11 +- cpp/include/gherkin/app.hpp | 6 + cpp/include/gherkin/cb_types.hpp | 4 + cpp/include/gherkin/dialect.hpp | 3 + cpp/include/gherkin/exceptions.hpp | 24 +- cpp/include/gherkin/location.hpp | 6 + cpp/include/gherkin/parse_error.hpp | 22 + cpp/include/gherkin/parser.hpp | 982 +++++++++++++------------ cpp/include/gherkin/parser_context.hpp | 26 +- cpp/include/gherkin/token_matcher.hpp | 5 +- cpp/src/bin/gherkin/gherkin.cpp | 3 + cpp/src/lib/gherkin/app.cpp | 41 +- cpp/src/lib/gherkin/dialect.cpp | 11 +- cpp/src/lib/gherkin/exceptions.cpp | 30 +- cpp/src/lib/gherkin/keywords.cpp | 1 + cpp/src/lib/gherkin/line.cpp | 14 + cpp/src/lib/gherkin/location.cpp | 11 + cpp/src/lib/gherkin/parse_error.cpp | 17 + cpp/src/lib/gherkin/token_matcher.cpp | 10 +- 20 files changed, 747 insertions(+), 531 deletions(-) create mode 100644 cpp/include/gherkin/parse_error.hpp create mode 100644 cpp/src/lib/gherkin/parse_error.cpp diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index 4f1d9566e..b53fa4aad 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -34,23 +34,24 @@ public static string NameOf(Rule rule) } @helper HandleParserError(IEnumerable expectedTokens, State state) { - /* "State: @state.Id - @Raw(state.Comment)" */ + std::string state_comment = "State: @state.Id - @Raw(state.Comment)"; std::string expected_tokens = "@Raw(string.Join(", ", expectedTokens))"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return @state.Id; } @@ -62,12 +63,6 @@ public static string NameOf(Rule rule) namespace gherkin { -enum class error_type -{ - unexpected_eof, - unexpected_token -}; - template < typename Builder = ast_builder, typename Scanner = token_scanner, @@ -100,7 +95,7 @@ protected: end_rule(context, rule_type::@NameOf(Model.RuleSet.StartRule)); if (context.has_errors()) { - context.report_errors(); + throw composite_parser_error(context.eptrs); } } @@ -139,15 +134,6 @@ protected: { using ret_type = decltype(action(argument)); - if (context.stop_at_first_error) { - if constexpr (std::is_same_v) { - action(argument); - return default_value; - } else { - return action(argument); - } - } - try { if constexpr (std::is_same_v) { action(argument); @@ -155,8 +141,13 @@ protected: } else { return action(argument); } - } catch (const std::exception& e) { - context.add_error(e); + } catch (const composite_parser_error& e) { + for (const auto& ep : e.errors()) { + context.add_error(ep); + } + } catch (const parser_error& e) { + auto ep = new_parser_error(e); + context.add_error(ep); } return default_value; @@ -267,7 +258,11 @@ protected: @:return match_token_at_@(state.Id)(token, context); } default: - context.add_error("invalid operation: " + std::to_string(state)); + throw + std::runtime_error( + "invalid operation: " + std::to_string(state) + ); + return -1; } } diff --git a/cpp/gherkin-dialect.cpp.jq b/cpp/gherkin-dialect.cpp.jq index 34a6b4a6d..2affeac59 100644 --- a/cpp/gherkin-dialect.cpp.jq +++ b/cpp/gherkin-dialect.cpp.jq @@ -2,8 +2,8 @@ [ "#include \n\n", "namespace gherkin {\n\n", - "const keywords_map&\n", - "keywords(const std::string_view& language)\n", + "const keywords_maps&\n", + "all_keywords()\n", "{\n", " static const keywords_maps kwms = {\n", " ", @@ -33,7 +33,12 @@ ] | join(",\n ") ), "\n };\n\n", - " return kwms.at(language);\n", + " return kwms;", + "}\n\n", + "const keywords_map&\n", + "keywords(const std::string_view& language)\n", + "{\n", + " return all_keywords().at(language);\n", "}\n\n", "}\n" ] | add diff --git a/cpp/include/gherkin/app.hpp b/cpp/include/gherkin/app.hpp index ca7e245b7..a9f254936 100644 --- a/cpp/include/gherkin/app.hpp +++ b/cpp/include/gherkin/app.hpp @@ -28,6 +28,12 @@ class app void parse(const cms::source& s, const callbacks& cbs = {}); private: + void send_parse_error( + const std::string& uri, + const parser_error& e, + const callbacks& cbs + ) const; + id_generator_ptr idp_; parser p_; bool include_source_ = true; diff --git a/cpp/include/gherkin/cb_types.hpp b/cpp/include/gherkin/cb_types.hpp index 302f52167..ec53e2af0 100644 --- a/cpp/include/gherkin/cb_types.hpp +++ b/cpp/include/gherkin/cb_types.hpp @@ -7,12 +7,15 @@ #include #include +#include + namespace gherkin { namespace cms = cucumber::messages; using source_cb = std::function; using pickle_cb = std::function; +using error_cb = std::function; template struct callbacks @@ -22,6 +25,7 @@ struct callbacks gherkin::source_cb source; ast_cb ast; gherkin::pickle_cb pickle; + error_cb error; }; template diff --git a/cpp/include/gherkin/dialect.hpp b/cpp/include/gherkin/dialect.hpp index 6a7d30c90..b7d59d4aa 100644 --- a/cpp/include/gherkin/dialect.hpp +++ b/cpp/include/gherkin/dialect.hpp @@ -22,6 +22,9 @@ struct dialect const string_views& but_keywords; }; +const keywords_maps& +all_keywords(); + const keywords_map& keywords(const std::string_view& language); diff --git a/cpp/include/gherkin/exceptions.hpp b/cpp/include/gherkin/exceptions.hpp index faf72cabd..2a5d0d1d8 100644 --- a/cpp/include/gherkin/exceptions.hpp +++ b/cpp/include/gherkin/exceptions.hpp @@ -12,16 +12,26 @@ namespace gherkin { class parser_error : public std::runtime_error { public: - parser_error(const std::string& message, location location); + parser_error( + const std::string& message, + const gherkin::location& location + ); + + parser_error(const parser_error& other); + virtual ~parser_error(); std::string make_message( const std::string& message, - location location + const gherkin::location& location ) const; + bool same_message(const parser_error& other) const; + + const gherkin::location& location() const; + private: - location location_; + gherkin::location location_; }; using parser_error_ptr = std::shared_ptr; @@ -37,7 +47,11 @@ using ast_builder_error = parser_error; class no_such_language_error : public parser_error { public: - no_such_language_error(const std::string& language, location location); + no_such_language_error( + const std::string& language, + const gherkin::location& location + ); + virtual ~no_such_language_error(); }; @@ -90,6 +104,8 @@ class composite_parser_error : public parser_error std::string make_message(const parser_error_ptrs& ptrs) const; + const parser_error_ptrs& errors() const; + private: parser_error_ptrs ptrs_; }; diff --git a/cpp/include/gherkin/location.hpp b/cpp/include/gherkin/location.hpp index f17c60478..dcaac4ec2 100644 --- a/cpp/include/gherkin/location.hpp +++ b/cpp/include/gherkin/location.hpp @@ -2,14 +2,20 @@ #include +#include + namespace gherkin { +using json = nlohmann::json; + struct location { std::size_t line; std::size_t column; std::string to_string() const; + + json to_json() const; }; inline diff --git a/cpp/include/gherkin/parse_error.hpp b/cpp/include/gherkin/parse_error.hpp new file mode 100644 index 000000000..d71a24ecf --- /dev/null +++ b/cpp/include/gherkin/parse_error.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include + +#include + +namespace gherkin { + +using json = nlohmann::json; + +struct parse_error +{ + std::string uri; + gherkin::location location; + std::string message; + + json to_json() const; +}; + +} diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/parser.hpp index d245c3fad..127a96483 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -4,12 +4,6 @@ namespace gherkin { -enum class error_type -{ - unexpected_eof, - unexpected_token -}; - template < typename Builder = ast_builder, typename Scanner = token_scanner, @@ -42,7 +36,7 @@ class parser : public parser_base end_rule(context, rule_type::gherkin_document); if (context.has_errors()) { - context.report_errors(); + throw composite_parser_error(context.eptrs); } } @@ -81,15 +75,6 @@ class parser : public parser_base { using ret_type = decltype(action(argument)); - if (context.stop_at_first_error) { - if constexpr (std::is_same_v) { - action(argument); - return default_value; - } else { - return action(argument); - } - } - try { if constexpr (std::is_same_v) { action(argument); @@ -97,8 +82,13 @@ class parser : public parser_base } else { return action(argument); } - } catch (const std::exception& e) { - context.add_error(e); + } catch (const composite_parser_error& e) { + for (const auto& ep : e.errors()) { + context.add_error(ep); + } + } catch (const parser_error& e) { + auto ep = new_parser_error(e); + context.add_error(ep); } return default_value; @@ -438,23 +428,24 @@ class parser : public parser_base return 0; } - /* "State: 0 - Start" */ + std::string state_comment = "State: 0 - Start"; std::string expected_tokens = "#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 0; } @@ -480,23 +471,24 @@ class parser : public parser_base return 1; } - /* "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0" */ + std::string state_comment = "State: 1 - GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0"; std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 1; } @@ -522,23 +514,24 @@ class parser : public parser_base return 2; } - /* "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0" */ + std::string state_comment = "State: 2 - GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0"; std::string expected_tokens = "#TagLine, #FeatureLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 2; } @@ -603,23 +596,24 @@ class parser : public parser_base return 4; } - /* "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0" */ + std::string state_comment = "State: 3 - GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0"; std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 3; } @@ -686,23 +680,24 @@ class parser : public parser_base return 4; } - /* "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0" */ + std::string state_comment = "State: 4 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0"; std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 4; } @@ -762,23 +757,24 @@ class parser : public parser_base return 5; } - /* "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0" */ + std::string state_comment = "State: 5 - GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0"; std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 5; } @@ -842,23 +838,24 @@ class parser : public parser_base return 7; } - /* "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0" */ + std::string state_comment = "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0"; std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 6; } @@ -924,23 +921,24 @@ class parser : public parser_base return 7; } - /* "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string state_comment = "State: 7 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0"; std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 7; } @@ -999,23 +997,24 @@ class parser : public parser_base return 8; } - /* "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string state_comment = "State: 8 - GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0"; std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 8; } @@ -1090,23 +1089,24 @@ class parser : public parser_base return 9; } - /* "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0" */ + std::string state_comment = "State: 9 - GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0"; std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 9; } @@ -1181,23 +1181,24 @@ class parser : public parser_base return 10; } - /* "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string state_comment = "State: 10 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0"; std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 10; } @@ -1224,23 +1225,24 @@ class parser : public parser_base return 11; } - /* "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string state_comment = "State: 11 - GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0"; std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 11; } @@ -1323,23 +1325,24 @@ class parser : public parser_base return 13; } - /* "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string state_comment = "State: 12 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0"; std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 12; } @@ -1426,23 +1429,24 @@ class parser : public parser_base return 13; } - /* "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string state_comment = "State: 13 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0"; std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 13; } @@ -1520,23 +1524,24 @@ class parser : public parser_base return 14; } - /* "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string state_comment = "State: 14 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0"; std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 14; } @@ -1632,23 +1637,24 @@ class parser : public parser_base return 15; } - /* "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string state_comment = "State: 15 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0"; std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 15; } @@ -1746,23 +1752,24 @@ class parser : public parser_base return 16; } - /* "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string state_comment = "State: 16 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0"; std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 16; } @@ -1789,23 +1796,24 @@ class parser : public parser_base return 17; } - /* "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string state_comment = "State: 17 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0"; std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 17; } @@ -1902,23 +1910,24 @@ class parser : public parser_base return 19; } - /* "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string state_comment = "State: 18 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0"; std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 18; } @@ -2019,23 +2028,24 @@ class parser : public parser_base return 19; } - /* "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string state_comment = "State: 19 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0"; std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 19; } @@ -2127,23 +2137,24 @@ class parser : public parser_base return 20; } - /* "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string state_comment = "State: 20 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0"; std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 20; } @@ -2241,23 +2252,24 @@ class parser : public parser_base return 21; } - /* "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string state_comment = "State: 21 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0"; std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 21; } @@ -2283,23 +2295,24 @@ class parser : public parser_base return 22; } - /* "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0" */ + std::string state_comment = "State: 22 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0"; std::string expected_tokens = "#TagLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 22; } @@ -2367,23 +2380,24 @@ class parser : public parser_base return 24; } - /* "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0" */ + std::string state_comment = "State: 23 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0"; std::string expected_tokens = "#EOF, #Empty, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 23; } @@ -2453,23 +2467,24 @@ class parser : public parser_base return 24; } - /* "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0" */ + std::string state_comment = "State: 24 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0"; std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 24; } @@ -2532,23 +2547,24 @@ class parser : public parser_base return 25; } - /* "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0" */ + std::string state_comment = "State: 25 - GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0"; std::string expected_tokens = "#EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 25; } @@ -2615,23 +2631,24 @@ class parser : public parser_base return 27; } - /* "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0" */ + std::string state_comment = "State: 26 - GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0"; std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 26; } @@ -2700,23 +2717,24 @@ class parser : public parser_base return 27; } - /* "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string state_comment = "State: 27 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0"; std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 27; } @@ -2778,23 +2796,24 @@ class parser : public parser_base return 28; } - /* "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0" */ + std::string state_comment = "State: 28 - GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0"; std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 28; } @@ -2872,23 +2891,24 @@ class parser : public parser_base return 29; } - /* "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0" */ + std::string state_comment = "State: 29 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0"; std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 29; } @@ -2966,23 +2986,24 @@ class parser : public parser_base return 30; } - /* "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string state_comment = "State: 30 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0"; std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 30; } @@ -3009,23 +3030,24 @@ class parser : public parser_base return 31; } - /* "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0" */ + std::string state_comment = "State: 31 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0"; std::string expected_tokens = "#TagLine, #ScenarioLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 31; } @@ -3111,23 +3133,24 @@ class parser : public parser_base return 33; } - /* "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0" */ + std::string state_comment = "State: 32 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0"; std::string expected_tokens = "#EOF, #Empty, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 32; } @@ -3217,23 +3240,24 @@ class parser : public parser_base return 33; } - /* "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string state_comment = "State: 33 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0"; std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 33; } @@ -3314,23 +3338,24 @@ class parser : public parser_base return 34; } - /* "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0" */ + std::string state_comment = "State: 34 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0"; std::string expected_tokens = "#EOF, #Comment, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 34; } @@ -3429,23 +3454,24 @@ class parser : public parser_base return 35; } - /* "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0" */ + std::string state_comment = "State: 35 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0"; std::string expected_tokens = "#EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 35; } @@ -3546,23 +3572,24 @@ class parser : public parser_base return 36; } - /* "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0" */ + std::string state_comment = "State: 36 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0"; std::string expected_tokens = "#EOF, #TableRow, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 36; } @@ -3589,23 +3616,24 @@ class parser : public parser_base return 37; } - /* "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0" */ + std::string state_comment = "State: 37 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0"; std::string expected_tokens = "#TagLine, #ExamplesLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 37; } @@ -3705,23 +3733,24 @@ class parser : public parser_base return 39; } - /* "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0" */ + std::string state_comment = "State: 38 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0"; std::string expected_tokens = "#EOF, #Empty, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 38; } @@ -3825,23 +3854,24 @@ class parser : public parser_base return 39; } - /* "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0" */ + std::string state_comment = "State: 39 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0"; std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 39; } @@ -3936,23 +3966,24 @@ class parser : public parser_base return 40; } - /* "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0" */ + std::string state_comment = "State: 40 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0"; std::string expected_tokens = "#EOF, #Comment, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 40; } @@ -4053,23 +4084,24 @@ class parser : public parser_base return 41; } - /* "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0" */ + std::string state_comment = "State: 41 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0"; std::string expected_tokens = "#EOF, #TableRow, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 41; } @@ -4086,23 +4118,24 @@ class parser : public parser_base return 43; } - /* "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string state_comment = "State: 43 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0"; std::string expected_tokens = "#DocStringSeparator, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 43; } @@ -4199,23 +4232,24 @@ class parser : public parser_base return 44; } - /* "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string state_comment = "State: 44 - GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0"; std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 44; } @@ -4232,23 +4266,24 @@ class parser : public parser_base return 45; } - /* "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string state_comment = "State: 45 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0"; std::string expected_tokens = "#DocStringSeparator, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 45; } @@ -4322,23 +4357,24 @@ class parser : public parser_base return 46; } - /* "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string state_comment = "State: 46 - GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0"; std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 46; } @@ -4355,23 +4391,24 @@ class parser : public parser_base return 47; } - /* "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string state_comment = "State: 47 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0"; std::string expected_tokens = "#DocStringSeparator, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 47; } @@ -4465,23 +4502,24 @@ class parser : public parser_base return 48; } - /* "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string state_comment = "State: 48 - GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0"; std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 48; } @@ -4498,23 +4536,24 @@ class parser : public parser_base return 49; } - /* "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0" */ + std::string state_comment = "State: 49 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0"; std::string expected_tokens = "#DocStringSeparator, #Other"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 49; } @@ -4585,23 +4624,24 @@ class parser : public parser_base return 50; } - /* "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0" */ + std::string state_comment = "State: 50 - GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0"; std::string expected_tokens = "#EOF, #StepLine, #TagLine, #ScenarioLine, #RuleLine, #Comment, #Empty"; - auto error = - ( - token.is_eof() - ? "unexpected eof: " - : "unexpected token: " + auto ep = + token.is_eof() + ? new_parser_error( + token, expected_tokens, state_comment + ) + : new_parser_error( + token, expected_tokens, state_comment ) - + expected_tokens ; if (context.stop_at_first_error) { - //throw parser_error(error + ); + throw *ep; } - context.add_error(expected_tokens); + context.add_error(std::move(ep)); return 50; } @@ -4710,7 +4750,11 @@ class parser : public parser_base case 50: return match_token_at_50(token, context); default: - context.add_error("invalid operation: " + std::to_string(state)); + throw + std::runtime_error( + "invalid operation: " + std::to_string(state) + ); + return -1; } } diff --git a/cpp/include/gherkin/parser_context.hpp b/cpp/include/gherkin/parser_context.hpp index 2f609b511..2fd0cdb8c 100644 --- a/cpp/include/gherkin/parser_context.hpp +++ b/cpp/include/gherkin/parser_context.hpp @@ -1,5 +1,6 @@ #include #include +#include #include namespace gherkin { @@ -16,8 +17,9 @@ struct parser_context Matcher& matcher; token_queue queue; - strings errors; + parser_error_ptrs eptrs; bool stop_at_first_error = false; + std::size_t max_errors = 10; bool has_token() const { return !queue.empty(); } @@ -37,19 +39,23 @@ struct parser_context { queue.insert(queue.end(), q.begin(), q.end()); } bool has_errors() const - { return !errors.empty(); } + { return !eptrs.empty(); } - void add_error(const std::string& e) - { errors.push_back(e); } + void add_error(parser_error_ptr ep) + { + for (const auto& p : eptrs) { + if (p->same_message(*ep)) { + return; + } - void add_error(const std::exception& e) - { add_error(e.what()); } + std::cerr << "not duplicate" << std::endl; + } - void report_errors() const - { - auto es = join("\n", errors); + eptrs.emplace_back(std::move(ep)); - throw std::runtime_error("errors:\n" + es); + if (eptrs.size() > max_errors) { + throw composite_parser_error(eptrs); + } } }; diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index 161e68ecf..c368565cc 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -71,7 +71,10 @@ class token_matcher cucumber::messages::step_keyword_type keyword_type(std::string_view keyword) const; - void change_dialect(const std::string& dialect_name); + void change_dialect( + const std::string& dialect_name, + const gherkin::location& location = { 1, 1 } + ); std::string unescape_docstring(const std::string& text) const; diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 0b56dd795..0f63abf69 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -77,6 +77,9 @@ int main(int ac, char** av) p.to_json(j["pickle"]); std::cout << j << std::endl; + }, + .error = [&](const auto& e) { + std::cout << e.to_json() << std::endl; } }; diff --git a/cpp/src/lib/gherkin/app.cpp b/cpp/src/lib/gherkin/app.cpp index 0da163551..8b351644b 100644 --- a/cpp/src/lib/gherkin/app.cpp +++ b/cpp/src/lib/gherkin/app.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace gherkin { @@ -47,17 +48,41 @@ app::parse(const cms::envelope& e, const callbacks& cbs) void app::parse(const cms::source& s, const callbacks& cbs) { - auto ast = p_.parse(s.uri, s.data); - - if (include_ast_ && cbs.ast) { - cbs.ast(ast); + try { + auto ast = p_.parse(s.uri, s.data); + + if (include_ast_ && cbs.ast) { + cbs.ast(ast); + } + + if (include_pickles_ && cbs.pickle) { + pickle_compiler pc(idp_); + + pc.compile(ast, s.uri, cbs.pickle); + } + } catch (const composite_parser_error& e) { + for (const auto& ep : e.errors()) { + send_parse_error(s.uri, *ep, cbs); + } + } catch (const parser_error& e) { + send_parse_error(s.uri, e, cbs); } +} - if (include_pickles_ && cbs.pickle) { - pickle_compiler pc(idp_); +void +app::send_parse_error( + const std::string& uri, + const parser_error& e, + const callbacks& cbs +) const +{ + parse_error pe{ + .uri = uri, + .location = e.location(), + .message = e.what() + }; - pc.compile(ast, s.uri, cbs.pickle); - } + call_cb(cbs.error, pe); } } diff --git a/cpp/src/lib/gherkin/dialect.cpp b/cpp/src/lib/gherkin/dialect.cpp index 2a2dd7c97..89abfb5b5 100644 --- a/cpp/src/lib/gherkin/dialect.cpp +++ b/cpp/src/lib/gherkin/dialect.cpp @@ -2,8 +2,8 @@ namespace gherkin { -const keywords_map& -keywords(const std::string_view& language) +const keywords_maps& +all_keywords() { static const keywords_maps kwms = { { @@ -1272,7 +1272,12 @@ keywords(const std::string_view& language) } }; - return kwms.at(language); + return kwms;} + +const keywords_map& +keywords(const std::string_view& language) +{ + return all_keywords().at(language); } } diff --git a/cpp/src/lib/gherkin/exceptions.cpp b/cpp/src/lib/gherkin/exceptions.cpp index 3edb452e0..00d26bec1 100644 --- a/cpp/src/lib/gherkin/exceptions.cpp +++ b/cpp/src/lib/gherkin/exceptions.cpp @@ -11,8 +11,17 @@ namespace gherkin { // parser error // /////////////////////////////////////////////////////////////////////////////// -parser_error::parser_error(const std::string& message, location location) -: std::runtime_error(make_message(message, location)) +parser_error::parser_error( + const std::string& message, + const gherkin::location& location +) +: std::runtime_error(make_message(message, location)), +location_(location) +{} + +parser_error::parser_error(const parser_error& other) +: std::runtime_error(other.what()), +location_(other.location_) {} parser_error::~parser_error() @@ -21,7 +30,7 @@ parser_error::~parser_error() std::string parser_error::make_message( const std::string& message, - location location + const gherkin::location& location ) const { std::ostringstream oss; @@ -31,6 +40,14 @@ parser_error::make_message( return oss.str(); } +bool +parser_error::same_message(const parser_error& other) const +{ return std::strcmp(what(), other.what()) == 0; } + +const gherkin::location& +parser_error::location() const +{ return location_; } + /////////////////////////////////////////////////////////////////////////////// // // no such language error @@ -38,7 +55,8 @@ parser_error::make_message( /////////////////////////////////////////////////////////////////////////////// no_such_language_error::no_such_language_error( const std::string& language, - location location) + const gherkin::location& location +) : parser_error("Language not supported: " + language, location) {} @@ -143,4 +161,8 @@ composite_parser_error::make_message(const parser_error_ptrs& ptrs) const return oss.str(); } +const parser_error_ptrs& +composite_parser_error::errors() const +{ return ptrs_; } + } diff --git a/cpp/src/lib/gherkin/keywords.cpp b/cpp/src/lib/gherkin/keywords.cpp index f35720da4..ca5a276ba 100644 --- a/cpp/src/lib/gherkin/keywords.cpp +++ b/cpp/src/lib/gherkin/keywords.cpp @@ -1,4 +1,5 @@ #include +#include namespace gherkin { diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index 5d63bf5a5..4d3eeaed9 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace gherkin { @@ -161,11 +162,24 @@ line::tags() const auto column = indent_ + 1; auto items_line = subst(trimmed_line_text_, "\\s+(?:#.*)?$", ""); auto items = split("@", items_line); + std::regex no_spaces("^\\S+$"); for (std::size_t i = 1; i < items.size(); ++i) { auto original_item = items[i]; auto sitem = strip(items[i]); + if (sitem.empty()) { + continue; + } + + if (!full_match(sitem, no_spaces)) { + throw + parser_error( + "A tag may not contain whitespace", + location{ .line = line_number_, .column = column } + ); + } + tags.emplace_back(item{ .column = column, .text = "@" + sitem diff --git a/cpp/src/lib/gherkin/location.cpp b/cpp/src/lib/gherkin/location.cpp index 8a0776263..499fffd25 100644 --- a/cpp/src/lib/gherkin/location.cpp +++ b/cpp/src/lib/gherkin/location.cpp @@ -14,4 +14,15 @@ location::to_string() const return oss.str(); } +json +location::to_json() const +{ + json j; + + j["line"] = line; + j["column"] = column; + + return j; +} + } diff --git a/cpp/src/lib/gherkin/parse_error.cpp b/cpp/src/lib/gherkin/parse_error.cpp new file mode 100644 index 000000000..9d6d185ab --- /dev/null +++ b/cpp/src/lib/gherkin/parse_error.cpp @@ -0,0 +1,17 @@ +#include + +namespace gherkin { + +json +parse_error::to_json() const +{ + json j; + + j["parseError"]["source"]["uri"] = uri; + j["parseError"]["source"]["location"] = location.to_json(); + j["parseError"]["message"] = message; + + return j; +} + +} diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index 6c55ebedb..d6896e2f3 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace gherkin { @@ -337,8 +338,15 @@ token_matcher::keyword_type(std::string_view keyword) const } void -token_matcher::change_dialect(const std::string& dialect_name) +token_matcher::change_dialect( + const std::string& dialect_name, + const gherkin::location& location +) { + if (all_keywords().find(dialect_name) == all_keywords().end()) { + throw no_such_language_error(dialect_name, location); + } + dialect_name_ = dialect_name; auto d = get_dialect(dialect_name_); From 994b39f181c2f059b88956d853e036290ff6d977 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Wed, 31 May 2023 10:29:40 +0200 Subject: [PATCH 51/76] feat: ACCEPTANCE OK (phewww) --- cpp/include/gherkin/ast_builder.hpp | 1 + cpp/include/gherkin/exceptions.hpp | 17 ++++++---- cpp/include/gherkin/location.hpp | 30 ----------------- cpp/include/gherkin/parse_error.hpp | 7 ++-- cpp/include/gherkin/token.hpp | 4 +-- cpp/include/gherkin/token_matcher.hpp | 2 +- cpp/src/bin/gherkin/gherkin.cpp | 33 ++++++++----------- cpp/src/lib/gherkin/ast_builder.cpp | 26 +++++++++++++++ cpp/src/lib/gherkin/exceptions.cpp | 27 +++++++++++---- cpp/src/lib/gherkin/line.cpp | 2 +- cpp/src/lib/gherkin/location.cpp | 28 ---------------- cpp/src/lib/gherkin/parse_error.cpp | 2 +- .../lib/gherkin/token_formatter_builder.cpp | 3 +- cpp/src/lib/gherkin/token_matcher.cpp | 2 +- 14 files changed, 84 insertions(+), 100 deletions(-) delete mode 100644 cpp/include/gherkin/location.hpp delete mode 100644 cpp/src/lib/gherkin/location.cpp diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 403e62f05..a63dabeac 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -64,6 +64,7 @@ class ast_builder ) const; table_rows get_table_rows(const ast_node& node); + void ensure_cell_count(const table_rows& rows) const; table_cells get_table_cells(const token& token); tags get_tags(const ast_node& node); diff --git a/cpp/include/gherkin/exceptions.hpp b/cpp/include/gherkin/exceptions.hpp index 2a5d0d1d8..770547936 100644 --- a/cpp/include/gherkin/exceptions.hpp +++ b/cpp/include/gherkin/exceptions.hpp @@ -3,18 +3,21 @@ #include #include +#include + #include #include -#include namespace gherkin { +namespace cms = cucumber::messages; + class parser_error : public std::runtime_error { public: parser_error( const std::string& message, - const gherkin::location& location + const cms::location& location ); parser_error(const parser_error& other); @@ -23,15 +26,15 @@ class parser_error : public std::runtime_error std::string make_message( const std::string& message, - const gherkin::location& location + const cms::location& location ) const; bool same_message(const parser_error& other) const; - const gherkin::location& location() const; + const cms::location& location() const; private: - gherkin::location location_; + cms::location location_; }; using parser_error_ptr = std::shared_ptr; @@ -49,7 +52,7 @@ class no_such_language_error : public parser_error public: no_such_language_error( const std::string& language, - const gherkin::location& location + const cms::location& location ); virtual ~no_such_language_error(); @@ -71,6 +74,8 @@ class unexpected_token : public parser_error const std::string& expected_tokens ) const; + cms::location make_location(const token& t) const; + private: token received_token_; std::string expected_tokens_; diff --git a/cpp/include/gherkin/location.hpp b/cpp/include/gherkin/location.hpp deleted file mode 100644 index dcaac4ec2..000000000 --- a/cpp/include/gherkin/location.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include - -#include - -namespace gherkin { - -using json = nlohmann::json; - -struct location -{ - std::size_t line; - std::size_t column; - - std::string to_string() const; - - json to_json() const; -}; - -inline -std::ostream& -operator<<(std::ostream& os, const location& l) -{ - os << l.to_string(); - - return os; -} - -} diff --git a/cpp/include/gherkin/parse_error.hpp b/cpp/include/gherkin/parse_error.hpp index d71a24ecf..aaddf2605 100644 --- a/cpp/include/gherkin/parse_error.hpp +++ b/cpp/include/gherkin/parse_error.hpp @@ -2,18 +2,19 @@ #include -#include - #include +#include + namespace gherkin { using json = nlohmann::json; +namespace cms = cucumber::messages; struct parse_error { std::string uri; - gherkin::location location; + cms::location location; std::string message; json to_json() const; diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index 9b99fbd14..99e156776 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -6,10 +6,10 @@ #include #include +#include #include #include -#include #include #include @@ -28,7 +28,7 @@ struct token gherkin::items matched_items; std::string matched_text; std::string matched_gherkin_dialect; - gherkin::location location; + cms::location location; bool is_eof() const; diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index c368565cc..8421d91ec 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -73,7 +73,7 @@ class token_matcher void change_dialect( const std::string& dialect_name, - const gherkin::location& location = { 1, 1 } + const cms::location& location = { 1, 1 } ); std::string unescape_docstring(const std::string& text) const; diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 0f63abf69..619210c80 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -51,6 +51,15 @@ parse_options(int ac, char** av) return opts; } +void print_json_obj(std::string_view key, const auto& o) +{ + nlohmann::json j; + + o.to_json(j[key]); + + std::cout << j << std::endl; +} + int main(int ac, char** av) { auto opts = parse_options(ac, av); @@ -61,26 +70,10 @@ int main(int ac, char** av) gherkin::app app; gherkin::app::callbacks cbs{ - .source = [&](const auto& s) { - std::cout << s.to_json() << std::endl; - }, - .ast = [&](const auto& a) { - nlohmann::json j; - - a.to_json(j["gherkinDocument"]); - - std::cout << j << std::endl; - }, - .pickle = [&](const auto& p) { - nlohmann::json j; - - p.to_json(j["pickle"]); - - std::cout << j << std::endl; - }, - .error = [&](const auto& e) { - std::cout << e.to_json() << std::endl; - } + .source = [&](const auto& m) { print_json_obj("source", m); }, + .ast = [&](const auto& m) { print_json_obj("gherkinDocument", m); }, + .pickle = [&](const auto& m) { print_json_obj("pickle", m); }, + .error = [&](const auto& m) { std::cout << m.to_json() << std::endl; } }; app.include_source(opts.include_source); diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index 26154457b..f255b4ece 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace gherkin { @@ -393,9 +394,34 @@ ast_builder::get_table_rows(const ast_node& node) }); } + ensure_cell_count(rows); + return rows; } +void +ast_builder::ensure_cell_count(const table_rows& rows) const +{ + if (rows.empty()) { + return; + } + + std::size_t cell_count = rows.front().cells.size(); + + for (const auto& row : rows) { + if (row.cells.size() != cell_count) { + throw + ast_builder_error( + "inconsistent cell count within the table", + { + .line = row.location.line, + .column = row.location.column.value_or(0) + } + ); + } + } +} + table_cells ast_builder::get_table_cells(const token& token) { diff --git a/cpp/src/lib/gherkin/exceptions.cpp b/cpp/src/lib/gherkin/exceptions.cpp index 00d26bec1..1dced3398 100644 --- a/cpp/src/lib/gherkin/exceptions.cpp +++ b/cpp/src/lib/gherkin/exceptions.cpp @@ -13,7 +13,7 @@ namespace gherkin { /////////////////////////////////////////////////////////////////////////////// parser_error::parser_error( const std::string& message, - const gherkin::location& location + const cms::location& location ) : std::runtime_error(make_message(message, location)), location_(location) @@ -30,12 +30,14 @@ parser_error::~parser_error() std::string parser_error::make_message( const std::string& message, - const gherkin::location& location + const cms::location& location ) const { std::ostringstream oss; - oss << location << ": " << message; + oss + << "(" << location.line << ":" << location.column.value_or(0) << ")" + << ": " << message; return oss.str(); } @@ -44,7 +46,7 @@ bool parser_error::same_message(const parser_error& other) const { return std::strcmp(what(), other.what()) == 0; } -const gherkin::location& +const cms::location& parser_error::location() const { return location_; } @@ -55,7 +57,7 @@ parser_error::location() const /////////////////////////////////////////////////////////////////////////////// no_such_language_error::no_such_language_error( const std::string& language, - const gherkin::location& location + const cms::location& location ) : parser_error("Language not supported: " + language, location) {} @@ -75,7 +77,7 @@ unexpected_token::unexpected_token( ) : parser_error( make_message(received_token, expected_tokens), - received_token.location + make_location(received_token) ), received_token_(received_token), expected_tokens_(expected_tokens), @@ -101,6 +103,19 @@ unexpected_token::make_message( return oss.str(); } +cms::location +unexpected_token::make_location(const token& t) const +{ + return + t.location.column.value_or(0) > 1 + ? t.location + : cms::location{ + .line = t.location.line, + .column = t.line.indent() + 1 + } + ; +} + /////////////////////////////////////////////////////////////////////////////// // // unexpected eof diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index 4d3eeaed9..d87f70e47 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -176,7 +176,7 @@ line::tags() const throw parser_error( "A tag may not contain whitespace", - location{ .line = line_number_, .column = column } + { .line = line_number_, .column = column } ); } diff --git a/cpp/src/lib/gherkin/location.cpp b/cpp/src/lib/gherkin/location.cpp deleted file mode 100644 index 499fffd25..000000000 --- a/cpp/src/lib/gherkin/location.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -#include - -namespace gherkin { - -std::string -location::to_string() const -{ - std::ostringstream oss; - - oss << "(" << line << ":" << column << ")"; - - return oss.str(); -} - -json -location::to_json() const -{ - json j; - - j["line"] = line; - j["column"] = column; - - return j; -} - -} diff --git a/cpp/src/lib/gherkin/parse_error.cpp b/cpp/src/lib/gherkin/parse_error.cpp index 9d6d185ab..d194f4a1d 100644 --- a/cpp/src/lib/gherkin/parse_error.cpp +++ b/cpp/src/lib/gherkin/parse_error.cpp @@ -8,7 +8,7 @@ parse_error::to_json() const json j; j["parseError"]["source"]["uri"] = uri; - j["parseError"]["source"]["location"] = location.to_json(); + location.to_json(j["parseError"]["source"]["location"]); j["parseError"]["message"] = message; return j; diff --git a/cpp/src/lib/gherkin/token_formatter_builder.cpp b/cpp/src/lib/gherkin/token_formatter_builder.cpp index 438679682..179762809 100644 --- a/cpp/src/lib/gherkin/token_formatter_builder.cpp +++ b/cpp/src/lib/gherkin/token_formatter_builder.cpp @@ -44,7 +44,8 @@ token_formatter_builder::format_token(const token& token) std::ostringstream oss; oss - << "(" << token.location.line << ":" << token.location.column << ")" + << "(" << token.location.line + << ":" << token.location.column.value_or(0) << ")" << token.matched_type << ":" ; diff --git a/cpp/src/lib/gherkin/token_matcher.cpp b/cpp/src/lib/gherkin/token_matcher.cpp index d6896e2f3..9d8928e3f 100644 --- a/cpp/src/lib/gherkin/token_matcher.cpp +++ b/cpp/src/lib/gherkin/token_matcher.cpp @@ -340,7 +340,7 @@ token_matcher::keyword_type(std::string_view keyword) const void token_matcher::change_dialect( const std::string& dialect_name, - const gherkin::location& location + const cms::location& location ) { if (all_keywords().find(dialect_name) == all_keywords().end()) { From e46b515483d6229c43dbdf18e5dddb79894223a1 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Wed, 31 May 2023 11:11:26 +0200 Subject: [PATCH 52/76] chore: added nlohmann::json dependency --- cpp/CMakeLists.txt | 1 + cpp/deps.txt | 1 + cpp/src/lib/gherkin/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 754d6224a..ef94374c4 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -9,6 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +find_package(nlohmann_json CONFIG REQUIRED) find_package(cucumber-messages CONFIG REQUIRED) add_subdirectory(src/lib/gherkin) diff --git a/cpp/deps.txt b/cpp/deps.txt index 0a6b587c8..19078b659 100644 --- a/cpp/deps.txt +++ b/cpp/deps.txt @@ -1 +1,2 @@ +https://github.com/nlohmann/json/archive/refs/tags/v3.11.2.zip -DJSON_BuildTests=OFF https://github.com/chybz/cucumber-messages/archive/refs/heads/feature/cpp.zip --src-dir=cpp diff --git a/cpp/src/lib/gherkin/CMakeLists.txt b/cpp/src/lib/gherkin/CMakeLists.txt index a25d9d98a..fda4c0584 100644 --- a/cpp/src/lib/gherkin/CMakeLists.txt +++ b/cpp/src/lib/gherkin/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries( gherkin-cpp PUBLIC cucumber::cucumber-messages + nlohmann_json::nlohmann_json ) set_target_properties( From 825bd8cff62d0b9f1096ef4d7a597b0dad6a4c2c Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Wed, 31 May 2023 19:18:29 +0200 Subject: [PATCH 53/76] chore: added introductory documentation --- .github/workflows/test-cpp.yml | 33 +++++++++++++++++++++++++ Makefile | 4 +-- README.md | 22 +++++++++++++++++ cpp/include/gherkin/pickle_compiler.hpp | 2 ++ cpp/src/lib/gherkin/pickle_compiler.cpp | 4 +++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test-cpp.yml diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml new file mode 100644 index 000000000..ba5784541 --- /dev/null +++ b/.github/workflows/test-cpp.yml @@ -0,0 +1,33 @@ +name: test-c + +on: + push: + branches: + - main + - renovate/** + pull_request: + branches: + - main + workflow_call: + +jobs: + test-cpp: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: install cmake and libraries + run: | + sudo apt-get update + sudo apt-get install ninja-build cmake + sudo apt-get install nlohmann-json3-dev + ninja --version + cmake --version + gcc --version + + - name: configure and build + run: | + make install-deps + make acceptance + working-directory: cpp diff --git a/Makefile b/Makefile index 9e74f29cf..78f4a616d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -languages = c dart dotnet elixir go java javascript perl php python ruby +languages = c cpp dart dotnet elixir go java javascript perl php python ruby .DEFAULT_GOAL = help @@ -59,4 +59,4 @@ docker-run: ## Start a docker container with all languages and tools installed --tty \ cucumber/cucumber-build:0.13.0 \ bash -.PHONY: \ No newline at end of file +.PHONY: diff --git a/README.md b/README.md index fb4652fca..f8b71acb9 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Gherkin is currently implemented for the following platforms (in order of birthd - [Objective-C](./objective-c) - [Perl](./perl) - [PHP](./php) +- [C++](./cpp) ## Contributing Translations (i18n) @@ -150,6 +151,27 @@ $parser = new GherkinParser(); $pickles = $parser->parseString(uri: $path, data: file_get_contents($path)); ``` +```c++ +// C++ +#include +#include +#include + +int main(int ac, char** av) +{ + gherkin::parser<> p; + std::string feature_file{ av[1] }; + + auto ast = p.parse(feature_file, slurp(feature_file)); + + gherkin::pickle_compiler pc; + + auto pickles = pc.compile(ast, feature_file); + + return 0; +} +``` + ### CLI The Gherkin CLI `gherkin` reads Gherkin source files (`.feature` files) and outputs diff --git a/cpp/include/gherkin/pickle_compiler.hpp b/cpp/include/gherkin/pickle_compiler.hpp index 03c003db6..b471ab01c 100644 --- a/cpp/include/gherkin/pickle_compiler.hpp +++ b/cpp/include/gherkin/pickle_compiler.hpp @@ -13,7 +13,9 @@ namespace gherkin { class pickle_compiler { public: + pickle_compiler(); pickle_compiler(id_generator_ptr idp); + virtual ~pickle_compiler(); pickles compile( diff --git a/cpp/src/lib/gherkin/pickle_compiler.cpp b/cpp/src/lib/gherkin/pickle_compiler.cpp index fe882e055..eb1d122b0 100644 --- a/cpp/src/lib/gherkin/pickle_compiler.cpp +++ b/cpp/src/lib/gherkin/pickle_compiler.cpp @@ -27,6 +27,10 @@ void append(Vector& to, const Vector& from) { to.insert(to.end(), from.begin(), from.end()); } +pickle_compiler::pickle_compiler() +: pickle_compiler(new_id_generator()) +{} + pickle_compiler::pickle_compiler(id_generator_ptr idp) : idp_(idp) {} From f7b2b3882c4ed69914719249f4c66bf7df44d684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Chibois?= Date: Wed, 31 May 2023 19:21:35 +0200 Subject: [PATCH 54/76] Update README.md missing c++ namespace --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8b71acb9..079081771 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ int main(int ac, char** av) gherkin::parser<> p; std::string feature_file{ av[1] }; - auto ast = p.parse(feature_file, slurp(feature_file)); + auto ast = p.parse(feature_file, gherkin::slurp(feature_file)); gherkin::pickle_compiler pc; From 848b6b8f44357716cb6ec9ffdd73a24570f0ab59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Chibois?= Date: Wed, 31 May 2023 19:27:29 +0200 Subject: [PATCH 55/76] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a2efc0bc..59a7b36f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org). This document is formatted according to the principles of [Keep A CHANGELOG](http://keepachangelog.com). ## [Unreleased] +### Added +- C++ implementation [#117](https://github.com/cucumber/gherkin/pull/117) ## [26.2.0] - 2023-04-07 ### Changed From 35ad8be62ef2459ae3764b25b1a4841de9d591a7 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 10:36:04 +0200 Subject: [PATCH 56/76] chore: use main cucumber/messages repository, fix workflow name --- .github/workflows/test-cpp.yml | 2 +- cpp/deps.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index ba5784541..0dde82e6a 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -1,4 +1,4 @@ -name: test-c +name: test-cpp on: push: diff --git a/cpp/deps.txt b/cpp/deps.txt index 19078b659..b535c7d5a 100644 --- a/cpp/deps.txt +++ b/cpp/deps.txt @@ -1,2 +1,2 @@ https://github.com/nlohmann/json/archive/refs/tags/v3.11.2.zip -DJSON_BuildTests=OFF -https://github.com/chybz/cucumber-messages/archive/refs/heads/feature/cpp.zip --src-dir=cpp +https://github.com/cucumber/messages/archive/refs/heads/main.zip --src-dir=cpp From 57d5751ddc1482671a20a16f961ed24acf74c903 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 11:55:37 +0200 Subject: [PATCH 57/76] chore: increasing default step timeout --- .github/workflows/test-cpp.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index 0dde82e6a..0620f51a8 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -27,6 +27,7 @@ jobs: gcc --version - name: configure and build + timeout-minutes: 5 run: | make install-deps make acceptance From 2d44e526630be29135d0cc71dd4fdef7b4a67a16 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 13:18:23 +0200 Subject: [PATCH 58/76] chore: limiting parallelism --- .github/workflows/test-cpp.yml | 2 +- cpp/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index 0620f51a8..8979c9fef 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -27,8 +27,8 @@ jobs: gcc --version - name: configure and build - timeout-minutes: 5 run: | + export NPROCS=1 make install-deps make acceptance working-directory: cpp diff --git a/cpp/Makefile b/cpp/Makefile index c8bbd05e9..d0d6353c7 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -62,7 +62,7 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac .built: $(SRC_FILES) .configured cmake \ --build build/gherkin \ - --parallel \ + --parallel $(NPROCS) \ && touch $@ cmake --install build/gherkin From 2fab1315d49fa6271d3d76cba73924c60c1b745c Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 13:30:39 +0200 Subject: [PATCH 59/76] chore: setting NPROCS environment variable --- .github/workflows/test-cpp.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index 8979c9fef..94a6477b9 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -27,8 +27,9 @@ jobs: gcc --version - name: configure and build + env: + NPROCS: 1 run: | - export NPROCS=1 make install-deps make acceptance working-directory: cpp From 1284f81330491aac647f0c2f0905572e1b126c40 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 13:41:53 +0200 Subject: [PATCH 60/76] chore: debugging workflow --- .github/workflows/test-cpp.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index 94a6477b9..e0e672e94 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -30,6 +30,8 @@ jobs: env: NPROCS: 1 run: | + echo $PATH + ls -al ~/bin make install-deps make acceptance working-directory: cpp From 8a98ddbd93b75a457baff2e483c058b35b23d040 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 14:17:38 +0200 Subject: [PATCH 61/76] chore: debugging workflow --- cpp/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/Makefile b/cpp/Makefile index d0d6353c7..2bb20d1f4 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -84,10 +84,12 @@ reconfigure: clean-configure .configured rebuild: reconfigure .built include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp + ls -al include/gherkin *.razor $(berp-generate-parser) rm -f .configured include/gherkin/parser.hpp: gherkin-cpp.razor ../gherkin.berp + ls -al include/gherkin *.razor $(berp-generate-parser) rm -f .configured From 6992857078e0b6b944b25131aeb675779b48491c Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 14:18:33 +0200 Subject: [PATCH 62/76] chore: debugging workflow --- .github/workflows/test-cpp.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index e0e672e94..b28f8692b 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -31,7 +31,6 @@ jobs: NPROCS: 1 run: | echo $PATH - ls -al ~/bin make install-deps make acceptance working-directory: cpp From c2aed4247a86d2e9704c27eadf41698fcd00c63f Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 14:48:33 +0200 Subject: [PATCH 63/76] chore: debugging workflow --- .github/workflows/test-cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index b28f8692b..a6ebc7952 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -32,5 +32,5 @@ jobs: run: | echo $PATH make install-deps - make acceptance + make --trace acceptance working-directory: cpp From b310b9a66d4c63e0fe0e833e0356f2d20a92be0c Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 15:30:22 +0200 Subject: [PATCH 64/76] chore: generate files int their own directory --- cpp/Makefile | 21 +++++++++---------- cpp/include/gherkin/app.hpp | 2 +- cpp/include/gherkin/ast_builder.hpp | 2 +- cpp/include/gherkin/ast_node.hpp | 2 +- cpp/include/gherkin/builder.hpp | 2 +- .../gherkin/{ => generated}/parser.hpp | 2 +- .../gherkin/{ => generated}/rule_type.hpp | 0 cpp/include/gherkin/token.hpp | 2 +- .../gherkin/token_formatter_builder.hpp | 2 +- cpp/include/gherkin/token_matcher.hpp | 2 +- .../gherkin-generate-tokens.cpp | 2 +- .../lib/gherkin/{ => generated}/dialect.cpp | 0 cpp/src/lib/gherkin/rule_type.cpp | 2 +- 13 files changed, 20 insertions(+), 21 deletions(-) rename cpp/include/gherkin/{ => generated}/parser.hpp (99%) rename cpp/include/gherkin/{ => generated}/rule_type.hpp (100%) rename cpp/src/lib/gherkin/{ => generated}/dialect.cpp (100%) diff --git a/cpp/Makefile b/cpp/Makefile index 2bb20d1f4..0c4d071f0 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -2,9 +2,9 @@ SHELL := /usr/bin/env bash GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json GHERKIN_GENERATED = \ - include/gherkin/rule_type.hpp \ - include/gherkin/parser.hpp \ - src/lib/gherkin/dialect.cpp + include/gherkin/generated/rule_type.hpp \ + include/gherkin/generated/parser.hpp \ + src/lib/gherkin/generated/dialect.cpp GHERKIN = stage/bin/gherkin GHERKIN_GENERATE_TOKENS = stage/bin/gherkin-generate-tokens @@ -17,9 +17,7 @@ PICKLES = $(patsubst ../testdata/%,acceptance/testdata/%.pickles.ndjson,$(G SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GOOD_FEATURE_FILES)) ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES)) -SRC_FILES = \ - $(shell find include -name "*.[ch]*") \ - $(shell find src -name "*.[ch]*") +SRC_FILES = $(shell find src include -name "*.[ch]*" | grep -v "/generated/") HERE = $(shell pwd) CMAKE_BUILDROOT = $(HERE)/build/root @@ -31,6 +29,9 @@ define berp-generate-parser = berp -g ../gherkin.berp -t $< -o $@ --noBOM endef +toto: + @echo $(SRC_FILES) + help: ## Show this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) @@ -83,17 +84,15 @@ reconfigure: clean-configure .configured rebuild: reconfigure .built -include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp - ls -al include/gherkin *.razor +include/gherkin/generated/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) rm -f .configured -include/gherkin/parser.hpp: gherkin-cpp.razor ../gherkin.berp - ls -al include/gherkin *.razor +include/gherkin/generated/parser.hpp: gherkin-cpp.razor ../gherkin.berp $(berp-generate-parser) rm -f .configured -src/lib/gherkin/dialect.cpp: $(GHERKIN_LANGUAGES_JSON) gherkin-dialect.cpp.jq +src/lib/gherkin/generated/dialect.cpp: $(GHERKIN_LANGUAGES_JSON) gherkin-dialect.cpp.jq jq -f gherkin-dialect.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens diff --git a/cpp/include/gherkin/app.hpp b/cpp/include/gherkin/app.hpp index a9f254936..774b521e8 100644 --- a/cpp/include/gherkin/app.hpp +++ b/cpp/include/gherkin/app.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index a63dabeac..9af43bca1 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 89147ef1a..19dac9c81 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/gherkin/builder.hpp b/cpp/include/gherkin/builder.hpp index cba657c00..ae68c172b 100644 --- a/cpp/include/gherkin/builder.hpp +++ b/cpp/include/gherkin/builder.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include namespace gherkin { diff --git a/cpp/include/gherkin/parser.hpp b/cpp/include/gherkin/generated/parser.hpp similarity index 99% rename from cpp/include/gherkin/parser.hpp rename to cpp/include/gherkin/generated/parser.hpp index 127a96483..9586a1fbe 100644 --- a/cpp/include/gherkin/parser.hpp +++ b/cpp/include/gherkin/generated/parser.hpp @@ -1,6 +1,6 @@ // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. #include -#include +#include namespace gherkin { diff --git a/cpp/include/gherkin/rule_type.hpp b/cpp/include/gherkin/generated/rule_type.hpp similarity index 100% rename from cpp/include/gherkin/rule_type.hpp rename to cpp/include/gherkin/generated/rule_type.hpp diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index 99e156776..1a59673ad 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include namespace gherkin { diff --git a/cpp/include/gherkin/token_formatter_builder.hpp b/cpp/include/gherkin/token_formatter_builder.hpp index db1c50cf8..ad8558bcb 100644 --- a/cpp/include/gherkin/token_formatter_builder.hpp +++ b/cpp/include/gherkin/token_formatter_builder.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index 8421d91ec..fa7bcd270 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include namespace gherkin { diff --git a/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp b/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp index 3c265c953..bf1e0c485 100644 --- a/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp +++ b/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include #include diff --git a/cpp/src/lib/gherkin/dialect.cpp b/cpp/src/lib/gherkin/generated/dialect.cpp similarity index 100% rename from cpp/src/lib/gherkin/dialect.cpp rename to cpp/src/lib/gherkin/generated/dialect.cpp diff --git a/cpp/src/lib/gherkin/rule_type.cpp b/cpp/src/lib/gherkin/rule_type.cpp index 4b7233414..7337ead9b 100644 --- a/cpp/src/lib/gherkin/rule_type.cpp +++ b/cpp/src/lib/gherkin/rule_type.cpp @@ -1,6 +1,6 @@ #include -#include +#include namespace gherkin { From e65778a6bd4b98db67eaf747582ac1593eadfb0b Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 15:48:43 +0200 Subject: [PATCH 65/76] fix: don't delete parent files... --- cpp/Makefile | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cpp/Makefile b/cpp/Makefile index 0c4d071f0..34b0218eb 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -1,10 +1,6 @@ SHELL := /usr/bin/env bash GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json -GHERKIN_GENERATED = \ - include/gherkin/generated/rule_type.hpp \ - include/gherkin/generated/parser.hpp \ - src/lib/gherkin/generated/dialect.cpp GHERKIN = stage/bin/gherkin GHERKIN_GENERATE_TOKENS = stage/bin/gherkin-generate-tokens @@ -35,19 +31,19 @@ toto: help: ## Show this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -generate: $(GHERKIN_GENERATED) ## Generate gherkin parser files +generate: include/gherkin/generated/rule_type.hpp include/gherkin/generated/parser.hpp ## Generate gherkin parser files clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files - rm -f $(GHERKIN_GENERATED) + rm -f include/gherkin/generated/rule_type.hpp include/gherkin/generated/parser.hpp copy-gherkin-languages: $(GHERKIN_LANGUAGES_JSON) ## Copy gherkin-languages.json and/or generate derived files echo "Nothing to do" clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files - rm -f $(GHERKIN_LANGUAGES_JSON) + rm -f src/lib/gherkin/generated/dialect.cpp clean: ## Remove all build artifacts and files generated by the acceptance tests - rm -f build .built .configured + rm -rf build .built .configured rm -rf acceptance clean-deps: @@ -92,8 +88,8 @@ include/gherkin/generated/parser.hpp: gherkin-cpp.razor ../gherkin.berp $(berp-generate-parser) rm -f .configured -src/lib/gherkin/generated/dialect.cpp: $(GHERKIN_LANGUAGES_JSON) gherkin-dialect.cpp.jq - jq -f gherkin-dialect.cpp.jq -r -c <$(GHERKIN_LANGUAGES_JSON) >$@ +src/lib/gherkin/generated/dialect.cpp: ../gherkin-languages.json gherkin-dialect.cpp.jq + jq -f gherkin-dialect.cpp.jq -r -c $< >$@ acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens mkdir -p $(@D) From ce49fe941523ca59db7df9c80ded6bedd24cc353 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 15:58:38 +0200 Subject: [PATCH 66/76] fix: clean targets --- cpp/Makefile | 2 +- cpp/gherkin-cpp.razor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/Makefile b/cpp/Makefile index 34b0218eb..b28bef290 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -63,7 +63,7 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac && touch $@ cmake --install build/gherkin -.configured: $(CMAKELISTS) +.configured: $(CMAKELISTS) include/gherkin/generated/rule_type.hpp include/gherkin/generated/parser.hpp src/lib/gherkin/generated/dialect.cpp rm -rf build/gherkin && mkdir -p build/gherkin cmake \ -DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \ diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp.razor index b53fa4aad..059a0669b 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp.razor @@ -59,7 +59,7 @@ public static string NameOf(Rule rule) {match_@(ToSnakeCase(tokenType.Name))(context, token)} // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. #include -#include +#include namespace gherkin { From 3ba4c395d5d1ede6ca5cfeecc4769846f186c588 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 16:04:33 +0200 Subject: [PATCH 67/76] fix: don't delete dialect.cpp --- cpp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/Makefile b/cpp/Makefile index b28bef290..8fcbc4f3b 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -40,7 +40,7 @@ copy-gherkin-languages: $(GHERKIN_LANGUAGES_JSON) ## Copy gherkin-languages.json echo "Nothing to do" clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files - rm -f src/lib/gherkin/generated/dialect.cpp + echo "Nothing to do" clean: ## Remove all build artifacts and files generated by the acceptance tests rm -rf build .built .configured From c4f175f1f1bcf3b0426fcf0727eeb02865ec1191 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 16:32:29 +0200 Subject: [PATCH 68/76] chore: loosing my mind... --- cpp/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/Makefile b/cpp/Makefile index 8fcbc4f3b..48f253bee 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -81,6 +81,8 @@ reconfigure: clean-configure .configured rebuild: reconfigure .built include/gherkin/generated/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp + ls -al include/gherkin/generated/rule_type.hpp + ls -al ../gherkin.berp $(berp-generate-parser) rm -f .configured From f8d5b1611139756078c3a571a6c7ad246cfdf1d6 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Thu, 1 Jun 2023 18:03:47 +0200 Subject: [PATCH 69/76] chore: enough for today... --- .github/workflows/test-cpp.yml | 3 +- cpp/Makefile | 118 ++++++++---------- ...{gherkin-dialect.cpp.jq => dialect.cpp.jq} | 0 ...kin-cpp.razor => gherkin-cpp-parser.razor} | 2 +- cpp/include/gherkin/app.hpp | 2 +- cpp/include/gherkin/ast_builder.hpp | 2 +- cpp/include/gherkin/ast_node.hpp | 2 +- cpp/include/gherkin/builder.hpp | 2 +- .../gherkin/{generated => }/parser.hpp | 2 +- .../gherkin/{generated => }/rule_type.hpp | 0 cpp/include/gherkin/token.hpp | 2 +- .../gherkin/token_formatter_builder.hpp | 2 +- cpp/include/gherkin/token_matcher.hpp | 2 +- .../gherkin-generate-tokens.cpp | 2 +- .../lib/gherkin/{generated => }/dialect.cpp | 0 cpp/src/lib/gherkin/rule_type.cpp | 2 +- 16 files changed, 66 insertions(+), 77 deletions(-) rename cpp/{gherkin-dialect.cpp.jq => dialect.cpp.jq} (100%) rename cpp/{gherkin-cpp.razor => gherkin-cpp-parser.razor} (99%) rename cpp/include/gherkin/{generated => }/parser.hpp (99%) rename cpp/include/gherkin/{generated => }/rule_type.hpp (100%) rename cpp/src/lib/gherkin/{generated => }/dialect.cpp (100%) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index a6ebc7952..47d72d651 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -30,7 +30,6 @@ jobs: env: NPROCS: 1 run: | - echo $PATH make install-deps - make --trace acceptance + make -d acceptance working-directory: cpp diff --git a/cpp/Makefile b/cpp/Makefile index 48f253bee..2bcb109bc 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -1,9 +1,5 @@ SHELL := /usr/bin/env bash -GHERKIN_LANGUAGES_JSON = ../gherkin-languages.json -GHERKIN = stage/bin/gherkin -GHERKIN_GENERATE_TOKENS = stage/bin/gherkin-generate-tokens - GOOD_FEATURE_FILES = $(shell find ../testdata/good -name "*.feature") BAD_FEATURE_FILES = $(shell find ../testdata/bad -name "*.feature") @@ -13,107 +9,101 @@ PICKLES = $(patsubst ../testdata/%,acceptance/testdata/%.pickles.ndjson,$(G SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GOOD_FEATURE_FILES)) ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES)) -SRC_FILES = $(shell find src include -name "*.[ch]*" | grep -v "/generated/") +SRC_FILES = $(shell find src -name "*.[ch]*") + +GHERKIN=stage/bin/gherkin +RUN_GHERKIN=$(GHERKIN) +GHERKIN_GENERATE_TOKENS=stage/bin/gherkin-generate-tokens +RUN_GHERKIN_GENERATE_TOKENS=$(GHERKIN_GENERATE_TOKENS) HERE = $(shell pwd) CMAKE_BUILDROOT = $(HERE)/build/root CMAKELISTS = $(shell find src -name CMakeLists.txt) -.DEFAULT_GOAL = help +.DELETE_ON_ERROR: -define berp-generate-parser = -berp -g ../gherkin.berp -t $< -o $@ --noBOM -endef +default: .compared +.PHONY: default -toto: - @echo $(SRC_FILES) +acceptance: .compared ## Build acceptance test dir and compare results with reference -help: ## Show this help - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +.compared: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) .run + touch $@ -generate: include/gherkin/generated/rule_type.hpp include/gherkin/generated/parser.hpp ## Generate gherkin parser files +generate: ./include/gherkin/rule_type.hpp ./include/gherkin/parser.hpp ## Generate gherkin parser files clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files - rm -f include/gherkin/generated/rule_type.hpp include/gherkin/generated/parser.hpp + rm -f ./include/gherkin/rule_type.hpp ./include/gherkin/parser.hpp +.PHONY: clean-generate -copy-gherkin-languages: $(GHERKIN_LANGUAGES_JSON) ## Copy gherkin-languages.json and/or generate derived files +copy-gherkin-languages: src/lib/gherkin/dialect.cpp ## Copy gherkin-languages.json and/or generate derived files echo "Nothing to do" clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files - echo "Nothing to do" - -clean: ## Remove all build artifacts and files generated by the acceptance tests - rm -rf build .built .configured - rm -rf acceptance - -clean-deps: - rm -rf ext build/src build/root - -install-deps: - ./scripts/build-externals deps.txt - -.DELETE_ON_ERROR: - -acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference + rm -f src/lib/gherkin/dialect.cpp -.built: $(SRC_FILES) .configured - cmake \ - --build build/gherkin \ - --parallel $(NPROCS) \ - && touch $@ +.built: generate $(SRC_FILES) .configured + cmake --build build/gherkin --parallel $(NPROCS) cmake --install build/gherkin + touch $@ -.configured: $(CMAKELISTS) include/gherkin/generated/rule_type.hpp include/gherkin/generated/parser.hpp src/lib/gherkin/generated/dialect.cpp +.configured: rm -rf build/gherkin && mkdir -p build/gherkin cmake \ -DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \ -DCMAKE_INSTALL_PREFIX=$(HERE)/stage \ -S . \ -B build/gherkin \ - --toolchain cmake/toolchains/ext.cmake \ - && touch $@ + --toolchain cmake/toolchains/ext.cmake + touch $@ -clean-configure: - rm -f .configured +clean: + rm -rf .compared .configured .built .run acceptance build ext +.PHONY: clean -reconfigure: clean-configure .configured +.run: $(GHERKIN) $(GOOD_FEATURE_FILES) + $(RUN_GHERKIN) $(GOOD_FEATURE_FILES) | jq . > /dev/null + touch $@ -rebuild: reconfigure .built +define berp-generate-parser = +berp -g ../gherkin.berp -t $< -o $@ --noBOM +endef -include/gherkin/generated/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp - ls -al include/gherkin/generated/rule_type.hpp - ls -al ../gherkin.berp +./include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor gherkin.berp $(berp-generate-parser) - rm -f .configured -include/gherkin/generated/parser.hpp: gherkin-cpp.razor ../gherkin.berp +./include/gherkin/parser.hpp: gherkin-cpp-parser.razor gherkin.berp $(berp-generate-parser) - rm -f .configured -src/lib/gherkin/generated/dialect.cpp: ../gherkin-languages.json gherkin-dialect.cpp.jq - jq -f gherkin-dialect.cpp.jq -r -c $< >$@ +src/lib/gherkin/dialect.cpp: ../gherkin-languages.json dialect.cpp.jq + cat $< | jq -f dialect.cpp.jq -r -c > $@ -acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens +acceptance/testdata/%.feature.tokens: ../testdata/%.feature ../testdata/%.feature.tokens $(GHERKIN_GENERATE_TOKENS) mkdir -p $(@D) - $(GHERKIN_GENERATE_TOKENS) $< > $@ - diff --unified $<.tokens $@ + echo $(RUN_GHERKIN_GENERATE_TOKENS) + $(RUN_GHERKIN_GENERATE_TOKENS) $< > $@ + diff --strip-trailing-cr --unified $<.tokens $@ -acceptance/testdata/%.ast.ndjson: ../testdata/% ../testdata/%.ast.ndjson +acceptance/testdata/%.feature.ast.ndjson: ../testdata/%.feature ../testdata/%.feature.ast.ndjson $(GHERKIN) mkdir -p $(@D) - $(GHERKIN) --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $@ + $(RUN_GHERKIN) --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $@ diff --unified <(jq "." $<.ast.ndjson) <(jq "." $@) -acceptance/testdata/%.pickles.ndjson: ../testdata/% ../testdata/%.pickles.ndjson +acceptance/testdata/%.feature.errors.ndjson: ../testdata/%.feature ../testdata/%.feature.errors.ndjson $(GHERKIN) mkdir -p $(@D) - $(GHERKIN) --no-source --no-ast $< | jq --sort-keys --compact-output "." > $@ + $(RUN_GHERKIN) --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $@ + diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@) + +acceptance/testdata/%.feature.pickles.ndjson: ../testdata/%.feature ../testdata/%.feature.pickles.ndjson $(GHERKIN) + mkdir -p $(@D) + $(RUN_GHERKIN) --no-source --no-ast $< | jq --sort-keys --compact-output "." > $@ diff --unified <(jq "." $<.pickles.ndjson) <(jq "." $@) -acceptance/testdata/%.source.ndjson: ../testdata/% ../testdata/%.source.ndjson +acceptance/testdata/%.feature.source.ndjson: ../testdata/%.feature ../testdata/%.feature.source.ndjson .built mkdir -p $(@D) - $(GHERKIN) --no-ast --no-pickles $< | jq --sort-keys --compact-output "." > $@ + $(RUN_GHERKIN) --no-ast --no-pickles $< | jq --sort-keys --compact-output "." > $@ diff --unified <(jq "." $<.source.ndjson) <(jq "." $@) -acceptance/testdata/%.errors.ndjson: ../testdata/% ../testdata/%.errors.ndjson - mkdir -p $(@D) - $(GHERKIN) --no-source $< | jq --sort-keys --compact-output "." > $@ - diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@) +install-deps: + ./scripts/build-externals deps.txt +.PHONY: install-deps diff --git a/cpp/gherkin-dialect.cpp.jq b/cpp/dialect.cpp.jq similarity index 100% rename from cpp/gherkin-dialect.cpp.jq rename to cpp/dialect.cpp.jq diff --git a/cpp/gherkin-cpp.razor b/cpp/gherkin-cpp-parser.razor similarity index 99% rename from cpp/gherkin-cpp.razor rename to cpp/gherkin-cpp-parser.razor index 059a0669b..b53fa4aad 100644 --- a/cpp/gherkin-cpp.razor +++ b/cpp/gherkin-cpp-parser.razor @@ -59,7 +59,7 @@ public static string NameOf(Rule rule) {match_@(ToSnakeCase(tokenType.Name))(context, token)} // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. #include -#include +#include namespace gherkin { diff --git a/cpp/include/gherkin/app.hpp b/cpp/include/gherkin/app.hpp index 774b521e8..a9f254936 100644 --- a/cpp/include/gherkin/app.hpp +++ b/cpp/include/gherkin/app.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/gherkin/ast_builder.hpp b/cpp/include/gherkin/ast_builder.hpp index 9af43bca1..a63dabeac 100644 --- a/cpp/include/gherkin/ast_builder.hpp +++ b/cpp/include/gherkin/ast_builder.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 19dac9c81..89147ef1a 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/gherkin/builder.hpp b/cpp/include/gherkin/builder.hpp index ae68c172b..cba657c00 100644 --- a/cpp/include/gherkin/builder.hpp +++ b/cpp/include/gherkin/builder.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include namespace gherkin { diff --git a/cpp/include/gherkin/generated/parser.hpp b/cpp/include/gherkin/parser.hpp similarity index 99% rename from cpp/include/gherkin/generated/parser.hpp rename to cpp/include/gherkin/parser.hpp index 9586a1fbe..127a96483 100644 --- a/cpp/include/gherkin/generated/parser.hpp +++ b/cpp/include/gherkin/parser.hpp @@ -1,6 +1,6 @@ // This file is generated. Do not edit! Edit gherkin-cpp-parser.razor instead. #include -#include +#include namespace gherkin { diff --git a/cpp/include/gherkin/generated/rule_type.hpp b/cpp/include/gherkin/rule_type.hpp similarity index 100% rename from cpp/include/gherkin/generated/rule_type.hpp rename to cpp/include/gherkin/rule_type.hpp diff --git a/cpp/include/gherkin/token.hpp b/cpp/include/gherkin/token.hpp index 1a59673ad..99e156776 100644 --- a/cpp/include/gherkin/token.hpp +++ b/cpp/include/gherkin/token.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include namespace gherkin { diff --git a/cpp/include/gherkin/token_formatter_builder.hpp b/cpp/include/gherkin/token_formatter_builder.hpp index ad8558bcb..db1c50cf8 100644 --- a/cpp/include/gherkin/token_formatter_builder.hpp +++ b/cpp/include/gherkin/token_formatter_builder.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/gherkin/token_matcher.hpp b/cpp/include/gherkin/token_matcher.hpp index fa7bcd270..8421d91ec 100644 --- a/cpp/include/gherkin/token_matcher.hpp +++ b/cpp/include/gherkin/token_matcher.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include namespace gherkin { diff --git a/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp b/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp index bf1e0c485..3c265c953 100644 --- a/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp +++ b/cpp/src/bin/gherkin-generate-tokens/gherkin-generate-tokens.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include #include diff --git a/cpp/src/lib/gherkin/generated/dialect.cpp b/cpp/src/lib/gherkin/dialect.cpp similarity index 100% rename from cpp/src/lib/gherkin/generated/dialect.cpp rename to cpp/src/lib/gherkin/dialect.cpp diff --git a/cpp/src/lib/gherkin/rule_type.cpp b/cpp/src/lib/gherkin/rule_type.cpp index 7337ead9b..4b7233414 100644 --- a/cpp/src/lib/gherkin/rule_type.cpp +++ b/cpp/src/lib/gherkin/rule_type.cpp @@ -1,6 +1,6 @@ #include -#include +#include namespace gherkin { From bda6c358eee73740249c86c768cdaeeb711757a6 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 2 Jun 2023 10:35:16 +0200 Subject: [PATCH 70/76] chore: hopefully fixed makefile and generation --- .github/workflows/test-cpp.yml | 2 +- cpp/.gitignore | 1 + cpp/Makefile | 116 +++++++++++++++++--------------- cpp/scripts/build-externals | 2 +- cpp/src/bin/gherkin/gherkin.cpp | 3 + 5 files changed, 69 insertions(+), 55 deletions(-) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index 47d72d651..94a6477b9 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -31,5 +31,5 @@ jobs: NPROCS: 1 run: | make install-deps - make -d acceptance + make acceptance working-directory: cpp diff --git a/cpp/.gitignore b/cpp/.gitignore index d1e3352ae..5abb1e17c 100644 --- a/cpp/.gitignore +++ b/cpp/.gitignore @@ -4,3 +4,4 @@ acceptance/ stage/ .built .configured +.deps-installed diff --git a/cpp/Makefile b/cpp/Makefile index 2bcb109bc..3d702c7d0 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -1,5 +1,21 @@ SHELL := /usr/bin/env bash +GRAMMAR_GENERATED = \ + include/gherkin/rule_type.hpp \ + include/gherkin/parser.hpp +LANGUAGE_GENERATED = \ + src/lib/gherkin/dialect.cpp +ALL_GENERATED := $(GRAMMAR_GENERATED) $(LANGUAGE_GENERATED) +ALL_SOURCE_FILES = $(shell find . -name "*.[ch]*") +SOURCE_FILES := $(filter-out $(ALL_GENERATED),$(ALL_SOURCE_FILES)) + +HERE = $(shell pwd) +CMAKE_BUILDROOT = $(HERE)/build/root +CMAKELISTS = $(shell find src -name CMakeLists.txt) + +GHERKIN = stage/bin/gherkin +GHERKIN_GENERATE_TOKENS = stage/bin/gherkin-generate-tokens + GOOD_FEATURE_FILES = $(shell find ../testdata/good -name "*.feature") BAD_FEATURE_FILES = $(shell find ../testdata/bad -name "*.feature") @@ -9,45 +25,37 @@ PICKLES = $(patsubst ../testdata/%,acceptance/testdata/%.pickles.ndjson,$(G SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GOOD_FEATURE_FILES)) ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES)) -SRC_FILES = $(shell find src -name "*.[ch]*") - -GHERKIN=stage/bin/gherkin -RUN_GHERKIN=$(GHERKIN) -GHERKIN_GENERATE_TOKENS=stage/bin/gherkin-generate-tokens -RUN_GHERKIN_GENERATE_TOKENS=$(GHERKIN_GENERATE_TOKENS) - -HERE = $(shell pwd) -CMAKE_BUILDROOT = $(HERE)/build/root -CMAKELISTS = $(shell find src -name CMakeLists.txt) - -.DELETE_ON_ERROR: +.DEFAULT_GOAL = help -default: .compared -.PHONY: default +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -acceptance: .compared ## Build acceptance test dir and compare results with reference - -.compared: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) .run - touch $@ - -generate: ./include/gherkin/rule_type.hpp ./include/gherkin/parser.hpp ## Generate gherkin parser files +generate: $(GRAMMAR_GENERATED) ## Generate gherkin parser files clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files - rm -f ./include/gherkin/rule_type.hpp ./include/gherkin/parser.hpp -.PHONY: clean-generate + rm -f $(GRAMMAR_GENERATED) -copy-gherkin-languages: src/lib/gherkin/dialect.cpp ## Copy gherkin-languages.json and/or generate derived files +copy-gherkin-languages: echo "Nothing to do" clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files - rm -f src/lib/gherkin/dialect.cpp + echo "Nothing to do" + +clean: clean-deps ## Remove all build artifacts and files generated by the acceptance tests + rm -rf .built .configured + rm -rf acceptance + rm -rf build -.built: generate $(SRC_FILES) .configured +.DELETE_ON_ERROR: + +acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference + +.built: .configured $(SOURCE_FILES) cmake --build build/gherkin --parallel $(NPROCS) cmake --install build/gherkin touch $@ -.configured: +.configured: .deps-installed rm -rf build/gherkin && mkdir -p build/gherkin cmake \ -DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \ @@ -57,53 +65,55 @@ clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files --toolchain cmake/toolchains/ext.cmake touch $@ -clean: - rm -rf .compared .configured .built .run acceptance build ext -.PHONY: clean - -.run: $(GHERKIN) $(GOOD_FEATURE_FILES) - $(RUN_GHERKIN) $(GOOD_FEATURE_FILES) | jq . > /dev/null - touch $@ - define berp-generate-parser = berp -g ../gherkin.berp -t $< -o $@ --noBOM +touch $@ endef -./include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor gherkin.berp +include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) -./include/gherkin/parser.hpp: gherkin-cpp-parser.razor gherkin.berp +include/gherkin/parser.hpp: gherkin-cpp-parser.razor ../gherkin.berp $(berp-generate-parser) src/lib/gherkin/dialect.cpp: ../gherkin-languages.json dialect.cpp.jq cat $< | jq -f dialect.cpp.jq -r -c > $@ -acceptance/testdata/%.feature.tokens: ../testdata/%.feature ../testdata/%.feature.tokens $(GHERKIN_GENERATE_TOKENS) +acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens mkdir -p $(@D) - echo $(RUN_GHERKIN_GENERATE_TOKENS) - $(RUN_GHERKIN_GENERATE_TOKENS) $< > $@ - diff --strip-trailing-cr --unified $<.tokens $@ + $(GHERKIN_GENERATE_TOKENS) $< > $@ + diff --unified $<.tokens $@ -acceptance/testdata/%.feature.ast.ndjson: ../testdata/%.feature ../testdata/%.feature.ast.ndjson $(GHERKIN) +acceptance/testdata/%.ast.ndjson: ../testdata/% ../testdata/%.ast.ndjson mkdir -p $(@D) - $(RUN_GHERKIN) --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $@ + $(GHERKIN) --no-source --no-pickles --predictable-ids $< | jq --sort-keys --compact-output "." > $@ diff --unified <(jq "." $<.ast.ndjson) <(jq "." $@) -acceptance/testdata/%.feature.errors.ndjson: ../testdata/%.feature ../testdata/%.feature.errors.ndjson $(GHERKIN) - mkdir -p $(@D) - $(RUN_GHERKIN) --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $@ - diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@) - -acceptance/testdata/%.feature.pickles.ndjson: ../testdata/%.feature ../testdata/%.feature.pickles.ndjson $(GHERKIN) +acceptance/testdata/%.pickles.ndjson: ../testdata/% ../testdata/%.pickles.ndjson mkdir -p $(@D) - $(RUN_GHERKIN) --no-source --no-ast $< | jq --sort-keys --compact-output "." > $@ + $(GHERKIN) --no-source --no-ast --predictable-ids $< | jq --sort-keys --compact-output "." > $@ diff --unified <(jq "." $<.pickles.ndjson) <(jq "." $@) -acceptance/testdata/%.feature.source.ndjson: ../testdata/%.feature ../testdata/%.feature.source.ndjson .built +acceptance/testdata/%.source.ndjson: ../testdata/% ../testdata/%.source.ndjson mkdir -p $(@D) - $(RUN_GHERKIN) --no-ast --no-pickles $< | jq --sort-keys --compact-output "." > $@ + $(GHERKIN) --no-ast --no-pickles --predictable-ids $< | jq --sort-keys --compact-output "." > $@ diff --unified <(jq "." $<.source.ndjson) <(jq "." $@) -install-deps: - ./scripts/build-externals deps.txt +acceptance/testdata/%.errors.ndjson: ../testdata/% ../testdata/%.errors.ndjson + mkdir -p $(@D) + $(GHERKIN) --no-source --predictable-ids $< | jq --sort-keys --compact-output "." > $@ + diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@) + +# +# External dependencies +# +install-deps: .deps-installed .PHONY: install-deps + +.deps-installed: + ./scripts/build-externals deps.txt + touch $@ + +clean-deps: + rm -rf .deps-installed build/root build/ext +.PHONY: clean-deps diff --git a/cpp/scripts/build-externals b/cpp/scripts/build-externals index 42ef6a786..daea781b2 100755 --- a/cpp/scripts/build-externals +++ b/cpp/scripts/build-externals @@ -14,7 +14,7 @@ MYPID=$$ BUILDER=$MYDIR/scripts/build-ext -EXTDIR=$MYDIR/ext +EXTDIR=$MYDIR/build/ext DLFILE=$EXTDIR/.downloaded INSTFILE=$EXTDIR/.installed TMPDIR=$EXTDIR/tmp diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 619210c80..9b44f5929 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -11,6 +11,7 @@ struct options bool include_source = true; bool include_ast = true; bool include_pickles = true; + bool predicatable_ids = true; }; options @@ -27,6 +28,8 @@ parse_options(int ac, char** av) opts.include_ast = false; } else if (arg == "--no-pickles") { opts.include_pickles = false; + } else if (arg == "--predictable-ids") { + opts.predicatable_ids = true; } else if (arg.starts_with('-')) { if (arg != "-h" && arg != "--help") { std::cout << "Unknown option: " << arg << std::endl; From ca7899543cf205690cc26d5e86847871f8818ede Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 2 Jun 2023 10:47:29 +0200 Subject: [PATCH 71/76] chore: getting rid of spurious generation. Attempt 1 --- .github/workflows/test-cpp.yml | 3 +-- cpp/Makefile | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index 94a6477b9..661dd3a8e 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -30,6 +30,5 @@ jobs: env: NPROCS: 1 run: | - make install-deps - make acceptance + make -d --no-builtin-rules acceptance working-directory: cpp diff --git a/cpp/Makefile b/cpp/Makefile index 3d702c7d0..f62acc1da 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -66,6 +66,8 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac touch $@ define berp-generate-parser = +ls -al $< || true +ls -al $@ || true berp -g ../gherkin.berp -t $< -o $@ --noBOM touch $@ endef From 6aebf1d8927542a54965bb457d87ec9c77846415 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 2 Jun 2023 11:00:11 +0200 Subject: [PATCH 72/76] chore: getting rid of spurious generation. Attempt 2 --- .github/workflows/test-cpp.yml | 2 +- cpp/Makefile | 7 +++++-- cpp/scripts/build-ext | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-cpp.yml b/.github/workflows/test-cpp.yml index 661dd3a8e..82ba366ec 100644 --- a/.github/workflows/test-cpp.yml +++ b/.github/workflows/test-cpp.yml @@ -30,5 +30,5 @@ jobs: env: NPROCS: 1 run: | - make -d --no-builtin-rules acceptance + make acceptance working-directory: cpp diff --git a/cpp/Makefile b/cpp/Makefile index f62acc1da..87721b01a 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -9,6 +9,8 @@ ALL_GENERATED := $(GRAMMAR_GENERATED) $(LANGUAGE_GENERATED) ALL_SOURCE_FILES = $(shell find . -name "*.[ch]*") SOURCE_FILES := $(filter-out $(ALL_GENERATED),$(ALL_SOURCE_FILES)) +BERP := $(or $(shell which berp),"echo berp") + HERE = $(shell pwd) CMAKE_BUILDROOT = $(HERE)/build/root CMAKELISTS = $(shell find src -name CMakeLists.txt) @@ -58,6 +60,7 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac .configured: .deps-installed rm -rf build/gherkin && mkdir -p build/gherkin cmake \ + -G Ninja \ -DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \ -DCMAKE_INSTALL_PREFIX=$(HERE)/stage \ -S . \ @@ -66,9 +69,9 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac touch $@ define berp-generate-parser = -ls -al $< || true +ls -al include/gherkin/*.hpp || true ls -al $@ || true -berp -g ../gherkin.berp -t $< -o $@ --noBOM +$(BERP) -g ../gherkin.berp -t $< -o $@ --noBOM touch $@ endef diff --git a/cpp/scripts/build-ext b/cpp/scripts/build-ext index b3595953e..a8c64fa11 100755 --- a/cpp/scripts/build-ext +++ b/cpp/scripts/build-ext @@ -81,6 +81,7 @@ rm -rf $BUILDDIR && mkdir -p $BUILDDIR if [ -f $SRCDIR/CMakeLists.txt ]; then cmake \ + -G Ninja \ -DCMAKE_PREFIX_PATH=$BUILDROOT \ -DCMAKE_INSTALL_PREFIX=$BUILDROOT \ -DCMAKE_TOOLCHAIN_FILE=$MYDIR/cmake/toolchains/ext.cmake \ From dcd1cf09ff34559f5c8aeedb114dcd568bd21976 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 2 Jun 2023 11:05:43 +0200 Subject: [PATCH 73/76] chore: getting rid of spurious generation. Attempt 3 --- cpp/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/Makefile b/cpp/Makefile index 87721b01a..6f586c0a5 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -9,7 +9,7 @@ ALL_GENERATED := $(GRAMMAR_GENERATED) $(LANGUAGE_GENERATED) ALL_SOURCE_FILES = $(shell find . -name "*.[ch]*") SOURCE_FILES := $(filter-out $(ALL_GENERATED),$(ALL_SOURCE_FILES)) -BERP := $(or $(shell which berp),"echo berp") +BERP := $(or $(shell which berp),echo berp) HERE = $(shell pwd) CMAKE_BUILDROOT = $(HERE)/build/root @@ -70,7 +70,7 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac define berp-generate-parser = ls -al include/gherkin/*.hpp || true -ls -al $@ || true +ls -al $< || true $(BERP) -g ../gherkin.berp -t $< -o $@ --noBOM touch $@ endef From 5683fe56d79b58033547e52c145fa22c45402c21 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 2 Jun 2023 11:20:13 +0200 Subject: [PATCH 74/76] chore: getting rid of spurious generation. Attempt 4 --- cpp/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpp/Makefile b/cpp/Makefile index 6f586c0a5..fe533c837 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -76,13 +76,19 @@ touch $@ endef include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp + echo $? + ls -a --full-time include/gherkin/rule_type.hpp gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) include/gherkin/parser.hpp: gherkin-cpp-parser.razor ../gherkin.berp + echo $? + ls -a --full-time include/gherkin/parser.hpp gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) src/lib/gherkin/dialect.cpp: ../gherkin-languages.json dialect.cpp.jq - cat $< | jq -f dialect.cpp.jq -r -c > $@ + echo $? + ls -a --full-time src/lib/gherkin/dialect.cpp ../gherkin-languages.json dialect.cpp.jq + jq -f dialect.cpp.jq -r -c < $< > $@ acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens mkdir -p $(@D) From a7750f82223b1448fbe46078ca8cc293a170abcd Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 2 Jun 2023 12:44:25 +0200 Subject: [PATCH 75/76] fix: correct generated source file filtering --- cpp/Makefile | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/cpp/Makefile b/cpp/Makefile index fe533c837..2d334f4e6 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -6,11 +6,9 @@ GRAMMAR_GENERATED = \ LANGUAGE_GENERATED = \ src/lib/gherkin/dialect.cpp ALL_GENERATED := $(GRAMMAR_GENERATED) $(LANGUAGE_GENERATED) -ALL_SOURCE_FILES = $(shell find . -name "*.[ch]*") +ALL_SOURCE_FILES = $(shell find include src -name "*.[ch]*") SOURCE_FILES := $(filter-out $(ALL_GENERATED),$(ALL_SOURCE_FILES)) -BERP := $(or $(shell which berp),echo berp) - HERE = $(shell pwd) CMAKE_BUILDROOT = $(HERE)/build/root CMAKELISTS = $(shell find src -name CMakeLists.txt) @@ -69,25 +67,16 @@ acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build ac touch $@ define berp-generate-parser = -ls -al include/gherkin/*.hpp || true -ls -al $< || true -$(BERP) -g ../gherkin.berp -t $< -o $@ --noBOM -touch $@ +berp -g ../gherkin.berp -t $< -o $@ --noBOM endef include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp - echo $? - ls -a --full-time include/gherkin/rule_type.hpp gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) include/gherkin/parser.hpp: gherkin-cpp-parser.razor ../gherkin.berp - echo $? - ls -a --full-time include/gherkin/parser.hpp gherkin-cpp-rule-type.razor ../gherkin.berp $(berp-generate-parser) src/lib/gherkin/dialect.cpp: ../gherkin-languages.json dialect.cpp.jq - echo $? - ls -a --full-time src/lib/gherkin/dialect.cpp ../gherkin-languages.json dialect.cpp.jq jq -f dialect.cpp.jq -r -c < $< > $@ acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens From 9c6bfee371397551d2ecd0f5f16eb785a17a2882 Mon Sep 17 00:00:00 2001 From: Remy Chibois Date: Fri, 2 Jun 2023 15:59:43 +0200 Subject: [PATCH 76/76] chore: lowered to C++17 standard, added basic README --- cpp/CMakeLists.txt | 2 +- cpp/Makefile | 2 ++ cpp/README.md | 13 +++++++++++++ cpp/include/gherkin/ast_node.hpp | 7 +++---- cpp/include/gherkin/join_utils.hpp | 2 +- cpp/include/gherkin/regex.hpp | 4 ++-- cpp/src/bin/gherkin/gherkin.cpp | 5 +++-- cpp/src/lib/gherkin/ast_builder.cpp | 10 ++-------- cpp/src/lib/gherkin/line.cpp | 4 ++-- cpp/src/lib/gherkin/pickle_compiler.cpp | 6 +++--- 10 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 cpp/README.md diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ef94374c4..85bc7d396 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -4,7 +4,7 @@ project(gherkin-cpp VERSION 1.0.0 LANGUAGES C CXX) include(GNUInstallDirs) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/cpp/Makefile b/cpp/Makefile index 2d334f4e6..8bbb0c5ef 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -32,6 +32,8 @@ help: ## Show this help generate: $(GRAMMAR_GENERATED) ## Generate gherkin parser files +generate-all: $(ALL_GENERATED) + clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files rm -f $(GRAMMAR_GENERATED) diff --git a/cpp/README.md b/cpp/README.md new file mode 100644 index 000000000..8a8f521f9 --- /dev/null +++ b/cpp/README.md @@ -0,0 +1,13 @@ +# Gherkin for C++ + +Gherkin parser/compiler for C++. Please see [Gherkin](https://github.com/cucumber/gherkin) for details. + +## Developers + +Some files are generated from the `gherkin-*.razor` file. Please run the +following command to generate the C++ files. + +~~~bash +cd /cpp +make generate-all +~~~ diff --git a/cpp/include/gherkin/ast_node.hpp b/cpp/include/gherkin/ast_node.hpp index 89147ef1a..eb282c30a 100644 --- a/cpp/include/gherkin/ast_node.hpp +++ b/cpp/include/gherkin/ast_node.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include @@ -18,7 +17,7 @@ namespace gherkin { template struct sub_node { - using type = std::remove_cvref_t; + using type = std::decay_t; using vector_type = std::vector; using ptr_type = std::shared_ptr; @@ -119,7 +118,7 @@ class ast_node template void set_value(rule_type rule_type, V& v) const { - using type = std::remove_cvref_t; + using type = std::decay_t; if constexpr (is_container_v) { using value_type = typename type::value_type; @@ -146,7 +145,7 @@ class ast_node template void set(rule_type rule_type, T& v) const { - using type = std::remove_cvref_t; + using type = std::decay_t; if constexpr (is_container_v) { using value_type = typename type::value_type; diff --git a/cpp/include/gherkin/join_utils.hpp b/cpp/include/gherkin/join_utils.hpp index ca6148ae4..fdc4cca96 100644 --- a/cpp/include/gherkin/join_utils.hpp +++ b/cpp/include/gherkin/join_utils.hpp @@ -43,7 +43,7 @@ struct is_joinable_container std::false_type >; - static constexpr type::value_type value = type::value; + static constexpr typename type::value_type value = type::value; }; template diff --git a/cpp/include/gherkin/regex.hpp b/cpp/include/gherkin/regex.hpp index d7dbea6c2..e17c9dd4c 100644 --- a/cpp/include/gherkin/regex.hpp +++ b/cpp/include/gherkin/regex.hpp @@ -40,7 +40,7 @@ template auto extract_submatch(const SubMatch& sm, Arg&& a) { - using arg_type = std::remove_cvref_t; + using arg_type = std::decay_t; using sv_type = std::basic_string_view; constexpr bool is_string = @@ -55,7 +55,7 @@ extract_submatch(const SubMatch& sm, Arg&& a) std::is_floating_point_v ; - sv_type sv{sm.first, sm.second}; + sv_type sv{sm.first, static_cast(sm.length())}; if constexpr (is_string) { a.assign(sv); diff --git a/cpp/src/bin/gherkin/gherkin.cpp b/cpp/src/bin/gherkin/gherkin.cpp index 9b44f5929..57d95d410 100644 --- a/cpp/src/bin/gherkin/gherkin.cpp +++ b/cpp/src/bin/gherkin/gherkin.cpp @@ -30,7 +30,7 @@ parse_options(int ac, char** av) opts.include_pickles = false; } else if (arg == "--predictable-ids") { opts.predicatable_ids = true; - } else if (arg.starts_with('-')) { + } else if (arg.find('-') == 0) { if (arg != "-h" && arg != "--help") { std::cout << "Unknown option: " << arg << std::endl; opts.exit_code = 1; @@ -54,7 +54,8 @@ parse_options(int ac, char** av) return opts; } -void print_json_obj(std::string_view key, const auto& o) +template +void print_json_obj(std::string_view key, const Obj& o) { nlohmann::json j; diff --git a/cpp/src/lib/gherkin/ast_builder.cpp b/cpp/src/lib/gherkin/ast_builder.cpp index f255b4ece..84d473af3 100644 --- a/cpp/src/lib/gherkin/ast_builder.cpp +++ b/cpp/src/lib/gherkin/ast_builder.cpp @@ -128,14 +128,8 @@ ast_builder::make_doc_string(ast_node& node) string_views svs; - auto toks = - node.get_tokens(rule_type::other) - | std::views::transform([](const auto& t) { - return std::string_view(t.matched_text); - }); - - for (const auto& t : toks) { - svs.emplace_back(t); + for (const auto& t : node.get_tokens(rule_type::other)) { + svs.emplace_back(t.matched_text); } auto content = join("\n", svs); diff --git a/cpp/src/lib/gherkin/line.cpp b/cpp/src/lib/gherkin/line.cpp index d87f70e47..c3657373d 100644 --- a/cpp/src/lib/gherkin/line.cpp +++ b/cpp/src/lib/gherkin/line.cpp @@ -118,11 +118,11 @@ line::is_empty() const bool line::startswith(std::string_view prefix) const -{ return trimmed_line_text_.starts_with(prefix); } +{ return trimmed_line_text_.find(prefix) == 0; } bool line::startswith_title_keyword(const std::string& keyword) const -{ return trimmed_line_text_.starts_with(keyword + ":"); } +{ return trimmed_line_text_.find(keyword + ":") == 0; } items line::table_cells() const diff --git a/cpp/src/lib/gherkin/pickle_compiler.cpp b/cpp/src/lib/gherkin/pickle_compiler.cpp index eb1d122b0..29e1a3a70 100644 --- a/cpp/src/lib/gherkin/pickle_compiler.cpp +++ b/cpp/src/lib/gherkin/pickle_compiler.cpp @@ -323,10 +323,10 @@ pickle_compiler::make_pickle_table( cms::pickle_table t; for (const auto& row : dt.rows) { - pickle_table_cells cells; + cms::pickle_table_row r; for (const auto& cell : row.cells) { - cells.emplace_back(cms::pickle_table_cell{ + r.cells.emplace_back(cms::pickle_table_cell{ .value = interpolate( cell.value, variable_cells, @@ -335,7 +335,7 @@ pickle_compiler::make_pickle_table( }); } - t.rows.emplace_back(std::move(cells)); + t.rows.emplace_back(std::move(r)); } return t;