module Cucumber::Parser::TreetopExt

def parse_or_fail(source, file=nil, filter=nil, line_offset=0)

:nodoc:
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