raabro 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/raabro.rb +33 -13
  4. data/raabro.gemspec +1 -1
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aacf8b3ef595904e286ba4ed9544c3e7901e8815479a1a01cb70e02f40e03eda
4
- data.tar.gz: b359e9b7c05039623d288dfc69c931b2b38e2ae8ee1c3e211d66f9218c12e32e
3
+ metadata.gz: 6c97c1720256a9bd016f9a3644bf6a0a407afde36122fe666a415f65d8f11fa2
4
+ data.tar.gz: 0e52242404f2309cbccfd92f7ee1d4ef06777c883d1c40254bddcf033a63752e
5
5
  SHA512:
6
- metadata.gz: f31a3a5db74555d01b7d6a384ab4bd91dbf5beec8544aa99d7b012a60ce87767b51c1f6e74dd81e5c99b56eaea1bd0cb3cc1096452d58119a1fc33ada07e803e
7
- data.tar.gz: 75b99b8c242258baab31f85d325585ad5c611ec0d98ce80110a1972d2b39762b035cb49fc66b0964b32edf8a1867b6a858756836ab40da6625921af8afd4eb3f
6
+ metadata.gz: fa0aebdcbfaeadd23dfd1ac8c442e52b839bced502c0ae144c5562bc97fc0e2a54c3114b0e048f47fdcb46c8ac2a7def92b7cd6169256195957bb7acbd65a9a6
7
+ data.tar.gz: e9c3eab148ede2853cafa1ec3fceec9967af83b4c3453017666f01741a0d51cb5eb200dde64e5d7c62ede442768b5f861a3a8bdb5587ded9a6a5afde73844b05
@@ -2,6 +2,12 @@
2
2
  # raabro CHANGELOG.md
3
3
 
4
4
 
5
+ ## raabro 1.4.0 released 2020-10-06
6
+
7
+ * Ensure that jseq, for n elts, parses n-1 separators
8
+ * Introduce Tree #symbol, #symbod, #strind and #strinpd
9
+
10
+
5
11
  ## raabro 1.3.3 released 2020-09-24
6
12
 
7
13
  * Merge Henrik's rewrite_ optimization
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Raabro
3
4
 
4
- VERSION = '1.3.3'
5
+ VERSION = '1.4.0'
5
6
 
6
7
  class Input
7
8
 
@@ -79,10 +80,19 @@ module Raabro
79
80
  end
80
81
 
81
82
  def string; @input.string[@offset, @length]; end
82
- def strinp; @input.string[@offset, @length].strip; end
83
+ def strinp; string.strip; end
83
84
  alias strim strinp
84
85
  def nonstring(l=7); @input.string[@offset, l]; end
85
86
 
87
+ def stringd; string.downcase; end
88
+ alias strind stringd
89
+ def stringpd; strinp.downcase; end
90
+ alias strinpd stringpd
91
+
92
+ def symbol; strinp.to_sym; end
93
+ def symbold; symbol.downcase; end
94
+ alias symbod symbold
95
+
86
96
  def lookup(name=nil)
87
97
 
88
98
  name = name ? name.to_s : nil
@@ -466,26 +476,36 @@ module Raabro
466
476
 
467
477
  if r.result == 1
468
478
 
469
- i = 0
479
+ on_elt = false
480
+ count = 0
481
+ empty_stack = 0
470
482
 
471
483
  loop do
472
484
 
473
- st = i > 0 ? _parse(seppa, input) : nil
474
- et = st == nil || st.result == 1 ? _parse(eltpa, input) : nil
485
+ on_elt = ! on_elt
475
486
 
476
- break if st && et && st.empty? && et.result == 0
477
- break if st && et && st.empty? && et.empty?
487
+ cr = _parse(on_elt ? eltpa : seppa, input)
478
488
 
479
- r.children << st if st
480
- r.children << et if et
489
+ empty_stack = cr.empty? ? empty_stack + 1 : 0
490
+ cr.result = 0 if empty_stack > 1
491
+ #
492
+ # prevent "no progress"
481
493
 
482
- break if et == nil
483
- break if et.result != 1
494
+ r.children.push(cr)
495
+
496
+ if cr.result != 1
497
+ if on_elt && count > 0
498
+ lsep = r.children[-2]
499
+ lsep.result = 0
500
+ input.offset = lsep.offset
501
+ end
502
+ break
503
+ end
484
504
 
485
- i = i + 1
505
+ count += 1
486
506
  end
487
507
 
488
- r.result = 0 if jseq && i == 0
508
+ r.result = 0 if jseq && count < 1
489
509
  end
490
510
 
491
511
  if r.result == 1 && endpa
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ 'John Mettraux' ]
12
12
  s.email = [ 'jmettraux+flor@gmail.com' ]
13
- s.homepage = 'http://github.com/floraison/raabro'
13
+ s.homepage = 'https://github.com/floraison/raabro'
14
14
  s.license = 'MIT'
15
15
  s.summary = 'a very dumb PEG parser library'
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raabro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-24 00:00:00.000000000 Z
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,7 +38,7 @@ files:
38
38
  - README.md
39
39
  - lib/raabro.rb
40
40
  - raabro.gemspec
41
- homepage: http://github.com/floraison/raabro
41
+ homepage: https://github.com/floraison/raabro
42
42
  licenses:
43
43
  - MIT
44
44
  metadata: {}