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 Object
  • Field Details

  • Constructor Details

    • Operator

      public Operator(String name)
      Parameters:
      name - creates a new form of a valid mathronian Operator
  • Method Details

    • setName

      public void setName(String name)
      Parameters:
      name - set the name of the Operator object
    • getName

      public String getName()
      Returns:
      the name of the Operator object
    • isOperatorString

      public static boolean isOperatorString(String op)
      Parameters:
      op - The string to check.
      Returns:
      true if the operator is a valid mathronian operator
    • isExitCommand

      public static boolean isExitCommand(String op)
      Parameters:
      op - the String object in consideration
      Returns:
      true if the String object contains a exit command
    • isSemiColon

      public boolean isSemiColon(String op)
    • isAtOperator

      public static boolean isAtOperator(String op)
    • isStoreCommand

      public static boolean isStoreCommand(String op)
      Parameters:
      op - the String object in consideration
      Returns:
      true if the String object contains a STORE command
    • isConstantStoreCommand

      public static boolean isConstantStoreCommand(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(String op)
      Parameters:
      op - the String object in consideration
      Returns:
      true if the String object represents a [ character
    • isClosingBrace

      public static boolean isClosingBrace(String op)
      Parameters:
      op - the String object in consideration
      Returns:
      true if the String object represents a [ character
    • isColon

      public static boolean isColon(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(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(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the EQUALS operator
    • isAssignmentOperator

      public static boolean isAssignmentOperator(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(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(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(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(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(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(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the REMAINDER operator
    • isPower

      public static boolean isPower(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the POWER operator
    • isBracket

      public static boolean isBracket(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(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the OPEN_CIRC_BRAC operator
    • isClosingBracket

      public static boolean isClosingBracket(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the CLOSE_CIRC_BRAC operator
    • isFactorial

      public static boolean isFactorial(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the FACTORIAL operator
    • isInverse

      public static boolean isInverse(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the INVERSE operator
    • isSquareRoot

      public static boolean isSquareRoot(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the ROOT operator
    • isCubeRoot

      public static boolean isCubeRoot(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the "³√" operator
    • isSquare

      public static boolean isSquare(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the SQUARE operator
    • isCube

      public static boolean isCube(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the CUBE operator
    • isUnaryPreOperator

      public static boolean isUnaryPreOperator(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(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(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the comma(,) operator
    • getPrecedence

      public static Precedence getPrecedence(String name)
      The precedence of the operators
      Parameters:
      name - the name of the Operator object
      Returns:
      the Operator's Precedence attribute
    • validateAll

      public static boolean validateAll(ArrayList<String> scan)
      Parameters:
      scan - An ArrayList object containing a scanned function.
      Returns:
      true if validated