Class Operator

  • All Implemented Interfaces:
    java.lang.Comparable<Operator>
    Direct Known Subclasses:
    Function, Group

    public class Operator
    extends Token
    implements java.lang.Comparable<Operator>
    A mathematical operator is a "verb": a special infix (in the case of binary or greater arity) or prefix (in the case of unary) symbol which defines a relation between "nouns" (i.e.: literals and variables).
    Author:
    Curtis Rueden
    • Constructor Detail

      • Operator

        public Operator​(java.lang.String symbol,
                        int arity,
                        Operator.Associativity associativity,
                        double precedence)
    • Method Detail

      • getArity

        public int getArity()
        1 for unary, 2 for binary, etc.
      • isLeftAssociative

        public boolean isLeftAssociative()
      • isRightAssociative

        public boolean isRightAssociative()
      • isInfix

        public boolean isInfix()
        True iff the operator is an infix operator (e.g., a-b).
      • isPrefix

        public boolean isPrefix()
        True iff the operator is a prefix operator (e.g., -a).
      • isPostfix

        public boolean isPostfix()
        True iff the operator is a postfix operator (e.g., a').
      • getPrecedence

        public double getPrecedence()
      • compareTo

        public int compareTo​(Operator that)
        Specified by:
        compareTo in interface java.lang.Comparable<Operator>