Package parser
Class BinaryOperator
java.lang.Object
parser.Operator
parser.BinaryOperator
- All Implemented Interfaces:
Validatable
- Direct Known Subclasses:
AdditionOperator
,CombinationOperator
,DivisionOperator
,MultiplicationOperator
,PermutationOperator
,PowerOperator
,RemainderOperator
,SubtractionOperator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
The index of this operator in the scanned Function that it belongs to.private final Precedence
The precedence of this BinaryOperator object.Fields inherited from class parser.Operator
AND, ASSIGN, AT, CLOSE_CIRC_BRAC, CLOSE_SQUARE_BRAC, COLON, COMBINATION, COMMA, CONST, CUBE, CUBE_ROOT, DIVIDE, EN_DASH, EQUALS, EXIT, FACTORIAL, GREATER_OR_EQUALS, GREATER_THAN, INVERSE, LESS_OR_EQUALS, LESS_THAN, MINUS, MULTIPLY, name, OPEN_CIRC_BRAC, OPEN_SQUARE_BRAC, operators, OR, PERMUTATION, PLUS, POWER, REMAINDER, ROOT, SEMI_COLON, SPACE, SQUARE, STORE
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class parser.Operator
getName, getPrecedence, isAssignmentOperator, isAtOperator, isBinaryOperator, isBracket, isClosingBrace, isClosingBracket, isColon, isComma, isConstantStoreCommand, isCube, isCubeRoot, isEqualsOperator, isExitCommand, isFactorial, isInverse, isLogicOperator, isMulOrDiv, isMulOrDivOrRemOrPermOrCombOrPow, isOpeningBrace, isOpeningBracket, isOperatorString, isPermOrComb, isPlusOrMinus, isPower, isRemainder, isSemiColon, isSquare, isSquareRoot, isStoreCommand, isUnaryPostOperator, isUnaryPreOperator, setName, validateAll
-
Field Details
-
precedence
The precedence of this BinaryOperator object. -
index
private int indexThe index of this operator in the scanned Function that it belongs to.
-
-
Constructor Details
-
BinaryOperator
- Parameters:
name
- The bame of the operatorindex
- The index of the operatorscan
- The scanner output
-
-
Method Details
-
getPrecedence
- Returns:
- the precedence of this operator
-
setIndex
- Parameters:
index
- sets the index of this operator in the scanned Function that it belongs to.scan
- The Function object that this object exists in.
-
getIndex
public int getIndex()- Returns:
- the index of this operator in the scanned Function that it belongs to.
-
validate
- Specified by:
validate
in interfaceValidatable
- Parameters:
scan
- the Function object that this BinaryOperator object exists in. validates the grammatical usage of this operator (by leaving the correctFunction attribute of the function object un-modified) if the usage of this operator in its immediate environment i.e to its left and right is correct.- Returns:
- true if valid
-