public interface CAstNode
Note that there is no support for mutating these trees. This is deliberate, and should not be changed. We do not want to force all clients of the capa ast to handle mutating programs. In particular, the DOMO infrastructure has many forms of caching and other operations that rely on the underlying program being immutable. If you need to mutate these trees for some reason---and think carefully if you really need to, since this is meant to be essentially a wire format between components---make specialized implementations that understand how to do that.
Also note that this interface does not assume that you need some great big class hierarchy to structure types of nodes in an ast. Some people prefer such hierarchies as a matter of taste, but this interface is designed to not inflict this design choice on others.
Finally note that the set of node types in this file is not meant to be exhaustive. As new languages are added, feel free to add new nodes types as needed.
| Modifier and Type | Field and Description |
|---|---|
static int |
ANDOR_EXPR |
static int |
ARRAY_LENGTH |
static int |
ARRAY_LITERAL |
static int |
ARRAY_REF |
static int |
ASSERT |
static int |
ASSIGN |
static int |
ASSIGN_POST_OP |
static int |
ASSIGN_PRE_OP |
static int |
BINARY_EXPR |
static int |
BLOCK_EXPR
Represents a block of sequentially-executed nodes, the last of which produces the value for the
entire block (like progn from lisp).
|
static int |
BLOCK_STMT
Represents a block of sequential statements.
|
static int |
BREAK |
static int |
CALL |
static int |
CAST |
static int |
CATCH |
static int |
CHOICE_CASE |
static int |
CHOICE_EXPR |
static int |
CLASS_STMT |
static int |
COMPREHENSION_EXPR |
static int |
CONSTANT |
static int |
CONTINUE |
static int |
DECL_STMT |
static int |
EACH_ELEMENT_GET |
static int |
EACH_ELEMENT_HAS_NEXT |
static int |
ECHO |
static int |
EMPTY |
static int |
EMPTY_LIST_EXPR |
static int |
ERROR |
static int |
EXPR_LIST |
static int |
EXPR_STMT
Represents an expression statement (e.g.
|
static int |
FORIN_LOOP |
static int |
FUNCTION_EXPR |
static int |
FUNCTION_STMT |
static int |
GET_CAUGHT_EXCEPTION |
static int |
GLOBAL_DECL |
static int |
GOTO |
static int |
IF_EXPR |
static int |
IF_STMT |
static int |
IFGOTO |
static int |
INCLUDE |
static int |
INSTANCEOF |
static int |
IS_DEFINED_EXPR |
static int |
LABEL_STMT |
static int |
LIST_EXPR |
static int |
LOCAL_SCOPE |
static int |
LOOP
Represents a standard while loop.
|
static int |
MACRO_VAR |
static int |
MONITOR_ENTER |
static int |
MONITOR_EXIT |
static int |
NAMED_ENTITY_REF |
static int |
NARY_EXPR |
static int |
NEW |
static int |
NEW_ENCLOSING |
static int |
OBJECT_LITERAL |
static int |
OBJECT_REF |
static int |
OPERATOR |
static int |
PRIMITIVE |
static int |
RETURN |
static int |
RETURN_WITHOUT_BRANCH |
static int |
SPECIAL_PARENT_SCOPE |
static int |
SUB_LANGUAGE_BASE |
static int |
SUPER |
static int |
SWITCH
Represents a standard case statement.
|
static int |
THIS |
static int |
THROW |
static int |
TRY
Represents a standard try/catch statement.
|
static int |
TYPE_LITERAL_EXPR |
static int |
TYPE_OF |
static int |
UNARY_EXPR |
static int |
UNWIND |
static int |
VAR |
static int |
VOID |
static int |
YIELD_STMT |
| Modifier and Type | Method and Description |
|---|---|
default CAstNode |
getChild(int n)
Return the nth child of this node.
|
default int |
getChildCount()
How many children does this node have?
|
java.util.List<CAstNode> |
getChildren() |
int |
getKind()
What kind of node is this? Should return some constant from this file.
|
java.lang.Object |
getValue()
Returns the constant value represented by this node, if appropriate, and null otherwise.
|
static final int SWITCH
static final int LOOP
static final int BLOCK_STMT
static final int TRY
static final int EXPR_STMT
static final int DECL_STMT
static final int RETURN
static final int GOTO
static final int BREAK
static final int CONTINUE
static final int IF_STMT
static final int THROW
static final int FUNCTION_STMT
static final int ASSIGN
static final int ASSIGN_PRE_OP
static final int ASSIGN_POST_OP
static final int LABEL_STMT
static final int IFGOTO
static final int EMPTY
static final int RETURN_WITHOUT_BRANCH
static final int CATCH
static final int UNWIND
static final int MONITOR_ENTER
static final int MONITOR_EXIT
static final int ECHO
static final int YIELD_STMT
static final int FORIN_LOOP
static final int GLOBAL_DECL
static final int CLASS_STMT
static final int FUNCTION_EXPR
static final int EXPR_LIST
static final int CALL
static final int GET_CAUGHT_EXCEPTION
static final int BLOCK_EXPR
static final int BINARY_EXPR
static final int UNARY_EXPR
static final int IF_EXPR
static final int ANDOR_EXPR
static final int NEW
static final int OBJECT_LITERAL
static final int VAR
static final int OBJECT_REF
static final int CHOICE_EXPR
static final int CHOICE_CASE
static final int SUPER
static final int THIS
static final int ARRAY_LITERAL
static final int CAST
static final int INSTANCEOF
static final int ARRAY_REF
static final int ARRAY_LENGTH
static final int TYPE_OF
static final int EACH_ELEMENT_HAS_NEXT
static final int EACH_ELEMENT_GET
static final int LIST_EXPR
static final int EMPTY_LIST_EXPR
static final int TYPE_LITERAL_EXPR
static final int IS_DEFINED_EXPR
static final int MACRO_VAR
static final int NARY_EXPR
static final int NEW_ENCLOSING
static final int COMPREHENSION_EXPR
static final int LOCAL_SCOPE
static final int SPECIAL_PARENT_SCOPE
static final int CONSTANT
static final int OPERATOR
static final int PRIMITIVE
static final int ERROR
static final int VOID
static final int ASSERT
static final int INCLUDE
static final int NAMED_ENTITY_REF
static final int SUB_LANGUAGE_BASE
int getKind()
java.lang.Object getValue()
default CAstNode getChild(int n)
default int getChildCount()
java.util.List<CAstNode> getChildren()