Class: SbuilderSexp::Statement
- Inherits:
-
Root
- Object
- Treetop::Runtime::SyntaxNode
- Root
- SbuilderSexp::Statement
- Defined in:
- lib/parser/parser_nodes.rb
Overview
Tree node with ‘Label’ and Unlabeled statement
Direct Known Subclasses
Instance Method Summary collapse
-
#find_labelnode ⇒ Object
Locate ‘Label’ as direct child.
-
#get_statement ⇒ UnlabeledStatement:TreeNode
TLA -language statement.
- #node_value ⇒ Object
-
#statement_label ⇒ Label:SyntaxTree
Label assigned to the statement (nil if no label).
-
#statement_val ⇒ string
The value for traserval.
-
#statements ⇒ Object
tree structure (for compund statments).
- #traverse(memo = "", &blk) ⇒ Object
Methods inherited from Treetop::Runtime::SyntaxNode
#node_type, #recursive_inject, #recursive_inject_parent, #recursive_select, #value
Instance Method Details
#find_labelnode ⇒ Object
Locate ‘Label’ as direct child. Compound statements may contain statement, which are also labeled, and we cannot just do ‘recursive_select’
865 866 867 868 869 870 871 872 873 874 875 |
# File 'lib/parser/parser_nodes.rb', line 865 def find_labelnode # return labelnode = recursive_select( SbuilderSexp::Label ).first if !elements.nil? then elements.each do |e| return e if e.is_a?( SbuilderSexp::Label ) end end # Label node not found nil end |
#get_statement ⇒ UnlabeledStatement:TreeNode
Returns TLA -language statement.
885 886 887 888 |
# File 'lib/parser/parser_nodes.rb', line 885 def get_statement ret = recursive_select( SbuilderSexp::UnlabeledStatement ).first ret end |
#node_value ⇒ Object
919 920 921 |
# File 'lib/parser/parser_nodes.rb', line 919 def node_value statement_val end |
#statement_label ⇒ Label:SyntaxTree
Returns label assigned to the statement (nil if no label).
878 879 880 881 882 |
# File 'lib/parser/parser_nodes.rb', line 878 def statement_label labelnode = find_labelnode return labelnode.label if labelnode return nil end |
#statement_val ⇒ string
Returns the value for traserval.
900 901 902 |
# File 'lib/parser/parser_nodes.rb', line 900 def statement_val nil end |
#statements ⇒ Object
tree structure (for compund statments)
891 892 893 |
# File 'lib/parser/parser_nodes.rb', line 891 def statements nil end |
#traverse(memo = "", &blk) ⇒ Object
904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
# File 'lib/parser/parser_nodes.rb', line 904 def traverse( memo="", &blk ) # visit label as 'Statement' node memo = yield( memo, node_type, self ) if statement_label # visit the real thing 'as object sekf' uls = get_statement # raise "No unlabeled_statement statement found #{self} from \n '#{inspect}' " unless uls memo = yield( memo, uls.node_type, uls ) if uls statements.each{ |s| memo = s.traverse( memo, &blk ) } if statements memo end |