Package sanskrit

Class Node

java.lang.Object
sanskrit.Node
Direct Known Subclasses:
Ast.Alias, Ast.Arg, Ast.Arguments, Ast.Comprehension, Ast.ExceptHandler, Ast.Expr, Ast.Keyword, Ast.Module, Ast.Stmt

public abstract class Node extends Object
A node of the syntax tree. The tree follows the shape of CPython's ast module: same node names, same fields in the same order, so that a dump of it can be compared with the dump of the tree CPython builds for the same source.

Every kind of node is a class of Ast with typed fields; passes discriminate them with instanceof.

  • Field Details

    • line

      public final int line
    • col

      public final int col
  • Method Details

    • type

      public abstract String type()
      The name of the node in CPython's ast module ("Name", "BinOp"...).
    • toString

      public String toString()
      Overrides:
      toString in class Object