|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Untamed: Used to build an Astro tree -- a tree that could represent the results of parsing a string according to a grammar.
Several arguments or return values below are declared 'Object', but
pseudo-declared ":Args" in the javadoc comments. For these, the concrete
type represents a list of AstroArg
s, but the particular type used
to represent the list depends on the type of builder, and should be
documented in that builder's class comment.
Method Summary | |
Astro |
bag(Object args)
Enabled: For supporting the curly bracket shorthand for terms that represent named fields or attributes. |
Astro |
composite(AstroTag tag,
Object data,
SourceSpan optSpan)
Enabled: Makes an Astro whose tag is according to 'tag', and whose one argument is a leaf according to 'data'. |
AstroSchema |
getSchema()
Enabled: Describes the grammar whose trees we're building. |
Astro |
leafChar(char data,
SourceSpan optSpan)
Enabled: A Unicode character |
Astro |
leafData(Object data,
SourceSpan optSpan)
Enabled: Makes a leaf (eg, a Token) representing literal data. |
Astro |
leafFloat64(double data,
SourceSpan optSpan)
Enabled: An IEEE double precision floating point number |
Astro |
leafInteger(BigInteger data,
SourceSpan optSpan)
Enabled: A precision unlimited integer |
Astro |
leafLong(long data,
SourceSpan optSpan)
Enabled: Note that leafLong's data is a subrange of leafInteger's. |
Astro |
leafString(String data,
SourceSpan optSpan)
Enabled: A String is just a bare twine |
Astro |
leafTag(AstroTag tag,
SourceSpan optSource)
Enabled: Makes a leaf (eg, a Token) not representing literal data, but just a token tag (token type indicator) as identified by 'tag'. |
Astro |
leafTwine(Twine data,
SourceSpan optSpan)
Enabled: A list of characters with optional (ie, if not bare) annotation about where (source position) these characters came from. |
Object |
list()
Enabled: The empty args list |
Object |
list(AstroArg first)
Enabled: The args list of one element. |
Object |
list(AstroArg first,
AstroArg second)
Enabled: The two-argument args list |
Object |
list(AstroArg first,
AstroArg second,
AstroArg third)
Enabled: The three-argument args list |
Object |
list(AstroArg first,
AstroArg second,
AstroArg third,
AstroArg fourth)
Enabled: The four-argument args list |
Astro |
start(Astro top)
Enabled: When we're finished building, this should be applied to the root node. |
Astro |
term(Astro functor)
Enabled: For when a functor is used as a term without being followed by an explicit '()'. |
Astro |
term(Astro functor,
Object args)
Enabled: Returns an internal node (eg, an AST or Term), for which 'leaf' is the functor and 'args' are the arguments. |
Astro |
tuple(Object args)
Enabled: For supporting the square bracket shorthand for terms that represent tuples. |
Object |
unpack(Astro litString)
Enabled: Turns the string into a list of arguments representing each character as a character literal. |
Object |
with(Object list,
AstroArg next)
Enabled: Extend args list with an additional term, like a backwards cons. |
Method Detail |
public AstroSchema getSchema()
public Astro start(Astro top)
It is normally just an identity function, but allows, for example, post-parsing cleanup. This is called by the parser, but not currently by the 'build' or 'qbuild' methods of other trees.
public Astro leafTag(AstroTag tag, SourceSpan optSource)
The tag of the returned Astro should be according to the schema of this builder, even though the argument tag may be in a different schema. In this case, the correspondence is by tag name, rather than tag code.
public Astro composite(AstroTag tag, Object data, SourceSpan optSpan)
Is equivalent to:
term(leafTag(typeCode, src), list(term(leafData(data, src))))Exists to support legacy usage of Antlr Tokens, and in order to allow lexers, which wish to emit composites, to still emit only Tokens if allowed by the concrete builder.
public Astro leafData(Object data, SourceSpan optSpan)
Once coerced, this is equivalent to one of the following leaf* methods, which are provided for efficiency
public Astro leafChar(char data, SourceSpan optSpan)
public Astro leafLong(long data, SourceSpan optSpan)
The former is limited to 64 bits, and the latter isn't limited.
public Astro leafInteger(BigInteger data, SourceSpan optSpan)
public Astro leafFloat64(double data, SourceSpan optSpan)
public Astro leafString(String data, SourceSpan optSpan)
public Astro leafTwine(Twine data, SourceSpan optSpan)
public Astro term(Astro functor, Object args)
'leaf' must be a leaf (have no arguments).
May be destructive of 'leaf' and 'args'.
When parsing the term syntax, this is called if the empty args list appears explicitly, but not if it's left out. When usad as a quasi-term pattern, this allows us to distinguish between a) 'term`@foo`' and b) 'term`@foo()`'. #a matches any term, while #b matches only zero-arity terms. Note that c) 'term`@foo(*)`' or d) 'term`@foo(@args*)`' will also match any term, but in these cases, 'foo' will only be bound to the functor of the specimen, not, as in #a, the specimen as a whole. (In #c, the arguments are matched and ignored. In #d, 'args' is bound to the list of arguments.)
Similarly, this allows us to distinguish between the expressions e) 'term`$foo`' and f) 'term`$foo()`'. On success, both #e and #f mean the same thing. But #f additionally required the term bound to 'foo' to be zero-arity, or an exception will be thrown.
args
- :Argspublic Astro term(Astro functor)
For literal Astros, this is equivalent to 'term(functor, list())', but
is separate for support of quasi-literals, and explained at
term(Astro, Object)
.
public Astro tuple(Object args)
This is equivalent to 'term(leafTag(".tuple."), args)', although an individual builder/schema may have its own idea about what tagName to use to mark a tuple.
public Astro bag(Object args)
This is equivalent to 'term(leafTag(".bag."), args)', although an individual builder/schema may have its own idea about what tagName to use to mark a tuple.
public Object list()
public Object list(AstroArg first)
May be destructive of that element, as when it's an AST.
Should be equivalent to 'with(list(), first)'
public Object list(AstroArg first, AstroArg second)
public Object list(AstroArg first, AstroArg second, AstroArg third)
public Object list(AstroArg first, AstroArg second, AstroArg third, AstroArg fourth)
public Object with(Object list, AstroArg next)
May be destructive of 'list' and 'next'
list
- :Args
public Object unpack(Astro litString)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |