Module Simula

Class UnaryOperation


final class UnaryOperation extends Expression
Unary Operation.
 
 Syntax:
 
   unary-operation =  unary-operator  Expression
   
      unary-operator = NOT | + | -
 
Link to GitHub: Source File.
Author:
Øystein Myhre Andersen
  • Field Details

    • oprator

      final KeyWord oprator
      The unary operator.
    • operand

      Expression operand
      The operand Expression.
  • Constructor Details

    • UnaryOperation

      private UnaryOperation(KeyWord oprator, Expression operand)
      Create a new UnaryOperation.
      Parameters:
      oprator - the unary operator.
      operand - the operand Expression
  • Method Details

    • create

      static Expression create(KeyWord oprator, Expression operand)
      Create a new UnaryOperation.
      Parameters:
      oprator - the unary operator.
      operand - the operand Expression
      Returns:
      the newly created UnaryOperation
    • evaluate

      public Expression evaluate()
      Description copied from class: Expression
      Try to Compile-time Evaluate this expression
      Overrides:
      evaluate in class Expression
      Returns:
      the resulting evaluated expression
    • 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