class Treetop::Runtime::SyntaxNode
Each node in the AST produced by the treetop parser implements to_ruby
, which allows the Soroban
sheet to store the ruby version of the Excel contents of each cell in the sheet (and which also gathers and stores the dependencies that call has on other cells). Each concrete syntax node may override rewrite_ruby
and extract_labels.
Public Instance Methods
extract_labels(value)
click to toggle source
Return either a single label of the form :A1, or an array of labels of the form [:B1, :B2, …]. This is used to keep track of the dependencies of this particular cell.
# File lib/soroban/parser/rewrite.rb, line 31 def extract_labels(value) nil end
rewrite_ruby(value)
click to toggle source
Return the ruby version of the Excel value. By default this does nothing; see nodes.rb for concrete implementations.
# File lib/soroban/parser/rewrite.rb, line 24 def rewrite_ruby(value) value end
to_ruby(cell)
click to toggle source
# File lib/soroban/parser/rewrite.rb, line 10 def to_ruby(cell) if nonterminal? value = "" elements.each { |element| value << element.to_ruby(cell) } _add_dependency(cell, value) rewrite_ruby(value) else _add_dependency(cell, text_value) rewrite_ruby(text_value) end end
Private Instance Methods
_add_dependency(cell, value)
click to toggle source
# File lib/soroban/parser/rewrite.rb, line 37 def _add_dependency(cell, value) cell.add_dependencies(extract_labels(value)) end