|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--antlr.ASTFactory | +--de.zeigermann.xpa.treeParser.XMLASTFactory
This class replaces ANTLRs default ASTFactory
to make
creation of XMLAST
s possible for all kinds of sources.
You must set it in your parsers and tree parsers
using Parser.setASTFactory(antlr.ASTFactory)
resp.
TreeParser.setASTFactory(antlr.ASTFactory)
to create the right AST classes.
Field Summary | |
protected Parser2XMLASTAdapter |
parser
|
Fields inherited from class antlr.ASTFactory |
theASTNodeType, theASTNodeTypeClass, tokenTypeToASTClassMap |
Constructor Summary | |
XMLASTFactory(Parser2XMLASTAdapter parser)
Creates a new XMLASTFactory for XMLAST creation.
|
Method Summary | |
AST |
create()
Creates an empty XMLAST . |
AST |
create(AST tr)
Creates a copy of an AST .
|
AST |
create(int type)
Creates a new XMLAST with text "" |
AST |
create(int type,
String txt)
Creates a new XMLAST . |
AST |
create(String txt)
Creates an XMLAST from a string.
|
AST |
create(Token tok)
Creates a new AST from a Token .
|
AST |
create(XMLAST xa)
Creates a copy of an XMLAST . |
AST |
create(XMLStartAST xa)
Creates a copy of an XMLStartAST . |
void |
setParser(Parser2XMLASTAdapter parser)
Sets the parser to create XMLAST s from strings. |
Methods inherited from class antlr.ASTFactory |
addASTChild, create, create, create, createUsingCtor, dup, dupList, dupTree, error, getASTNodeType, getTokenTypeToASTClassMap, make, make, makeASTRoot, setASTNodeClass, setASTNodeType, setTokenTypeASTNodeType, setTokenTypeToASTClassMap |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Parser2XMLASTAdapter parser
Constructor Detail |
public XMLASTFactory(Parser2XMLASTAdapter parser)
XMLASTFactory
for XMLAST
creation.
This factory needs an XML parser to create XMLAST
s from strings.
parser
- the parser used to create XMLAST
s from stringsMethod Detail |
public void setParser(Parser2XMLASTAdapter parser)
XMLAST
s from strings.
parser
- the parser used to create XMLAST
s from stringspublic AST create(XMLAST xa)
XMLAST
.
public AST create(XMLStartAST xa)
XMLStartAST
.
public AST create(AST tr)
AST
.
As there is no dynamic dispatch over parameters, we need to simulate
it here. If the given AST
is of type XMLAST
or
XMLStartAST
this method delegates this call to
create(XMLAST)
resp. create(XMLStartAST)
. Otherwise
the method of the super class will be called.
create
in class ASTFactory
public AST create(String txt)
XMLAST
from a string.
To create the AST
this method parses the string using
the parser set with setParser(de.zeigermann.xpa.treeParser.Parser2XMLASTAdapter)
.
create
in class ASTFactory
XMLAST
generated by parser
or null
if parsing failessetParser(de.zeigermann.xpa.treeParser.Parser2XMLASTAdapter)
public AST create()
XMLAST
.
create
in class ASTFactory
public AST create(int type, String txt)
XMLAST
.
create
in class ASTFactory
type
- the type of the newly created XMLAST
public AST create(int type)
XMLAST
with text ""
create
in class ASTFactory
type
- the type of the newly created XMLAST
public AST create(Token tok)
AST
from a Token
.
As with create(AST)
we have the problem
there is no dynamic dispatch over parameters.
If the given Token
is of type XMLToken
or
XMLStartToken
this method creates a new XMLAST
resp.
XMLStartAST
. If it is an XMLEndToken
an empty
XMLAST
will be created, as no end tags are allowed.
In all other cases
the method of the super class will be called.
create
in class ASTFactory
create(AST)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |