Class: BabelBridge::NonTerminalNode
- Includes:
- Enumerable
- Defined in:
- lib/babel_bridge/nodes/non_terminal_node.rb
Overview
subclassed automatically by parser.rule for each unique non-terminal
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Node
#delimiter, #many_delimiter, #match_length, #offset, #parent, #parser, #src
Instance Method Summary collapse
- #add_match(node) ⇒ Object
- #last_match ⇒ Object
- #length ⇒ Object
-
#matches ⇒ Object
***************************** Array interface implementation *****************************.
- #update_match_length ⇒ Object
Methods inherited from Node
#column, #init_line_column, #initialize, #inspect, #line, #match_range, #node_init, #node_path, #offset_after_match, #on_matched, #onlychildren_list, #parent_list, #path_string, #relative_class_name, #relative_source_file, #remaining_src, #source_file, #text, #to_s, #to_sym
Constructor Details
This class inherits a constructor from BabelBridge::Node
Instance Method Details
#add_match(node) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/babel_bridge/nodes/non_terminal_node.rb', line 32 def add_match(node) return if !node || node.kind_of?(EmptyNode) || node == self node.tap do matches << node update_match_length end end |
#last_match ⇒ Object
23 24 25 |
# File 'lib/babel_bridge/nodes/non_terminal_node.rb', line 23 def last_match matches[-1] end |
#length ⇒ Object
28 29 30 |
# File 'lib/babel_bridge/nodes/non_terminal_node.rb', line 28 def length matches.length end |
#matches ⇒ Object
***************************** Array interface implementation *****************************
19 20 21 |
# File 'lib/babel_bridge/nodes/non_terminal_node.rb', line 19 def matches @matches ||= [] end |
#update_match_length ⇒ Object
12 13 14 |
# File 'lib/babel_bridge/nodes/non_terminal_node.rb', line 12 def update_match_length @match_length = last_match ? last_match.offset_after_match - offset : 0 end |