diff --git a/CHANGELOG.md b/CHANGELOG.md index 61298b7dd..972ef2193 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ 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] +### Changed +- [Ruby] Fixed up some style autofix cops ([#311](https://github.com/cucumber/gherkin/pull/311)) +- [Ruby] Internal rewrites to razor template variables and `TokenFormatterBuilder`) ([#311](https://github.com/cucumber/gherkin/pull/311)) + +### Fixed +- [Python] Release process didn't release to pypi correctly ## [30.0.0] - 2024-10-24 ### Added diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml index c13fb8562..80ee7446e 100644 --- a/ruby/.rubocop.yml +++ b/ruby/.rubocop.yml @@ -4,14 +4,39 @@ inherit_mode: merge: - Exclude +#require: +# - rubocop-packaging +# - rubocop-performance +# - rubocop-rails +# - rubocop-rake +# - rubocop-rspec + AllCops: - NewCops: disable - # Keep this inline with the lowest ruby version in the gemspec TargetRubyVersion: 3.0 - # Display cop name / style guide references - DisplayCopNames: true - DisplayStyleGuide: true + NewCops: enable + +# Disabled on our repo's to enable polyglot-release +Gemspec/RequireMFA: + Enabled: false + +Layout/LineLength: + Max: 200 + +# This allows us to read the chmod action in a more reproducible way +Style/NumericLiteralPrefix: + EnforcedOctalStyle: zero_only + +Style/Documentation: + Enabled: false + +Style/RegexpLiteral: + EnforcedStyle: slashes + AllowInnerSlashes: true + +## Disabled until rubocop-rspec is introduced +#RSpec/MessageSpies: +# EnforcedStyle: receive -# TODO: [LH] - Investigate this in terms of it not being fixed in rubocop? +# Hack to make rubocop not flag these (We need to re-analyse these later on) Naming/MethodName: Enabled: false diff --git a/ruby/.rubocop_todo.yml b/ruby/.rubocop_todo.yml index 6f52c1a6e..483adf388 100644 --- a/ruby/.rubocop_todo.yml +++ b/ruby/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-09-10 17:08:57 UTC using RuboCop version 1.26.1. +# on 2024-11-05 17:37:25 UTC using RuboCop version 1.26.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -11,6 +11,8 @@ # Pass 0 - July 2024 - 26 files inspected, 3031 offenses detected, 2667 offenses auto-correctable # Pass 1 - August 2024 (Fix up a load of Style autofix cops) - 27 files inspected, 2691 offenses detected, 2356 offenses auto-correctable # Pass 2 - September 2024 (Reconciled issues) - 27 files inspected, 2823 offenses detected, 2491 offenses auto-correctable +# Pass 3 - October 2024 (Minor tweaks for python fix) - 27 files inspected, 2831 offenses detected, 2472 offenses auto-correctable +# Pass 4 - November 2024 (Minor tweaks ready for 30.0.1) - 27 files inspected, 2725 offenses detected, 2444 offenses auto-correctable # Offense count: 63 # This cop supports safe auto-correction (--auto-correct). @@ -18,12 +20,6 @@ Layout/EmptyLineAfterGuardClause: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -Layout/EmptyLineAfterMagicComment: - Exclude: - - 'Gemfile' - # Offense count: 51 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. @@ -38,14 +34,6 @@ Layout/EmptyLines: - 'lib/gherkin/parser.rb' - 'spec/gherkin/stream/parser_message_stream_spec.rb' -# Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'lib/gherkin/pickles/compiler.rb' - # Offense count: 1 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. @@ -62,14 +50,6 @@ Layout/EmptyLinesAroundModuleBody: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 6 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/MultilineOperationIndentation: - Exclude: - - 'lib/gherkin/token_matcher.rb' - # Offense count: 2 # This cop supports safe auto-correction (--auto-correct). Layout/SpaceAfterComma: @@ -101,17 +81,6 @@ Layout/SpaceInsideParens: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 1 -# Configuration parameters: AllowSafeAssignment. -Lint/AssignmentInCondition: - Exclude: - - 'lib/gherkin/token_scanner.rb' - -# Offense count: 2 -Lint/ImplicitStringConcatenation: - Exclude: - - 'spec/gherkin/query_spec.rb' - # Offense count: 4 Lint/LiteralAsCondition: Exclude: @@ -123,20 +92,6 @@ Lint/Loop: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 3 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. -Lint/UnusedMethodArgument: - Exclude: - - 'lib/gherkin/ast_builder.rb' - - 'lib/gherkin/errors.rb' - -# Offense count: 2 -Lint/UselessAssignment: - Exclude: - - 'lib/gherkin/ast_builder.rb' - - 'spec/gherkin/gherkin_spec.rb' - # Offense count: 59 # Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: @@ -163,7 +118,7 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Max: 51 -# Offense count: 71 +# Offense count: 72 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. Metrics/MethodLength: Max: 141 @@ -186,39 +141,11 @@ Naming/AccessorMethodName: - 'lib/gherkin/parser.rb' - 'lib/gherkin/token_formatter_builder.rb' -# Offense count: 2 -# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to -Naming/MethodParameterName: - Exclude: - - 'lib/gherkin/parser.rb' - -# Offense count: 4 -# Configuration parameters: EnforcedStyle, AllowedIdentifiers. +# Offense count: 29 +# Configuration parameters: IgnoredPatterns. # SupportedStyles: snake_case, camelCase -Naming/VariableName: - Exclude: - - 'lib/gherkin/parser.rb' - -# Offense count: 52 -# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers. -# SupportedStyles: snake_case, normalcase, non_integer -# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 -Naming/VariableNumber: - Exclude: - - 'lib/gherkin/parser.rb' - -# Offense count: 6 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces -# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object -# FunctionalMethods: let, let!, subject, watch -# IgnoredMethods: lambda, proc, it -Style/BlockDelimiters: - Exclude: - - 'lib/gherkin/gherkin_line.rb' - - 'spec/gherkin/stream/parser_message_stream_spec.rb' +Naming/MethodName: + EnforcedStyle: snake_case # Offense count: 2 # This cop supports unsafe auto-correction (--auto-correct-all). @@ -233,30 +160,6 @@ Style/DefWithParentheses: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 18 -# Configuration parameters: AllowedConstants. -Style/Documentation: - Exclude: - - 'lib/gherkin.rb' - - 'lib/gherkin/ast_builder.rb' - - 'lib/gherkin/ast_node.rb' - - 'lib/gherkin/dialect.rb' - - 'lib/gherkin/errors.rb' - - 'lib/gherkin/gherkin_line.rb' - - 'lib/gherkin/parser.rb' - - 'lib/gherkin/pickles/compiler.rb' - - 'lib/gherkin/query.rb' - - 'lib/gherkin/stream/parser_message_stream.rb' - - 'lib/gherkin/token.rb' - - 'lib/gherkin/token_formatter_builder.rb' - - 'lib/gherkin/token_matcher.rb' - -# Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -Style/ExpandPathArguments: - Exclude: - - 'Rakefile' - # Offense count: 2 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. @@ -271,12 +174,13 @@ Style/FormatString: Style/FormatStringToken: EnforcedStyle: unannotated -# Offense count: 26 +# Offense count: 1 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: - Enabled: false + Exclude: + - 'lib/gherkin/parser.rb' # Offense count: 1 # This cop supports safe auto-correction (--auto-correct). @@ -285,12 +189,6 @@ Style/MethodCallWithoutArgsParentheses: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 3 -# This cop supports safe auto-correction (--auto-correct). -Style/MultilineTernaryOperator: - Exclude: - - 'lib/gherkin/pickles/compiler.rb' - # Offense count: 1 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. @@ -372,13 +270,12 @@ Style/SignalException: Exclude: - 'lib/gherkin/token_scanner.rb' -# Offense count: 4 +# Offense count: 3 # This cop supports unsafe auto-correction (--auto-correct-all). Style/SlicingWithRange: Exclude: - 'lib/gherkin/ast_builder.rb' - 'lib/gherkin/gherkin_line.rb' - - 'spec/gherkin/gherkin_spec.rb' # Offense count: 58 # This cop supports safe auto-correction (--auto-correct). @@ -480,10 +377,3 @@ Style/TrailingCommaInHashLiteral: Style/ZeroLengthPredicate: Exclude: - 'lib/gherkin/gherkin_line.rb' - -# Offense count: 124 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Layout/LineLength: - Max: 177 diff --git a/ruby/Gemfile b/ruby/Gemfile index e5ad85c8d..7f4f5e950 100644 --- a/ruby/Gemfile +++ b/ruby/Gemfile @@ -1,4 +1,5 @@ # frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/ruby/Rakefile b/ruby/Rakefile index c21069251..a2a1d4816 100644 --- a/ruby/Rakefile +++ b/ruby/Rakefile @@ -1,10 +1,12 @@ +# frozen_string_literal: true + require 'rubygems' require 'bundler' Bundler::GemHelper.install_tasks -$:.unshift File.expand_path('../lib', __FILE__) +$:.unshift File.expand_path('lib', __dir__) -Dir['./rake/*.rb'].sort.each { |f| require f } +Dir['./rake/*.rb'].each { |f| require f } require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) diff --git a/ruby/bin/gherkin b/ruby/bin/gherkin index 5f279838c..3bb687d15 100755 --- a/ruby/bin/gherkin +++ b/ruby/bin/gherkin @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib')) diff --git a/ruby/bin/gherkin-generate-tokens b/ruby/bin/gherkin-generate-tokens index e1a7fb843..c2e79fc29 100755 --- a/ruby/bin/gherkin-generate-tokens +++ b/ruby/bin/gherkin-generate-tokens @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'../lib')) require 'gherkin/parser' diff --git a/ruby/bin/gherkin-ruby b/ruby/bin/gherkin-ruby index 322dc1044..970386304 100755 --- a/ruby/bin/gherkin-ruby +++ b/ruby/bin/gherkin-ruby @@ -1,2 +1,4 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + load(File.dirname(__FILE__) + '/gherkin') diff --git a/ruby/cucumber-gherkin.gemspec b/ruby/cucumber-gherkin.gemspec index 1a46bcc22..0f84f1b45 100644 --- a/ruby/cucumber-gherkin.gemspec +++ b/ruby/cucumber-gherkin.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + version = File.read(File.expand_path('VERSION', __dir__)).strip Gem::Specification.new do |s| diff --git a/ruby/gherkin-ruby.razor b/ruby/gherkin-ruby.razor index 272ffec55..f648f623a 100644 --- a/ruby/gherkin-ruby.razor +++ b/ruby/gherkin-ruby.razor @@ -135,7 +135,7 @@ module Gherkin @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) { @:when @state.Id - @:match_token_at_@(state.Id)(token, context) + @:match_token_at_state@(state.Id)(token, context) } else raise InvalidOperationException, "Unknown state: #{state}" @@ -145,7 +145,7 @@ module Gherkin @foreach(var state in Model.States.Values.Where(s => !s.IsEndState)) { # @Raw(state.Comment) - def match_token_at_@(state.Id)(token, context) + def match_token_at_state@(state.Id)(token, context) @foreach(var transition in state.Transitions) { @:if @MatchToken(transition.TokenType) @@ -153,7 +153,7 @@ module Gherkin if (transition.LookAheadHint != null) { extraIndent = " "; - @:@("if lookahead_")@(transition.LookAheadHint.Id)(context, token) + @:@("if lookahead")@(transition.LookAheadHint.Id)(context, token) } foreach(var production in transition.Productions) { @@ -174,8 +174,8 @@ module Gherkin @foreach(var lookAheadHint in Model.RuleSet.LookAheadHints) { - def lookahead_@(lookAheadHint.Id)(context, currentToken) - currentToken.detach + def lookahead@(lookAheadHint.Id)(context, current_token) + current_token.detach token = nil queue = [] match = false diff --git a/ruby/lib/gherkin.rb b/ruby/lib/gherkin.rb index 0432c4d25..0c633ba2b 100644 --- a/ruby/lib/gherkin.rb +++ b/ruby/lib/gherkin.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'gherkin/stream/parser_message_stream' module Gherkin diff --git a/ruby/lib/gherkin/ast_builder.rb b/ruby/lib/gherkin/ast_builder.rb index 9a48f06b8..73584fa22 100644 --- a/ruby/lib/gherkin/ast_builder.rb +++ b/ruby/lib/gherkin/ast_builder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cucumber/messages' require_relative 'ast_node' @@ -17,7 +19,7 @@ def start_rule(rule_type) @stack.push AstNode.new(rule_type) end - def end_rule(rule_type) + def end_rule(_rule_type) node = @stack.pop current_node.add(node.rule_type, transform_node(node)) end @@ -79,8 +81,7 @@ def get_table_rows(node) cells: get_cells(token) ) end - ensure_cell_count(rows) - rows + rows.tap { ensure_cell_count(rows) } end def ensure_cell_count(rows) @@ -116,7 +117,7 @@ def transform_node(node) data_table = node.get_single(:DataTable) doc_string = node.get_single(:DocString) - step = Cucumber::Messages::Step.new( + Cucumber::Messages::Step.new( location: get_location(step_line, 0), keyword: step_line.matched_keyword, keyword_type: step_line.matched_keyword_type, diff --git a/ruby/lib/gherkin/ast_node.rb b/ruby/lib/gherkin/ast_node.rb index 577a35263..d0e065818 100644 --- a/ruby/lib/gherkin/ast_node.rb +++ b/ruby/lib/gherkin/ast_node.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gherkin class AstNode attr_reader :rule_type diff --git a/ruby/lib/gherkin/dialect.rb b/ruby/lib/gherkin/dialect.rb index 0be8dc1b9..0f0f46b46 100644 --- a/ruby/lib/gherkin/dialect.rb +++ b/ruby/lib/gherkin/dialect.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cucumber/messages' require 'json' diff --git a/ruby/lib/gherkin/errors.rb b/ruby/lib/gherkin/errors.rb index 3710b5bd0..8b86e893e 100644 --- a/ruby/lib/gherkin/errors.rb +++ b/ruby/lib/gherkin/errors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gherkin class ParserError < StandardError; end class AstNodeNotLocatedException < StandardError; end @@ -30,7 +32,7 @@ def initialize(errors) end class UnexpectedTokenException < ParserException - def initialize(received_token, expected_token_types, state_comment) + def initialize(received_token, expected_token_types, _state_comment) message = "expected: #{expected_token_types.join(", ")}, got '#{received_token.token_value.strip}'" column = received_token.location[:column] location = (column.nil? || column.zero?) ? { line: received_token.location[:line], column: received_token.line.indent + 1 } : received_token.location @@ -39,7 +41,7 @@ def initialize(received_token, expected_token_types, state_comment) end class UnexpectedEOFException < ParserException - def initialize(received_token, expected_token_types, state_comment) + def initialize(received_token, expected_token_types, _state_comment) message = "unexpected end of file, expected: #{expected_token_types.join(", ")}" super(message, received_token.location) end diff --git a/ruby/lib/gherkin/gherkin_line.rb b/ruby/lib/gherkin/gherkin_line.rb index 6c41dcaa2..16a99e1c6 100644 --- a/ruby/lib/gherkin/gherkin_line.rb +++ b/ruby/lib/gherkin/gherkin_line.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gherkin class GherkinLine attr_reader :indent, :trimmed_line_text @@ -88,7 +90,7 @@ def tags items = uncommented_line.split('@') tags = [] - items.each { |untrimmed| + items.each do |untrimmed| item = untrimmed.strip next if item.length == 0 @@ -99,7 +101,7 @@ def tags tags << Span.new(column, '@' + item) column += untrimmed.length + 1 - } + end tags end diff --git a/ruby/lib/gherkin/parser.rb b/ruby/lib/gherkin/parser.rb index 1a58d14f4..fa0f290b7 100644 --- a/ruby/lib/gherkin/parser.rb +++ b/ruby/lib/gherkin/parser.rb @@ -219,105 +219,105 @@ def match_Other( context, token) def match_token(state, token, context) case state when 0 - match_token_at_0(token, context) + match_token_at_state0(token, context) when 1 - match_token_at_1(token, context) + match_token_at_state1(token, context) when 2 - match_token_at_2(token, context) + match_token_at_state2(token, context) when 3 - match_token_at_3(token, context) + match_token_at_state3(token, context) when 4 - match_token_at_4(token, context) + match_token_at_state4(token, context) when 5 - match_token_at_5(token, context) + match_token_at_state5(token, context) when 6 - match_token_at_6(token, context) + match_token_at_state6(token, context) when 7 - match_token_at_7(token, context) + match_token_at_state7(token, context) when 8 - match_token_at_8(token, context) + match_token_at_state8(token, context) when 9 - match_token_at_9(token, context) + match_token_at_state9(token, context) when 10 - match_token_at_10(token, context) + match_token_at_state10(token, context) when 11 - match_token_at_11(token, context) + match_token_at_state11(token, context) when 12 - match_token_at_12(token, context) + match_token_at_state12(token, context) when 13 - match_token_at_13(token, context) + match_token_at_state13(token, context) when 14 - match_token_at_14(token, context) + match_token_at_state14(token, context) when 15 - match_token_at_15(token, context) + match_token_at_state15(token, context) when 16 - match_token_at_16(token, context) + match_token_at_state16(token, context) when 17 - match_token_at_17(token, context) + match_token_at_state17(token, context) when 18 - match_token_at_18(token, context) + match_token_at_state18(token, context) when 19 - match_token_at_19(token, context) + match_token_at_state19(token, context) when 20 - match_token_at_20(token, context) + match_token_at_state20(token, context) when 21 - match_token_at_21(token, context) + match_token_at_state21(token, context) when 22 - match_token_at_22(token, context) + match_token_at_state22(token, context) when 23 - match_token_at_23(token, context) + match_token_at_state23(token, context) when 24 - match_token_at_24(token, context) + match_token_at_state24(token, context) when 25 - match_token_at_25(token, context) + match_token_at_state25(token, context) when 26 - match_token_at_26(token, context) + match_token_at_state26(token, context) when 27 - match_token_at_27(token, context) + match_token_at_state27(token, context) when 28 - match_token_at_28(token, context) + match_token_at_state28(token, context) when 29 - match_token_at_29(token, context) + match_token_at_state29(token, context) when 30 - match_token_at_30(token, context) + match_token_at_state30(token, context) when 31 - match_token_at_31(token, context) + match_token_at_state31(token, context) when 32 - match_token_at_32(token, context) + match_token_at_state32(token, context) when 33 - match_token_at_33(token, context) + match_token_at_state33(token, context) when 34 - match_token_at_34(token, context) + match_token_at_state34(token, context) when 35 - match_token_at_35(token, context) + match_token_at_state35(token, context) when 36 - match_token_at_36(token, context) + match_token_at_state36(token, context) when 37 - match_token_at_37(token, context) + match_token_at_state37(token, context) when 38 - match_token_at_38(token, context) + match_token_at_state38(token, context) when 39 - match_token_at_39(token, context) + match_token_at_state39(token, context) when 40 - match_token_at_40(token, context) + match_token_at_state40(token, context) when 41 - match_token_at_41(token, context) + match_token_at_state41(token, context) when 43 - match_token_at_43(token, context) + match_token_at_state43(token, context) when 44 - match_token_at_44(token, context) + match_token_at_state44(token, context) when 45 - match_token_at_45(token, context) + match_token_at_state45(token, context) when 46 - match_token_at_46(token, context) + match_token_at_state46(token, context) when 47 - match_token_at_47(token, context) + match_token_at_state47(token, context) when 48 - match_token_at_48(token, context) + match_token_at_state48(token, context) when 49 - match_token_at_49(token, context) + match_token_at_state49(token, context) when 50 - match_token_at_50(token, context) + match_token_at_state50(token, context) else raise InvalidOperationException, "Unknown state: #{state}" end @@ -325,7 +325,7 @@ def match_token(state, token, context) # Start - def match_token_at_0(token, context) + def match_token_at_state0(token, context) if match_EOF(context, token) build(context, token); return 42 @@ -367,7 +367,7 @@ def match_token_at_0(token, context) return 0 end # GherkinDocument:0>Feature:0>FeatureHeader:0>#Language:0 - def match_token_at_1(token, context) + def match_token_at_state1(token, context) if match_TagLine(context, token) start_rule(context, :Tags); build(context, token); @@ -395,7 +395,7 @@ def match_token_at_1(token, context) return 1 end # GherkinDocument:0>Feature:0>FeatureHeader:1>Tags:0>#TagLine:0 - def match_token_at_2(token, context) + def match_token_at_state2(token, context) if match_TagLine(context, token) build(context, token); return 2 @@ -423,7 +423,7 @@ def match_token_at_2(token, context) return 2 end # GherkinDocument:0>Feature:0>FeatureHeader:2>#FeatureLine:0 - def match_token_at_3(token, context) + def match_token_at_state3(token, context) if match_EOF(context, token) end_rule(context, :FeatureHeader); end_rule(context, :Feature); @@ -445,7 +445,7 @@ def match_token_at_3(token, context) return 6 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :FeatureHeader); start_rule(context, :ScenarioDefinition); start_rule(context, :Tags); @@ -490,7 +490,7 @@ def match_token_at_3(token, context) return 3 end # GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:1>Description:0>#Other:0 - def match_token_at_4(token, context) + def match_token_at_state4(token, context) if match_EOF(context, token) end_rule(context, :Description); end_rule(context, :FeatureHeader); @@ -511,7 +511,7 @@ def match_token_at_4(token, context) return 6 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Description); end_rule(context, :FeatureHeader); start_rule(context, :ScenarioDefinition); @@ -559,7 +559,7 @@ def match_token_at_4(token, context) return 4 end # GherkinDocument:0>Feature:0>FeatureHeader:3>DescriptionHelper:2>#Comment:0 - def match_token_at_5(token, context) + def match_token_at_state5(token, context) if match_EOF(context, token) end_rule(context, :FeatureHeader); end_rule(context, :Feature); @@ -577,7 +577,7 @@ def match_token_at_5(token, context) return 6 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :FeatureHeader); start_rule(context, :ScenarioDefinition); start_rule(context, :Tags); @@ -621,7 +621,7 @@ def match_token_at_5(token, context) return 5 end # GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0 - def match_token_at_6(token, context) + def match_token_at_state6(token, context) if match_EOF(context, token) end_rule(context, :Background); end_rule(context, :Feature); @@ -642,7 +642,7 @@ def match_token_at_6(token, context) return 9 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Background); start_rule(context, :ScenarioDefinition); start_rule(context, :Tags); @@ -687,7 +687,7 @@ def match_token_at_6(token, context) return 6 end # GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 - def match_token_at_7(token, context) + def match_token_at_state7(token, context) if match_EOF(context, token) end_rule(context, :Description); end_rule(context, :Background); @@ -707,7 +707,7 @@ def match_token_at_7(token, context) return 9 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Description); end_rule(context, :Background); start_rule(context, :ScenarioDefinition); @@ -755,7 +755,7 @@ def match_token_at_7(token, context) return 7 end # GherkinDocument:0>Feature:1>Background:1>DescriptionHelper:2>#Comment:0 - def match_token_at_8(token, context) + def match_token_at_state8(token, context) if match_EOF(context, token) end_rule(context, :Background); end_rule(context, :Feature); @@ -772,7 +772,7 @@ def match_token_at_8(token, context) return 9 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Background); start_rule(context, :ScenarioDefinition); start_rule(context, :Tags); @@ -816,7 +816,7 @@ def match_token_at_8(token, context) return 8 end # GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:0 - def match_token_at_9(token, context) + def match_token_at_state9(token, context) if match_EOF(context, token) end_rule(context, :Step); end_rule(context, :Background); @@ -841,7 +841,7 @@ def match_token_at_9(token, context) return 9 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Step); end_rule(context, :Background); start_rule(context, :ScenarioDefinition); @@ -893,7 +893,7 @@ def match_token_at_9(token, context) return 9 end # GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 - def match_token_at_10(token, context) + def match_token_at_state10(token, context) if match_EOF(context, token) end_rule(context, :DataTable); end_rule(context, :Step); @@ -914,7 +914,7 @@ def match_token_at_10(token, context) return 9 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :DataTable); end_rule(context, :Step); end_rule(context, :Background); @@ -970,7 +970,7 @@ def match_token_at_10(token, context) return 10 end # GherkinDocument:0>Feature:2>ScenarioDefinition:0>Tags:0>#TagLine:0 - def match_token_at_11(token, context) + def match_token_at_state11(token, context) if match_TagLine(context, token) build(context, token); return 11 @@ -999,7 +999,7 @@ def match_token_at_11(token, context) return 11 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 - def match_token_at_12(token, context) + def match_token_at_state12(token, context) if match_EOF(context, token) end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); @@ -1021,7 +1021,7 @@ def match_token_at_12(token, context) return 15 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) start_rule(context, :ExamplesDefinition); start_rule(context, :Tags); build(context, token); @@ -1029,7 +1029,7 @@ def match_token_at_12(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); start_rule(context, :ScenarioDefinition); @@ -1084,7 +1084,7 @@ def match_token_at_12(token, context) return 12 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 - def match_token_at_13(token, context) + def match_token_at_state13(token, context) if match_EOF(context, token) end_rule(context, :Description); end_rule(context, :Scenario); @@ -1105,7 +1105,7 @@ def match_token_at_13(token, context) return 15 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Description); start_rule(context, :ExamplesDefinition); start_rule(context, :Tags); @@ -1114,7 +1114,7 @@ def match_token_at_13(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Description); end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); @@ -1173,7 +1173,7 @@ def match_token_at_13(token, context) return 13 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 - def match_token_at_14(token, context) + def match_token_at_state14(token, context) if match_EOF(context, token) end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); @@ -1191,7 +1191,7 @@ def match_token_at_14(token, context) return 15 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) start_rule(context, :ExamplesDefinition); start_rule(context, :Tags); build(context, token); @@ -1199,7 +1199,7 @@ def match_token_at_14(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); start_rule(context, :ScenarioDefinition); @@ -1253,7 +1253,7 @@ def match_token_at_14(token, context) return 14 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 - def match_token_at_15(token, context) + def match_token_at_state15(token, context) if match_EOF(context, token) end_rule(context, :Step); end_rule(context, :Scenario); @@ -1279,7 +1279,7 @@ def match_token_at_15(token, context) return 15 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Step); start_rule(context, :ExamplesDefinition); start_rule(context, :Tags); @@ -1288,7 +1288,7 @@ def match_token_at_15(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Step); end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); @@ -1351,7 +1351,7 @@ def match_token_at_15(token, context) return 15 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 - def match_token_at_16(token, context) + def match_token_at_state16(token, context) if match_EOF(context, token) end_rule(context, :DataTable); end_rule(context, :Step); @@ -1373,7 +1373,7 @@ def match_token_at_16(token, context) return 15 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :DataTable); end_rule(context, :Step); start_rule(context, :ExamplesDefinition); @@ -1383,7 +1383,7 @@ def match_token_at_16(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :DataTable); end_rule(context, :Step); end_rule(context, :Scenario); @@ -1451,7 +1451,7 @@ def match_token_at_16(token, context) return 16 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 - def match_token_at_17(token, context) + def match_token_at_state17(token, context) if match_TagLine(context, token) build(context, token); return 17 @@ -1480,7 +1480,7 @@ def match_token_at_17(token, context) return 17 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 - def match_token_at_18(token, context) + def match_token_at_state18(token, context) if match_EOF(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -1504,7 +1504,7 @@ def match_token_at_18(token, context) return 21 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); start_rule(context, :ExamplesDefinition); @@ -1514,7 +1514,7 @@ def match_token_at_18(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); end_rule(context, :Scenario); @@ -1579,7 +1579,7 @@ def match_token_at_18(token, context) return 18 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 - def match_token_at_19(token, context) + def match_token_at_state19(token, context) if match_EOF(context, token) end_rule(context, :Description); end_rule(context, :Examples); @@ -1602,7 +1602,7 @@ def match_token_at_19(token, context) return 21 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Description); end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -1613,7 +1613,7 @@ def match_token_at_19(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Description); end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -1682,7 +1682,7 @@ def match_token_at_19(token, context) return 19 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 - def match_token_at_20(token, context) + def match_token_at_state20(token, context) if match_EOF(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -1702,7 +1702,7 @@ def match_token_at_20(token, context) return 21 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); start_rule(context, :ExamplesDefinition); @@ -1712,7 +1712,7 @@ def match_token_at_20(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); end_rule(context, :Scenario); @@ -1776,7 +1776,7 @@ def match_token_at_20(token, context) return 20 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 - def match_token_at_21(token, context) + def match_token_at_state21(token, context) if match_EOF(context, token) end_rule(context, :ExamplesTable); end_rule(context, :Examples); @@ -1792,7 +1792,7 @@ def match_token_at_21(token, context) return 21 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :ExamplesTable); end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -1803,7 +1803,7 @@ def match_token_at_21(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :ExamplesTable); end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -1876,7 +1876,7 @@ def match_token_at_21(token, context) return 21 end # GherkinDocument:0>Feature:3>Rule:0>RuleHeader:0>Tags:0>#TagLine:0 - def match_token_at_22(token, context) + def match_token_at_state22(token, context) if match_TagLine(context, token) build(context, token); return 22 @@ -1904,7 +1904,7 @@ def match_token_at_22(token, context) return 22 end # GherkinDocument:0>Feature:3>Rule:0>RuleHeader:1>#RuleLine:0 - def match_token_at_23(token, context) + def match_token_at_state23(token, context) if match_EOF(context, token) end_rule(context, :RuleHeader); end_rule(context, :Rule); @@ -1927,7 +1927,7 @@ def match_token_at_23(token, context) return 26 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :RuleHeader); start_rule(context, :ScenarioDefinition); start_rule(context, :Tags); @@ -1974,7 +1974,7 @@ def match_token_at_23(token, context) return 23 end # GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:1>Description:0>#Other:0 - def match_token_at_24(token, context) + def match_token_at_state24(token, context) if match_EOF(context, token) end_rule(context, :Description); end_rule(context, :RuleHeader); @@ -1996,7 +1996,7 @@ def match_token_at_24(token, context) return 26 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Description); end_rule(context, :RuleHeader); start_rule(context, :ScenarioDefinition); @@ -2046,7 +2046,7 @@ def match_token_at_24(token, context) return 24 end # GherkinDocument:0>Feature:3>Rule:0>RuleHeader:2>DescriptionHelper:2>#Comment:0 - def match_token_at_25(token, context) + def match_token_at_state25(token, context) if match_EOF(context, token) end_rule(context, :RuleHeader); end_rule(context, :Rule); @@ -2065,7 +2065,7 @@ def match_token_at_25(token, context) return 26 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :RuleHeader); start_rule(context, :ScenarioDefinition); start_rule(context, :Tags); @@ -2111,7 +2111,7 @@ def match_token_at_25(token, context) return 25 end # GherkinDocument:0>Feature:3>Rule:1>Background:0>#BackgroundLine:0 - def match_token_at_26(token, context) + def match_token_at_state26(token, context) if match_EOF(context, token) end_rule(context, :Background); end_rule(context, :Rule); @@ -2133,7 +2133,7 @@ def match_token_at_26(token, context) return 29 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Background); start_rule(context, :ScenarioDefinition); start_rule(context, :Tags); @@ -2180,7 +2180,7 @@ def match_token_at_26(token, context) return 26 end # GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:1>Description:0>#Other:0 - def match_token_at_27(token, context) + def match_token_at_state27(token, context) if match_EOF(context, token) end_rule(context, :Description); end_rule(context, :Background); @@ -2201,7 +2201,7 @@ def match_token_at_27(token, context) return 29 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Description); end_rule(context, :Background); start_rule(context, :ScenarioDefinition); @@ -2251,7 +2251,7 @@ def match_token_at_27(token, context) return 27 end # GherkinDocument:0>Feature:3>Rule:1>Background:1>DescriptionHelper:2>#Comment:0 - def match_token_at_28(token, context) + def match_token_at_state28(token, context) if match_EOF(context, token) end_rule(context, :Background); end_rule(context, :Rule); @@ -2269,7 +2269,7 @@ def match_token_at_28(token, context) return 29 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Background); start_rule(context, :ScenarioDefinition); start_rule(context, :Tags); @@ -2315,7 +2315,7 @@ def match_token_at_28(token, context) return 28 end # GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:0>#StepLine:0 - def match_token_at_29(token, context) + def match_token_at_state29(token, context) if match_EOF(context, token) end_rule(context, :Step); end_rule(context, :Background); @@ -2341,7 +2341,7 @@ def match_token_at_29(token, context) return 29 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Step); end_rule(context, :Background); start_rule(context, :ScenarioDefinition); @@ -2395,7 +2395,7 @@ def match_token_at_29(token, context) return 29 end # GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 - def match_token_at_30(token, context) + def match_token_at_state30(token, context) if match_EOF(context, token) end_rule(context, :DataTable); end_rule(context, :Step); @@ -2417,7 +2417,7 @@ def match_token_at_30(token, context) return 29 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :DataTable); end_rule(context, :Step); end_rule(context, :Background); @@ -2475,7 +2475,7 @@ def match_token_at_30(token, context) return 30 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:0>Tags:0>#TagLine:0 - def match_token_at_31(token, context) + def match_token_at_state31(token, context) if match_TagLine(context, token) build(context, token); return 31 @@ -2504,7 +2504,7 @@ def match_token_at_31(token, context) return 31 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:0>#ScenarioLine:0 - def match_token_at_32(token, context) + def match_token_at_state32(token, context) if match_EOF(context, token) end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); @@ -2527,7 +2527,7 @@ def match_token_at_32(token, context) return 35 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) start_rule(context, :ExamplesDefinition); start_rule(context, :Tags); build(context, token); @@ -2535,7 +2535,7 @@ def match_token_at_32(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); start_rule(context, :ScenarioDefinition); @@ -2592,7 +2592,7 @@ def match_token_at_32(token, context) return 32 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:1>Description:0>#Other:0 - def match_token_at_33(token, context) + def match_token_at_state33(token, context) if match_EOF(context, token) end_rule(context, :Description); end_rule(context, :Scenario); @@ -2614,7 +2614,7 @@ def match_token_at_33(token, context) return 35 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Description); start_rule(context, :ExamplesDefinition); start_rule(context, :Tags); @@ -2623,7 +2623,7 @@ def match_token_at_33(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Description); end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); @@ -2684,7 +2684,7 @@ def match_token_at_33(token, context) return 33 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:1>DescriptionHelper:2>#Comment:0 - def match_token_at_34(token, context) + def match_token_at_state34(token, context) if match_EOF(context, token) end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); @@ -2703,7 +2703,7 @@ def match_token_at_34(token, context) return 35 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) start_rule(context, :ExamplesDefinition); start_rule(context, :Tags); build(context, token); @@ -2711,7 +2711,7 @@ def match_token_at_34(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); start_rule(context, :ScenarioDefinition); @@ -2767,7 +2767,7 @@ def match_token_at_34(token, context) return 34 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:0>#StepLine:0 - def match_token_at_35(token, context) + def match_token_at_state35(token, context) if match_EOF(context, token) end_rule(context, :Step); end_rule(context, :Scenario); @@ -2794,7 +2794,7 @@ def match_token_at_35(token, context) return 35 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Step); start_rule(context, :ExamplesDefinition); start_rule(context, :Tags); @@ -2803,7 +2803,7 @@ def match_token_at_35(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Step); end_rule(context, :Scenario); end_rule(context, :ScenarioDefinition); @@ -2868,7 +2868,7 @@ def match_token_at_35(token, context) return 35 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:0>DataTable:0>#TableRow:0 - def match_token_at_36(token, context) + def match_token_at_state36(token, context) if match_EOF(context, token) end_rule(context, :DataTable); end_rule(context, :Step); @@ -2891,7 +2891,7 @@ def match_token_at_36(token, context) return 35 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :DataTable); end_rule(context, :Step); start_rule(context, :ExamplesDefinition); @@ -2901,7 +2901,7 @@ def match_token_at_36(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :DataTable); end_rule(context, :Step); end_rule(context, :Scenario); @@ -2971,7 +2971,7 @@ def match_token_at_36(token, context) return 36 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:0>Tags:0>#TagLine:0 - def match_token_at_37(token, context) + def match_token_at_state37(token, context) if match_TagLine(context, token) build(context, token); return 37 @@ -3000,7 +3000,7 @@ def match_token_at_37(token, context) return 37 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:0>#ExamplesLine:0 - def match_token_at_38(token, context) + def match_token_at_state38(token, context) if match_EOF(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -3025,7 +3025,7 @@ def match_token_at_38(token, context) return 41 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); start_rule(context, :ExamplesDefinition); @@ -3035,7 +3035,7 @@ def match_token_at_38(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); end_rule(context, :Scenario); @@ -3102,7 +3102,7 @@ def match_token_at_38(token, context) return 38 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:1>Description:0>#Other:0 - def match_token_at_39(token, context) + def match_token_at_state39(token, context) if match_EOF(context, token) end_rule(context, :Description); end_rule(context, :Examples); @@ -3126,7 +3126,7 @@ def match_token_at_39(token, context) return 41 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Description); end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -3137,7 +3137,7 @@ def match_token_at_39(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Description); end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -3208,7 +3208,7 @@ def match_token_at_39(token, context) return 39 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:1>DescriptionHelper:2>#Comment:0 - def match_token_at_40(token, context) + def match_token_at_state40(token, context) if match_EOF(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -3229,7 +3229,7 @@ def match_token_at_40(token, context) return 41 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); start_rule(context, :ExamplesDefinition); @@ -3239,7 +3239,7 @@ def match_token_at_40(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); end_rule(context, :Scenario); @@ -3305,7 +3305,7 @@ def match_token_at_40(token, context) return 40 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:3>ExamplesDefinition:1>Examples:2>ExamplesTable:0>#TableRow:0 - def match_token_at_41(token, context) + def match_token_at_state41(token, context) if match_EOF(context, token) end_rule(context, :ExamplesTable); end_rule(context, :Examples); @@ -3322,7 +3322,7 @@ def match_token_at_41(token, context) return 41 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :ExamplesTable); end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -3333,7 +3333,7 @@ def match_token_at_41(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :ExamplesTable); end_rule(context, :Examples); end_rule(context, :ExamplesDefinition); @@ -3408,7 +3408,7 @@ def match_token_at_41(token, context) return 41 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 - def match_token_at_43(token, context) + def match_token_at_state43(token, context) if match_DocStringSeparator(context, token) build(context, token); return 44 @@ -3427,7 +3427,7 @@ def match_token_at_43(token, context) return 43 end # GherkinDocument:0>Feature:3>Rule:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 - def match_token_at_44(token, context) + def match_token_at_state44(token, context) if match_EOF(context, token) end_rule(context, :DocString); end_rule(context, :Step); @@ -3446,7 +3446,7 @@ def match_token_at_44(token, context) return 35 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :DocString); end_rule(context, :Step); start_rule(context, :ExamplesDefinition); @@ -3456,7 +3456,7 @@ def match_token_at_44(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :DocString); end_rule(context, :Step); end_rule(context, :Scenario); @@ -3526,7 +3526,7 @@ def match_token_at_44(token, context) return 44 end # GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 - def match_token_at_45(token, context) + def match_token_at_state45(token, context) if match_DocStringSeparator(context, token) build(context, token); return 46 @@ -3545,7 +3545,7 @@ def match_token_at_45(token, context) return 45 end # GherkinDocument:0>Feature:3>Rule:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 - def match_token_at_46(token, context) + def match_token_at_state46(token, context) if match_EOF(context, token) end_rule(context, :DocString); end_rule(context, :Step); @@ -3563,7 +3563,7 @@ def match_token_at_46(token, context) return 29 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :DocString); end_rule(context, :Step); end_rule(context, :Background); @@ -3621,7 +3621,7 @@ def match_token_at_46(token, context) return 46 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 - def match_token_at_47(token, context) + def match_token_at_state47(token, context) if match_DocStringSeparator(context, token) build(context, token); return 48 @@ -3640,7 +3640,7 @@ def match_token_at_47(token, context) return 47 end # GherkinDocument:0>Feature:2>ScenarioDefinition:1>Scenario:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 - def match_token_at_48(token, context) + def match_token_at_state48(token, context) if match_EOF(context, token) end_rule(context, :DocString); end_rule(context, :Step); @@ -3658,7 +3658,7 @@ def match_token_at_48(token, context) return 15 end if match_TagLine(context, token) - if lookahead_1(context, token) + if lookahead1(context, token) end_rule(context, :DocString); end_rule(context, :Step); start_rule(context, :ExamplesDefinition); @@ -3668,7 +3668,7 @@ def match_token_at_48(token, context) end end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :DocString); end_rule(context, :Step); end_rule(context, :Scenario); @@ -3736,7 +3736,7 @@ def match_token_at_48(token, context) return 48 end # GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:0>#DocStringSeparator:0 - def match_token_at_49(token, context) + def match_token_at_state49(token, context) if match_DocStringSeparator(context, token) build(context, token); return 50 @@ -3755,7 +3755,7 @@ def match_token_at_49(token, context) return 49 end # GherkinDocument:0>Feature:1>Background:2>Step:1>StepArg:0>__alt0:1>DocString:2>#DocStringSeparator:0 - def match_token_at_50(token, context) + def match_token_at_state50(token, context) if match_EOF(context, token) end_rule(context, :DocString); end_rule(context, :Step); @@ -3772,7 +3772,7 @@ def match_token_at_50(token, context) return 9 end if match_TagLine(context, token) - if lookahead_0(context, token) + if lookahead0(context, token) end_rule(context, :DocString); end_rule(context, :Step); end_rule(context, :Background); @@ -3828,8 +3828,8 @@ def match_token_at_50(token, context) return 50 end - def lookahead_0(context, currentToken) - currentToken.detach + def lookahead0(context, current_token) + current_token.detach token = nil queue = [] match = false @@ -3851,8 +3851,8 @@ def lookahead_0(context, currentToken) return match end - def lookahead_1(context, currentToken) - currentToken.detach + def lookahead1(context, current_token) + current_token.detach token = nil queue = [] match = false diff --git a/ruby/lib/gherkin/pickles/compiler.rb b/ruby/lib/gherkin/pickles/compiler.rb index 0f0aaf1bd..9c66e9b70 100644 --- a/ruby/lib/gherkin/pickles/compiler.rb +++ b/ruby/lib/gherkin/pickles/compiler.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cucumber/messages' module Gherkin @@ -66,8 +68,11 @@ def compile_scenario(inherited_tags, background_steps, scenario, language, pickl unless scenario.steps.empty? [].concat(background_steps).concat(scenario.steps).each do |step| last_keyword_type = - step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION ? - last_keyword_type : step.keyword_type + if step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION + last_keyword_type + else + step.keyword_type + end steps.push(Cucumber::Messages::PickleStep.new(**pickle_step_props(step, [], nil, last_keyword_type))) end end @@ -96,15 +101,21 @@ def compile_scenario_outline(inherited_tags, background_steps, scenario, languag unless scenario.steps.empty? background_steps.each do |step| last_keyword_type = - step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION ? - last_keyword_type : step.keyword_type + if step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION + last_keyword_type + else + step.keyword_type + end step_props = pickle_step_props(step, [], nil, last_keyword_type) steps.push(Cucumber::Messages::PickleStep.new(**step_props)) end scenario.steps.each do |step| last_keyword_type = - step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION ? - last_keyword_type : step.keyword_type + if step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION + last_keyword_type + else + step.keyword_type + end step_props = pickle_step_props(step, variable_cells, values_row, last_keyword_type) steps.push(Cucumber::Messages::PickleStep.new(**step_props)) end @@ -123,7 +134,6 @@ def compile_scenario_outline(inherited_tags, background_steps, scenario, languag ] ) pickles.push(pickle) - end end end diff --git a/ruby/lib/gherkin/query.rb b/ruby/lib/gherkin/query.rb index 12c78111e..9a3334bac 100644 --- a/ruby/lib/gherkin/query.rb +++ b/ruby/lib/gherkin/query.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gherkin class Query def initialize diff --git a/ruby/lib/gherkin/stream/parser_message_stream.rb b/ruby/lib/gherkin/stream/parser_message_stream.rb index 15633fcc8..4b39e66ef 100644 --- a/ruby/lib/gherkin/stream/parser_message_stream.rb +++ b/ruby/lib/gherkin/stream/parser_message_stream.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cucumber/messages' require_relative '../parser' require_relative '../token_matcher' diff --git a/ruby/lib/gherkin/token.rb b/ruby/lib/gherkin/token.rb index adc21a9cb..eeb97ccbd 100644 --- a/ruby/lib/gherkin/token.rb +++ b/ruby/lib/gherkin/token.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gherkin class Token < Struct.new(:line, :location) attr_accessor :matched_type, :matched_text, :matched_keyword, :matched_indent, diff --git a/ruby/lib/gherkin/token_formatter_builder.rb b/ruby/lib/gherkin/token_formatter_builder.rb index e2dea56b9..2fa1424fc 100644 --- a/ruby/lib/gherkin/token_formatter_builder.rb +++ b/ruby/lib/gherkin/token_formatter_builder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gherkin class TokenFormatterBuilder def initialize @@ -5,11 +7,11 @@ def initialize end def reset - @tokens_text = '' + @tokens = [] end def build(token) - @tokens_text << "#{format_token(token)}\n" + tokens << token end def start_rule(_rule_type); end @@ -17,11 +19,15 @@ def start_rule(_rule_type); end def end_rule(_rule_type); end def get_result - @tokens_text + tokens.map { |token| "#{format_token(token)}\n" }.join end private + def tokens + @tokens ||= [] + end + def format_token(token) return 'EOF' if token.eof? diff --git a/ruby/lib/gherkin/token_matcher.rb b/ruby/lib/gherkin/token_matcher.rb index b095121bf..028c3c527 100644 --- a/ruby/lib/gherkin/token_matcher.rb +++ b/ruby/lib/gherkin/token_matcher.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cucumber/messages' require_relative 'dialect' require_relative 'errors' @@ -35,7 +37,7 @@ def match_RuleLine(token) def match_ScenarioLine(token) match_title_line(token, :ScenarioLine, @dialect.scenario_keywords) || - match_title_line(token, :ScenarioLine, @dialect.scenario_outline_keywords) + match_title_line(token, :ScenarioLine, @dialect.scenario_outline_keywords) end def match_BackgroundLine(token) @@ -83,7 +85,7 @@ def match_DocStringSeparator(token) if @active_doc_string_separator.nil? # open _match_DocStringSeparator(token, '"""', true) || - _match_DocStringSeparator(token, '```', true) + _match_DocStringSeparator(token, '```', true) else # close _match_DocStringSeparator(token, @active_doc_string_separator, false) @@ -121,11 +123,12 @@ def match_Other(token) end def match_StepLine(token) - keywords = @dialect.given_keywords + - @dialect.when_keywords + - @dialect.then_keywords + - @dialect.and_keywords + - @dialect.but_keywords + keywords = + @dialect.given_keywords + + @dialect.when_keywords + + @dialect.then_keywords + + @dialect.and_keywords + + @dialect.but_keywords keyword = keywords.detect { |k| token.line.start_with?(k) } diff --git a/ruby/lib/gherkin/token_scanner.rb b/ruby/lib/gherkin/token_scanner.rb index 79df254e6..5df23bd9f 100644 --- a/ruby/lib/gherkin/token_scanner.rb +++ b/ruby/lib/gherkin/token_scanner.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'stringio' require_relative 'token' require_relative 'gherkin_line' @@ -26,8 +28,10 @@ def initialize(source_or_io) def read location = { line: @line_number += 1 } - if @io.nil? || line = @io.gets - gherkin_line = line ? GherkinLine.new(line, location[:line]) : nil + if @io.nil? + Token.new(nil, location) + elsif (line = @io.gets) + gherkin_line = GherkinLine.new(line, location[:line]) Token.new(gherkin_line, location) else @io.close unless @io.closed? # ARGF closes the last file after final gets diff --git a/ruby/spec/gherkin/dialect_spec.rb b/ruby/spec/gherkin/dialect_spec.rb index 1c444d0dc..77710063a 100644 --- a/ruby/spec/gherkin/dialect_spec.rb +++ b/ruby/spec/gherkin/dialect_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gherkin describe Dialect do it 'provides an interface to the keywords of a dialect' do diff --git a/ruby/spec/gherkin/gherkin_line_spec.rb b/ruby/spec/gherkin/gherkin_line_spec.rb index 56ac2558d..8485e298e 100644 --- a/ruby/spec/gherkin/gherkin_line_spec.rb +++ b/ruby/spec/gherkin/gherkin_line_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe Gherkin::GherkinLine do context '#tags' do def tags(line) diff --git a/ruby/spec/gherkin/gherkin_spec.rb b/ruby/spec/gherkin/gherkin_spec.rb index 053d53df6..55d278596 100644 --- a/ruby/spec/gherkin/gherkin_spec.rb +++ b/ruby/spec/gherkin/gherkin_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe Gherkin do it 'can process feature file paths' do messages = Gherkin.from_paths( @@ -26,7 +28,6 @@ it 'can set the default dialect for the feature file content' do data = File.open('../testdata/good/i18n_no.feature', 'r:UTF-8', &:read) - data_without_language_header = data.split("\n")[1..-1].join("\n") messages = Gherkin.from_source( 'uri', diff --git a/ruby/spec/gherkin/parser_spec.rb b/ruby/spec/gherkin/parser_spec.rb index bd7610f31..48e6935f1 100644 --- a/ruby/spec/gherkin/parser_spec.rb +++ b/ruby/spec/gherkin/parser_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe Gherkin::Parser do describe '#initialize' do it 'can be initialized with no arguments' do diff --git a/ruby/spec/gherkin/query_spec.rb b/ruby/spec/gherkin/query_spec.rb index 033156e71..95b3bb843 100644 --- a/ruby/spec/gherkin/query_spec.rb +++ b/ruby/spec/gherkin/query_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'gherkin/query' describe Gherkin::Query do @@ -26,7 +28,7 @@ def find_message_by_attribute(messages, attribute) end let(:feature_content) do - ''" + " @feature-tag Feature: my feature @@ -54,7 +56,7 @@ def find_message_by_attribute(messages, attribute) @ruled-scenario-tag Scenario: a ruled scenario Given a step in the ruled scenario - "'' + " end describe '#update' do diff --git a/ruby/spec/gherkin/stream/parser_message_stream_spec.rb b/ruby/spec/gherkin/stream/parser_message_stream_spec.rb index 341edfb9d..ccf3db715 100644 --- a/ruby/spec/gherkin/stream/parser_message_stream_spec.rb +++ b/ruby/spec/gherkin/stream/parser_message_stream_spec.rb @@ -1,29 +1,31 @@ +# frozen_string_literal: true + module Gherkin module Stream describe ParserMessageStream do - let(:feature_content) { + let(:feature_content) do "Feature: my feature\n" \ - " Scenario: a scenario\n" \ - " Given some context" - } + " Scenario: a scenario\n" \ + " Given some context" + end - let(:source_feature) { + let(:source_feature) do Cucumber::Messages::Source.new( uri: '//whatever/uri', data: feature_content, media_type: 'text/x.cucumber.gherkin+plain' ) - } + end - let(:options) { + let(:options) do { include_gherkin_document: true } - } + end - let(:gherkin_document) { + let(:gherkin_document) do ParserMessageStream.new([], [source_feature], options).messages.first.gherkin_document - } + end let(:scenario_id) { gherkin_document.feature.children.first.scenario.id } @@ -46,12 +48,12 @@ module Stream context 'when set' do let(:id_generator) { double } - let(:options) { + let(:options) do { include_gherkin_document: true, id_generator: id_generator } - } + end it 'uses the generator instance to produce the IDs' do allow(id_generator).to receive(:new_id).and_return('some-random-id') diff --git a/ruby/spec/spec_helper.rb b/ruby/spec/spec_helper.rb index 3f8a30c53..dc4e37433 100644 --- a/ruby/spec/spec_helper.rb +++ b/ruby/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec' require 'gherkin'