Sha256: f77953976f2471b1d8a9d6af095d6827201bbfae3fb3937e2dc46a7a4cd522f9

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

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 : "one of #{tf.map{|f| f.expected_string}.uniq*', '}"
          @message = "#{file}:#{parser.failure_line}: Parse error, expected #{expected}"
        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.feature
          feature.file = file
          feature
        end
      end      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aslakhellesoy-cucumber-0.1.1 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.2 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.3 lib/cucumber/treetop_parser/feature_parser.rb
aslakhellesoy-cucumber-0.1.4 lib/cucumber/treetop_parser/feature_parser.rb