LME Luna Machine Executable
- 5 Devlogs
- 7 Total hours
My own compiler from scratch. Language: C++, Target: x86-64 assembly (NASM), Syntax Language: Turkish, File Extension: .lme, Name: LME (luna machine executable)
My own compiler from scratch. Language: C++, Target: x86-64 assembly (NASM), Syntax Language: Turkish, File Extension: .lme, Name: LME (luna machine executable)
LME My own Compiler Devlog #5
Finished the first real end-to-end version of Luna today.
Wrote generation.h - takes the parse tree from the parser and walks it to spit out x86-64 NASM assembly. Right now it just handles the one node type I have (NodeExit) and generates the mov/syscall pair for exiting with a given code.
Rewired main.cpp so it actually uses the tokenizer -> parser -> generator pipeline properly instead of skipping straight from tokens to asm like before. Cleaner flow now:
source -> tokens -> parse tree -> asm -> nasm -> ld -> binary
Tested it with:
cik 42;
Compiled clean, ran the output binary, echo $? gave 42. First time the whole pipeline worked end to end without me hand-patching anything.
Also wrote a proper README and a .gitignore so I can actually put this on GitHub without dumping build folders and .idea junk into the repo.
Still only supports one statement (cik ;), no variables or math yet. Next up: probably adding a second statement type so the parser/generator actually have to branch on something.
DEVLOG #4
Took me allot to understand how a parse tree/Syntax tree works and how to programm it.
So I will be using the recursive descent technique and making nodes for each production.
Cleaned up code, made another file for the tokenization(lexer) almost at parsing tree (
[ SOURCE CODE ]
│
“there are two types of programmers - those who have written a compiler and those who haven’t”
-Terry Davis
LME My own Compiler Devlog #2
I got the basic compiler pipeline working for Luna.I implemented a tokenizer that converts Luna source code into tokens, including:cik → exit token integers → integer literals; → semicolon token then added code generation that converts the tokens into x86-64 NASM assembly using the Linux exit syscall.For example: cik 42; gets compiled into assembly that exits the program with status code 42.I also fixed a bounds-checking bug in the token parser and verified that the generated executable runs correctly under Linux/WSL.The basic pipeline is now:Luna source → tokenizer → tokens → x86-64 assembly → executable
Next step is the Parse Tree
Building my own compiler (vexa compiler) devlog #1
Semicolon based, whitespace does not matter.
File ending will be .tr so main.tr.
Syntax language will be turkish.
Now writing the tokenization stuff