1. # We attach precedence information to all operators here. This is instead of
  2. # putting the traits directly on the op bodies, since some of the things that
  3. # the traits are implemented using aren't defined that early.
  4. BEGIN {
  5. my Mu $methodcall := nqp::hash('prec', 'y=');
  6. my Mu $autoincrement := nqp::hash('prec', 'x=');
  7. my Mu $exponentiation := nqp::hash('prec', 'w=', 'assoc', 'right');
  8. my Mu $symbolic_unary := nqp::hash('prec', 'v=');
  9. my Mu $multiplicative := nqp::hash('prec', 'u=', 'assoc', 'left');
  10. my Mu $iffy := nqp::hash('prec', 'u=', 'assoc', 'left', 'iffy', 1);
  11. my Mu $additive := nqp::hash('prec', 't=', 'assoc', 'left');
  12. my Mu $replication := nqp::hash('prec', 's=', 'assoc', 'left');
  13. my Mu $replication_xx := nqp::hash('prec', 's=', 'assoc', 'left', 'thunky', 't.');
  14. my Mu $concatenation := nqp::hash('prec', 'r=', 'assoc', 'list');
  15. my Mu $junctive_and := nqp::hash('prec', 'q=', 'assoc', 'list');
  16. my Mu $junctive_or := nqp::hash('prec', 'p=', 'assoc', 'list');
  17. my Mu $structural := nqp::hash('prec', 'n=', 'assoc', 'non');
  18. my Mu $chaining := nqp::hash('prec', 'm=', 'assoc', 'chain', 'iffy', 1, 'pasttype', 'chain');
  19. my Mu $tight_and := nqp::hash('prec', 'l=', 'assoc', 'list', 'thunky', '.t');
  20. my Mu $tight_or := nqp::hash('prec', 'k=', 'assoc', 'list', 'thunky', '.t');
  21. my Mu $tight_or_xor := nqp::hash('prec', 'k=', 'assoc', 'list', 'thunky', '..t');
  22. my Mu $tight_or_minmax := nqp::hash('prec', 'k=', 'assoc', 'list');
  23. my Mu $item_assignment := nqp::hash('prec', 'i=', 'assoc', 'right');
  24. my Mu $loose_unary := nqp::hash('prec', 'h=');
  25. my Mu $comma := nqp::hash('prec', 'g=', 'assoc', 'list');
  26. my Mu $list_infix := nqp::hash('prec', 'f=', 'assoc', 'list');
  27. my Mu $list_prefix := nqp::hash('prec', 'e=');
  28. my Mu $loose_and := nqp::hash('prec', 'd=', 'assoc', 'list', 'thunky', '.t');
  29. my Mu $loose_andthen := nqp::hash('prec', 'd=', 'assoc', 'list', 'thunky', '.b');
  30. my Mu $loose_or := nqp::hash('prec', 'c=', 'assoc', 'list', 'thunky', '.t');
  31. my Mu $loose_orelse := nqp::hash('prec', 'c=', 'assoc', 'list', 'thunky', '.b');
  32. trait_mod:<is>(&postfix:<i>, :prec($methodcall));
  33. trait_mod:<is>(&postcircumfix:<[ ]>, :prec($methodcall));
  34. trait_mod:<is>(&postcircumfix:<[ ]>, :nodal);
  35. trait_mod:<is>(&postcircumfix:<{ }>, :prec($methodcall));
  36. trait_mod:<is>(&postcircumfix:<{ }>, :nodal);
  37. trait_mod:<is>(&prefix:<++>, :prec($autoincrement));
  38. trait_mod:<is>(&prefix:<-->, :prec($autoincrement));
  39. trait_mod:<is>(&postfix:<++>, :prec($autoincrement));
  40. trait_mod:<is>(&postfix:<-->, :prec($autoincrement));
  41. trait_mod:<is>(&infix:<**>, :prec($exponentiation));
  42. trait_mod:<is>(&prefix:<+>, :prec($symbolic_unary));
  43. trait_mod:<is>(&prefix:<~>, :prec($symbolic_unary));
  44. trait_mod:<is>(&prefix:<->, :prec($symbolic_unary));
  45. trait_mod:<is>(&prefix:<?>, :prec($symbolic_unary));
  46. trait_mod:<is>(&prefix:<!>, :prec($symbolic_unary));
  47. trait_mod:<is>(&prefix:<|>, :prec($symbolic_unary));
  48. trait_mod:<is>(&prefix:<+^>, :prec($symbolic_unary));
  49. trait_mod:<is>(&prefix:<~^>, :prec($symbolic_unary));
  50. trait_mod:<is>(&prefix:<?^>, :prec($symbolic_unary));
  51. trait_mod:<is>(&prefix:<^>, :prec($symbolic_unary));
  52. trait_mod:<is>(&infix:<*>, :prec($multiplicative));
  53. trait_mod:<is>(&infix:</>, :prec($multiplicative));
  54. trait_mod:<is>(&infix:<div>, :prec($multiplicative));
  55. trait_mod:<is>(&infix:<gcd>, :prec($multiplicative));
  56. trait_mod:<is>(&infix:<lcm>, :prec($multiplicative));
  57. trait_mod:<is>(&infix:<%>, :prec($multiplicative));
  58. trait_mod:<is>(&infix:<mod>, :prec($multiplicative));
  59. trait_mod:<is>(&infix:<+&>, :prec($multiplicative));
  60. trait_mod:<is>(&infix:<~&>, :prec($multiplicative));
  61. trait_mod:<is>(&infix:<?&>, :prec($multiplicative));
  62. trait_mod:<is>(&infix:<%%>, :prec($iffy));
  63. trait_mod:<is>(&infix:<+>, :prec($additive));
  64. trait_mod:<is>(&infix:<->, :prec($additive));
  65. trait_mod:<is>(&infix:<+|>, :prec($additive));
  66. trait_mod:<is>(&infix:<+^>, :prec($additive));
  67. trait_mod:<is>(&infix:<~|>, :prec($additive));
  68. trait_mod:<is>(&infix:<~^>, :prec($additive));
  69. trait_mod:<is>(&infix:<?|>, :prec($additive));
  70. trait_mod:<is>(&infix:<?^>, :prec($additive));
  71. trait_mod:<is>(&infix:<x>, :prec($replication));
  72. trait_mod:<is>(&infix:<xx>, :prec($replication_xx));
  73. trait_mod:<is>(&infix:<~>, :prec($concatenation));
  74. trait_mod:<is>(&infix:<&>, :prec($junctive_and));
  75. trait_mod:<is>(&infix:<(&)>, :prec($junctive_and));
  76. # U+2229 INTERSECTION
  77. trait_mod:<is>(&infix:<∩>, :prec($junctive_and));
  78. trait_mod:<is>(&infix:<(.)>, :prec($junctive_and));
  79. # U+228D MULTISET MULTIPLICATION
  80. trait_mod:<is>(&infix:<⊍>, :prec($junctive_and));
  81. trait_mod:<is>(&infix:<|>, :prec($junctive_or));
  82. trait_mod:<is>(&infix:<^>, :prec($junctive_or));
  83. trait_mod:<is>(&infix:<(+)>, :prec($junctive_or));
  84. # U+228E MULTISET UNION
  85. trait_mod:<is>(&infix:<⊎>, :prec($junctive_or));
  86. trait_mod:<is>(&infix:<(|)>, :prec($junctive_or));
  87. # U+222A UNION
  88. trait_mod:<is>(&infix:<∪>, :prec($junctive_or));
  89. trait_mod:<is>(&infix:<(-)>, :prec($junctive_or));
  90. # U+2216 SET MINUS
  91. trait_mod:<is>(&infix:<∖>, :prec($junctive_or));
  92. trait_mod:<is>(&infix:<(^)>, :prec($junctive_or));
  93. # U+2296 CIRCLED MINUS
  94. trait_mod:<is>(&infix:<⊖>, :prec($junctive_or));
  95. trait_mod:<is>(&infix:<==>, :prec($chaining));
  96. trait_mod:<is>(&infix:<!=>, :prec($chaining));
  97. trait_mod:<is>(&infix:<eq>, :prec($chaining));
  98. trait_mod:<is>(&infix:<ne>, :prec($chaining));
  99. trait_mod:<is>(&infix:<le>, :prec($chaining));
  100. trait_mod:<is>(&infix:<ge>, :prec($chaining));
  101. trait_mod:<is>(&infix:<lt>, :prec($chaining));
  102. trait_mod:<is>(&infix:<gt>, :prec($chaining));
  103. trait_mod:<is>(&infix:<=:=>, :prec($chaining));
  104. trait_mod:<is>(&infix:<===>, :prec($chaining));
  105. trait_mod:<is>(&infix:<eqv>, :prec($chaining));
  106. trait_mod:<is>(&infix:<before>, :prec($chaining));
  107. trait_mod:<is>(&infix:<after>, :prec($chaining));
  108. trait_mod:<is>(&infix:<~~>, :prec($chaining));
  109. trait_mod:<is>(&infix:<(elem)>, :prec($chaining));
  110. # U+2208 ELEMENT OF
  111. trait_mod:<is>(&infix:<∈>, :prec($chaining));
  112. # U+2209 NOT AN ELEMENT OF
  113. trait_mod:<is>(&infix:<∉>, :prec($chaining));
  114. trait_mod:<is>(&infix:<(cont)>, :prec($chaining));
  115. # U+220B CONTAINS AS MEMBER
  116. trait_mod:<is>(&infix:<∋>, :prec($chaining));
  117. # U+220C DOES NOT CONTAIN AS MEMBER
  118. trait_mod:<is>(&infix:<∌>, :prec($chaining));
  119. trait_mod:<is>(&infix:<<(<)>>, :prec($chaining));
  120. # U+2282 SUBSET OF
  121. trait_mod:<is>(&infix:<⊂>, :prec($chaining));
  122. # U+2284 NOT A SUBSET OF
  123. trait_mod:<is>(&infix:<⊄>, :prec($chaining));
  124. trait_mod:<is>(&infix:<<(>)>>, :prec($chaining));
  125. # U+2283 SUPERSET OF
  126. trait_mod:<is>(&infix:<⊃>, :prec($chaining));
  127. # U+2285 NOT A SUPERSET OF
  128. trait_mod:<is>(&infix:<⊅>, :prec($chaining));
  129. trait_mod:<is>(&infix:<<(<=)>>, :prec($chaining));
  130. # U+2286 SUBSET OF OR EQUAL TO
  131. trait_mod:<is>(&infix:<⊆>, :prec($chaining));
  132. # U+2288 NEITHER A SUBSET OF NOR EQUAL TO
  133. trait_mod:<is>(&infix:<⊈>, :prec($chaining));
  134. trait_mod:<is>(&infix:<<(>=)>>, :prec($chaining));
  135. # U+2287 SUPERSET OF OR EQUAL TO
  136. trait_mod:<is>(&infix:<⊇>, :prec($chaining));
  137. # U+2289 NEITHER A SUPERSET OF NOR EQUAL TO
  138. trait_mod:<is>(&infix:<⊉>, :prec($chaining));
  139. trait_mod:<is>(&infix:<<(<+)>>, :prec($chaining));
  140. # U+227C PRECEDES OR EQUAL TO
  141. trait_mod:<is>(&infix:<≼>, :prec($chaining));
  142. trait_mod:<is>(&infix:<<(>+)>>, :prec($chaining));
  143. # U+227D SUCCEEDS OR EQUAL TO
  144. trait_mod:<is>(&infix:<≽>, :prec($chaining));
  145. trait_mod:<is>(&infix:<..>, :prec($structural));
  146. trait_mod:<is>(&infix:<^..>, :prec($structural));
  147. trait_mod:<is>(&infix:<..^>, :prec($structural));
  148. trait_mod:<is>(&infix:<^..^>, :prec($structural));
  149. trait_mod:<is>(&infix:<leg>, :prec($structural));
  150. trait_mod:<is>(&infix:<cmp>, :prec($structural));
  151. trait_mod:<is>(&infix:<unicmp>, :prec($structural));
  152. trait_mod:<is>(&infix:<coll>, :prec($structural));
  153. trait_mod:<is>(&infix:<but>, :prec($structural));
  154. trait_mod:<is>(&infix:<does>, :prec($structural));
  155. trait_mod:<is>(&infix:<&&>, :prec($tight_and));
  156. trait_mod:<is>(&infix:<||>, :prec($tight_or));
  157. trait_mod:<is>(&infix:<^^>, :prec($tight_or_xor));
  158. trait_mod:<is>(&infix:<//>, :prec($tight_or));
  159. trait_mod:<is>(&infix:<min>, :prec($tight_or_minmax));
  160. trait_mod:<is>(&infix:<max>, :prec($tight_or_minmax));
  161. #trait_mod:<is>(&infix:<ff>, :prec($conditional_ff));
  162. #trait_mod:<is>(&infix:<fff>, :prec($conditional_ff));
  163. trait_mod:<is>(&infix:<< => >>, :prec($item_assignment));
  164. trait_mod:<is>(&prefix:<so>, :prec($loose_unary));
  165. trait_mod:<is>(&prefix:<not>, :prec($loose_unary));
  166. trait_mod:<is>(&infix:<,>, :prec($comma));
  167. trait_mod:<is>(&infix:<Z>, :prec($list_infix));
  168. trait_mod:<is>(&infix:<X>, :prec($list_infix));
  169. trait_mod:<is>(&infix:<...>, :prec($list_infix));
  170. trait_mod:<is>(&infix:<minmax>, :prec($list_infix));
  171. trait_mod:<is>(&infix:<=>, :prec($list_prefix));
  172. #trait_mod:<is>(&infix:<:=>, :prec($list_prefix));
  173. #trait_mod:<is>(&infix:<::=>, :prec($list_prefix));
  174. trait_mod:<is>(&infix:<and>, :prec($loose_and));
  175. trait_mod:<is>(&infix:<andthen>, :prec($loose_andthen));
  176. trait_mod:<is>(&infix:<notandthen>, :prec($loose_andthen));
  177. trait_mod:<is>(&infix:<or>, :prec($loose_orelse));
  178. trait_mod:<is>(&infix:<xor>, :prec($loose_orelse));
  179. trait_mod:<is>(&infix:<orelse>, :prec($loose_orelse));
  180. }