-
Notifications
You must be signed in to change notification settings - Fork 1
/
nodes.rb
48 lines (34 loc) · 876 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
43
44
45
46
47
48
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 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 ClassNode < Struct.new(:name, :body); end
class IfNode < Struct.new(:condition, :body); end
class WhileNode < Struct.new(:condition, :body); end
class DefNode < Struct.new(:name, :params, :body); end
class GetLocalNode < Struct.new(:name); end
class SetLocalNode < Struct.new(:name, :value); end
class CallNode < Struct.new(:receiver, :method, :arguments); end