<commit_before>package dotty.tools.dotc

import util.Chars._
import core.Names.Name
import core.StdNames.nme
import core.NameOps._

package object parsing {

  def precedence(operator: Name): Int =
    if (operator eq nme.ERROR) -1
    else {
      val firstCh = operator.firstPart.head
      if (isScalaLetter(firstCh)) 1
      else if (operator.isOpAssignmentName) 0
      else firstCh match {
        case '|' => 2
        case '^' => 3
        case '&' => 4<commit_msg>Give normative references for operator precedence<commit_after>package dotty.tools.dotc

import util.Chars._
import core.Names.Name
import core.StdNames.nme
import core.NameOps._

package object parsing {

  /**
   * Compute the precedence of infix operator `operator` according to the SLS [§ 6.12.3][SLS].
   * We implement [SIP-33][SIP-33] and give type operators the same precedence as term operators.
   *
   * [SLS]: https://www.scala-lang.org/files/archive/spec/2.13/06-expressions.html#infix-operations
   * [SIP-33]: https://docs.scala-lang.org/sips/priority-based-infix-type-precedence.html
   */
  def precedence(operator: Name): Int =
    if (operator eq nme.ERROR) -1
    else {
      val firstCh = operator.firstPart.head
      if (isScalaLetter(firstCh)) 1
      else if (operator.isOpAssignmentName) 0
      else firstCh match {
        case '|' => 2
        case '^' => 3
        case '&' => 4
{'fraction_non_alphanumeric': 0.11794500723589002, 'fraction_numerical': 0.019536903039073805, 'mean_word_length': 2.906779661016949, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6810227', 'n_tokens_mistral': 478, 'n_tokens_neox': 443, 'n_words': 118}