At the top level, a program consists of a sequence of declarations. The syntax is:
program: implement identifier ; top-declaration-sequence top-declaration-sequence: top-declaration top-declaration-sequence top-declaration top-declaration: declaration identifier-list := expression; identifier-list = expression; ( identifier-list ) := expression; module-declaration function-definition adt-declarationThe
implement
declaration at the start identifies the type of the module that is being implemented. The rest of the program consists of a sequence of various kinds of declarations and definitions that announces the names of data objects, constants, types, and functions, and it creates and initializes the declarations and definitions. It must include a module declaration for the module being implemented and the objects it announces. It can include declarations for the functions, data objects, types, and constants used privately within the module, as well as declarations for modules used by it.
Declarations are used both at the top level (outside of functions) and inside functions and module declarations. Some styles of declaration are allowed only in certain of these places, but all will be discussed together.