coins.casttohir
Class ParseString

java.lang.Object
  extended bycoins.casttohir.ParseString

public class ParseString
extends java.lang.Object

ParseString class Parse given String operand. Successive call of getNextToken() will return tokens in the given string successively. The token kind is one of DIGITS, IDENTIFIER, STRING, DELIMITER, UNKNOWN The token kind are listed up as public static final int item in this class. DIGITS is a string consisting of digit character only. IDENTIFIER is a string consisting of alphabet (upper case and lower case), digits, and special characters specified by the parameter pSpIdChars. IDENTIFIER does not begin with digit. STRING is a character string starting with '"' and ending with '"'. DELIMITER is a character specified by the parameter pDelimiters. Characters indicated by the parameter pSpaces are skipped in the parsing operation. To see if there is no more token left, call hasNext(). If there is no token remaining, getNextToken() will return ""; If token kind is undefined, getNextToken() will return "".


Field Summary
(package private) static java.lang.String[] alphabetCharacters
           
static int DELIMITER
           
(package private) static java.lang.String[] digitCharacters
           
static int DIGITS
           
static int IDENTIFIER
           
static int STRING
           
static int UNDEFINED
           
 
Constructor Summary
ParseString(java.lang.String pText, java.util.Set pDelimiters, java.util.Set pSpaces, java.util.Set pIdSpChars)
          ParseString constructor Example: ParseString lParseString = new ParseString( "#param %I32, %I32, w%I32\n", fromStringToSet("#%,\n"), fromStringToSet(" \t"), fromStringToSet("_"));
 
Method Summary
(package private)  java.lang.String characterString()
           
(package private)  java.lang.String digitString()
           
static java.util.Set fromStringToSet(java.lang.String pString)
          Make a set of Strings by taking out characters contained in the parameter pString and changing each character to a string of length 1.
 java.lang.String getNextToken()
          getNextToken Get the next token and advance the token position.
 int getTokenKind()
          Get the token kind of the token returned by getNextToken().
 boolean hasNext()
           
(package private)  java.lang.String identifierString()
           
 java.lang.String seeCurrentToken()
          getNextToken Get the next token and advance the token position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED

public static final int UNDEFINED
See Also:
Constant Field Values

IDENTIFIER

public static final int IDENTIFIER
See Also:
Constant Field Values

DELIMITER

public static final int DELIMITER
See Also:
Constant Field Values

DIGITS

public static final int DIGITS
See Also:
Constant Field Values

STRING

public static final int STRING
See Also:
Constant Field Values

alphabetCharacters

static final java.lang.String[] alphabetCharacters

digitCharacters

static final java.lang.String[] digitCharacters
Constructor Detail

ParseString

public ParseString(java.lang.String pText,
                   java.util.Set pDelimiters,
                   java.util.Set pSpaces,
                   java.util.Set pIdSpChars)
ParseString constructor Example: ParseString lParseString = new ParseString( "#param %I32, %I32, w%I32\n", fromStringToSet("#%,\n"), fromStringToSet(" \t"), fromStringToSet("_"));

Parameters:
pText - Text string to be parsed.
pDelimiters - Set of character strings (character in the form of String) to be treated as a delimiting token.
pSpaces - Set of character strings to be treated as a space (not a token).
pIdSpChars - Set of special character (non-alphanumeric character) strings used in identifiers.
Method Detail

hasNext

public boolean hasNext()

getNextToken

public java.lang.String getNextToken()
getNextToken Get the next token and advance the token position. The resultant string is applied intern(). To see its token kind, call getTokenKind().

Returns:
the character string of the next token.

seeCurrentToken

public java.lang.String seeCurrentToken()
getNextToken Get the next token and advance the token position. To see its token kind, call getTokenKind().

Returns:
the character string of the next token.

getTokenKind

public int getTokenKind()
Get the token kind of the token returned by getNextToken(). The token kind is one of DIGIT, IDENTIFIER, STRING, DELIMITER, UNDEFINED.

Returns:
the token kind of the token returned by

fromStringToSet

public static java.util.Set fromStringToSet(java.lang.String pString)
Make a set of Strings by taking out characters contained in the parameter pString and changing each character to a string of length 1. For example, if pString is "(),:;" then the resultant set is { "(", ")", ",", ":", ";" }

Parameters:
pString - specifies the characters to be included in the resultant set.
Returns:
the set of strings obtained from pString.

digitString

java.lang.String digitString()

characterString

java.lang.String characterString()

identifierString

java.lang.String identifierString()