|
|
||||||||||
| 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 ASTs 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 with| Method Detail |
public String toString()
toString in interface ASTtoString in class BaseASTpublic 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)
ASTs 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 ASTgetText in class BaseASTpublic int getType()
Token.INVALID_TYPE.
getType in interface ASTgetType in class BaseASTpublic 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 ASTinitialize in class BaseASToptToken - :AstroToken the non-composite token to associate with
this instance
public void initialize(int type,
String optText)
CommonToken with the given
parameters and associate this instance with it.
initialize in interface ASTinitialize in class BaseASTtype - 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 ASTinitialize in class BaseASTast - non-null; the AST to base this instance onpublic void setText(String text)
Token.INVALID_TYPE and the given text.
setText in interface ASTsetText in class BaseASTtext - the new token textpublic void setType(int type)
setType in interface ASTsetType in class BaseASTtype - the new token typepublic AstroTag getTag()
getTag in interface Astropublic short getOptTagCode()
getOptTagCode in interface Astropublic Object getOptData()
getOptData in interface Astropublic String getOptString()
getOptString in interface Astropublic Object getOptArgData()
getOptArgData in interface Astropublic Object getOptArgData(short tagCode)
getOptArgData in interface Astropublic String getOptArgString(short tagCode)
getOptArgString in interface Astropublic SourceSpan getOptSpan()
getOptSpan in interface AstroArgpublic ConstList getArgs()
getArgs in interface Astropublic Astro withoutArgs()
withoutArgs in interface Astropublic Astro withArgs(ConstList args)
withArgs in interface Astro
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||