Module Simula

Class ExternalDeclaration


public final class ExternalDeclaration extends Declaration
External Declaration.
 Simula Standard: 6.1 External declarations
 
   external-head = external-declaration ; { external-declaration ; }
   
   external-declaration
      = external-procedure-declaration | external-class-declaration
 
An external declaration is a substitute for a complete introduction of the corresponding source module referred to, including its external head. In the case where multiple but identical external declarations occur as a consequence of this rule, this declaration will be incorporated only once. External Class Declaration
    external-class-declaration
        =  EXTERNAL  CLASS  external-list
 
An implementation may restrict the number of block levels at which an external class declaration may occur.

Note: As a consequence of 5.5.1 all classes belonging to the prefix chain of a separately compiled class must be declared in the same block as this class. However, this need not be done explicitly; an external declaration of a separately compiled class implicitly declares all classes in its prefix chain (since these will be declared in the external head of the class in question). External procedure declaration

 
 external-procedure-declaration
         = EXTERNAL [ kind ] [ type ] PROCEDURE external-list
         | EXTERNAL kind PROCEDURE external-item  IS procedure-declaration
         
    external-list = external-item { , external-item }
          external-item = identifier [ "=" external-identification ]
 
                 kind  =  identifier  // E.g. FORTRAN, JAVA, ...
                 external-identification = string   // E.g  a file-name
 
 

The kind of an external procedure declaration may indicate the source language in which the separately compiled procedure is written (e.g assembly, Cobol, Fortran, PL1 etc.). The kind must be empty if this language is Simula. The interpretation of kind (if given) is implementation-dependent.

If an external procedure declaration contains a procedure specification, the procedure body of the procedure declaration must be empty. This specifies a procedure whose actual body, which embodies the algorithm required, is supplied in a separate (non-Simula) module. The procedure heading of the procedure declaration will determine the procedure identifier (function designator) to be used within the source module in which the external declaration occurs, as well as the type, order, and transmission mode of the parameters.

A non-Simula procedure cannot be used as an actual parameter corresponding to a formal procedure.

Link to GitHub: Source File.

Author:
SIMULA Standards Group, Øystein Myhre Andersen
  • Constructor Details

    • ExternalDeclaration

      private ExternalDeclaration()
      Create a new ExternalDeclaration.
  • Method Details

    • expectExternalHead

      public static void expectExternalHead(DeclarationList declarationList)
      Parse an external declaration updating a declaration list.
          external-head = external-declaration ; { external-declaration ; }
             external-class-declaration
                  =  EXTERNAL  CLASS  external-list
              
             external-procedure-declaration
                  = EXTERNAL [ kind ] [ type ] PROCEDURE external-list
                  | EXTERNAL kind PROCEDURE external-item  IS procedure-declaration
       
      Precondition: EXTERNAL is already read.
      Parameters:
      declarationList - the declaration list which is updated
    • findJarFile

      private static File findJarFile(String identifier, Token externalIdentifier)
      Find the .jar file containing an external class or procedure.
      Parameters:
      identifier - class or procedure identifier
      externalIdentifier - the external identifier if any
      Returns:
      the resulting File
    • readAttributeFile

      private static Type readAttributeFile(String identifier, File file, DeclarationList declarationList)
      Read an attribute file.
      Parameters:
      identifier - class or procedure identifier
      file - the file to read
      declarationList - the declaration list to update
      Returns:
      the module type
    • expandJarEntries

      private static void expandJarEntries(JarFile jarFile, File destDir) throws IOException
      Expand .jar file entries into the given directory.
      Parameters:
      jarFile - the .jar file
      destDir - the output directory
      Throws:
      IOException - if something went wrong