class Temple::Mixins::GrammarDSL::Root
Public Class Methods
new(grammar, name)
click to toggle source
Calls superclass method
Temple::Mixins::GrammarDSL::Or.new
# File lib/temple/mixins/grammar_dsl.rb, line 45 def initialize(grammar, name) super(grammar) @name = name.to_sym end
Public Instance Methods
after_copy(source)
click to toggle source
Calls superclass method
Temple::Mixins::GrammarDSL::Or#after_copy
# File lib/temple/mixins/grammar_dsl.rb, line 76 def after_copy(source) @grammar.const_set(@name, self) super end
copy_to(grammar)
click to toggle source
Calls superclass method
Temple::Mixins::GrammarDSL::Rule#copy_to
# File lib/temple/mixins/grammar_dsl.rb, line 72 def copy_to(grammar) grammar.const_defined?(@name) ? grammar.const_get(@name) : super end
match(exp, unmatched)
click to toggle source
Calls superclass method
Temple::Mixins::GrammarDSL::Or#match
# File lib/temple/mixins/grammar_dsl.rb, line 50 def match(exp, unmatched) success = super unmatched << [@name, exp] unless success success end
match?(exp)
click to toggle source
# File lib/temple/mixins/grammar_dsl.rb, line 56 def match?(exp) match(exp, []) end
validate!(exp)
click to toggle source
# File lib/temple/mixins/grammar_dsl.rb, line 60 def validate!(exp) unmatched = [] unless match(exp, unmatched) require 'pp' entry = unmatched.first unmatched.reverse_each do |u| entry = u if u.flatten.size < entry.flatten.size end raise(InvalidExpression, PP.pp(entry.last, "#{@grammar}::#{entry.first} did not match\n")) end end