Module: Cucumber::Parser::TreetopExt

Included in:
Treetop::Runtime::CompiledParser
Defined in:
lib/cucumber/parser/treetop_ext.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#parse_or_fail(source, file = nil, filter = nil, line_offset = 0) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/cucumber/parser/treetop_ext.rb', line 27

def parse_or_fail(source, file=nil, filter=nil, line_offset=0)
  parse_tree = parse(source)
  if parse_tree.nil?
    raise Cucumber::Parser::SyntaxError.new(self, file, line_offset)
  else
    ast = parse_tree.build(filter) # may return nil if it doesn't match filter.
    ast.file = file unless ast.nil?
    ast
  end
end