Class: C::Label
Direct Known Subclasses
Constant Summary
Constants inherited from Node
Instance Attribute Summary
Attributes inherited from Node
Class Method Summary collapse
Methods inherited from Node
#==, #=~, abstract, add_field, #assert_invariants, #attached?, child, #clone, #depth_first, #detach, #detached?, #dup, #each, #eql?, field, #fields, fields, #hash, inherited, initializer, #insert_next, #insert_prev, #inspect, inspect1, #list_next, #list_prev, #match?, #method_missing, new_at, #next, #node_after, #node_before, #postorder, #preorder, #prev, #remove_node, #replace_node, #replace_with, #reverse_depth_first, #reverse_each, #reverse_postorder, #reverse_preorder, subclasses_recursive, #swap_with
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class C::Node
Class Method Details
.parse(s, parser = nil) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/cast/parse.rb', line 191 def self.parse(s, parser=nil) parser ||= C.default_parser ents = parser.parse("void f() {switch (0) #{s};}").entities if ents.length == 1 && # } void f() { ents[0].def.stmts.length == 1 && # ; ents[0].def.stmts[0].stmt && # ents[0].def.stmts[0].stmt.labels.length == 1 && # x ents[0].def.stmts[0].stmt.labels[0].is_a?(self) return ents[0].def.stmts[0].stmt.labels[0].detach else raise ParseError, "invalid #{self}" end end |