raabro 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +12 -0
  4. data/lib/raabro.rb +11 -6
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72a0f2a013fa2997e7c6e8edd1a821634dba5b593afdfb00369add4b257f3015
4
- data.tar.gz: 4a62a9fcdb3571eab480dde394269c85768c9c6e48e6b07e4891032982ea970d
3
+ metadata.gz: 7caf050a3b4f2c16bbebbd5a79df2b1e6a8b385f2034aa396bc90a851b147dd0
4
+ data.tar.gz: 0fac1498ab34ea572d502361c47529dd226e2a7ddee940af64d0dc4d4ba96f66
5
5
  SHA512:
6
- metadata.gz: 7ab5adf883c241fefde881980f4b9783d26d49cbb651058803f1ee888d0e0eb7aa4ba6276c05e795eaa7bcae9d9b4c245add84d61e0f48ee1c720c5bc16eff7d
7
- data.tar.gz: 139efc8e983e62d9d0911e7dd25276171948ea453c6caaf950fa67107d5b724ffb81dab705151ae77727e7b2a7b93688328339e4613ce4ceda32ad2748d74559
6
+ metadata.gz: def56f991d1be234cd77e75aabbe1782498353af37be31c49c4c6b2ef1be9ffab938ef75430c1e56e21af6bcbb38986b33222eb08285cd9cff0c42877d3914ad
7
+ data.tar.gz: d687992c730b43594e6ad4d9acba6a0f636f3815672a632df900cbc7d3adc8bf94c44a20cb6cd1c656facdc04eab9c0b1d539d825c198201377a4f7ca48bf613
@@ -2,6 +2,11 @@
2
2
  # raabro CHANGELOG.md
3
3
 
4
4
 
5
+ ## raabro 1.3.1 released 2020-05-10
6
+
7
+ * Add '!' (not) seq quantifier
8
+
9
+
5
10
  ## raabro 1.3.0 released 2020-05-10
6
11
 
7
12
  * Add `nott` parser element
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
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Raabro
3
3
 
4
- VERSION = '1.3.0'
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
- when '?', :q, :qmark then [ 0, 1 ]
262
- when '*', :s, :star then [ 0, 0 ]
263
- when '+', :p, :plus then [ 1, 0 ]
264
- else nil
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 q = _quantify(parsers.first)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raabro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux