Skip to content

Commit c351d43

Browse files
committed
[Impl] !~~by adding NOT_ACCEPTS method
1 parent 049f5a6 commit c351d43

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/NQP/Actions.nqp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,10 @@ class NQP::Actions is HLL::Actions {
16741674
make QAST::Op.new( :op<callmethod>, :name<ACCEPTS>, :node($/) );
16751675
}
16761676

1677+
method infix:sym<!~~>($/) {
1678+
make QAST::Op.new( :op<callmethod>, :name<NOT_ACCEPTS>, :node($/) );
1679+
}
1680+
16771681
# Takes a multi-part name that we know is in a package and generates
16781682
# QAST to look it up using NQP package semantics.
16791683
sub lexical_package_lookup(@name, $/) {

src/NQP/Grammar.nqp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ grammar NQP::Grammar is HLL::Grammar {
821821
token infix:sym«gt» { <sym> <O(|%relational, :op<isgt_s>)> }
822822
token infix:sym«=:=» { <sym> <O(|%relational, :op<eqaddr>)> }
823823
token infix:sym<~~> { <sym> <O(|%relational, :reducecheck<smartmatch>)> }
824+
token infix:sym<!~~> { <sym> <O(|%relational, :reducecheck<smartmatch>)> }
824825

825826
token infix:sym<&&> { <sym> <O(|%tight_and, :op<if>)> }
826827

src/QRegex/Cursor.nqp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,9 @@ class NQPRegexMethod {
13681368
multi method ACCEPTS(NQPRegexMethod:D $self: $target) {
13691369
NQPMatch.parse($target, :rule(self))
13701370
}
1371+
multi method NOT_ACCEPTS(NQPRegexMethod:D $self: $target) {
1372+
nqp::isfalse(NQPMatch.parse($target, :rule(self)))
1373+
}
13711374
method name() {
13721375
nqp::getcodename($!code)
13731376
}
@@ -1381,5 +1384,8 @@ class NQPRegex is NQPRegexMethod {
13811384
multi method ACCEPTS(NQPRegex:D $self: $target) {
13821385
NQPMatch.parse($target, :rule(self), :c(0))
13831386
}
1387+
multi method NOT_ACCEPTS(NQPRegex:D $self: $target) {
1388+
nqp::isfalse(NQPMatch.parse($target, :rule(self), :c(0)))
1389+
}
13841390
}
13851391
nqp::setinvokespec(NQPRegex, NQPRegexMethod, '$!code', nqp::null);

src/core/NQPMu.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ my class NQPMu {
8888
nqp::istype($topic, self.WHAT)
8989
}
9090

91+
proto method NOT_ACCEPTS($topic) { * }
92+
multi method NOT_ACCEPTS(NQPMu:U $self: $topic) {
93+
nqp::isfalse(nqp::istype($topic, self.WHAT))
94+
}
95+
9196
method isa($type) {
9297
self.HOW.isa(self, $type)
9398
}

0 commit comments

Comments
 (0)