sexp_processor 4.13.0 → 4.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +9 -0
- data/lib/sexp_matcher.rb +41 -2
- data/lib/sexp_processor.rb +1 -1
- data/test/test_sexp.rb +16 -9
- metadata +15 -14
- 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: cc011ca4a8aa9fcdf85662ce6986f007f1d81ba4d1d8caa09ae435fe473de2b7
|
4
|
+
data.tar.gz: c59277cfb37f85fe144a3e4888d3723dcf85ec860f371e1477b1b5a137d81add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8a91b76f43e488512e61b3a1533efa01456122128cc15901f238dde5457372b79005f63c7941e11d94ef0ce93ccd827859fc7ae3592e1e08f635f26b16f532
|
7
|
+
data.tar.gz: bd2be1290e3eb2f801267950ea782ae6dc72766e8b7fe3a2c6674a4f7ce2c89960d4afbc1b56adf48eee381c4fcdedc00ef10a931d3e7a07e04f8790373da0d2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== 4.14.0 / 2020-02-06
|
2
|
+
|
3
|
+
* 4 minor enhancements:
|
4
|
+
|
5
|
+
* Added '-' as an alias for the 'not?' pattern matching command.
|
6
|
+
* Added Klass matcher to match on types.
|
7
|
+
* Added `k` shortcut for Klass & hooked into Sexp::Matcher.parse.
|
8
|
+
* Added any matcher to pattern parser.
|
9
|
+
|
1
10
|
=== 4.13.0 / 2019-09-24
|
2
11
|
|
3
12
|
* 4 minor enhancements:
|
data/lib/sexp_matcher.rb
CHANGED
@@ -156,6 +156,9 @@ class Sexp #:nodoc:
|
|
156
156
|
Not.new arg
|
157
157
|
end
|
158
158
|
|
159
|
+
mc = (class << self; self; end)
|
160
|
+
mc.alias_method :-, :not?
|
161
|
+
|
159
162
|
# TODO: add Sibling factory method?
|
160
163
|
|
161
164
|
##
|
@@ -196,6 +199,15 @@ class Sexp #:nodoc:
|
|
196
199
|
Pattern.new Regexp.union(*res)
|
197
200
|
end
|
198
201
|
|
202
|
+
##
|
203
|
+
# Matches an atom of the specified +klass+ (or module).
|
204
|
+
#
|
205
|
+
# See Pattern for examples.
|
206
|
+
|
207
|
+
def self.k klass
|
208
|
+
Klass.new klass
|
209
|
+
end
|
210
|
+
|
199
211
|
##
|
200
212
|
# Defines a family of objects that can be used to match sexps to
|
201
213
|
# certain types of patterns, much like regexps can be used on
|
@@ -438,9 +450,11 @@ class Sexp #:nodoc:
|
|
438
450
|
# | "_" => Sexp._
|
439
451
|
# | /^\/(.*)\/$/:re => Regexp.new re[0]
|
440
452
|
# | /^"(.*)"$/:s => String.new s[0]
|
453
|
+
# | UP_NAME:name => Object.const_get name
|
441
454
|
# | NAME:name => name.to_sym
|
455
|
+
# UP_NAME: /[A-Z]\w*/
|
442
456
|
# NAME : /:?[\w?!=~-]+/
|
443
|
-
# CMD : "t" | "m" | "atom" | "not?"
|
457
|
+
# CMD : "t" | "k" | "m" | "atom" | "not?" | "-" | "any"
|
444
458
|
|
445
459
|
def parse_sexp
|
446
460
|
token = next_token
|
@@ -465,6 +479,8 @@ class Sexp #:nodoc:
|
|
465
479
|
Regexp.new re
|
466
480
|
when /^"(.*)"$/ then
|
467
481
|
$1
|
482
|
+
when /^([A-Z]\w*)$/ then
|
483
|
+
Object.const_get $1
|
468
484
|
when /^:?([\w?!=~-]+)$/ then
|
469
485
|
$1.to_sym
|
470
486
|
else
|
@@ -488,7 +504,7 @@ class Sexp #:nodoc:
|
|
488
504
|
##
|
489
505
|
# A collection of allowed commands to convert into matchers.
|
490
506
|
|
491
|
-
ALLOWED = [:t, :m, :atom, :not
|
507
|
+
ALLOWED = [:t, :m, :k, :atom, :not?, :-, :any].freeze
|
492
508
|
|
493
509
|
##
|
494
510
|
# Parses a balanced command. A command is denoted by square
|
@@ -847,6 +863,29 @@ class Sexp #:nodoc:
|
|
847
863
|
end
|
848
864
|
end
|
849
865
|
|
866
|
+
##
|
867
|
+
# Matches any atom that is an instance of the specified class or module.
|
868
|
+
#
|
869
|
+
# examples:
|
870
|
+
#
|
871
|
+
# s(:lit, 6.28) / s{ q(:lit, k(Float)) } #=> [s(:lit, 6.28)]
|
872
|
+
|
873
|
+
class Klass < Pattern
|
874
|
+
def satisfy? o
|
875
|
+
o.kind_of? self.pattern
|
876
|
+
end
|
877
|
+
|
878
|
+
def inspect # :nodoc:
|
879
|
+
"k(%p)" % pattern
|
880
|
+
end
|
881
|
+
|
882
|
+
def pretty_print q # :nodoc:
|
883
|
+
q.group 1, "k(", ")" do
|
884
|
+
q.pp pattern
|
885
|
+
end
|
886
|
+
end
|
887
|
+
end
|
888
|
+
|
850
889
|
##
|
851
890
|
# Matches anything having the same sexp_type, which is the first
|
852
891
|
# 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
|
@@ -1591,12 +1595,15 @@ class TestSexpMatcherParser < Minitest::Test
|
|
1591
1595
|
test_parse "match_n", delay{ m(re) }, "[m a b c]"
|
1592
1596
|
test_parse "ne", delay{ q(:call, _, :!=, _) }, "(call _ != _)"
|
1593
1597
|
test_parse "eq", delay{ q(:call, _, :==, _) }, "(call _ == _)"
|
1594
|
-
test_parse "
|
1598
|
+
test_parse "not_call", delay{ q(:call, _, :"!") }, "(call _ !)"
|
1595
1599
|
test_parse "eh", delay{ q(:call, _, :include?, _) }, "(call _ include? _)"
|
1596
1600
|
test_parse "under", delay{ q(:call, nil, :_, _) }, "(call nil :_ _)"
|
1597
1601
|
test_parse "sym_nil", delay{ q(:call, nil, :nil, _) }, "(call nil :nil _)"
|
1598
|
-
|
1599
|
-
test_parse "
|
1602
|
+
test_parse "not?", delay{ not?(m(/^_$/)) }, "[not? [m /^_$/]]"
|
1603
|
+
test_parse "not2", delay{ -_ }, "[- _]"
|
1604
|
+
test_parse "any", delay{ q(:a) | q(:b) }, "[any (a) (b)]"
|
1605
|
+
|
1606
|
+
test_parse "klass", delay{ q(:lit, k(Float)) }, "(lit [k Float])"
|
1600
1607
|
|
1601
1608
|
test_bad_parse "open_sexp", "(a"
|
1602
1609
|
test_bad_parse "closed_sexp", "a)"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sexp_processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -10,9 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDPjCCAiagAwIBAgIBBDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTE5MTIxMzAwMDIwNFoXDTIwMTIxMjAwMDIwNFowRTETMBEGA1UE
|
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
|
+
AQCkkcHqAa6IKLYGl93rn78J3L+LnqyxaA059n4IGMHWN5bv9KBQnIjOrpLadtYZ
|
26
|
+
vhWkunWDKdfVapBEq5+T4HzqnsEXC3aCv6JEKJY6Zw7iSzl0M8hozuzRr+w46wvT
|
27
|
+
fV2yTN6QTVxqbMsJJyjosks4ZdQYov2zdvQpt1HsLi+Qmckmg8SPZsd+T8uiiBCf
|
28
|
+
b+1ORSM5eEfBQenPXy83LZcoQz8i6zVB4aAfTGGdhxjoMGUEmSZ6xpkOzmnGa9QK
|
29
|
+
m5x9IDiApM+vCELNwDXXGNFEnQBBK+wAe4Pek8o1V1TTOxL1kGPewVOitX1p3xoN
|
30
|
+
h7iEjga8iM1LbZUfiISZ+WrB
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2020-02-07 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.21'
|
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.21'
|
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,7 +96,8 @@ files:
|
|
96
96
|
homepage: https://github.com/seattlerb/sexp_processor
|
97
97
|
licenses:
|
98
98
|
- MIT
|
99
|
-
metadata:
|
99
|
+
metadata:
|
100
|
+
homepage_uri: https://github.com/seattlerb/sexp_processor
|
100
101
|
post_install_message:
|
101
102
|
rdoc_options:
|
102
103
|
- "--main"
|
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
115
|
- !ruby/object:Gem::Version
|
115
116
|
version: '0'
|
116
117
|
requirements: []
|
117
|
-
rubygems_version: 3.0.
|
118
|
+
rubygems_version: 3.0.3
|
118
119
|
signing_key:
|
119
120
|
specification_version: 4
|
120
121
|
summary: sexp_processor branches from ParseTree bringing all the generic sexp processing
|
metadata.gz.sig
CHANGED
Binary file
|