summaryrefslogtreecommitdiff
path: root/etc/token_class_hierarchy.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-01-20 03:19:23 +0000
committermurphy <murphy@rubychan.de>2010-01-20 03:19:23 +0000
commit88a7c8532f3f86206c25c40b81fc2e25f6ae2593 (patch)
treedc4d585068fa320c94a4735061d683dc02446a91 /etc/token_class_hierarchy.rb
parent5d647876e01a0f279b8a434107ff89357d88e3ec (diff)
downloadcoderay-88a7c8532f3f86206c25c40b81fc2e25f6ae2593.tar.gz
Experiments with token classes.
Diffstat (limited to 'etc/token_class_hierarchy.rb')
-rw-r--r--etc/token_class_hierarchy.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/etc/token_class_hierarchy.rb b/etc/token_class_hierarchy.rb
new file mode 100644
index 0000000..4dc3f1f
--- /dev/null
+++ b/etc/token_class_hierarchy.rb
@@ -0,0 +1,22 @@
+class TokenClass
+ def self.const_missing name
+ const_set name, Class.new(self)
+ end
+ def self.method_missing name, &block
+ clas = const_missing name
+ if block
+ clas.instance_eval(&block)
+ end
+ end
+end
+
+class Comment < TokenClass
+ Multiline
+ class Shebang < self
+ Foo
+ end
+end
+
+p Comment::Blubb::Bla <= Comment::Blubb
+
+ObjectSpace.each_object(Class) { |o| p o if o < TokenClass } \ No newline at end of file