mutant-melbourne 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +25 -0
- data/README.md +69 -0
- data/Rakefile +14 -0
- data/ext/melbourne/.gitignore +3 -0
- data/ext/melbourne/bstring-license.txt +29 -0
- data/ext/melbourne/bstrlib.c +2687 -0
- data/ext/melbourne/bstrlib.h +267 -0
- data/ext/melbourne/encoding_compat.cpp +188 -0
- data/ext/melbourne/encoding_compat.hpp +57 -0
- data/ext/melbourne/extconf.rb +87 -0
- data/ext/melbourne/grammar18.cpp +11280 -0
- data/ext/melbourne/grammar18.hpp +13 -0
- data/ext/melbourne/grammar18.y +6088 -0
- data/ext/melbourne/grammar19.cpp +12420 -0
- data/ext/melbourne/grammar19.hpp +11 -0
- data/ext/melbourne/grammar19.y +7113 -0
- data/ext/melbourne/lex.c.blt +152 -0
- data/ext/melbourne/lex.c.tab +136 -0
- data/ext/melbourne/local_state.hpp +43 -0
- data/ext/melbourne/melbourne.cpp +88 -0
- data/ext/melbourne/melbourne.hpp +19 -0
- data/ext/melbourne/node18.hpp +262 -0
- data/ext/melbourne/node19.hpp +271 -0
- data/ext/melbourne/node_types.rb +304 -0
- data/ext/melbourne/node_types18.cpp +255 -0
- data/ext/melbourne/node_types18.hpp +129 -0
- data/ext/melbourne/node_types19.cpp +249 -0
- data/ext/melbourne/node_types19.hpp +126 -0
- data/ext/melbourne/parser_state18.hpp +181 -0
- data/ext/melbourne/parser_state19.hpp +251 -0
- data/ext/melbourne/quark.cpp +42 -0
- data/ext/melbourne/quark.hpp +45 -0
- data/ext/melbourne/symbols.cpp +224 -0
- data/ext/melbourne/symbols.hpp +119 -0
- data/ext/melbourne/var_table18.cpp +83 -0
- data/ext/melbourne/var_table18.hpp +33 -0
- data/ext/melbourne/var_table19.cpp +65 -0
- data/ext/melbourne/var_table19.hpp +35 -0
- data/ext/melbourne/visitor18.cpp +963 -0
- data/ext/melbourne/visitor18.hpp +12 -0
- data/ext/melbourne/visitor19.cpp +960 -0
- data/ext/melbourne/visitor19.hpp +15 -0
- data/lib/compiler/ast/constants.rb +81 -0
- data/lib/compiler/ast/control_flow.rb +290 -0
- data/lib/compiler/ast/data.rb +14 -0
- data/lib/compiler/ast/definitions.rb +749 -0
- data/lib/compiler/ast/encoding.rb +18 -0
- data/lib/compiler/ast/exceptions.rb +138 -0
- data/lib/compiler/ast/file.rb +11 -0
- data/lib/compiler/ast/grapher.rb +89 -0
- data/lib/compiler/ast/literals.rb +207 -0
- data/lib/compiler/ast/node.rb +362 -0
- data/lib/compiler/ast/operators.rb +106 -0
- data/lib/compiler/ast/self.rb +15 -0
- data/lib/compiler/ast/sends.rb +615 -0
- data/lib/compiler/ast/transforms.rb +298 -0
- data/lib/compiler/ast/values.rb +88 -0
- data/lib/compiler/ast/variables.rb +351 -0
- data/lib/compiler/ast.rb +20 -0
- data/lib/compiler/locals.rb +109 -0
- data/lib/melbourne/processor.rb +651 -0
- data/lib/melbourne/version.rb +3 -0
- data/lib/melbourne.rb +143 -0
- metadata +112 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
#ifndef MEL_VISITOR19_HPP
|
2
|
+
#define MEL_VISITOR19_HPP
|
3
|
+
|
4
|
+
namespace melbourne {
|
5
|
+
namespace grammar19 {
|
6
|
+
rb_parser_state *parser_alloc_state();
|
7
|
+
void *pt_allocate(rb_parser_state *st, int size);
|
8
|
+
void pt_free(rb_parser_state *st);
|
9
|
+
|
10
|
+
void create_error(rb_parser_state *parser_state, char *msg);
|
11
|
+
};
|
12
|
+
};
|
13
|
+
|
14
|
+
#endif
|
15
|
+
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# -*- encoding: us-ascii -*-
|
2
|
+
|
3
|
+
module Rubinius
|
4
|
+
module AST
|
5
|
+
|
6
|
+
class TypeConstant < Node
|
7
|
+
def initialize(line)
|
8
|
+
@line = line
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class ScopedConstant < Node
|
13
|
+
attr_accessor :parent, :name
|
14
|
+
|
15
|
+
def initialize(line, parent, name)
|
16
|
+
@line = line
|
17
|
+
@parent = parent
|
18
|
+
@name = name
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_sexp
|
22
|
+
[:colon2, @parent.to_sexp, @name]
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method :assign_sexp, :to_sexp
|
26
|
+
end
|
27
|
+
|
28
|
+
class ToplevelConstant < Node
|
29
|
+
attr_accessor :name
|
30
|
+
|
31
|
+
def initialize(line, name)
|
32
|
+
@line = line
|
33
|
+
@name = name
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_sexp
|
37
|
+
[:colon3, @name]
|
38
|
+
end
|
39
|
+
|
40
|
+
alias_method :assign_sexp, :to_sexp
|
41
|
+
end
|
42
|
+
|
43
|
+
class ConstantAccess < Node
|
44
|
+
attr_accessor :name
|
45
|
+
|
46
|
+
def initialize(line, name)
|
47
|
+
@line = line
|
48
|
+
@name = name
|
49
|
+
end
|
50
|
+
|
51
|
+
def assign_sexp
|
52
|
+
@name
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_sexp
|
56
|
+
[:const, @name]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class ConstantAssignment < Node
|
61
|
+
attr_accessor :constant, :value
|
62
|
+
|
63
|
+
def initialize(line, expr, value)
|
64
|
+
@line = line
|
65
|
+
@value = value
|
66
|
+
|
67
|
+
if expr.kind_of? Symbol
|
68
|
+
@constant = ConstantAccess.new line, expr
|
69
|
+
else
|
70
|
+
@constant = expr
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def to_sexp
|
75
|
+
sexp = [:cdecl, @constant.assign_sexp]
|
76
|
+
sexp << @value.to_sexp if @value
|
77
|
+
sexp
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,290 @@
|
|
1
|
+
# -*- encoding: us-ascii -*-
|
2
|
+
|
3
|
+
module Rubinius
|
4
|
+
module AST
|
5
|
+
class Case < Node
|
6
|
+
attr_accessor :whens, :else
|
7
|
+
|
8
|
+
def initialize(line, whens, else_body)
|
9
|
+
@line = line
|
10
|
+
@whens = whens
|
11
|
+
@else = else_body || NilLiteral.new(line)
|
12
|
+
end
|
13
|
+
|
14
|
+
def receiver_sexp
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_sexp
|
19
|
+
else_sexp = @else.kind_of?(NilLiteral) ? nil : @else.to_sexp
|
20
|
+
sexp = [:case, receiver_sexp]
|
21
|
+
sexp << [:whens] + @whens.map { |x| x.to_sexp }
|
22
|
+
sexp << else_sexp
|
23
|
+
sexp
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class ReceiverCase < Case
|
28
|
+
attr_accessor :receiver
|
29
|
+
|
30
|
+
def initialize(line, receiver, whens, else_body)
|
31
|
+
@line = line
|
32
|
+
@receiver = receiver
|
33
|
+
@whens = whens
|
34
|
+
@else = else_body || NilLiteral.new(line)
|
35
|
+
end
|
36
|
+
|
37
|
+
def receiver_sexp
|
38
|
+
@receiver.to_sexp
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class When < Node
|
43
|
+
attr_accessor :conditions, :body, :single, :splat
|
44
|
+
|
45
|
+
def initialize(line, conditions, body)
|
46
|
+
@line = line
|
47
|
+
@body = body || NilLiteral.new(line)
|
48
|
+
@splat = nil
|
49
|
+
@single = nil
|
50
|
+
|
51
|
+
if conditions.kind_of? ConcatArgs
|
52
|
+
@splat = SplatWhen.new line, conditions.rest
|
53
|
+
conditions = conditions.array
|
54
|
+
end
|
55
|
+
|
56
|
+
if conditions.kind_of? ArrayLiteral
|
57
|
+
if conditions.body.last.kind_of? When
|
58
|
+
last = conditions.body.pop
|
59
|
+
if last.conditions.kind_of? ArrayLiteral
|
60
|
+
conditions.body.concat last.conditions.body
|
61
|
+
elsif last.single
|
62
|
+
@splat = SplatWhen.new line, last.single
|
63
|
+
else
|
64
|
+
@splat = SplatWhen.new line, last.conditions
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
if conditions.body.size == 1 and !@splat
|
69
|
+
@single = conditions.body.first
|
70
|
+
else
|
71
|
+
@conditions = conditions
|
72
|
+
end
|
73
|
+
elsif conditions.kind_of? SplatValue
|
74
|
+
@splat = SplatWhen.new line, conditions.value
|
75
|
+
@conditions = nil
|
76
|
+
else
|
77
|
+
@conditions = conditions
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_sexp
|
82
|
+
if @single
|
83
|
+
conditions_sexp = [:array, @single.to_sexp]
|
84
|
+
else
|
85
|
+
conditions_sexp = @conditions.to_sexp
|
86
|
+
conditions_sexp << @splat.to_sexp if @splat
|
87
|
+
end
|
88
|
+
[:when, conditions_sexp, @body.to_sexp]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class SplatWhen < Node
|
93
|
+
attr_accessor :condition
|
94
|
+
|
95
|
+
def initialize(line, condition)
|
96
|
+
@line = line
|
97
|
+
@condition = condition
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_sexp
|
101
|
+
[:when, @condition.to_sexp, nil]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class Flip2 < Node
|
106
|
+
def initialize(line, start, finish)
|
107
|
+
@line = line
|
108
|
+
@start = start
|
109
|
+
@finish = finish
|
110
|
+
end
|
111
|
+
|
112
|
+
def sexp_name
|
113
|
+
:flip2
|
114
|
+
end
|
115
|
+
|
116
|
+
def exclusive?
|
117
|
+
false
|
118
|
+
end
|
119
|
+
|
120
|
+
def to_sexp
|
121
|
+
[sexp_name, @start.to_sexp, @finish.to_sexp]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class Flip3 < Flip2
|
126
|
+
def sexp_name
|
127
|
+
:flip3
|
128
|
+
end
|
129
|
+
|
130
|
+
def exclusive?
|
131
|
+
true
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
class If < Node
|
136
|
+
attr_accessor :condition, :body, :else
|
137
|
+
|
138
|
+
def initialize(line, condition, body, else_body)
|
139
|
+
@line = line
|
140
|
+
@condition = condition
|
141
|
+
@body = body || NilLiteral.new(line)
|
142
|
+
@else = else_body || NilLiteral.new(line)
|
143
|
+
end
|
144
|
+
|
145
|
+
def to_sexp
|
146
|
+
else_sexp = @else.kind_of?(NilLiteral) ? nil : @else.to_sexp
|
147
|
+
[:if, @condition.to_sexp, @body.to_sexp, else_sexp]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
class While < Node
|
152
|
+
attr_accessor :condition, :body, :check_first
|
153
|
+
|
154
|
+
def initialize(line, condition, body, check_first)
|
155
|
+
@line = line
|
156
|
+
@condition = condition
|
157
|
+
@body = body || NilLiteral.new(line)
|
158
|
+
@check_first = check_first
|
159
|
+
end
|
160
|
+
|
161
|
+
def sexp_name
|
162
|
+
:while
|
163
|
+
end
|
164
|
+
|
165
|
+
def to_sexp
|
166
|
+
[sexp_name, @condition.to_sexp, @body.to_sexp, @check_first]
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
class Until < While
|
171
|
+
def sexp_name
|
172
|
+
:until
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class Match < Node
|
177
|
+
attr_accessor :pattern
|
178
|
+
|
179
|
+
def initialize(line, pattern, flags)
|
180
|
+
@line = line
|
181
|
+
@pattern = RegexLiteral.new line, pattern, flags
|
182
|
+
end
|
183
|
+
|
184
|
+
def to_sexp
|
185
|
+
[:match, @pattern.to_sexp]
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
class Match2 < Node
|
190
|
+
attr_accessor :pattern, :value
|
191
|
+
|
192
|
+
def initialize(line, pattern, value)
|
193
|
+
@line = line
|
194
|
+
@pattern = pattern
|
195
|
+
@value = value
|
196
|
+
end
|
197
|
+
|
198
|
+
def to_sexp
|
199
|
+
[:match2, @pattern.to_sexp, @value.to_sexp]
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
class Match3 < Node
|
204
|
+
attr_accessor :pattern, :value
|
205
|
+
|
206
|
+
def initialize(line, pattern, value)
|
207
|
+
@line = line
|
208
|
+
@pattern = pattern
|
209
|
+
@value = value
|
210
|
+
end
|
211
|
+
|
212
|
+
def to_sexp
|
213
|
+
[:match3, @pattern.to_sexp, @value.to_sexp]
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
class Break < Node
|
218
|
+
attr_accessor :value
|
219
|
+
|
220
|
+
def initialize(line, expr)
|
221
|
+
@line = line
|
222
|
+
@value = expr || NilLiteral.new(line)
|
223
|
+
end
|
224
|
+
|
225
|
+
def jump_error(g, name)
|
226
|
+
g.push_rubinius
|
227
|
+
g.push_literal name
|
228
|
+
g.send :jump_error, 1
|
229
|
+
end
|
230
|
+
|
231
|
+
def sexp_name
|
232
|
+
:break
|
233
|
+
end
|
234
|
+
|
235
|
+
def to_sexp
|
236
|
+
sexp = [sexp_name]
|
237
|
+
sexp << @value.to_sexp if @value
|
238
|
+
sexp
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
class Next < Break
|
243
|
+
def initialize(line, value)
|
244
|
+
@line = line
|
245
|
+
@value = value
|
246
|
+
end
|
247
|
+
|
248
|
+
def sexp_name
|
249
|
+
:next
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
class Redo < Break
|
254
|
+
def initialize(line)
|
255
|
+
@line = line
|
256
|
+
end
|
257
|
+
|
258
|
+
def to_sexp
|
259
|
+
[:redo]
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
class Retry < Break
|
264
|
+
def initialize(line)
|
265
|
+
@line = line
|
266
|
+
end
|
267
|
+
|
268
|
+
def to_sexp
|
269
|
+
[:retry]
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
class Return < Node
|
274
|
+
attr_accessor :value
|
275
|
+
|
276
|
+
def initialize(line, expr)
|
277
|
+
@line = line
|
278
|
+
@value = expr
|
279
|
+
@splat = nil
|
280
|
+
end
|
281
|
+
|
282
|
+
def to_sexp
|
283
|
+
sexp = [:return]
|
284
|
+
sexp << @value.to_sexp if @value
|
285
|
+
sexp << @splat.to_sexp if @splat
|
286
|
+
sexp
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|