Module: TlaParserS::LValue

Instance Method Summary collapse

Instance Method Details

#default_lvalue(memo, node) ⇒ Object

default implmentation for ‘recurse_lvalue’ when no block: create expression



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/parser/lvalue.rb', line 8

def default_lvalue( memo, node )
  case node.node_type
  when  "LValue"
  # when 'Identifier', "LValue"        
  memo = node.lvalue
  # when 'RecordField'
  #   memo = memo ? "#{memo}.#{node.lvalue}" : node.lvalue
  # when 'RecordFieldName'
  #   memo = memo ? "#{memo}[#{node.lvalue}]" : node.lvalue
  when 'UnitExpression'
  # no output - just recurs
  when 'FieldByName'
    memo = "#{memo}.#{node.lvalue}"
  when 'FieldByValue'
    memo = "#{memo}[#{node.lvalue}]"        
  else
    raise "Lvalue recursion, parser error unkown node_type #{node_type} #{node.inspect}" 
  end
  memo
end

#lvalueString

Returns lvalue.

Returns:

  • (String)

    lvalue



30
31
32
33
34
# File 'lib/parser/lvalue.rb', line 30

def lvalue
  # n = recursive_select( SbuilderSexp::Root ).first
  # return nil unless n
  recursive_select( SbuilderSexp::Identifier ).first.node_value
end

#recurse_lvalue(ret = nil, &blk) ⇒ String

Recurse down ‘RecordField’ structure and create string for lvalue or yield block with ‘ret’ and ‘node’.

Parameters:

  • ret (Object|String) (defaults to: nil)

    to create in recursion

Returns:

  • (String)

    like A, A.b, A, A.e



42
43
44
45
46
47
48
49
50
51
# File 'lib/parser/lvalue.rb', line 42

def recurse_lvalue( ret=nil, &blk )
  if ( blk )
    ret = yield( ret, self )
  else
    ret = default_lvalue( ret, self )
  end
  ret = lvalue_down.recurse_lvalue( ret, &blk ) if lvalue_down
  ret
  
end