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,9 +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::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
|
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
BasicSpec {
|
3
|
-
name: "Stream::Parser"
|
4
|
-
|
5
|
-
new_parser: Stream::Parser.new
|
6
|
-
|
7
|
-
[tests]
|
8
|
-
|
9
|
-
it "can match from a minimal grammar": {
|
10
|
-
parser = new_parser
|
11
|
-
parser.grammar = Grammar {
|
12
|
-
[rules]
|
13
|
-
rule root: si.+
|
14
|
-
}
|
15
|
-
state = parser.parse([:x, :y, :z])
|
16
|
-
assert_equal(state.end_idx, 3)
|
17
|
-
}
|
18
|
-
|
19
|
-
it "can match from a minimal grammar with rules in the stream items": {
|
20
|
-
parser = new_parser
|
21
|
-
parser.grammar = Grammar {
|
22
|
-
[rules]
|
23
|
-
rule root: si([:to_sym, [], :x]).+
|
24
|
-
}
|
25
|
-
state = parser.parse([:x, :x, :x])
|
26
|
-
assert_equal(state.end_idx, 3)
|
27
|
-
}
|
28
|
-
|
29
|
-
it "can create a result from reductions": {
|
30
|
-
parser = new_parser
|
31
|
-
parser.grammar = Grammar {
|
32
|
-
[rules]
|
33
|
-
rule root: r(si.+[:list]) { list.join('.') }[:root]
|
34
|
-
}
|
35
|
-
state = parser.parse([:x, :y, :z])
|
36
|
-
assert_equal(state.result[:root], 'x.y.z')
|
37
|
-
}
|
38
|
-
|
39
|
-
it "captures individual items for single-item captures": {
|
40
|
-
parser = new_parser
|
41
|
-
parser.grammar = Grammar {
|
42
|
-
[rules]
|
43
|
-
rule root: r(si[:a] + si[:b] + si.+[:rest]) { [a, b, rest] }[:root]
|
44
|
-
}
|
45
|
-
state = parser.parse([:x, :y, :z])
|
46
|
-
assert_equal(state.result[:root], [:x, :y, [:z]])
|
47
|
-
}
|
48
|
-
|
49
|
-
}
|
@@ -1,119 +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::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) { |*| ("Stream::Parser")}
|
6
|
-
declare_meme(:new_parser, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Stream)::Parser.new)}
|
7
|
-
__category__(:tests).component_eval {(
|
8
|
-
declare_meme(:"can match from a minimal grammar", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
9
|
-
parser = self.new_parser
|
10
|
-
parser.__send__(
|
11
|
-
:grammar=,
|
12
|
-
::Myco::Component.new([::Myco.find_constant(:Grammar)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
13
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(__category__(:rules).component_eval {(declare_meme(:root, [[:rule, []]], nil, ::Myco.cscope.dup) { |*| (self.si.__send__(:+))})})}}.instance
|
14
|
-
)
|
15
|
-
state = parser.parse([
|
16
|
-
:x,
|
17
|
-
:y,
|
18
|
-
:z
|
19
|
-
])
|
20
|
-
self.assert_equal(
|
21
|
-
state.end_idx,
|
22
|
-
3
|
23
|
-
)
|
24
|
-
)}
|
25
|
-
declare_meme(:"can match from a minimal grammar with rules in the stream items", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
26
|
-
parser = self.new_parser
|
27
|
-
parser.__send__(
|
28
|
-
:grammar=,
|
29
|
-
::Myco::Component.new([::Myco.find_constant(:Grammar)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
30
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(__category__(:rules).component_eval {(declare_meme(:root, [[:rule, []]], nil, ::Myco.cscope.dup) { |*| (self.si([
|
31
|
-
:to_sym,
|
32
|
-
[],
|
33
|
-
:x
|
34
|
-
]).__send__(:+))})})}}.instance
|
35
|
-
)
|
36
|
-
state = parser.parse([
|
37
|
-
:x,
|
38
|
-
:x,
|
39
|
-
:x
|
40
|
-
])
|
41
|
-
self.assert_equal(
|
42
|
-
state.end_idx,
|
43
|
-
3
|
44
|
-
)
|
45
|
-
)}
|
46
|
-
declare_meme(:"can create a result from reductions", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
47
|
-
parser = self.new_parser
|
48
|
-
parser.__send__(
|
49
|
-
:grammar=,
|
50
|
-
::Myco::Component.new([::Myco.find_constant(:Grammar)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
51
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(__category__(:rules).component_eval {(declare_meme(:root, [[:rule, []]], nil, ::Myco.cscope.dup) { |*| (self.r(self.si.__send__(:+).__send__(
|
52
|
-
:[],
|
53
|
-
:list
|
54
|
-
)) { || (self.list.join("."))}.__send__(
|
55
|
-
:[],
|
56
|
-
:root
|
57
|
-
))})})}}.instance
|
58
|
-
)
|
59
|
-
state = parser.parse([
|
60
|
-
:x,
|
61
|
-
:y,
|
62
|
-
:z
|
63
|
-
])
|
64
|
-
self.assert_equal(
|
65
|
-
state.result.__send__(
|
66
|
-
:[],
|
67
|
-
:root
|
68
|
-
),
|
69
|
-
"x.y.z"
|
70
|
-
)
|
71
|
-
)}
|
72
|
-
declare_meme(:"captures individual items for single-item captures", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
73
|
-
parser = self.new_parser
|
74
|
-
parser.__send__(
|
75
|
-
:grammar=,
|
76
|
-
::Myco::Component.new([::Myco.find_constant(:Grammar)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
77
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(__category__(:rules).component_eval {(declare_meme(:root, [[:rule, []]], nil, ::Myco.cscope.dup) { |*| (self.r(self.si.__send__(
|
78
|
-
:[],
|
79
|
-
:a
|
80
|
-
).__send__(
|
81
|
-
:+,
|
82
|
-
self.si.__send__(
|
83
|
-
:[],
|
84
|
-
:b
|
85
|
-
)
|
86
|
-
).__send__(
|
87
|
-
:+,
|
88
|
-
self.si.__send__(:+).__send__(
|
89
|
-
:[],
|
90
|
-
:rest
|
91
|
-
)
|
92
|
-
)) { || ([
|
93
|
-
self.a,
|
94
|
-
self.b,
|
95
|
-
self.rest
|
96
|
-
])}.__send__(
|
97
|
-
:[],
|
98
|
-
:root
|
99
|
-
))})})}}.instance
|
100
|
-
)
|
101
|
-
state = parser.parse([
|
102
|
-
:x,
|
103
|
-
:y,
|
104
|
-
:z
|
105
|
-
])
|
106
|
-
self.assert_equal(
|
107
|
-
state.result.__send__(
|
108
|
-
:[],
|
109
|
-
:root
|
110
|
-
),
|
111
|
-
[
|
112
|
-
:x,
|
113
|
-
:y,
|
114
|
-
[:z]
|
115
|
-
]
|
116
|
-
)
|
117
|
-
)}
|
118
|
-
)}
|
119
|
-
)}}.instance)}}.instance
|
@@ -1,131 +0,0 @@
|
|
1
|
-
|
2
|
-
BasicSpec {
|
3
|
-
name: "Stream::Patterns"
|
4
|
-
|
5
|
-
new_parser: Stream::Parser.new
|
6
|
-
|
7
|
-
var shorthand: Common::Patterns::ShorthandMethods { }
|
8
|
-
si: |*args| shorthand.si(*args)
|
9
|
-
esi: |*args| shorthand.esi(*args)
|
10
|
-
|
11
|
-
match?: |pattern, *items| {
|
12
|
-
parser = new_parser
|
13
|
-
parser.grammar = Grammar {
|
14
|
-
[rules]
|
15
|
-
rule root: pattern
|
16
|
-
}
|
17
|
-
state = parser.parse(items)
|
18
|
-
state.end_idx == items.size
|
19
|
-
}
|
20
|
-
|
21
|
-
assert_match: |pattern, *items| assert(
|
22
|
-
match?(pattern, *items)
|
23
|
-
"Expected "pattern.inspect" to match "items.inspect"."
|
24
|
-
)
|
25
|
-
|
26
|
-
refute_match: |pattern, *items| assert(
|
27
|
-
!match?(pattern, *items)
|
28
|
-
"Expected "pattern.inspect" not to match "items.inspect"."
|
29
|
-
)
|
30
|
-
|
31
|
-
var test_item: BasicObject {
|
32
|
-
return_true: true
|
33
|
-
return_false: false
|
34
|
-
return_null: null
|
35
|
-
return_88: 88
|
36
|
-
return_99: 99
|
37
|
-
return_foo: :foo
|
38
|
-
return_bar: :bar
|
39
|
-
return_foo_s: "foo"
|
40
|
-
return_bar_s: "bar"
|
41
|
-
return_object: BasicObject.new
|
42
|
-
first_arg: |*a| a[0]
|
43
|
-
second_arg: |*a| a[1]
|
44
|
-
third_arg: |*a| a[2]
|
45
|
-
}
|
46
|
-
|
47
|
-
[tests]
|
48
|
-
|
49
|
-
"no checks": {
|
50
|
-
si |> assert_match(test_item)
|
51
|
-
si |> assert_match(true)
|
52
|
-
si |> assert_match(false)
|
53
|
-
si |> assert_match(null)
|
54
|
-
si |> assert_match(88)
|
55
|
-
si |> assert_match(99)
|
56
|
-
si |> assert_match(:foo)
|
57
|
-
si |> assert_match(:bar)
|
58
|
-
si |> assert_match("foo")
|
59
|
-
si |> assert_match("bar")
|
60
|
-
}
|
61
|
-
|
62
|
-
"single check with no arguments for literal result": {
|
63
|
-
si([:return_true, [], true ]) |> assert_match(test_item)
|
64
|
-
si([:return_false, [], false]) |> assert_match(test_item)
|
65
|
-
si([:return_null, [], null ]) |> assert_match(test_item)
|
66
|
-
si([:return_88, [], 88 ]) |> assert_match(test_item)
|
67
|
-
si([:return_99, [], 99 ]) |> assert_match(test_item)
|
68
|
-
si([:return_foo, [], :foo ]) |> assert_match(test_item)
|
69
|
-
si([:return_bar, [], :bar ]) |> assert_match(test_item)
|
70
|
-
si([:return_false, [], true ]) |> refute_match(test_item)
|
71
|
-
si([:return_null, [], true ]) |> refute_match(test_item)
|
72
|
-
si([:return_88, [], true ]) |> refute_match(test_item)
|
73
|
-
si([:return_null, [], false]) |> refute_match(test_item)
|
74
|
-
si([:return_false, [], null ]) |> refute_match(test_item)
|
75
|
-
si([:return_88, [], 99 ]) |> refute_match(test_item)
|
76
|
-
si([:return_99, [], 88 ]) |> refute_match(test_item)
|
77
|
-
si([:return_foo, [], :bar ]) |> refute_match(test_item)
|
78
|
-
si([:return_bar, [], :foo ]) |> refute_match(test_item)
|
79
|
-
si([:return_object, [], true ]) |> refute_match(test_item)
|
80
|
-
si([:return_object, [], false]) |> refute_match(test_item)
|
81
|
-
si([:return_object, [], null ]) |> refute_match(test_item)
|
82
|
-
}
|
83
|
-
|
84
|
-
"single check with no arguments for nonliteral result": {
|
85
|
-
si([:return_foo_s, [], "foo"]) |> assert_match(test_item)
|
86
|
-
si([:return_bar_s, [], "bar"]) |> assert_match(test_item)
|
87
|
-
si([:return_foo_s, [], "bar"]) |> refute_match(test_item)
|
88
|
-
si([:return_bar_s, [], "foo"]) |> refute_match(test_item)
|
89
|
-
si([:return_true, [], "bar"]) |> refute_match(test_item)
|
90
|
-
si([:return_false, [], "bar"]) |> refute_match(test_item)
|
91
|
-
si([:return_null, [], "bar"]) |> refute_match(test_item)
|
92
|
-
si([:return_88, [], "bar"]) |> refute_match(test_item)
|
93
|
-
si([:return_99, [], "bar"]) |> refute_match(test_item)
|
94
|
-
si([:return_object, [], "bar"]) |> refute_match(test_item)
|
95
|
-
si([:return_object, [], test_item.return_object]) |> refute_match(test_item)
|
96
|
-
}
|
97
|
-
|
98
|
-
"single check with arguments": {
|
99
|
-
si([:first_arg, [:x,"y",3], :x ]) |> assert_match(test_item)
|
100
|
-
si([:second_arg, [:x,"y",3], "y" ]) |> assert_match(test_item)
|
101
|
-
si([:third_arg, [:x,"y",3], 3 ]) |> assert_match(test_item)
|
102
|
-
si([:first_arg, [:x,"y",3], true ]) |> refute_match(test_item)
|
103
|
-
si([:second_arg, [:x,"y",3], false]) |> refute_match(test_item)
|
104
|
-
si([:third_arg, [:x,"y",3], null ]) |> refute_match(test_item)
|
105
|
-
}
|
106
|
-
|
107
|
-
"multiple checks": {
|
108
|
-
si([:return_true, [], true], [:first_arg, [:x,"y",3], :x]) |> assert_match(test_item)
|
109
|
-
si([:return_true, [], false], [:first_arg, [:x,"y",3], :x]) |> refute_match(test_item)
|
110
|
-
si([:return_true, [], true], [:first_arg, [:x,"y",3], 88]) |> refute_match(test_item)
|
111
|
-
si([:return_true, [], false], [:first_arg, [:x,"y",3], 88]) |> refute_match(test_item)
|
112
|
-
}
|
113
|
-
|
114
|
-
"with :self as check method, checks the item directly against the result": {
|
115
|
-
si([:self, [], 88]) |> assert_match(88)
|
116
|
-
si([:self, [], 99]) |> refute_match(88)
|
117
|
-
}
|
118
|
-
|
119
|
-
"with block literal as check method, runs the block with the item as self": {
|
120
|
-
si([&{ self.return_88 }, [], 88]) |> assert_match(test_item)
|
121
|
-
si([&{ self.return_99 }, [], 88]) |> refute_match(test_item)
|
122
|
-
si([&|a,b,c|{ self.return_88 + (a * b) - c }, [2,3,4], 90]) |> assert_match(test_item)
|
123
|
-
si([&|a,b,c|{ self.return_99 + (a * b) - c }, [2,3,4], 90]) |> refute_match(test_item)
|
124
|
-
}
|
125
|
-
|
126
|
-
"end of stream pattern": {
|
127
|
-
esi |> assert_match()
|
128
|
-
esi |> refute_match(test_item)
|
129
|
-
esi |> refute_match(test_item, test_item)
|
130
|
-
}
|
131
|
-
}
|
@@ -1,595 +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::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) { |*| ("Stream::Patterns")}
|
6
|
-
declare_meme(:new_parser, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Stream)::Parser.new)}
|
7
|
-
declare_meme(:shorthand, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Common)::Patterns::ShorthandMethods], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
8
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}.instance)}
|
9
|
-
declare_meme(:si, [], nil, ::Myco.cscope.dup) { |*args| (self.shorthand.si(*args))}
|
10
|
-
declare_meme(:esi, [], nil, ::Myco.cscope.dup) { |*args| (self.shorthand.esi(*args))}
|
11
|
-
declare_meme(:match?, [], nil, ::Myco.cscope.dup) { |pattern, *items| (
|
12
|
-
parser = self.new_parser
|
13
|
-
parser.__send__(
|
14
|
-
:grammar=,
|
15
|
-
::Myco::Component.new([::Myco.find_constant(:Grammar)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
16
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(__category__(:rules).component_eval {(declare_meme(:root, [[:rule, []]], nil, ::Myco.cscope.dup) { |*| (pattern)})})}}.instance
|
17
|
-
)
|
18
|
-
state = parser.parse(items)
|
19
|
-
state.end_idx.__send__(
|
20
|
-
:==,
|
21
|
-
items.size
|
22
|
-
)
|
23
|
-
)}
|
24
|
-
declare_meme(:assert_match, [], nil, ::Myco.cscope.dup) { |pattern, *items| (self.assert(
|
25
|
-
self.__send__(
|
26
|
-
:match?,
|
27
|
-
pattern,
|
28
|
-
*items
|
29
|
-
),
|
30
|
-
"Expected #{pattern.inspect} to match #{items.inspect}."
|
31
|
-
))}
|
32
|
-
declare_meme(:refute_match, [], nil, ::Myco.cscope.dup) { |pattern, *items| (self.assert(
|
33
|
-
self.__send__(
|
34
|
-
:match?,
|
35
|
-
pattern,
|
36
|
-
*items
|
37
|
-
).__send__(:!),
|
38
|
-
"Expected #{pattern.inspect} not to match #{items.inspect}."
|
39
|
-
))}
|
40
|
-
declare_meme(:test_item, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:BasicObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
41
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
42
|
-
declare_meme(:return_true, [], nil, ::Myco.cscope.dup) { |*| (true)}
|
43
|
-
declare_meme(:return_false, [], nil, ::Myco.cscope.dup) { |*| (false)}
|
44
|
-
declare_meme(:return_null, [], nil, ::Myco.cscope.dup) { |*| (nil)}
|
45
|
-
declare_meme(:return_88, [], nil, ::Myco.cscope.dup) { |*| (88)}
|
46
|
-
declare_meme(:return_99, [], nil, ::Myco.cscope.dup) { |*| (99)}
|
47
|
-
declare_meme(:return_foo, [], nil, ::Myco.cscope.dup) { |*| (:foo)}
|
48
|
-
declare_meme(:return_bar, [], nil, ::Myco.cscope.dup) { |*| (:bar)}
|
49
|
-
declare_meme(:return_foo_s, [], nil, ::Myco.cscope.dup) { |*| ("foo")}
|
50
|
-
declare_meme(:return_bar_s, [], nil, ::Myco.cscope.dup) { |*| ("bar")}
|
51
|
-
declare_meme(:return_object, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:BasicObject).new)}
|
52
|
-
declare_meme(:first_arg, [], nil, ::Myco.cscope.dup) { |*a| (a.__send__(
|
53
|
-
:[],
|
54
|
-
0
|
55
|
-
))}
|
56
|
-
declare_meme(:second_arg, [], nil, ::Myco.cscope.dup) { |*a| (a.__send__(
|
57
|
-
:[],
|
58
|
-
1
|
59
|
-
))}
|
60
|
-
declare_meme(:third_arg, [], nil, ::Myco.cscope.dup) { |*a| (a.__send__(
|
61
|
-
:[],
|
62
|
-
2
|
63
|
-
))}
|
64
|
-
)}}.instance)}
|
65
|
-
__category__(:tests).component_eval {(
|
66
|
-
declare_meme(:"no checks", [], nil, ::Myco.cscope.dup) { |*| (
|
67
|
-
self.assert_match(
|
68
|
-
self.si,
|
69
|
-
self.test_item
|
70
|
-
)
|
71
|
-
self.assert_match(
|
72
|
-
self.si,
|
73
|
-
true
|
74
|
-
)
|
75
|
-
self.assert_match(
|
76
|
-
self.si,
|
77
|
-
false
|
78
|
-
)
|
79
|
-
self.assert_match(
|
80
|
-
self.si,
|
81
|
-
nil
|
82
|
-
)
|
83
|
-
self.assert_match(
|
84
|
-
self.si,
|
85
|
-
88
|
86
|
-
)
|
87
|
-
self.assert_match(
|
88
|
-
self.si,
|
89
|
-
99
|
90
|
-
)
|
91
|
-
self.assert_match(
|
92
|
-
self.si,
|
93
|
-
:foo
|
94
|
-
)
|
95
|
-
self.assert_match(
|
96
|
-
self.si,
|
97
|
-
:bar
|
98
|
-
)
|
99
|
-
self.assert_match(
|
100
|
-
self.si,
|
101
|
-
"foo"
|
102
|
-
)
|
103
|
-
self.assert_match(
|
104
|
-
self.si,
|
105
|
-
"bar"
|
106
|
-
)
|
107
|
-
)}
|
108
|
-
declare_meme(:"single check with no arguments for literal result", [], nil, ::Myco.cscope.dup) { |*| (
|
109
|
-
self.assert_match(
|
110
|
-
self.si([
|
111
|
-
:return_true,
|
112
|
-
[],
|
113
|
-
true
|
114
|
-
]),
|
115
|
-
self.test_item
|
116
|
-
)
|
117
|
-
self.assert_match(
|
118
|
-
self.si([
|
119
|
-
:return_false,
|
120
|
-
[],
|
121
|
-
false
|
122
|
-
]),
|
123
|
-
self.test_item
|
124
|
-
)
|
125
|
-
self.assert_match(
|
126
|
-
self.si([
|
127
|
-
:return_null,
|
128
|
-
[],
|
129
|
-
nil
|
130
|
-
]),
|
131
|
-
self.test_item
|
132
|
-
)
|
133
|
-
self.assert_match(
|
134
|
-
self.si([
|
135
|
-
:return_88,
|
136
|
-
[],
|
137
|
-
88
|
138
|
-
]),
|
139
|
-
self.test_item
|
140
|
-
)
|
141
|
-
self.assert_match(
|
142
|
-
self.si([
|
143
|
-
:return_99,
|
144
|
-
[],
|
145
|
-
99
|
146
|
-
]),
|
147
|
-
self.test_item
|
148
|
-
)
|
149
|
-
self.assert_match(
|
150
|
-
self.si([
|
151
|
-
:return_foo,
|
152
|
-
[],
|
153
|
-
:foo
|
154
|
-
]),
|
155
|
-
self.test_item
|
156
|
-
)
|
157
|
-
self.assert_match(
|
158
|
-
self.si([
|
159
|
-
:return_bar,
|
160
|
-
[],
|
161
|
-
:bar
|
162
|
-
]),
|
163
|
-
self.test_item
|
164
|
-
)
|
165
|
-
self.refute_match(
|
166
|
-
self.si([
|
167
|
-
:return_false,
|
168
|
-
[],
|
169
|
-
true
|
170
|
-
]),
|
171
|
-
self.test_item
|
172
|
-
)
|
173
|
-
self.refute_match(
|
174
|
-
self.si([
|
175
|
-
:return_null,
|
176
|
-
[],
|
177
|
-
true
|
178
|
-
]),
|
179
|
-
self.test_item
|
180
|
-
)
|
181
|
-
self.refute_match(
|
182
|
-
self.si([
|
183
|
-
:return_88,
|
184
|
-
[],
|
185
|
-
true
|
186
|
-
]),
|
187
|
-
self.test_item
|
188
|
-
)
|
189
|
-
self.refute_match(
|
190
|
-
self.si([
|
191
|
-
:return_null,
|
192
|
-
[],
|
193
|
-
false
|
194
|
-
]),
|
195
|
-
self.test_item
|
196
|
-
)
|
197
|
-
self.refute_match(
|
198
|
-
self.si([
|
199
|
-
:return_false,
|
200
|
-
[],
|
201
|
-
nil
|
202
|
-
]),
|
203
|
-
self.test_item
|
204
|
-
)
|
205
|
-
self.refute_match(
|
206
|
-
self.si([
|
207
|
-
:return_88,
|
208
|
-
[],
|
209
|
-
99
|
210
|
-
]),
|
211
|
-
self.test_item
|
212
|
-
)
|
213
|
-
self.refute_match(
|
214
|
-
self.si([
|
215
|
-
:return_99,
|
216
|
-
[],
|
217
|
-
88
|
218
|
-
]),
|
219
|
-
self.test_item
|
220
|
-
)
|
221
|
-
self.refute_match(
|
222
|
-
self.si([
|
223
|
-
:return_foo,
|
224
|
-
[],
|
225
|
-
:bar
|
226
|
-
]),
|
227
|
-
self.test_item
|
228
|
-
)
|
229
|
-
self.refute_match(
|
230
|
-
self.si([
|
231
|
-
:return_bar,
|
232
|
-
[],
|
233
|
-
:foo
|
234
|
-
]),
|
235
|
-
self.test_item
|
236
|
-
)
|
237
|
-
self.refute_match(
|
238
|
-
self.si([
|
239
|
-
:return_object,
|
240
|
-
[],
|
241
|
-
true
|
242
|
-
]),
|
243
|
-
self.test_item
|
244
|
-
)
|
245
|
-
self.refute_match(
|
246
|
-
self.si([
|
247
|
-
:return_object,
|
248
|
-
[],
|
249
|
-
false
|
250
|
-
]),
|
251
|
-
self.test_item
|
252
|
-
)
|
253
|
-
self.refute_match(
|
254
|
-
self.si([
|
255
|
-
:return_object,
|
256
|
-
[],
|
257
|
-
nil
|
258
|
-
]),
|
259
|
-
self.test_item
|
260
|
-
)
|
261
|
-
)}
|
262
|
-
declare_meme(:"single check with no arguments for nonliteral result", [], nil, ::Myco.cscope.dup) { |*| (
|
263
|
-
self.assert_match(
|
264
|
-
self.si([
|
265
|
-
:return_foo_s,
|
266
|
-
[],
|
267
|
-
"foo"
|
268
|
-
]),
|
269
|
-
self.test_item
|
270
|
-
)
|
271
|
-
self.assert_match(
|
272
|
-
self.si([
|
273
|
-
:return_bar_s,
|
274
|
-
[],
|
275
|
-
"bar"
|
276
|
-
]),
|
277
|
-
self.test_item
|
278
|
-
)
|
279
|
-
self.refute_match(
|
280
|
-
self.si([
|
281
|
-
:return_foo_s,
|
282
|
-
[],
|
283
|
-
"bar"
|
284
|
-
]),
|
285
|
-
self.test_item
|
286
|
-
)
|
287
|
-
self.refute_match(
|
288
|
-
self.si([
|
289
|
-
:return_bar_s,
|
290
|
-
[],
|
291
|
-
"foo"
|
292
|
-
]),
|
293
|
-
self.test_item
|
294
|
-
)
|
295
|
-
self.refute_match(
|
296
|
-
self.si([
|
297
|
-
:return_true,
|
298
|
-
[],
|
299
|
-
"bar"
|
300
|
-
]),
|
301
|
-
self.test_item
|
302
|
-
)
|
303
|
-
self.refute_match(
|
304
|
-
self.si([
|
305
|
-
:return_false,
|
306
|
-
[],
|
307
|
-
"bar"
|
308
|
-
]),
|
309
|
-
self.test_item
|
310
|
-
)
|
311
|
-
self.refute_match(
|
312
|
-
self.si([
|
313
|
-
:return_null,
|
314
|
-
[],
|
315
|
-
"bar"
|
316
|
-
]),
|
317
|
-
self.test_item
|
318
|
-
)
|
319
|
-
self.refute_match(
|
320
|
-
self.si([
|
321
|
-
:return_88,
|
322
|
-
[],
|
323
|
-
"bar"
|
324
|
-
]),
|
325
|
-
self.test_item
|
326
|
-
)
|
327
|
-
self.refute_match(
|
328
|
-
self.si([
|
329
|
-
:return_99,
|
330
|
-
[],
|
331
|
-
"bar"
|
332
|
-
]),
|
333
|
-
self.test_item
|
334
|
-
)
|
335
|
-
self.refute_match(
|
336
|
-
self.si([
|
337
|
-
:return_object,
|
338
|
-
[],
|
339
|
-
"bar"
|
340
|
-
]),
|
341
|
-
self.test_item
|
342
|
-
)
|
343
|
-
self.refute_match(
|
344
|
-
self.si([
|
345
|
-
:return_object,
|
346
|
-
[],
|
347
|
-
self.test_item.return_object
|
348
|
-
]),
|
349
|
-
self.test_item
|
350
|
-
)
|
351
|
-
)}
|
352
|
-
declare_meme(:"single check with arguments", [], nil, ::Myco.cscope.dup) { |*| (
|
353
|
-
self.assert_match(
|
354
|
-
self.si([
|
355
|
-
:first_arg,
|
356
|
-
[
|
357
|
-
:x,
|
358
|
-
"y",
|
359
|
-
3
|
360
|
-
],
|
361
|
-
:x
|
362
|
-
]),
|
363
|
-
self.test_item
|
364
|
-
)
|
365
|
-
self.assert_match(
|
366
|
-
self.si([
|
367
|
-
:second_arg,
|
368
|
-
[
|
369
|
-
:x,
|
370
|
-
"y",
|
371
|
-
3
|
372
|
-
],
|
373
|
-
"y"
|
374
|
-
]),
|
375
|
-
self.test_item
|
376
|
-
)
|
377
|
-
self.assert_match(
|
378
|
-
self.si([
|
379
|
-
:third_arg,
|
380
|
-
[
|
381
|
-
:x,
|
382
|
-
"y",
|
383
|
-
3
|
384
|
-
],
|
385
|
-
3
|
386
|
-
]),
|
387
|
-
self.test_item
|
388
|
-
)
|
389
|
-
self.refute_match(
|
390
|
-
self.si([
|
391
|
-
:first_arg,
|
392
|
-
[
|
393
|
-
:x,
|
394
|
-
"y",
|
395
|
-
3
|
396
|
-
],
|
397
|
-
true
|
398
|
-
]),
|
399
|
-
self.test_item
|
400
|
-
)
|
401
|
-
self.refute_match(
|
402
|
-
self.si([
|
403
|
-
:second_arg,
|
404
|
-
[
|
405
|
-
:x,
|
406
|
-
"y",
|
407
|
-
3
|
408
|
-
],
|
409
|
-
false
|
410
|
-
]),
|
411
|
-
self.test_item
|
412
|
-
)
|
413
|
-
self.refute_match(
|
414
|
-
self.si([
|
415
|
-
:third_arg,
|
416
|
-
[
|
417
|
-
:x,
|
418
|
-
"y",
|
419
|
-
3
|
420
|
-
],
|
421
|
-
nil
|
422
|
-
]),
|
423
|
-
self.test_item
|
424
|
-
)
|
425
|
-
)}
|
426
|
-
declare_meme(:"multiple checks", [], nil, ::Myco.cscope.dup) { |*| (
|
427
|
-
self.assert_match(
|
428
|
-
self.si(
|
429
|
-
[
|
430
|
-
:return_true,
|
431
|
-
[],
|
432
|
-
true
|
433
|
-
],
|
434
|
-
[
|
435
|
-
:first_arg,
|
436
|
-
[
|
437
|
-
:x,
|
438
|
-
"y",
|
439
|
-
3
|
440
|
-
],
|
441
|
-
:x
|
442
|
-
]
|
443
|
-
),
|
444
|
-
self.test_item
|
445
|
-
)
|
446
|
-
self.refute_match(
|
447
|
-
self.si(
|
448
|
-
[
|
449
|
-
:return_true,
|
450
|
-
[],
|
451
|
-
false
|
452
|
-
],
|
453
|
-
[
|
454
|
-
:first_arg,
|
455
|
-
[
|
456
|
-
:x,
|
457
|
-
"y",
|
458
|
-
3
|
459
|
-
],
|
460
|
-
:x
|
461
|
-
]
|
462
|
-
),
|
463
|
-
self.test_item
|
464
|
-
)
|
465
|
-
self.refute_match(
|
466
|
-
self.si(
|
467
|
-
[
|
468
|
-
:return_true,
|
469
|
-
[],
|
470
|
-
true
|
471
|
-
],
|
472
|
-
[
|
473
|
-
:first_arg,
|
474
|
-
[
|
475
|
-
:x,
|
476
|
-
"y",
|
477
|
-
3
|
478
|
-
],
|
479
|
-
88
|
480
|
-
]
|
481
|
-
),
|
482
|
-
self.test_item
|
483
|
-
)
|
484
|
-
self.refute_match(
|
485
|
-
self.si(
|
486
|
-
[
|
487
|
-
:return_true,
|
488
|
-
[],
|
489
|
-
false
|
490
|
-
],
|
491
|
-
[
|
492
|
-
:first_arg,
|
493
|
-
[
|
494
|
-
:x,
|
495
|
-
"y",
|
496
|
-
3
|
497
|
-
],
|
498
|
-
88
|
499
|
-
]
|
500
|
-
),
|
501
|
-
self.test_item
|
502
|
-
)
|
503
|
-
)}
|
504
|
-
declare_meme(:"with :self as check method, checks the item directly against the result", [], nil, ::Myco.cscope.dup) { |*| (
|
505
|
-
self.assert_match(
|
506
|
-
self.si([
|
507
|
-
:self,
|
508
|
-
[],
|
509
|
-
88
|
510
|
-
]),
|
511
|
-
88
|
512
|
-
)
|
513
|
-
self.refute_match(
|
514
|
-
self.si([
|
515
|
-
:self,
|
516
|
-
[],
|
517
|
-
99
|
518
|
-
]),
|
519
|
-
88
|
520
|
-
)
|
521
|
-
)}
|
522
|
-
declare_meme(:"with block literal as check method, runs the block with the item as self", [], nil, ::Myco.cscope.dup) { |*| (
|
523
|
-
self.assert_match(
|
524
|
-
self.si([
|
525
|
-
::Object::Proc.new { || (self.__send__(:return_88))},
|
526
|
-
[],
|
527
|
-
88
|
528
|
-
]),
|
529
|
-
self.test_item
|
530
|
-
)
|
531
|
-
self.refute_match(
|
532
|
-
self.si([
|
533
|
-
::Object::Proc.new { || (self.__send__(:return_99))},
|
534
|
-
[],
|
535
|
-
88
|
536
|
-
]),
|
537
|
-
self.test_item
|
538
|
-
)
|
539
|
-
self.assert_match(
|
540
|
-
self.si([
|
541
|
-
::Object::Proc.new { |a, b, c| (self.__send__(:return_88).__send__(
|
542
|
-
:+,
|
543
|
-
a.__send__(
|
544
|
-
:*,
|
545
|
-
b
|
546
|
-
)
|
547
|
-
).__send__(
|
548
|
-
:-,
|
549
|
-
c
|
550
|
-
))},
|
551
|
-
[
|
552
|
-
2,
|
553
|
-
3,
|
554
|
-
4
|
555
|
-
],
|
556
|
-
90
|
557
|
-
]),
|
558
|
-
self.test_item
|
559
|
-
)
|
560
|
-
self.refute_match(
|
561
|
-
self.si([
|
562
|
-
::Object::Proc.new { |a, b, c| (self.__send__(:return_99).__send__(
|
563
|
-
:+,
|
564
|
-
a.__send__(
|
565
|
-
:*,
|
566
|
-
b
|
567
|
-
)
|
568
|
-
).__send__(
|
569
|
-
:-,
|
570
|
-
c
|
571
|
-
))},
|
572
|
-
[
|
573
|
-
2,
|
574
|
-
3,
|
575
|
-
4
|
576
|
-
],
|
577
|
-
90
|
578
|
-
]),
|
579
|
-
self.test_item
|
580
|
-
)
|
581
|
-
)}
|
582
|
-
declare_meme(:"end of stream pattern", [], nil, ::Myco.cscope.dup) { |*| (
|
583
|
-
self.assert_match(self.esi)
|
584
|
-
self.refute_match(
|
585
|
-
self.esi,
|
586
|
-
self.test_item
|
587
|
-
)
|
588
|
-
self.refute_match(
|
589
|
-
self.esi,
|
590
|
-
self.test_item,
|
591
|
-
self.test_item
|
592
|
-
)
|
593
|
-
)}
|
594
|
-
)}
|
595
|
-
)}}.instance)}}.instance
|