|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--antlr.Token
|
+--org.quasiliteral.antlr.AstroToken
Untamed: A Kind of Antlr Token that preserves all the information in a
Functor.
In keeping with the nature of an Antlr Token, and in order to be usable from within Antlr itself, AstroToken is mutable, but just mutable enough to accomodate Antlr. Specifically, the various values are settable once.
| Field Summary | |
private Object |
myOptData
Must be a null, Character, BigInteger, Double,
String, or Twine. |
private AstroSchema |
myOptSchema
|
private SourceSpan |
myOptSpan
|
private AstroTag |
myOptTag
|
| Fields inherited from class antlr.Token |
badToken, EOF_TYPE, INVALID_TYPE, MIN_USER_TYPE, NULL_TREE_LOOKAHEAD, SKIP |
| Constructor Summary | |
|
AstroToken()
Enabled: Construct an instance. |
(package private) |
AstroToken(AstroSchema optSchema,
AstroTag tag,
Object optData,
SourceSpan optSpan)
Makes an AstroToken that represents a token in some grammar. |
| Method Summary | |
Astro |
build(AstroBuilder builder)
Enabled: |
static Astro |
build(Token self,
AstroBuilder builder)
Enabled: Since not all Tokens are AstroTokens, this static method
provides the equivalent of the build/1 instance method for Tokens in
general. |
ConstList |
getArgs()
Enabled: |
int |
getColumn()
Enabled: |
int |
getLine()
Enabled: |
Object |
getOptArgData()
Enabled: |
Object |
getOptArgData(short tagCode)
Enabled: |
String |
getOptArgString(short tagCode)
Enabled: |
Object |
getOptData()
Enabled: If this token represents literal data, return that data, else null. |
SourceSpan |
getOptSpan()
Enabled: |
String |
getOptString()
Enabled: |
short |
getOptTagCode()
Enabled: |
AstroTag |
getTag()
Enabled: |
String |
getText()
Enabled: |
void |
setColumn(int c)
Enabled: Override to make set-once, and so set the source-span info of myOptSpan |
void |
setLine(int l)
Enabled: Override to make set-once, and so set the source-span info of myOptSpan |
void |
setSchema(AstroSchema schema)
Enabled: For when the type-code is already set by generic Antlr code, while Astro-specific knowledge of the schema comes along later. |
void |
setText(String s)
Enabled: |
void |
setType(int t)
Enabled: Override to make set-once |
Astro |
withArgs(ConstList args)
Enabled: |
Astro |
withoutArgs()
Enabled: |
| Methods inherited from class antlr.Token |
getType, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private AstroSchema myOptSchema
private AstroTag myOptTag
private Object myOptData
Character, BigInteger, Double,
String, or Twine. If not null, then the type must
correspond to the tag.
private final SourceSpan myOptSpan
| Constructor Detail |
public AstroToken()
The instance will have the tag code -1, null optData, and null optSpan.
AstroToken(AstroSchema optSchema,
AstroTag tag,
Object optData,
SourceSpan optSpan)
The invariants of an AstroToken are not checked here, but rather are enforced by the callers in this class and in ASTBuilder.
optSchema - If provided, the AstroSchema in which tag is defined.
To use the composite representation, a schema must
be provided.tag - Identifies a token type in a particular grammar or set
of related grammars.optData - null, Character,
BigInteger, Double,
or Twine presumably calculated
from lexing this tokenoptSpan - Where this token was extracted from.| Method Detail |
public Astro build(AstroBuilder builder)
build in interface Astro
public static Astro build(Token self,
AstroBuilder builder)
Tokens are AstroTokens, this static method
provides the equivalent of the build/1 instance method for Tokens in
general.
In the understanding of non-Astro Tokens used here, their functor is only according to the AST's type code, for the tag, and the AST's text, for the data. 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 Token.
public AstroTag getTag()
getTag in interface Astropublic void setSchema(AstroSchema schema)
To use this, the type code must already be set, the tag must not yet be set, and the schema must not be set to a different schema.
public void setType(int t)
setType in class Tokenpublic 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 String getText()
getText in class Tokenpublic void setText(String s)
setText in class Tokenpublic int getLine()
getLine in class Tokenpublic void setLine(int l)
setLine in class Tokenpublic int getColumn()
getColumn in class Tokenpublic void setColumn(int c)
setColumn in class Tokenpublic 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 | ||||||||||