|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--antlr.BaseAST | +--org.quasiliteral.antlr.AstroAST
Untamed: AST node implementation which stores tokens explicitly.
This is handy if you'd rather derive information from tokens on an as-needed basis instead of snarfing data from a token as an AST is being built.
In keeping with the nature of Antlr ASTs, Astros are mutable. The
corresponding immutable, Persistent, & PassByCopy type is the
org.quasiliteral.term.Term
.
Field Summary | |
private AstroToken |
myOptToken
|
Fields inherited from class antlr.BaseAST |
down, right |
Constructor Summary | |
AstroAST()
Enabled: Construct an instance which (at least initially) is not associated with a token. |
|
AstroAST(Token optToken)
Enabled: Construct an instance which is associated with the given token. |
Method Summary | |
static Astro |
build(AST self,
AstroBuilder builder)
Enabled: Since not all AST s are Astros, this static method
provides the equivalent of the build/1 instance method for ASTs in
general. |
Astro |
build(AstroBuilder builder)
Enabled: Builds an equivalent of this AST using the building methods of 'builder'. |
ConstList |
getArgs()
Enabled: |
Object |
getOptArgData()
Enabled: |
Object |
getOptArgData(short tagCode)
Enabled: |
String |
getOptArgString(short tagCode)
Enabled: |
Object |
getOptData()
Enabled: |
SourceSpan |
getOptSpan()
Enabled: |
String |
getOptString()
Enabled: |
short |
getOptTagCode()
Enabled: |
AstroToken |
getOptToken()
Enabled: Get the token associated with this instance. |
AstroTag |
getTag()
Enabled: |
String |
getText()
Enabled: Get the token text for this instance. |
int |
getType()
Enabled: Get the token type for this instance. |
void |
initialize(AST ast)
Enabled: Initialize this instance based on the given AST . |
void |
initialize(int type,
String optText)
Enabled: Initialize this instance with the given token type and text. |
void |
initialize(Token optToken)
Enabled: Initialize this instance with the given non-composite token. |
void |
setOptToken(AstroToken optToken)
Enabled: Set the token associated with this instance. |
void |
setText(String text)
Enabled: Set the token text for this node. |
void |
setType(int type)
Enabled: Set the token type for this node. |
String |
toString()
Suppressed: |
Astro |
withArgs(ConstList args)
Enabled: |
Astro |
withoutArgs()
Enabled: |
Methods inherited from class antlr.BaseAST |
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private AstroToken myOptToken
Constructor Detail |
public AstroAST()
public AstroAST(Token optToken)
optToken
- :AstroToken The (optional) token to associate this
instance withMethod Detail |
public String toString()
toString
in interface AST
toString
in class BaseAST
public Astro build(AstroBuilder builder)
Pattern-wise, the schema functions here as both a visitor and as a factory.
build
in interface Astro
public static Astro build(AST self, AstroBuilder builder)
AST
s are Astros, this static method
provides the equivalent of the build/1 instance method for ASTs in
general.
In the understanding of non-Astro ASTs used here, their functor is only according to the AST's type code, for the tag, the optSpan is null (since a generic AST doesn't provide an API for source position, and the implementation generally don't record it either), and the data is the AST's getText(). This choice for data will often be a mistake, but there's no generic way to make a better decision. For grammars where this is wrong, you should build a grammar-specific converter.
XXX This should probably be made into a sugar-instance-method of AST.
public String getText()
getText
in interface AST
getText
in class BaseAST
public int getType()
Token.INVALID_TYPE
.
getType
in interface AST
getType
in class BaseAST
public AstroToken getOptToken()
public void setOptToken(AstroToken optToken)
optToken
- The new token (or null) to associate with this
instance.public void initialize(Token optToken)
initialize
in interface AST
initialize
in class BaseAST
optToken
- :AstroToken the non-composite token to associate with
this instancepublic void initialize(int type, String optText)
CommonToken
with the given
parameters and associate this instance with it.
initialize
in interface AST
initialize
in class BaseAST
type
- the token typeoptText
- The token text, or nullpublic void initialize(AST ast)
AST
.
If the given AST is in fact an instance of
AstroAST, then this instance will be initialized
to point at the same token as the given one. If not, then this
instance will be initialized with the same token type and text
as the given one.
initialize
in interface AST
initialize
in class BaseAST
ast
- non-null; the AST to base this instance onpublic void setText(String text)
Token.INVALID_TYPE
and the given text.
setText
in interface AST
setText
in class BaseAST
text
- the new token textpublic void setType(int type)
setType
in interface AST
setType
in class BaseAST
type
- the new token typepublic AstroTag getTag()
getTag
in interface Astro
public short getOptTagCode()
getOptTagCode
in interface Astro
public Object getOptData()
getOptData
in interface Astro
public String getOptString()
getOptString
in interface Astro
public Object getOptArgData()
getOptArgData
in interface Astro
public Object getOptArgData(short tagCode)
getOptArgData
in interface Astro
public String getOptArgString(short tagCode)
getOptArgString
in interface Astro
public SourceSpan getOptSpan()
getOptSpan
in interface AstroArg
public ConstList getArgs()
getArgs
in interface Astro
public Astro withoutArgs()
withoutArgs
in interface Astro
public Astro withArgs(ConstList args)
withArgs
in interface Astro
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |