Chapter 10. Packages and Compilation Units

Table of Contents

10.1. Compilation Units
10.2. Import Declarations

As for the Java programming language, programmes of the XL programming language are organized in a hierarchical structure of packages. A package has subpackages, class and interface types, and class predicates as its members. Class and interface types are declared in compilation units of the package. A compilation unit is normally stored in a single file of source code. For the XL programming language, such a compilation unit has to be either a legal compilation unit in the sense of the Java programming language, or a legal compilation unit as defined in this XL language specification. The former type of compilation units is normally indicated by filenames ending with .java, whereas the latter type is indicated by the suffix .xl.

10.1. Compilation Units

CompilationUnit is the goal symbol for the syntactic grammar of XL programmes. It is defined by the following production:

Compilation Unit
[6]CompilationUnit::=[PackageDeclaration] {ImportDeclaration} {TypeDeclaration}  
[7]PackageDeclaration::=package Name ';'  

This is the same as for the Java programming language. Also the predefined package java.lang is always imported. However, the possibilities for import declarations (Section 10.2, “Import Declarations”) have been extended to static imports.