Enum Precedence

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ADDITIVE
      The level of binary + and -.
      AND
      The level of the short-circuiting &&, binding tighter than ||.
      ASSIGNMENT
      The loosest operator level, covering plain assignment and every compound assignment; right-associative.
      BIT_AND
      The level of the single &, the tightest of the three bitwise levels.
      BIT_OR
      The level of the single |, the loosest of the three bitwise levels.
      BIT_XOR
      The level of ^, between bitwise or and bitwise and.
      COMPARISON
      The relational level, covering the four ordering operators and instanceof.
      EQUALITY
      The level of == and !=, binding looser than the ordering comparisons.
      MULTIPLICATIVE
      The level of *, /, and %.
      NONE
      No binding at all; the level reported for a token that is not an operator, which stops the parser from extending an expression.
      OR
      The level of the short-circuiting ||, the loosest binary operator.
      POSTFIX
      The postfix level, covering ++ and -- as well as member access, array indexing, and call parentheses.
      PRIMARY
      The tightest level, above every operator; literals, names, and parenthesized expressions sit here.
      SHIFT
      The level of the three shift operators.
      TERNARY
      The conditional ?: level, reached from the ? token and right-associative like assignment.
      UNARY
      The prefix operator level, covering negation, complement, prefix increment and decrement, and casts.
    • Enum Constant Detail

      • NONE

        public static final Precedence NONE
        No binding at all; the level reported for a token that is not an operator, which stops the parser from extending an expression.
      • ASSIGNMENT

        public static final Precedence ASSIGNMENT
        The loosest operator level, covering plain assignment and every compound assignment; right-associative.
      • TERNARY

        public static final Precedence TERNARY
        The conditional ?: level, reached from the ? token and right-associative like assignment.
      • OR

        public static final Precedence OR
        The level of the short-circuiting ||, the loosest binary operator.
      • AND

        public static final Precedence AND
        The level of the short-circuiting &&, binding tighter than ||.
      • BIT_OR

        public static final Precedence BIT_OR
        The level of the single |, the loosest of the three bitwise levels.
      • BIT_XOR

        public static final Precedence BIT_XOR
        The level of ^, between bitwise or and bitwise and.
      • BIT_AND

        public static final Precedence BIT_AND
        The level of the single &, the tightest of the three bitwise levels.
      • EQUALITY

        public static final Precedence EQUALITY
        The level of == and !=, binding looser than the ordering comparisons.
      • COMPARISON

        public static final Precedence COMPARISON
        The relational level, covering the four ordering operators and instanceof.
      • SHIFT

        public static final Precedence SHIFT
        The level of the three shift operators.
      • ADDITIVE

        public static final Precedence ADDITIVE
        The level of binary + and -.
      • MULTIPLICATIVE

        public static final Precedence MULTIPLICATIVE
        The level of *, /, and %.
      • UNARY

        public static final Precedence UNARY
        The prefix operator level, covering negation, complement, prefix increment and decrement, and casts.
      • POSTFIX

        public static final Precedence POSTFIX
        The postfix level, covering ++ and -- as well as member access, array indexing, and call parentheses.
      • PRIMARY

        public static final Precedence PRIMARY
        The tightest level, above every operator; literals, names, and parenthesized expressions sit here.
    • Method Detail

      • values

        public static Precedence[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Precedence c : Precedence.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Precedence valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getLevel

        public int getLevel()
        Returns:
        the level
      • of

        public static Precedence of​(TokenType type)
        Maps an operator token to the precedence at which it binds.
        Parameters:
        type - the token to classify
        Returns:
        the matching precedence, or NONE when the token is not an operator
      • isRightAssociative

        public boolean isRightAssociative()
        Returns:
        true for assignment and ternary, the two right-associative levels