Package compilation.analysis.syntax
Class OperatorPrecedence
- java.lang.Object
-
- compilation.analysis.syntax.OperatorPrecedence
-
public final class OperatorPrecedence extends java.lang.ObjectThe 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 Summary
Constructors Constructor Description OperatorPrecedence()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intgetBinaryOperatorPrecedence(TokenType type)Return the operator precedence for a binary operator.static intgetUnaryOperatorPrecedence(TokenType type)Return the operator precedence for a unary operator.
-
-
-
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
-
-