raabro 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +12 -0
- data/lib/raabro.rb +11 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7caf050a3b4f2c16bbebbd5a79df2b1e6a8b385f2034aa396bc90a851b147dd0
|
4
|
+
data.tar.gz: 0fac1498ab34ea572d502361c47529dd226e2a7ddee940af64d0dc4d4ba96f66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: def56f991d1be234cd77e75aabbe1782498353af37be31c49c4c6b2ef1be9ffab938ef75430c1e56e21af6bcbb38986b33222eb08285cd9cff0c42877d3914ad
|
7
|
+
data.tar.gz: d687992c730b43594e6ad4d9acba6a0f636f3815672a632df900cbc7d3adc8bf94c44a20cb6cd1c656facdc04eab9c0b1d539d825c198201377a4f7ca48bf613
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -159,6 +159,8 @@ def eseq(name, input, startpa, eltpa, seppa, endpa)
|
|
159
159
|
|
160
160
|
`seq` is special, it understands "quantifiers": `'?'`, `'+'` or `'*'`. They make behave `seq` a bit like a classical regex.
|
161
161
|
|
162
|
+
The `'!'` (bang, not) quantifier is explained at the end of this section.
|
163
|
+
|
162
164
|
```ruby
|
163
165
|
module CartParser include Raabro
|
164
166
|
|
@@ -178,6 +180,16 @@ end
|
|
178
180
|
|
179
181
|
(Yes, this sample parser parses string like "appletomatocabbage", it's not very useful, but I hope you get the point about `.seq`)
|
180
182
|
|
183
|
+
The `'!'` (bang, not) quantifier is a kind of "negative lookahead".
|
184
|
+
|
185
|
+
```ruby
|
186
|
+
def menu(i)
|
187
|
+
seq(:menu, i, :mise_en_bouche, :main, :main, '!', :dessert)
|
188
|
+
end
|
189
|
+
```
|
190
|
+
|
191
|
+
Lousy example, but here a main cannot follow a main.
|
192
|
+
|
181
193
|
|
182
194
|
## trees
|
183
195
|
|
data/lib/raabro.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module Raabro
|
3
3
|
|
4
|
-
VERSION = '1.3.
|
4
|
+
VERSION = '1.3.1'
|
5
5
|
|
6
6
|
class Input
|
7
7
|
|
@@ -258,10 +258,11 @@ module Raabro
|
|
258
258
|
# so that :plus and co can be overriden
|
259
259
|
|
260
260
|
case parser
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
261
|
+
when '?', :q, :qmark then [ 0, 1 ]
|
262
|
+
when '*', :s, :star then [ 0, 0 ]
|
263
|
+
when '+', :p, :plus then [ 1, 0 ]
|
264
|
+
when '!' then :bang
|
265
|
+
else nil
|
265
266
|
end
|
266
267
|
end
|
267
268
|
|
@@ -293,7 +294,11 @@ module Raabro
|
|
293
294
|
pa = parsers.shift
|
294
295
|
break unless pa
|
295
296
|
|
296
|
-
if
|
297
|
+
if parsers.first == '!'
|
298
|
+
parsers.shift
|
299
|
+
c = nott(nil, input, pa)
|
300
|
+
r.children << c
|
301
|
+
elsif q = _quantify(parsers.first)
|
297
302
|
parsers.shift
|
298
303
|
c = rep(nil, input, pa, *q)
|
299
304
|
r.children.concat(c.children)
|