Abstract superclass of all AST nodes.

Note that nodes are not Identifiable: as they are immutable, the identity of a particular instance is meaningless.

Additional information

You can attach additional information to individual AST nodes using the put() and get() methods. Usage example:

// toplevel
shared Key<Token[]> tokensKey
    = ScopedKey<Token[]>(`module my.parser`, "tokens");

// in the parser
node.put(tokensKey, tokens);

// somewhere else
assert (exists tokens = node.get(tokensKey));
Initializer
Node()
Attributes
childrenSource Codeshared formal Node[] children

The child nodes of this node.

stringSource Codeshared actual String string

A developer-friendly string representing the instance.

At the moment, this is a Ceylon expression (created by CeylonExpressionTransformer), but this may change in the future; for anything other than diagnostic information, use CeylonExpressionTransformer or one of the other attributes directly.

Inherited Attributes
Attributes inherited from: Object
Methods
copyExtraInfoToSource Codeshared void copyExtraInfoTo(Node other)

Copies this node’s additional information to the other node.

See also put(), get()
getSource Codeshared Type? get<out Type>(Key<out Type> key)
given Type satisfies Object

Returns the additional information attached to this node using the given key, if any.

See also put()
putSource Codeshared Type? put<Type>(Key<Type> key, Type item)
given Type satisfies Object

Attaches the given additional information to this node using the given key. If other information was attached with the same key previously, it is returned.

If you don’t care about the previously attached information, you might want to use set() instead.

Parameters:
  • key
    • is Type? ret = extraInfo.put(key.id, item)
  • item
    • is Type? ret = extraInfo.put(key.id, item)
See also set(), get(), remove()
removeSource Codeshared Type? remove<Type>(Key<out Type> key)
given Type satisfies Object

Removes the additional information attached to this node using the given key from this node, returning it.

Parameters:
  • key
    • is Type? ret = extraInfo.remove(key.id)
See also put()
setSource Codeshared void set<in Type>(Key<in Type> key, Type item)
given Type satisfies Object

Attaches the given additional information to this node using the given key.

Unlike put(), this method discards any previously attached information; this makes it possible to declare the type parameter of key contravariant, enabling users to abstract over keys of different types.

See also put(), get(), remove()
transformSource Codeshared formal Result transform<out Result>(Transformer<Result> transformer)

Transform this node with the given transformer by calling the appropriate transformX method on the transformer.

If you have a Node node that’s actually an LIdentifier instance, then the runtime will call LIdentifier.transform; therefore, this method is by nature narrowing. This means that if transformer is a NarrowingTransformer, calling node.transform(transformer) is equivalent to calling transformer.transformNode(node). On the other hand, if transformer is a WideningTransformer, then the two operations are very different.

transformChildrenSource Codeshared Result[] transformChildren<out Result>(Transformer<Result> transformer)

Transform all child nodes by calling their transform() methods.

visitSource Codeshared void visit(Visitor visitor)

Visit this node with the given visitor. Calls the appropriate visitX method on the visitor.

visitChildrenSource Codeshared void visitChildren(Visitor visitor)

Visit the children of this node with the given visitor. Calls visit() on each child node.

Inherited Methods
Methods inherited from: Object