dk.brics.grammar.operations
Class CharSet

java.lang.Object
  extended by dk.brics.grammar.operations.CharSet

public class CharSet
extends Object

Representation of a set of chars using an ordered list of intervals.


Constructor Summary
CharSet()
          Constructs a new empty charset.
CharSet(Automaton a, boolean first_only, boolean last_only, boolean expanded)
          Constructs a charset from the chars occuring in the given automaton.
CharSet(String s, boolean first_only, boolean last_only, boolean expanded)
          Constructs a charset from the chars occuring in the given string.
 
Method Summary
 boolean add(CharSet cs)
          Adds chars from the given charset to this charset.
 boolean addEOF()
          Adds EOF this charset.
 boolean contains(char c)
          Checks whether this charset contains the given char.
 boolean containsEOF()
          Checks whether this charset contains EOF.
 boolean disjoint(CharSet cs)
          Checks whether this charset is disjoint from the given one.
 boolean equals(Object obj)
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharSet

public CharSet()
Constructs a new empty charset.


CharSet

public CharSet(Automaton a,
               boolean first_only,
               boolean last_only,
               boolean expanded)
Constructs a charset from the chars occuring in the given automaton.

Parameters:
a - automaton
first_only - of set, only consider transitions from the start state
last_only - of set, only consider transitions to an accept state
expanded - if set, assume alphabet has been expanded

CharSet

public CharSet(String s,
               boolean first_only,
               boolean last_only,
               boolean expanded)
Constructs a charset from the chars occuring in the given string.

Parameters:
s - string
first_only - of set, only consider first character
last_only - of set, only consider last character
expanded - if set, assume alphabet has been expanded
Method Detail

add

public boolean add(CharSet cs)
Adds chars from the given charset to this charset.

Parameters:
cs - charset
Returns:
true if this charset changed

addEOF

public boolean addEOF()
Adds EOF this charset.

Returns:
true if this charset changed

contains

public boolean contains(char c)
Checks whether this charset contains the given char.

Parameters:
c - char
Returns:
true if the char is in the charset

containsEOF

public boolean containsEOF()
Checks whether this charset contains EOF.

Returns:
true if EOF is in the charset

disjoint

public boolean disjoint(CharSet cs)
Checks whether this charset is disjoint from the given one.

Parameters:
cs - charset
Returns:
true if disjoint

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2005-2008 Anders Møller.