Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Add bitwise operators
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Jun 24, 2010
1 parent 4ee17c4 commit a915b78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/NQP/Grammar.pm
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,12 @@ token prefix:sym<|> { <sym> <O('%symbolic_unary')> }
token infix:sym<*> { <sym> <O('%multiplicative, :pirop<mul>')> }
token infix:sym</> { <sym> <O('%multiplicative, :pirop<div>')> }
token infix:sym<%> { <sym> <O('%multiplicative, :pirop<mod>')> }
token infix:sym<+&> { <sym> <O('%multiplicative, :pirop<band III>')> }

token infix:sym<+> { <sym> <O('%additive, :pirop<add>')> }
token infix:sym<-> { <sym> <O('%additive, :pirop<sub>')> }
token infix:sym<+|> { <sym> <O('%additive, :pirop<bor III>')> }
token infix:sym<+^> { <sym> <O('%additive, :pirop<bxor III>')> }

token infix:sym<~> { <sym> <O('%concatenation , :pirop<concat>')> }

Expand Down
7 changes: 6 additions & 1 deletion t/nqp/13-op.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# checking basic operands and circumfix:( )

plan(29);
plan(32);

##Additive operators
ok( 1+2 == 3, 'Checking addition 1+2');
Expand Down Expand Up @@ -46,3 +46,8 @@ ok( !(2 > 3) );
ok( ?(2 >= 1) );
ok( !(2 >= 3) );

#Bitwise operators
ok( (1 +| 3) == 3, 'Checking 1 +| 3' );
ok( (3 +& 2) == 2, 'Checking 3 +& 2' );
ok( (3 +^ 3) == 0, 'Checking 3 +^ 3' );

0 comments on commit a915b78

Please sign in to comment.