Class InfixExpression

    • Constructor Detail

      • InfixExpression

        public InfixExpression()
      • InfixExpression

        public InfixExpression​(int pos)
      • InfixExpression

        public InfixExpression​(int pos,
                               int len)
      • InfixExpression

        public InfixExpression​(int pos,
                               int len,
                               AstNode left,
                               AstNode right)
      • InfixExpression

        public InfixExpression​(AstNode left,
                               AstNode right)
        Constructs a new InfixExpression. Updates bounds to include left and right nodes.
      • InfixExpression

        public InfixExpression​(int operator,
                               AstNode left,
                               AstNode right,
                               int operatorPos)
        Constructs a new InfixExpression.
        operatorPos - the absolute position of the operator
    • Method Detail

      • setLeftAndRight

        public void setLeftAndRight​(AstNode left,
                                    AstNode right)
      • getOperator

        public int getOperator()
        Returns operator token – alias for Node.getType()
      • setOperator

        public void setOperator​(int operator)
        Sets operator token – like Node.setType(int), but throws an exception if the operator is invalid.
        IllegalArgumentException - if operator is not a valid token code
      • getLeft

        public AstNode getLeft()
        Returns the left-hand side of the expression
      • setLeft

        public void setLeft​(AstNode left)
        Sets the left-hand side of the expression, and sets its parent to this node.
        left - the left-hand side of the expression
        IllegalArgumentException - } if left is null
      • getRight

        public AstNode getRight()
        Returns the right-hand side of the expression
        the right-hand side. It's usually an AstNode node, but can also be a FunctionNode representing Function expressions.
      • setRight

        public void setRight​(AstNode right)
        Sets the right-hand side of the expression, and sets its parent to this node.
        IllegalArgumentException - } if right is null
      • getOperatorPosition

        public int getOperatorPosition()
        Returns relative offset of operator token
      • setOperatorPosition

        public void setOperatorPosition​(int operatorPosition)
        Sets operator token's relative offset
        operatorPosition - offset in parent of operator token
      • 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.

        Specified by:
        toSource in class AstNode
        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 left operand, and the right operand.
        Specified by:
        visit in class AstNode
        v - the object to call with this node and its children