All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.org.antlr.v4.kotlinruntime.tree.AbstractParseTreeVisitor.kt Maven / Gradle / Ivy

// Copyright 2017-present Strumenta and contributors, licensed under Apache 2.0.
// Copyright 2024-present Strumenta and contributors, licensed under BSD 3-Clause.

package org.antlr.v4.kotlinruntime.tree

public abstract class AbstractParseTreeVisitor : ParseTreeVisitor {
  /**
   * The default implementation calls [ParseTree.accept] on the specified tree.
   */
  override fun visit(tree: ParseTree): T =
    tree.accept(this)

  /**
   * The default implementation initializes the aggregate result to
   * [defaultResult]. Before visiting each child, it calls [shouldVisitNextChild];
   * if the result is `false` no more children are visited and the current
   * aggregate result is returned.
   *
   * After visiting a child, the aggregate result is updated by calling
   * [aggregateResult] with the previous aggregate result and the result of
   * visiting the child.
   *
   * The default implementation is not safe for use in visitors that modify
   * the tree structure. Visitors that modify the tree should override this
   * method to behave properly in respect to the specific algorithm in use.
   */
  override fun visitChildren(node: RuleNode): T {
    var result = defaultResult()
    val n = node.childCount

    for (i in 0..




© 2015 - 2024 Weber Informatics LLC | Privacy Policy