myco 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/bootstrap/instance.rb +13 -3
  3. data/lib/myco/code_tools/AST.my +0 -2
  4. data/lib/myco/code_tools/AST.my.rb +0 -1
  5. data/lib/myco/code_tools/AST/Block.my +15 -4
  6. data/lib/myco/code_tools/AST/Block.my.rb +16 -3
  7. data/lib/myco/code_tools/AST/DeclareMeme.my +44 -64
  8. data/lib/myco/code_tools/AST/DeclareMeme.my.rb +66 -74
  9. data/lib/myco/code_tools/AST/ToRuby.my +17 -20
  10. data/lib/myco/code_tools/AST/ToRuby.my.rb +24 -22
  11. data/lib/myco/code_tools/Parser.my +2 -1
  12. data/lib/myco/code_tools/Parser.my.rb +2 -1
  13. data/lib/myco/code_tools/parser/MycoBuilder.my +2 -2
  14. data/lib/myco/code_tools/parser/MycoBuilder.my.rb +2 -2
  15. data/lib/myco/code_tools/parser/MycoGrammar.my +28 -21
  16. data/lib/myco/code_tools/parser/MycoGrammar.my.rb +94 -56
  17. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my +10 -11
  18. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my.rb +10 -9
  19. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +25 -3
  20. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +38 -0
  21. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my +152 -0
  22. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my.rb +189 -0
  23. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my +84 -0
  24. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my.rb +114 -0
  25. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common/Parser.my +139 -0
  26. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/{BytecodeParser.my.rb → Common/Parser.my.rb} +17 -36
  27. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my +229 -0
  28. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my.rb +296 -0
  29. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +8 -25
  30. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +9 -37
  31. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +139 -37
  32. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +206 -36
  33. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +21 -12
  34. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +45 -24
  35. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my +99 -0
  36. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my.rb +152 -0
  37. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my +37 -0
  38. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my.rb +57 -0
  39. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my +136 -0
  40. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my.rb +147 -0
  41. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my +45 -0
  42. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my.rb +85 -0
  43. data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my +31 -25
  44. data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my.rb +44 -25
  45. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my +49 -0
  46. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my.rb +119 -0
  47. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my +131 -0
  48. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my.rb +595 -0
  49. data/lib/myco/code_tools/parser/pegleromyces/spec/{BytecodeParser.test.my → String/Parser.test.my} +41 -2
  50. data/lib/myco/code_tools/parser/pegleromyces/spec/{BytecodeParser.test.my.rb → String/Parser.test.my.rb} +144 -3
  51. data/lib/myco/code_tools/parser/pegleromyces/spec/run.my +4 -10
  52. data/lib/myco/code_tools/parser/pegleromyces/spec/run.my.rb +4 -8
  53. data/lib/myco/core.my +1 -0
  54. data/lib/myco/core.my.rb +1 -0
  55. data/lib/myco/core/BasicObject.my +4 -2
  56. data/lib/myco/core/BasicObject.my.rb +2 -5
  57. data/lib/myco/core/Loop.my +5 -0
  58. data/lib/myco/core/Loop.my.rb +13 -0
  59. data/lib/myco/dev.rb +1 -0
  60. data/lib/myco/dev/profile.rb +12 -0
  61. data/lib/myco/version.rb +3 -3
  62. metadata +54 -59
  63. data/lib/myco/code_tools/AST/DeclareDecorator.my +0 -19
  64. data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +0 -24
  65. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my +0 -4
  66. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my.rb +0 -5
  67. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +0 -420
  68. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +0 -415
  69. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +0 -147
  70. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my +0 -183
  71. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my.rb +0 -370
  72. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my +0 -139
  73. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my.rb +0 -284
  74. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my +0 -37
  75. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +0 -24
  76. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my +0 -123
  77. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +0 -164
  78. data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my +0 -10
  79. data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my.rb +0 -9
  80. data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my +0 -10
  81. data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my.rb +0 -9
  82. data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my +0 -229
  83. data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my.rb +0 -663
  84. data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my +0 -10
  85. data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my.rb +0 -9
  86. data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my +0 -13
  87. data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my.rb +0 -20
  88. data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my +0 -54
  89. data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my.rb +0 -215
@@ -0,0 +1,152 @@
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::Stream = ::Myco::Component.new([::Myco.find_constant(:EmptyObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ ::Myco.cscope.for_method_definition::Patterns = ::Myco::Component.new([::Myco.find_constant(:EmptyObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
6
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
7
+ ::Myco.cscope.for_method_definition::Base = ::Myco::Component.new([::Myco.find_constant(:Common)::Patterns::Base], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
8
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}
9
+ .tap { |__c__| __c__.__name__ = :Base }
10
+ ::Myco.cscope.for_method_definition::End = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
11
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:construct, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Constructions)::End.new)})}}
12
+ .tap { |__c__| __c__.__name__ = :End }
13
+ ::Myco.cscope.for_method_definition::Item = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
14
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
15
+ declare_meme(:checks, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
16
+ declare_meme(:construct, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Constructions)::Item.new({:checks => self.checks}))}
17
+ )}}
18
+ .tap { |__c__| __c__.__name__ = :Item }
19
+ )}}
20
+ .tap { |__c__| __c__.__name__ = :Patterns }
21
+ ::Myco.cscope.for_method_definition::Constructions = ::Myco::Component.new([::Myco.find_constant(:EmptyObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
22
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
23
+ ::Myco.cscope.for_method_definition::Base = ::Myco::Component.new([::Myco.find_constant(:Common)::Constructions::Base], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
24
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}
25
+ .tap { |__c__| __c__.__name__ = :Base }
26
+ ::Myco.cscope.for_method_definition::End = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
27
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}
28
+ .tap { |__c__| __c__.__name__ = :End }
29
+ ::Myco.cscope.for_method_definition::Item = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
30
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:checks, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil})}}
31
+ .tap { |__c__| __c__.__name__ = :Item }
32
+ )}}
33
+ .tap { |__c__| __c__.__name__ = :Constructions }
34
+ ::Myco.find_constant(:Constructions).component_eval {(
35
+ ::Myco.find_constant(:End).component_eval {(declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
36
+ g.push_subject
37
+ g.send(
38
+ :size,
39
+ 0
40
+ )
41
+ g.push_idx
42
+ g.send(
43
+ :>,
44
+ 1
45
+ )
46
+ g.goto_if_true(g.overall_fail)
47
+ )})}
48
+ ::Myco.find_constant(:Item).component_eval {(declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
49
+ many_checks = self.checks.size.__send__(
50
+ :>,
51
+ 1
52
+ )
53
+ local_fail = g.overall_fail
54
+ self.__send__(
55
+ :if,
56
+ many_checks
57
+ ) { || (local_fail = g.new_label)}
58
+ g.push_subject
59
+ g.send(
60
+ :size,
61
+ 0
62
+ )
63
+ g.push_idx
64
+ g.send(
65
+ :>,
66
+ 1
67
+ )
68
+ g.goto_if_false(g.overall_fail)
69
+ ::Myco.branch_op(:"||", self.checks.__send__(:empty?)) {(
70
+ g.push_subject_at_idx
71
+ self.checks.each { |method, args, result| (
72
+ self.__send__(
73
+ :if,
74
+ many_checks
75
+ ) { || (g.dup_top)}
76
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", :self.__send__(
77
+ :equal?,
78
+ method
79
+ )) {nil}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", method.__send__(
80
+ :is_a?,
81
+ ::Myco.find_constant(:Symbol)
82
+ )) {(
83
+ args.each { |arg| (g.push_literal_or_array(arg))}
84
+ g.send(
85
+ method,
86
+ args.size
87
+ )
88
+ )}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", method.__send__(
89
+ :is_a?,
90
+ ::Myco.find_constant(:Proc)
91
+ )) {(
92
+ code = method.block.compiled_code
93
+ g.push_literal(code)
94
+ g.swap_stack
95
+ g.push_literal(code.name)
96
+ g.swap_stack
97
+ g.push_cpath_top
98
+ g.find_const(:Myco)
99
+ g.swap_stack
100
+ g.push_literal_array(args)
101
+ g.push_nil
102
+ g.send(
103
+ :invoke,
104
+ 5
105
+ )
106
+ )}) {self.raise("Unknown type of check method: #{method}")}}}
107
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", nil.__send__(
108
+ :equal?,
109
+ result
110
+ )) {g.goto_if_not_nil(local_fail)}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", ::Myco.branch_op(:"||", ::Myco.branch_op(:"||", ::Myco.branch_op(:"||", false.__send__(
111
+ :equal?,
112
+ result
113
+ )) {true.__send__(
114
+ :equal?,
115
+ result
116
+ )}) {result.__send__(
117
+ :is_a?,
118
+ ::Myco.find_constant(:Symbol)
119
+ )}) {result.__send__(
120
+ :is_a?,
121
+ ::Myco.find_constant(:Fixnum)
122
+ )}) {(
123
+ g.push_literal(result)
124
+ g.goto_if_not_equal(local_fail)
125
+ )}) {(
126
+ g.push_literal_or_array(result)
127
+ g.send(
128
+ :==,
129
+ 1
130
+ )
131
+ g.goto_if_false(local_fail)
132
+ )}}
133
+ )}
134
+ self.__send__(
135
+ :if,
136
+ many_checks
137
+ ) { || (
138
+ local_done = g.new_label
139
+ g.pop
140
+ g.goto(local_done)
141
+ local_fail.__send__(:set!)
142
+ g.pop
143
+ g.goto(g.overall_fail)
144
+ local_done.__send__(:set!)
145
+ )}
146
+ )}
147
+ g.__send__(:meta_push_1)
148
+ g.increment_idx
149
+ )})}
150
+ )}
151
+ )}}
152
+ .tap { |__c__| __c__.__name__ = :Stream })}}.instance
@@ -0,0 +1,37 @@
1
+
2
+ Stream << {
3
+ Parser < Common::Parser {
4
+ State < Common::Parser::State {
5
+ var stream
6
+
7
+ raise_error: self.error_idx && raise(SyntaxError
8
+ "Unexpected item with parser: "self.rule \
9
+ " at index: "self.error_idx \
10
+ ", item: "self.stream[self.error_idx].inspect""
11
+ )
12
+ }
13
+
14
+ # Match and process the given stream using the current grammar
15
+ parse: |stream, rule:"root", start_idx:0| {
16
+ worker = new_worker
17
+ processor = new_processor
18
+ state = State.new(
19
+ stream: stream
20
+ rule: rule.to_sym
21
+ start_idx: start_idx.to_i
22
+ )
23
+
24
+ state.end_idx = worker.__send__(state.rule, state.stream, state.start_idx)
25
+
26
+ state.end_idx &? (
27
+ processor.string = state.stream
28
+ processor.capture_items = captures_of_worker(worker)
29
+ grammar.?tokenizer && (processor.tokenizer = grammar.tokenizer)
30
+ state.result = processor.process
31
+ ) ?? (
32
+ state.error_idx = highest_idx_of_worker(worker)
33
+ )
34
+ state
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,57 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:Stream).component_eval {(::Myco.cscope.for_method_definition::Parser = ::Myco::Component.new([::Myco.find_constant(:Common)::Parser], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ ::Myco.cscope.for_method_definition::State = ::Myco::Component.new([::Myco.find_constant(:Common)::Parser::State], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
6
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
7
+ declare_meme(:stream, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
8
+ declare_meme(:raise_error, [], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"&&", self.error_idx) {self.raise(
9
+ ::Myco.find_constant(:SyntaxError),
10
+ "Unexpected item with parser: #{self.rule} at index: #{self.error_idx}, item: #{self.stream.__send__(
11
+ :[],
12
+ self.error_idx
13
+ ).inspect}"
14
+ )})}
15
+ )}}
16
+ .tap { |__c__| __c__.__name__ = :State }
17
+ declare_meme(:parse, [], nil, ::Myco.cscope.dup) { |stream, rule:"root", start_idx:0| (
18
+ worker = self.new_worker
19
+ processor = self.new_processor
20
+ state = ::Myco.find_constant(:State).new({
21
+ :stream => stream,
22
+ :rule => rule.to_sym,
23
+ :start_idx => start_idx.to_i
24
+ })
25
+ state.__send__(
26
+ :end_idx=,
27
+ worker.__send__(
28
+ state.rule,
29
+ state.stream,
30
+ state.start_idx
31
+ )
32
+ )
33
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", state.end_idx) {(
34
+ processor.__send__(
35
+ :string=,
36
+ state.stream
37
+ )
38
+ processor.__send__(
39
+ :capture_items=,
40
+ self.captures_of_worker(worker)
41
+ )
42
+ ::Myco.branch_op(:"&&", (Rubinius::Type.object_respond_to?(self.grammar, :tokenizer).false? ? ::Myco::Void : self.grammar.tokenizer)) {processor.__send__(
43
+ :tokenizer=,
44
+ self.grammar.tokenizer
45
+ )}
46
+ state.__send__(
47
+ :result=,
48
+ processor.process
49
+ )
50
+ )}) {state.__send__(
51
+ :error_idx=,
52
+ self.highest_idx_of_worker(worker)
53
+ )}
54
+ state
55
+ )}
56
+ )}}
57
+ .tap { |__c__| __c__.__name__ = :Parser })})}}.instance
@@ -0,0 +1,136 @@
1
+
2
+ String < EmptyObject {
3
+ Patterns < EmptyObject {
4
+ Base < Common::Patterns::Base { }
5
+
6
+ AnyCharacter < Base {
7
+ construct: Constructions::AnyCharacter.new
8
+ }
9
+ Character < Base { var code
10
+ construct: Constructions::Character.new(code: code)
11
+ }
12
+ CharacterString < Base { var codes
13
+ construct: Constructions::CharacterString.new(codes: codes)
14
+ }
15
+ CharacterSet < Base { var codes
16
+ construct: Constructions::CharacterSet.new(codes: codes)
17
+ }
18
+ CharacterRange < Base { var start, var stop
19
+ construct: Constructions::CharacterRange.new(start: start, stop: stop)
20
+ }
21
+ }
22
+
23
+ Constructions < EmptyObject {
24
+ Base < Common::Constructions::Base { }
25
+
26
+ AnyCharacter < Base { }
27
+ Character < Base { var code }
28
+ CharacterString < Base { var codes }
29
+ CharacterSet < Base { var codes }
30
+ CharacterRange < Base { var start, var stop }
31
+ }
32
+
33
+ Constructions << {
34
+ AnyCharacter << { bytecode: |g| {
35
+ ##
36
+ # overall_fail! if idx == subject.size
37
+ # idx = idx + 1
38
+
39
+ g.push_idx
40
+ g.push_subject; g.send(:size, 0)
41
+ g.send(:"==", 1)
42
+ g.goto_if_true(g.overall_fail)
43
+
44
+ g.meta_push_1
45
+ g.increment_idx
46
+ }}
47
+
48
+ Character << { bytecode: |g| {
49
+ ##
50
+ # overall_fail! unless chr == subject[idx]
51
+ # idx = idx + 1
52
+
53
+ g.push_literal(code.chr)
54
+ g.push_subject_chr_at_idx
55
+ g.send(:"==", 1)
56
+ g.goto_if_false(g.overall_fail)
57
+
58
+ g.meta_push_1
59
+ g.increment_idx
60
+ }}
61
+
62
+ # TODO: get rid of this ugly hack.
63
+ STRING_HACK_PATCH: Ruby.eval("
64
+ class ::String
65
+ def compare_substring_safe(*args)
66
+ compare_substring(*args)
67
+ rescue Exception
68
+ nil
69
+ end
70
+ end
71
+ ")
72
+
73
+ CharacterString << { bytecode: |g| {
74
+ string = codes.map(&:chr).join
75
+ ##
76
+ # begin
77
+ # overall_fail! unless string.compare_substring(subject, idx, string.size) == 0
78
+ # rescue
79
+ # overall_fail!
80
+ # end
81
+ # idx = idx + string.size
82
+
83
+ g.push_literal(string)
84
+ g.push_subject
85
+ g.push_idx
86
+ g.push_int(string.size)
87
+ g.send(:compare_substring_safe, 3)
88
+ g.meta_push_0
89
+
90
+ g.goto_if_not_equal(g.overall_fail)
91
+
92
+ g.push_int(string.size)
93
+ g.increment_idx
94
+ }}
95
+
96
+ CharacterSet << { bytecode: |g| {
97
+ string = codes.map(&:chr).join
98
+ ##
99
+ # overall_fail! unless subject[idx]
100
+ # overall_fail! unless string.find_string(subject[idx], 0)
101
+ # idx = idx + 1
102
+
103
+ g.push_subject_chr_at_idx
104
+ g.goto_if_nil(g.overall_fail) # TODO: avoid second lookup using register instructions
105
+
106
+ g.push_literal(string)
107
+ g.push_subject_chr_at_idx
108
+ g.meta_push_0
109
+ g.send(:find_string, 2)
110
+ g.goto_if_false(g.overall_fail)
111
+
112
+ g.meta_push_1
113
+ g.increment_idx
114
+ }}
115
+
116
+ CharacterRange << { bytecode: |g| {
117
+ codes = Range.new(start,stop); string = codes.map(&:chr).join
118
+ ##
119
+ # overall_fail! unless subject[idx]
120
+ # overall_fail! unless string.find_string(subject[idx], 0)
121
+ # idx = idx + 1
122
+
123
+ g.push_subject_chr_at_idx
124
+ g.goto_if_nil(g.overall_fail) # TODO: avoid second lookup using register instructions
125
+
126
+ g.push_literal(string)
127
+ g.push_subject_chr_at_idx
128
+ g.meta_push_0
129
+ g.send(:find_string, 2)
130
+ g.goto_if_false(g.overall_fail)
131
+
132
+ g.meta_push_1
133
+ g.increment_idx
134
+ }}
135
+ }
136
+ }
@@ -0,0 +1,147 @@
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::String = ::Myco::Component.new([::Myco.find_constant(:EmptyObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ ::Myco.cscope.for_method_definition::Patterns = ::Myco::Component.new([::Myco.find_constant(:EmptyObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
6
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
7
+ ::Myco.cscope.for_method_definition::Base = ::Myco::Component.new([::Myco.find_constant(:Common)::Patterns::Base], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
8
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}
9
+ .tap { |__c__| __c__.__name__ = :Base }
10
+ ::Myco.cscope.for_method_definition::AnyCharacter = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
11
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:construct, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Constructions)::AnyCharacter.new)})}}
12
+ .tap { |__c__| __c__.__name__ = :AnyCharacter }
13
+ ::Myco.cscope.for_method_definition::Character = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
14
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
15
+ declare_meme(:code, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
16
+ declare_meme(:construct, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Constructions)::Character.new({:code => self.code}))}
17
+ )}}
18
+ .tap { |__c__| __c__.__name__ = :Character }
19
+ ::Myco.cscope.for_method_definition::CharacterString = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
20
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
21
+ declare_meme(:codes, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
22
+ declare_meme(:construct, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Constructions)::CharacterString.new({:codes => self.codes}))}
23
+ )}}
24
+ .tap { |__c__| __c__.__name__ = :CharacterString }
25
+ ::Myco.cscope.for_method_definition::CharacterSet = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
26
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
27
+ declare_meme(:codes, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
28
+ declare_meme(:construct, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Constructions)::CharacterSet.new({:codes => self.codes}))}
29
+ )}}
30
+ .tap { |__c__| __c__.__name__ = :CharacterSet }
31
+ ::Myco.cscope.for_method_definition::CharacterRange = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
32
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
33
+ declare_meme(:start, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
34
+ declare_meme(:stop, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
35
+ declare_meme(:construct, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Constructions)::CharacterRange.new({
36
+ :start => self.start,
37
+ :stop => self.stop
38
+ }))}
39
+ )}}
40
+ .tap { |__c__| __c__.__name__ = :CharacterRange }
41
+ )}}
42
+ .tap { |__c__| __c__.__name__ = :Patterns }
43
+ ::Myco.cscope.for_method_definition::Constructions = ::Myco::Component.new([::Myco.find_constant(:EmptyObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
44
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
45
+ ::Myco.cscope.for_method_definition::Base = ::Myco::Component.new([::Myco.find_constant(:Common)::Constructions::Base], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
46
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}
47
+ .tap { |__c__| __c__.__name__ = :Base }
48
+ ::Myco.cscope.for_method_definition::AnyCharacter = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
49
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}
50
+ .tap { |__c__| __c__.__name__ = :AnyCharacter }
51
+ ::Myco.cscope.for_method_definition::Character = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
52
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:code, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil})}}
53
+ .tap { |__c__| __c__.__name__ = :Character }
54
+ ::Myco.cscope.for_method_definition::CharacterString = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
55
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:codes, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil})}}
56
+ .tap { |__c__| __c__.__name__ = :CharacterString }
57
+ ::Myco.cscope.for_method_definition::CharacterSet = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
58
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:codes, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil})}}
59
+ .tap { |__c__| __c__.__name__ = :CharacterSet }
60
+ ::Myco.cscope.for_method_definition::CharacterRange = ::Myco::Component.new([::Myco.find_constant(:Base)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
61
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
62
+ declare_meme(:start, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
63
+ declare_meme(:stop, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
64
+ )}}
65
+ .tap { |__c__| __c__.__name__ = :CharacterRange }
66
+ )}}
67
+ .tap { |__c__| __c__.__name__ = :Constructions }
68
+ ::Myco.find_constant(:Constructions).component_eval {(
69
+ ::Myco.find_constant(:AnyCharacter).component_eval {(declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
70
+ g.push_idx
71
+ g.push_subject
72
+ g.send(
73
+ :size,
74
+ 0
75
+ )
76
+ g.send(
77
+ :==,
78
+ 1
79
+ )
80
+ g.goto_if_true(g.overall_fail)
81
+ g.__send__(:meta_push_1)
82
+ g.increment_idx
83
+ )})}
84
+ ::Myco.find_constant(:Character).component_eval {(declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
85
+ g.push_literal(self.code.chr)
86
+ g.push_subject_chr_at_idx
87
+ g.send(
88
+ :==,
89
+ 1
90
+ )
91
+ g.goto_if_false(g.overall_fail)
92
+ g.__send__(:meta_push_1)
93
+ g.increment_idx
94
+ )})}
95
+ ::Myco.cscope.for_method_definition::STRING_HACK_PATCH = (::Myco.find_constant(:Ruby).eval("\n class ::String\n def compare_substring_safe(*args)\n compare_substring(*args)\n rescue Exception\n nil\n end\n end\n "))
96
+ ::Myco.find_constant(:CharacterString).component_eval {(declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
97
+ string = self.codes.map(&:chr).join
98
+ g.push_literal(string)
99
+ g.push_subject
100
+ g.push_idx
101
+ g.push_int(string.size)
102
+ g.send(
103
+ :compare_substring_safe,
104
+ 3
105
+ )
106
+ g.__send__(:meta_push_0)
107
+ g.goto_if_not_equal(g.overall_fail)
108
+ g.push_int(string.size)
109
+ g.increment_idx
110
+ )})}
111
+ ::Myco.find_constant(:CharacterSet).component_eval {(declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
112
+ string = self.codes.map(&:chr).join
113
+ g.push_subject_chr_at_idx
114
+ g.goto_if_nil(g.overall_fail)
115
+ g.push_literal(string)
116
+ g.push_subject_chr_at_idx
117
+ g.__send__(:meta_push_0)
118
+ g.send(
119
+ :find_string,
120
+ 2
121
+ )
122
+ g.goto_if_false(g.overall_fail)
123
+ g.__send__(:meta_push_1)
124
+ g.increment_idx
125
+ )})}
126
+ ::Myco.find_constant(:CharacterRange).component_eval {(declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
127
+ codes = ::Myco.find_constant(:Range).new(
128
+ self.start,
129
+ self.stop
130
+ )
131
+ string = codes.map(&:chr).join
132
+ g.push_subject_chr_at_idx
133
+ g.goto_if_nil(g.overall_fail)
134
+ g.push_literal(string)
135
+ g.push_subject_chr_at_idx
136
+ g.__send__(:meta_push_0)
137
+ g.send(
138
+ :find_string,
139
+ 2
140
+ )
141
+ g.goto_if_false(g.overall_fail)
142
+ g.__send__(:meta_push_1)
143
+ g.increment_idx
144
+ )})}
145
+ )}
146
+ )}}
147
+ .tap { |__c__| __c__.__name__ = :String })}}.instance