public final class TreeBuilder
extends java.lang.Object
An instance of this class can be thought of as a stack-machine. Calling methods, such as createDatum(String), causes leaf AST nodes to be pushed onto the stack. Calling methods, such as createSequenceStatement(), causes an inner AST node to be created. Using these different types of methods in combination facilitates the construction of an AST.
This stack-machine employs a primary-stack and a stack-of-stacks. The primary stack is the stack that is manipulated when building an AST node. Sometimes it is necessary to limit the scope of a node construction operation. As a result, it is possible to push the current primary-stack onto the stack-of-stacks. When the primary-stack is pushed onto the stack-of-stacks, a new stack will replace it. Later, the old primary-stack can be restored by popping it off of the stack-of-stacks.
Some methods herein denote the bottom element on the primary-stack as ".....". This means that the method only manipulates the topmost element(s) on the stack. The elements below the manipulated elements will not be popped, relocated, etc. On the other hand, some methods do not denote the bottom element as ".....". These methods may manipulate the entire primary-stack.
| Constructor and Description |
|---|
TreeBuilder()
Sole Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
This method removes all the elements off of the primary-stack.
|
java.util.Stack<IConstruct> |
copyStack()
This method creates and returns a copy of the primary-stack.
|
void |
createComponentAnnotation(java.util.List<java.lang.String> values)
This method creates an annotation-usage.
|
void |
createComponentAnnotationList()
This method creates an annotation-list.
|
void |
createComponentConditionalCase()
This method creates a conditional-case.
|
void |
createComponentDocComment()
This method creates a doc-comment.
|
void |
createComponentDocCommentLine(java.lang.String text)
This method creates a doc-comment-line.
|
void |
createComponentElement()
This method creates an element.
|
void |
createComponentElementList()
This method creates an element-list.
|
void |
createComponentExceptionHandler()
This method creates an exception-handler for a try-catch statement.
|
void |
createComponentFormalParameter()
This method creates a formal-parameter.
|
void |
createComponentFormalParameterList()
This method creates a formal-parameter.
|
void |
createComponentLabel(java.lang.String name)
This method creates a label.
|
void |
createComponentName(java.lang.String name)
This method creates a name.
|
void |
createComponentNamespace()
This method creates a namespace component.
|
void |
createComponentTypeSpecifier()
This method creates a type-specifier for an array-type.
|
void |
createComponentTypeSpecifier(java.lang.Integer dimensions)
This method creates a type-specifier for an array-type.
|
void |
createComponentVariable(java.lang.String name)
This method creates a variable.
|
void |
createDatum(BigDecimalLiteral value)
This method creates a big-decimal-datum.
|
void |
createDatum(BigIntegerLiteral value)
This method creates a big-integer-datum.
|
void |
createDatum(boolean value)
This method creates a boolean-datum.
|
void |
createDatum(boolean verbatim,
java.lang.String value)
This method creates a String-datum.
|
void |
createDatum(ByteLiteral value)
This method creates a byte-datum.
|
void |
createDatum(CharLiteral value)
This method creates a char-datum.
|
void |
createDatum(DoubleLiteral value)
This method creates a double-datum.
|
void |
createDatum(FloatLiteral value)
This method creates a float-datum.
|
void |
createDatum(IntLiteral value)
This method creates a int-datum.
|
void |
createDatum(LongLiteral value)
This method creates a long-datum.
|
void |
createDatum(ShortLiteral value)
This method creates a short-datum.
|
void |
createDatumClass()
This method creates a class-datum.
|
void |
createDatumNull()
This method creates a null-datum.
|
void |
createDatumVariable()
This method creates a variable-datum.
|
void |
createDefinitionAnnotation()
This method creates an annotation-definition.
|
void |
createDefinitionDesign()
This method creates an design-definition.
|
void |
createDefinitionEnum()
This method creates an enum-definition.
|
void |
createDefinitionException()
This method creates an exception-definition.
|
void |
createDefinitionFunction()
This method creates a function-definition.
|
void |
createDefinitionFunctor()
This method creates an functor-definition.
|
void |
createDefinitionStruct()
This method creates a struct-definition.
|
void |
createDefinitionTuple()
This method creates an tuple-definition.
|
void |
createDirectiveImport()
This method creates an import-directive.
|
void |
createDirectiveModule()
This method creates a module-directive.
|
void |
createExpressionCallMethod()
This method creates a call-method expression.
|
void |
createExpressionCallStaticMethod()
This method creates a call-static-method expression.
|
void |
createExpressionDispatch()
This method creates a dispatch-expression.
|
void |
createExpressionGetField()
This method creates a get-field expression.
|
void |
createExpressionGetStaticField()
This method creates a get-static-field expression.
|
void |
createExpressionInstanceOf()
This method creates an instanceof-expression.
|
void |
createExpressionList()
This method creates a list-expression.
|
void |
createExpressionListComprehension()
This method creates a list-comprehension-expression.
|
void |
createExpressionLocals()
This method creates a locals-expression.
|
void |
createExpressionNew()
This method creates a new-expression.
|
void |
createExpressionOnce()
This method creates a once-expression.
|
void |
createExpressionProgn()
This method creates a progn-expression.
|
void |
createExpressionSetField()
This method creates a set-field expression.
|
void |
createExpressionSetStaticField()
This method creates a set-static-field expression.
|
void |
createExpressionTernaryConditional()
This method creates an ternary-conditional expression.
|
void |
createModule()
This method creates a module.
|
void |
createOperationAdd()
This method creates a add-operation.
|
void |
createOperationAnd()
This method creates an AND-operation.
|
void |
createOperationAs()
This method creates an as-operation.
|
void |
createOperationConcat()
This method creates a concat-operation.
|
void |
createOperationDivide()
This method creates a divide-operation.
|
void |
createOperationEquals()
This method creates an equals-operation.
|
void |
createOperationGreaterThan()
This method creates a greater-than operation.
|
void |
createOperationGreaterThanOrEquals()
This method creates a greater-than-or-equals operation.
|
void |
createOperationIdentityEquals()
This method creates an identity-equals operation.
|
void |
createOperationIdentityNotEquals()
This method creates an identity-not-equals operation.
|
void |
createOperationImplies()
This method creates an IMPLIES-operation.
|
void |
createOperationIs()
This method creates an is-operation.
|
void |
createOperationLessThan()
This method creates a less-than operation.
|
void |
createOperationLessThanOrEquals()
This method creates a less-than-or-equals operation.
|
void |
createOperationModulo()
This method creates a modulo-operation.
|
void |
createOperationMultiply()
This method creates a multiply-operation.
|
void |
createOperationNegate()
This method creates a negate-operation.
|
void |
createOperationNot()
This method creates a not-operation.
|
void |
createOperationNotEquals()
This method creates an not-equals-operation.
|
void |
createOperationNullCoalescing()
This method creates a null-coalescing operation.
|
void |
createOperationOr()
This method creates an OR-operation.
|
void |
createOperationSubtract()
This method creates a subtract-operation.
|
void |
createOperationXor()
This method creates an XOR-operation.
|
void |
createStatementAssert()
This method creates an assert-statement.
|
void |
createStatementAssume()
This method creates an assume-statement.
|
void |
createStatementBranch()
This method creates a branch-statement.
|
void |
createStatementBreak()
This method creates a break-statement.
|
void |
createStatementContinue()
This method creates a continue-statement.
|
void |
createStatementDelegate()
This method creates a delegate-statement.
|
void |
createStatementDoUntil()
This method creates a do-until-loop statement.
|
void |
createStatementDoWhile()
This method creates a do-while-loop statement.
|
void |
createStatementExpression()
This method creates an expression-statement.
|
void |
createStatementFor()
This method creates a for-statement.
|
void |
createStatementForeach()
This method creates a foreach-statement.
|
void |
createStatementForever()
This method creates a forever-loop statement.
|
void |
createStatementGoto()
This method creates a goto-statement.
|
void |
createStatementIf()
This method creates an if-statement.
|
void |
createStatementLambda()
This method creates a lambda-statement.
|
void |
createStatementLet()
This method creates a let-statement.
|
void |
createStatementMarker()
This method creates a marker-statement.
|
void |
createStatementNop()
This method creates a nop-statement.
|
void |
createStatementRecur()
This method creates a recur-statement.
|
void |
createStatementRedo()
This method creates a redo-statement.
|
void |
createStatementReturnValue()
This method creates a return-value statement.
|
void |
createStatementReturnVoid()
This method creates a return-void statement.
|
void |
createStatementSequence()
This method creates a sequence-statement.
|
void |
createStatementThrow()
This method creates a throw-statement.
|
void |
createStatementTryCatch()
This method creates a try-catch statement.
|
void |
createStatementUntil()
This method creates a until-statement.
|
void |
createStatementVal()
This method creates a val-statement.
|
void |
createStatementVar()
This method creates a var-statement.
|
void |
createStatementWhen()
This method creates a when-statement.
|
void |
createStatementWhile()
This method creates a while-statement.
|
boolean |
isEmpty()
This method determines whether the primary-stack is empty.
|
IConstruct |
peek()
This method retrieves, but does not remove, the topmost value on the primary-stack.
|
IConstruct |
pop()
This method retrieves and removes the topmost value on the primary-stack.
|
void |
popStack()
This method restores the previous stack, by popping it off of the
stack-of-stacks.
|
void |
push(IConstruct value)
This method pushes a construct onto the primary-stack.
|
void |
pushNull()
This method pushes null onto the primary-stack.
|
void |
pushStack()
This method pushes the primary-stack onto the stack-of-stacks.
|
void |
setSourceLocation(java.net.URL file,
java.lang.Integer line,
java.lang.Integer column,
java.lang.Object additional_info)
This method sets the source-location information for the topmost node on the stack.
|
int |
size()
This method retrieves the current size of the primary-stack.
|
public void setSourceLocation(java.net.URL file,
java.lang.Integer line,
java.lang.Integer column,
java.lang.Object additional_info)
This method has no effect, if the stack is empty or the topmost node is null.
file - is the path to the source-code file.
This is null, if no file is specified.line - is the one-based line-number where the node starts.
This is null, if no line-number is specified.column - is the one-based column-number where the node starts.
This is null, if the column-number is specified.additional_info - is additional information that helps locate the node.
This is null, if no additional-info is specified.public void pushStack()
public void popStack()
Note: If the current stack is not empty, then its elements will be pushed onto the restored stack.
Warning: Do not confuse this method with pop().
public void pushNull()
public void push(IConstruct value)
value - is the value to push onto the stack.public IConstruct peek()
public IConstruct pop()
public java.util.Stack<IConstruct> copyStack()
public boolean isEmpty()
public int size()
public void clear()
public void createModule()
Precondition of the Stack
A module-member is one of:
Postcondition of the Stack
public void createDirectiveModule()
Precondition of the Stack
The name must be null, if the module is anonymous.
Postcondition of the Stack
public void createDirectiveImport()
Precondition of the Stack
Postcondition of the Stack
public void createDefinitionAnnotation()
Precondition of the Stack
Postcondition of the Stack
public void createDefinitionException()
Precondition of the Stack
Postcondition of the Stack
public void createDefinitionDesign()
Precondition of the Stack
Postcondition of the Stack
public void createDefinitionTuple()
Precondition of the Stack
Postcondition of the Stack
public void createDefinitionStruct()
Precondition of the Stack
Postcondition of the Stack
public void createDefinitionFunctor()
Precondition of the Stack
Postcondition of the Stack
public void createDefinitionEnum()
Precondition of the Stack
Postcondition of the Stack
public void createDefinitionFunction()
Precondition of the Stack
Postcondition of the Stack
public void createStatementIf()
Precondition of the Stack
Note: The elif-cases and the else-case are optional.
Postcondition of the Stack
public void createStatementGoto()
Precondition of the Stack
Postcondition of the Stack
public void createStatementMarker()
Precondition of the Stack
Postcondition of the Stack
public void createStatementBranch()
Precondition of the Stack
Postcondition of the Stack
public void createStatementWhen()
Precondition of the Stack
Postcondition of the Stack
public void createStatementForever()
Precondition of the Stack
Postcondition of the Stack
public void createStatementDoWhile()
Precondition of the Stack
Postcondition of the Stack
public void createStatementDoUntil()
Precondition of the Stack
Postcondition of the Stack
public void createStatementBreak()
Postcondition of the Stack
public void createStatementContinue()
Postcondition of the Stack
public void createStatementRedo()
Postcondition of the Stack
public void createStatementForeach()
Precondition of the Stack
Postcondition of the Stack
public void createStatementFor()
Precondition of the Stack
Note: The step is null, iff the step is implicit.
Postcondition of the Stack
public void createStatementWhile()
Precondition of the Stack
Postcondition of the Stack
public void createStatementUntil()
Precondition of the Stack
Postcondition of the Stack
public void createStatementAssert()
Precondition of the Stack
Note: The message must be null, if the message is unspecified.
Postcondition of the Stack
public void createStatementAssume()
Precondition of the Stack
Note: The message must be null, if the message is unspecified.
Postcondition of the Stack
public void createStatementThrow()
Precondition of the Stack
Postcondition of the Stack
public void createStatementTryCatch()
Precondition of the Stack
Note: At least one exception-handler must be provided.
Postcondition of the Stack
public void createComponentExceptionHandler()
Precondition of the Stack
Postcondition of the Stack
public void createStatementVar()
Precondition of the Stack
Postcondition of the Stack
public void createStatementVal()
Precondition of the Stack
Postcondition of the Stack
public void createStatementLet()
Precondition of the Stack
Postcondition of the Stack
public void createStatementNop()
Postcondition of the Stack
public void createStatementReturnValue()
Precondition of the Stack
Postcondition of the Stack
public void createStatementReturnVoid()
Postcondition of the Stack
public void createStatementRecur()
Precondition of the Stack
Postcondition of the Stack
public void createStatementExpression()
Precondition of the Stack
Postcondition of the Stack
public void createStatementSequence()
Precondition of the Stack
Postcondition of the Stack
public void createOperationAs()
Precondition of the Stack
Postcondition of the Stack
public void createOperationIs()
Precondition of the Stack
Postcondition of the Stack
public void createOperationNullCoalescing()
Precondition of the Stack
Postcondition of the Stack
public void createOperationAnd()
Precondition of the Stack
Postcondition of the Stack
public void createOperationOr()
Precondition of the Stack
Postcondition of the Stack
public void createOperationXor()
Precondition of the Stack
Postcondition of the Stack
public void createOperationImplies()
Precondition of the Stack
Postcondition of the Stack
public void createOperationIdentityEquals()
Precondition of the Stack
Postcondition of the Stack
public void createOperationIdentityNotEquals()
Precondition of the Stack
Postcondition of the Stack
public void createOperationEquals()
Precondition of the Stack
Postcondition of the Stack
public void createOperationNotEquals()
Precondition of the Stack
Postcondition of the Stack
public void createOperationLessThan()
Precondition of the Stack
Postcondition of the Stack
public void createOperationLessThanOrEquals()
Precondition of the Stack
Postcondition of the Stack
public void createOperationGreaterThan()
Precondition of the Stack
Postcondition of the Stack
public void createOperationGreaterThanOrEquals()
Precondition of the Stack
Postcondition of the Stack
public void createOperationAdd()
Precondition of the Stack
Postcondition of the Stack
public void createOperationSubtract()
Precondition of the Stack
Postcondition of the Stack
public void createOperationConcat()
Precondition of the Stack
Postcondition of the Stack
public void createOperationMultiply()
Precondition of the Stack
Postcondition of the Stack
public void createOperationModulo()
Precondition of the Stack
Postcondition of the Stack
public void createOperationDivide()
Precondition of the Stack
Postcondition of the Stack
public void createOperationNegate()
Precondition of the Stack
Postcondition of the Stack
public void createOperationNot()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionDispatch()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionNew()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionCallMethod()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionCallStaticMethod()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionSetField()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionGetField()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionSetStaticField()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionGetStaticField()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionInstanceOf()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionTernaryConditional()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionProgn()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionList()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionListComprehension()
Precondition of the Stack
The condition is optional.
Postcondition of the Stack
public void createStatementLambda()
Precondition of the Stack
Postcondition of the Stack
public void createStatementDelegate()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionLocals()
Precondition of the Stack
Postcondition of the Stack
public void createExpressionOnce()
Precondition of the Stack
Postcondition of the Stack
public void createDatum(boolean value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(CharLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(ByteLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(ShortLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(IntLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(LongLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(FloatLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(DoubleLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(BigIntegerLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(BigDecimalLiteral value)
Precondition of the Stack
Postcondition of the Stack
value - is the value that the new datum represents.public void createDatum(boolean verbatim,
java.lang.String value)
Precondition of the Stack
Postcondition of the Stack
verbatim - is false, if the string may contain escape sequences.value - is the value that the new datum represents.public void createDatumClass()
Precondition of the Stack
Postcondition of the Stack
public void createDatumNull()
Precondition of the Stack
Postcondition of the Stack
public void createDatumVariable()
Precondition of the Stack
Postcondition of the Stack
public void createComponentDocComment()
Precondition of the Stack
There may be zero or more lines.
Postcondition of the Stack
public void createComponentDocCommentLine(java.lang.String text)
Precondition of the Stack
There may be zero or more lines.
Postcondition of the Stack
text - is the comment line itself.public void createComponentAnnotation(java.util.List<java.lang.String> values)
Precondition of the Stack
Postcondition of the Stack
values - are the values to store in the annotation.public void createComponentAnnotationList()
Precondition of the Stack
Postcondition of the Stack
public void createComponentTypeSpecifier(java.lang.Integer dimensions)
Precondition of the Stack
Note: The namespace must be null, if the namespace is implicit.
Postcondition of the Stack
dimensions - are the the number of dimensions in the array type.public void createComponentTypeSpecifier()
Precondition of the Stack
Note: The namespace must be null, if the namespace is implicit.
Postcondition of the Stack
public void createComponentVariable(java.lang.String name)
Precondition of the Stack
Postcondition of the Stack
public void createComponentLabel(java.lang.String name)
Precondition of the Stack
Postcondition of the Stack
public void createComponentName(java.lang.String name)
Precondition of the Stack
Postcondition of the Stack
public void createComponentElement()
Precondition of the Stack
Postcondition of the Stack
public void createComponentElementList()
Precondition of the Stack
Postcondition of the Stack
public void createComponentFormalParameter()
Precondition of the Stack
Postcondition of the Stack
public void createComponentFormalParameterList()
Precondition of the Stack
Postcondition of the Stack
public void createComponentNamespace()
Precondition of the Stack
Example: If the namespace is "java.util", then name[0] = "java" and name[1] = "util".
Postcondition of the Stack
public void createComponentConditionalCase()
Precondition of the Stack
Postcondition of the Stack