public class Operator extends Token implements Comparable<Operator>
Operator
class represents the operators, functions, variables, and constants in the expression.Modifier and Type | Class and Description |
---|---|
static class |
Operator.Properties
The
Properties class represents the properties of an operator.It contains information about the number of parameters supported, the precedence, and the associativity. It also helps determine if an operator is a function or not and provides the function implementation. |
Constructor and Description |
---|
Operator(String value)
Parameterized constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Operator other)
Method to compare this operator to another operator on the basis of precedence.
|
Operand |
evaluate(Operand... operands)
Method to evaluate this operator, function, variable, or constant.
It takes a variable number of operands as parameter depending on the number of operands required for this operator. |
Operator.Properties.Associativity |
getAssociativity()
Get associativity information of this operator.
|
int |
getOperandCount()
Get count of operands supported by this operator.
|
boolean |
isFunction()
Determine if this operator is a function or not.
|
boolean |
isVariableOrConstant()
Determine if this operator is a variable or constant, or not.
|
public Operator(String value)
value
- The operator, function, variable, or constant as a stringpublic int getOperandCount()
public Operator.Properties.Associativity getAssociativity()
public boolean isFunction()
public boolean isVariableOrConstant()
public Operand evaluate(Operand... operands)
operands
- Variable number of operands required by this operatorpublic int compareTo(Operator other)
compareTo
in interface Comparable<Operator>
Copyright © 2019 Pratanu Mandal. All rights reserved.