Class: Treetop::Runtime::SyntaxNode
- Inherits:
-
Object
- Object
- Treetop::Runtime::SyntaxNode
- Defined in:
- lib/origen_stil/syntax/node.rb
Instance Method Summary collapse
- #elements_to_ast(elmnts = elements) ⇒ Object
- #file ⇒ Object
- #n(type, *children) ⇒ Object
- #number_of_lines(elmnts = elements) ⇒ Object
Instance Method Details
#elements_to_ast(elmnts = elements) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/origen_stil/syntax/node.rb', line 94 def elements_to_ast(elmnts = elements) elmnts.map do |e| if e.respond_to?(:to_ast) e.to_ast elsif e.nonterminal? && !e.elements.empty? elements_to_ast(e.elements) end end.compact.flatten end |
#file ⇒ Object
111 112 113 |
# File 'lib/origen_stil/syntax/node.rb', line 111 def file OrigenSTIL::Syntax::Parser.file end |
#n(type, *children) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/origen_stil/syntax/node.rb', line 85 def n(type, *children) properties = children.pop if children.last.is_a?(Hash) properties ||= {} properties[:input] ||= input properties[:interval] ||= interval properties[:file] ||= file OrigenSTIL::Syntax::Node.new(type, children, properties) end |
#number_of_lines(elmnts = elements) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/origen_stil/syntax/node.rb', line 104 def number_of_lines(elmnts = elements) elmnts.inject(0) do |sum, e| lines = e.text_value.split("\n").size sum + lines end end |