Module Simula

Class SimpleVariableDeclaration

All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
LabelDeclaration

public sealed class SimpleVariableDeclaration extends Declaration implements Externalizable permits LabelDeclaration
Simple Variable Declaration.
 
 Simula Standard: 5.1 Simple variable declarations
 
  simple-variable-declaration
        =  type  type-list

    type-list
        =  type-list-element  { , type-list-element }

    type-list-element
        =  identifier
        |  constant-element 
 
    constant-element
        =  identifier  "="  value-expression
        |  identifier  "="  text-expression
   
 
Link to GitHub: Source File.
Author:
SIMULA Standards Group, Øystein Myhre Andersen
See Also:
  • Field Details

    • constant

      private boolean constant
      Constant indicator. Is used to prevent assignment of a new value.
    • constantElement

      public Expression constantElement
      The constant initial value.
  • Constructor Details

    • SimpleVariableDeclaration

      public SimpleVariableDeclaration(Type type, String identifier)
      Create a new SimpleVariableDeclaration.
      Parameters:
      type - the variable type
      identifier - the variable identifier
    • SimpleVariableDeclaration

      SimpleVariableDeclaration(Type type, String identifier, boolean constant, Constant constantElement)
      Create a new SimpleVariableDeclaration.
      Parameters:
      type - the variable type
      identifier - the variable identifier
      constant - the constant indicator
      constantElement - a constant initial value
    • SimpleVariableDeclaration

      public SimpleVariableDeclaration()
      Default constructor used by Externalization.
  • Method Details

    • isConstant

      public boolean isConstant()
      Constant indicator. Is used to prevent assignment of a new value.
      Returns:
      the constant indicator
    • expectSimpleVariable

      static void expectSimpleVariable(Type type, DeclarationList declarationList)
      Parse a simple variable declaration.
       
       Syntax:
       
        simple-variable-declaration
              =  type  type-list
      
          type-list
              =  type-list-element  { , type-list-element }
      
          type-list-element
              =  identifier
              |  constant-element 
       
          constant-element
              =  identifier  "="  value-expression
              |  identifier  "="  text-expression
         
       
      Precodition: Type is already read.
      Parameters:
      type - the variable type
      declarationList - the declaration list to update
    • doChecking

      public void doChecking()
      Description copied from class: SyntaxClass
      Perform semantic checking.

      This must be redefined in every subclass.

      Overrides:
      doChecking in class SyntaxClass
    • doDeclarationCoding

      public void doDeclarationCoding()
      Description copied from class: SyntaxClass
      Output possible declaration code.
      Overrides:
      doDeclarationCoding in class SyntaxClass
    • toJavaCode

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

      public void printTree(int indent)
      Description copied from class: SyntaxClass
      Utility print syntax tree method.
      Overrides:
      printTree in class SyntaxClass
      Parameters:
      indent - number of spaces leading the lines
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeExternal

      public void writeExternal(ObjectOutput oupt) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput inpt) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException