myco 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/bootstrap.my.rb +50 -14
  3. data/lib/myco/bootstrap/add_method.rb +5 -5
  4. data/lib/myco/bootstrap/meme.rb +2 -1
  5. data/lib/myco/code_tools/AST.my.rb +211 -43
  6. data/lib/myco/code_tools/AST/ArgumentAssembly.my.rb +92 -48
  7. data/lib/myco/code_tools/AST/ArrayAssembly.my.rb +39 -27
  8. data/lib/myco/code_tools/AST/Block.my.rb +176 -112
  9. data/lib/myco/code_tools/AST/BlockArgument.my.rb +29 -17
  10. data/lib/myco/code_tools/AST/BlockLiteral.my.rb +37 -17
  11. data/lib/myco/code_tools/AST/BlockParameter.my.rb +25 -9
  12. data/lib/myco/code_tools/AST/BranchOperator.my.rb +95 -75
  13. data/lib/myco/code_tools/AST/ConstantAccess.my.rb +52 -32
  14. data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +52 -36
  15. data/lib/myco/code_tools/AST/ConstantDefine.my.rb +50 -26
  16. data/lib/myco/code_tools/AST/DeclareCategory.my.rb +38 -18
  17. data/lib/myco/code_tools/AST/DeclareExtension.my.rb +29 -13
  18. data/lib/myco/code_tools/AST/DeclareFile.my.rb +51 -31
  19. data/lib/myco/code_tools/AST/DeclareMeme.my.rb +96 -68
  20. data/lib/myco/code_tools/AST/DeclareObject.my.rb +66 -42
  21. data/lib/myco/code_tools/AST/DeclareString.my.rb +39 -19
  22. data/lib/myco/code_tools/AST/DeclaredScope.my.rb +92 -64
  23. data/lib/myco/code_tools/AST/Invoke.my +8 -4
  24. data/lib/myco/code_tools/AST/Invoke.my.rb +74 -31
  25. data/lib/myco/code_tools/AST/InvokeMethod.my.rb +34 -14
  26. data/lib/myco/code_tools/AST/KeywordAssembly.my.rb +36 -24
  27. data/lib/myco/code_tools/AST/KeywordOptionalParameter.my.rb +28 -8
  28. data/lib/myco/code_tools/AST/KeywordRequiredParameter.my.rb +23 -7
  29. data/lib/myco/code_tools/AST/KeywordRestParameter.my.rb +23 -7
  30. data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my.rb +24 -12
  31. data/lib/myco/code_tools/AST/LocalVariableAssignment.my.rb +30 -10
  32. data/lib/myco/code_tools/AST/Node.my.rb +234 -102
  33. data/lib/myco/code_tools/AST/NumericLiteral.my.rb +18 -6
  34. data/lib/myco/code_tools/AST/OptionalParameter.my.rb +33 -13
  35. data/lib/myco/code_tools/AST/ParameterAssembly.my.rb +275 -211
  36. data/lib/myco/code_tools/AST/PipeOperator.my.rb +42 -18
  37. data/lib/myco/code_tools/AST/Quest.my.rb +65 -37
  38. data/lib/myco/code_tools/AST/RequiredParameter.my.rb +20 -4
  39. data/lib/myco/code_tools/AST/RestParameter.my.rb +20 -4
  40. data/lib/myco/code_tools/AST/Script.my.rb +51 -23
  41. data/lib/myco/code_tools/AST/Sequence.my.rb +22 -10
  42. data/lib/myco/code_tools/AST/SplatValue.my.rb +28 -16
  43. data/lib/myco/code_tools/AST/StringCompose.my.rb +23 -11
  44. data/lib/myco/code_tools/AST/StringLiteral.my.rb +19 -7
  45. data/lib/myco/code_tools/AST/SymbolCompose.my.rb +27 -15
  46. data/lib/myco/code_tools/AST/SymbolLiteral.my.rb +18 -6
  47. data/lib/myco/code_tools/AST/ToRuby.my.rb +581 -341
  48. data/lib/myco/code_tools/AST/misc.my.rb +87 -35
  49. data/lib/myco/code_tools/Parser.my.rb +39 -12
  50. data/lib/myco/code_tools/parser/MycoBuilder.my.rb +106 -90
  51. data/lib/myco/code_tools/parser/MycoCharacterClasses.my.rb +98 -50
  52. data/lib/myco/code_tools/parser/MycoGrammar.my +1 -6
  53. data/lib/myco/code_tools/parser/MycoGrammar.my.rb +2124 -1710
  54. data/lib/myco/code_tools/parser/MycoTokens.my +0 -5
  55. data/lib/myco/code_tools/parser/MycoTokens.my.rb +387 -156
  56. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my.rb +55 -11
  57. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +321 -205
  58. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my.rb +223 -127
  59. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my.rb +188 -72
  60. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common/Parser.my +48 -0
  61. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common/Parser.my.rb +365 -189
  62. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my.rb +313 -233
  63. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +99 -55
  64. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +493 -325
  65. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my.rb +138 -114
  66. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my.rb +56 -44
  67. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my.rb +173 -93
  68. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my.rb +90 -70
  69. data/lib/myco/command.my.rb +85 -25
  70. data/lib/myco/command/inoculate.my.rb +219 -127
  71. data/lib/myco/core.my.rb +20 -4
  72. data/lib/myco/core/BasicDecorators.my.rb +211 -119
  73. data/lib/myco/core/BasicObject.my.rb +108 -44
  74. data/lib/myco/core/Category.my.rb +37 -13
  75. data/lib/myco/core/Decorator.my.rb +35 -27
  76. data/lib/myco/core/FileToplevel.my.rb +55 -27
  77. data/lib/myco/core/Loop.my.rb +16 -8
  78. data/lib/myco/core/Object.my.rb +34 -14
  79. data/lib/myco/core/Ruby.my.rb +13 -5
  80. data/lib/myco/core/Switch.my.rb +79 -47
  81. data/lib/myco/tools/BasicCommand.my.rb +79 -47
  82. data/lib/myco/tools/mycompile.my.rb +153 -69
  83. data/lib/myco/version.rb +1 -1
  84. metadata +34 -52
  85. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +0 -144
  86. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +0 -221
  87. data/lib/myco/code_tools/parser/pegleromyces/spec/BasicSpec.my +0 -35
  88. data/lib/myco/code_tools/parser/pegleromyces/spec/BasicSpec.my.rb +0 -35
  89. data/lib/myco/code_tools/parser/pegleromyces/spec/Grammar.test.my +0 -10
  90. data/lib/myco/code_tools/parser/pegleromyces/spec/Grammar.test.my.rb +0 -9
  91. data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my +0 -162
  92. data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my.rb +0 -353
  93. data/lib/myco/code_tools/parser/pegleromyces/spec/Processor.test.my +0 -10
  94. data/lib/myco/code_tools/parser/pegleromyces/spec/Processor.test.my.rb +0 -9
  95. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my +0 -49
  96. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my.rb +0 -119
  97. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my +0 -131
  98. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my.rb +0 -595
  99. data/lib/myco/code_tools/parser/pegleromyces/spec/String/Parser.test.my +0 -120
  100. data/lib/myco/code_tools/parser/pegleromyces/spec/String/Parser.test.my.rb +0 -350
  101. data/lib/myco/code_tools/parser/pegleromyces/spec/run.my +0 -14
  102. data/lib/myco/code_tools/parser/pegleromyces/spec/run.my.rb +0 -12
@@ -1,15 +1,59 @@
1
1
 
2
2
  ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
3
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
4
- declare_meme(:"pegleromyces/Common.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
5
- declare_meme(:"pegleromyces/Capture.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
- declare_meme(:"pegleromyces/Composite.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
- declare_meme(:"pegleromyces/String.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
8
- declare_meme(:"pegleromyces/Stream.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
9
- declare_meme(:"pegleromyces/Grammar.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
10
- declare_meme(:"pegleromyces/BytecodeHelpers.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
11
- declare_meme(:"pegleromyces/Common/Parser.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
12
- declare_meme(:"pegleromyces/String/Parser.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
13
- declare_meme(:"pegleromyces/Stream/Parser.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
14
- declare_meme(:"pegleromyces/Processor.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
4
+ declare_meme(
5
+ :"pegleromyces/Common.my",
6
+ [:import],
7
+ ::Object::Proc.new { |*| nil}
8
+ )
9
+ declare_meme(
10
+ :"pegleromyces/Capture.my",
11
+ [:import],
12
+ ::Object::Proc.new { |*| nil}
13
+ )
14
+ declare_meme(
15
+ :"pegleromyces/Composite.my",
16
+ [:import],
17
+ ::Object::Proc.new { |*| nil}
18
+ )
19
+ declare_meme(
20
+ :"pegleromyces/String.my",
21
+ [:import],
22
+ ::Object::Proc.new { |*| nil}
23
+ )
24
+ declare_meme(
25
+ :"pegleromyces/Stream.my",
26
+ [:import],
27
+ ::Object::Proc.new { |*| nil}
28
+ )
29
+ declare_meme(
30
+ :"pegleromyces/Grammar.my",
31
+ [:import],
32
+ ::Object::Proc.new { |*| nil}
33
+ )
34
+ declare_meme(
35
+ :"pegleromyces/BytecodeHelpers.my",
36
+ [:import],
37
+ ::Object::Proc.new { |*| nil}
38
+ )
39
+ declare_meme(
40
+ :"pegleromyces/Common/Parser.my",
41
+ [:import],
42
+ ::Object::Proc.new { |*| nil}
43
+ )
44
+ declare_meme(
45
+ :"pegleromyces/String/Parser.my",
46
+ [:import],
47
+ ::Object::Proc.new { |*| nil}
48
+ )
49
+ declare_meme(
50
+ :"pegleromyces/Stream/Parser.my",
51
+ [:import],
52
+ ::Object::Proc.new { |*| nil}
53
+ )
54
+ declare_meme(
55
+ :"pegleromyces/Processor.my",
56
+ [:import],
57
+ ::Object::Proc.new { |*| nil}
58
+ )
15
59
  )}}.instance
@@ -2,218 +2,334 @@
2
2
  ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
3
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.cscope.for_method_definition::BytecodeHelpers = ::Myco::Component.new([::Myco.find_constant(:BasicDecorators)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
- declare_meme(:debug_mode, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (false)}
6
- declare_meme(:overall_fail, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (self.new_label)}
7
- declare_meme(:g, [], nil, ::Myco.cscope.dup) { |*| (self)}
8
- declare_meme(:puts_string, [], nil, ::Myco.cscope.dup) { |string| (
9
- self.g.push_rubinius
10
- self.g.push_literal(string)
11
- self.g.send(
12
- :puts,
13
- 1,
14
- true
15
- )
16
- self.g.pop
17
- )}
18
- declare_meme(:inspect_top, [], nil, ::Myco.cscope.dup) { |*| (
19
- self.g.dup_top
20
- self.g.push_rubinius
21
- self.g.swap
22
- self.g.send(
23
- :p,
24
- 1,
25
- true
26
- )
27
- self.g.pop
28
- )}
29
- declare_meme(:set_subject, [], nil, ::Myco.cscope.dup) { |*| (self.g.set_local(0))}
30
- declare_meme(:push_subject, [], nil, ::Myco.cscope.dup) { |*| (self.g.push_local(0))}
31
- declare_meme(:set_idx, [], nil, ::Myco.cscope.dup) { |*| (self.g.set_local(1))}
32
- declare_meme(:push_idx, [], nil, ::Myco.cscope.dup) { |*| (self.g.push_local(1))}
33
- declare_meme(:set_captures, [], nil, ::Myco.cscope.dup) { |*| (self.g.set_ivar(:@captures))}
34
- declare_meme(:push_captures, [], nil, ::Myco.cscope.dup) { |*| (self.g.push_ivar(:@captures))}
35
- declare_meme(:set_memo_for, [], nil, ::Myco.cscope.dup) { |name| (self.g.set_ivar(:"@memo_for_#{name}"))}
36
- declare_meme(:push_memo_for, [], nil, ::Myco.cscope.dup) { |name| (self.g.push_ivar(:"@memo_for_#{name}"))}
37
- declare_meme(:pop_to_set_idx, [], nil, ::Myco.cscope.dup) { |*| (
38
- self.g.set_idx
39
- self.g.pop
40
- )}
41
- declare_meme(:push_temp_captures, [], nil, ::Myco.cscope.dup) { |*| (
42
- self.g.push_captures
43
- self.g.make_array(0)
44
- self.g.set_captures
45
- self.g.pop
46
- )}
47
- declare_meme(:pop_to_reject_captures, [], nil, ::Myco.cscope.dup) { |*| (
48
- self.g.set_captures
49
- self.g.pop
50
- )}
51
- declare_meme(:pop_to_accept_captures, [], nil, ::Myco.cscope.dup) { |*| (
52
- self.g.push_captures
53
- self.g.send(
54
- :concat,
55
- 1
56
- )
57
- self.g.set_captures
58
- self.g.pop
59
- )}
60
- declare_meme(:push_subject_at_idx, [], nil, ::Myco.cscope.dup) { |*| (
61
- self.g.push_subject
62
- self.g.push_idx
63
- self.g.send(
64
- :at,
65
- 1
66
- )
67
- )}
68
- declare_meme(:push_subject_chr_at_idx, [], nil, ::Myco.cscope.dup) { |*| (
69
- self.g.push_subject
70
- self.g.push_idx
71
- self.g.send(
72
- :chr_at,
73
- 1
74
- )
75
- )}
76
- declare_meme(:push_new_table, [], nil, ::Myco.cscope.dup) { |*| (
77
- self.g.push_rubinius
78
- self.g.find_const(:LookupTable)
79
- self.g.send(
80
- :new,
81
- 0
82
- )
83
- )}
84
- declare_meme(:memo_or_eq_new_hash, [], nil, ::Myco.cscope.dup) { |name| (
85
- memo_exists_label = self.g.new_label
86
- self.g.push_memo_for(name)
87
- self.g.goto_if_true(memo_exists_label)
88
- self.g.push_new_table
89
- self.g.set_memo_for(name)
90
- self.g.pop
91
- memo_exists_label.__send__(:set!)
92
- )}
93
- declare_meme(:copy_result_to_memo, [], nil, ::Myco.cscope.dup) { |name| (
94
- self.g.dup_top
95
- self.g.push_captures
96
- self.g.make_array(2)
97
- self.g.push_memo_for(name)
98
- self.g.swap
99
- self.g.push_idx
100
- self.g.swap
101
- self.g.send(
102
- :[]=,
103
- 2
104
- )
105
- self.g.pop
106
- )}
107
- declare_meme(:goto_if_memo_for_idx, [], nil, ::Myco.cscope.dup) { |name, label| (
108
- skip_label = self.g.new_label
109
- self.g.push_memo_for(name)
110
- self.g.push_idx
111
- self.g.send(
112
- :[],
113
- 1
114
- )
115
- self.g.dup_top
116
- self.g.goto_if_nil(skip_label)
117
- self.g.shift_array
118
- self.g.swap
119
- self.g.shift_array
120
- self.g.set_captures
121
- self.g.pop
122
- self.g.pop
123
- self.g.goto(label)
124
- skip_label.__send__(:set!)
125
- self.g.pop
126
- )}
127
- declare_meme(:increment_idx, [], nil, ::Myco.cscope.dup) { |*| (
128
- self.g.push_idx
129
- self.g.send(
130
- :+,
131
- 1
132
- )
133
- self.g.set_idx
134
- self.g.dup_top
135
- self.g.push_ivar(:@highest_idx)
136
- self.g.send(
137
- :>,
138
- 1
139
- )
140
- not_highest_idx_label = self.g.new_label
141
- self.g.goto_if_false(not_highest_idx_label)
142
- self.g.set_ivar(:@highest_idx)
143
- not_highest_idx_label.__send__(:set!)
144
- self.g.pop
145
- )}
146
- declare_meme(:rule_start, [], nil, ::Myco.cscope.dup) { |*| (
147
- self.g.__send__(
148
- :required_args=,
149
- 2
150
- )
151
- self.g.__send__(
152
- :total_args=,
153
- 2
154
- )
155
- self.g.__send__(
156
- :splat_index=,
157
- nil
158
- )
159
- self.g.__send__(
160
- :local_count=,
161
- 2
162
- )
163
- self.g.__send__(
164
- :local_names=,
165
- [
166
- :subject,
167
- :idx
168
- ]
169
- )
170
- ::Myco.branch_op(:"&&", self.g.debug_mode) {(
5
+ declare_meme(
6
+ :debug_mode,
7
+ [:var],
8
+ ::Object::Proc.new { |*| (false)}
9
+ )
10
+ declare_meme(
11
+ :overall_fail,
12
+ [:var],
13
+ ::Object::Proc.new { |*| (self.new_label)}
14
+ )
15
+ declare_meme(
16
+ :g,
17
+ [],
18
+ ::Object::Proc.new { |*| (self)}
19
+ )
20
+ declare_meme(
21
+ :puts_string,
22
+ [],
23
+ ::Object::Proc.new { |string| (
24
+ self.g.push_rubinius
25
+ self.g.push_literal(string)
26
+ self.g.send(
27
+ :puts,
28
+ 1,
29
+ true
30
+ )
31
+ self.g.pop
32
+ )}
33
+ )
34
+ declare_meme(
35
+ :inspect_top,
36
+ [],
37
+ ::Object::Proc.new { |*| (
38
+ self.g.dup_top
39
+ self.g.push_rubinius
40
+ self.g.swap
41
+ self.g.send(
42
+ :p,
43
+ 1,
44
+ true
45
+ )
46
+ self.g.pop
47
+ )}
48
+ )
49
+ declare_meme(
50
+ :set_subject,
51
+ [],
52
+ ::Object::Proc.new { |*| (self.g.set_local(0))}
53
+ )
54
+ declare_meme(
55
+ :push_subject,
56
+ [],
57
+ ::Object::Proc.new { |*| (self.g.push_local(0))}
58
+ )
59
+ declare_meme(
60
+ :set_idx,
61
+ [],
62
+ ::Object::Proc.new { |*| (self.g.set_local(1))}
63
+ )
64
+ declare_meme(
65
+ :push_idx,
66
+ [],
67
+ ::Object::Proc.new { |*| (self.g.push_local(1))}
68
+ )
69
+ declare_meme(
70
+ :set_captures,
71
+ [],
72
+ ::Object::Proc.new { |*| (self.g.set_ivar(:@captures))}
73
+ )
74
+ declare_meme(
75
+ :push_captures,
76
+ [],
77
+ ::Object::Proc.new { |*| (self.g.push_ivar(:@captures))}
78
+ )
79
+ declare_meme(
80
+ :set_memo_for,
81
+ [],
82
+ ::Object::Proc.new { |name| (self.g.set_ivar(:"@memo_for_#{name}"))}
83
+ )
84
+ declare_meme(
85
+ :push_memo_for,
86
+ [],
87
+ ::Object::Proc.new { |name| (self.g.push_ivar(:"@memo_for_#{name}"))}
88
+ )
89
+ declare_meme(
90
+ :pop_to_set_idx,
91
+ [],
92
+ ::Object::Proc.new { |*| (
93
+ self.g.set_idx
94
+ self.g.pop
95
+ )}
96
+ )
97
+ declare_meme(
98
+ :push_temp_captures,
99
+ [],
100
+ ::Object::Proc.new { |*| (
101
+ self.g.push_captures
102
+ self.g.make_array(0)
103
+ self.g.set_captures
104
+ self.g.pop
105
+ )}
106
+ )
107
+ declare_meme(
108
+ :pop_to_reject_captures,
109
+ [],
110
+ ::Object::Proc.new { |*| (
111
+ self.g.set_captures
112
+ self.g.pop
113
+ )}
114
+ )
115
+ declare_meme(
116
+ :pop_to_accept_captures,
117
+ [],
118
+ ::Object::Proc.new { |*| (
119
+ self.g.push_captures
120
+ self.g.send(
121
+ :concat,
122
+ 1
123
+ )
124
+ self.g.set_captures
125
+ self.g.pop
126
+ )}
127
+ )
128
+ declare_meme(
129
+ :push_subject_at_idx,
130
+ [],
131
+ ::Object::Proc.new { |*| (
132
+ self.g.push_subject
171
133
  self.g.push_idx
172
- self.g.inspect_top
134
+ self.g.send(
135
+ :at,
136
+ 1
137
+ )
138
+ )}
139
+ )
140
+ declare_meme(
141
+ :push_subject_chr_at_idx,
142
+ [],
143
+ ::Object::Proc.new { |*| (
144
+ self.g.push_subject
145
+ self.g.push_idx
146
+ self.g.send(
147
+ :chr_at,
148
+ 1
149
+ )
150
+ )}
151
+ )
152
+ declare_meme(
153
+ :push_new_table,
154
+ [],
155
+ ::Object::Proc.new { |*| (
156
+ self.g.push_rubinius
157
+ self.g.find_const(:LookupTable)
158
+ self.g.send(
159
+ :new,
160
+ 0
161
+ )
162
+ )}
163
+ )
164
+ declare_meme(
165
+ :memo_or_eq_new_hash,
166
+ [],
167
+ ::Object::Proc.new { |name| (
168
+ memo_exists_label = self.g.new_label
169
+ self.g.push_memo_for(name)
170
+ self.g.goto_if_true(memo_exists_label)
171
+ self.g.push_new_table
172
+ self.g.set_memo_for(name)
173
+ self.g.pop
174
+ memo_exists_label.__send__(:set!)
175
+ )}
176
+ )
177
+ declare_meme(
178
+ :copy_result_to_memo,
179
+ [],
180
+ ::Object::Proc.new { |name| (
181
+ self.g.dup_top
182
+ self.g.push_captures
183
+ self.g.make_array(2)
184
+ self.g.push_memo_for(name)
185
+ self.g.swap
186
+ self.g.push_idx
187
+ self.g.swap
188
+ self.g.send(
189
+ :[]=,
190
+ 2
191
+ )
192
+ self.g.pop
193
+ )}
194
+ )
195
+ declare_meme(
196
+ :goto_if_memo_for_idx,
197
+ [],
198
+ ::Object::Proc.new { |name, label| (
199
+ skip_label = self.g.new_label
200
+ self.g.push_memo_for(name)
201
+ self.g.push_idx
202
+ self.g.send(
203
+ :[],
204
+ 1
205
+ )
206
+ self.g.dup_top
207
+ self.g.goto_if_nil(skip_label)
208
+ self.g.shift_array
209
+ self.g.swap
210
+ self.g.shift_array
211
+ self.g.set_captures
212
+ self.g.pop
213
+ self.g.pop
214
+ self.g.goto(label)
215
+ skip_label.__send__(:set!)
173
216
  self.g.pop
174
- self.g.puts_string("trying.. #{self.g.name}")
175
217
  )}
176
- )}
177
- declare_meme(:rule_finish, [], nil, ::Myco.cscope.dup) { |*| (
178
- overall_done = self.g.new_label
179
- self.g.push_idx
180
- ::Myco.branch_op(:"&&", self.g.debug_mode) {(
218
+ )
219
+ declare_meme(
220
+ :increment_idx,
221
+ [],
222
+ ::Object::Proc.new { |*| (
181
223
  self.g.push_idx
182
- self.g.inspect_top
224
+ self.g.send(
225
+ :+,
226
+ 1
227
+ )
228
+ self.g.set_idx
229
+ self.g.dup_top
230
+ self.g.push_ivar(:@highest_idx)
231
+ self.g.send(
232
+ :>,
233
+ 1
234
+ )
235
+ not_highest_idx_label = self.g.new_label
236
+ self.g.goto_if_false(not_highest_idx_label)
237
+ self.g.set_ivar(:@highest_idx)
238
+ not_highest_idx_label.__send__(:set!)
183
239
  self.g.pop
184
- self.g.puts_string("SUCCESS! #{self.g.name}")
185
240
  )}
186
- self.g.goto(overall_done)
187
- self.g.overall_fail.__send__(:set!)
188
- self.g.push_nil
189
- ::Myco.branch_op(:"&&", self.g.debug_mode) {(
241
+ )
242
+ declare_meme(
243
+ :rule_start,
244
+ [],
245
+ ::Object::Proc.new { |*| (
246
+ self.g.__send__(
247
+ :required_args=,
248
+ 2
249
+ )
250
+ self.g.__send__(
251
+ :total_args=,
252
+ 2
253
+ )
254
+ self.g.__send__(
255
+ :splat_index=,
256
+ nil
257
+ )
258
+ self.g.__send__(
259
+ :local_count=,
260
+ 2
261
+ )
262
+ self.g.__send__(
263
+ :local_names=,
264
+ [
265
+ :subject,
266
+ :idx
267
+ ]
268
+ )
269
+ ::Myco.branch_op(:"&&", self.g.debug_mode) {(
270
+ self.g.push_idx
271
+ self.g.inspect_top
272
+ self.g.pop
273
+ self.g.puts_string("trying.. #{self.g.name}")
274
+ )}
275
+ )}
276
+ )
277
+ declare_meme(
278
+ :rule_finish,
279
+ [],
280
+ ::Object::Proc.new { |*| (
281
+ overall_done = self.g.new_label
190
282
  self.g.push_idx
191
- self.g.inspect_top
283
+ ::Myco.branch_op(:"&&", self.g.debug_mode) {(
284
+ self.g.push_idx
285
+ self.g.inspect_top
286
+ self.g.pop
287
+ self.g.puts_string("SUCCESS! #{self.g.name}")
288
+ )}
289
+ self.g.goto(overall_done)
290
+ self.g.overall_fail.__send__(:set!)
291
+ self.g.push_nil
292
+ ::Myco.branch_op(:"&&", self.g.debug_mode) {(
293
+ self.g.push_idx
294
+ self.g.inspect_top
295
+ self.g.pop
296
+ self.g.puts_string("failure: #{self.g.name}")
297
+ )}
298
+ overall_done.__send__(:set!)
299
+ self.g.ret
300
+ self.g.close
301
+ )}
302
+ )
303
+ declare_meme(
304
+ :push_literal_array,
305
+ [],
306
+ ::Object::Proc.new { |ary| (
307
+ ary.each { |lit| (self.g.push_literal_or_array(lit))}
308
+ self.make_array(ary.size)
309
+ )}
310
+ )
311
+ declare_meme(
312
+ :push_literal_or_array,
313
+ [],
314
+ ::Object::Proc.new { |item| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", item.__send__(
315
+ :is_a?,
316
+ ::Myco.find_constant(:Array)
317
+ )) {self.push_literal_array(item)}) {self.push_literal(item)})}
318
+ )
319
+ declare_meme(
320
+ :capture,
321
+ [],
322
+ ::Object::Proc.new { |*metadata| (
323
+ self.g.push_captures
324
+ self.g.push_idx
325
+ self.g.push_literal_array(metadata)
326
+ self.g.make_array(2)
327
+ self.g.send(
328
+ :push,
329
+ 1
330
+ )
192
331
  self.g.pop
193
- self.g.puts_string("failure: #{self.g.name}")
194
- )}
195
- overall_done.__send__(:set!)
196
- self.g.ret
197
- self.g.close
198
- )}
199
- declare_meme(:push_literal_array, [], nil, ::Myco.cscope.dup) { |ary| (
200
- ary.each { |lit| (self.g.push_literal_or_array(lit))}
201
- self.make_array(ary.size)
202
- )}
203
- declare_meme(:push_literal_or_array, [], nil, ::Myco.cscope.dup) { |item| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", item.__send__(
204
- :is_a?,
205
- ::Myco.find_constant(:Array)
206
- )) {self.push_literal_array(item)}) {self.push_literal(item)})}
207
- declare_meme(:capture, [], nil, ::Myco.cscope.dup) { |*metadata| (
208
- self.g.push_captures
209
- self.g.push_idx
210
- self.g.push_literal_array(metadata)
211
- self.g.make_array(2)
212
- self.g.send(
213
- :push,
214
- 1
215
- )
216
- self.g.pop
217
- )}
332
+ )}
333
+ )
218
334
  )}}
219
335
  .tap { |__c__| __c__.__name__ = :BytecodeHelpers })}}.instance