raabro 1.3.3 → 1.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/CREDITS.md +4 -3
- data/LICENSE.txt +1 -1
- data/README.md +11 -3
- data/lib/raabro.rb +52 -33
- data/raabro.gemspec +16 -5
- metadata +17 -12
- data/Makefile +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b1e044dceb04da7a6f57861afd82bf3b6c534db46b15eb3ef80b9e1320bb009
|
|
4
|
+
data.tar.gz: df1ca803a864ffdfc9af86f72455cd44beeda2688ee9921d18640577f3059768
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cfae6a0f379f69167e06625bb9b6ae992ad9be178f8fcd117257a8733f3bd6828941a72b4184a37c0b88c9d4797b744da72a9c1db955a6226a0ba5b062928858
|
|
7
|
+
data.tar.gz: 7b98eb4991c75b89309d0c5daedc1759965263762523340371c6caba5e76d669f9b4d5638aae6ff56f1ed8356dda12eff9ac5c45c5d628987dc5f40c8f149c10
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
# raabro CHANGELOG.md
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## raabro 1.5.0 released 2026-07-22
|
|
6
|
+
|
|
7
|
+
* Follow colours: true/false when Raabro.pp(t)
|
|
8
|
+
* Use 0;90 for Raabro.pp dark gray
|
|
9
|
+
* Harden alt() when no :subparser returns nil
|
|
10
|
+
* Harden seq() when no :subparser returns nil
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## raabro 1.4.0 released 2020-10-06
|
|
14
|
+
|
|
15
|
+
* Ensure that jseq, for n elts, parses n-1 separators
|
|
16
|
+
* Introduce Tree #symbol, #symbod, #strind and #strinpd
|
|
17
|
+
|
|
18
|
+
|
|
5
19
|
## raabro 1.3.3 released 2020-09-24
|
|
6
20
|
|
|
7
21
|
* Merge Henrik's rewrite_ optimization
|
data/CREDITS.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
# raabro credits
|
|
3
3
|
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Peter Goldstein, https://github.com/petergoldstein Travis to GHA, gh-7
|
|
5
|
+
* Henryk, Nyh https://github.com/henrik optimized rewrite_, gh-6
|
|
6
|
+
* Utilum, https://github.com/utilum removed unused var
|
|
7
|
+
* John Mettraux, https://github.com/jmettraux author and maintainer
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
## aabro and jaabro credits
|
data/LICENSE.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
Copyright (c) 2015-
|
|
2
|
+
Copyright (c) 2015-2025, John Mettraux, jmettraux@gmail.com
|
|
3
3
|
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
# raabro
|
|
3
3
|
|
|
4
|
-
[](https://github.com/floraison/raabro/actions)
|
|
5
5
|
[](http://badge.fury.io/rb/raabro)
|
|
6
6
|
|
|
7
7
|
A very dumb PEG parser library.
|
|
@@ -29,7 +29,7 @@ module Fun include Raabro
|
|
|
29
29
|
|
|
30
30
|
def pstart(i); rex(nil, i, /\(\s*/); end
|
|
31
31
|
def pend(i); rex(nil, i, /\)\s*/); end
|
|
32
|
-
#
|
|
32
|
+
# parentheses start and end, including trailing white space
|
|
33
33
|
|
|
34
34
|
def comma(i); rex(nil, i, /,\s*/); end
|
|
35
35
|
# a comma, including trailing white space
|
|
@@ -122,6 +122,14 @@ def rex(name, input, regex_or_string)
|
|
|
122
122
|
# matching a regexp
|
|
123
123
|
# no need for ^ or \A, checks the match occurs at current offset
|
|
124
124
|
|
|
125
|
+
def blk(name, input, &block)
|
|
126
|
+
#
|
|
127
|
+
# takes a block returning nil or false when it doesn't match or the
|
|
128
|
+
# length of the matching string if it matches
|
|
129
|
+
#
|
|
130
|
+
# the block take 0, 1 [ string_from_parse_point ], or 2 [ str, input ]
|
|
131
|
+
# arguments
|
|
132
|
+
|
|
125
133
|
def seq(name, input, *parsers)
|
|
126
134
|
# a sequence of parsers
|
|
127
135
|
|
|
@@ -246,7 +254,7 @@ One can reparse with `error: true` and receive an error array with the parse err
|
|
|
246
254
|
```ruby
|
|
247
255
|
err = Sample::Fun.parse('f(a, b', error: true)
|
|
248
256
|
# yields:
|
|
249
|
-
# [ line, column,
|
|
257
|
+
# [ line, column, offset, error_message, error_visual ]
|
|
250
258
|
[ 1, 4, 3, 'parsing failed .../:exp/:fun/:arg', "f(a, b\n ^---" ]
|
|
251
259
|
```
|
|
252
260
|
|
data/lib/raabro.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
|
|
2
3
|
module Raabro
|
|
3
4
|
|
|
4
|
-
VERSION = '1.
|
|
5
|
+
VERSION = '1.5.0'
|
|
5
6
|
|
|
6
7
|
class Input
|
|
7
8
|
|
|
@@ -15,13 +16,16 @@ module Raabro
|
|
|
15
16
|
@options = offset.is_a?(Hash) ? offset : options
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
def match(
|
|
19
|
+
def match(str_rex_or_block)
|
|
19
20
|
|
|
20
|
-
if
|
|
21
|
-
m = @string[@offset..-1].match(
|
|
21
|
+
if str_rex_or_block.is_a?(Regexp)
|
|
22
|
+
m = @string[@offset..-1].match(str_rex_or_block)
|
|
22
23
|
m && (m.offset(0).first == 0) ? m[0].length : false
|
|
24
|
+
elsif str_rex_or_block.is_a?(Proc)
|
|
25
|
+
str_rex_or_block.call(
|
|
26
|
+
*[ @string[@offset..-1], self ].take(str_rex_or_block.arity))
|
|
23
27
|
else # String or whatever responds to #to_s
|
|
24
|
-
s =
|
|
28
|
+
s = str_rex_or_block.to_s
|
|
25
29
|
l = s.length
|
|
26
30
|
@string[@offset, l] == s ? l : false
|
|
27
31
|
end
|
|
@@ -79,10 +83,19 @@ module Raabro
|
|
|
79
83
|
end
|
|
80
84
|
|
|
81
85
|
def string; @input.string[@offset, @length]; end
|
|
82
|
-
def strinp;
|
|
86
|
+
def strinp; string.strip; end
|
|
83
87
|
alias strim strinp
|
|
84
88
|
def nonstring(l=7); @input.string[@offset, l]; end
|
|
85
89
|
|
|
90
|
+
def stringd; string.downcase; end
|
|
91
|
+
alias strind stringd
|
|
92
|
+
def stringpd; strinp.downcase; end
|
|
93
|
+
alias strinpd stringpd
|
|
94
|
+
|
|
95
|
+
def symbol; strinp.to_sym; end
|
|
96
|
+
def symbold; symbol.downcase; end
|
|
97
|
+
alias symbod symbold
|
|
98
|
+
|
|
86
99
|
def lookup(name=nil)
|
|
87
100
|
|
|
88
101
|
name = name ? name.to_s : nil
|
|
@@ -229,11 +242,11 @@ module Raabro
|
|
|
229
242
|
|
|
230
243
|
module ModuleMethods
|
|
231
244
|
|
|
232
|
-
def _match(name, input, parter,
|
|
245
|
+
def _match(name, input, parter, str_rex_or_block)
|
|
233
246
|
|
|
234
247
|
r = Raabro::Tree.new(name, parter, input)
|
|
235
248
|
|
|
236
|
-
if l = input.match(
|
|
249
|
+
if l = input.match(str_rex_or_block)
|
|
237
250
|
r.result = 1
|
|
238
251
|
r.length = l
|
|
239
252
|
input.offset += l
|
|
@@ -252,10 +265,15 @@ module Raabro
|
|
|
252
265
|
_match(name, input, :rex, Regexp.new(regex_or_string))
|
|
253
266
|
end
|
|
254
267
|
|
|
268
|
+
def blk(name, input, &block)
|
|
269
|
+
|
|
270
|
+
_match(name, input, :blk, block)
|
|
271
|
+
end
|
|
272
|
+
|
|
255
273
|
def _quantify(parser)
|
|
256
274
|
|
|
257
275
|
return nil if parser.is_a?(Symbol) && respond_to?(parser)
|
|
258
|
-
# so that :plus and co can be
|
|
276
|
+
# so that :plus and co can be overridden
|
|
259
277
|
|
|
260
278
|
case parser
|
|
261
279
|
when '?', :q, :qmark then [ 0, 1 ]
|
|
@@ -307,7 +325,7 @@ module Raabro
|
|
|
307
325
|
r.children << c
|
|
308
326
|
end
|
|
309
327
|
|
|
310
|
-
break if c.result != 1
|
|
328
|
+
break if c && c.result != 1
|
|
311
329
|
end
|
|
312
330
|
|
|
313
331
|
if c && c.result == 1
|
|
@@ -350,7 +368,7 @@ module Raabro
|
|
|
350
368
|
end
|
|
351
369
|
else
|
|
352
370
|
c = cc
|
|
353
|
-
break if c.result == 1
|
|
371
|
+
break if c && c.result == 1
|
|
354
372
|
end
|
|
355
373
|
end
|
|
356
374
|
|
|
@@ -466,26 +484,36 @@ module Raabro
|
|
|
466
484
|
|
|
467
485
|
if r.result == 1
|
|
468
486
|
|
|
469
|
-
|
|
487
|
+
on_elt = false
|
|
488
|
+
count = 0
|
|
489
|
+
empty_stack = 0
|
|
470
490
|
|
|
471
491
|
loop do
|
|
472
492
|
|
|
473
|
-
|
|
474
|
-
|
|
493
|
+
on_elt = ! on_elt
|
|
494
|
+
|
|
495
|
+
cr = _parse(on_elt ? eltpa : seppa, input)
|
|
475
496
|
|
|
476
|
-
|
|
477
|
-
|
|
497
|
+
empty_stack = cr.empty? ? empty_stack + 1 : 0
|
|
498
|
+
cr.result = 0 if empty_stack > 1
|
|
499
|
+
#
|
|
500
|
+
# prevent "no progress"
|
|
478
501
|
|
|
479
|
-
r.children
|
|
480
|
-
r.children << et if et
|
|
502
|
+
r.children.push(cr)
|
|
481
503
|
|
|
482
|
-
|
|
483
|
-
|
|
504
|
+
if cr.result != 1
|
|
505
|
+
if on_elt && count > 0
|
|
506
|
+
lsep = r.children[-2]
|
|
507
|
+
lsep.result = 0
|
|
508
|
+
input.offset = lsep.offset
|
|
509
|
+
end
|
|
510
|
+
break
|
|
511
|
+
end
|
|
484
512
|
|
|
485
|
-
|
|
513
|
+
count += 1
|
|
486
514
|
end
|
|
487
515
|
|
|
488
|
-
r.result = 0 if jseq &&
|
|
516
|
+
r.result = 0 if jseq && count < 1
|
|
489
517
|
end
|
|
490
518
|
|
|
491
519
|
if r.result == 1 && endpa
|
|
@@ -586,15 +614,6 @@ module Raabro
|
|
|
586
614
|
|
|
587
615
|
make_includable
|
|
588
616
|
|
|
589
|
-
# Black 0;30 Dark Gray 1;30
|
|
590
|
-
# Blue 0;34 Light Blue 1;34
|
|
591
|
-
# Green 0;32 Light Green 1;32
|
|
592
|
-
# Cyan 0;36 Light Cyan 1;36
|
|
593
|
-
# Red 0;31 Light Red 1;31
|
|
594
|
-
# Purple 0;35 Light Purple 1;35
|
|
595
|
-
# Brown 0;33 Yellow 1;33
|
|
596
|
-
# Light Gray 0;37 White 1;37
|
|
597
|
-
|
|
598
617
|
def self.pp(tree, depth=0, opts={})
|
|
599
618
|
|
|
600
619
|
fail ArgumentError.new(
|
|
@@ -604,8 +623,8 @@ module Raabro
|
|
|
604
623
|
depth, opts = 0, depth if depth.is_a?(Hash)
|
|
605
624
|
|
|
606
625
|
_rs, _dg, _gn, _yl, _bl, _lg =
|
|
607
|
-
(opts[:colors] || opts[:colours]
|
|
608
|
-
[ "[0;0m", "[
|
|
626
|
+
(opts[:colors] || opts[:colours]) ?
|
|
627
|
+
[ "[0;0m", "[0;90m", "[0;32m", "[1;33m", "[0;34m", "[0;37m" ] :
|
|
609
628
|
[ '', '', '', '', '', '' ]
|
|
610
629
|
|
|
611
630
|
lc = tree.result == 1 ? _gn : _dg
|
data/raabro.gemspec
CHANGED
|
@@ -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 = '
|
|
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
|
|
|
@@ -18,18 +18,29 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
A very dumb PEG parser library, with a horrible interface.
|
|
19
19
|
}.strip
|
|
20
20
|
|
|
21
|
+
s.metadata = {
|
|
22
|
+
'changelog_uri' => s.homepage + '/blob/master/CHANGELOG.md',
|
|
23
|
+
'bug_tracker_uri' => s.homepage + '/issues',
|
|
24
|
+
'documentation_uri' => s.homepage,
|
|
25
|
+
'source_code_uri' => s.homepage,
|
|
26
|
+
'homepage_uri' => s.homepage,
|
|
27
|
+
#'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/floraison',
|
|
28
|
+
#'wiki_uri' => s.homepage + '/wiki',
|
|
29
|
+
'rubygems_mfa_required' => 'true',
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
#s.files = `git ls-files`.split("\n")
|
|
22
33
|
s.files = Dir[
|
|
23
|
-
'README.{md,txt}',
|
|
24
|
-
'
|
|
25
|
-
'Makefile',
|
|
34
|
+
'{README,CHANGELOG,CREDITS,LICENSE}.{md,txt}',
|
|
35
|
+
#'Makefile',
|
|
26
36
|
'lib/**/*.rb', #'spec/**/*.rb', 'test/**/*.rb',
|
|
27
37
|
"#{s.name}.gemspec",
|
|
28
38
|
]
|
|
29
39
|
|
|
30
40
|
#s.add_runtime_dependency 'tzinfo'
|
|
31
41
|
|
|
32
|
-
s.add_development_dependency 'rspec', '~> 3.7'
|
|
42
|
+
#s.add_development_dependency 'rspec', '~> 3.7'
|
|
43
|
+
s.add_development_dependency 'probatio', '~> 1.6'
|
|
33
44
|
|
|
34
45
|
s.require_path = 'lib'
|
|
35
46
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raabro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Mettraux
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-07-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: probatio
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '1.6'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '1.6'
|
|
27
27
|
description: A very dumb PEG parser library, with a horrible interface.
|
|
28
28
|
email:
|
|
29
29
|
- jmettraux+flor@gmail.com
|
|
@@ -34,15 +34,20 @@ files:
|
|
|
34
34
|
- CHANGELOG.md
|
|
35
35
|
- CREDITS.md
|
|
36
36
|
- LICENSE.txt
|
|
37
|
-
- Makefile
|
|
38
37
|
- README.md
|
|
39
38
|
- lib/raabro.rb
|
|
40
39
|
- raabro.gemspec
|
|
41
|
-
homepage:
|
|
40
|
+
homepage: https://github.com/floraison/raabro
|
|
42
41
|
licenses:
|
|
43
42
|
- MIT
|
|
44
|
-
metadata:
|
|
45
|
-
|
|
43
|
+
metadata:
|
|
44
|
+
changelog_uri: https://github.com/floraison/raabro/blob/master/CHANGELOG.md
|
|
45
|
+
bug_tracker_uri: https://github.com/floraison/raabro/issues
|
|
46
|
+
documentation_uri: https://github.com/floraison/raabro
|
|
47
|
+
source_code_uri: https://github.com/floraison/raabro
|
|
48
|
+
homepage_uri: https://github.com/floraison/raabro
|
|
49
|
+
rubygems_mfa_required: 'true'
|
|
50
|
+
post_install_message:
|
|
46
51
|
rdoc_options: []
|
|
47
52
|
require_paths:
|
|
48
53
|
- lib
|
|
@@ -57,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
57
62
|
- !ruby/object:Gem::Version
|
|
58
63
|
version: '0'
|
|
59
64
|
requirements: []
|
|
60
|
-
rubygems_version: 3.
|
|
61
|
-
signing_key:
|
|
65
|
+
rubygems_version: 3.4.19
|
|
66
|
+
signing_key:
|
|
62
67
|
specification_version: 4
|
|
63
68
|
summary: a very dumb PEG parser library
|
|
64
69
|
test_files: []
|
data/Makefile
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
## gem tasks ##
|
|
3
|
-
|
|
4
|
-
NAME = \
|
|
5
|
-
$(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.name")
|
|
6
|
-
VERSION = \
|
|
7
|
-
$(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.version")
|
|
8
|
-
|
|
9
|
-
count_lines:
|
|
10
|
-
find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
|
|
11
|
-
find spec -name "*_spec.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
|
|
12
|
-
cl: count_lines
|
|
13
|
-
|
|
14
|
-
gemspec_validate:
|
|
15
|
-
@echo "---"
|
|
16
|
-
ruby -e "s = eval(File.read(Dir['*.gemspec'].first)); p s.validate"
|
|
17
|
-
@echo "---"
|
|
18
|
-
|
|
19
|
-
name: gemspec_validate
|
|
20
|
-
@echo "$(NAME) $(VERSION)"
|
|
21
|
-
|
|
22
|
-
cw:
|
|
23
|
-
find lib -name "*.rb" -exec ruby -cw {} \;
|
|
24
|
-
|
|
25
|
-
build: gemspec_validate
|
|
26
|
-
gem build $(NAME).gemspec
|
|
27
|
-
mkdir -p pkg
|
|
28
|
-
mv $(NAME)-$(VERSION).gem pkg/
|
|
29
|
-
|
|
30
|
-
push: build
|
|
31
|
-
gem push --otp "$(OTP)" pkg/$(NAME)-$(VERSION).gem
|
|
32
|
-
|
|
33
|
-
spec:
|
|
34
|
-
bundle exec rspec
|
|
35
|
-
test: spec
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.PHONY: count_lines gemspec_validate name cw build push spec
|
|
39
|
-
|