myco 0.1.9 → 0.1.10
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.my.rb +50 -14
- data/lib/myco/bootstrap/add_method.rb +5 -5
- data/lib/myco/bootstrap/meme.rb +2 -1
- data/lib/myco/code_tools/AST.my.rb +211 -43
- data/lib/myco/code_tools/AST/ArgumentAssembly.my.rb +92 -48
- data/lib/myco/code_tools/AST/ArrayAssembly.my.rb +39 -27
- data/lib/myco/code_tools/AST/Block.my.rb +176 -112
- data/lib/myco/code_tools/AST/BlockArgument.my.rb +29 -17
- data/lib/myco/code_tools/AST/BlockLiteral.my.rb +37 -17
- data/lib/myco/code_tools/AST/BlockParameter.my.rb +25 -9
- data/lib/myco/code_tools/AST/BranchOperator.my.rb +95 -75
- data/lib/myco/code_tools/AST/ConstantAccess.my.rb +52 -32
- data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +52 -36
- data/lib/myco/code_tools/AST/ConstantDefine.my.rb +50 -26
- data/lib/myco/code_tools/AST/DeclareCategory.my.rb +38 -18
- data/lib/myco/code_tools/AST/DeclareExtension.my.rb +29 -13
- data/lib/myco/code_tools/AST/DeclareFile.my.rb +51 -31
- data/lib/myco/code_tools/AST/DeclareMeme.my.rb +96 -68
- data/lib/myco/code_tools/AST/DeclareObject.my.rb +66 -42
- data/lib/myco/code_tools/AST/DeclareString.my.rb +39 -19
- data/lib/myco/code_tools/AST/DeclaredScope.my.rb +92 -64
- data/lib/myco/code_tools/AST/Invoke.my +8 -4
- data/lib/myco/code_tools/AST/Invoke.my.rb +74 -31
- data/lib/myco/code_tools/AST/InvokeMethod.my.rb +34 -14
- data/lib/myco/code_tools/AST/KeywordAssembly.my.rb +36 -24
- data/lib/myco/code_tools/AST/KeywordOptionalParameter.my.rb +28 -8
- data/lib/myco/code_tools/AST/KeywordRequiredParameter.my.rb +23 -7
- data/lib/myco/code_tools/AST/KeywordRestParameter.my.rb +23 -7
- data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my.rb +24 -12
- data/lib/myco/code_tools/AST/LocalVariableAssignment.my.rb +30 -10
- data/lib/myco/code_tools/AST/Node.my.rb +234 -102
- data/lib/myco/code_tools/AST/NumericLiteral.my.rb +18 -6
- data/lib/myco/code_tools/AST/OptionalParameter.my.rb +33 -13
- data/lib/myco/code_tools/AST/ParameterAssembly.my.rb +275 -211
- data/lib/myco/code_tools/AST/PipeOperator.my.rb +42 -18
- data/lib/myco/code_tools/AST/Quest.my.rb +65 -37
- data/lib/myco/code_tools/AST/RequiredParameter.my.rb +20 -4
- data/lib/myco/code_tools/AST/RestParameter.my.rb +20 -4
- data/lib/myco/code_tools/AST/Script.my.rb +51 -23
- data/lib/myco/code_tools/AST/Sequence.my.rb +22 -10
- data/lib/myco/code_tools/AST/SplatValue.my.rb +28 -16
- data/lib/myco/code_tools/AST/StringCompose.my.rb +23 -11
- data/lib/myco/code_tools/AST/StringLiteral.my.rb +19 -7
- data/lib/myco/code_tools/AST/SymbolCompose.my.rb +27 -15
- data/lib/myco/code_tools/AST/SymbolLiteral.my.rb +18 -6
- data/lib/myco/code_tools/AST/ToRuby.my.rb +581 -341
- data/lib/myco/code_tools/AST/misc.my.rb +87 -35
- data/lib/myco/code_tools/Parser.my.rb +39 -12
- data/lib/myco/code_tools/parser/MycoBuilder.my.rb +106 -90
- data/lib/myco/code_tools/parser/MycoCharacterClasses.my.rb +98 -50
- data/lib/myco/code_tools/parser/MycoGrammar.my +1 -6
- data/lib/myco/code_tools/parser/MycoGrammar.my.rb +2124 -1710
- data/lib/myco/code_tools/parser/MycoTokens.my +0 -5
- data/lib/myco/code_tools/parser/MycoTokens.my.rb +387 -156
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my.rb +55 -11
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +321 -205
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my.rb +223 -127
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my.rb +188 -72
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common/Parser.my +48 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common/Parser.my.rb +365 -189
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my.rb +313 -233
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +99 -55
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +493 -325
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my.rb +138 -114
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my.rb +56 -44
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my.rb +173 -93
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my.rb +90 -70
- data/lib/myco/command.my.rb +85 -25
- data/lib/myco/command/inoculate.my.rb +219 -127
- data/lib/myco/core.my.rb +20 -4
- data/lib/myco/core/BasicDecorators.my.rb +211 -119
- data/lib/myco/core/BasicObject.my.rb +108 -44
- data/lib/myco/core/Category.my.rb +37 -13
- data/lib/myco/core/Decorator.my.rb +35 -27
- data/lib/myco/core/FileToplevel.my.rb +55 -27
- data/lib/myco/core/Loop.my.rb +16 -8
- data/lib/myco/core/Object.my.rb +34 -14
- data/lib/myco/core/Ruby.my.rb +13 -5
- data/lib/myco/core/Switch.my.rb +79 -47
- data/lib/myco/tools/BasicCommand.my.rb +79 -47
- data/lib/myco/tools/mycompile.my.rb +153 -69
- data/lib/myco/version.rb +1 -1
- metadata +34 -52
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +0 -144
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +0 -221
- data/lib/myco/code_tools/parser/pegleromyces/spec/BasicSpec.my +0 -35
- data/lib/myco/code_tools/parser/pegleromyces/spec/BasicSpec.my.rb +0 -35
- data/lib/myco/code_tools/parser/pegleromyces/spec/Grammar.test.my +0 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/Grammar.test.my.rb +0 -9
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my +0 -162
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my.rb +0 -353
- data/lib/myco/code_tools/parser/pegleromyces/spec/Processor.test.my +0 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/Processor.test.my.rb +0 -9
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my +0 -49
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my.rb +0 -119
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my +0 -131
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my.rb +0 -595
- data/lib/myco/code_tools/parser/pegleromyces/spec/String/Parser.test.my +0 -120
- data/lib/myco/code_tools/parser/pegleromyces/spec/String/Parser.test.my.rb +0 -350
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my +0 -14
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my.rb +0 -12
@@ -1,144 +0,0 @@
|
|
1
|
-
|
2
|
-
Common << {
|
3
|
-
Parser < BasicObject {
|
4
|
-
State < BasicObject {
|
5
|
-
var string
|
6
|
-
var start_idx
|
7
|
-
var end_idx
|
8
|
-
var rule
|
9
|
-
var result
|
10
|
-
|
11
|
-
var error_idx
|
12
|
-
var error_row
|
13
|
-
var error_col
|
14
|
-
|
15
|
-
raise_error: self.error_idx && raise(SyntaxError
|
16
|
-
"Unexpected character with parser: "self.rule \
|
17
|
-
" near line: "self.error_row \
|
18
|
-
", column: "self.error_col".\n" \
|
19
|
-
self.string.each_line.to_a[self.error_row - 1]"" \
|
20
|
-
(' ' * [(self.error_col - 1), 0].max)"^"
|
21
|
-
)
|
22
|
-
}
|
23
|
-
|
24
|
-
var debug_mode: false
|
25
|
-
|
26
|
-
var grammar: Grammar.new
|
27
|
-
var builder: null
|
28
|
-
|
29
|
-
new_worker: set_up_worker(prototype.new)
|
30
|
-
new_processor: Processor.new(builder: builder)
|
31
|
-
|
32
|
-
var prototype: compile_prototype
|
33
|
-
|
34
|
-
refresh: self.prototype = compile_prototype
|
35
|
-
|
36
|
-
compile_prototype: {
|
37
|
-
proto = Component.new
|
38
|
-
grammar.construct_all_rules
|
39
|
-
grammar.rule_table.each |name, rule| {
|
40
|
-
compile_rule_into(proto, name, rule)
|
41
|
-
}
|
42
|
-
proto
|
43
|
-
}
|
44
|
-
|
45
|
-
compile_rule_into: |proto, name, rule| {
|
46
|
-
construct = rule.inner.construct
|
47
|
-
|
48
|
-
Myco.add_dynamic_method(proto, name, "(compiled parser)") |g| {
|
49
|
-
g.extend(BytecodeHelpers)
|
50
|
-
g.debug_mode = self.debug_mode
|
51
|
-
g.rule_start
|
52
|
-
construct.bytecode(g)
|
53
|
-
g.rule_finish
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
compile_generator: |name, file, line=1, &block| {
|
58
|
-
g = Myco::ToolSet::Generator.new
|
59
|
-
g.name = name
|
60
|
-
g.file = file
|
61
|
-
g.set_line(line)
|
62
|
-
|
63
|
-
block.call(g)
|
64
|
-
|
65
|
-
g.ret
|
66
|
-
g.close
|
67
|
-
g.use_detected
|
68
|
-
g
|
69
|
-
}
|
70
|
-
|
71
|
-
compile_code: |name, file, line=1, &block| {
|
72
|
-
g = compile_generator(name, file, line, &block)
|
73
|
-
g.encode
|
74
|
-
g.package(Rubinius::CompiledCode)
|
75
|
-
}
|
76
|
-
|
77
|
-
save_prototype: |filename| {
|
78
|
-
code = compile_code(:__script__, :"(snippet)") |g| {
|
79
|
-
g.push_cpath_top; g.find_const(:Class)
|
80
|
-
g.create_block(compile_generator(:__block__, :"(snippet)") |g| {
|
81
|
-
prototype.instance_methods.each |name| {
|
82
|
-
code = prototype.instance_method(name).executable
|
83
|
-
if(code.is_a?(Rubinius::CompiledCode)) {
|
84
|
-
g.push_rubinius
|
85
|
-
g.push_literal(name)
|
86
|
-
g.push_literal(code)
|
87
|
-
g.push_scope
|
88
|
-
g.push_variables; g.send(:method_visibility, 0)
|
89
|
-
g.send(:add_defn_method, 4)
|
90
|
-
}
|
91
|
-
}
|
92
|
-
})
|
93
|
-
g.send_with_block(:new, 0)
|
94
|
-
}
|
95
|
-
|
96
|
-
Myco::ToolSet::CompiledFile.dump(code, filename, Rubinius::Signature, Rubinius::RUBY_LIB_VERSION)
|
97
|
-
}
|
98
|
-
|
99
|
-
load_prototype: |filename| {
|
100
|
-
loader = Myco::CodeLoader::BytecodeLoader.new(filename)
|
101
|
-
loader.bind_to(call_depth:1)
|
102
|
-
self.prototype = loader.load
|
103
|
-
}
|
104
|
-
|
105
|
-
set_up_worker: |worker| {
|
106
|
-
worker.__set_ivar__(:"@captures", [])
|
107
|
-
worker.__set_ivar__(:"@highest_idx", 0)
|
108
|
-
worker
|
109
|
-
}
|
110
|
-
|
111
|
-
captures_of_worker: |worker|
|
112
|
-
worker.__get_ivar__(:"@captures")
|
113
|
-
|
114
|
-
highest_idx_of_worker: |worker|
|
115
|
-
worker.__get_ivar__(:"@highest_idx")
|
116
|
-
|
117
|
-
|
118
|
-
# Match and process the given string using the current grammar
|
119
|
-
parse: |string, rule:"root", start_idx:0| {
|
120
|
-
worker = new_worker
|
121
|
-
processor = new_processor
|
122
|
-
state = State.new(
|
123
|
-
string: string.to_s
|
124
|
-
rule: rule.to_sym
|
125
|
-
start_idx: start_idx.to_i
|
126
|
-
)
|
127
|
-
|
128
|
-
state.end_idx = worker.__send__(state.rule, state.string, state.start_idx)
|
129
|
-
|
130
|
-
state.end_idx &? (
|
131
|
-
processor.string = state.string
|
132
|
-
processor.capture_items = captures_of_worker(worker)
|
133
|
-
grammar.?tokenizer && (processor.tokenizer = grammar.tokenizer)
|
134
|
-
state.result = processor.process
|
135
|
-
) ?? (
|
136
|
-
state.error_idx = highest_idx_of_worker(worker)
|
137
|
-
pos = processor.position_of(state.error_idx, state.string)
|
138
|
-
state.error_row = pos.first
|
139
|
-
state.error_col = pos.last
|
140
|
-
)
|
141
|
-
state
|
142
|
-
}
|
143
|
-
}
|
144
|
-
}
|
@@ -1,221 +0,0 @@
|
|
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(:Common).component_eval {(::Myco.cscope.for_method_definition::Parser = ::Myco::Component.new([::Myco.find_constant(:BasicObject)], ::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(:BasicObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
6
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
7
|
-
declare_meme(:string, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
8
|
-
declare_meme(:start_idx, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
9
|
-
declare_meme(:end_idx, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
10
|
-
declare_meme(:rule, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
11
|
-
declare_meme(:result, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
12
|
-
declare_meme(:error_idx, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
13
|
-
declare_meme(:error_row, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
14
|
-
declare_meme(:error_col, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
15
|
-
declare_meme(:raise_error, [], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"&&", self.error_idx) {self.raise(
|
16
|
-
::Myco.find_constant(:SyntaxError),
|
17
|
-
"Unexpected character with parser: #{self.rule} near line: #{self.error_row}, column: #{self.error_col}.\n#{self.string.each_line.to_a.__send__(
|
18
|
-
:[],
|
19
|
-
self.error_row.__send__(
|
20
|
-
:-,
|
21
|
-
1
|
22
|
-
)
|
23
|
-
)}#{" ".__send__(
|
24
|
-
:*,
|
25
|
-
[
|
26
|
-
self.error_col.__send__(
|
27
|
-
:-,
|
28
|
-
1
|
29
|
-
),
|
30
|
-
0
|
31
|
-
].max
|
32
|
-
)}^"
|
33
|
-
)})}
|
34
|
-
)}}
|
35
|
-
.tap { |__c__| __c__.__name__ = :State }
|
36
|
-
declare_meme(:debug_mode, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (false)}
|
37
|
-
declare_meme(:grammar, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Grammar).new)}
|
38
|
-
declare_meme(:builder, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (nil)}
|
39
|
-
declare_meme(:new_worker, [], nil, ::Myco.cscope.dup) { |*| (self.set_up_worker(self.prototype.new))}
|
40
|
-
declare_meme(:new_processor, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Processor).new({:builder => self.builder}))}
|
41
|
-
declare_meme(:prototype, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (self.compile_prototype)}
|
42
|
-
declare_meme(:refresh, [], nil, ::Myco.cscope.dup) { |*| (self.__send__(
|
43
|
-
:prototype=,
|
44
|
-
self.compile_prototype
|
45
|
-
))}
|
46
|
-
declare_meme(:compile_prototype, [], nil, ::Myco.cscope.dup) { |*| (
|
47
|
-
proto = ::Myco.find_constant(:Component).new
|
48
|
-
self.grammar.construct_all_rules
|
49
|
-
self.grammar.rule_table.each { |name, rule| (self.compile_rule_into(
|
50
|
-
proto,
|
51
|
-
name,
|
52
|
-
rule
|
53
|
-
))}
|
54
|
-
proto
|
55
|
-
)}
|
56
|
-
declare_meme(:compile_rule_into, [], nil, ::Myco.cscope.dup) { |proto, name, rule| (
|
57
|
-
construct = rule.inner.construct
|
58
|
-
::Myco.find_constant(:Myco).add_dynamic_method(
|
59
|
-
proto,
|
60
|
-
name,
|
61
|
-
"(compiled parser)"
|
62
|
-
) { |g| (
|
63
|
-
g.extend(::Myco.find_constant(:BytecodeHelpers))
|
64
|
-
g.__send__(
|
65
|
-
:debug_mode=,
|
66
|
-
self.debug_mode
|
67
|
-
)
|
68
|
-
g.rule_start
|
69
|
-
construct.bytecode(g)
|
70
|
-
g.rule_finish
|
71
|
-
)}
|
72
|
-
)}
|
73
|
-
declare_meme(:compile_generator, [], nil, ::Myco.cscope.dup) { |name, file, line=1, &block| (
|
74
|
-
g = ::Myco.find_constant(:Myco)::ToolSet::Generator.new
|
75
|
-
g.__send__(
|
76
|
-
:name=,
|
77
|
-
name
|
78
|
-
)
|
79
|
-
g.__send__(
|
80
|
-
:file=,
|
81
|
-
file
|
82
|
-
)
|
83
|
-
g.set_line(line)
|
84
|
-
block.call(g)
|
85
|
-
g.ret
|
86
|
-
g.close
|
87
|
-
g.use_detected
|
88
|
-
g
|
89
|
-
)}
|
90
|
-
declare_meme(:compile_code, [], nil, ::Myco.cscope.dup) { |name, file, line=1, &block| (
|
91
|
-
g = self.compile_generator(
|
92
|
-
name,
|
93
|
-
file,
|
94
|
-
line,
|
95
|
-
&block
|
96
|
-
)
|
97
|
-
g.encode
|
98
|
-
g.package(::Myco.find_constant(:Rubinius)::CompiledCode)
|
99
|
-
)}
|
100
|
-
declare_meme(:save_prototype, [], nil, ::Myco.cscope.dup) { |filename| (
|
101
|
-
code = self.compile_code(
|
102
|
-
:__script__,
|
103
|
-
:"(snippet)"
|
104
|
-
) { |g| (
|
105
|
-
g.push_cpath_top
|
106
|
-
g.find_const(:Class)
|
107
|
-
g.create_block(self.compile_generator(
|
108
|
-
:__block__,
|
109
|
-
:"(snippet)"
|
110
|
-
) { |g| (self.prototype.instance_methods.each { |name| (
|
111
|
-
code = self.prototype.instance_method(name).executable
|
112
|
-
self.__send__(
|
113
|
-
:if,
|
114
|
-
code.__send__(
|
115
|
-
:is_a?,
|
116
|
-
::Myco.find_constant(:Rubinius)::CompiledCode
|
117
|
-
)
|
118
|
-
) { || (
|
119
|
-
g.push_rubinius
|
120
|
-
g.push_literal(name)
|
121
|
-
g.push_literal(code)
|
122
|
-
g.push_scope
|
123
|
-
g.push_variables
|
124
|
-
g.send(
|
125
|
-
:method_visibility,
|
126
|
-
0
|
127
|
-
)
|
128
|
-
g.send(
|
129
|
-
:add_defn_method,
|
130
|
-
4
|
131
|
-
)
|
132
|
-
)}
|
133
|
-
)})})
|
134
|
-
g.send_with_block(
|
135
|
-
:new,
|
136
|
-
0
|
137
|
-
)
|
138
|
-
)}
|
139
|
-
::Myco.find_constant(:Myco)::ToolSet::CompiledFile.dump(
|
140
|
-
code,
|
141
|
-
filename,
|
142
|
-
::Myco.find_constant(:Rubinius)::Signature,
|
143
|
-
::Myco.find_constant(:Rubinius)::RUBY_LIB_VERSION
|
144
|
-
)
|
145
|
-
)}
|
146
|
-
declare_meme(:load_prototype, [], nil, ::Myco.cscope.dup) { |filename| (
|
147
|
-
loader = ::Myco.find_constant(:Myco)::CodeLoader::BytecodeLoader.new(filename)
|
148
|
-
loader.bind_to({:call_depth => 1})
|
149
|
-
self.__send__(
|
150
|
-
:prototype=,
|
151
|
-
loader.load
|
152
|
-
)
|
153
|
-
)}
|
154
|
-
declare_meme(:set_up_worker, [], nil, ::Myco.cscope.dup) { |worker| (
|
155
|
-
worker.__set_ivar__(
|
156
|
-
:@captures,
|
157
|
-
[]
|
158
|
-
)
|
159
|
-
worker.__set_ivar__(
|
160
|
-
:@highest_idx,
|
161
|
-
0
|
162
|
-
)
|
163
|
-
worker
|
164
|
-
)}
|
165
|
-
declare_meme(:captures_of_worker, [], nil, ::Myco.cscope.dup) { |worker| (worker.__get_ivar__(:@captures))}
|
166
|
-
declare_meme(:highest_idx_of_worker, [], nil, ::Myco.cscope.dup) { |worker| (worker.__get_ivar__(:@highest_idx))}
|
167
|
-
declare_meme(:parse, [], nil, ::Myco.cscope.dup) { |string, rule:"root", start_idx:0| (
|
168
|
-
worker = self.new_worker
|
169
|
-
processor = self.new_processor
|
170
|
-
state = ::Myco.find_constant(:State).new({
|
171
|
-
:string => string.to_s,
|
172
|
-
:rule => rule.to_sym,
|
173
|
-
:start_idx => start_idx.to_i
|
174
|
-
})
|
175
|
-
state.__send__(
|
176
|
-
:end_idx=,
|
177
|
-
worker.__send__(
|
178
|
-
state.rule,
|
179
|
-
state.string,
|
180
|
-
state.start_idx
|
181
|
-
)
|
182
|
-
)
|
183
|
-
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", state.end_idx) {(
|
184
|
-
processor.__send__(
|
185
|
-
:string=,
|
186
|
-
state.string
|
187
|
-
)
|
188
|
-
processor.__send__(
|
189
|
-
:capture_items=,
|
190
|
-
self.captures_of_worker(worker)
|
191
|
-
)
|
192
|
-
::Myco.branch_op(:"&&", (Rubinius::Type.object_respond_to?(self.grammar, :tokenizer).false? ? ::Myco::Void : self.grammar.tokenizer)) {processor.__send__(
|
193
|
-
:tokenizer=,
|
194
|
-
self.grammar.tokenizer
|
195
|
-
)}
|
196
|
-
state.__send__(
|
197
|
-
:result=,
|
198
|
-
processor.process
|
199
|
-
)
|
200
|
-
)}) {(
|
201
|
-
state.__send__(
|
202
|
-
:error_idx=,
|
203
|
-
self.highest_idx_of_worker(worker)
|
204
|
-
)
|
205
|
-
pos = processor.position_of(
|
206
|
-
state.error_idx,
|
207
|
-
state.string
|
208
|
-
)
|
209
|
-
state.__send__(
|
210
|
-
:error_row=,
|
211
|
-
pos.first
|
212
|
-
)
|
213
|
-
state.__send__(
|
214
|
-
:error_col=,
|
215
|
-
pos.last
|
216
|
-
)
|
217
|
-
)}
|
218
|
-
state
|
219
|
-
)}
|
220
|
-
)}}
|
221
|
-
.tap { |__c__| __c__.__name__ = :Parser })})}}.instance
|
@@ -1,35 +0,0 @@
|
|
1
|
-
|
2
|
-
# Implementation from central Myco repository
|
3
|
-
# TODO: import instead of copying this code
|
4
|
-
|
5
|
-
BasicSpec < Object {
|
6
|
-
assert: |arg, message="expected "arg.inspect" to be truthy"|
|
7
|
-
arg || raise(message)
|
8
|
-
|
9
|
-
refute: |arg, message="expected "arg.inspect" to be falsey"|
|
10
|
-
arg && raise(message)
|
11
|
-
|
12
|
-
assert_equal: |a, b, message="expected "a.inspect" to equal "b.inspect""|
|
13
|
-
a == b || raise(message)
|
14
|
-
|
15
|
-
refute_equal: |a, b, message="expected "a.inspect" to not equal "b.inspect""|
|
16
|
-
a == b && raise(message)
|
17
|
-
|
18
|
-
assert_is_a: |a, b, message="expected "a.inspect" to be a "b.inspect""|
|
19
|
-
a.is_a?(b) || raise(message)
|
20
|
-
|
21
|
-
name: to_s
|
22
|
-
|
23
|
-
on creation: {
|
24
|
-
self.?tests && (
|
25
|
-
STDOUT.print(""self.name" ")
|
26
|
-
self.tests.memes.each |name, test| { test.result; STDOUT.print(".") }
|
27
|
-
STDOUT.print("\n")
|
28
|
-
)
|
29
|
-
}
|
30
|
-
|
31
|
-
[decorators]
|
32
|
-
|
33
|
-
const it: Decorator { }
|
34
|
-
const specify: Decorator { }
|
35
|
-
}
|
@@ -1,35 +0,0 @@
|
|
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::BasicSpec = ::Myco::Component.new([::Myco.find_constant(:Object)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
4
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
5
|
-
declare_meme(:assert, [], nil, ::Myco.cscope.dup) { |arg, message="expected #{arg.inspect} to be truthy"| (::Myco.branch_op(:"||", arg) {self.raise(message)})}
|
6
|
-
declare_meme(:refute, [], nil, ::Myco.cscope.dup) { |arg, message="expected #{arg.inspect} to be falsey"| (::Myco.branch_op(:"&&", arg) {self.raise(message)})}
|
7
|
-
declare_meme(:assert_equal, [], nil, ::Myco.cscope.dup) { |a, b, message="expected #{a.inspect} to equal #{b.inspect}"| (::Myco.branch_op(:"||", a.__send__(
|
8
|
-
:==,
|
9
|
-
b
|
10
|
-
)) {self.raise(message)})}
|
11
|
-
declare_meme(:refute_equal, [], nil, ::Myco.cscope.dup) { |a, b, message="expected #{a.inspect} to not equal #{b.inspect}"| (::Myco.branch_op(:"&&", a.__send__(
|
12
|
-
:==,
|
13
|
-
b
|
14
|
-
)) {self.raise(message)})}
|
15
|
-
declare_meme(:assert_is_a, [], nil, ::Myco.cscope.dup) { |a, b, message="expected #{a.inspect} to be a #{b.inspect}"| (::Myco.branch_op(:"||", a.__send__(
|
16
|
-
:is_a?,
|
17
|
-
b
|
18
|
-
)) {self.raise(message)})}
|
19
|
-
declare_meme(:name, [], nil, ::Myco.cscope.dup) { |*| (self.to_s)}
|
20
|
-
declare_meme(:creation, [[:on, []]], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"&&", (Rubinius::Type.object_respond_to?(self, :tests).false? ? ::Myco::Void : self.tests)) {(
|
21
|
-
::Myco.find_constant(:STDOUT).print("#{self.name} ")
|
22
|
-
self.tests.memes.each { |name, test| (
|
23
|
-
test.result
|
24
|
-
::Myco.find_constant(:STDOUT).print(".")
|
25
|
-
)}
|
26
|
-
::Myco.find_constant(:STDOUT).print("\n")
|
27
|
-
)})}
|
28
|
-
__category__(:decorators).component_eval {(
|
29
|
-
declare_meme(:it, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
30
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}.instance)}
|
31
|
-
declare_meme(:specify, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
32
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}.instance)}
|
33
|
-
)}
|
34
|
-
)}}
|
35
|
-
.tap { |__c__| __c__.__name__ = :BasicSpec })}}.instance
|