Computer Science Master's Project (Second Semester)
MGL is a simple domain-specific language (DSL) for defining and compiling graph-based map structures. It was developed as a university project using C/C++, with inspiration drawn from how maps are represented in computer games.
| Component | Linux(Arch, Ubuntu) | MacOS | Windows (WSL2) |
|---|---|---|---|
| Compiler | GCC ≥ 14.2.1 | CLANG 16+ | GCC via Ubuntu/Arch |
| Assembler | NASM ≥ 2.16.03 | NASM ≥ 2.16.03 | NASM via Ubuntu/Arch |
| Build Tools | CMake ≥ 3.25.1 | CMake ≥ 3.25.1 | CMake ≥ 3.25.1 |
| GNU Make ≥ 4.4.1 | GNU Make ≥ 4.4.1 | GNU Make ≥ 4.4.1 | |
| Demo Tools | Python ≥ 3.13.3 | Python Anaconda ≥ 3.10 | Python ≥ 3.13.3 |
| Environment | - | Sequoia Recommended | WSL2 with Ubuntu/Arch |
Note: All platforms require standard C23/C++23 toolchain support.
- git clone https://github.com/eske4/MGL.git
- cd MGL
- make build
-
Design your map
- File location:
data/input.MF - Basic syntax:
Map Example { Room A; Room B; Connect(A -> B); } - Key rules:
- Map declaration:
Map mapname { ... } - Rooms:
Room RoomName; - Connections:
->for one-way<->for two-way
- End all statements with a semicolon (
;) - See
data/input_example.MFfor complete examples.
- Map declaration:
- File location:
-
Generate assembly
To generate assembly code:
make generate
make runThe validator checks:
- All rooms are traversable
Note: Windows users must use WSL2 to run this.
- Output:
generated/map.asmfile, along with interfaces for communication with the assembly code. - Can be embedded in C, Python, or other tools supporting assembly
| Command | Description |
|---|---|
make |
Full pipeline: (build -> test -> generate) |
make build |
Compile all C/C++ source files |
make generate |
Convert .MF map into assembly code |
make run |
Validate map traversal and integrity |
make test |
Run unit and integration tests |
make clean |
Remove all build artifacts |
make py_demo |
Run Python integration demo (NASM + Python) |
make c_demo |
Run C integration demo (NASM + C) |
Run the verification suite:
make testClean up build artifacts:
make clean- Map generation error: Check
data/input.MFsyntax - Build issues: Confirm compiler supports C++23/C23
- WSL2 users: Make sure it's updated and properly configured
You’ll find example C and Python integrations under demos/.
make c_demo # C integration
make py_demo # Python integrationNote: Win only support quickdemo on WSL2
Note: On macOS, the Python demo requires setting up a Conda Enviroment See Conda Setup. If already done before running quickdemo conda activate my_x86_env
Prefer to build it yourself? Here's how to compile everything manually from the demos/ directory:
C:
nasm -f elf64 map.asm -o map.o
gcc demo.c map.o -o demo
./demoPython:
nasm -f elf64 map.asm -o map.o
gcc -shared map.o -o map.so
python demo.pyC:
nasm -f macho64 map_mac.asm -o map.o
arch -x86_64 clang demo.c map.o -o c_demo
./c_demoConda Setup
conda create -n my_x86_env -y
conda activate my_x86_env
conda config --env --set subdir osx-64
conda install python=3.10Python (with Conda):
conda activate my_x86_env
nasm -f macho64 map_mac.asm -o map.o
arch -x86_64 clang -shared map.o -o map.so
python demo.pyUse WSL2 and follow Linux instructions.
Alternatively, for native Windows builds:
- Install Chocolatey
- Use Chocolatey to install MSYS2
- Add to PATH:
C:\tools\msys64\mingw64\bin - In MSYS2 terminal:
pacman -S make gcc cmake nasm python
Then:
winmake.bat build
winmake.bat c_demo
winmake.bat py_demoFor manual compilation, refer to the commands inside winmake.bat
If Python demo fails, ensure MSYS2’s Python is being used, not the system default.
- [Eske Klintø Larsen] - [eske.larsen@gmail.com]
- [Faustas Anulis] - [faustis1337@gmail.com]
- [Mathias Holm Mariager] - [math214j@hotmail.com]
- [Toms Vanders] - [toms.vanders@gmail.com]
- [Thormod Jakob Schøn Merstrand] - [thormodx@gmail.com]