diff --git a/src/core.c/OperatorProperties.pm6 b/src/core.c/OperatorProperties.pm6 new file mode 100644 index 00000000000..fc7e3114487 --- /dev/null +++ b/src/core.c/OperatorProperties.pm6 @@ -0,0 +1,129 @@ +class OperatorProperties { + has str $.precedence = ""; + has str $.associative = ""; + has str $.thunky = ""; + has int $.iffy; + + # shorten signatures and invocations + my constant OP = OperatorProperties; + + multi method WHICH(OP:D: --> ValueObjAt) { + my $parts := nqp::list_s('OperatorProperties'); + + nqp::push_s($parts,nqp::concat('precedence=',$!precedence)) + if $!precedence; + nqp::push_s($parts,nqp::concat('associative=',$!associative)) + if $!associative; + nqp::push_s($parts,nqp::concat('thunky=',$!thunky)) + if $!thunky; + nqp::push_s($parts,nqp::concat('iffy=',$!iffy)) + if $!iffy; + + nqp::box_s(nqp::join('|',$parts),ValueObjAt) + } + + method equiv(OP:D:) { + self.new: :$!precedence, + :associative(''), :$!thunky, :$!iffy + } + method looser(OP:D:) { + self.new: precedence => $!precedence.subst('=','@='), + :associative(''), :$!thunky, :$!iffy + } + method tighter(OP:D:) { + self.new: precedence => $!precedence.subst('=',':=') + :associative(''), :$!thunky, :$!iffy + } + + method prec() { + Map.new: + (prec => $!precedence if $!precedence), + (assoc => $!associative if $!associative), + (thunky => $!thunky if $!thunky), + (iffy => $!iffy) + } + + method methodcall(OP:U:) { OP.new: + :precedence + } + method autoincrement(OP:U:) { OP.new: + :precedence + } + method exponentiation(OP:U:) { OP.new: + :precedence, :associative + } + method symbolic-unary(OP:U:) { OP.new: + :precedence + } + method multiplicative(OP:U:) { OP.new: + :precedence, :associative + } + method iffytive(OP:U:) { OP.new: + :precedence, :associative, :iffy + } + method additive(OP:U:) { OP.new: + :precedence, :associative + } + method replication(OP:U:) { OP.new: + :precedence, :associative + } + method replication-xx(OP:U:) { OP.new: + :precedence, :associative, :thunky + } + method concatenation(OP:U:) { OP.new: + :precedence, :associative + } + method junctive-and(OP:U:) { OP.new: + :precedence, :associative + } + method junctive-or(OP:U:) { OP.new: + :precedence, :associative + } + method structural(OP:U:) { OP.new: + :precedence, :associative + } + method chaining(OP:U:) { OP.new: + :precedence, :associative, :iffy + } + method tight-and(OP:U:) { OP.new: + :precedence, :associative, :thunky<.t> + } + method tight-or(OP:U:) { OP.new: + :precedence, :associative, :thunky<.t> + } + method tight-or-xor(OP:U:) { OP.new: + :precedence, :associative, :thunky<..t> + } + method tight-or-minmax(OP:U:) { OP.new: + :precedence, :associative + } + method item-assignment(OP:U:) { OP.new: + :precedence, :associative + } + method loose-unary(OP:U:) { OP.new: + :precedence + } + method comma(OP:U:) { OP.new: + :precedence, :associative + } + method list-infix(OP:U:) { OP.new: + :precedence, :associative + } + method list-prefix(OP:U:) { OP.new: + :precedence + } + method loose-and(OP:U:) { OP.new: + :precedence, :associative, :thunky<.t> + } + method loose-andthen(OP:U:) { OP.new: + :precedence, :associative, :thunky<.b> + } + method loose-or(OP:U:) { OP.new: + :precedence, :associative, :thunky<.t> + } + method loose-orelse(OP:U:) { OP.new: + :precedence, :associative, :thunky<.b> + } +} + +# vim: expandtab shiftwidth=4