Module: TlaParserS::LValue
- Included in:
- SbuilderSexp::FieldByName, SbuilderSexp::FieldByValue, SbuilderSexp::Identifier, SbuilderSexp::LValue, SbuilderSexp::OriginalValue, SbuilderSexp::RecordField, SbuilderSexp::RecordFieldName, SbuilderSexp::UnitExpression
- Defined in:
- lib/parser/lvalue.rb
Instance Method Summary collapse
-
#default_lvalue(memo, node) ⇒ Object
default implmentation for ‘recurse_lvalue’ when no block: create expression.
-
#lvalue ⇒ String
Lvalue.
-
#recurse_lvalue(ret = nil, &blk) ⇒ String
Recurse down ‘RecordField’ structure and create string for lvalue or yield block with ‘ret’ and ‘node’.
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 |
#lvalue ⇒ String
Returns 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’.
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 |