Module Simula

Class ConditionalExpression


public final class ConditionalExpression extends Expression
Conditional Expression.
 
 Syntax: 
 
   conditional-expression
       = IF Boolean-expression THEN simple-expression ELSE expression
 
 
Link to GitHub: Source File.
Author:
Øystein Myhre Andersen
  • Field Details

    • condition

      final Expression condition
      The condition.
    • thenExpression

      Expression thenExpression
      The then branch expression
    • elseExpression

      Expression elseExpression
      The else branch expression
  • Constructor Details

    • ConditionalExpression

      ConditionalExpression(Type type, Expression condition, Expression thenExpression, Expression elseExpression)
      Create a new ConditionalExpression.
      Parameters:
      type - expression's type
      condition - the condition
      thenExpression - then branch expression
      elseExpression - 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 class SyntaxClass
    • maybeStatement

      public boolean maybeStatement()
      Description copied from class: Expression
      Returns true if this expression may be used as a statement.
      Specified by:
      maybeStatement in class Expression
      Returns:
      true if this expression may be used as a statement
    • toJavaCode

      public String toJavaCode()
      Description copied from class: SyntaxClass
      Generate Java code for this Syntax Class.
      Overrides:
      toJavaCode in class SyntaxClass
      Returns:
      Java code
    • toString

      public String toString()
      Overrides:
      toString in class Expression