From: Josh Turmel Date: Wed, 27 Jul 2011 07:10:01 +0000 (-0500) Subject: Add bitwise operators to core X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=c2c01dedf864fbd0a3811ba76ad933b6cb0290c4;p=web%2Fkonrad%2Ftwig.git Add bitwise operators to core * Added bitwise operators (and, xor, or) to core --- diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 2c9bdb6..bf3cd12 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -129,6 +129,9 @@ class Twig_Extension_Core extends Twig_Extension '+' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Pos'), ), array( + 'b-and' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-xor' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-or' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'or' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'and' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), diff --git a/lib/Twig/Node/Expression/Binary/BitwiseAnd.php b/lib/Twig/Node/Expression/Binary/BitwiseAnd.php new file mode 100644 index 0000000..9a46d84 --- /dev/null +++ b/lib/Twig/Node/Expression/Binary/BitwiseAnd.php @@ -0,0 +1,18 @@ +raw('&'); + } +} diff --git a/lib/Twig/Node/Expression/Binary/BitwiseOr.php b/lib/Twig/Node/Expression/Binary/BitwiseOr.php new file mode 100644 index 0000000..058a20b --- /dev/null +++ b/lib/Twig/Node/Expression/Binary/BitwiseOr.php @@ -0,0 +1,18 @@ +raw('|'); + } +} diff --git a/lib/Twig/Node/Expression/Binary/BitwiseXor.php b/lib/Twig/Node/Expression/Binary/BitwiseXor.php new file mode 100644 index 0000000..f4da73d --- /dev/null +++ b/lib/Twig/Node/Expression/Binary/BitwiseXor.php @@ -0,0 +1,18 @@ +raw('^'); + } +}