Class: Treetop::Runtime::SyntaxNode

Inherits:
Object
  • Object
show all
Defined in:
lib/tnql/treetop/extensions.rb

Overview

We extend the SyntaxNode class to include a hash of meta data. Individual rules can define meta_data_item method that must return a hash that is merged with the hash data for the entire query.

Instance Method Summary collapse

Instance Method Details

#meta_data(hash = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tnql/treetop/extensions.rb', line 7

def (hash = {})
  hash.merge!() if respond_to?(:meta_data_item)

  if nonterminal?
    elements.each do |element|
      element.(hash)
    end
  end

  hash
end