Class NodeFactory<Source, Output>

Type Parameters

  • Source
  • Output extends Node

Constructors

Properties

children: Map<string, undefined | ChildNodeFactory<Source, any, any>> = ...
childrenSetAtConstruction: boolean = false
constructorFunction: ((s, t, f) => Output[])

Type declaration

finalizer: ((node) => void) = ...

Type declaration

    • (node): void
    • Parameters

      Returns void

skipChildren: boolean = false

Methods

  • Tells the transformer whether this factory already takes care of the node's children and no further computation is desired on that subtree. E.g., when we're mapping an ANTLR parse tree, and we have a context that is only a wrapper over several alternatives, and for some reason those are not labeled alternatives in ANTLR (subclasses), we may configure the transformer as follows:

    transformer.registerNodeFactory(XYZContext) { ctx => transformer.transform(ctx.children[0]) }
    

    However, if the result of transformer.transform(ctx.children[0]) is an instance of a Node with a child for which withChild was configured, the transformer will think that it has to populate that child, according to the configuration determined by reflection. When it tries to do so, the "source" of the node will be an instance of XYZContext that may not have a child with a corresponding name, and the transformation will fail – or worse, it will map an unrelated node.

    Note: this method is called skipChildren in StarLasu, but skipChildren is already the name of a property, and the TypeScript and JavaScript languages don't allow to have a property with the same name as a method.

    Parameters

    • skip: boolean = true

    Returns NodeFactory<Source, Output>

Generated using TypeDoc