asdlGen Reference Manual : Input Syntax : Module Syntax
Previous: Lexical Tokens
Next: Type Definitions

3.2. Module Syntax


module = "module" id [ imports ]"{" definitions "}"
imports = "(" { "imports" id } ")"

An ASDL module declaration consists of the keyword "module" followed by an identifier, an optional set of imported modules, and a sequence of type definitions enclosed in braces. For example the following example declares modules A, B, and C. B imports types from A. C imports types from both A and B. Imports cannot be recursive. It is an error for B to import C, since C also imports B.

 module A { ... } 
 module B (imports A) { ... }
 module C (imports A 
           imports B) { ... }

To refer to a type imported from another module the type must always be qualified by the module name from which is imported. The following declares two different types called "t". One in the A module and one in the B module. The type "t" in the B module defines a type "t" that recursively mentions itself and the type "t" imported from the A module.

module A { t = ... } 
module B (imports A) { t = T(A.t, t) | N  ... }


asdlGen Reference Manual : Input Syntax : Module Syntax
Previous: Lexical Tokens
Next: Type Definitions