The abstract
ASTNode class represents a generic AST node.
It contains a line number (
lineNumber).
AST Summary
ASTNode
An
ASTNode is an abstract class that represents a generic node
in the AST. It contains a line number indicating where the original source
code (represented by
the node) was scanned. All nodes in the AST extend
ASTNode.
- Program
Each (correct) Bantam program contains one top-level Program node. A
Program node extends ASTNode and contains a list of classes
(ClassList).
- ClassList
A ClassList node extends ListNode and contains a list of
Class_ nodes.
- Class_
A Class_ node represents a class from the Bantam source program. It
extends ASTNode and contains a filename (String), a class
name (String), a parent name (String), and a list of class
members (MemberList).
- Member
A Member node is an abstract class that represents a class member in
a Bantam source program. It is extended by the following:
- Method
A Method node represents a method from the Bantam source program. It
extends Member and contains a return type (String), a name
(String), a list of parameters (ExprList), a list of
statements (StmtList), and a return statement (RetnStmt).
- Field
A Field node represents a field from the Bantam source program. It
extends Member and contains a declaration type (String), a
name (String), and an (optional) initialization expression (
Expr). For fields without initialization expressions, the
initialization expression is null.
- Stmt
A Stmt node is an abstract class that represents a statement in a
Bantam source program. It is extended by the following:
- ExprStmt
An ExprStmt represents an expression statement from the Bantam
source program. It extends Stmt and contains an expression (
Expr).
- DeclStmt
A DeclStmt represents a declaration statement from the Bantam source
program. It extends Stmt and contains a declaration type (
String), a name (String), and a (non-optional)
initialization expression (Expr).
- IfStmt
An IfStmt represents an if statement from the Bantam source program.
It extends Stmt and contains a predicate expression (Expr),
a then statement (Stmt), and a else statement (Stmt).
- WhileStmt
A WhileStmt represents a while statement from the Bantam source
program. It extends Stmt and contains a continuation expression (
Expr) and a body statement (Stmt).
- BlockStmt
A BlockStmt represents a block statement from the Bantam source
program. It contains a list of expressions (ExprList).
- Expr
An Expr node is an abstract class that represents an expression in a
Bantam source program. It is extended by the following:
- AssignExpr
An AssignExpr represents an assignment expression from the Bantam
source program. It extends Expr and contains an optional reference
object (String, which can be null), a lefthand variable
name (String), and a righthand expression (Expr).
- DispatchExpr
A DispatchExpr represents a dynamic dispatch expression from the
Bantam source program. It extends Expr and contains an optional
reference object (Expr, which can be null), a method name (
String), and a list of arguments (ExprList).
- CastExpr
A CastExpr represents an explicit cast expression from the Bantam
source program. It extends Expr and contains a target object type (
String), an expression to cast (Expr), and a flag (
boolean) indicating whether it's an upcast or a downcast.
- InstanceofExpr
An InstanceofExpr represents an instanceof operation in a
Bantam source program. It extends Expr and contains a expression to
test (Expr) and an object type (String).
- BinaryExpr
A BinaryExpr is an abstract class that represents all binary
expressions where the left and right operands are both expressions
(i.e., not casts or instanceof). It extends Expr and
contains a lefthand expression (Expr) and a righthand expression (
Expr). It is extended by the following:
- BinaryArithExpr
A BinaryArithExpr is an abstract class that represents binary
arithmetic expressions. It extends BinaryExpr. It is subclassed by
the following:
- BinaryArithPlusExpr
A BinaryArithPlusExpr represents a addition (`+')
expression.
- BinaryArithMinusExpr
A BinaryArithMinusExpr represents a subtraction (`-')
expression.
- BinaryArithTimesExpr
A BinaryArithTimesExpr represents a multiplication (`*')
expression.
- BinaryArithDivideExpr
A BinaryArithDivideExpr represents a division (`/')
expression.
- BinaryArithModulusExpr
A BinaryArithModulusExpr represents a modulus (`%')
expression.
- BinaryCompExpr
A BinaryCompExpr is an abstract class that represents binary
comparison expressions. It extends BinaryExpr. It is subclassed by
the following:
- BinaryCompEqExpr
A BinaryCompEqExpr represents an equivalence (`==')
expression.
- BinaryCompNeExpr
A BinaryCompNeExpr represents a not equals (`!=')
expression.
- BinaryCompLtExpr
A BinaryCompLtExpr represents a less than (`<') expression.
- BinaryCompLeqExpr
A BinaryCompLeqExpr represents a less than or equal to (`<=
') expression.
- BinaryCompGtExpr
A BinaryCompGtExpr represents a greater than (`>')
expression.
- BinaryCompGeqExpr
A BinaryCompGeqExpr represents a greater than or equal to (`
>=') expression.
- BinaryLogicExpr
A BinaryLogicExpr is an abstract class that represents binary
boolean logic expressions. It extends BinaryExpr. It is subclassed
by the following:
- BinaryLogicAndExpr
A BinaryLogicAndExpr represents a logical AND (`&&')
expression.
- BinaryLogicOrExpr
A BinaryLogicOrExpr represents a logical OR (`||')
expression.
- UnaryExpr
A UnaryExpr is an abstract class that represents all unary
expressions where the operand is an expression (i.e., not new
). It extends Expr and contains an expression operand (Expr
). It is extended by the following:
- UnaryNegExpr
A UnaryNegExpr represents a unary integer negation (`-')
expression.
- UnaryNotExpr
A UnaryNotExpr represents a unary boolean complement (`!')
expression.
- ConstExpr
A ConstExpr is an abstract class that represents all constant
expressions. It extends Expr and contains a constant value (
String). It is extended by the following:
- ConstIntExpr
A ConstIntExpr represents an integer constant (e.g.,
12) expression.
- ConstBooleanExpr
A ConstBooleanExpr represent a boolean constant (e.g.,
true, false) expression.
- ConstStringExpr
A ConstStringExpr represent a string constant (e.g.,
``abc'') expression.
- VarExpr
A VarExpr represents a variable reference expression. It extends
Expr and contains an optional reference object name (String
, which might be null) and a variable name (String).
- ListNode
A ListNode is an abstract class that represents a generic list of
nodes in the AST. All lists of nodes must extend ListNode. These
include the following:
- MemberList
A MemberList node extends ListNode and contains a list of
Member nodes.
- StmtList
A StmtList node extends ListNode and contains a list of
Stmt nodes.
- ExprList
An ExprList node extends ListNode and contains a list of
Expr nodes.