Class: SbuilderSexp::AbstractSetExpression

Inherits:
AbstactExpression show all
Defined in:
lib/parser/parser_nodes.rb

Direct Known Subclasses

SetConstructor, SetExpression, SetExpressionMap

Instance Method Summary collapse

Methods inherited from AbstactExpression

#expression_postfix, #expression_prefix, #expressions, #has_rhs, #node_value, #rhs_node, #traverse

Methods inherited from Treetop::Runtime::SyntaxNode

#node_type, #node_value, #recursive_inject, #recursive_inject_parent, #recursive_select, #value

Instance Method Details

#binds_nodeBoundInExpression|nil

Return set generator ( x in Set ) for set constructor

generator variable and set

Returns:



619
620
621
622
623
624
625
# File 'lib/parser/parser_nodes.rb', line 619

def binds_node
  ret = recursive_select( SbuilderSexp::BoundInExpression ).first
  return nil unless ret
  ret = ret.recursive_select( SbuilderSexp::BoundInExpression ).first
  # puts ret
  ret
end

#expression_valObject

AbstactExpression.traverse calls in yield



611
612
613
# File 'lib/parser/parser_nodes.rb', line 611

def expression_val
  true
end

#lhs_nodeObject

AbstactExpression.traverse quit traversing the expression



606
607
608
# File 'lib/parser/parser_nodes.rb', line 606

def lhs_node
  nil
end

#nameString

For documentation purposes symbol table context needs a name (For procedures, and macros name is ovbious. For a set expression we define name set a string “Set+<generator set>”

Returns:

  • (String)

    name identifying context in symbol table



647
648
649
# File 'lib/parser/parser_nodes.rb', line 647

def name
  "Set-#{binds_node.bind_set.text_value}"
end

#set_elementsObject

Elements defined on constructore



637
638
639
640
# File 'lib/parser/parser_nodes.rb', line 637

def set_elements
  elems = recursive_select( SbuilderSexp::Expression )
  elems
end

#set_expressionObject



627
628
629
630
631
632
633
634
# File 'lib/parser/parser_nodes.rb', line 627

def set_expression 
  deffi = recursive_select( SbuilderSexp::SetExpressionDef )
  return nil unless deffi && deffi.any?
  ret = deffi.first.elements[0]
  # # ret = deffi.first.recursive_select( SbuilderSexp::SetExpression ).first
  # puts "set_expression=#{ret.inspect}"
  ret
end

#symbol_definitionsHash:Array

Some variables in ‘set_expression’ (most likely) refer to variable defined in set constructor generate. Return name of this variables.

Returns:

  • (Hash:Array)

    with :node_type,:value, :tree -properties



655
656
657
658
# File 'lib/parser/parser_nodes.rb', line 655

def symbol_definitions
  return [] unless binds_node
  [ { :node_type => node_type, :value => binds_node.bind_var.expression_val, :tree=>binds_node } ]
end