Skip to content

Commit

Permalink
[Impl] !~~by adding NOT_ACCEPTS method
Browse files Browse the repository at this point in the history
  • Loading branch information
陈梓立 authored and 陈梓立 committed Jun 8, 2018
1 parent 049f5a6 commit e9bb509
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/NQP/Actions.nqp
Expand Up @@ -1674,6 +1674,10 @@ class NQP::Actions is HLL::Actions {
make QAST::Op.new( :op<callmethod>, :name<ACCEPTS>, :node($/) );
}

method infix:sym<!~~>($/) {
make QAST::Op.new( :op<callmethod>, :name<NOT_ACCEPTS>, :node($/) );
}

# Takes a multi-part name that we know is in a package and generates
# QAST to look it up using NQP package semantics.
sub lexical_package_lookup(@name, $/) {
Expand Down
1 change: 1 addition & 0 deletions src/NQP/Grammar.nqp
Expand Up @@ -821,6 +821,7 @@ grammar NQP::Grammar is HLL::Grammar {
token infix:sym«gt» { <sym> <O(|%relational, :op<isgt_s>)> }
token infix:sym«=:=» { <sym> <O(|%relational, :op<eqaddr>)> }
token infix:sym<~~> { <sym> <O(|%relational, :reducecheck<smartmatch>)> }
token infix:sym<!~~> { <sym> <O(|%relational, :reducecheck<smartmatch>)> }

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

Expand Down
6 changes: 6 additions & 0 deletions src/QRegex/Cursor.nqp
Expand Up @@ -1368,6 +1368,9 @@ class NQPRegexMethod {
multi method ACCEPTS(NQPRegexMethod:D $self: $target) {
NQPMatch.parse($target, :rule(self))
}
multi method NOT_ACCEPTS(NQPRegexMethod:D $self: $target) {
nqp::isfalse(NQPMatch.parse($target, :rule(self)))
}
method name() {
nqp::getcodename($!code)
}
Expand All @@ -1381,5 +1384,8 @@ class NQPRegex is NQPRegexMethod {
multi method ACCEPTS(NQPRegex:D $self: $target) {
NQPMatch.parse($target, :rule(self), :c(0))
}
multi method NOT_ACCEPTS(NQPRegex:D $self: $target) {
nqp::isfalse(NQPMatch.parse($target, :rule(self), :c(0)))
}
}
nqp::setinvokespec(NQPRegex, NQPRegexMethod, '$!code', nqp::null);
5 changes: 5 additions & 0 deletions src/core/NQPMu.nqp
Expand Up @@ -88,6 +88,11 @@ my class NQPMu {
nqp::istype($topic, self.WHAT)
}

proto method NOT_ACCEPTS($topic) { * }
multi method NOT_ACCEPTS(NQPMu:U $self: $topic) {
nqp::isfalse(nqp::istype($topic, self.WHAT))
}

method isa($type) {
self.HOW.isa(self, $type)
}
Expand Down

0 comments on commit e9bb509

Please sign in to comment.