Case study 03 / Coursework
LALG Compiler and Interpreter.
From source text to an executable intermediate representation.
01 The problem
A small teaching language needs a way to recognize valid source, track identifiers and scope, and execute programs.
02 The solution
This coursework implements a Python toolchain for LALG, with a desktop interface and sample inputs that exercise valid programs and error cases.
03 The architecture
The lexical and syntax modules use PLY. Scope and symbol-table modules track declarations. Code generation builds an intermediate representation, which a separate interpreter executes. PyQt provides the desktop interface.
- 01Source & parseTokens, grammar, and scope
- 02GenerateIntermediate instructions
- 03InterpretExecute generated instructions
04 Engineering decisions
The intermediate representation gives parsing and execution a visible boundary. Sample programs make it possible to inspect how constructs such as branches and loops pass through that boundary and to exercise error handling independently of the UI.