lib/keisan/ast/line_builder.rb
# Array of AST elements, and Parsing operators
Array of AST elements, and Parsing operators
Array of AST elements and Parsing operators
def components_to_basic_nodes(components)
        nodes_components = []
        components.each do |component|
          if component.is_a?(Keisan::Parsing::LineSeparator)
            nodes_components << [component]
          elsif nodes_components.empty? || nodes_components.last.last.is_a?(Keisan::Parsing::LineSeparator)
            nodes_components << [component]
          else
            is_operator = [nodes_components.last.last.is_a?(Keisan::Parsing::Operator), component.is_a?(Keisan::Parsing::Operator)]
            if is_operator.first == is_operator.last
              nodes_components.last << component
            else
              nodes_components << [component]
            end
          end
        end
        nodes_components.inject([]) do |nodes, node_or_component_group|
          if node_or_component_group.first.is_a?(Keisan::Parsing::Operator)
            node_or_component_group.each do |component|
              nodes << component
            end
          else
            nodes << node_from_components(node_or_component_group)
          end
          nodes
        end
      end
def components_to_basic_nodes ( components ) nodes_components = [ ] components . each do | component | if component . is_a? ( Keisan :: Parsing :: LineSeparator ) nodes_components << [ component ] elsif nodes_components . empty? || nodes_components . last . last . is_a? ( Keisan :: Parsing :: LineSeparator ) nodes_components << [ component ] else is_operator = [ nodes_components . last . last . is_a? ( Keisan :: Parsing :: Operator ) , component . is_a? ( Keisan :: Parsing :: Operator ) ] if is_operator . first == is_operator . last nodes_components . last << component else nodes_components << [ component ] end end end nodes_components . inject ( [ ] ) do | nodes , node_or_component_group | if node_or_component_group . first . is_a? ( Keisan :: Parsing :: Operator ) node_or_component_group . each do | component | nodes << component end else nodes << node_from_components ( node_or_component_group ) end nodes end end
Array of AST elements, and Parsing operators
Array of AST elements and Parsing operators
components
<not_specific>