|
| |
| Navigation |
Synopsis Declare a module.
Syntax
module Name Imports; Declaration1; ... Declarationn;
Description A module declaration consists of:
Name will be used when the current module is imported in another module.
A module name is in general a qualified name of the form:
Name1::Name2:: ... ::Namenwhich corresponds to a path relative to the root of the current workspace. The constituents of a module are shown in the figure below.
An Import declares other modules that are used by the current module. Following imports, a module may contain declarations (in arbitrary order, but a SyntaxDefinition can occur directly following the imports) for: Each declaration may contain a private or public keyword that determines
the visibility of the declared entity.
The entities that are visible inside a module are
Module::NameEach module resides in a separate file with extension .rsc.
Examples Here is the
Hello module:
module demo::basic::Hello
import IO;
void hello() {
println("Hello world, this is my first Rascal program");
}
It defines a module with the name demo::basic::Hello and imports the IO library.
Finally, it declares the hello function.
The actual source of this module can be found in library/demo/basic/Hello.rsc in the Rascal sources.
More ways to write this example are discussed in Recipes:Hello. |