Sha256: 50eb7057cd2cca49c40d9f59ff57a1b077295807780e35d1734811ed7a7fa2f6

Contents?: true

Size: 1.01 KB

Versions: 20

Compression:

Stored size: 1.01 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)
        ast = parse(IO.read(file))
        if ast.nil?
          raise SyntaxError.new(file, self)
        else
          feature = ast.compile
          feature.file = file
          feature
        end
      end      
    end
  end
end

Version data entries

20 entries across 20 versions & 5 rubygems

Version Path
aslakhellesoy-cucumber-0.1.10 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.11 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.12 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.13.2 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.13.3 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.13 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.9 lib/cucumber/treetop_parser/feature_parser.rb
bts-cucumber-0.1.13.1 lib/cucumber/treetop_parser/feature_parser.rb
bts-cucumber-0.1.13.2 lib/cucumber/treetop_parser/feature_parser.rb
bts-cucumber-0.1.13.3 lib/cucumber/treetop_parser/feature_parser.rb
elight-cucumber-0.1.9 lib/cucumber/treetop_parser/feature_parser.rb
jeffrafter-cucumber-0.1.10 lib/cucumber/treetop_parser/feature_parser.rb
jeffrafter-cucumber-0.1.12 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.10 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.12 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.13 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.11 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.8 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.7 lib/cucumber/treetop_parser/feature_parser.rb
cucumber-0.1.9 lib/cucumber/treetop_parser/feature_parser.rb