public abstract class GenericParser
extends java.lang.Object
ParserGenerator,
StaticParser,
DynamicParser| Modifier and Type | Field and Description |
|---|---|
static int |
COMPACT_TREE
A value indicating that a compact parse tree must be built.
|
static ParseNode |
E_O_I
Canonical token denoting the end of input.
|
static ParserTerminal |
ERROR_SYMBOL
Canonical terminal to identify error tokens.
|
static int |
FULL_TREE
A value indicating that the full (concrete) parse tree must be built.
|
static int |
NO_TREE
A value indicating that no parse tree must be built.
|
int |
parseTreeType
The value used by the parser to build, or not, a parse tree.
|
static int |
XML_TREE
A value indicating that an XML serialization tree must be built.
|
| Constructor and Description |
|---|
GenericParser()
The members of this class are divided into a static group and non-static
group.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Aborts the parsing upon an unrecoverable error and throws an exception
signaling so.
|
ParseNode |
currentNode()
Returns the current node; i.e., the result returned by
the most recent semantic action.
|
static ParseNode |
eoi()
Returns the end of input token with the current location.
|
ParseNode |
error()
Returns an error token.
|
static ParseNode |
error(ParseNode node)
Returns an error token whose svalue is set to the supplied ParseNode's
printed value, and whose span is set to that of the supplied node.
|
static ParseNode |
error(java.lang.String errval)
Returns an error token whose svalue is set to the supplied string.
|
ErrorManager |
errorManager() |
Error |
fatalError(java.lang.String msg) |
Error |
fatalError(java.lang.String msg,
Locatable extent) |
java.lang.String |
fileName()
The following is for showing items - for debugging purposes...
|
Tokenizer |
getTokenizer() |
void |
initialize()
One may override this method to execute whatever initializations one wishes.
|
static ParseNode |
literalToken(java.lang.String symbol) |
ParseNode |
locate(ParseNode node) |
org.jdom.Document |
makeXmlDocument(ParseNode node)
Returns the XML document rooted in the specified node.
|
static ParseNode |
numberToken(java.lang.String symbol,
double num) |
static ParseNode |
numberToken(java.lang.String symbol,
int num) |
void |
parse()
This is the method to invoke for parsing a token stream using the
Tokenizer instance specified as input.
|
void |
parse(boolean fullTree)
This is the same as parse(), but specifies building
the parse tree: true is equivalent to FULL_TREE,
and false is equivalent to COMPACT_TREE.
|
void |
parse(int treeType)
This is the same as parse(), but specifies what type of
parse tree to build.
|
void |
parse(java.io.Reader reader)
Same as parse() but sets the tokenizer's reader to the specified one
before doing the parse.
|
void |
parse(java.lang.String file)
Same as parse() but sets the tokenizer's reader to one
reading from the file having the specified name before doing the
parse.
|
void |
parse(Tokenizer input)
Same as parse() but sets the tokenizer to the specified one before doing
the parse.
|
void |
resetParser() |
void |
setErrorManager(ErrorManager errorManager) |
void |
setSwitchToken(ParseNode token) |
void |
setTokenizer(Tokenizer input) |
void |
setTrace(boolean flag) |
void |
setTreeType(int type)
Sets the parse tree type to the specified value (one of
NO_TREE, COMPACT_TREE, FULL_TREE, or
XML_TREE).
|
void |
setTreeType(java.lang.String type)
Sets the parse tree type according to the specified string (one of
"NONE", "COMPACT", "FULL", or
"XML").
|
static ParseNode |
symbolToken(java.lang.String symbol,
java.lang.String token)
The following methods are public conveniences that may be used by the
class implementing the tokenizer interface.
|
Error |
syntaxError(java.lang.String msg) |
Error |
syntaxError(java.lang.String msg,
Locatable extent) |
void |
toggleTrace() |
void |
trace() |
void |
traceAction(ParserAction a) |
boolean |
tracingIsOn() |
void |
writeXml(ParseNode node,
java.io.PrintStream out)
Serializes the XML tree rooted in this node on the specified output
stream.
|
static java.lang.String |
xmlForm(org.jdom.Document document)
Serializes the XML tree rooted in this node on the specified output
stream.
|
static org.jdom.output.XMLOutputter |
xmlWriter() |
public static final int NO_TREE
public static final int COMPACT_TREE
public static final int FULL_TREE
public static final int XML_TREE
public static ParseNode E_O_I
public static ParserTerminal ERROR_SYMBOL
public int parseTreeType
public GenericParser()
public void initialize()
public static final ParseNode eoi()
public static final ParseNode error(java.lang.String errval)
public static final ParseNode error(ParseNode node)
public static final ParseNode symbolToken(java.lang.String symbol, java.lang.String token)
public static final ParseNode numberToken(java.lang.String symbol, double num)
public static final ParseNode numberToken(java.lang.String symbol, int num)
public static ParseNode literalToken(java.lang.String symbol)
public static final org.jdom.output.XMLOutputter xmlWriter()
public static java.lang.String xmlForm(org.jdom.Document document)
public void writeXml(ParseNode node, java.io.PrintStream out) throws java.lang.Exception
java.lang.Exceptionpublic org.jdom.Document makeXmlDocument(ParseNode node) throws java.lang.Exception
java.lang.Exceptionpublic ParseNode error()
public ParseNode currentNode()
public final void setSwitchToken(ParseNode token)
public final void setTokenizer(Tokenizer input)
public final Tokenizer getTokenizer()
public void resetParser()
public final void setTreeType(int type)
public final void setTreeType(java.lang.String type)
public final void parse()
throws java.io.IOException
java.io.IOExceptionpublic final void parse(java.io.Reader reader)
throws java.io.IOException
java.io.IOExceptionpublic final void parse(java.lang.String file)
throws java.io.IOException
java.io.IOExceptionpublic final void parse(Tokenizer input) throws java.io.IOException
java.io.IOExceptionpublic final void parse(int treeType)
throws java.io.IOException
java.io.IOExceptionpublic final void parse(boolean fullTree)
throws java.io.IOException
java.io.IOExceptionpublic final ErrorManager errorManager()
public final void setErrorManager(ErrorManager errorManager)
public final Error syntaxError(java.lang.String msg)
public final Error fatalError(java.lang.String msg)
public java.lang.String fileName()
public final void abort()
public final boolean tracingIsOn()
public final void setTrace(boolean flag)
public final void toggleTrace()
public final void trace()
throws java.io.IOException
java.io.IOExceptionpublic final void traceAction(ParserAction a) throws java.io.IOException
java.io.IOException