Class LetNode

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

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

         let ( VariableDeclarationList ) Block
         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

      • 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.)

        the body form
      • setBody

        public void setBody​(AstNode body)
        Sets body statement or expression. Also sets the body parent to this node.
        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 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.

        toSource in class Scope
        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.
        visit in class Scope
        v - the object to call with this node and its children