myco 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/myco/bootstrap/add_method.rb +38 -0
- data/lib/myco/bootstrap/component.rb +43 -21
- data/lib/myco/bootstrap/find_constant.rb +73 -25
- data/lib/myco/bootstrap/instance.rb +96 -25
- data/lib/myco/bootstrap/meme.rb +18 -12
- data/lib/myco/bootstrap/tuple.rb +13 -0
- data/lib/myco/bootstrap/undefined.rb +9 -0
- data/lib/myco/bootstrap/void.rb +5 -4
- data/lib/myco/bootstrap.my +24 -13
- data/lib/myco/bootstrap.my.rb +41 -4
- data/lib/myco/bootstrap.rb +4 -0
- data/lib/myco/code_loader.rb +11 -9
- data/lib/myco/code_tools/AST/Block.my.rb +2 -2
- data/lib/myco/code_tools/AST/ConstantAccess.my.rb +4 -4
- data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +4 -4
- data/lib/myco/code_tools/AST/Invoke.my +1 -1
- data/lib/myco/code_tools/AST/Invoke.my.rb +1 -1
- data/lib/myco/code_tools/AST/Node.my +2 -4
- data/lib/myco/code_tools/AST/Node.my.rb +3 -3
- data/lib/myco/code_tools/AST/PipeOperator.my.rb +1 -1
- data/lib/myco/code_tools/AST/ToRuby.my.rb +8 -8
- data/lib/myco/code_tools/AST/misc.my.rb +1 -1
- data/lib/myco/code_tools/Parser.my +8 -15
- data/lib/myco/code_tools/Parser.my.rb +8 -14
- data/lib/myco/code_tools/parser/MycoBuilder.my +3 -4
- data/lib/myco/code_tools/parser/MycoBuilder.my.rb +5 -6
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +8 -4
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +5 -5
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +2 -2
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +12 -12
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +54 -44
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my.rb +69 -83
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +18 -8
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +24 -10
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +1 -2
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +3 -3
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +5 -6
- data/lib/myco/code_tools/parser/pegleromyces/spec/BasicSpec.my +35 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BasicSpec.my.rb +35 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeParser.test.my +81 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeParser.test.my.rb +209 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my +229 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my.rb +663 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Grammar.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Grammar.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my +13 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my.rb +20 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my +54 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my.rb +215 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my +156 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my.rb +334 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Processor.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Processor.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my +20 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my.rb +16 -0
- data/lib/myco/core/BasicDecorators.my +19 -11
- data/lib/myco/core/BasicDecorators.my.rb +24 -20
- data/lib/myco/core/BasicObject.my +12 -7
- data/lib/myco/core/BasicObject.my.rb +50 -44
- data/lib/myco/core/Category.my +12 -2
- data/lib/myco/core/Category.my.rb +15 -7
- data/lib/myco/core/Decorator.my +1 -1
- data/lib/myco/core/Decorator.my.rb +8 -10
- data/lib/myco/core/FileToplevel.my +3 -3
- data/lib/myco/core/FileToplevel.my.rb +4 -6
- data/lib/myco/core/Object.my +7 -10
- data/lib/myco/core/Object.my.rb +11 -17
- data/lib/myco/core/Ruby.my +6 -0
- data/lib/myco/core/Ruby.my.rb +16 -0
- data/lib/myco/core/Switch.my +1 -1
- data/lib/myco/core/Switch.my.rb +1 -1
- data/lib/myco/core.my +4 -0
- data/lib/myco/core.my.rb +7 -0
- data/lib/myco/dev/call_sites.rb +39 -0
- data/lib/myco/dev/counter.rb +26 -0
- data/lib/myco/dev.rb +3 -0
- data/lib/myco/eval.rb +1 -1
- data/lib/myco/tools/BasicCommand.my.rb +1 -1
- data/lib/myco/version.rb +1 -1
- data/lib/myco.rb +2 -3
- metadata +53 -20
- data/lib/myco/bootstrap/evaluator.rb +0 -58
@@ -0,0 +1,334 @@
|
|
1
|
+
|
2
|
+
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::Component.new([::Myco.find_constant(:BasicSpec)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
4
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
5
|
+
declare_meme(:name, [], nil, ::Myco.cscope.dup) { |*| ("Patterns")}
|
6
|
+
declare_meme(:new_pattern, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Patterns)::Base], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
7
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}.instance)}
|
8
|
+
declare_meme(:shorthand, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Patterns)::ShorthandMethods], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
9
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}.instance)}
|
10
|
+
__category__(:tests).component_eval {(
|
11
|
+
declare_meme(:"knows its name", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (self.assert_equal(
|
12
|
+
self.new_pattern.name,
|
13
|
+
:new_pattern
|
14
|
+
))}
|
15
|
+
declare_meme(:"creates a NegativePredicate with the '!' unary operator", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
16
|
+
a = self.new_pattern
|
17
|
+
b = a.__send__(:!)
|
18
|
+
self.assert_is_a(
|
19
|
+
b,
|
20
|
+
::Myco.find_constant(:Patterns)::NegativePredicate
|
21
|
+
)
|
22
|
+
self.assert_equal(
|
23
|
+
b.inner,
|
24
|
+
a
|
25
|
+
)
|
26
|
+
)}
|
27
|
+
declare_meme(:"creates a PositivePredicate with two uses of the '!' unary operator", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
28
|
+
a = self.new_pattern
|
29
|
+
b = a.__send__(:!).__send__(:!)
|
30
|
+
self.assert_is_a(
|
31
|
+
b,
|
32
|
+
::Myco.find_constant(:Patterns)::PositivePredicate
|
33
|
+
)
|
34
|
+
self.assert_equal(
|
35
|
+
b.inner,
|
36
|
+
a
|
37
|
+
)
|
38
|
+
)}
|
39
|
+
declare_meme(:"creates a NegativePredicate with three uses of the '!' unary operator", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
40
|
+
a = self.new_pattern
|
41
|
+
b = a.__send__(:!).__send__(:!).__send__(:!)
|
42
|
+
self.assert_is_a(
|
43
|
+
b,
|
44
|
+
::Myco.find_constant(:Patterns)::NegativePredicate
|
45
|
+
)
|
46
|
+
self.assert_equal(
|
47
|
+
b.inner,
|
48
|
+
a
|
49
|
+
)
|
50
|
+
)}
|
51
|
+
declare_meme(:"creates an OrderedChoice with the '/' operator", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
52
|
+
a = self.new_pattern
|
53
|
+
b = self.new_pattern
|
54
|
+
c = a.__send__(
|
55
|
+
:/,
|
56
|
+
b
|
57
|
+
)
|
58
|
+
self.assert_is_a(
|
59
|
+
c,
|
60
|
+
::Myco.find_constant(:Patterns)::OrderedChoice
|
61
|
+
)
|
62
|
+
self.assert_equal(
|
63
|
+
c.first,
|
64
|
+
a
|
65
|
+
)
|
66
|
+
self.assert_equal(
|
67
|
+
c.second,
|
68
|
+
b
|
69
|
+
)
|
70
|
+
)}
|
71
|
+
declare_meme(:"interprets a series of OrderedChoices as a right-associative tree", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
72
|
+
a = self.new_pattern
|
73
|
+
b = self.new_pattern
|
74
|
+
c = self.new_pattern
|
75
|
+
d = self.new_pattern
|
76
|
+
e = a.__send__(
|
77
|
+
:/,
|
78
|
+
b
|
79
|
+
).__send__(
|
80
|
+
:/,
|
81
|
+
c
|
82
|
+
).__send__(
|
83
|
+
:/,
|
84
|
+
d
|
85
|
+
)
|
86
|
+
self.assert_is_a(
|
87
|
+
e,
|
88
|
+
::Myco.find_constant(:Patterns)::OrderedChoice
|
89
|
+
)
|
90
|
+
self.assert_is_a(
|
91
|
+
e.second,
|
92
|
+
::Myco.find_constant(:Patterns)::OrderedChoice
|
93
|
+
)
|
94
|
+
self.assert_is_a(
|
95
|
+
e.second.second,
|
96
|
+
::Myco.find_constant(:Patterns)::OrderedChoice
|
97
|
+
)
|
98
|
+
self.assert_equal(
|
99
|
+
e.first,
|
100
|
+
a
|
101
|
+
)
|
102
|
+
self.assert_equal(
|
103
|
+
e.second.first,
|
104
|
+
b
|
105
|
+
)
|
106
|
+
self.assert_equal(
|
107
|
+
e.second.second.first,
|
108
|
+
c
|
109
|
+
)
|
110
|
+
self.assert_equal(
|
111
|
+
e.second.second.second,
|
112
|
+
d
|
113
|
+
)
|
114
|
+
)}
|
115
|
+
declare_meme(:"creates a Concatenation with the '+' operator", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
116
|
+
a = self.new_pattern
|
117
|
+
b = self.new_pattern
|
118
|
+
c = a.__send__(
|
119
|
+
:+,
|
120
|
+
b
|
121
|
+
)
|
122
|
+
self.assert_is_a(
|
123
|
+
c,
|
124
|
+
::Myco.find_constant(:Patterns)::Concatenation
|
125
|
+
)
|
126
|
+
self.assert_equal(
|
127
|
+
c.first,
|
128
|
+
a
|
129
|
+
)
|
130
|
+
self.assert_equal(
|
131
|
+
c.second,
|
132
|
+
b
|
133
|
+
)
|
134
|
+
)}
|
135
|
+
declare_meme(:"interprets a series of Concatenations as a right-associative tree", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
136
|
+
a = self.new_pattern
|
137
|
+
b = self.new_pattern
|
138
|
+
c = self.new_pattern
|
139
|
+
d = self.new_pattern
|
140
|
+
e = a.__send__(
|
141
|
+
:+,
|
142
|
+
b
|
143
|
+
).__send__(
|
144
|
+
:+,
|
145
|
+
c
|
146
|
+
).__send__(
|
147
|
+
:+,
|
148
|
+
d
|
149
|
+
)
|
150
|
+
self.assert_is_a(
|
151
|
+
e,
|
152
|
+
::Myco.find_constant(:Patterns)::Concatenation
|
153
|
+
)
|
154
|
+
self.assert_is_a(
|
155
|
+
e.second,
|
156
|
+
::Myco.find_constant(:Patterns)::Concatenation
|
157
|
+
)
|
158
|
+
self.assert_is_a(
|
159
|
+
e.second.second,
|
160
|
+
::Myco.find_constant(:Patterns)::Concatenation
|
161
|
+
)
|
162
|
+
self.assert_equal(
|
163
|
+
e.first,
|
164
|
+
a
|
165
|
+
)
|
166
|
+
self.assert_equal(
|
167
|
+
e.second.first,
|
168
|
+
b
|
169
|
+
)
|
170
|
+
self.assert_equal(
|
171
|
+
e.second.second.first,
|
172
|
+
c
|
173
|
+
)
|
174
|
+
self.assert_equal(
|
175
|
+
e.second.second.second,
|
176
|
+
d
|
177
|
+
)
|
178
|
+
)}
|
179
|
+
declare_meme(:"creates a OneOrMore with the '+' operator used as a 'suffix' call", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
180
|
+
a = self.new_pattern
|
181
|
+
b = a.__send__(:+)
|
182
|
+
self.assert_is_a(
|
183
|
+
b,
|
184
|
+
::Myco.find_constant(:Patterns)::OneOrMore
|
185
|
+
)
|
186
|
+
self.assert_equal(
|
187
|
+
b.inner,
|
188
|
+
a
|
189
|
+
)
|
190
|
+
a = self.new_pattern.__send__(
|
191
|
+
:+,
|
192
|
+
self.new_pattern
|
193
|
+
)
|
194
|
+
b = a.__send__(:+)
|
195
|
+
self.assert_is_a(
|
196
|
+
b,
|
197
|
+
::Myco.find_constant(:Patterns)::OneOrMore
|
198
|
+
)
|
199
|
+
self.assert_equal(
|
200
|
+
b.inner,
|
201
|
+
a
|
202
|
+
)
|
203
|
+
)}
|
204
|
+
declare_meme(:"creates a ZeroOrOne with the '-' operator used as a 'suffix' call", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
205
|
+
a = self.new_pattern
|
206
|
+
b = a.__send__(:-)
|
207
|
+
self.assert_is_a(
|
208
|
+
b,
|
209
|
+
::Myco.find_constant(:Patterns)::ZeroOrOne
|
210
|
+
)
|
211
|
+
self.assert_equal(
|
212
|
+
b.inner,
|
213
|
+
a
|
214
|
+
)
|
215
|
+
)}
|
216
|
+
declare_meme(:"creates a ZeroOrMore with the '*' operator used as a 'suffix' call", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
217
|
+
a = self.new_pattern
|
218
|
+
b = a.__send__(:*)
|
219
|
+
self.assert_is_a(
|
220
|
+
b,
|
221
|
+
::Myco.find_constant(:Patterns)::ZeroOrMore
|
222
|
+
)
|
223
|
+
self.assert_equal(
|
224
|
+
b.inner,
|
225
|
+
a
|
226
|
+
)
|
227
|
+
)}
|
228
|
+
declare_meme(:"creates a NamedCapture with the '[]' operator, given a capture name", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
229
|
+
a = self.new_pattern
|
230
|
+
b = a.__send__(
|
231
|
+
:[],
|
232
|
+
:foo
|
233
|
+
)
|
234
|
+
self.assert_is_a(
|
235
|
+
b,
|
236
|
+
::Myco.find_constant(:Patterns)::NamedCapture
|
237
|
+
)
|
238
|
+
self.assert_equal(
|
239
|
+
b.inner,
|
240
|
+
a
|
241
|
+
)
|
242
|
+
self.assert_equal(
|
243
|
+
b.name,
|
244
|
+
:foo
|
245
|
+
)
|
246
|
+
)}
|
247
|
+
declare_meme(:"creates an AnyCharacter with the 'any' shorthand method", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
248
|
+
a = self.shorthand.any
|
249
|
+
self.assert_is_a(
|
250
|
+
a,
|
251
|
+
::Myco.find_constant(:Patterns)::AnyCharacter
|
252
|
+
)
|
253
|
+
)}
|
254
|
+
declare_meme(:"creates a Character with the 'char' shorthand method", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
255
|
+
a = self.shorthand.char("x")
|
256
|
+
self.assert_is_a(
|
257
|
+
a,
|
258
|
+
::Myco.find_constant(:Patterns)::Character
|
259
|
+
)
|
260
|
+
self.assert_equal(
|
261
|
+
a.code,
|
262
|
+
120
|
263
|
+
)
|
264
|
+
)}
|
265
|
+
declare_meme(:"creates a CharacterString with the 'str' shorthand method", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
266
|
+
a = self.shorthand.str("xyz")
|
267
|
+
self.assert_is_a(
|
268
|
+
a,
|
269
|
+
::Myco.find_constant(:Patterns)::CharacterString
|
270
|
+
)
|
271
|
+
self.assert_equal(
|
272
|
+
a.codes,
|
273
|
+
[
|
274
|
+
120,
|
275
|
+
121,
|
276
|
+
122
|
277
|
+
]
|
278
|
+
)
|
279
|
+
)}
|
280
|
+
declare_meme(:"creates a CharacterSet with the 'set' shorthand method", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
281
|
+
a = self.shorthand.set("xyz")
|
282
|
+
self.assert_is_a(
|
283
|
+
a,
|
284
|
+
::Myco.find_constant(:Patterns)::CharacterSet
|
285
|
+
)
|
286
|
+
self.assert_equal(
|
287
|
+
a.codes,
|
288
|
+
[
|
289
|
+
120,
|
290
|
+
121,
|
291
|
+
122
|
292
|
+
]
|
293
|
+
)
|
294
|
+
)}
|
295
|
+
declare_meme(:"creates a CharacterRange with the 'range' shorthand method", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
296
|
+
a = self.shorthand.range(
|
297
|
+
"x",
|
298
|
+
"z"
|
299
|
+
)
|
300
|
+
self.assert_is_a(
|
301
|
+
a,
|
302
|
+
::Myco.find_constant(:Patterns)::CharacterRange
|
303
|
+
)
|
304
|
+
self.assert_equal(
|
305
|
+
a.start,
|
306
|
+
120
|
307
|
+
)
|
308
|
+
self.assert_equal(
|
309
|
+
a.stop,
|
310
|
+
122
|
311
|
+
)
|
312
|
+
)}
|
313
|
+
declare_meme(:"creates a Reduction with the 'r' shorthand method", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
314
|
+
a_proc = ::Myco.find_constant(:Proc).new { || nil}
|
315
|
+
a = self.new_pattern
|
316
|
+
b = self.shorthand.r(
|
317
|
+
a,
|
318
|
+
&a_proc
|
319
|
+
)
|
320
|
+
self.assert_is_a(
|
321
|
+
b,
|
322
|
+
::Myco.find_constant(:Patterns)::Reduction
|
323
|
+
)
|
324
|
+
self.assert_equal(
|
325
|
+
b.inner,
|
326
|
+
a
|
327
|
+
)
|
328
|
+
self.assert_equal(
|
329
|
+
b.block,
|
330
|
+
a_proc
|
331
|
+
)
|
332
|
+
)}
|
333
|
+
)}
|
334
|
+
)}}.instance)}}.instance
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::Component.new([::Myco.find_constant(:BasicSpec)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
4
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
5
|
+
declare_meme(:name, [], nil, ::Myco.cscope.dup) { |*| ("Processor")}
|
6
|
+
declare_meme(:new_processor, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Processor)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
7
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}.instance)}
|
8
|
+
__category__(:tests).component_eval {(declare_meme(:exists, [[:it, []]], nil, ::Myco.cscope.dup) { |*| (self.assert(self.new_processor))})}
|
9
|
+
)}}.instance)}}.instance
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
import 'BasicSpec.my'
|
3
|
+
|
4
|
+
import '../lib/pegleromyces.my'
|
5
|
+
|
6
|
+
|
7
|
+
import 'Patterns.test.my'
|
8
|
+
import 'Constructions.test.my'
|
9
|
+
|
10
|
+
import 'Instructions.test.my'
|
11
|
+
import 'Machine.test.my'
|
12
|
+
|
13
|
+
import 'Processor.test.my'
|
14
|
+
import 'Builder.test.my'
|
15
|
+
|
16
|
+
import 'Grammar.test.my'
|
17
|
+
import 'Parser.test.my'
|
18
|
+
|
19
|
+
import 'BytecodeInstructions.test.my'
|
20
|
+
import 'BytecodeParser.test.my'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
4
|
+
declare_meme(:"BasicSpec.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
5
|
+
declare_meme(:"../lib/pegleromyces.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:"Patterns.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:"Constructions.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
8
|
+
declare_meme(:"Instructions.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
9
|
+
declare_meme(:"Machine.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
10
|
+
declare_meme(:"Processor.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
11
|
+
declare_meme(:"Builder.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
12
|
+
declare_meme(:"Grammar.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
13
|
+
declare_meme(:"Parser.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
14
|
+
declare_meme(:"BytecodeInstructions.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
15
|
+
declare_meme(:"BytecodeParser.test.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
16
|
+
)}}.instance
|
@@ -1,10 +1,18 @@
|
|
1
1
|
|
2
|
-
::Myco::BasicDecorators
|
2
|
+
::Myco::BasicDecorators << {
|
3
3
|
[decorators]
|
4
4
|
|
5
|
+
# The 'const' decorator evaluates immediately and creates a thunk method
|
6
|
+
const: ConstDecorator
|
7
|
+
ConstDecorator: Decorator {
|
8
|
+
apply: |meme| {
|
9
|
+
meme.body = Rubinius::Thunk.new(meme.result)
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
5
13
|
# The 'storage' decorator acts like a set of var decorators
|
6
14
|
# TODO: consolidate with 'var'
|
7
|
-
storage: Decorator {
|
15
|
+
const storage: Decorator {
|
8
16
|
# Create a corresponding "writer" meme to go with this "reader" meme
|
9
17
|
apply: |meme| {
|
10
18
|
meme.target.declare_meme(:""meme.name"=") |new_value, *args| {
|
@@ -19,25 +27,25 @@
|
|
19
27
|
# TODO: add const decorator to make all of these decorators 'thunks'
|
20
28
|
|
21
29
|
# The 'var' decorator creates an instance variable getter and setter:
|
22
|
-
var: Decorator {
|
30
|
+
const var: Decorator {
|
23
31
|
[transforms]
|
24
32
|
var: true
|
25
33
|
}
|
26
34
|
|
27
35
|
# The 'memoize' decorator enables caching of the result
|
28
|
-
memoize: Decorator {
|
36
|
+
const memoize: Decorator {
|
29
37
|
[transforms]
|
30
38
|
cache: true
|
31
39
|
}
|
32
40
|
|
33
41
|
# The 'static' decorator makes the component's singleton class the target
|
34
|
-
static: Decorator {
|
42
|
+
const static: Decorator {
|
35
43
|
[transforms]
|
36
44
|
target: |meme| meme.target.singleton_class
|
37
45
|
}
|
38
46
|
|
39
47
|
# The 'before' decorator defines a wrapper that runs before the existing meme
|
40
|
-
before: Decorator {
|
48
|
+
const before: Decorator {
|
41
49
|
apply: |meme| {
|
42
50
|
orig_meme = meme.target.memes[meme.name]
|
43
51
|
wrap_meme = meme.dup
|
@@ -49,7 +57,7 @@
|
|
49
57
|
}
|
50
58
|
|
51
59
|
# The 'after' decorator defines a wrapper that runs after the existing meme
|
52
|
-
after: Decorator {
|
60
|
+
const after: Decorator {
|
53
61
|
apply: |meme| {
|
54
62
|
orig_meme = meme.target.memes[meme.name]
|
55
63
|
wrap_meme = meme.dup
|
@@ -63,7 +71,7 @@
|
|
63
71
|
}
|
64
72
|
|
65
73
|
# The 'pre' decorator defines a wrapper that pre-processes arguments
|
66
|
-
pre: Decorator {
|
74
|
+
const pre: Decorator {
|
67
75
|
apply: |meme| {
|
68
76
|
orig_meme = meme.target.memes[meme.name]
|
69
77
|
wrap_meme = meme.dup
|
@@ -76,7 +84,7 @@
|
|
76
84
|
}
|
77
85
|
|
78
86
|
# The 'post' decorator defines a wrapper that post-processes return value
|
79
|
-
post: Decorator {
|
87
|
+
const post: Decorator {
|
80
88
|
apply: |meme| {
|
81
89
|
orig_meme = meme.target.memes[meme.name]
|
82
90
|
wrap_meme = meme.dup
|
@@ -89,7 +97,7 @@
|
|
89
97
|
}
|
90
98
|
|
91
99
|
# The 'setter' decorator defines a setter that pre-processes the given value
|
92
|
-
setter: Decorator {
|
100
|
+
const setter: Decorator {
|
93
101
|
apply: |meme| {
|
94
102
|
wrap_meme = meme.dup
|
95
103
|
meme.setter = &|orig_value| {
|
@@ -99,7 +107,7 @@
|
|
99
107
|
}
|
100
108
|
|
101
109
|
# The 'getter' decorator defines a getter that post-processes the return value
|
102
|
-
getter: Decorator {
|
110
|
+
const getter: Decorator {
|
103
111
|
apply: |meme| {
|
104
112
|
wrap_meme = meme.dup
|
105
113
|
meme.getter = &|orig_value| {
|
@@ -1,8 +1,13 @@
|
|
1
1
|
|
2
2
|
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::BasicDecorators
|
4
|
-
|
5
|
-
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::BasicDecorators.component_eval {(__category__(:decorators).component_eval {(
|
4
|
+
declare_meme(:const, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:ConstDecorator))}
|
5
|
+
::Myco.cscope.for_method_definition::ConstDecorator = (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
6
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (meme.__send__(
|
7
|
+
:body=,
|
8
|
+
::Myco.find_constant(:Rubinius)::Thunk.new(meme.result)
|
9
|
+
))})}}.instance)
|
10
|
+
declare_meme(:storage, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
6
11
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
7
12
|
declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (meme.target.declare_meme(:"#{meme.name}=") { |new_value, *args| (meme.set_result_for(
|
8
13
|
self,
|
@@ -11,13 +16,13 @@
|
|
11
16
|
))})}
|
12
17
|
__category__(:transforms).component_eval {(declare_meme(:cache, [], nil, ::Myco.cscope.dup) { |*| (true)})}
|
13
18
|
)}}.instance)}
|
14
|
-
declare_meme(:var, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
19
|
+
declare_meme(:var, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
15
20
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(__category__(:transforms).component_eval {(declare_meme(:var, [], nil, ::Myco.cscope.dup) { |*| (true)})})}}.instance)}
|
16
|
-
declare_meme(:memoize, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
21
|
+
declare_meme(:memoize, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
17
22
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(__category__(:transforms).component_eval {(declare_meme(:cache, [], nil, ::Myco.cscope.dup) { |*| (true)})})}}.instance)}
|
18
|
-
declare_meme(:static, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
23
|
+
declare_meme(:static, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
19
24
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(__category__(:transforms).component_eval {(declare_meme(:target, [], nil, ::Myco.cscope.dup) { |meme| (meme.target.singleton_class)})})}}.instance)}
|
20
|
-
declare_meme(:before, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
25
|
+
declare_meme(:before, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
21
26
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (
|
22
27
|
orig_meme = meme.target.memes.__send__(
|
23
28
|
:[],
|
@@ -26,7 +31,7 @@
|
|
26
31
|
wrap_meme = meme.dup
|
27
32
|
meme.__send__(
|
28
33
|
:body=,
|
29
|
-
::Proc.new { |*a, &b| (
|
34
|
+
::Object::Proc.new { |*a, &b| (
|
30
35
|
wrap_meme.result_for(
|
31
36
|
self,
|
32
37
|
*a,
|
@@ -40,7 +45,7 @@
|
|
40
45
|
)}
|
41
46
|
)
|
42
47
|
)})}}.instance)}
|
43
|
-
declare_meme(:after, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
48
|
+
declare_meme(:after, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
44
49
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (
|
45
50
|
orig_meme = meme.target.memes.__send__(
|
46
51
|
:[],
|
@@ -49,7 +54,7 @@
|
|
49
54
|
wrap_meme = meme.dup
|
50
55
|
meme.__send__(
|
51
56
|
:body=,
|
52
|
-
::Proc.new { |*a, &b| (
|
57
|
+
::Object::Proc.new { |*a, &b| (
|
53
58
|
result = orig_meme.result_for(
|
54
59
|
self,
|
55
60
|
*a,
|
@@ -64,7 +69,7 @@
|
|
64
69
|
)}
|
65
70
|
)
|
66
71
|
)})}}.instance)}
|
67
|
-
declare_meme(:pre, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
72
|
+
declare_meme(:pre, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
68
73
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (
|
69
74
|
orig_meme = meme.target.memes.__send__(
|
70
75
|
:[],
|
@@ -73,7 +78,7 @@
|
|
73
78
|
wrap_meme = meme.dup
|
74
79
|
meme.__send__(
|
75
80
|
:body=,
|
76
|
-
::Proc.new { |*a, &b| (
|
81
|
+
::Object::Proc.new { |*a, &b| (
|
77
82
|
new_a = wrap_meme.result_for(
|
78
83
|
self,
|
79
84
|
*a
|
@@ -86,7 +91,7 @@
|
|
86
91
|
)}
|
87
92
|
)
|
88
93
|
)})}}.instance)}
|
89
|
-
declare_meme(:post, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
94
|
+
declare_meme(:post, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
90
95
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (
|
91
96
|
orig_meme = meme.target.memes.__send__(
|
92
97
|
:[],
|
@@ -95,7 +100,7 @@
|
|
95
100
|
wrap_meme = meme.dup
|
96
101
|
meme.__send__(
|
97
102
|
:body=,
|
98
|
-
::Proc.new { |*a, &b| (
|
103
|
+
::Object::Proc.new { |*a, &b| (
|
99
104
|
result = orig_meme.result_for(
|
100
105
|
self,
|
101
106
|
*a,
|
@@ -108,27 +113,26 @@
|
|
108
113
|
)}
|
109
114
|
)
|
110
115
|
)})}}.instance)}
|
111
|
-
declare_meme(:setter, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
116
|
+
declare_meme(:setter, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
112
117
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (
|
113
118
|
wrap_meme = meme.dup
|
114
119
|
meme.__send__(
|
115
120
|
:setter=,
|
116
|
-
::Proc.new { |orig_value| (wrap_meme.result_for(
|
121
|
+
::Object::Proc.new { |orig_value| (wrap_meme.result_for(
|
117
122
|
self,
|
118
123
|
orig_value
|
119
124
|
))}
|
120
125
|
)
|
121
126
|
)})}}.instance)}
|
122
|
-
declare_meme(:getter, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
127
|
+
declare_meme(:getter, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
123
128
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (
|
124
129
|
wrap_meme = meme.dup
|
125
130
|
meme.__send__(
|
126
131
|
:getter=,
|
127
|
-
::Proc.new { |orig_value| (wrap_meme.result_for(
|
132
|
+
::Object::Proc.new { |orig_value| (wrap_meme.result_for(
|
128
133
|
self,
|
129
134
|
orig_value
|
130
135
|
))}
|
131
136
|
)
|
132
137
|
)})}}.instance)}
|
133
|
-
)})}}
|
134
|
-
.tap { |__c__| __c__.__name__ = :BasicDecorators })}}.instance
|
138
|
+
)})})}}.instance
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
::Myco::BasicObject
|
2
|
+
::Myco::BasicObject << {
|
3
3
|
# Basic conditional handling
|
4
4
|
if: |cond, &blk| cond && blk.call
|
5
5
|
unless: |cond, &blk| cond || blk.call
|
@@ -40,16 +40,21 @@
|
|
40
40
|
# TODO: alias more efficiently
|
41
41
|
# alias(::Ruby::Kernel, :raise) raise
|
42
42
|
# alias(::Ruby::Kernel, :loop) loop
|
43
|
-
raise: |*args| ::Ruby
|
44
|
-
loop: |&block| ::Ruby
|
43
|
+
raise: |*args| ::Ruby.__send__(:raise, *args)
|
44
|
+
loop: |&block| ::Ruby.__send__(:loop, &block)
|
45
45
|
break: raise(::Ruby::StopIteration)
|
46
46
|
|
47
|
+
send: |*args, &block| __send__(*args, &block)
|
48
|
+
|
49
|
+
kind_of?: |mod| __kind_of__(mod)
|
50
|
+
is_a?: |mod| __kind_of__(mod)
|
51
|
+
|
52
|
+
class: __class__ # TODO: consider removing
|
53
|
+
|
54
|
+
dup: __dup__ # TODO: remove
|
55
|
+
|
47
56
|
puts: |*args| STDOUT.puts(*args)
|
48
57
|
p: |*args| STDOUT.puts(args.map |a| { a.inspect }.join(', '))
|
49
58
|
|
50
59
|
ruby_require: |arg| ::Ruby.send(:require, arg)
|
51
60
|
}
|
52
|
-
|
53
|
-
# Because ::Myco::Instance is a ::BasicObject, we must shadow ::BasicObject here
|
54
|
-
::Myco::Instance::BasicObject: ::Myco::BasicObject
|
55
|
-
|