Java Python COMP6580: Programming Language Implementation
In this mini-project, you will add a feature to a simple imperative programming language.
Project structure
We have prepared a basic example compiler and interpreter written in OCaml on Kent’s Git-
Lab installation https://git.cs.kent.ac.uk/mjb211/example-compiler. It compiles a simple imperative language with arrays and loops into x86-64 assembly code, or alternately, can interpret these programs. You will implement a parallel assignment feature, explained below, in the parser,type checker, and either the interpreter or the compiler (your choice).
What to hand in
Submit on Moodlea .zip file of the compiler source files that you modified, and a (maximum) 1-page document explaining what you did, and to what extent your project works or does not work and why.
Parallel assignment
Add a new kind of statement whose syntax is as follows.
identifiers ::=
| identifier
| identifier identifiers
atomic_exps ::=
| atomic_exp
| atomic_exp atomic_exps
s COMP6580: Programming Language ImplementationR tmt ::=
...
| parallel identifiers := atomic_exps
This will require modifying the lexer with the new keyword parallel, and also extending the abstract syntax and parser for the new non-terminals and statement form. The type checker should be extended to check parallel assignments: the number of identifiers must be the same as the number of atomic expressions, and each identifier should have the same type as its corresponding expression.
To update the compiler (if this is your choice), you should add a new compilation pass that runs immediatelyaftertypecheckingandconvertseachparallelstatementintoasequenceofnormal assignments. To update the interpreter (if this is your choice), the interp_stmt function will need to be extended with an extra case for parallel.
The semantics of parallel assignment is that each variable is assigned the value of the corresponding expression, and that all of the assignments happen at the same time, after the expressions are evaluated. For example, after running the following statements, the value in x is 301, in y is 21, and in z is 2