Module Simula

Class MaybeBlockDeclaration


public final class MaybeBlockDeclaration extends BlockDeclaration
Maybe Block Declaration. I.e: CompoundStatement or SubBlock depends on whether it contains declarations.
 Simula Standard: 4.9 Compound statement
 Simula Standard: 4.9 Blocks
  
   MaybeBlockDeclaration = compound-statement | subblock
 
            compound-statement = BEGIN [ { statement ; } ] END

            subblock = BEGIN [ { declaration ; } ]  [ { statement ; } ] END

 
Link to GitHub: Source File.
Author:
SIMULA Standards Group, Øystein Myhre Andersen
  • Constructor Details

    • MaybeBlockDeclaration

      public MaybeBlockDeclaration(String identifier)
      Create a new MaybeBlockDeclaration.
      Parameters:
      identifier - block identifier
  • Method Details

    • createMainProgramBlock

      public static MaybeBlockDeclaration createMainProgramBlock()
      Create the main program block. Used by ProgramModule.
      Returns:
      the main program block
    • parseMaybeBlock

      public BlockStatement parseMaybeBlock(int line)
      Parse CompoundStatement or SubBlock.
       Syntax:
       
       Block = CompoundStatement | SubBlock
       
               CompoundStatement = BEGIN [ { Statement ; } ] END
               SubBlock = BEGIN [ { Declaration ; } ]  [ { Statement ; } ] END
      
       
      Parameters:
      line - source line number
      Returns:
      a BlockStatement
    • moveLabelsFrom

      static void moveLabelsFrom(DeclarationScope block)
      Utility: Moves labels from the givent block.

      Special case: Labels in a CompoundStatement or ConnectionBlock.

      Move Label Declaration to nearest enclosing Block which is not a CompoundStatement or ConnectionBlock.

      Parameters:
      block - the block containing labels to be moved
    • doChecking

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

      This must be redefined in every subclass.

      Overrides:
      doChecking in class SyntaxClass
    • findVisibleAttributeMeaning

      public Meaning findVisibleAttributeMeaning(String ident)
      Description copied from class: DeclarationScope
      Find visible attribute's Meaning
      Overrides:
      findVisibleAttributeMeaning in class DeclarationScope
      Parameters:
      ident - attribute identifier
      Returns:
      the resulting Meaning
    • doJavaCoding

      public void doJavaCoding()
      Description copied from class: SyntaxClass
      Output Java code.
      Overrides:
      doJavaCoding in class SyntaxClass
    • doCompoundStatementCoding

      private void doCompoundStatementCoding()
      Code utility: Code compound statement
    • doSubBlockCoding

      private void doSubBlockCoding()
      Code utility: Code sub-block
    • doCodeConstructor

      private void doCodeConstructor()
      Code utility: Code constructor
    • doCodeStatements

      private void doCodeStatements()
      Code utility: Code statements
    • print

      public void print(int indent)
      Description copied from class: SyntaxClass
      Utility print method.
      Overrides:
      print in class SyntaxClass
      Parameters:
      indent - number of spaces leading the line
    • 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 BlockDeclaration