Package java_cup

Class terminal_set


  • public class terminal_set
    extends java.lang.Object
    A set of terminals implemented as a bitset.
    Version:
    last updated: 11/25/95
    Author:
    Scott Hudson
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.BitSet _elements
      Bitset to implement the actual set.
      static terminal_set EMPTY
      Constant for the empty set.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(terminal sym)
      Add a single terminal to the set.
      boolean add​(terminal_set other)
      Add (union) in a complete set.
      boolean contains​(int indx)
      Given its index determine if the set contains a particular terminal.
      boolean contains​(terminal sym)
      Determine if the set contains a particular terminal.
      boolean empty()
      Determine if the set is empty.
      boolean equals​(terminal_set other)
      Equality comparison.
      boolean equals​(java.lang.Object other)
      Generic equality comparison.
      boolean intersects​(terminal_set other)
      Determine if this set intersects another.
      boolean is_subset_of​(terminal_set other)
      Determine if this set is an (improper) subset of another.
      boolean is_superset_of​(terminal_set other)
      Determine if this set is an (improper) superset of another.
      protected void not_null​(java.lang.Object obj)
      Helper function to test for a null object and throw an exception if one is found.
      void remove​(terminal sym)
      Remove a terminal if it is in the set.
      java.lang.String toString()
      Convert to string.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • EMPTY

        public static final terminal_set EMPTY
        Constant for the empty set.
      • _elements

        protected java.util.BitSet _elements
        Bitset to implement the actual set.
    • Constructor Detail

      • terminal_set

        public terminal_set()
        Constructor for an empty set.
    • Method Detail

      • not_null

        protected void not_null​(java.lang.Object obj)
                         throws internal_error
        Helper function to test for a null object and throw an exception if one is found.
        Parameters:
        obj - the object we are testing.
        Throws:
        internal_error
      • empty

        public boolean empty()
        Determine if the set is empty.
      • contains

        public boolean contains​(terminal sym)
                         throws internal_error
        Determine if the set contains a particular terminal.
        Parameters:
        sym - the terminal symbol we are looking for.
        Throws:
        internal_error
      • contains

        public boolean contains​(int indx)
        Given its index determine if the set contains a particular terminal.
        Parameters:
        indx - the index of the terminal in question.
      • is_subset_of

        public boolean is_subset_of​(terminal_set other)
                             throws internal_error
        Determine if this set is an (improper) subset of another.
        Parameters:
        other - the set we are testing against.
        Throws:
        internal_error
      • is_superset_of

        public boolean is_superset_of​(terminal_set other)
                               throws internal_error
        Determine if this set is an (improper) superset of another.
        Parameters:
        other - the set we are testing against.
        Throws:
        internal_error
      • add

        public boolean add​(terminal sym)
                    throws internal_error
        Add a single terminal to the set.
        Parameters:
        sym - the terminal being added.
        Returns:
        true if this changes the set.
        Throws:
        internal_error
      • add

        public boolean add​(terminal_set other)
                    throws internal_error
        Add (union) in a complete set.
        Parameters:
        other - the set being added.
        Returns:
        true if this changes the set.
        Throws:
        internal_error
      • equals

        public boolean equals​(terminal_set other)
        Equality comparison.
      • equals

        public boolean equals​(java.lang.Object other)
        Generic equality comparison.
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Convert to string.
        Overrides:
        toString in class java.lang.Object