lib/keisan/ast/line_builder.rb
# Returns an array of the form
# [node, postfix_operators]
# middle_node is the main node which will be modified by prefix and postfix operators
# postfix_operators is an array of Keisan::Parsing::Indexing, DotWord, and DotOperator objects
Returns an array of the form
[node, postfix_operators]
middle_node is the main node which will be modified by prefix and postfix operators
postfix_operators is an array of Keisan::Parsing::Indexing, DotWord, and DotOperator objects
Returns an array of the form [ node postfix_operators ] middle_node is the main node which will be modified by prefix and postfix operators postfix_operators is an array of Keisan :: Parsing :: Indexing DotWord and DotOperator objects
def node_postfixes(components)
        index_of_postfix_components = components.map.with_index {|c,i| [c,i]}.select {|c,i|
          c.is_a?(Keisan::Parsing::Indexing) || c.is_a?(Keisan::Parsing::DotWord) || c.is_a?(Keisan::Parsing::DotOperator)
        }.map(&:last)
        unless index_of_postfix_components.reverse.map.with_index.all? {|i,j| i + j == components.size - 1 }
          raise Keisan::Exceptions::ASTError.new("postfix components must be in back")
        end
        num_postfix = index_of_postfix_components.size
        unless num_postfix + 1 == components.size
          raise Keisan::Exceptions::ASTError.new("have too many components")
        end
        [
          node_of_component(components[0]),
          index_of_postfix_components.map {|i| components[i]}
        ]
      end
def node_postfixes ( components ) index_of_postfix_components = components . map . with_index { | c , i | [ c , i ] } . select { | c , i | c . is_a? ( Keisan :: Parsing :: Indexing ) || c . is_a? ( Keisan :: Parsing :: DotWord ) || c . is_a? ( Keisan :: Parsing :: DotOperator ) } . map ( & :last ) unless index_of_postfix_components . reverse . map . with_index . all? { | i , j | i + j == components . size - 1 } raise Keisan :: Exceptions :: ASTError . new ( "postfix components must be in back" ) end num_postfix = index_of_postfix_components . size unless num_postfix + 1 == components . size raise Keisan :: Exceptions :: ASTError . new ( "have too many components" ) end [ node_of_component ( components [ 0 ] ) , index_of_postfix_components . map { | i | components [ i ] } ] end
Returns an array of the form
[node, postfix_operators]
middle_node is the main node which will be modified by prefix and postfix operators
postfix_operators is an array of Keisan::Parsing::Indexing, DotWord, and DotOperator objects
Returns an array of the form [ node postfix_operators ] middle_node is the main node which will be modified by prefix and postfix operators postfix_operators is an array of Keisan :: Parsing :: Indexing DotWord and DotOperator objects
components
<not_specific>