8 — Modules
Due Thursday, 30 October 2025, 11:59:59pm
Purpose to build a model of a language with a simple module system
Delivery Deliver your solutions in a directory called 8 within your assigned GitHub repository. The directory should contain the following items:
the executables xmodule as specified below;
the sub-directory 8/Tests/ with the required integration test; and
an optional sub-directory called 8/Other/ for all auxiliary files.
Programming Task Using your favorite programming language, you are to create a syntax model of the Module language, a revision of Class with a simple module system. This task requires (1) the extension of the parser, which maps ExampleEE expressions to ASTs; (2) a validity-checking checker; and (3) a linker, which eliminates modules and construct a conventional Class program.
ExampleEE is an Example whose Names also contain the following keywords: if0, while0, block, def, =, /, +, ==, class, method, isa, new, –>, module, import.
A module is a lexical region in which the module’s imports are visible.
A system’s body consists of the potentially empty sequence of import specifications that follow the module sequence, the declarations, the statements, and the return expression.
The body of a system is a lexical region in which the imported classes are visible.
The implementation of the parser should adapt your solution to 6 —
No two modules in a system may have the same ModuleName.
Every import specification must refer to a ModuleName that is defined in the preceding sequence of modules. This includes the import specifications in the body of the system.
Each module must be closed with respect to collection of imported classes.
The system’s body must be closed with respect to collection of imported classes.
First, it replaces all occurrences of any ClassName with its fully-qualified name.
If module M defines class C, the fully qualified name is M.C—
that is, a name that is illegal in the surface syntax and guaranteed to be unique. Second, it strips the module and import forms from the AST.
If more than one import in a sequence of import specification refers to the same ClassName, the linker uses the last one in the sequence to construct a fully-qualified name. If any imported ClassName coincides with the name of the module’s class definition, it is shadowed.
System ::= (Module^*
Import^*
Declaration^*
Statement^*
Expression)
Module ::= (module ModuleName Import^* Class)
Import ::= (import ModuleName)
The set of ModuleNames is the same as the set of Variables.
"parser error" if the given ExampleEE is not an element of the Module grammar;
"duplicate module name" if in the well-formed Module system two of the module definitions come with the same name;
"duplicate method, field, or parameter name" if in the well-formed Module system at least one class definition comes with two fields or methods that have the same name;
"undeclared variable error" if in the well-formed Module system one of its variable occurrences comes without declaration or one occurrence of a ClassName in a statement or an expression comes without class definition;
"object" if the CESK machine produces an object for the well-formed and valid Module system;
a number n if the CESK machine produces a number n for the well-formed and valid Module system;
"run-time error" if the CESK machine produces an error outcome for the well-formed and valid Moduled system.
Testing Task Create 10 integration tests for xmodule.
A test always consists of inputs, expected
output, and an automated procedure for comparing the actual output
with the expected one. —