Sha256: 0b5940bac239a3f35be89a9690ccfce670835ccf2abd27705c50f82b75e18436

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

module Treetop
  class Parser
    attr_reader :grammar, :parse_cache
    
    def initialize(grammar)
      @grammar = grammar
      @parse_cache = ParseCache.new      
    end

    def parse(input)
      @parse_cache = ParseCache.new
      result = grammar.root.parse_at(input, 0, self)
      if result.success? and result.interval.end == input.size
        return result
      else        
        return ParseFailure.new(result.interval.end, result.nested_failures)
      end
    end
    
    def node_cache_for(parsing_expression)
      parse_cache[parsing_expression]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
treetop-0.1.0 lib/treetop/parser/parser.rb