ParseTreeToASTTransformer
Implements a transformation from an ANTLR parse tree (the output of the parser) to an AST (a higher-level representation of the source code).
Constructors
Functions
Alternative to registerNodeFactoryUnwrappingChild(KClass) which is slightly more concise.
Often in ANTLR grammar we have rules which wraps other rules and act as wrapper. When there is only a ParserRuleContext child we can transform that child and return that result.
Performs the transformation of a node and, recursively, its descendants. In addition to the overridden method, it also assigns the parseTreeNode to the AST node so that it can keep track of its range. However, a node transformer can override the parseTreeNode of the nodes it creates (but not the parent).
Translate the given node and ensure a certain type will be obtained.
Translate a whole collection into a mutable list, translating each element and ensuring the list has the expected type.
Translate the only child (of type ParseRuleContext) and ensure the resulting value as the expected type.
Translate the given node and ensure a certain type will be obtained, if the value is not null. If the value is null, null is returned.