sexp_processor 4.13.0 → 4.15.2
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +34 -0
- data/Rakefile +2 -0
- data/lib/pt_testcase.rb +2 -2
- data/lib/sexp_matcher.rb +44 -7
- data/lib/sexp_processor.rb +1 -1
- data/test/test_sexp.rb +21 -10
- metadata +22 -18
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a1ff30b6d0fb789e333a721668f6a71d0ea050847ee74dd202053617779d78d
|
|
4
|
+
data.tar.gz: 025f98b49497f076193e118d887914034ed174f165f8388a6114e464da7e9f4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ce0cf0eb8144e47edc0e4b7550d2e14c81e5d2745fa3d19203e8c6737ff61f58314b087bc2d07cfe087037e0f8138895240a585196328f0a7279a16fc0c5a46
|
|
7
|
+
data.tar.gz: 1d1ba8b291bd55ad533ad45ee7d7a6d894e6f3b2354b58d0d5663bb683fea37b8c21abc75386ed4f01f5df8ff92040415b8557172d7680ee9d2f0dc8e4f789eb
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
=== 4.15.2 / 2021-01-10
|
|
2
|
+
|
|
3
|
+
* 1 bug fix:
|
|
4
|
+
|
|
5
|
+
* Bumped ruby version to include < 4 (trunk).
|
|
6
|
+
|
|
7
|
+
=== 4.15.1 / 2020-08-31
|
|
8
|
+
|
|
9
|
+
* 1 bug fix:
|
|
10
|
+
|
|
11
|
+
* Bumped ruby version to include 3.0 (trunk).
|
|
12
|
+
|
|
13
|
+
=== 4.15.0 / 2020-06-09
|
|
14
|
+
|
|
15
|
+
* 1 minor enhancement:
|
|
16
|
+
|
|
17
|
+
* Added `child` and `include` to Sexp::Matcher.parse language.
|
|
18
|
+
|
|
19
|
+
=== 4.14.1 / 2020-02-09
|
|
20
|
+
|
|
21
|
+
* 2 bug fixes:
|
|
22
|
+
|
|
23
|
+
* Declared support for ruby 2.2+ to gemspec.
|
|
24
|
+
* Fixed alias for `not?` to `-` for ruby <= 2.4. (nard-tech).
|
|
25
|
+
|
|
26
|
+
=== 4.14.0 / 2020-02-06
|
|
27
|
+
|
|
28
|
+
* 4 minor enhancements:
|
|
29
|
+
|
|
30
|
+
* Added '-' as an alias for the 'not?' pattern matching command.
|
|
31
|
+
* Added Klass matcher to match on types.
|
|
32
|
+
* Added `k` shortcut for Klass & hooked into Sexp::Matcher.parse.
|
|
33
|
+
* Added any matcher to pattern parser.
|
|
34
|
+
|
|
1
35
|
=== 4.13.0 / 2019-09-24
|
|
2
36
|
|
|
3
37
|
* 4 minor enhancements:
|
data/Rakefile
CHANGED
data/lib/pt_testcase.rb
CHANGED
|
@@ -77,7 +77,7 @@ class ParseTreeTestCase < Minitest::Test
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def self.add_19tests name, hash
|
|
80
|
-
add_tests "#{name}
|
|
80
|
+
add_tests "#{name}__19_20_21_22_23_24_25_26_27", hash # HACK?
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def self.add_19edgecases ruby, sexp, cases
|
|
@@ -102,7 +102,7 @@ class ParseTreeTestCase < Minitest::Test
|
|
|
102
102
|
testcases[verbose][klass] = testcases[nonverbose][klass]
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
-
VER_RE = "(1[89]|2[
|
|
105
|
+
VER_RE = "(1[89]|2[01234567])"
|
|
106
106
|
|
|
107
107
|
def self.generate_test klass, node, data, input_name, output_name
|
|
108
108
|
klass.send :define_method, "test_#{node}" do
|
data/lib/sexp_matcher.rb
CHANGED
|
@@ -156,6 +156,10 @@ class Sexp #:nodoc:
|
|
|
156
156
|
Not.new arg
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
+
class << self
|
|
160
|
+
alias - not?
|
|
161
|
+
end
|
|
162
|
+
|
|
159
163
|
# TODO: add Sibling factory method?
|
|
160
164
|
|
|
161
165
|
##
|
|
@@ -196,6 +200,15 @@ class Sexp #:nodoc:
|
|
|
196
200
|
Pattern.new Regexp.union(*res)
|
|
197
201
|
end
|
|
198
202
|
|
|
203
|
+
##
|
|
204
|
+
# Matches an atom of the specified +klass+ (or module).
|
|
205
|
+
#
|
|
206
|
+
# See Pattern for examples.
|
|
207
|
+
|
|
208
|
+
def self.k klass
|
|
209
|
+
Klass.new klass
|
|
210
|
+
end
|
|
211
|
+
|
|
199
212
|
##
|
|
200
213
|
# Defines a family of objects that can be used to match sexps to
|
|
201
214
|
# certain types of patterns, much like regexps can be used on
|
|
@@ -438,9 +451,11 @@ class Sexp #:nodoc:
|
|
|
438
451
|
# | "_" => Sexp._
|
|
439
452
|
# | /^\/(.*)\/$/:re => Regexp.new re[0]
|
|
440
453
|
# | /^"(.*)"$/:s => String.new s[0]
|
|
454
|
+
# | UP_NAME:name => Object.const_get name
|
|
441
455
|
# | NAME:name => name.to_sym
|
|
456
|
+
# UP_NAME: /[A-Z]\w*/
|
|
442
457
|
# NAME : /:?[\w?!=~-]+/
|
|
443
|
-
# CMD :
|
|
458
|
+
# CMD : t | k | m | atom | not? | - | any | child | include
|
|
444
459
|
|
|
445
460
|
def parse_sexp
|
|
446
461
|
token = next_token
|
|
@@ -465,6 +480,8 @@ class Sexp #:nodoc:
|
|
|
465
480
|
Regexp.new re
|
|
466
481
|
when /^"(.*)"$/ then
|
|
467
482
|
$1
|
|
483
|
+
when /^([A-Z]\w*)$/ then
|
|
484
|
+
Object.const_get $1
|
|
468
485
|
when /^:?([\w?!=~-]+)$/ then
|
|
469
486
|
$1.to_sym
|
|
470
487
|
else
|
|
@@ -488,7 +505,7 @@ class Sexp #:nodoc:
|
|
|
488
505
|
##
|
|
489
506
|
# A collection of allowed commands to convert into matchers.
|
|
490
507
|
|
|
491
|
-
ALLOWED = [:t, :m, :atom, :not
|
|
508
|
+
ALLOWED = [:t, :m, :k, :atom, :not?, :-, :any, :child, :include].freeze
|
|
492
509
|
|
|
493
510
|
##
|
|
494
511
|
# Parses a balanced command. A command is denoted by square
|
|
@@ -743,11 +760,8 @@ class Sexp #:nodoc:
|
|
|
743
760
|
# +child+.
|
|
744
761
|
|
|
745
762
|
def satisfy? o
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
elsif o.kind_of? Sexp
|
|
749
|
-
o.search_each(child).any?
|
|
750
|
-
end
|
|
763
|
+
child.satisfy?(o) ||
|
|
764
|
+
(o.kind_of?(Sexp) && o.search_each(child).any?)
|
|
751
765
|
end
|
|
752
766
|
|
|
753
767
|
def == o # :nodoc:
|
|
@@ -847,6 +861,29 @@ class Sexp #:nodoc:
|
|
|
847
861
|
end
|
|
848
862
|
end
|
|
849
863
|
|
|
864
|
+
##
|
|
865
|
+
# Matches any atom that is an instance of the specified class or module.
|
|
866
|
+
#
|
|
867
|
+
# examples:
|
|
868
|
+
#
|
|
869
|
+
# s(:lit, 6.28) / s{ q(:lit, k(Float)) } #=> [s(:lit, 6.28)]
|
|
870
|
+
|
|
871
|
+
class Klass < Pattern
|
|
872
|
+
def satisfy? o
|
|
873
|
+
o.kind_of? self.pattern
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
def inspect # :nodoc:
|
|
877
|
+
"k(%p)" % pattern
|
|
878
|
+
end
|
|
879
|
+
|
|
880
|
+
def pretty_print q # :nodoc:
|
|
881
|
+
q.group 1, "k(", ")" do
|
|
882
|
+
q.pp pattern
|
|
883
|
+
end
|
|
884
|
+
end
|
|
885
|
+
end
|
|
886
|
+
|
|
850
887
|
##
|
|
851
888
|
# Matches anything having the same sexp_type, which is the first
|
|
852
889
|
# value in a Sexp.
|
data/lib/sexp_processor.rb
CHANGED
data/test/test_sexp.rb
CHANGED
|
@@ -529,8 +529,6 @@ class TestSexp < SexpTestCase # ZenTest FULL
|
|
|
529
529
|
def test_shift
|
|
530
530
|
skip_if_strict 5
|
|
531
531
|
|
|
532
|
-
skip "https://github.com/MagLev/maglev/issues/250" if maglev?
|
|
533
|
-
|
|
534
532
|
assert_equal(1, @sexp.shift)
|
|
535
533
|
assert_equal(2, @sexp.shift)
|
|
536
534
|
assert_equal(3, @sexp.shift)
|
|
@@ -722,11 +720,17 @@ class TestSexpMatcher < SexpTestCase
|
|
|
722
720
|
end
|
|
723
721
|
|
|
724
722
|
def test_cls_m
|
|
725
|
-
assert_equal M::Pattern.new(/a/), s{ m(/a/) }
|
|
726
|
-
assert_equal M::Pattern.new(/\Aa\Z/), s{ m(:a) }
|
|
727
|
-
assert_equal M::Pattern.new(/test_\w/), s{ m(/test_\w/) }
|
|
728
723
|
re = Regexp.union [/\w/, /\d/]
|
|
729
|
-
|
|
724
|
+
|
|
725
|
+
assert_equal M::Pattern.new(/a/), s{ m(/a/) }
|
|
726
|
+
assert_equal M::Pattern.new(/\Aa\Z/), s{ m(:a) }
|
|
727
|
+
assert_equal M::Pattern.new(/test_\w/), s{ m(/test_\w/) }
|
|
728
|
+
assert_equal M::Pattern.new(re), s{ m(/\w/,/\d/) }
|
|
729
|
+
end
|
|
730
|
+
|
|
731
|
+
def test_cls_k
|
|
732
|
+
assert_equal M::Klass.new(Float), s{ k(Float) }
|
|
733
|
+
assert_operator M::Klass.new(Float), :===, 6.28
|
|
730
734
|
end
|
|
731
735
|
|
|
732
736
|
def test_amp
|
|
@@ -902,7 +906,7 @@ class TestChild < MatcherTestCase
|
|
|
902
906
|
end
|
|
903
907
|
|
|
904
908
|
def sexp
|
|
905
|
-
s(:x, s(:a))
|
|
909
|
+
s(:x, s(:b), s(:a))
|
|
906
910
|
end
|
|
907
911
|
|
|
908
912
|
def bad_sexp
|
|
@@ -922,6 +926,8 @@ class TestChild < MatcherTestCase
|
|
|
922
926
|
|
|
923
927
|
def test_satisfy_eh_by_child
|
|
924
928
|
assert_satisfy matcher, s(:a)
|
|
929
|
+
assert_satisfy matcher, sexp
|
|
930
|
+
refute_satisfy matcher, bad_sexp
|
|
925
931
|
end
|
|
926
932
|
end
|
|
927
933
|
|
|
@@ -1591,12 +1597,17 @@ class TestSexpMatcherParser < Minitest::Test
|
|
|
1591
1597
|
test_parse "match_n", delay{ m(re) }, "[m a b c]"
|
|
1592
1598
|
test_parse "ne", delay{ q(:call, _, :!=, _) }, "(call _ != _)"
|
|
1593
1599
|
test_parse "eq", delay{ q(:call, _, :==, _) }, "(call _ == _)"
|
|
1594
|
-
test_parse "
|
|
1600
|
+
test_parse "not_call", delay{ q(:call, _, :"!") }, "(call _ !)"
|
|
1595
1601
|
test_parse "eh", delay{ q(:call, _, :include?, _) }, "(call _ include? _)"
|
|
1596
1602
|
test_parse "under", delay{ q(:call, nil, :_, _) }, "(call nil :_ _)"
|
|
1597
1603
|
test_parse "sym_nil", delay{ q(:call, nil, :nil, _) }, "(call nil :nil _)"
|
|
1598
|
-
|
|
1599
|
-
test_parse "
|
|
1604
|
+
test_parse "not?", delay{ not?(m(/^_$/)) }, "[not? [m /^_$/]]"
|
|
1605
|
+
test_parse "not2", delay{ -_ }, "[- _]"
|
|
1606
|
+
test_parse "any", delay{ q(:a) | q(:b) }, "[any (a) (b)]"
|
|
1607
|
+
test_parse "child", delay{ child(q(:str, m(/woot/))) }, "[child (str [m /woot/])]"
|
|
1608
|
+
|
|
1609
|
+
test_parse "klass", delay{ q(:lit, k(Float)) }, "(lit [k Float])"
|
|
1610
|
+
test_parse "const", delay{ q(:const, :Float) }, "(const :Float)"
|
|
1600
1611
|
|
|
1601
1612
|
test_bad_parse "open_sexp", "(a"
|
|
1602
1613
|
test_bad_parse "closed_sexp", "a)"
|
metadata
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sexp_processor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.15.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Davis
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain:
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
|
-
|
|
13
|
+
MIIDPjCCAiagAwIBAgIBBTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
|
15
|
-
|
|
15
|
+
GRYDY29tMB4XDTIwMTIyMjIwMzgzMFoXDTIxMTIyMjIwMzgzMFowRTETMBEGA1UE
|
|
16
16
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
|
17
17
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
|
18
18
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
|
@@ -22,14 +22,14 @@ cert_chain:
|
|
|
22
22
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
|
23
23
|
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
|
24
24
|
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
AQAE3XRm1YZcCVjAJy5yMZvTOFrS7B2SYErc+0QwmKYbHztTTDY2m5Bii+jhpuxh
|
|
26
|
+
H+ETcU1z8TUKLpsBUP4kUpIRowkVN1p/jKapV8T3Rbwq+VuYFe+GMKsf8wGZSecG
|
|
27
|
+
oMQ8DzzauZfbvhe2kDg7G9BBPU0wLQlY25rDcCy9bLnD7R0UK3ONqpwvsI5I7x5X
|
|
28
|
+
ZIMXR0a9/DG+55mawwdGzCQobDKiSNLK89KK7OcNTALKU0DfgdTkktdgKchzKHqZ
|
|
29
|
+
d/AHw/kcnU6iuMUoJEcGiJd4gVCTn1l3cDcIvxakGslCA88Jubw0Sqatan0TnC9g
|
|
30
|
+
KToW560QIey7SPfHWduzFJnV
|
|
31
31
|
-----END CERTIFICATE-----
|
|
32
|
-
date:
|
|
32
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
|
33
33
|
dependencies:
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: rdoc
|
|
@@ -57,14 +57,14 @@ dependencies:
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '3.
|
|
60
|
+
version: '3.22'
|
|
61
61
|
type: :development
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '3.
|
|
67
|
+
version: '3.22'
|
|
68
68
|
description: |-
|
|
69
69
|
sexp_processor branches from ParseTree bringing all the generic sexp
|
|
70
70
|
processing tools with it. Sexp, SexpProcessor, Environment, etc... all
|
|
@@ -96,8 +96,9 @@ files:
|
|
|
96
96
|
homepage: https://github.com/seattlerb/sexp_processor
|
|
97
97
|
licenses:
|
|
98
98
|
- MIT
|
|
99
|
-
metadata:
|
|
100
|
-
|
|
99
|
+
metadata:
|
|
100
|
+
homepage_uri: https://github.com/seattlerb/sexp_processor
|
|
101
|
+
post_install_message:
|
|
101
102
|
rdoc_options:
|
|
102
103
|
- "--main"
|
|
103
104
|
- README.rdoc
|
|
@@ -107,15 +108,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
107
108
|
requirements:
|
|
108
109
|
- - ">="
|
|
109
110
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
111
|
+
version: '2.1'
|
|
112
|
+
- - "<"
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: '4'
|
|
111
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
116
|
requirements:
|
|
113
117
|
- - ">="
|
|
114
118
|
- !ruby/object:Gem::Version
|
|
115
119
|
version: '0'
|
|
116
120
|
requirements: []
|
|
117
|
-
rubygems_version: 3.
|
|
118
|
-
signing_key:
|
|
121
|
+
rubygems_version: 3.1.4
|
|
122
|
+
signing_key:
|
|
119
123
|
specification_version: 4
|
|
120
124
|
summary: sexp_processor branches from ParseTree bringing all the generic sexp processing
|
|
121
125
|
tools with it
|
metadata.gz.sig
CHANGED
|
Binary file
|