Package parser

Class UnaryPostOperator

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

public class UnaryPostOperator
extends Operator
implements Validatable
Models a post-operand Operator object e.g the !, inverse, square, cube operators
Author:
GBEMIRO
  • Constructor Details

    • UnaryPostOperator

      public UnaryPostOperator​(java.lang.String name, int index, java.util.ArrayList<java.lang.String> scan)
      Creates a new UnaryPostOperator object
      Parameters:
      name - The name that identifies this UnaryPostOperator object
      scan - The List object that contains the tokens
  • Method Details

    • getPrecedence

      public Precedence getPrecedence()
      Returns:
      the Precedence of this Operator object.
    • validate

      public boolean validate​(java.util.ArrayList<java.lang.String> scan)
      Specified by:
      validate in interface Validatable
      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

      public static void assignCompoundTokens​(java.util.ArrayList<java.lang.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. Examples: ²,³,-¹,!
      Parameters:
      scan - The ArrayList object that is the scanner of the MathExpression object and so contains this UnaryPostOperator object