Class LetNode

  • All Implemented Interfaces:
    java.lang.Comparable<AstNode>, java.lang.Iterable<Node>

    public class LetNode
    extends Scope
    AST node for let statements and expressions. Node type is Token.LET or Token.LETEXPR.

     LetStatement:
         let ( VariableDeclarationList ) Block
     LetExpression:
         let ( VariableDeclarationList ) Expression
    Note that standalone let-statements with no parens or body block, such as let x=6, y=7;, are represented as a VariableDeclaration node of type Token.LET, wrapped with an ExpressionStatement.

    • Constructor Detail

      • LetNode

        public LetNode()
      • LetNode

        public LetNode​(int pos)
      • LetNode

        public LetNode​(int pos,
                       int len)
    • Method Detail

      • setVariables

        public void setVariables​(VariableDeclaration variables)
        Sets variable list. Sets list parent to this node.
        Throws:
        java.lang.IllegalArgumentException - if variables is null
      • getBody

        public AstNode getBody()
        Returns body statement or expression. Body is null if the form of the let statement is similar to a VariableDeclaration, with no curly-brace. (This form is used to define let-bound variables in the scope of the current block.)

        Returns:
        the body form
      • setBody

        public void setBody​(AstNode body)
        Sets body statement or expression. Also sets the body parent to this node.
        Parameters:
        body - the body statement or expression. May be null.
      • getLp

        public int getLp()
        Returns left paren position, -1 if missing
      • setLp

        public void setLp​(int lp)
        Sets left paren position
      • getRp

        public int getRp()
        Returns right paren position, -1 if missing
      • setRp

        public void setRp​(int rp)
        Sets right paren position
      • setParens

        public void setParens​(int lp,
                              int rp)
        Sets both paren positions
      • toSource

        public java.lang.String toSource​(int depth)
        Description copied from class: AstNode
        Emits source code for this node. Callee is responsible for calling this function recursively on children, incrementing indent as appropriate.

        Note: if the parser was in error-recovery mode, some AST nodes may have null children that are expected to be non-null when no errors are present. In this situation, the behavior of the toSource method is undefined: toSource implementations may assume that the AST node is error-free, since it is intended to be invoked only at runtime after a successful parse.

        Overrides:
        toSource in class Scope
        Parameters:
        depth - the current recursion depth, typically beginning at 0 when called on the root node.
      • visit

        public void visit​(NodeVisitor v)
        Visits this node, the variable list, and if present, the body expression or statement.
        Overrides:
        visit in class Scope
        Parameters:
        v - the object to call with this node and its children