-
Notifications
You must be signed in to change notification settings - Fork 1
/
nodes.rb
42 lines (33 loc) · 902 Bytes
/
nodes.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Nodes < Struct.new(:nodes)
def <<(node)
nodes << node
self
end
end
class LiteralNode < Struct.new(:value); end
class NumberNode < LiteralNode; end
class StringNode < LiteralNode; end
class ArrayNode < LiteralNode; end
class TrueNode < LiteralNode
def initialize
super(true)
end
end
class FalseNode < LiteralNode
def initialize
super(false)
end
end
class NilNode < LiteralNode
def initialize
super(nil)
end
end
class CallNode < Struct.new(:receiver, :method, :arguments); end
class GetConstantNode < Struct.new(:name); end
class SetConstantNode < Struct.new(:name, :value); end
class SetLocalNode < Struct.new(:name, :value); end
class DefNode < Struct.new(:name, :params, :body); end
class ClassNode < Struct.new(:name, :body, :super_class); end
class IfNode < Struct.new(:condition, :body); end
class WhileNode < Struct.new(:condition, :body); end