Class UnaryPreOperator

java.lang.Object
parser.Operator
parser.UnaryPreOperator
All Implemented Interfaces:
Validatable

public final class UnaryPreOperator extends Operator implements Validatable
Models a post-operand Operator object e.g the trigonometric,logarithmic,exponential e.t.c. operators.
  • Field Details

    • precedence

      private final Precedence precedence
      The precedence of this BinaryOperator object.
    • index

      private int index
      The index of this operator in the scanned MathExpression that it belongs to.
  • Constructor Details

    • UnaryPreOperator

      public UnaryPreOperator(String name, int index, ArrayList<String> scan)
      Creates a new UnaryPreOperator object
      Parameters:
      name - The name of the operator
      index - The index of the operator in the list
      scan - The scanner output
  • Method Details

    • getPrecedence

      public Precedence getPrecedence()
      Returns:
      the precedence of this operator
    • validate

      public boolean validate(ArrayList<String> scan)
      Specified by:
      validate in interface Validatable
      Parameters:
      scan - the ArrayList object that this UnaryPreOperator 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 repect to its 2 immediate neighbouring tokens to the left and to the right is correct.
    • assignCompoundTokens

      public static void assignCompoundTokens(MathExpression function)
      Parameters:
      function - the MathExpression object that contains the power operator