Package parser
Class Operator
java.lang.Object
parser.Operator
- Direct Known Subclasses:
BinaryOperator,Bracket,ListReturningStatsOperator,LogicOperator,LogOrAntiLogToAnyBase,MOperator,NumberReturningStatsOperator,UnaryPostOperator,UnaryPreOperator
public class Operator
extends java.lang.Object
- Author:
- GBENRO
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringANDstatic java.lang.StringASSIGNstatic java.lang.StringATstatic java.lang.StringCLOSE_CIRC_BRACstatic java.lang.StringCLOSE_SQUARE_BRACstatic java.lang.StringCOLONstatic java.lang.StringCOMBINATIONstatic java.lang.StringCOMMAstatic java.lang.StringCONSTstatic java.lang.StringCUBEstatic java.lang.StringCUBE_ROOTstatic java.lang.StringDIVIDEstatic java.lang.StringEN_DASHstatic java.lang.StringEQUALSstatic java.lang.StringEXITstatic java.lang.StringFACTORIALstatic java.lang.StringGREATER_OR_EQUALSstatic java.lang.StringGREATER_THANstatic java.lang.StringINVERSEstatic java.lang.StringLESS_OR_EQUALSstatic java.lang.StringLESS_THANstatic java.lang.StringMINUSstatic java.lang.StringMULTIPLYprotected java.lang.StringnameThe name of the operator objectstatic java.lang.StringOPEN_CIRC_BRACstatic java.lang.StringOPEN_SQUARE_BRACstatic java.lang.String[]operatorsThe instruction set of the parser of this software.static java.lang.StringORstatic java.lang.StringPERMUTATIONstatic java.lang.StringPLUSstatic java.lang.StringPOWERstatic java.lang.StringREMAINDERstatic java.lang.StringROOTstatic java.lang.StringSEMI_COLONstatic java.lang.StringSPACEstatic java.lang.StringSQUAREstatic java.lang.StringSTORE -
Constructor Summary
Constructors Constructor Description Operator(java.lang.String name) -
Method Summary
Modifier and Type Method Description java.lang.StringgetName()static PrecedencegetPrecedence(java.lang.String name)The precedence of the operatorsstatic booleanisAssignmentOperator(java.lang.String op)static booleanisAtOperator(java.lang.String op)static booleanisBinaryOperator(java.lang.String op)static booleanisBracket(java.lang.String op)static booleanisClosingBrace(java.lang.String op)static booleanisClosingBracket(java.lang.String op)static booleanisColon(java.lang.String op)static booleanisComma(java.lang.String op)static booleanisConstantStoreCommand(java.lang.String op)static booleanisCube(java.lang.String op)static booleanisCubeRoot(java.lang.String op)static booleanisEqualsOperator(java.lang.String op)static booleanisExitCommand(java.lang.String op)static booleanisFactorial(java.lang.String op)static booleanisInverse(java.lang.String op)static booleanisLogicOperator(java.lang.String op)static booleanisMulOrDiv(java.lang.String op)static booleanisMulOrDivOrRemOrPermOrCombOrPow(java.lang.String op)static booleanisOpeningBrace(java.lang.String op)static booleanisOpeningBracket(java.lang.String op)static booleanisOperatorString(java.lang.String op)static booleanisPermOrComb(java.lang.String op)static booleanisPlusOrMinus(java.lang.String op)static booleanisPower(java.lang.String op)static booleanisRemainder(java.lang.String op)booleanisSemiColon(java.lang.String op)static booleanisSquare(java.lang.String op)static booleanisSquareRoot(java.lang.String op)static booleanisStoreCommand(java.lang.String op)static booleanisUnaryPostOperator(java.lang.String op)static booleanisUnaryPreOperator(java.lang.String op)voidsetName(java.lang.String name)static booleanvalidateAll(java.util.ArrayList<java.lang.String> scan)
-
Field Details
-
name
protected java.lang.String nameThe name of the operator object -
PLUS
public static final java.lang.String PLUS- See Also:
- Constant Field Values
-
MINUS
public static final java.lang.String MINUS- See Also:
- Constant Field Values
-
DIVIDE
public static final java.lang.String DIVIDE- See Also:
- Constant Field Values
-
MULTIPLY
public static final java.lang.String MULTIPLY- See Also:
- Constant Field Values
-
EN_DASH
public static final java.lang.String EN_DASH- See Also:
- Constant Field Values
-
FACTORIAL
public static final java.lang.String FACTORIAL- See Also:
- Constant Field Values
-
POWER
public static final java.lang.String POWER- See Also:
- Constant Field Values
-
LESS_THAN
public static final java.lang.String LESS_THAN- See Also:
- Constant Field Values
-
GREATER_THAN
public static final java.lang.String GREATER_THAN- See Also:
- Constant Field Values
-
ASSIGN
public static final java.lang.String ASSIGN- See Also:
- Constant Field Values
-
EQUALS
public static final java.lang.String EQUALS- See Also:
- Constant Field Values
-
LESS_OR_EQUALS
public static final java.lang.String LESS_OR_EQUALS- See Also:
- Constant Field Values
-
GREATER_OR_EQUALS
public static final java.lang.String GREATER_OR_EQUALS- See Also:
- Constant Field Values
-
AND
public static final java.lang.String AND- See Also:
- Constant Field Values
-
OR
public static final java.lang.String OR- See Also:
- Constant Field Values
-
REMAINDER
public static final java.lang.String REMAINDER- See Also:
- Constant Field Values
-
OPEN_CIRC_BRAC
public static final java.lang.String OPEN_CIRC_BRAC- See Also:
- Constant Field Values
-
CLOSE_CIRC_BRAC
public static final java.lang.String CLOSE_CIRC_BRAC- See Also:
- Constant Field Values
-
COMMA
public static final java.lang.String COMMA- See Also:
- Constant Field Values
-
ROOT
public static final java.lang.String ROOT- See Also:
- Constant Field Values
-
CUBE_ROOT
public static final java.lang.String CUBE_ROOT- See Also:
- Constant Field Values
-
PERMUTATION
public static final java.lang.String PERMUTATION- See Also:
- Constant Field Values
-
COMBINATION
public static final java.lang.String COMBINATION- See Also:
- Constant Field Values
-
INVERSE
public static final java.lang.String INVERSE- See Also:
- Constant Field Values
-
SQUARE
public static final java.lang.String SQUARE- See Also:
- Constant Field Values
-
CUBE
public static final java.lang.String CUBE- See Also:
- Constant Field Values
-
OPEN_SQUARE_BRAC
public static final java.lang.String OPEN_SQUARE_BRAC- See Also:
- Constant Field Values
-
CLOSE_SQUARE_BRAC
public static final java.lang.String CLOSE_SQUARE_BRAC- See Also:
- Constant Field Values
-
COLON
public static final java.lang.String COLON- See Also:
- Constant Field Values
-
CONST
public static final java.lang.String CONST- See Also:
- Constant Field Values
-
STORE
public static final java.lang.String STORE- See Also:
- Constant Field Values
-
EXIT
public static final java.lang.String EXIT- See Also:
- Constant Field Values
-
SPACE
public static final java.lang.String SPACE- See Also:
- Constant Field Values
-
SEMI_COLON
public static final java.lang.String SEMI_COLON- See Also:
- Constant Field Values
-
AT
public static final java.lang.String AT- See Also:
- Constant Field Values
-
operators
public static final java.lang.String[] operatorsThe instruction set of the parser of this software.
-
-
Constructor Details
-
Operator
public Operator(java.lang.String name)- Parameters:
name- creates a new form of a valid mathronian Operator
-
-
Method Details
-
setName
public void setName(java.lang.String name)- Parameters:
name- set the name of the Operator object
-
getName
public java.lang.String getName()- Returns:
- the name of the Operator object
-
isOperatorString
public static boolean isOperatorString(java.lang.String op)- Parameters:
op- The string to check.- Returns:
- true if the operator is a valid mathronian operator
-
isExitCommand
public static boolean isExitCommand(java.lang.String op)- Parameters:
op- the String object in consideration- Returns:
- true if the String object contains a exit command
-
isSemiColon
public boolean isSemiColon(java.lang.String op) -
isAtOperator
public static boolean isAtOperator(java.lang.String op) -
isStoreCommand
public static boolean isStoreCommand(java.lang.String op)- Parameters:
op- the String object in consideration- Returns:
- true if the String object contains a STORE command
-
isConstantStoreCommand
public static boolean isConstantStoreCommand(java.lang.String op)- Parameters:
op- the String object in consideration- Returns:
- true if the String object contains a constant storage command
-
isOpeningBrace
public static boolean isOpeningBrace(java.lang.String op)- Parameters:
op- the String object in consideration- Returns:
- true if the String object represents a [ character
-
isClosingBrace
public static boolean isClosingBrace(java.lang.String op)- Parameters:
op- the String object in consideration- Returns:
- true if the String object represents a [ character
-
isColon
public static boolean isColon(java.lang.String op)- Parameters:
op- the String object in consideration- Returns:
- true if the String object represents a : character This operator is used to mark the end-point of Variable initialization e.g [A=2,AA=3,acy=8.838383]:3A+6AA-8acy This instructs the parser to initialize the variables A, AA, acy with the values given and then evaluate the expression
-
isLogicOperator
public static boolean isLogicOperator(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is a logic operator the logic operators defined here are ==,<e;,>e;,<,>,|,&
-
isEqualsOperator
public static boolean isEqualsOperator(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the EQUALS operator
-
isAssignmentOperator
public static boolean isAssignmentOperator(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the ASSIGN operator it means that we assign or store the value of the RHS in the LHS and so the LHS must represent a valid variable
-
isBinaryOperator
public static boolean isBinaryOperator(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is an operator that functions in between 2 numbers or variables i.e,+,-,*,/,^,%,Č,Р
-
isPlusOrMinus
public static boolean isPlusOrMinus(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the + operator or is the - operator the form is log-¹(num,base)
-
isMulOrDiv
public static boolean isMulOrDiv(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the / operator or is the * operator the form is log-¹(num,base)
-
isPermOrComb
public static boolean isPermOrComb(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the permutation operator or is the combination operator the form is log-¹(num,base)
-
isMulOrDivOrRemOrPermOrCombOrPow
public static boolean isMulOrDivOrRemOrPermOrCombOrPow(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the + operator or is the - operator the form is log-¹(num,base)
-
isRemainder
public static boolean isRemainder(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the REMAINDER operator
-
isPower
public static boolean isPower(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the POWER operator
-
isBracket
public static boolean isBracket(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the OPEN_CIRC_BRAC or the CLOSE_CIRC_BRAC operator
-
isOpeningBracket
public static boolean isOpeningBracket(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the OPEN_CIRC_BRAC operator
-
isClosingBracket
public static boolean isClosingBracket(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the CLOSE_CIRC_BRAC operator
-
isFactorial
public static boolean isFactorial(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the FACTORIAL operator
-
isInverse
public static boolean isInverse(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the INVERSE operator
-
isSquareRoot
public static boolean isSquareRoot(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the ROOT operator
-
isCubeRoot
public static boolean isCubeRoot(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the "³√" operator
-
isSquare
public static boolean isSquare(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the SQUARE operator
-
isCube
public static boolean isCube(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the CUBE operator
-
isUnaryPreOperator
public static boolean isUnaryPreOperator(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is a pre-number operator e.g the trig operators,exponential operators,logarithmic operators(not to any base)
-
isUnaryPostOperator
public static boolean isUnaryPostOperator(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is a post number operator e.g the inverse operator,the factorial,the square and the cube
-
isComma
public static boolean isComma(java.lang.String op)- Parameters:
op- the String to check- Returns:
- true if the operator is the comma(,) operator
-
getPrecedence
The precedence of the operators- Parameters:
name- the name of the Operator object- Returns:
- the Operator's Precedence attribute
-
validateAll
public static boolean validateAll(java.util.ArrayList<java.lang.String> scan)- Parameters:
scan- An ArrayList object containing a scanned function.- Returns:
- true if validated
-