public interface Parser
The typical caller is a Template System and will usually ask us to parse either a character at a time or a fragment of a template at a time, stopping only when it needs to determine the state of the parser for escaping purposes.
We will later add methods to save and restore the full state of the parser to better support conditional processing.
Modifier and Type | Field and Description |
---|---|
static ExternalState |
STATE_ERROR |
Modifier and Type | Method and Description |
---|---|
int |
getColumnNumber()
Returns the current column number.
|
int |
getLineNumber()
Returns the current line number.
|
ExternalState |
getState()
Returns the current state of the parser.
|
void |
parse(char input)
Tell the parser to process the provided
char . |
void |
parse(String input)
Tell the parser to process the provided
String . |
void |
reset()
Reset the parser back to its initial default state.
|
void |
setColumnNumber(int columnNumber)
Sets the current column number which is returned during error messages.
|
void |
setLineNumber(int lineNumber)
Sets the current line number which is returned during error messages.
|
static final ExternalState STATE_ERROR
void parse(char input) throws ParseException
char
. Throws exception
on an unrecoverable parsing error.input
- the character readParseException
- if an unrecoverable error occurred during parsingvoid parse(String input) throws ParseException
String
. Throws exception
on an unrecoverable parsing error.input
- the String
to parseParseException
- if an unrecoverable error occurred during parsingvoid reset()
ExternalState getState()
STATE_ERROR
if the parser encountered an error. Such an error may be recoverable
and the caller may want to continue parsing until parse(String)
returns false
.void setLineNumber(int lineNumber)
lineNumber
- the line number to set in the parserint getLineNumber()
void setColumnNumber(int columnNumber)
columnNumber
- the column number to set in the parserint getColumnNumber()
Copyright © 2010-2012 Google. All Rights Reserved.