math.test 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. Mathematical operators
  2. -----
  3. <?php
  4. // unary ops
  5. ~$a;
  6. +$a;
  7. -$a;
  8. // binary ops
  9. $a & $b;
  10. $a | $b;
  11. $a ^ $b;
  12. $a . $b;
  13. $a / $b;
  14. $a - $b;
  15. $a % $b;
  16. $a * $b;
  17. $a + $b;
  18. $a << $b;
  19. $a >> $b;
  20. $a ** $b;
  21. // associativity
  22. $a * $b * $c;
  23. $a * ($b * $c);
  24. // precedence
  25. $a + $b * $c;
  26. ($a + $b) * $c;
  27. // pow is special
  28. $a ** $b ** $c;
  29. ($a ** $b) ** $c;
  30. -----
  31. array(
  32. 0: Stmt_Expression(
  33. expr: Expr_BitwiseNot(
  34. expr: Expr_Variable(
  35. name: a
  36. )
  37. comments: array(
  38. 0: // unary ops
  39. )
  40. )
  41. comments: array(
  42. 0: // unary ops
  43. )
  44. )
  45. 1: Stmt_Expression(
  46. expr: Expr_UnaryPlus(
  47. expr: Expr_Variable(
  48. name: a
  49. )
  50. )
  51. )
  52. 2: Stmt_Expression(
  53. expr: Expr_UnaryMinus(
  54. expr: Expr_Variable(
  55. name: a
  56. )
  57. )
  58. )
  59. 3: Stmt_Expression(
  60. expr: Expr_BinaryOp_BitwiseAnd(
  61. left: Expr_Variable(
  62. name: a
  63. comments: array(
  64. 0: // binary ops
  65. )
  66. )
  67. right: Expr_Variable(
  68. name: b
  69. )
  70. comments: array(
  71. 0: // binary ops
  72. )
  73. )
  74. comments: array(
  75. 0: // binary ops
  76. )
  77. )
  78. 4: Stmt_Expression(
  79. expr: Expr_BinaryOp_BitwiseOr(
  80. left: Expr_Variable(
  81. name: a
  82. )
  83. right: Expr_Variable(
  84. name: b
  85. )
  86. )
  87. )
  88. 5: Stmt_Expression(
  89. expr: Expr_BinaryOp_BitwiseXor(
  90. left: Expr_Variable(
  91. name: a
  92. )
  93. right: Expr_Variable(
  94. name: b
  95. )
  96. )
  97. )
  98. 6: Stmt_Expression(
  99. expr: Expr_BinaryOp_Concat(
  100. left: Expr_Variable(
  101. name: a
  102. )
  103. right: Expr_Variable(
  104. name: b
  105. )
  106. )
  107. )
  108. 7: Stmt_Expression(
  109. expr: Expr_BinaryOp_Div(
  110. left: Expr_Variable(
  111. name: a
  112. )
  113. right: Expr_Variable(
  114. name: b
  115. )
  116. )
  117. )
  118. 8: Stmt_Expression(
  119. expr: Expr_BinaryOp_Minus(
  120. left: Expr_Variable(
  121. name: a
  122. )
  123. right: Expr_Variable(
  124. name: b
  125. )
  126. )
  127. )
  128. 9: Stmt_Expression(
  129. expr: Expr_BinaryOp_Mod(
  130. left: Expr_Variable(
  131. name: a
  132. )
  133. right: Expr_Variable(
  134. name: b
  135. )
  136. )
  137. )
  138. 10: Stmt_Expression(
  139. expr: Expr_BinaryOp_Mul(
  140. left: Expr_Variable(
  141. name: a
  142. )
  143. right: Expr_Variable(
  144. name: b
  145. )
  146. )
  147. )
  148. 11: Stmt_Expression(
  149. expr: Expr_BinaryOp_Plus(
  150. left: Expr_Variable(
  151. name: a
  152. )
  153. right: Expr_Variable(
  154. name: b
  155. )
  156. )
  157. )
  158. 12: Stmt_Expression(
  159. expr: Expr_BinaryOp_ShiftLeft(
  160. left: Expr_Variable(
  161. name: a
  162. )
  163. right: Expr_Variable(
  164. name: b
  165. )
  166. )
  167. )
  168. 13: Stmt_Expression(
  169. expr: Expr_BinaryOp_ShiftRight(
  170. left: Expr_Variable(
  171. name: a
  172. )
  173. right: Expr_Variable(
  174. name: b
  175. )
  176. )
  177. )
  178. 14: Stmt_Expression(
  179. expr: Expr_BinaryOp_Pow(
  180. left: Expr_Variable(
  181. name: a
  182. )
  183. right: Expr_Variable(
  184. name: b
  185. )
  186. )
  187. )
  188. 15: Stmt_Expression(
  189. expr: Expr_BinaryOp_Mul(
  190. left: Expr_BinaryOp_Mul(
  191. left: Expr_Variable(
  192. name: a
  193. comments: array(
  194. 0: // associativity
  195. )
  196. )
  197. right: Expr_Variable(
  198. name: b
  199. )
  200. comments: array(
  201. 0: // associativity
  202. )
  203. )
  204. right: Expr_Variable(
  205. name: c
  206. )
  207. comments: array(
  208. 0: // associativity
  209. )
  210. )
  211. comments: array(
  212. 0: // associativity
  213. )
  214. )
  215. 16: Stmt_Expression(
  216. expr: Expr_BinaryOp_Mul(
  217. left: Expr_Variable(
  218. name: a
  219. )
  220. right: Expr_BinaryOp_Mul(
  221. left: Expr_Variable(
  222. name: b
  223. )
  224. right: Expr_Variable(
  225. name: c
  226. )
  227. )
  228. )
  229. )
  230. 17: Stmt_Expression(
  231. expr: Expr_BinaryOp_Plus(
  232. left: Expr_Variable(
  233. name: a
  234. comments: array(
  235. 0: // precedence
  236. )
  237. )
  238. right: Expr_BinaryOp_Mul(
  239. left: Expr_Variable(
  240. name: b
  241. )
  242. right: Expr_Variable(
  243. name: c
  244. )
  245. )
  246. comments: array(
  247. 0: // precedence
  248. )
  249. )
  250. comments: array(
  251. 0: // precedence
  252. )
  253. )
  254. 18: Stmt_Expression(
  255. expr: Expr_BinaryOp_Mul(
  256. left: Expr_BinaryOp_Plus(
  257. left: Expr_Variable(
  258. name: a
  259. )
  260. right: Expr_Variable(
  261. name: b
  262. )
  263. )
  264. right: Expr_Variable(
  265. name: c
  266. )
  267. )
  268. )
  269. 19: Stmt_Expression(
  270. expr: Expr_BinaryOp_Pow(
  271. left: Expr_Variable(
  272. name: a
  273. comments: array(
  274. 0: // pow is special
  275. )
  276. )
  277. right: Expr_BinaryOp_Pow(
  278. left: Expr_Variable(
  279. name: b
  280. )
  281. right: Expr_Variable(
  282. name: c
  283. )
  284. )
  285. comments: array(
  286. 0: // pow is special
  287. )
  288. )
  289. comments: array(
  290. 0: // pow is special
  291. )
  292. )
  293. 20: Stmt_Expression(
  294. expr: Expr_BinaryOp_Pow(
  295. left: Expr_BinaryOp_Pow(
  296. left: Expr_Variable(
  297. name: a
  298. )
  299. right: Expr_Variable(
  300. name: b
  301. )
  302. )
  303. right: Expr_Variable(
  304. name: c
  305. )
  306. )
  307. )
  308. )