Enum Parser.Operator

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Parser.Operator>
    Enclosing class:
    Parser

    static enum Parser.Operator
    extends java.lang.Enum<Parser.Operator>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int precedence  
      (package private) java.lang.String symbol  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Operator​(java.lang.String symbol, int precedence)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String toString()  
      static Parser.Operator valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Parser.Operator[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • STOP

        public static final Parser.Operator STOP
        A dummy operator with low precedence. When parsing subexpressions, we always stop when we reach an operator of lower precedence than the "current precedence". For example, when parsing 1 + 2 * 3 + 4, we'll stop parsing the subexpression * 3 + 4 when we reach the + because it has lower precedence than *. This dummy operator, then, behaves like + when the minimum precedence is *. We also return it if we're looking for an operator and don't find one. If this operator is , it's as if our expressions are bracketed with it, like ⊙ 1 + 2 * 3 + 4 ⊙.
    • Field Detail

      • symbol

        final java.lang.String symbol
      • precedence

        final int precedence
    • Constructor Detail

      • Operator

        private Operator​(java.lang.String symbol,
                         int precedence)
    • Method Detail

      • values

        public static Parser.Operator[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Parser.Operator c : Parser.Operator.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Parser.Operator valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Enum<Parser.Operator>