Package parser
Class UnaryPostOperator
java.lang.Object
parser.Operator
parser.UnaryPostOperator
- All Implemented Interfaces:
Validatable
Models a post-operand Operator
object e.g the !, inverse, square, cube operators
-
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 UnaryPostOperator 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
ConstructorsConstructorDescriptionUnaryPostOperator
(String name, int index, ArrayList<String> scan) Creates a new UnaryPostOperator object -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assignCompoundTokens
(ArrayList<String> scan) Carefully interpretes the correct arrangement of a loose math statement for objects of this class and applies the correct one to the MathExpression object.boolean
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 UnaryPostOperator object. -
index
private int indexThe index of this operator in the scanned Function that it belongs to.
-
-
Constructor Details
-
UnaryPostOperator
Creates a new UnaryPostOperator object- Parameters:
name
- The name that identifies this UnaryPostOperator objectscan
- The List object that contains the tokens
-
-
Method Details
-
getPrecedence
- Returns:
- the Precedence of this Operator object.
-
validate
- Specified by:
validate
in interfaceValidatable
- Parameters:
scan
- the scanner-list object that this UnaryPostOperator 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 the grammatical usage of this token with respect to its 2 immediate neighboring tokens to the left and to the right is correct.
-
assignCompoundTokens
Carefully interpretes the correct arrangement of a loose math statement for objects of this class and applies the correct one to the MathExpression object. Examples: ²,³,-¹,!- Parameters:
scan
- The ArrayList object that is the scanner of the MathExpression object and so contains this UnaryPostOperator object
-