myco 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/code_loader.rb +1 -1
  3. data/lib/myco/parser/ast/ToRuby.my +400 -0
  4. data/lib/myco/parser/ast/ToRuby.my.rb +574 -0
  5. data/lib/myco/parser/ast.rb +1 -1
  6. data/lib/myco/version.rb +1 -1
  7. data/lib/myco.rb +24 -2
  8. metadata +3 -40
  9. data/lib/myco/parser/ast/to_ruby/array_assembly.rb +0 -15
  10. data/lib/myco/parser/ast/to_ruby/block.rb +0 -14
  11. data/lib/myco/parser/ast/to_ruby/block_pass.rb +0 -6
  12. data/lib/myco/parser/ast/to_ruby/branch_operator.rb +0 -9
  13. data/lib/myco/parser/ast/to_ruby/constant_access.rb +0 -10
  14. data/lib/myco/parser/ast/to_ruby/constant_assignment.rb +0 -6
  15. data/lib/myco/parser/ast/to_ruby/constant_define.rb +0 -9
  16. data/lib/myco/parser/ast/to_ruby/constant_reopen.rb +0 -6
  17. data/lib/myco/parser/ast/to_ruby/declare_category.rb +0 -7
  18. data/lib/myco/parser/ast/to_ruby/declare_decorator.rb +0 -6
  19. data/lib/myco/parser/ast/to_ruby/declare_file.rb +0 -6
  20. data/lib/myco/parser/ast/to_ruby/declare_meme.rb +0 -16
  21. data/lib/myco/parser/ast/to_ruby/declare_object.rb +0 -8
  22. data/lib/myco/parser/ast/to_ruby/declare_string.rb +0 -6
  23. data/lib/myco/parser/ast/to_ruby/dynamic_string.rb +0 -14
  24. data/lib/myco/parser/ast/to_ruby/dynamic_symbol.rb +0 -7
  25. data/lib/myco/parser/ast/to_ruby/eval_expression.rb +0 -6
  26. data/lib/myco/parser/ast/to_ruby/false_literal.rb +0 -6
  27. data/lib/myco/parser/ast/to_ruby/hash_literal.rb +0 -16
  28. data/lib/myco/parser/ast/to_ruby/invoke.rb +0 -6
  29. data/lib/myco/parser/ast/to_ruby/invoke_method.rb +0 -35
  30. data/lib/myco/parser/ast/to_ruby/iter.rb +0 -10
  31. data/lib/myco/parser/ast/to_ruby/local_variable_access_ambiguous.rb +0 -16
  32. data/lib/myco/parser/ast/to_ruby/local_variable_assignment.rb +0 -8
  33. data/lib/myco/parser/ast/to_ruby/myco_module_scope.rb +0 -8
  34. data/lib/myco/parser/ast/to_ruby/null_literal.rb +0 -6
  35. data/lib/myco/parser/ast/to_ruby/parameters.rb +0 -60
  36. data/lib/myco/parser/ast/to_ruby/quest.rb +0 -13
  37. data/lib/myco/parser/ast/to_ruby/return.rb +0 -7
  38. data/lib/myco/parser/ast/to_ruby/scoped_constant.rb +0 -11
  39. data/lib/myco/parser/ast/to_ruby/self.rb +0 -6
  40. data/lib/myco/parser/ast/to_ruby/splat_value.rb +0 -33
  41. data/lib/myco/parser/ast/to_ruby/string_literal.rb +0 -6
  42. data/lib/myco/parser/ast/to_ruby/symbol_literal.rb +0 -6
  43. data/lib/myco/parser/ast/to_ruby/toplevel_constant.rb +0 -11
  44. data/lib/myco/parser/ast/to_ruby/true_literal.rb +0 -6
  45. data/lib/myco/parser/ast/to_ruby/void_literal.rb +0 -6
  46. data/lib/myco/parser/ast/to_ruby.rb +0 -138
  47. data/lib/myco/toolset.rb +0 -13
@@ -0,0 +1,574 @@
1
+ ::Myco::Component.new([
2
+ ::Myco::FileToplevel
3
+ ], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ ::Myco.find_constant(:CodeTools)::AST.component_eval {(
6
+ ::Myco.cscope.for_method_definition.const_set(:ToRuby, ::Myco::Component.new([
7
+ ::Myco::Object
8
+ ], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
9
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
10
+ declare_meme(:lines, [
11
+ [:var, []]
12
+ ], nil, ::Myco.cscope.dup) { |*| (
13
+ [
14
+ ""
15
+ ]
16
+ )}
17
+ declare_meme(:to_s, [], nil, ::Myco.cscope.dup) { |*| (
18
+ self.lines.join("\n")
19
+ )}
20
+ declare_meme(:add, [], nil, ::Myco.cscope.dup) { |*strings| (
21
+ strings.each { |string| (
22
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", string.__send__(
23
+ :is_a?,
24
+ ::Myco.find_constant(:String)
25
+ )) {self.lines.last.concat(string.dup)}) {string.to_ruby(self)}
26
+ )}
27
+ )}
28
+ declare_meme(:line, [], nil, ::Myco.cscope.dup) { |*strings| (
29
+ self.lines.push(self.indents.last.dup)
30
+ self.add(*strings)
31
+ )}
32
+ declare_meme(:list, [], nil, ::Myco.cscope.dup) { |items, separator="", auto_lines:false, &block| (
33
+ ::Myco.branch_op(:"&&", items.__send__(:any?)) {(
34
+ items = items.dup
35
+ last_item = items.pop
36
+ use_lines = ::Myco.branch_op(:"&&", items.__send__(:any?)) {auto_lines}
37
+ ::Myco.branch_op(:"&&", use_lines) {self.push_indent}
38
+ items.each { |item| (
39
+ ::Myco.branch_op(:"&&", use_lines) {self.line}
40
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", block) {block.call(item)}) {self.add(item)}
41
+ self.add(separator)
42
+ )}
43
+ ::Myco.branch_op(:"&&", use_lines) {self.line}
44
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", block) {block.call(last_item)}) {self.add(last_item)}
45
+ ::Myco.branch_op(:"&&", use_lines) {self.pop_indent}
46
+ ::Myco.branch_op(:"&&", use_lines) {self.line}
47
+ )}
48
+ )}
49
+ declare_meme(:indents, [
50
+ [:var, []]
51
+ ], nil, ::Myco.cscope.dup) { |*| (
52
+ [
53
+ ""
54
+ ]
55
+ )}
56
+ declare_meme(:indent_amount, [
57
+ [:var, []]
58
+ ], nil, ::Myco.cscope.dup) { |*| (
59
+ 2
60
+ )}
61
+ declare_meme(:pop_indent, [], nil, ::Myco.cscope.dup) { |*| (
62
+ self.indents.pop
63
+ )}
64
+ declare_meme(:push_indent, [], nil, ::Myco.cscope.dup) { |amount=self.indent_amount| (
65
+ self.indents.push(self.indents.last.__send__(
66
+ :+,
67
+ " ".__send__(
68
+ :*,
69
+ amount
70
+ )
71
+ ))
72
+ )}
73
+ declare_meme(:var_scopes, [
74
+ [:var, []]
75
+ ], nil, ::Myco.cscope.dup) { |*| (
76
+ []
77
+ )}
78
+ declare_meme(:var_scope, [], nil, ::Myco.cscope.dup) { |*| (
79
+ self.var_scopes.last
80
+ )}
81
+ declare_meme(:with_nested_var_scope, [], nil, ::Myco.cscope.dup) { |node, &block| (
82
+ self.var_scopes.push(node)
83
+ block.call
84
+ self.var_scopes.pop
85
+ )}
86
+ declare_meme(:var_scope_declare_local, [], nil, ::Myco.cscope.dup) { |name| (
87
+ self.var_scope.variables.__send__(
88
+ :[]=,
89
+ name,
90
+ true
91
+ )
92
+ )}
93
+ declare_meme(:var_scope_declare_locals, [], nil, ::Myco.cscope.dup) { |*names| (
94
+ names.each { |name| (
95
+ self.var_scope_declare_local(name)
96
+ )}
97
+ )}
98
+ declare_meme(:var_scope_has_local?, [], nil, ::Myco.cscope.dup) { |name| (
99
+ self.var_scopes.reverse.detect { |scope| (
100
+ scope.variables.__send__(
101
+ :has_key?,
102
+ name
103
+ )
104
+ )}.__send__(:!).__send__(:!)
105
+ )}
106
+ declare_meme(:easy_ident?, [], nil, ::Myco.cscope.dup) { |sym| (
107
+ str = sym.to_s
108
+ ::Myco.branch_op(:"&&", str.__send__(
109
+ :=~,
110
+ ::Myco.find_constant(:Regexp).new("^[a-z_][A-Za-z_]*$")
111
+ )) {[
112
+ :if,
113
+ :unless,
114
+ :and,
115
+ :or,
116
+ :def,
117
+ :do,
118
+ :class,
119
+ :module,
120
+ :end,
121
+ :break,
122
+ :begin,
123
+ :rescue,
124
+ :ensure
125
+ ].__send__(
126
+ :include?,
127
+ sym
128
+ ).__send__(:!)}
129
+ )}
130
+ )}})
131
+ .tap { |__c__| __c__.__name__ = :ToRuby }
132
+ ::Myco.find_constant(:Node).component_eval {(
133
+ declare_meme(:to_ruby_code, [], nil, ::Myco.cscope.dup) { |*| (
134
+ g = ::Myco.find_constant(:ToRuby).new
135
+ self.to_ruby(g)
136
+ g.to_s
137
+ )}
138
+ )}
139
+ ::Myco.find_constant(:Self).component_eval {(
140
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
141
+ g.add("self")
142
+ )}
143
+ )}
144
+ ::Myco.find_constant(:NullLiteral).component_eval {(
145
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
146
+ g.add("nil")
147
+ )}
148
+ )}
149
+ ::Myco.find_constant(:VoidLiteral).component_eval {(
150
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
151
+ g.add("::Myco::Void")
152
+ )}
153
+ )}
154
+ ::Myco.find_constant(:TrueLiteral).component_eval {(
155
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
156
+ g.add("true")
157
+ )}
158
+ )}
159
+ ::Myco.find_constant(:FalseLiteral).component_eval {(
160
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
161
+ g.add("false")
162
+ )}
163
+ )}
164
+ ::Myco.find_constant(:StringLiteral).component_eval {(
165
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
166
+ g.add(self.string.inspect)
167
+ )}
168
+ )}
169
+ ::Myco.find_constant(:SymbolLiteral).component_eval {(
170
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
171
+ g.add(self.value.inspect)
172
+ )}
173
+ )}
174
+ ::Myco.find_constant(:DynamicString).component_eval {(
175
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
176
+ inspect_escape = ::Myco.find_constant(:Proc).new { |str| (
177
+ str.inspect.slice(::Range.new(
178
+ 1,
179
+ -2
180
+ ))
181
+ )}
182
+ g.add("\"")
183
+ g.add(inspect_escape.call(self.string))
184
+ self.array.each_slice(2) { |interpolated, inner_string| (
185
+ g.add("\#{")
186
+ g.add(interpolated.value)
187
+ g.add("}")
188
+ g.add(inspect_escape.call(inner_string.value))
189
+ )}
190
+ g.add("\"")
191
+ )}
192
+ )}
193
+ ::Myco.find_constant(:DynamicSymbol).component_eval {(
194
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
195
+ g.add(":")
196
+ ::Myco.find_constant(:DynamicString).instance_method(:to_ruby).bind(self).call(g)
197
+ )}
198
+ )}
199
+ ::Myco.find_constant(:HashLiteral).component_eval {(
200
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
201
+ g.add("{")
202
+ g.list(
203
+ self.array.each_slice(2).to_a,
204
+ ",",
205
+ {
206
+ :auto_lines => true
207
+ }
208
+ ) { |pair| (
209
+ g.add(
210
+ pair.first,
211
+ " => ",
212
+ pair.last
213
+ )
214
+ )}
215
+ g.add("}")
216
+ )}
217
+ )}
218
+ ::Myco.find_constant(:ArrayAssembly).component_eval {(
219
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
220
+ g.add("[")
221
+ g.list(
222
+ self.body,
223
+ ",",
224
+ {
225
+ :auto_lines => true
226
+ }
227
+ )
228
+ g.add("]")
229
+ )}
230
+ )}
231
+ ::Myco.find_constant(:ScopedConstant).component_eval {(
232
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
233
+ g.add(self.parent)
234
+ g.add("::#{self.name}")
235
+ )}
236
+ declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
237
+ self.to_ruby(g)
238
+ g.add(" = ")
239
+ g.add(value)
240
+ )}
241
+ )}
242
+ ::Myco.find_constant(:ToplevelConstant).component_eval {(
243
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
244
+ g.add("::#{self.name}")
245
+ )}
246
+ declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
247
+ self.to_ruby(g)
248
+ g.add(" = ")
249
+ g.add(value)
250
+ )}
251
+ )}
252
+ ::Myco.find_constant(:ConstantAccess).component_eval {(
253
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
254
+ g.add("::Myco.find_constant(#{self.name.inspect})")
255
+ )}
256
+ declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
257
+ g.add("::Myco.cscope.for_method_definition.const_set(#{self.name.inspect}, ")
258
+ g.add(value)
259
+ g.add(")")
260
+ )}
261
+ )}
262
+ ::Myco.find_constant(:ConstantAssignment).component_eval {(
263
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
264
+ self.constant.to_ruby_assign(
265
+ g,
266
+ self.value
267
+ )
268
+ )}
269
+ )}
270
+ ::Myco.find_constant(:ConstantDefine).component_eval {(
271
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
272
+ g.add(self.implementation)
273
+ g.line(".tap { |__c__| __c__.__name__ = ")
274
+ g.add(self.name.name.inspect)
275
+ g.add(" }")
276
+ )}
277
+ )}
278
+ ::Myco.find_constant(:ConstantReopen).component_eval {(
279
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
280
+ g.add(self.name)
281
+ g.add(".component_eval {")
282
+ g.add(self.body)
283
+ g.add("}")
284
+ )}
285
+ )}
286
+ ::Myco.find_constant(:MycoModuleScope).component_eval {(
287
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
288
+ g.with_nested_var_scope(self) { || (
289
+ g.add(self.body)
290
+ )}
291
+ )}
292
+ )}
293
+ ::Myco.find_constant(:EvalExpression).component_eval {(
294
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
295
+ g.add(self.body)
296
+ )}
297
+ )}
298
+ ::Myco.find_constant(:DeclareFile).component_eval {(
299
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
300
+ self.implementation.to_ruby(g)
301
+ )}
302
+ )}
303
+ ::Myco.find_constant(:DeclareObject).component_eval {(
304
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
305
+ g.add("::Myco::Component.new(")
306
+ g.add(self.types)
307
+ g.add(", ::Myco.cscope.for_method_definition, __FILE__, __LINE__)")
308
+ g.line(".tap { |__c__| __c__.__last__ = __c__.component_eval {")
309
+ g.add(self.scope_implementation)
310
+ g.add("}}")
311
+ ::Myco.branch_op(:"&&", self.create) {g.add(".instance")}
312
+ )}
313
+ )}
314
+ ::Myco.find_constant(:DeclareString).component_eval {(
315
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
316
+ g.add(self.implementation)
317
+ )}
318
+ )}
319
+ ::Myco.find_constant(:DeclareCategory).component_eval {(
320
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
321
+ g.add("__category__(#{self.name.value.inspect})")
322
+ g.add(".component_eval {")
323
+ g.add(self.body)
324
+ g.add("}")
325
+ )}
326
+ )}
327
+ ::Myco.find_constant(:DeclareMeme).component_eval {(
328
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
329
+ g.with_nested_var_scope(self.body_implementation) { || (
330
+ g.var_scope_declare_locals(*self.arguments.names)
331
+ g.add("declare_meme(")
332
+ g.add("#{self.name.inspect}, ")
333
+ g.add(self.decorations)
334
+ g.add(", nil, ::Myco.cscope.dup)")
335
+ g.add(" { ")
336
+ g.add(self.arguments)
337
+ g.add(" ")
338
+ g.add(self.body)
339
+ g.add("}")
340
+ )}
341
+ )}
342
+ )}
343
+ ::Myco.find_constant(:DeclareDecorator).component_eval {(
344
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
345
+ g.add("[#{self.name.value.inspect}, ")
346
+ g.add(self.arguments)
347
+ g.add("]")
348
+ )}
349
+ )}
350
+ ::Myco.find_constant(:Parameters).component_eval {(
351
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
352
+ list = []
353
+ list_add = ::Myco.find_constant(:Proc).new { |&blk| (
354
+ list.push(::Myco.find_constant(:Proc).new(&blk))
355
+ )}
356
+ self.required.each { |item| (
357
+ list_add.call { || (
358
+ g.add(item.to_s)
359
+ )}
360
+ )}
361
+ ::Myco.branch_op(:"&?", self.defaults) {self.defaults.arguments.each { |asgn| (
362
+ name = asgn.name
363
+ value = asgn.value
364
+ list_add.call { || (
365
+ g.add("#{name}=")
366
+ ::Myco.branch_op(:"||", ::Myco.branch_op(:"&&", value.__send__(
367
+ :is_a?,
368
+ ::Myco.find_constant(:SymbolLiteral)
369
+ )) {value.value.__send__(
370
+ :==,
371
+ :*
372
+ )}) {g.add(value)}
373
+ )}
374
+ )}}
375
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.splat.__send__(
376
+ :==,
377
+ :*
378
+ )) {list_add.call { || (
379
+ g.add("*")
380
+ )}}) {::Myco.branch_op(:"&?", self.splat) {list_add.call { || (
381
+ g.add("*#{self.splat}")
382
+ )}}}
383
+ ::Myco.branch_op(:"&?", self.keywords) {(
384
+ self.keywords.arguments.each { |asgn| (
385
+ name = asgn.name
386
+ value = asgn.value
387
+ list_add.call { || (
388
+ g.add("#{name}:")
389
+ ::Myco.branch_op(:"||", ::Myco.branch_op(:"&&", value.__send__(
390
+ :is_a?,
391
+ ::Myco.find_constant(:SymbolLiteral)
392
+ )) {value.value.__send__(
393
+ :==,
394
+ :*
395
+ )}) {g.add(value)}
396
+ )}
397
+ )}
398
+ ::Myco.branch_op(:"&?", ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.keywords.kwrest.__send__(
399
+ :==,
400
+ true
401
+ )) {list_add.call { || (
402
+ g.add("**")
403
+ )}}) {self.keywords.kwrest}) {list_add.call { || (
404
+ g.add("**#{self.keywords.kwrest.name}")
405
+ )}}
406
+ )}
407
+ ::Myco.branch_op(:"&?", self.block_arg) {list_add.call { || (
408
+ g.add("&#{self.block_arg.name}")
409
+ )}}
410
+ g.add("|")
411
+ g.list(
412
+ list,
413
+ ", "
414
+ ) { |proc| (
415
+ proc.call
416
+ )}
417
+ g.add("|")
418
+ )}
419
+ )}
420
+ ::Myco.find_constant(:Block).component_eval {(
421
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
422
+ g.add("(")
423
+ g.list(
424
+ self.array,
425
+ "",
426
+ {
427
+ :auto_lines => true
428
+ }
429
+ )
430
+ g.add(")")
431
+ )}
432
+ )}
433
+ ::Myco.find_constant(:Invoke).component_eval {(
434
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
435
+ g.add(self.implementation)
436
+ )}
437
+ )}
438
+ ::Myco.find_constant(:InvokeMethod).component_eval {(
439
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
440
+ list = ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.arguments) {self.arguments.body.dup}) {[]}
441
+ ::Myco.branch_op(:"&&", self.arguments.block.__send__(
442
+ :is_a?,
443
+ ::Myco.find_constant(:BlockPass)
444
+ )) {list.push(self.arguments.block)}
445
+ g.add(self.receiver)
446
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
447
+ :easy_ident?,
448
+ self.name
449
+ )) {g.add(".#{self.name}")}) {(
450
+ g.add(".__send__")
451
+ list.unshift(::Myco.find_constant(:SymbolLiteral).new(
452
+ self.line,
453
+ self.name
454
+ ))
455
+ )}
456
+ ::Myco.branch_op(:"&&", list.__send__(:any?)) {(
457
+ g.add("(")
458
+ g.list(
459
+ list,
460
+ ",",
461
+ {
462
+ :auto_lines => true
463
+ }
464
+ )
465
+ g.add(")")
466
+ )}
467
+ ::Myco.branch_op(:"&&", self.arguments.block.__send__(
468
+ :is_a?,
469
+ ::Myco.find_constant(:Iter)
470
+ )) {(
471
+ g.add(" {")
472
+ g.add(self.arguments.block)
473
+ g.add("}")
474
+ )}
475
+ )}
476
+ )}
477
+ ::Myco.find_constant(:LocalVariableAssignment).component_eval {(
478
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
479
+ g.var_scope_declare_local(self.name)
480
+ g.var_scope.variables.__send__(
481
+ :[]=,
482
+ self.name,
483
+ true
484
+ )
485
+ g.add(self.name.to_s)
486
+ g.add(" = ")
487
+ g.add(self.value)
488
+ )}
489
+ )}
490
+ ::Myco.find_constant(:LocalVariableAccessAmbiguous).component_eval {(
491
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
492
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
493
+ :var_scope_has_local?,
494
+ self.name
495
+ )) {g.add(self.name.to_s)}) {(
496
+ g.add("self")
497
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
498
+ :easy_ident?,
499
+ self.name
500
+ )) {g.add(".#{self.name}")}) {g.add(".__send__(#{self.name.inspect})")}
501
+ )}
502
+ )}
503
+ )}
504
+ ::Myco.find_constant(:SplatValue).component_eval {(
505
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
506
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.value.__send__(
507
+ :is_a?,
508
+ self.__send__(:class)
509
+ )) {self.value.to_ruby(g)}) {(
510
+ g.add("*")
511
+ self.value.to_ruby(g)
512
+ )}
513
+ )}
514
+ )}
515
+ ::Myco.find_constant(:CollectSplat).component_eval {(
516
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil}
517
+ )}
518
+ ::Myco.find_constant(:ConcatArgs).component_eval {(
519
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil}
520
+ )}
521
+ ::Myco.find_constant(:PushArgs).component_eval {(
522
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil}
523
+ )}
524
+ ::Myco.find_constant(:BlockPass).component_eval {(
525
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
526
+ g.add("&")
527
+ g.add(self.body)
528
+ )}
529
+ )}
530
+ ::Myco.find_constant(:Iter).component_eval {(
531
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
532
+ g.with_nested_var_scope(self) { || (
533
+ g.var_scope_declare_locals(*self.arguments.names)
534
+ g.add(" ")
535
+ g.add(self.arguments)
536
+ g.add(" ")
537
+ g.add(self.body)
538
+ )}
539
+ )}
540
+ )}
541
+ ::Myco.find_constant(:Quest).component_eval {(
542
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
543
+ associated_questable = self.questable.dup
544
+ associated_questable.__send__(
545
+ :receiver=,
546
+ self.receiver
547
+ )
548
+ g.add("(")
549
+ g.add(self.receiver)
550
+ g.add(".respond_to?(#{self.questable.name.inspect}).false?")
551
+ g.add(" ? ::Myco::Void : ")
552
+ g.add(associated_questable)
553
+ g.add(")")
554
+ )}
555
+ )}
556
+ ::Myco.find_constant(:BranchOperator).component_eval {(
557
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
558
+ g.add("::Myco.branch_op(")
559
+ g.add(self.type.inspect)
560
+ g.add(", ")
561
+ g.add(self.left)
562
+ g.add(") {")
563
+ g.add(self.right)
564
+ g.add("}")
565
+ )}
566
+ )}
567
+ ::Myco.find_constant(:Return).component_eval {(
568
+ declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
569
+ g.add("return ")
570
+ g.add(self.value)
571
+ )}
572
+ )}
573
+ )}
574
+ )}}.instance
@@ -18,4 +18,4 @@ require_relative "ast/branch_operator"
18
18
 
19
19
  require_relative "ast/misc"
20
20
 
21
- require_relative "ast/to_ruby"
21
+ Myco.eval_file 'ast/ToRuby.my'
data/lib/myco/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Myco
3
- MYCO_VERSION = '0.1.1'
3
+ MYCO_VERSION = '0.1.2'
4
4
 
5
5
  MYCO_REQUIRED_GEMS = [
6
6
  ['rubinius-toolset', '~> 2.3'],
data/lib/myco.rb CHANGED
@@ -2,8 +2,6 @@
2
2
  require_relative 'myco/version'
3
3
  Myco.activate_required_gems
4
4
 
5
- require_relative 'myco/toolset'
6
- require_relative 'myco/parser'
7
5
  require_relative 'myco/code_loader'
8
6
  require_relative 'myco/eval'
9
7
  require_relative 'myco/misc'
@@ -15,3 +13,27 @@ Myco.rescue do
15
13
  Myco::CoreLoadPath = File.expand_path('myco', File.dirname(__FILE__))
16
14
  Myco.eval_file 'myco/bootstrap.my'
17
15
  end
16
+
17
+ # Load the boot toolset from (possibly old) cached bytecode files
18
+ module Myco
19
+ ToolSet = Rubinius::ToolSets.create :myco_boot do
20
+ require "rubinius/melbourne"
21
+ require "rubinius/processor"
22
+ require "rubinius/compiler"
23
+ require "rubinius/ast"
24
+
25
+ require_relative 'myco/parser'
26
+ end
27
+ end
28
+
29
+ # Load the runtime toolset from the latest code
30
+ module Myco
31
+ ToolSet = Rubinius::ToolSets.create :myco do
32
+ require "rubinius/melbourne"
33
+ require "rubinius/processor"
34
+ require "rubinius/compiler"
35
+ require "rubinius/ast"
36
+
37
+ require_relative 'myco/parser'
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain
@@ -223,6 +223,8 @@ files:
223
223
  - lib/myco/misc.rb
224
224
  - lib/myco/parser.rb
225
225
  - lib/myco/parser/ast.rb
226
+ - lib/myco/parser/ast/ToRuby.my
227
+ - lib/myco/parser/ast/ToRuby.my.rb
226
228
  - lib/myco/parser/ast/argument_assembly.rb
227
229
  - lib/myco/parser/ast/array_assembly.rb
228
230
  - lib/myco/parser/ast/branch_operator.rb
@@ -241,50 +243,11 @@ files:
241
243
  - lib/myco/parser/ast/misc.rb
242
244
  - lib/myco/parser/ast/myco_module_scope.rb
243
245
  - lib/myco/parser/ast/quest.rb
244
- - lib/myco/parser/ast/to_ruby.rb
245
- - lib/myco/parser/ast/to_ruby/array_assembly.rb
246
- - lib/myco/parser/ast/to_ruby/block.rb
247
- - lib/myco/parser/ast/to_ruby/block_pass.rb
248
- - lib/myco/parser/ast/to_ruby/branch_operator.rb
249
- - lib/myco/parser/ast/to_ruby/constant_access.rb
250
- - lib/myco/parser/ast/to_ruby/constant_assignment.rb
251
- - lib/myco/parser/ast/to_ruby/constant_define.rb
252
- - lib/myco/parser/ast/to_ruby/constant_reopen.rb
253
- - lib/myco/parser/ast/to_ruby/declare_category.rb
254
- - lib/myco/parser/ast/to_ruby/declare_decorator.rb
255
- - lib/myco/parser/ast/to_ruby/declare_file.rb
256
- - lib/myco/parser/ast/to_ruby/declare_meme.rb
257
- - lib/myco/parser/ast/to_ruby/declare_object.rb
258
- - lib/myco/parser/ast/to_ruby/declare_string.rb
259
- - lib/myco/parser/ast/to_ruby/dynamic_string.rb
260
- - lib/myco/parser/ast/to_ruby/dynamic_symbol.rb
261
- - lib/myco/parser/ast/to_ruby/eval_expression.rb
262
- - lib/myco/parser/ast/to_ruby/false_literal.rb
263
- - lib/myco/parser/ast/to_ruby/hash_literal.rb
264
- - lib/myco/parser/ast/to_ruby/invoke.rb
265
- - lib/myco/parser/ast/to_ruby/invoke_method.rb
266
- - lib/myco/parser/ast/to_ruby/iter.rb
267
- - lib/myco/parser/ast/to_ruby/local_variable_access_ambiguous.rb
268
- - lib/myco/parser/ast/to_ruby/local_variable_assignment.rb
269
- - lib/myco/parser/ast/to_ruby/myco_module_scope.rb
270
- - lib/myco/parser/ast/to_ruby/null_literal.rb
271
- - lib/myco/parser/ast/to_ruby/parameters.rb
272
- - lib/myco/parser/ast/to_ruby/quest.rb
273
- - lib/myco/parser/ast/to_ruby/return.rb
274
- - lib/myco/parser/ast/to_ruby/scoped_constant.rb
275
- - lib/myco/parser/ast/to_ruby/self.rb
276
- - lib/myco/parser/ast/to_ruby/splat_value.rb
277
- - lib/myco/parser/ast/to_ruby/string_literal.rb
278
- - lib/myco/parser/ast/to_ruby/symbol_literal.rb
279
- - lib/myco/parser/ast/to_ruby/toplevel_constant.rb
280
- - lib/myco/parser/ast/to_ruby/true_literal.rb
281
- - lib/myco/parser/ast/to_ruby/void_literal.rb
282
246
  - lib/myco/parser/peg_parser.rb
283
247
  - lib/myco/tools/BasicCommand.my
284
248
  - lib/myco/tools/BasicCommand.my.rb
285
249
  - lib/myco/tools/mycompile.my
286
250
  - lib/myco/tools/mycompile.my.rb
287
- - lib/myco/toolset.rb
288
251
  - lib/myco/version.rb
289
252
  homepage: https://github.com/jemc/myco/
290
253
  licenses: