raabro 1.4.0 → 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 +8 -0
- data/CREDITS.md +4 -3
- data/LICENSE.txt +1 -1
- data/README.md +11 -3
- data/lib/raabro.rb +20 -21
- data/raabro.gemspec +15 -4
- metadata +16 -11
- 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,14 @@
|
|
|
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
|
+
|
|
5
13
|
## raabro 1.4.0 released 2020-10-06
|
|
6
14
|
|
|
7
15
|
* Ensure that jseq, for n elts, parses n-1 separators
|
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Raabro
|
|
4
4
|
|
|
5
|
-
VERSION = '1.
|
|
5
|
+
VERSION = '1.5.0'
|
|
6
6
|
|
|
7
7
|
class Input
|
|
8
8
|
|
|
@@ -16,13 +16,16 @@ module Raabro
|
|
|
16
16
|
@options = offset.is_a?(Hash) ? offset : options
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def match(
|
|
19
|
+
def match(str_rex_or_block)
|
|
20
20
|
|
|
21
|
-
if
|
|
22
|
-
m = @string[@offset..-1].match(
|
|
21
|
+
if str_rex_or_block.is_a?(Regexp)
|
|
22
|
+
m = @string[@offset..-1].match(str_rex_or_block)
|
|
23
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))
|
|
24
27
|
else # String or whatever responds to #to_s
|
|
25
|
-
s =
|
|
28
|
+
s = str_rex_or_block.to_s
|
|
26
29
|
l = s.length
|
|
27
30
|
@string[@offset, l] == s ? l : false
|
|
28
31
|
end
|
|
@@ -239,11 +242,11 @@ module Raabro
|
|
|
239
242
|
|
|
240
243
|
module ModuleMethods
|
|
241
244
|
|
|
242
|
-
def _match(name, input, parter,
|
|
245
|
+
def _match(name, input, parter, str_rex_or_block)
|
|
243
246
|
|
|
244
247
|
r = Raabro::Tree.new(name, parter, input)
|
|
245
248
|
|
|
246
|
-
if l = input.match(
|
|
249
|
+
if l = input.match(str_rex_or_block)
|
|
247
250
|
r.result = 1
|
|
248
251
|
r.length = l
|
|
249
252
|
input.offset += l
|
|
@@ -262,10 +265,15 @@ module Raabro
|
|
|
262
265
|
_match(name, input, :rex, Regexp.new(regex_or_string))
|
|
263
266
|
end
|
|
264
267
|
|
|
268
|
+
def blk(name, input, &block)
|
|
269
|
+
|
|
270
|
+
_match(name, input, :blk, block)
|
|
271
|
+
end
|
|
272
|
+
|
|
265
273
|
def _quantify(parser)
|
|
266
274
|
|
|
267
275
|
return nil if parser.is_a?(Symbol) && respond_to?(parser)
|
|
268
|
-
# so that :plus and co can be
|
|
276
|
+
# so that :plus and co can be overridden
|
|
269
277
|
|
|
270
278
|
case parser
|
|
271
279
|
when '?', :q, :qmark then [ 0, 1 ]
|
|
@@ -317,7 +325,7 @@ module Raabro
|
|
|
317
325
|
r.children << c
|
|
318
326
|
end
|
|
319
327
|
|
|
320
|
-
break if c.result != 1
|
|
328
|
+
break if c && c.result != 1
|
|
321
329
|
end
|
|
322
330
|
|
|
323
331
|
if c && c.result == 1
|
|
@@ -360,7 +368,7 @@ module Raabro
|
|
|
360
368
|
end
|
|
361
369
|
else
|
|
362
370
|
c = cc
|
|
363
|
-
break if c.result == 1
|
|
371
|
+
break if c && c.result == 1
|
|
364
372
|
end
|
|
365
373
|
end
|
|
366
374
|
|
|
@@ -606,15 +614,6 @@ module Raabro
|
|
|
606
614
|
|
|
607
615
|
make_includable
|
|
608
616
|
|
|
609
|
-
# Black 0;30 Dark Gray 1;30
|
|
610
|
-
# Blue 0;34 Light Blue 1;34
|
|
611
|
-
# Green 0;32 Light Green 1;32
|
|
612
|
-
# Cyan 0;36 Light Cyan 1;36
|
|
613
|
-
# Red 0;31 Light Red 1;31
|
|
614
|
-
# Purple 0;35 Light Purple 1;35
|
|
615
|
-
# Brown 0;33 Yellow 1;33
|
|
616
|
-
# Light Gray 0;37 White 1;37
|
|
617
|
-
|
|
618
617
|
def self.pp(tree, depth=0, opts={})
|
|
619
618
|
|
|
620
619
|
fail ArgumentError.new(
|
|
@@ -624,8 +623,8 @@ module Raabro
|
|
|
624
623
|
depth, opts = 0, depth if depth.is_a?(Hash)
|
|
625
624
|
|
|
626
625
|
_rs, _dg, _gn, _yl, _bl, _lg =
|
|
627
|
-
(opts[:colors] || opts[:colours]
|
|
628
|
-
[ "[0;0m", "[
|
|
626
|
+
(opts[:colors] || opts[:colours]) ?
|
|
627
|
+
[ "[0;0m", "[0;90m", "[0;32m", "[1;33m", "[0;34m", "[0;37m" ] :
|
|
629
628
|
[ '', '', '', '', '', '' ]
|
|
630
629
|
|
|
631
630
|
lc = tree.result == 1 ? _gn : _dg
|
data/raabro.gemspec
CHANGED
|
@@ -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
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
|
-
|