Class: Treetop::Runtime::SyntaxNode

Inherits:
Object
  • Object
show all
Defined in:
lib/canql/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



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/canql/treetop/extensions.rb', line 9

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

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

  hash
end

#reverse_scan_for_marker(marker) ⇒ Object



27
28
29
30
31
32
# File 'lib/canql/treetop/extensions.rb', line 27

def reverse_scan_for_marker(marker)
  marker_value = reverse_marker_scanner(self, marker)
  return if marker_value.blank?

  marker_value
end

#text_values_for_marker(marker) ⇒ Object



21
22
23
24
25
# File 'lib/canql/treetop/extensions.rb', line 21

def text_values_for_marker(marker)
  list = []
  text_values_for_marker_scanner(self, marker, list)
  list
end