Package compilation.analysis.syntax
Class ConditionalStatement
- java.lang.Object
-
- compilation.analysis.syntax.ConditionalStatement
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConditionalStatement.ElseStatementThe ElseStatement class is used to store information about else statements declared during compilation.
-
Constructor Summary
Constructors Constructor Description ConditionalStatement(Token ifToken, Expression condition, Statement thenStatement)Constructs a ConditionalStatement object, initialised with the statements contents.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddElseStatement(Token elseToken, Statement statement)Adds an ElseStatement to this ConditionalStatement, which will run if the condition is false.booleanincludesElseStatement()Returns a boolean to indicate if a ConditionalStatement contains an ElseStatement.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface compilation.analysis.syntax.Statement
getChildren, getSpan, getStatementType
-
-
-
-
Constructor Detail
-
ConditionalStatement
public ConditionalStatement(Token ifToken, Expression condition, Statement thenStatement)
Constructs a ConditionalStatement object, initialised with the statements contents.A SourceSpan containing the range of the statement is automatically generated, as well as a LinkedList of its children.
- Parameters:
ifToken- The if Tokencondition- The condition Expression for the then Statement to runthenStatement- The Statement to be run if the condition is true
-
-
Method Detail
-
addElseStatement
public void addElseStatement(Token elseToken, Statement statement)
Adds an ElseStatement to this ConditionalStatement, which will run if the condition is false.- Parameters:
elseToken- The else Tokenstatement- The Statement to be run if the condition is false
-
includesElseStatement
public boolean includesElseStatement()
Returns a boolean to indicate if a ConditionalStatement contains an ElseStatement.- Returns:
- A boolean indicating if an else is present
-
-