Package java_cup

Class terminal


public class terminal extends symbol
This class represents a terminal symbol in the grammar. Each terminal has a textual name, an index, and a string which indicates the type of object it will be implemented with at runtime (i.e. the class of object that will be returned by the scanner and pushed on the parse stack to represent it).
  • Field Details

    • _all

      protected static Hashtable _all
      Table of all terminals. Elements are stored using name strings as the key
    • _all_by_index

      protected static Hashtable _all_by_index
      Table of all terminals indexed by their index number.
    • next_index

      protected static int next_index
      Static counter to assign unique index.
    • EOF

      public static final terminal EOF
      Special terminal for end of input.
    • error

      public static final terminal error
      special terminal used for error recovery
  • Constructor Details

    • terminal

      public terminal(String nm, String tp)
      Full constructor.
      Parameters:
      nm - the name of the terminal.
      tp - the type of the terminal.
    • terminal

      public terminal(String nm)
      Constructor with default type.
      Parameters:
      nm - the name of the terminal.
  • Method Details

    • all

      public static Enumeration all()
      Access to all terminals.
    • find

      public static terminal find(String with_name)
      Lookup a terminal by name string.
    • find

      public static terminal find(int indx)
      Lookup a terminal by index.
    • number

      public static int number()
      Total number of terminals.
    • is_non_term

      public boolean is_non_term()
      Report this symbol as not being a non-terminal.
      Specified by:
      is_non_term in class symbol
    • toString

      public String toString()
      Convert to a string.
      Overrides:
      toString in class symbol