|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcoins.casttohir.ParseString
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 |
public static final int UNDEFINED
public static final int IDENTIFIER
public static final int DELIMITER
public static final int DIGITS
public static final int STRING
static final java.lang.String[] alphabetCharacters
static final java.lang.String[] digitCharacters
| Constructor Detail |
public ParseString(java.lang.String pText,
java.util.Set pDelimiters,
java.util.Set pSpaces,
java.util.Set pIdSpChars)
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 |
public boolean hasNext()
public java.lang.String getNextToken()
public java.lang.String seeCurrentToken()
public int getTokenKind()
public static java.util.Set fromStringToSet(java.lang.String pString)
pString - specifies the characters to be included in the resultant set.
java.lang.String digitString()
java.lang.String characterString()
java.lang.String identifierString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||