1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-11 08:59:46 +01:00
PHP-Parser/test/code/parser/expr/math.test

313 lines
6.6 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(
2017-01-19 22:25:22 +01:00
0: Stmt_Expression(
expr: Expr_BitwiseNot(
expr: Expr_Variable(
name: a
)
comments: array(
0: // unary ops
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // unary ops
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
1: Stmt_Expression(
expr: Expr_UnaryPlus(
expr: Expr_Variable(
name: a
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
2: Stmt_Expression(
expr: Expr_UnaryMinus(
expr: Expr_Variable(
name: a
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
3: Stmt_Expression(
expr: Expr_BinaryOp_BitwiseAnd(
left: Expr_Variable(
name: a
comments: array(
0: // binary ops
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // binary ops
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // binary ops
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
4: Stmt_Expression(
expr: Expr_BinaryOp_BitwiseOr(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
5: Stmt_Expression(
expr: Expr_BinaryOp_BitwiseXor(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
6: Stmt_Expression(
expr: Expr_BinaryOp_Concat(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
7: Stmt_Expression(
expr: Expr_BinaryOp_Div(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
8: Stmt_Expression(
expr: Expr_BinaryOp_Minus(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
9: Stmt_Expression(
expr: Expr_BinaryOp_Mod(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
10: Stmt_Expression(
expr: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
11: Stmt_Expression(
expr: Expr_BinaryOp_Plus(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
12: Stmt_Expression(
expr: Expr_BinaryOp_ShiftLeft(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
13: Stmt_Expression(
expr: Expr_BinaryOp_ShiftRight(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2014-03-26 19:18:16 +01:00
)
)
2017-01-19 22:25:22 +01:00
14: Stmt_Expression(
expr: Expr_BinaryOp_Pow(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
2017-01-19 22:25:22 +01:00
)
right: Expr_Variable(
name: b
)
)
)
15: Stmt_Expression(
expr: Expr_BinaryOp_Mul(
left: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: a
comments: array(
0: // associativity
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // associativity
)
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: c
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // associativity
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // associativity
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
16: Stmt_Expression(
expr: Expr_BinaryOp_Mul(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: a
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
right: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
2011-11-27 11:20:35 +01:00
)
)
)
2017-01-19 22:25:22 +01:00
17: Stmt_Expression(
expr: Expr_BinaryOp_Plus(
left: Expr_Variable(
name: a
comments: array(
0: // precedence
)
)
right: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
comments: array(
0: // precedence
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
comments: array(
0: // precedence
)
)
18: Stmt_Expression(
expr: Expr_BinaryOp_Mul(
left: Expr_BinaryOp_Plus(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
name: c
)
)
)
2017-01-19 22:25:22 +01:00
19: Stmt_Expression(
expr: Expr_BinaryOp_Pow(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
2017-01-19 22:25:22 +01:00
comments: array(
0: // pow is special
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
right: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // pow is special
)
2014-03-26 19:18:16 +01:00
)
comments: array(
0: // pow is special
)
2014-03-26 19:18:16 +01:00
)
2017-01-19 22:25:22 +01:00
20: Stmt_Expression(
expr: Expr_BinaryOp_Pow(
left: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2014-03-26 19:18:16 +01:00
)
right: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: c
2014-03-26 19:18:16 +01:00
)
)
)
2011-11-27 11:20:35 +01:00
)