myco 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/bootstrap/find_constant.rb +4 -11
  3. data/lib/myco/code_loader.rb +2 -1
  4. data/lib/myco/code_tools/AST/ConstantAccess.my +47 -3
  5. data/lib/myco/code_tools/AST/ConstantAccess.my.rb +13 -9
  6. data/lib/myco/code_tools/AST/ConstantAssignment.my +1 -5
  7. data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +3 -9
  8. data/lib/myco/code_tools/AST/ToRuby.my +5 -2
  9. data/lib/myco/code_tools/AST/ToRuby.my.rb +7 -3
  10. data/lib/myco/code_tools/AST.my +1 -0
  11. data/lib/myco/code_tools/AST.my.rb +9 -1
  12. data/lib/myco/code_tools/Parser.my +24 -0
  13. data/lib/myco/code_tools/Parser.my.rb +25 -0
  14. data/lib/myco/code_tools/parser/MycoBuilder.my +67 -0
  15. data/lib/myco/code_tools/parser/MycoBuilder.my.rb +99 -0
  16. data/lib/myco/code_tools/parser/MycoCharacterClasses.my +20 -0
  17. data/lib/myco/code_tools/parser/MycoCharacterClasses.my.rb +56 -0
  18. data/lib/myco/code_tools/parser/MycoGrammar.my +564 -0
  19. data/lib/myco/code_tools/parser/MycoGrammar.my.rb +1851 -0
  20. data/lib/myco/code_tools/parser/MycoTokens.my +78 -0
  21. data/lib/myco/code_tools/parser/MycoTokens.my.rb +170 -0
  22. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my +4 -0
  23. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my.rb +5 -0
  24. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +142 -0
  25. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +181 -0
  26. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +420 -0
  27. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +415 -0
  28. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +137 -0
  29. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my.rb +237 -0
  30. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my +183 -0
  31. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my.rb +370 -0
  32. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +65 -0
  33. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +83 -0
  34. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my +139 -0
  35. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my.rb +284 -0
  36. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my +37 -0
  37. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +24 -0
  38. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +42 -0
  39. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +52 -0
  40. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my +123 -0
  41. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +164 -0
  42. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +236 -0
  43. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +339 -0
  44. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my +15 -0
  45. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my.rb +14 -0
  46. data/lib/myco/code_tools.rb +1 -1
  47. data/lib/myco/version.rb +1 -1
  48. data/lib/myco.rb +2 -0
  49. metadata +44 -25
  50. data/lib/myco/code_tools/parser/peg_parser.rb +0 -7182
  51. data/lib/myco/code_tools/parser.rb +0 -39
@@ -0,0 +1,78 @@
1
+
2
+ MycoTokens: Pegleromyces::Grammar {
3
+ C: MycoCharacterClasses
4
+
5
+ [main]
6
+
7
+ token const_sep: str(',')
8
+ token expr_sep: str(';') / C.nl
9
+ token arg_sep: str(',') / C.nl
10
+ token declare_begin: str('{')
11
+ token declare_end: str('}') / C.eof
12
+ token meme_mark: str(':')
13
+ token meme_begin: str('{')
14
+ token meme_end: str('}')
15
+ token paren_begin: str('(')
16
+ token paren_end: str(')')
17
+ token define: str('<')
18
+ token reopen: str('<<')
19
+ token params_begin: str('|')
20
+ token params_end: str('|')
21
+ token args_begin: str('(')
22
+ token args_end: str(')')
23
+ token array_begin: str('[')
24
+ token array_end: str(']')
25
+
26
+ token constant: C.upper + C.alnum.*
27
+ token identifier: C.lower + C.alnum.* + C.suffix.-
28
+ token symbol: str(':') + C.lower + C.alnum.*
29
+ token null: str('null')
30
+ token void: str('void')
31
+ token true: str('true')
32
+ token false: str('false')
33
+ token self: str('self')
34
+ token float: str('-').- + C.num.+ + str('.') + C.num.+
35
+ token integer: str('-').- + C.num.+
36
+
37
+ token dot: str('.')
38
+ token quest: str('.') + C.spc_nl.* + str('?')
39
+ token scope: str('::')
40
+ token assign: str('=')
41
+ token op_toproc: str('&')
42
+ token op_not: str('!')
43
+ token op_plus: str('+')
44
+ token op_minus: str('-')
45
+ token op_mult: str('*')
46
+ token op_div: str('/')
47
+ token op_mod: str('%')
48
+ token op_exp: str('**')
49
+ token op_and: str('&&')
50
+ token op_or: str('||')
51
+ token op_and_q: str('&?')
52
+ token op_or_q: str('|?')
53
+ token op_void_q: str('??')
54
+ token op_compare: str('<=>') / str('=~') / str('==') /
55
+ str('<=') / str('>=') / str('<') / str('>')
56
+
57
+ string_norm: !set("\\\"") + any
58
+ token string_body: string_norm.* + (str("\\") + any + string_norm.*).*
59
+ token string_begin: str('"')
60
+ token string_end: str('"')
61
+ token symstr_begin: str(':"')
62
+
63
+ sstring_norm: !set("\\\'") + any
64
+ token sstring_body: sstring_norm.* + (str("\\") + any + sstring_norm.*).*
65
+ token sstring_begin: str("'")
66
+ token sstring_end: str("'")
67
+
68
+ catgry_norm: !set("\\[]") + any
69
+ token catgry_body: catgry_norm.* + (str("\\") + any + catgry_norm.*).*
70
+ token catgry_begin: str('[')
71
+ token catgry_end: str(']')
72
+
73
+ # TODO: more flexible declstrs?
74
+ declstr_norm: !str("@@@") + any
75
+ token declstr_body: declstr_norm.*
76
+ token declstr_begin: str('@@@')
77
+ token declstr_end: str('@@@')
78
+ }
@@ -0,0 +1,170 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.cscope.for_method_definition.const_set(:MycoTokens, (::Myco::Component.new([::Myco.find_constant(:Pegleromyces)::Grammar], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ ::Myco.cscope.for_method_definition.const_set(:C, (::Myco.find_constant(:MycoCharacterClasses)))
6
+ __category__(:main).component_eval {(
7
+ declare_meme(:const_sep, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(","))}
8
+ declare_meme(:expr_sep, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(";").__send__(
9
+ :/,
10
+ ::Myco.find_constant(:C).nl
11
+ ))}
12
+ declare_meme(:arg_sep, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(",").__send__(
13
+ :/,
14
+ ::Myco.find_constant(:C).nl
15
+ ))}
16
+ declare_meme(:declare_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("{"))}
17
+ declare_meme(:declare_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("}").__send__(
18
+ :/,
19
+ ::Myco.find_constant(:C).eof
20
+ ))}
21
+ declare_meme(:meme_mark, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(":"))}
22
+ declare_meme(:meme_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("{"))}
23
+ declare_meme(:meme_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("}"))}
24
+ declare_meme(:paren_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("("))}
25
+ declare_meme(:paren_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(")"))}
26
+ declare_meme(:define, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("<"))}
27
+ declare_meme(:reopen, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("<<"))}
28
+ declare_meme(:params_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("|"))}
29
+ declare_meme(:params_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("|"))}
30
+ declare_meme(:args_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("("))}
31
+ declare_meme(:args_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(")"))}
32
+ declare_meme(:array_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("["))}
33
+ declare_meme(:array_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("]"))}
34
+ declare_meme(:constant, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:C).upper.__send__(
35
+ :+,
36
+ ::Myco.find_constant(:C).alnum.__send__(:*)
37
+ ))}
38
+ declare_meme(:identifier, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:C).lower.__send__(
39
+ :+,
40
+ ::Myco.find_constant(:C).alnum.__send__(:*)
41
+ ).__send__(
42
+ :+,
43
+ ::Myco.find_constant(:C).suffix.__send__(:-)
44
+ ))}
45
+ declare_meme(:symbol, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(":").__send__(
46
+ :+,
47
+ ::Myco.find_constant(:C).lower
48
+ ).__send__(
49
+ :+,
50
+ ::Myco.find_constant(:C).alnum.__send__(:*)
51
+ ))}
52
+ declare_meme(:null, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("null"))}
53
+ declare_meme(:void, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("void"))}
54
+ declare_meme(:true, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("true"))}
55
+ declare_meme(:false, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("false"))}
56
+ declare_meme(:self, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("self"))}
57
+ declare_meme(:float, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("-").__send__(:-).__send__(
58
+ :+,
59
+ ::Myco.find_constant(:C).num.__send__(:+)
60
+ ).__send__(
61
+ :+,
62
+ self.str(".")
63
+ ).__send__(
64
+ :+,
65
+ ::Myco.find_constant(:C).num.__send__(:+)
66
+ ))}
67
+ declare_meme(:integer, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("-").__send__(:-).__send__(
68
+ :+,
69
+ ::Myco.find_constant(:C).num.__send__(:+)
70
+ ))}
71
+ declare_meme(:dot, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("."))}
72
+ declare_meme(:quest, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(".").__send__(
73
+ :+,
74
+ ::Myco.find_constant(:C).spc_nl.__send__(:*)
75
+ ).__send__(
76
+ :+,
77
+ self.str("?")
78
+ ))}
79
+ declare_meme(:scope, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("::"))}
80
+ declare_meme(:assign, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("="))}
81
+ declare_meme(:op_toproc, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("&"))}
82
+ declare_meme(:op_not, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("!"))}
83
+ declare_meme(:op_plus, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("+"))}
84
+ declare_meme(:op_minus, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("-"))}
85
+ declare_meme(:op_mult, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("*"))}
86
+ declare_meme(:op_div, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("/"))}
87
+ declare_meme(:op_mod, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("%"))}
88
+ declare_meme(:op_exp, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("**"))}
89
+ declare_meme(:op_and, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("&&"))}
90
+ declare_meme(:op_or, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("||"))}
91
+ declare_meme(:op_and_q, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("&?"))}
92
+ declare_meme(:op_or_q, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("|?"))}
93
+ declare_meme(:op_void_q, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("??"))}
94
+ declare_meme(:op_compare, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("<=>").__send__(
95
+ :/,
96
+ self.str("=~")
97
+ ).__send__(
98
+ :/,
99
+ self.str("==")
100
+ ).__send__(
101
+ :/,
102
+ self.str("<=")
103
+ ).__send__(
104
+ :/,
105
+ self.str(">=")
106
+ ).__send__(
107
+ :/,
108
+ self.str("<")
109
+ ).__send__(
110
+ :/,
111
+ self.str(">")
112
+ ))}
113
+ declare_meme(:string_norm, [], nil, ::Myco.cscope.dup) { |*| (self.set("\\\"").__send__(:!).__send__(
114
+ :+,
115
+ self.any
116
+ ))}
117
+ declare_meme(:string_body, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.string_norm.__send__(:*).__send__(
118
+ :+,
119
+ self.str("\\").__send__(
120
+ :+,
121
+ self.any
122
+ ).__send__(
123
+ :+,
124
+ self.string_norm.__send__(:*)
125
+ ).__send__(:*)
126
+ ))}
127
+ declare_meme(:string_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("\""))}
128
+ declare_meme(:string_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("\""))}
129
+ declare_meme(:symstr_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str(":\""))}
130
+ declare_meme(:sstring_norm, [], nil, ::Myco.cscope.dup) { |*| (self.set("\\'").__send__(:!).__send__(
131
+ :+,
132
+ self.any
133
+ ))}
134
+ declare_meme(:sstring_body, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.sstring_norm.__send__(:*).__send__(
135
+ :+,
136
+ self.str("\\").__send__(
137
+ :+,
138
+ self.any
139
+ ).__send__(
140
+ :+,
141
+ self.sstring_norm.__send__(:*)
142
+ ).__send__(:*)
143
+ ))}
144
+ declare_meme(:sstring_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("'"))}
145
+ declare_meme(:sstring_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("'"))}
146
+ declare_meme(:catgry_norm, [], nil, ::Myco.cscope.dup) { |*| (self.set("\\[]").__send__(:!).__send__(
147
+ :+,
148
+ self.any
149
+ ))}
150
+ declare_meme(:catgry_body, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.catgry_norm.__send__(:*).__send__(
151
+ :+,
152
+ self.str("\\").__send__(
153
+ :+,
154
+ self.any
155
+ ).__send__(
156
+ :+,
157
+ self.catgry_norm.__send__(:*)
158
+ ).__send__(:*)
159
+ ))}
160
+ declare_meme(:catgry_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("["))}
161
+ declare_meme(:catgry_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("]"))}
162
+ declare_meme(:declstr_norm, [], nil, ::Myco.cscope.dup) { |*| (self.str("@@@").__send__(:!).__send__(
163
+ :+,
164
+ self.any
165
+ ))}
166
+ declare_meme(:declstr_body, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.declstr_norm.__send__(:*))}
167
+ declare_meme(:declstr_begin, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("@@@"))}
168
+ declare_meme(:declstr_end, [[:token, []]], nil, ::Myco.cscope.dup) { |*| (self.str("@@@"))}
169
+ )}
170
+ )}}.instance)))}}.instance
@@ -0,0 +1,4 @@
1
+
2
+ Builder < BasicObject {
3
+
4
+ }
@@ -0,0 +1,5 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.cscope.for_method_definition.const_set(:Builder, ::Myco::Component.new([::Myco.find_constant(:BasicObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {nil}})
5
+ .tap { |__c__| __c__.__name__ = :Builder })}}.instance
@@ -0,0 +1,142 @@
1
+
2
+ BytecodeHelpers < BasicObject {
3
+ ##
4
+ # Bytecode Generation Helper Methods
5
+
6
+ var overall_fail: new_label
7
+
8
+ g: self # For consistency
9
+
10
+ puts_string: |string|
11
+ g.push_rubinius; g.push_literal(string); g.send(:puts, 1, true); g.pop
12
+
13
+ inspect_top:
14
+ g.dup_top; g.push_rubinius; g.swap; g.send(:p, 1, true); g.pop
15
+
16
+ set_subject: g.set_local (0)
17
+ push_subject: g.push_local (0)
18
+ set_idx: g.set_local (1)
19
+ push_idx: g.push_local (1)
20
+ set_captures: g.set_ivar (:"@captures")
21
+ push_captures: g.push_ivar (:"@captures")
22
+ set_memo_for: |name| g.set_ivar (:"@memo_for_"name"")
23
+ push_memo_for: |name| g.push_ivar (:"@memo_for_"name"")
24
+
25
+ pop_to_set_idx:
26
+ g.set_idx; g.pop
27
+
28
+ push_temp_captures:
29
+ g.push_captures; g.make_array(0); g.set_captures; g.pop
30
+
31
+ pop_to_reject_captures:
32
+ g.set_captures; g.pop
33
+
34
+ pop_to_accept_captures:
35
+ g.push_captures; g.send(:concat, 1); g.set_captures; g.pop
36
+
37
+ push_subject_at_idx:
38
+ g.push_subject; g.push_idx; g.send(:chr_at, 1)
39
+
40
+ push_new_hash:
41
+ g.push_cpath_top; g.find_const(:"Hash"); g.send(:new, 0)
42
+
43
+ # Set the memo ivar to a new hash if it doesn't already exist
44
+ memo_or_eq_new_hash: |name| {
45
+ memo_exists_label = g.new_label
46
+
47
+ g.push_memo_for(name)
48
+ g.goto_if_true(memo_exists_label)
49
+ g.push_new_hash
50
+ g.set_memo_for(name)
51
+ g.pop # ivar
52
+ memo_exists_label.set!
53
+ }
54
+
55
+ # Copy the top two values into the memo ivar for |name| at the current idx.
56
+ copy_result_to_memo: |name| {
57
+ g.dup
58
+ g.push_captures
59
+ g.make_array(2) # [result_idx, result_captures]
60
+
61
+ g.push_memo_for(name)
62
+ g.swap # [result_idx, result_captures]
63
+ g.push_idx # idx
64
+ g.swap # TODO: use rotate
65
+ g.send(:"[]=", 2)
66
+ g.pop
67
+ }
68
+
69
+ # Goto the given |label| and push the result values if a memoized result
70
+ # exists for the given |name| at the current idx.
71
+ goto_if_memo_for_idx: |name, label| {
72
+ skip_label = g.new_label
73
+
74
+ g.push_memo_for(name)
75
+ g.push_idx
76
+ g.send(:"[]", 1)
77
+ g.dup # dup the result to retain after goto test
78
+ g.goto_if_nil(skip_label)
79
+
80
+ # Shift result_idx onto the stack and swap with array
81
+ g.shift_array; g.swap
82
+ # Shift result_captures, set to @captures, and pop
83
+ g.shift_array; g.set_captures; g.pop
84
+ g.pop # pop the empty containing array
85
+ g.goto(label)
86
+
87
+ skip_label.set!
88
+ g.pop
89
+ }
90
+
91
+ # Increment the idx local by the current number at the top of the stack
92
+ # Saves the new idx to @highest_idx ivar if it is highest
93
+ increment_idx: {
94
+ g.push_idx
95
+ g.send(:"+", 1)
96
+ g.set_idx
97
+ g.dup_top
98
+ g.push_ivar(:"@highest_idx")
99
+ g.send(:">", 1)
100
+ not_highest_idx_label = g.new_label
101
+ g.goto_if_false(not_highest_idx_label)
102
+ g.set_ivar(:"@highest_idx")
103
+ not_highest_idx_label.set!
104
+ g.pop
105
+ }
106
+
107
+ # Begin a compiled parser method
108
+ rule_start: {
109
+ # 2 argument: (subject, idx)
110
+ g.required_args = 2
111
+ g.total_args = 2
112
+ g.splat_index = null
113
+
114
+ g.local_count = 2
115
+ g.local_names = [:subject, :idx]
116
+ }
117
+
118
+ # Wrap up a compiled parser method
119
+ rule_finish: {
120
+ overall_done = g.new_label
121
+
122
+ # end
123
+ g.push_idx
124
+ g.goto(overall_done)
125
+
126
+ # fail
127
+ g.overall_fail.set!
128
+ g.push_nil
129
+
130
+ overall_done.set!
131
+ g.ret
132
+ g.close
133
+ }
134
+
135
+ push_literal_array: |ary|
136
+ ary.each |lit| { g.push_literal_or_array(lit) }; make_array(ary.size)
137
+
138
+ push_literal_or_array: |item|
139
+ item.is_a?(::Array)
140
+ &? push_literal_array(item)
141
+ ?? push_literal(item)
142
+ }
@@ -0,0 +1,181 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.cscope.for_method_definition.const_set(:BytecodeHelpers, ::Myco::Component.new([::Myco.find_constant(:BasicObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ declare_meme(:overall_fail, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (self.new_label)}
6
+ declare_meme(:g, [], nil, ::Myco.cscope.dup) { |*| (self)}
7
+ declare_meme(:puts_string, [], nil, ::Myco.cscope.dup) { |string| (
8
+ self.g.push_rubinius
9
+ self.g.push_literal(string)
10
+ self.g.send(
11
+ :puts,
12
+ 1,
13
+ true
14
+ )
15
+ self.g.pop
16
+ )}
17
+ declare_meme(:inspect_top, [], nil, ::Myco.cscope.dup) { |*| (
18
+ self.g.dup_top
19
+ self.g.push_rubinius
20
+ self.g.swap
21
+ self.g.send(
22
+ :p,
23
+ 1,
24
+ true
25
+ )
26
+ self.g.pop
27
+ )}
28
+ declare_meme(:set_subject, [], nil, ::Myco.cscope.dup) { |*| (self.g.set_local(0))}
29
+ declare_meme(:push_subject, [], nil, ::Myco.cscope.dup) { |*| (self.g.push_local(0))}
30
+ declare_meme(:set_idx, [], nil, ::Myco.cscope.dup) { |*| (self.g.set_local(1))}
31
+ declare_meme(:push_idx, [], nil, ::Myco.cscope.dup) { |*| (self.g.push_local(1))}
32
+ declare_meme(:set_captures, [], nil, ::Myco.cscope.dup) { |*| (self.g.set_ivar(:@captures))}
33
+ declare_meme(:push_captures, [], nil, ::Myco.cscope.dup) { |*| (self.g.push_ivar(:@captures))}
34
+ declare_meme(:set_memo_for, [], nil, ::Myco.cscope.dup) { |name| (self.g.set_ivar(:"@memo_for_#{name}"))}
35
+ declare_meme(:push_memo_for, [], nil, ::Myco.cscope.dup) { |name| (self.g.push_ivar(:"@memo_for_#{name}"))}
36
+ declare_meme(:pop_to_set_idx, [], nil, ::Myco.cscope.dup) { |*| (
37
+ self.g.set_idx
38
+ self.g.pop
39
+ )}
40
+ declare_meme(:push_temp_captures, [], nil, ::Myco.cscope.dup) { |*| (
41
+ self.g.push_captures
42
+ self.g.make_array(0)
43
+ self.g.set_captures
44
+ self.g.pop
45
+ )}
46
+ declare_meme(:pop_to_reject_captures, [], nil, ::Myco.cscope.dup) { |*| (
47
+ self.g.set_captures
48
+ self.g.pop
49
+ )}
50
+ declare_meme(:pop_to_accept_captures, [], nil, ::Myco.cscope.dup) { |*| (
51
+ self.g.push_captures
52
+ self.g.send(
53
+ :concat,
54
+ 1
55
+ )
56
+ self.g.set_captures
57
+ self.g.pop
58
+ )}
59
+ declare_meme(:push_subject_at_idx, [], nil, ::Myco.cscope.dup) { |*| (
60
+ self.g.push_subject
61
+ self.g.push_idx
62
+ self.g.send(
63
+ :chr_at,
64
+ 1
65
+ )
66
+ )}
67
+ declare_meme(:push_new_hash, [], nil, ::Myco.cscope.dup) { |*| (
68
+ self.g.push_cpath_top
69
+ self.g.find_const(:Hash)
70
+ self.g.send(
71
+ :new,
72
+ 0
73
+ )
74
+ )}
75
+ declare_meme(:memo_or_eq_new_hash, [], nil, ::Myco.cscope.dup) { |name| (
76
+ memo_exists_label = self.g.new_label
77
+ self.g.push_memo_for(name)
78
+ self.g.goto_if_true(memo_exists_label)
79
+ self.g.push_new_hash
80
+ self.g.set_memo_for(name)
81
+ self.g.pop
82
+ memo_exists_label.__send__(:set!)
83
+ )}
84
+ declare_meme(:copy_result_to_memo, [], nil, ::Myco.cscope.dup) { |name| (
85
+ self.g.dup
86
+ self.g.push_captures
87
+ self.g.make_array(2)
88
+ self.g.push_memo_for(name)
89
+ self.g.swap
90
+ self.g.push_idx
91
+ self.g.swap
92
+ self.g.send(
93
+ :[]=,
94
+ 2
95
+ )
96
+ self.g.pop
97
+ )}
98
+ declare_meme(:goto_if_memo_for_idx, [], nil, ::Myco.cscope.dup) { |name, label| (
99
+ skip_label = self.g.new_label
100
+ self.g.push_memo_for(name)
101
+ self.g.push_idx
102
+ self.g.send(
103
+ :[],
104
+ 1
105
+ )
106
+ self.g.dup
107
+ self.g.goto_if_nil(skip_label)
108
+ self.g.shift_array
109
+ self.g.swap
110
+ self.g.shift_array
111
+ self.g.set_captures
112
+ self.g.pop
113
+ self.g.pop
114
+ self.g.goto(label)
115
+ skip_label.__send__(:set!)
116
+ self.g.pop
117
+ )}
118
+ declare_meme(:increment_idx, [], nil, ::Myco.cscope.dup) { |*| (
119
+ self.g.push_idx
120
+ self.g.send(
121
+ :+,
122
+ 1
123
+ )
124
+ self.g.set_idx
125
+ self.g.dup_top
126
+ self.g.push_ivar(:@highest_idx)
127
+ self.g.send(
128
+ :>,
129
+ 1
130
+ )
131
+ not_highest_idx_label = self.g.new_label
132
+ self.g.goto_if_false(not_highest_idx_label)
133
+ self.g.set_ivar(:@highest_idx)
134
+ not_highest_idx_label.__send__(:set!)
135
+ self.g.pop
136
+ )}
137
+ declare_meme(:rule_start, [], nil, ::Myco.cscope.dup) { |*| (
138
+ self.g.__send__(
139
+ :required_args=,
140
+ 2
141
+ )
142
+ self.g.__send__(
143
+ :total_args=,
144
+ 2
145
+ )
146
+ self.g.__send__(
147
+ :splat_index=,
148
+ nil
149
+ )
150
+ self.g.__send__(
151
+ :local_count=,
152
+ 2
153
+ )
154
+ self.g.__send__(
155
+ :local_names=,
156
+ [
157
+ :subject,
158
+ :idx
159
+ ]
160
+ )
161
+ )}
162
+ declare_meme(:rule_finish, [], nil, ::Myco.cscope.dup) { |*| (
163
+ overall_done = self.g.new_label
164
+ self.g.push_idx
165
+ self.g.goto(overall_done)
166
+ self.g.overall_fail.__send__(:set!)
167
+ self.g.push_nil
168
+ overall_done.__send__(:set!)
169
+ self.g.ret
170
+ self.g.close
171
+ )}
172
+ declare_meme(:push_literal_array, [], nil, ::Myco.cscope.dup) { |ary| (
173
+ ary.each { |lit| (self.g.push_literal_or_array(lit))}
174
+ self.make_array(ary.size)
175
+ )}
176
+ declare_meme(:push_literal_or_array, [], nil, ::Myco.cscope.dup) { |item| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", item.__send__(
177
+ :is_a?,
178
+ ::Array
179
+ )) {self.push_literal_array(item)}) {self.push_literal(item)})}
180
+ )}})
181
+ .tap { |__c__| __c__.__name__ = :BytecodeHelpers })}}.instance