Sha256: 9db58ba68d61fb309fc467ae6b71348ea8166cbe0fa05368baaebf590e6ac304

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

module Cucumber
  module TreetopParser
    module Feature
      class SyntaxError < StandardError
        def initialize(file, parser)
          tf = parser.terminal_failures
          expected = tf.size == 1 ? tf[0].expected_string.inspect : "one of #{tf.map{|f| f.expected_string.inspect}.uniq*', '}"
          after = parser.input[parser.index...parser.failure_index]
          found = parser.input[parser.failure_index..parser.failure_index]
          @message = "#{file}:#{parser.failure_line}:#{parser.failure_column}: Parse error, expected #{expected}. After #{after.inspect}. Found: #{found.inspect}"
        end
        
        def message
          @message
        end
      end
      
      class << self
        attr_accessor :last_scenario
      end
      
      def parse_feature(file)
        gherkin = IO.read(file)
        gherkin = gherkin.force_encoding('utf-8') if Cucumber::RUBY_1_9
        ast = parse(gherkin)
        if ast.nil?
          raise SyntaxError.new(file, self)
        else
          feature = ast.compile
          feature.file = file
          feature
        end
      end      
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
aslakhellesoy-cucumber-0.1.14.1 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.14.2 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.15 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.16.1 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.16.2 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.16.3 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.16.4 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.16 lib/cucumber/treetop_parser/feature_parser.rb
kosmas58-cucumber-0.1.16.5 lib/cucumber/treetop_parser/feature_parser.rb
kosmas58-cucumber-0.1.16.6 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.14 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.15 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.16 lib/cucumber/treetop_parser/feature_parser.rb
mack-0.8.3.1 lib/gems/cucumber-0.1.15/lib/cucumber/treetop_parser/feature_parser.rb
mack-0.8.3 lib/gems/cucumber-0.1.15/lib/cucumber/treetop_parser/feature_parser.rb