A compiler for a simple programming language, built as a learning project for compiler design.
358
A custom compiler for a simple hobby programming language, built primarily as a learning project to explore compiler design, lexical analysis (Flex), parsing (Bison), symbol tables, and basic interpretation and assembly code generation(codeGen, using MASM32).
Focus: Understanding the logic and grammar implementation rather than creating a polished production language.
func_begin … func_enddesign intvar name; / design strvar name;/design intvar x=5;calc expression to var;read var;visible expr; or visible nl; (newline)while condition: … ; (nested supported)check condition: … ; default: … ;+ - * < > == != <= >="text"// …func_begin
design intvar a;
read a;
design strvar s; calc " " to s;
design strvar tr; calc "^" to tr;
while design intvar t = 0; t<a; calc t+1 to t; :
while design intvar j = 0; j<a-t; calc j+1 to j; : visible s; ;
while design intvar j = 0; j<2*t-1; calc j+1 to j; : visible tr; ;
visible nl;
;
func_end
More example programs named input.txt, input2.txt are included in the image.
docker pull miraz173/hobby-compiler
docker run --rm -it miraz173/hobby-compiler
# Build compiler
make createCompiler
# Run input program
make compile
Educational project to understand:
TLDR; Note: The docker image does not contain the masm32 as masm32 runs on windows only and running it through wine doesn't work as masm32 installation needs GUI which is not available in docker system. In order to run the output.asm, install masm32 in your windows machine or install it via wine in your local host machine. The image only supports compilerCode(s)->compiler.exe/.out, program.txt->token.txt->intermediate.txt->output.asm, output.asm->output.exe is not available in this image as it would require running masm32 via wine.
The Docker image does not include MASM32 (Microsoft Macro Assembler) or any Windows-specific assembly toolchain, as
The container contains your compiler and can fully process input programs up to the assembly stage:
program.txt
↓ (hobby_compiler)
token.txt → intermediate.txt → output.asm
text- You get a clean output.asm file (x86 assembly code).
It cannot assemble or link output.asm → output.exe because:
Option 1 – On Windows host
Install the MASM32 SDK on your Windows machine:
http://www.masm32.com/ (classic installer, ~10 MB)
Copy output.asm from the Docker container to your Windows host:
docker cp <container_id>:/app/output.asm ./output.asm
Compile the output.asm file using masm32
C:\masm32\bin\ml /c /coff /Cp output.asm && C:\masm32\bin\link -entry:main /subsystem:console output.obj && output
Option 2 - ON Linux host:
Install Wine and MASM32(guide)
Download source code
Use Makefile to run the program
make main
Happy tinkering!
—Miraz, Dhaka 2026
Content type
Image
Digest
sha256:2747f36fb…
Size
99.6 MB
Last updated
8 months ago
docker pull miraz173/hobby_compiler