Class ASTNode


  • public class ASTNode
    extends java.lang.Object
    Expressions are parsed into an abstract syntax tree (AST). The tree has one root node and each node has zero or more children (parameters), depending on the operation. A leaf node is a numerical or string constant that has no more children (parameters). Other nodes define operators, functions and special operations like array index and structure separation.

    The tree is evaluated from bottom (leafs) to top, in a recursive way, until the root node is evaluated, which then holds the result of the complete expression.

    To be able to visualize the tree, a toJSON method is provided. The produced JSON string can be used to visualize the tree. OE.g. with this online tool:

    Online JSON to Tree Diagram Converter

    • Constructor Summary

      Constructors 
      Constructor Description
      ASTNode​(Token token, ASTNode... parameters)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String toJSON()
      Produces a JSON string representation of this node ad all its children.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ASTNode

        public ASTNode​(Token token,
                       ASTNode... parameters)
    • Method Detail

      • toJSON

        public java.lang.String toJSON()
        Produces a JSON string representation of this node ad all its children.
        Returns:
        A JSON string of the tree structure starting at this node.