public class TokenParser extends Object implements AutoCloseable
for more informations on availables tokens.| Modifier and Type | Field and Description |
|---|---|
static String |
ERR_EXPECTED_NUMERIC |
static String |
ERR_EXPECTED_TOKEN |
static String |
ERR_EXPECTING_EOF |
static String |
ERR_INVALID_CHARACTER |
static String |
ERR_READER_NULL |
static String |
ERR_UNEXPECTED_EOS |
static String |
ERR_WRONG_QUOTE |
| Constructor and Description |
|---|
TokenParser(Reader aReader)
Create a new Parser.
|
TokenParser(String s)
Create a new Parser having a string as it's source.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the underlying stream.
|
boolean |
consume()
Used to invalidate current token getValue and set the parsed
flag to false, firing the parsing of a new token from the stream.
|
Object |
get(Token expectedToken1) |
Object |
get(Token expectedToken1,
Token expectedToken2) |
Object |
get(Token expectedToken1,
Token expectedToken2,
Token expectedToken3) |
String |
getIdentifier()
Read the identifier getValue from the parser.
|
String |
getKeyword()
Read the keyword from the parser.
|
Number |
getNumeric()
Read the numeric getValue from the parser.
|
String |
getString()
Read the string getValue from the parser.
|
Token |
getToken()
Get the available token in the stream.
|
Token |
getValidToken(Token expectedToken1) |
Token |
getValidToken(Token expectedToken1,
Token expectedToken2) |
Token |
getValidToken(Token expectedToken1,
Token expectedToken2,
Token expectedToken3) |
boolean |
isToken(Token validToken1) |
boolean |
isToken(Token validToken1,
Token validToken2) |
boolean |
isToken(Token validToken1,
Token validToken2,
Token validToken3) |
void |
raiseError(String msg)
Throw a ParseException.
|
void |
raiseExpectedTokenError(Token foundToken,
Token... expectedTokens) |
Object |
read(Token expectedToken1) |
Object |
read(Token expectedToken1,
Token expectedToken2) |
Object |
read(Token expectedToken1,
Token expectedToken2,
Token expectedToken3) |
String |
readIdentifier()
Read the identifier getValue from the parser.
|
String |
readKeyword()
Read the keyword from the parser.
|
Number |
readNumeric()
Read the numeric getValue from the parser.
|
String |
readString()
Read the string getValue from the parser.
|
public static String ERR_READER_NULL
public static String ERR_INVALID_CHARACTER
public static String ERR_UNEXPECTED_EOS
public static String ERR_EXPECTED_NUMERIC
public static String ERR_EXPECTED_TOKEN
public static String ERR_WRONG_QUOTE
public static String ERR_EXPECTING_EOF
public TokenParser(Reader aReader)
aReader - The source of the text stream.public TokenParser(String s)
s - The source of the text stream.public void raiseError(String msg)
msg - The message to include in the error.public void raiseExpectedTokenError(Token foundToken, Token... expectedTokens)
public Token getToken()
public boolean isToken(Token validToken1)
public Token getValidToken(Token expectedToken1, Token expectedToken2, Token expectedToken3)
public Number getNumeric()
ParseException - if current token is not numeric.public Number readNumeric()
Move the parser on the next token.
ParseException - if current token is not numeric.public String getKeyword()
ParseException - if current token is not a keyword.public String readKeyword()
Move the parser on the next token.
ParseException - if current token is not a keyword.public String getIdentifier()
ParseException - if current token is not string.public String readIdentifier()
Move the parser on the next token.
ParseException - if current token is not string.public String getString()
Does not care about the quoting of the string.
ParseException - if current token is not string.public String readString()
Does not care about the quoting of the string.
Move the parser on the next token.
ParseException - if current token is not string.public boolean consume()
public void close()
close in interface AutoCloseableCopyright © 2014. All rights reserved.