walrat 0.1 → 0.3.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/walrat/additions/proc.rb +2 -21
- data/lib/walrat/additions/regexp.rb +3 -22
- data/lib/walrat/additions/string.rb +2 -34
- data/lib/walrat/additions/symbol.rb +3 -22
- data/lib/walrat/and_predicate.rb +2 -21
- data/lib/walrat/array_result.rb +2 -21
- data/lib/walrat/continuation_wrapper_exception.rb +2 -21
- data/lib/walrat/grammar.rb +9 -27
- data/lib/walrat/left_recursion_exception.rb +2 -21
- data/lib/walrat/location_tracking.rb +5 -26
- data/lib/walrat/match_data_wrapper.rb +2 -21
- data/lib/walrat/memoizing.rb +3 -23
- data/lib/walrat/memoizing_cache.rb +3 -23
- data/lib/walrat/no_parameter_marker.rb +3 -22
- data/lib/walrat/node.rb +4 -23
- data/lib/walrat/not_predicate.rb +2 -21
- data/lib/walrat/parse_error.rb +2 -21
- data/lib/walrat/parser_state.rb +2 -21
- data/lib/walrat/parslet.rb +2 -21
- data/lib/walrat/parslet_choice.rb +2 -21
- data/lib/walrat/parslet_combination.rb +2 -21
- data/lib/walrat/parslet_combining.rb +22 -90
- data/lib/walrat/parslet_merge.rb +2 -21
- data/lib/walrat/parslet_omission.rb +2 -21
- data/lib/walrat/parslet_repetition.rb +2 -21
- data/lib/walrat/parslet_repetition_default.rb +2 -21
- data/lib/walrat/parslet_sequence.rb +2 -21
- data/lib/walrat/predicate.rb +2 -21
- data/lib/walrat/proc_parslet.rb +2 -21
- data/lib/walrat/regexp_parslet.rb +2 -21
- data/lib/walrat/skipped_substring_exception.rb +2 -21
- data/lib/walrat/string_enumerator.rb +2 -23
- data/lib/walrat/string_parslet.rb +2 -21
- data/lib/walrat/string_result.rb +3 -22
- data/lib/walrat/symbol_parslet.rb +2 -21
- data/lib/walrat/version.rb +4 -23
- data/lib/walrat.rb +3 -28
- metadata +54 -54
data/lib/walrat/parser_state.rb
CHANGED
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
data/lib/walrat/parslet.rb
CHANGED
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -32,27 +13,19 @@ module Walrat
|
|
32
13
|
module ParsletCombining
|
33
14
|
# Convenience method.
|
34
15
|
def memoizing_parse string, options = {}
|
35
|
-
|
16
|
+
to_parseable.memoizing_parse string, options
|
36
17
|
end
|
37
18
|
|
38
19
|
# Convenience method.
|
39
20
|
def parse string, options = {}
|
40
|
-
|
21
|
+
to_parseable.parse string, options
|
41
22
|
end
|
42
23
|
|
43
|
-
# Defines a sequence of Parslets (or ParsletCombinations).
|
44
|
-
# Returns a ParsletSequence instance.
|
45
|
-
def sequence first, second, *others
|
46
|
-
Walrat::ParsletSequence.new first.to_parseable,
|
47
|
-
second.to_parseable, *others
|
48
|
-
end
|
49
|
-
|
50
|
-
# Shorthand for ParsletCombining.sequence(first, second).
|
51
24
|
def &(next_parslet)
|
52
|
-
|
25
|
+
ParsletSequence.new self.to_parseable, next_parslet.to_parseable
|
53
26
|
end
|
54
27
|
|
55
|
-
# Defines a sequence of Parslets similar to the
|
28
|
+
# Defines a sequence of Parslets similar to the #& method but with
|
56
29
|
# the difference that the contents of array results from the component
|
57
30
|
# parslets will be merged into a single array rather than being added as
|
58
31
|
# arrays. To illustrate:
|
@@ -60,49 +33,29 @@ module Walrat
|
|
60
33
|
# 'foo' & 'bar'.one_or_more # returns results like ['foo', ['bar', 'bar', 'bar']]
|
61
34
|
# 'foo' >> 'bar'.one_or_more # returns results like ['foo', 'bar', 'bar', 'bar']
|
62
35
|
#
|
63
|
-
def merge first, second, *others
|
64
|
-
Walrat::ParsletMerge.new first.to_parseable,
|
65
|
-
second.to_parseable, *others
|
66
|
-
end
|
67
|
-
|
68
|
-
# Shorthand for ParsletCombining.sequence(first, second)
|
69
36
|
def >>(next_parslet)
|
70
|
-
|
37
|
+
ParsletMerge.new self.to_parseable, next_parslet.to_parseable
|
71
38
|
end
|
72
39
|
|
73
40
|
# Defines a choice of Parslets (or ParsletCombinations).
|
74
41
|
# Returns a ParsletChoice instance.
|
75
|
-
def choice left, right, *others
|
76
|
-
Walrat::ParsletChoice.new left.to_parseable,
|
77
|
-
right.to_parseable, *others
|
78
|
-
end
|
79
|
-
|
80
|
-
# Shorthand for ParsletCombining.choice(left, right)
|
81
42
|
def |(alternative_parslet)
|
82
|
-
|
43
|
+
ParsletChoice.new self.to_parseable,
|
44
|
+
alternative_parslet.to_parseable
|
83
45
|
end
|
84
46
|
|
85
47
|
# Defines a repetition of the supplied Parslet (or ParsletCombination).
|
86
48
|
# Returns a ParsletRepetition instance.
|
87
|
-
def repetition parslet, min, max
|
88
|
-
Walrat::ParsletRepetition.new parslet.to_parseable, min, max
|
89
|
-
end
|
90
|
-
|
91
|
-
# Shorthand for ParsletCombining.repetition.
|
92
49
|
def repeat min = nil, max = nil
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
def repetition_with_default parslet, min, max, default
|
97
|
-
Walrat::ParsletRepetitionDefault.new parslet.to_parseable, min,
|
98
|
-
max, default
|
50
|
+
ParsletRepetition.new self.to_parseable, min, max
|
99
51
|
end
|
100
52
|
|
101
53
|
def repeat_with_default min = nil, max = nil, default = nil
|
102
|
-
|
54
|
+
ParsletRepetitionDefault.new self.to_parseable, min,
|
55
|
+
max, default
|
103
56
|
end
|
104
57
|
|
105
|
-
# Shorthand for ParsletCombining
|
58
|
+
# Shorthand for ParsletCombining#repetition(0, 1).
|
106
59
|
# This method optionally takes a single parameter specifying what object
|
107
60
|
# should be returned as a placeholder when there are no matches; this is
|
108
61
|
# useful for packing into ASTs where it may be better to parse an empty
|
@@ -113,44 +66,36 @@ module Walrat
|
|
113
66
|
# explicitly passing an "ArrayResult.new")
|
114
67
|
def optional default_return_value = NoParameterMarker.instance
|
115
68
|
if default_return_value == NoParameterMarker.instance
|
116
|
-
|
69
|
+
repeat 0, 1 # default behaviour
|
117
70
|
else
|
118
|
-
|
71
|
+
repeat_with_default 0, 1, default_return_value
|
119
72
|
end
|
120
73
|
end
|
121
74
|
|
122
75
|
# Alternative to optional.
|
123
76
|
def zero_or_one
|
124
|
-
|
77
|
+
optional
|
125
78
|
end
|
126
79
|
|
127
80
|
# possible synonym "star"
|
128
81
|
def zero_or_more default_return_value = NoParameterMarker.instance
|
129
82
|
if default_return_value == NoParameterMarker.instance
|
130
|
-
|
83
|
+
repeat 0 # default behaviour
|
131
84
|
else
|
132
|
-
|
85
|
+
repeat_with_default 0, nil, default_return_value
|
133
86
|
end
|
134
87
|
end
|
135
88
|
|
136
89
|
# possible synonym "plus"
|
137
90
|
def one_or_more
|
138
|
-
|
91
|
+
repeat 1
|
139
92
|
end
|
140
93
|
|
141
94
|
# Parsing Expression Grammar support.
|
142
95
|
# Succeeds if parslet succeeds but consumes no input (throws an
|
143
96
|
# :AndPredicateSuccess symbol).
|
144
|
-
def and_predicate parslet
|
145
|
-
Walrat::AndPredicate.new parslet.to_parseable
|
146
|
-
end
|
147
|
-
|
148
|
-
# Shorthand for and_predicate
|
149
|
-
# Strictly speaking, this shorthand breaks with established Ruby practice
|
150
|
-
# that "?" at the end of a method name should indicate a method that
|
151
|
-
# returns true or false.
|
152
97
|
def and?
|
153
|
-
|
98
|
+
AndPredicate.new self.to_parseable
|
154
99
|
end
|
155
100
|
|
156
101
|
# Parsing Expression Grammar support.
|
@@ -161,16 +106,8 @@ module Walrat
|
|
161
106
|
# operator, like this:
|
162
107
|
# rule :foo, :p1 & :p2.not_predicate
|
163
108
|
# rule :foo, :p1 & :p2.not!
|
164
|
-
def not_predicate parslet
|
165
|
-
Walrat::NotPredicate.new parslet.to_parseable
|
166
|
-
end
|
167
|
-
|
168
|
-
# Shorthand for not_predicate.
|
169
|
-
# Strictly speaking, this shorthand breaks with established Ruby practice
|
170
|
-
# that "!" at the end of a method name should indicate a destructive
|
171
|
-
# behaviour on (mutation of) the receiver.
|
172
109
|
def not!
|
173
|
-
|
110
|
+
NotPredicate.new self.to_parseable
|
174
111
|
end
|
175
112
|
|
176
113
|
# Succeeds if parsing succeeds, consuming the output, but doesn't actually
|
@@ -178,13 +115,8 @@ module Walrat
|
|
178
115
|
#
|
179
116
|
# This is for elements which are required but which shouldn't appear in the
|
180
117
|
# final AST.
|
181
|
-
def omission parslet
|
182
|
-
Walrat::ParsletOmission.new parslet.to_parseable
|
183
|
-
end
|
184
|
-
|
185
|
-
# Shorthand for ParsletCombining.omission
|
186
118
|
def skip
|
187
|
-
|
119
|
+
ParsletOmission.new self.to_parseable
|
188
120
|
end
|
189
121
|
end # module ParsletCombining
|
190
122
|
end # module Walrat
|
data/lib/walrat/parslet_merge.rb
CHANGED
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
data/lib/walrat/predicate.rb
CHANGED
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
data/lib/walrat/proc_parslet.rb
CHANGED
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|
@@ -1,31 +1,11 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'strscan'
|
24
5
|
require 'walrat'
|
25
6
|
|
26
7
|
module Walrat
|
27
8
|
# Unicode-aware (UTF-8) string enumerator.
|
28
|
-
# For Unicode support $KCODE must be set to 'U' (UTF-8).
|
29
9
|
class StringEnumerator
|
30
10
|
# Returns the char most recently scanned before the last "next" call, or
|
31
11
|
# nil if nothing previously scanned.
|
@@ -38,7 +18,6 @@ module Walrat
|
|
38
18
|
@last = nil
|
39
19
|
end
|
40
20
|
|
41
|
-
# This method will only work as expected if $KCODE is set to 'U' (UTF-8).
|
42
21
|
def next
|
43
22
|
@last = @current
|
44
23
|
@current = @scanner.scan(/./m) # must use multiline mode or "." won't match newlines
|
@@ -1,24 +1,5 @@
|
|
1
|
-
# Copyright 2007-
|
2
|
-
#
|
3
|
-
# modification, are permitted provided that the following conditions are met:
|
4
|
-
#
|
5
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
6
|
-
# this list of conditions and the following disclaimer.
|
7
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer in the documentation
|
9
|
-
# and/or other materials provided with the distribution.
|
10
|
-
#
|
11
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
12
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
13
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
14
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
15
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
16
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
17
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
18
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
19
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
20
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
21
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# Copyright 2007-present Greg Hurrell. All rights reserved.
|
2
|
+
# Licensed under the terms of the BSD 2-clause license.
|
22
3
|
|
23
4
|
require 'walrat'
|
24
5
|
|