Sha256: f9ff9f35207011c6ed468fc5be8fa228495c8c05edace2d6a715fd4e331a96f0

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

module Melbourne

  class Parser #:nodoc:

    def self.parse_string(string, name = '(eval)', line = 1)
      new(name, line).parse_string(string)
    end

    def self.parse_file(name, line=1)
      new(name, line).parse_file
    end

    def initialize(name, line, transforms=[])
      @name = name
      @line = line > 0 ? line : 1
    end

    def syntax_error
      raise @exc if @exc
    end

    def parse_string(string)
      syntax_error unless ast = string_to_ast(string, @name, @line)
      ast
    end

    def parse_file
      unless @name and File.exists?(@name)
        raise Errno::ENOENT, @name.inspect
      end
      
      syntax_error unless ast = file_to_ast(@name, @line)
      ast
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
melbourne-1.0.0 lib/melbourne/parser.rb