Class OperatorPrecedence


  • public final class OperatorPrecedence
    extends java.lang.Object
    The OperatorPrecedence class is used to identify the precedence of an operator Token.

    Using pre-defined operator precedence values, the class takes an operators TokenType and returns a number. This can be used to discover which operators take priority when performing mathematical operations.

    Since:
    1.0
    • Constructor Detail

      • OperatorPrecedence

        public OperatorPrecedence()
    • Method Detail

      • getUnaryOperatorPrecedence

        public static int getUnaryOperatorPrecedence​(TokenType type)
        Return the operator precedence for a unary operator.
        Parameters:
        type - The TokenType of the unary operator
        Returns:
        An int representing the operators precedence value
      • getBinaryOperatorPrecedence

        public static int getBinaryOperatorPrecedence​(TokenType type)
        Return the operator precedence for a binary operator.
        Parameters:
        type - The TokenType of the binary operator
        Returns:
        An int representing the operators precedence value