1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-04 18:28:25 +01:00
PHP-Parser/test/code/parser/expr/math.test

256 lines
4.8 KiB
Plaintext
Raw Normal View History

2011-11-27 11:20:35 +01:00
Mathematical operators
-----
<?php
// unary ops
~$a;
+$a;
-$a;
// binary ops
$a & $b;
$a | $b;
$a ^ $b;
$a . $b;
$a / $b;
$a - $b;
$a % $b;
$a * $b;
$a + $b;
$a << $b;
$a >> $b;
2014-03-26 19:18:16 +01:00
$a ** $b;
2011-11-27 11:20:35 +01:00
// associativity
$a * $b * $c;
$a * ($b * $c);
// precedence
$a + $b * $c;
($a + $b) * $c;
2014-03-26 19:18:16 +01:00
// pow is special
$a ** $b ** $c;
($a ** $b) ** $c;
2011-11-27 11:20:35 +01:00
-----
array(
0: Expr_BitwiseNot(
expr: Expr_Variable(
name: a
)
comments: array(
0: // unary ops
)
2011-11-27 11:20:35 +01:00
)
1: Expr_UnaryPlus(
expr: Expr_Variable(
name: a
)
)
2: Expr_UnaryMinus(
expr: Expr_Variable(
name: a
)
)
3: Expr_BinaryOp_BitwiseAnd(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
comments: array(
0: // binary ops
)
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
name: b
)
comments: array(
0: // binary ops
)
2011-11-27 11:20:35 +01:00
)
4: Expr_BinaryOp_BitwiseOr(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
5: Expr_BinaryOp_BitwiseXor(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
6: Expr_BinaryOp_Concat(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
7: Expr_BinaryOp_Div(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
8: Expr_BinaryOp_Minus(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
9: Expr_BinaryOp_Mod(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
10: Expr_BinaryOp_Mul(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
11: Expr_BinaryOp_Plus(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
12: Expr_BinaryOp_ShiftLeft(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
13: Expr_BinaryOp_ShiftRight(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
2014-03-26 19:18:16 +01:00
14: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
15: Expr_BinaryOp_Mul(
left: Expr_BinaryOp_Mul(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
comments: array(
0: // associativity
)
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
name: b
)
comments: array(
0: // associativity
)
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
name: c
)
comments: array(
0: // associativity
)
2011-11-27 11:20:35 +01:00
)
2014-03-26 19:18:16 +01:00
16: Expr_BinaryOp_Mul(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_BinaryOp_Mul(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
)
2014-03-26 19:18:16 +01:00
17: Expr_BinaryOp_Plus(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
comments: array(
0: // precedence
)
2011-11-27 11:20:35 +01:00
)
right: Expr_BinaryOp_Mul(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
comments: array(
0: // precedence
)
2011-11-27 11:20:35 +01:00
)
2014-03-26 19:18:16 +01:00
18: Expr_BinaryOp_Mul(
left: Expr_BinaryOp_Plus(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
right: Expr_Variable(
name: c
)
)
2014-03-26 19:18:16 +01:00
19: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: a
comments: array(
0: // pow is special
)
2014-03-26 19:18:16 +01:00
)
right: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
comments: array(
0: // pow is special
)
2014-03-26 19:18:16 +01:00
)
20: Expr_BinaryOp_Pow(
left: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
right: Expr_Variable(
name: c
)
)
2011-11-27 11:20:35 +01:00
)