myco 0.1.8 → 0.1.9
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/instance.rb +13 -3
- data/lib/myco/code_tools/AST.my +0 -2
- data/lib/myco/code_tools/AST.my.rb +0 -1
- data/lib/myco/code_tools/AST/Block.my +15 -4
- data/lib/myco/code_tools/AST/Block.my.rb +16 -3
- data/lib/myco/code_tools/AST/DeclareMeme.my +44 -64
- data/lib/myco/code_tools/AST/DeclareMeme.my.rb +66 -74
- data/lib/myco/code_tools/AST/ToRuby.my +17 -20
- data/lib/myco/code_tools/AST/ToRuby.my.rb +24 -22
- data/lib/myco/code_tools/Parser.my +2 -1
- data/lib/myco/code_tools/Parser.my.rb +2 -1
- data/lib/myco/code_tools/parser/MycoBuilder.my +2 -2
- data/lib/myco/code_tools/parser/MycoBuilder.my.rb +2 -2
- data/lib/myco/code_tools/parser/MycoGrammar.my +28 -21
- data/lib/myco/code_tools/parser/MycoGrammar.my.rb +94 -56
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my +10 -11
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my.rb +10 -9
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +25 -3
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +38 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my +152 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my.rb +189 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my +84 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my.rb +114 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common/Parser.my +139 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/{BytecodeParser.my.rb → Common/Parser.my.rb} +17 -36
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my +229 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my.rb +296 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +8 -25
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +9 -37
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +139 -37
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +206 -36
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +21 -12
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +45 -24
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my +99 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my.rb +152 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my +37 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my.rb +57 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my +136 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my.rb +147 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my +45 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my.rb +85 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my +31 -25
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my.rb +44 -25
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my +49 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my.rb +119 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my +131 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my.rb +595 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/{BytecodeParser.test.my → String/Parser.test.my} +41 -2
- data/lib/myco/code_tools/parser/pegleromyces/spec/{BytecodeParser.test.my.rb → String/Parser.test.my.rb} +144 -3
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my +4 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my.rb +4 -8
- data/lib/myco/core.my +1 -0
- data/lib/myco/core.my.rb +1 -0
- data/lib/myco/core/BasicObject.my +4 -2
- data/lib/myco/core/BasicObject.my.rb +2 -5
- data/lib/myco/core/Loop.my +5 -0
- data/lib/myco/core/Loop.my.rb +13 -0
- data/lib/myco/dev.rb +1 -0
- data/lib/myco/dev/profile.rb +12 -0
- data/lib/myco/version.rb +3 -3
- metadata +54 -59
- data/lib/myco/code_tools/AST/DeclareDecorator.my +0 -19
- data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +0 -24
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my +0 -4
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my.rb +0 -5
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +0 -420
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +0 -415
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +0 -147
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my +0 -183
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my.rb +0 -370
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my +0 -139
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my.rb +0 -284
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my +0 -37
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +0 -24
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my +0 -123
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +0 -164
- data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my +0 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my.rb +0 -9
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my +0 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my.rb +0 -9
- data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my +0 -229
- data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my.rb +0 -663
- data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my +0 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my.rb +0 -9
- data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my +0 -13
- data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my.rb +0 -20
- data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my +0 -54
- data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my.rb +0 -215
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
String << {
|
3
|
+
Parser < Common::Parser {
|
4
|
+
State < Common::Parser::State {
|
5
|
+
var string
|
6
|
+
|
7
|
+
var error_row
|
8
|
+
var error_col
|
9
|
+
|
10
|
+
raise_error: self.error_idx && raise(SyntaxError
|
11
|
+
"Unexpected character with parser: "self.rule \
|
12
|
+
" near line: "self.error_row \
|
13
|
+
", column: "self.error_col".\n" \
|
14
|
+
self.string.each_line.to_a[self.error_row - 1]"" \
|
15
|
+
(' ' * [(self.error_col - 1), 0].max)"^"
|
16
|
+
)
|
17
|
+
}
|
18
|
+
|
19
|
+
# Match and process the given string using the current grammar
|
20
|
+
parse: |string, rule:"root", start_idx:0| {
|
21
|
+
worker = new_worker
|
22
|
+
processor = new_processor
|
23
|
+
state = State.new(
|
24
|
+
string: string.to_s
|
25
|
+
rule: rule.to_sym
|
26
|
+
start_idx: start_idx.to_i
|
27
|
+
)
|
28
|
+
|
29
|
+
state.end_idx = worker.__send__(state.rule, state.string, state.start_idx)
|
30
|
+
|
31
|
+
state.end_idx &? (
|
32
|
+
processor.string = state.string
|
33
|
+
processor.capture_items = captures_of_worker(worker)
|
34
|
+
grammar.?tokenizer && (processor.tokenizer = grammar.tokenizer)
|
35
|
+
state.result = processor.process
|
36
|
+
) ?? (
|
37
|
+
state.error_idx = highest_idx_of_worker(worker)
|
38
|
+
pos = processor.position_of(state.error_idx, state.string)
|
39
|
+
state.error_row = pos.first
|
40
|
+
state.error_col = pos.last
|
41
|
+
)
|
42
|
+
state
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,85 @@
|
|
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(:String).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(:string, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
8
|
+
declare_meme(:error_row, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
9
|
+
declare_meme(:error_col, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
10
|
+
declare_meme(:raise_error, [], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"&&", self.error_idx) {self.raise(
|
11
|
+
::Myco.find_constant(:SyntaxError),
|
12
|
+
"Unexpected character with parser: #{self.rule} near line: #{self.error_row}, column: #{self.error_col}.\n#{self.string.each_line.to_a.__send__(
|
13
|
+
:[],
|
14
|
+
self.error_row.__send__(
|
15
|
+
:-,
|
16
|
+
1
|
17
|
+
)
|
18
|
+
)}#{" ".__send__(
|
19
|
+
:*,
|
20
|
+
[
|
21
|
+
self.error_col.__send__(
|
22
|
+
:-,
|
23
|
+
1
|
24
|
+
),
|
25
|
+
0
|
26
|
+
].max
|
27
|
+
)}^"
|
28
|
+
)})}
|
29
|
+
)}}
|
30
|
+
.tap { |__c__| __c__.__name__ = :State }
|
31
|
+
declare_meme(:parse, [], nil, ::Myco.cscope.dup) { |string, rule:"root", start_idx:0| (
|
32
|
+
worker = self.new_worker
|
33
|
+
processor = self.new_processor
|
34
|
+
state = ::Myco.find_constant(:State).new({
|
35
|
+
:string => string.to_s,
|
36
|
+
:rule => rule.to_sym,
|
37
|
+
:start_idx => start_idx.to_i
|
38
|
+
})
|
39
|
+
state.__send__(
|
40
|
+
:end_idx=,
|
41
|
+
worker.__send__(
|
42
|
+
state.rule,
|
43
|
+
state.string,
|
44
|
+
state.start_idx
|
45
|
+
)
|
46
|
+
)
|
47
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", state.end_idx) {(
|
48
|
+
processor.__send__(
|
49
|
+
:string=,
|
50
|
+
state.string
|
51
|
+
)
|
52
|
+
processor.__send__(
|
53
|
+
:capture_items=,
|
54
|
+
self.captures_of_worker(worker)
|
55
|
+
)
|
56
|
+
::Myco.branch_op(:"&&", (Rubinius::Type.object_respond_to?(self.grammar, :tokenizer).false? ? ::Myco::Void : self.grammar.tokenizer)) {processor.__send__(
|
57
|
+
:tokenizer=,
|
58
|
+
self.grammar.tokenizer
|
59
|
+
)}
|
60
|
+
state.__send__(
|
61
|
+
:result=,
|
62
|
+
processor.process
|
63
|
+
)
|
64
|
+
)}) {(
|
65
|
+
state.__send__(
|
66
|
+
:error_idx=,
|
67
|
+
self.highest_idx_of_worker(worker)
|
68
|
+
)
|
69
|
+
pos = processor.position_of(
|
70
|
+
state.error_idx,
|
71
|
+
state.string
|
72
|
+
)
|
73
|
+
state.__send__(
|
74
|
+
:error_row=,
|
75
|
+
pos.first
|
76
|
+
)
|
77
|
+
state.__send__(
|
78
|
+
:error_col=,
|
79
|
+
pos.last
|
80
|
+
)
|
81
|
+
)}
|
82
|
+
state
|
83
|
+
)}
|
84
|
+
)}}
|
85
|
+
.tap { |__c__| __c__.__name__ = :Parser })})}}.instance
|
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
2
|
BasicSpec {
|
3
|
-
name: "Patterns"
|
3
|
+
name: "Common::Patterns"
|
4
4
|
|
5
|
-
new_pattern: Patterns::Base { }
|
6
|
-
var shorthand: Patterns::ShorthandMethods { }
|
5
|
+
new_pattern: Common::Patterns::Base { }
|
6
|
+
var shorthand: Common::Patterns::ShorthandMethods { }
|
7
7
|
|
8
8
|
[tests]
|
9
9
|
|
@@ -14,21 +14,21 @@ BasicSpec {
|
|
14
14
|
it "creates a NegativePredicate with the '!' unary operator": {
|
15
15
|
a = new_pattern
|
16
16
|
b = !a
|
17
|
-
assert_is_a(b, Patterns::NegativePredicate)
|
17
|
+
assert_is_a(b, Composite::Patterns::NegativePredicate)
|
18
18
|
assert_equal(b.inner, a)
|
19
19
|
}
|
20
20
|
|
21
21
|
it "creates a PositivePredicate with two uses of the '!' unary operator": {
|
22
22
|
a = new_pattern
|
23
23
|
b = !!a
|
24
|
-
assert_is_a(b, Patterns::PositivePredicate)
|
24
|
+
assert_is_a(b, Composite::Patterns::PositivePredicate)
|
25
25
|
assert_equal(b.inner, a)
|
26
26
|
}
|
27
27
|
|
28
28
|
it "creates a NegativePredicate with three uses of the '!' unary operator": {
|
29
29
|
a = new_pattern
|
30
30
|
b = !!!a
|
31
|
-
assert_is_a(b, Patterns::NegativePredicate)
|
31
|
+
assert_is_a(b, Composite::Patterns::NegativePredicate)
|
32
32
|
assert_equal(b.inner, a)
|
33
33
|
}
|
34
34
|
|
@@ -36,7 +36,7 @@ BasicSpec {
|
|
36
36
|
a = new_pattern
|
37
37
|
b = new_pattern
|
38
38
|
c = a / b
|
39
|
-
assert_is_a(c, Patterns::OrderedChoice)
|
39
|
+
assert_is_a(c, Composite::Patterns::OrderedChoice)
|
40
40
|
assert_equal(c.first, a)
|
41
41
|
assert_equal(c.second, b)
|
42
42
|
}
|
@@ -47,9 +47,9 @@ BasicSpec {
|
|
47
47
|
c = new_pattern
|
48
48
|
d = new_pattern
|
49
49
|
e = a / b / c / d
|
50
|
-
assert_is_a(e, Patterns::OrderedChoice)
|
51
|
-
assert_is_a(e.second, Patterns::OrderedChoice)
|
52
|
-
assert_is_a(e.second.second, Patterns::OrderedChoice)
|
50
|
+
assert_is_a(e, Composite::Patterns::OrderedChoice)
|
51
|
+
assert_is_a(e.second, Composite::Patterns::OrderedChoice)
|
52
|
+
assert_is_a(e.second.second, Composite::Patterns::OrderedChoice)
|
53
53
|
assert_equal(e.first, a)
|
54
54
|
assert_equal(e.second.first, b)
|
55
55
|
assert_equal(e.second.second.first, c)
|
@@ -60,7 +60,7 @@ BasicSpec {
|
|
60
60
|
a = new_pattern
|
61
61
|
b = new_pattern
|
62
62
|
c = a + b
|
63
|
-
assert_is_a(c, Patterns::Concatenation)
|
63
|
+
assert_is_a(c, Composite::Patterns::Concatenation)
|
64
64
|
assert_equal(c.first, a)
|
65
65
|
assert_equal(c.second, b)
|
66
66
|
}
|
@@ -71,9 +71,9 @@ BasicSpec {
|
|
71
71
|
c = new_pattern
|
72
72
|
d = new_pattern
|
73
73
|
e = a + b + c + d
|
74
|
-
assert_is_a(e, Patterns::Concatenation)
|
75
|
-
assert_is_a(e.second, Patterns::Concatenation)
|
76
|
-
assert_is_a(e.second.second, Patterns::Concatenation)
|
74
|
+
assert_is_a(e, Composite::Patterns::Concatenation)
|
75
|
+
assert_is_a(e.second, Composite::Patterns::Concatenation)
|
76
|
+
assert_is_a(e.second.second, Composite::Patterns::Concatenation)
|
77
77
|
assert_equal(e.first, a)
|
78
78
|
assert_equal(e.second.first, b)
|
79
79
|
assert_equal(e.second.second.first, c)
|
@@ -83,64 +83,64 @@ BasicSpec {
|
|
83
83
|
it "creates a OneOrMore with the '+' operator used as a 'suffix' call": {
|
84
84
|
a = new_pattern
|
85
85
|
b = a.+
|
86
|
-
assert_is_a(b, Patterns::OneOrMore)
|
86
|
+
assert_is_a(b, Composite::Patterns::OneOrMore)
|
87
87
|
assert_equal(b.inner, a)
|
88
88
|
|
89
89
|
# This is implemented as a special case but should act the same
|
90
90
|
a = (new_pattern + new_pattern)
|
91
91
|
b = a.+
|
92
|
-
assert_is_a(b, Patterns::OneOrMore)
|
92
|
+
assert_is_a(b, Composite::Patterns::OneOrMore)
|
93
93
|
assert_equal(b.inner, a)
|
94
94
|
}
|
95
95
|
|
96
96
|
it "creates a ZeroOrOne with the '-' operator used as a 'suffix' call": {
|
97
97
|
a = new_pattern
|
98
98
|
b = a.-
|
99
|
-
assert_is_a(b, Patterns::ZeroOrOne)
|
99
|
+
assert_is_a(b, Composite::Patterns::ZeroOrOne)
|
100
100
|
assert_equal(b.inner, a)
|
101
101
|
}
|
102
102
|
|
103
103
|
it "creates a ZeroOrMore with the '*' operator used as a 'suffix' call": {
|
104
104
|
a = new_pattern
|
105
105
|
b = a.*
|
106
|
-
assert_is_a(b, Patterns::ZeroOrMore)
|
106
|
+
assert_is_a(b, Composite::Patterns::ZeroOrMore)
|
107
107
|
assert_equal(b.inner, a)
|
108
108
|
}
|
109
109
|
|
110
110
|
it "creates a NamedCapture with the '[]' operator, given a capture name": {
|
111
111
|
a = new_pattern
|
112
112
|
b = a[:foo]
|
113
|
-
assert_is_a(b, Patterns::NamedCapture)
|
113
|
+
assert_is_a(b, Capture::Patterns::NamedCapture)
|
114
114
|
assert_equal(b.inner, a)
|
115
115
|
assert_equal(b.name, :foo)
|
116
116
|
}
|
117
117
|
|
118
118
|
it "creates an AnyCharacter with the 'any' shorthand method": {
|
119
119
|
a = shorthand.any
|
120
|
-
assert_is_a(a, Patterns::AnyCharacter)
|
120
|
+
assert_is_a(a, String::Patterns::AnyCharacter)
|
121
121
|
}
|
122
122
|
|
123
123
|
it "creates a Character with the 'char' shorthand method": {
|
124
124
|
a = shorthand.char('x')
|
125
|
-
assert_is_a(a, Patterns::Character)
|
125
|
+
assert_is_a(a, String::Patterns::Character)
|
126
126
|
assert_equal(a.code, 120)
|
127
127
|
}
|
128
128
|
|
129
129
|
it "creates a CharacterString with the 'str' shorthand method": {
|
130
130
|
a = shorthand.str('xyz')
|
131
|
-
assert_is_a(a, Patterns::CharacterString)
|
131
|
+
assert_is_a(a, String::Patterns::CharacterString)
|
132
132
|
assert_equal(a.codes, [120,121,122])
|
133
133
|
}
|
134
134
|
|
135
135
|
it "creates a CharacterSet with the 'set' shorthand method": {
|
136
136
|
a = shorthand.set('xyz')
|
137
|
-
assert_is_a(a, Patterns::CharacterSet)
|
137
|
+
assert_is_a(a, String::Patterns::CharacterSet)
|
138
138
|
assert_equal(a.codes, [120,121,122])
|
139
139
|
}
|
140
140
|
|
141
141
|
it "creates a CharacterRange with the 'range' shorthand method": {
|
142
142
|
a = shorthand.range('x','z')
|
143
|
-
assert_is_a(a, Patterns::CharacterRange)
|
143
|
+
assert_is_a(a, String::Patterns::CharacterRange)
|
144
144
|
assert_equal(a.start, 120)
|
145
145
|
assert_equal(a.stop, 122)
|
146
146
|
}
|
@@ -149,8 +149,14 @@ BasicSpec {
|
|
149
149
|
a_proc = Proc.new { }
|
150
150
|
a = new_pattern
|
151
151
|
b = shorthand.r(a, &a_proc)
|
152
|
-
assert_is_a(b, Patterns::Reduction)
|
152
|
+
assert_is_a(b, Capture::Patterns::Reduction)
|
153
153
|
assert_equal(b.inner, a)
|
154
154
|
assert_equal(b.block, a_proc)
|
155
155
|
}
|
156
|
+
|
157
|
+
it "creates a Stream Item with the 'si' shorthand method": {
|
158
|
+
a = shorthand.si([:foo?, [], true])
|
159
|
+
assert_is_a(a, Stream::Patterns::Item)
|
160
|
+
assert_equal(a.checks, [[:foo?, [], true]])
|
161
|
+
}
|
156
162
|
}
|
@@ -2,10 +2,10 @@
|
|
2
2
|
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
3
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::Component.new([::Myco.find_constant(:BasicSpec)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
4
4
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
5
|
-
declare_meme(:name, [], nil, ::Myco.cscope.dup) { |*| ("Patterns")}
|
6
|
-
declare_meme(:new_pattern, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:
|
5
|
+
declare_meme(:name, [], nil, ::Myco.cscope.dup) { |*| ("Common::Patterns")}
|
6
|
+
declare_meme(:new_pattern, [], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Common)::Patterns::Base], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
7
7
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}.instance)}
|
8
|
-
declare_meme(:shorthand, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:
|
8
|
+
declare_meme(:shorthand, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Common)::Patterns::ShorthandMethods], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
9
9
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {nil}}.instance)}
|
10
10
|
__category__(:tests).component_eval {(
|
11
11
|
declare_meme(:"knows its name", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (self.assert_equal(
|
@@ -17,7 +17,7 @@
|
|
17
17
|
b = a.__send__(:!)
|
18
18
|
self.assert_is_a(
|
19
19
|
b,
|
20
|
-
::Myco.find_constant(:
|
20
|
+
::Myco.find_constant(:Composite)::Patterns::NegativePredicate
|
21
21
|
)
|
22
22
|
self.assert_equal(
|
23
23
|
b.inner,
|
@@ -29,7 +29,7 @@
|
|
29
29
|
b = a.__send__(:!).__send__(:!)
|
30
30
|
self.assert_is_a(
|
31
31
|
b,
|
32
|
-
::Myco.find_constant(:
|
32
|
+
::Myco.find_constant(:Composite)::Patterns::PositivePredicate
|
33
33
|
)
|
34
34
|
self.assert_equal(
|
35
35
|
b.inner,
|
@@ -41,7 +41,7 @@
|
|
41
41
|
b = a.__send__(:!).__send__(:!).__send__(:!)
|
42
42
|
self.assert_is_a(
|
43
43
|
b,
|
44
|
-
::Myco.find_constant(:
|
44
|
+
::Myco.find_constant(:Composite)::Patterns::NegativePredicate
|
45
45
|
)
|
46
46
|
self.assert_equal(
|
47
47
|
b.inner,
|
@@ -57,7 +57,7 @@
|
|
57
57
|
)
|
58
58
|
self.assert_is_a(
|
59
59
|
c,
|
60
|
-
::Myco.find_constant(:
|
60
|
+
::Myco.find_constant(:Composite)::Patterns::OrderedChoice
|
61
61
|
)
|
62
62
|
self.assert_equal(
|
63
63
|
c.first,
|
@@ -85,15 +85,15 @@
|
|
85
85
|
)
|
86
86
|
self.assert_is_a(
|
87
87
|
e,
|
88
|
-
::Myco.find_constant(:
|
88
|
+
::Myco.find_constant(:Composite)::Patterns::OrderedChoice
|
89
89
|
)
|
90
90
|
self.assert_is_a(
|
91
91
|
e.second,
|
92
|
-
::Myco.find_constant(:
|
92
|
+
::Myco.find_constant(:Composite)::Patterns::OrderedChoice
|
93
93
|
)
|
94
94
|
self.assert_is_a(
|
95
95
|
e.second.second,
|
96
|
-
::Myco.find_constant(:
|
96
|
+
::Myco.find_constant(:Composite)::Patterns::OrderedChoice
|
97
97
|
)
|
98
98
|
self.assert_equal(
|
99
99
|
e.first,
|
@@ -121,7 +121,7 @@
|
|
121
121
|
)
|
122
122
|
self.assert_is_a(
|
123
123
|
c,
|
124
|
-
::Myco.find_constant(:
|
124
|
+
::Myco.find_constant(:Composite)::Patterns::Concatenation
|
125
125
|
)
|
126
126
|
self.assert_equal(
|
127
127
|
c.first,
|
@@ -149,15 +149,15 @@
|
|
149
149
|
)
|
150
150
|
self.assert_is_a(
|
151
151
|
e,
|
152
|
-
::Myco.find_constant(:
|
152
|
+
::Myco.find_constant(:Composite)::Patterns::Concatenation
|
153
153
|
)
|
154
154
|
self.assert_is_a(
|
155
155
|
e.second,
|
156
|
-
::Myco.find_constant(:
|
156
|
+
::Myco.find_constant(:Composite)::Patterns::Concatenation
|
157
157
|
)
|
158
158
|
self.assert_is_a(
|
159
159
|
e.second.second,
|
160
|
-
::Myco.find_constant(:
|
160
|
+
::Myco.find_constant(:Composite)::Patterns::Concatenation
|
161
161
|
)
|
162
162
|
self.assert_equal(
|
163
163
|
e.first,
|
@@ -181,7 +181,7 @@
|
|
181
181
|
b = a.__send__(:+)
|
182
182
|
self.assert_is_a(
|
183
183
|
b,
|
184
|
-
::Myco.find_constant(:
|
184
|
+
::Myco.find_constant(:Composite)::Patterns::OneOrMore
|
185
185
|
)
|
186
186
|
self.assert_equal(
|
187
187
|
b.inner,
|
@@ -194,7 +194,7 @@
|
|
194
194
|
b = a.__send__(:+)
|
195
195
|
self.assert_is_a(
|
196
196
|
b,
|
197
|
-
::Myco.find_constant(:
|
197
|
+
::Myco.find_constant(:Composite)::Patterns::OneOrMore
|
198
198
|
)
|
199
199
|
self.assert_equal(
|
200
200
|
b.inner,
|
@@ -206,7 +206,7 @@
|
|
206
206
|
b = a.__send__(:-)
|
207
207
|
self.assert_is_a(
|
208
208
|
b,
|
209
|
-
::Myco.find_constant(:
|
209
|
+
::Myco.find_constant(:Composite)::Patterns::ZeroOrOne
|
210
210
|
)
|
211
211
|
self.assert_equal(
|
212
212
|
b.inner,
|
@@ -218,7 +218,7 @@
|
|
218
218
|
b = a.__send__(:*)
|
219
219
|
self.assert_is_a(
|
220
220
|
b,
|
221
|
-
::Myco.find_constant(:
|
221
|
+
::Myco.find_constant(:Composite)::Patterns::ZeroOrMore
|
222
222
|
)
|
223
223
|
self.assert_equal(
|
224
224
|
b.inner,
|
@@ -233,7 +233,7 @@
|
|
233
233
|
)
|
234
234
|
self.assert_is_a(
|
235
235
|
b,
|
236
|
-
::Myco.find_constant(:
|
236
|
+
::Myco.find_constant(:Capture)::Patterns::NamedCapture
|
237
237
|
)
|
238
238
|
self.assert_equal(
|
239
239
|
b.inner,
|
@@ -248,14 +248,14 @@
|
|
248
248
|
a = self.shorthand.any
|
249
249
|
self.assert_is_a(
|
250
250
|
a,
|
251
|
-
::Myco.find_constant(:
|
251
|
+
::Myco.find_constant(:String)::Patterns::AnyCharacter
|
252
252
|
)
|
253
253
|
)}
|
254
254
|
declare_meme(:"creates a Character with the 'char' shorthand method", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
255
255
|
a = self.shorthand.char("x")
|
256
256
|
self.assert_is_a(
|
257
257
|
a,
|
258
|
-
::Myco.find_constant(:
|
258
|
+
::Myco.find_constant(:String)::Patterns::Character
|
259
259
|
)
|
260
260
|
self.assert_equal(
|
261
261
|
a.code,
|
@@ -266,7 +266,7 @@
|
|
266
266
|
a = self.shorthand.str("xyz")
|
267
267
|
self.assert_is_a(
|
268
268
|
a,
|
269
|
-
::Myco.find_constant(:
|
269
|
+
::Myco.find_constant(:String)::Patterns::CharacterString
|
270
270
|
)
|
271
271
|
self.assert_equal(
|
272
272
|
a.codes,
|
@@ -281,7 +281,7 @@
|
|
281
281
|
a = self.shorthand.set("xyz")
|
282
282
|
self.assert_is_a(
|
283
283
|
a,
|
284
|
-
::Myco.find_constant(:
|
284
|
+
::Myco.find_constant(:String)::Patterns::CharacterSet
|
285
285
|
)
|
286
286
|
self.assert_equal(
|
287
287
|
a.codes,
|
@@ -299,7 +299,7 @@
|
|
299
299
|
)
|
300
300
|
self.assert_is_a(
|
301
301
|
a,
|
302
|
-
::Myco.find_constant(:
|
302
|
+
::Myco.find_constant(:String)::Patterns::CharacterRange
|
303
303
|
)
|
304
304
|
self.assert_equal(
|
305
305
|
a.start,
|
@@ -319,7 +319,7 @@
|
|
319
319
|
)
|
320
320
|
self.assert_is_a(
|
321
321
|
b,
|
322
|
-
::Myco.find_constant(:
|
322
|
+
::Myco.find_constant(:Capture)::Patterns::Reduction
|
323
323
|
)
|
324
324
|
self.assert_equal(
|
325
325
|
b.inner,
|
@@ -330,5 +330,24 @@
|
|
330
330
|
a_proc
|
331
331
|
)
|
332
332
|
)}
|
333
|
+
declare_meme(:"creates a Stream Item with the 'si' shorthand method", [[:it, []]], nil, ::Myco.cscope.dup) { |*| (
|
334
|
+
a = self.shorthand.si([
|
335
|
+
:foo?,
|
336
|
+
[],
|
337
|
+
true
|
338
|
+
])
|
339
|
+
self.assert_is_a(
|
340
|
+
a,
|
341
|
+
::Myco.find_constant(:Stream)::Patterns::Item
|
342
|
+
)
|
343
|
+
self.assert_equal(
|
344
|
+
a.checks,
|
345
|
+
[[
|
346
|
+
:foo?,
|
347
|
+
[],
|
348
|
+
true
|
349
|
+
]]
|
350
|
+
)
|
351
|
+
)}
|
333
352
|
)}
|
334
353
|
)}}.instance)}}.instance
|