Class: Treetop::Runtime::SyntaxNode
- Inherits:
-
Object
- Object
- Treetop::Runtime::SyntaxNode
- Defined in:
- lib/origen_verilog/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
100 101 102 103 104 105 106 107 108 |
# File 'lib/origen_verilog/node.rb', line 100 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
117 118 119 |
# File 'lib/origen_verilog/node.rb', line 117 def file Treetop.origen_verilog_parser.file end |
#n(type, *children) ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/origen_verilog/node.rb', line 91 def n(type, *children) properties = children.pop if children.last.is_a?(Hash) properties ||= {} properties[:input] ||= input properties[:interval] ||= interval properties[:file] ||= file Treetop.origen_verilog_parser.node.new(type, children, properties) end |
#number_of_lines(elmnts = elements) ⇒ Object
110 111 112 113 114 115 |
# File 'lib/origen_verilog/node.rb', line 110 def number_of_lines(elmnts = elements) elmnts.inject(0) do |sum, e| lines = e.text_value.split("\n").size sum + lines end end |