Class: Packrat::ErrorReporter

Inherits:
GrammarElement show all
Defined in:
lib/packrat/grammar.rb

Overview

Report results of parsing a prod or grammar element

Instance Attribute Summary

Attributes inherited from GrammarElement

#hidden

Instance Method Summary collapse

Methods inherited from GrammarElement

#to_packrat_grammar_element

Constructor Details

#initialize(sub) ⇒ ErrorReporter

Returns a new instance of ErrorReporter.



126
127
128
# File 'lib/packrat/grammar.rb', line 126

def initialize(sub)
  @sub = sub
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



141
142
143
# File 'lib/packrat/grammar.rb', line 141

def method_missing(method, *args)
  @sub.send(method, *args)
end

Instance Method Details

#inspectObject



140
# File 'lib/packrat/grammar.rb', line 140

def inspect; @sub.inspect; end

#parse(parser) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/packrat/grammar.rb', line 129

def parse(parser)
  res = @sub.parse(parser)
  if false == res
    lputs "\t\t\t  FAIL #{@sub.inspect}"
    puts ""
  else
    lputs "    #{parser.pos}: Match #{@sub.inspect}"
    puts ""
  end
  res
end