AstVisitor

io.eleven19.krueger.ast.AstVisitor
See theAstVisitor companion trait
object AstVisitor

Utilities for visiting and folding over AST trees.

Traversal uses trampolining (scala.util.control.TailCalls) for stack safety, so arbitrarily deep AST trees can be processed without risk of stack overflow.

Attributes

Companion
trait
Source
AstVisitor.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
AstVisitor.type

Members list

Value members

Concrete methods

def children(node: AstNode): List[AstNode]

Return the direct children of a node.

Return the direct children of a node.

Attributes

Source
AstVisitor.scala
def collect[B](node: AstNode)(pf: PartialFunction[AstNode, B]): List[B]

Collect nodes matching a partial function, pre-order.

Collect nodes matching a partial function, pre-order.

Attributes

Source
AstVisitor.scala
def collectPostOrder[B](node: AstNode)(pf: PartialFunction[AstNode, B]): List[B]

Collect nodes matching a partial function, post-order.

Collect nodes matching a partial function, post-order.

Attributes

Source
AstVisitor.scala
def count(node: AstNode): Int

Count all nodes in the tree.

Count all nodes in the tree.

Attributes

Source
AstVisitor.scala
def foldLeft[A](node: AstNode, z: A)(f: (A, AstNode) => A): A

Pre-order left fold over all nodes.

Pre-order left fold over all nodes.

Attributes

Source
AstVisitor.scala
def visit[A](node: AstNode, visitor: AstVisitor[A]): A

Dispatch a node to the appropriate visitor method.

Dispatch a node to the appropriate visitor method.

Attributes

Source
AstVisitor.scala

Extensions

Extensions

extension (node: AstNode)
def children: List[AstNode]

Attributes

Source
AstVisitor.scala
def collect[B](pf: PartialFunction[AstNode, B]): List[B]

Attributes

Source
AstVisitor.scala
def count: Int

Attributes

Source
AstVisitor.scala
def fold[A](z: A)(f: (A, AstNode) => A): A

Attributes

Source
AstVisitor.scala
def visit[A](visitor: AstVisitor[A]): A

Attributes

Source
AstVisitor.scala