JFlex

Class CharClasses

public class CharClasses extends Object

Field Summary
static charmaxChar
the largest character that can be used in char classes
Constructor Summary
CharClasses(int maxCharCode)
Constructs a new CharClass object that provides space for classes of characters from 0 to maxCharCode.
Method Summary
voiddump()
Dump charclasses to the dump output stream
intgetClassCode(char letter)
Returns the code of the character class the specified character belongs to.
int[]getClassCodes(Vector intervallVec)
Returns an array that contains the character class codes of all characters in the specified set of input characters.
CharClassIntervall[]getIntervalls()
Returns an array of all CharClassIntervalls in this char class collection.
chargetMaxCharCode()
Returns the greatest Unicode value of the current input character set.
int[]getNotClassCodes(Vector intervallVec)
Returns an array that contains the character class codes of all characters that are not in the specified set of input characters.
intgetNumClasses()
Returns the current number of character classes.
voidmakeClass(IntCharSet set)
Updates the current partition, so that the specified set of characters gets a new character class.
voidmakeClass(char singleChar)
Creates a new character class for the single character singleChar.
voidmakeClass(String str)
Creates a new character class for each character of the specified String.
voidmakeClass(Vector v)
Updates the current partition, so that the specified set of characters gets a new character class.
voidmakeClassNot(Vector v)
Updates the current partition, so that the set of all characters not contained in the specified set of characters gets a new character class.
voidsetMaxCharCode(int charCode)
Sets the larges Unicode value of the current input character set.
StringtoString(int theClass)
Return a string representation of one char class
StringtoString()
Return a string representation of the char classes stored in this class.

Field Detail

maxChar

public static final char maxChar
the largest character that can be used in char classes

Constructor Detail

CharClasses

public CharClasses(int maxCharCode)
Constructs a new CharClass object that provides space for classes of characters from 0 to maxCharCode. Initially all characters are in class 0.

Parameters: maxCharCode the last character code to be considered. (127 for 7bit Lexers, 255 for 8bit Lexers and 0xFFFF for Unicode Lexers).

Method Detail

dump

public void dump()
Dump charclasses to the dump output stream

getClassCode

public int getClassCode(char letter)
Returns the code of the character class the specified character belongs to.

getClassCodes

public int[] getClassCodes(Vector intervallVec)
Returns an array that contains the character class codes of all characters in the specified set of input characters.

Parameters: intervallVec a Vector of Intervalls, the set of characters to get the class codes for

Returns: an array with the class codes for intervallVec

getIntervalls

public CharClassIntervall[] getIntervalls()
Returns an array of all CharClassIntervalls in this char class collection. The array is ordered by char code, i.e. result[i+1].start = result[i].end+1 Each CharClassIntervall contains the number of the char class it belongs to.

getMaxCharCode

public char getMaxCharCode()
Returns the greatest Unicode value of the current input character set.

getNotClassCodes

public int[] getNotClassCodes(Vector intervallVec)
Returns an array that contains the character class codes of all characters that are not in the specified set of input characters.

Parameters: intervallVec a Vector of Intervalls, the complement of the set of characters to get the class codes for

Returns: an array with the class codes for the complement of intervallVec

getNumClasses

public int getNumClasses()
Returns the current number of character classes.

makeClass

public void makeClass(IntCharSet set)
Updates the current partition, so that the specified set of characters gets a new character class. Characters that are elements of set are not in the same equivalence class with characters that are not elements of set.

makeClass

public void makeClass(char singleChar)
Creates a new character class for the single character singleChar.

makeClass

public void makeClass(String str)
Creates a new character class for each character of the specified String.

makeClass

public void makeClass(Vector v)
Updates the current partition, so that the specified set of characters gets a new character class. Characters that are elements of the set v are not in the same equivalence class with characters that are not elements of the set v.

Parameters: v a Vector of Intervall objects. This Vector represents a set of characters. The set of characters is the union of all intervalls in the Vector.

makeClassNot

public void makeClassNot(Vector v)
Updates the current partition, so that the set of all characters not contained in the specified set of characters gets a new character class. Characters that are elements of the set v are not in the same equivalence class with characters that are not elements of the set v. This method is equivalent to makeClass(v)

Parameters: v a Vector of Intervall objects. This Vector represents a set of characters. The set of characters is the union of all intervalls in the Vector.

setMaxCharCode

public void setMaxCharCode(int charCode)
Sets the larges Unicode value of the current input character set.

Parameters: charCode the largest character code, used for the scanner (i.e. %7bit, %8bit, %16bit etc.)

toString

public String toString(int theClass)
Return a string representation of one char class

Parameters: theClass the index of the class to

toString

public String toString()
Return a string representation of the char classes stored in this class. Enumerates the classes by index.