java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.expression.Expression
simula.compiler.syntaxClass.expression.ConditionalExpression
Conditional Expression.
Syntax: conditional-expression = IF Boolean-expression THEN simple-expression ELSE expressionLink to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Field Summary
Modifier and TypeFieldDescription(package private) final Expression
The condition.(package private) Expression
The else branch expression(package private) Expression
The then branch expressionFields inherited from class simula.compiler.syntaxClass.expression.Expression
backLink, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
lineNumber
-
Constructor Summary
ConstructorDescriptionConditionalExpression
(Type type, Expression condition, Expression thenExpression, Expression elseExpression) Create a new ConditionalExpression. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Perform semantic checking.boolean
Returns true if this expression may be used as a statement.Generate Java code for this Syntax Class.toString()
Methods inherited from class simula.compiler.syntaxClass.expression.Expression
acceptExpression, checkCompatibility, evaluate, expectExpression, get, getInt, getNumber, getQualification, getWriteableVariable, printTree, put
Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED
-
Field Details
-
condition
The condition. -
thenExpression
Expression thenExpressionThe then branch expression -
elseExpression
Expression elseExpressionThe else branch expression
-
-
Constructor Details
-
ConditionalExpression
ConditionalExpression(Type type, Expression condition, Expression thenExpression, Expression elseExpression) Create a new ConditionalExpression.- Parameters:
type
- expression's typecondition
- the conditionthenExpression
- then branch expressionelseExpression
- else branch expression
-
-
Method Details
-
doChecking
public void doChecking()Description copied from class:SyntaxClass
Perform semantic checking.This must be redefined in every subclass.
- Overrides:
doChecking
in classSyntaxClass
-
maybeStatement
public boolean maybeStatement()Description copied from class:Expression
Returns true if this expression may be used as a statement.- Specified by:
maybeStatement
in classExpression
- Returns:
- true if this expression may be used as a statement
-
toJavaCode
Description copied from class:SyntaxClass
Generate Java code for this Syntax Class.- Overrides:
toJavaCode
in classSyntaxClass
- Returns:
- Java code
-
toString
- Overrides:
toString
in classExpression
-