M2C is a modular Morse-flavored compiler that reads .cym2c programs, tokenizes them, parses a small statement-level IR, generates GNU assembly, links against an assembly runtime library, and produces a native executable.
CLI input
-> main.cpp
-> Lexer
-> std::vector<Token>
-> Parser
-> std::vector<Statement>
-> CodeGenerator
-> temp.s
-> runtime/io.s + runtime/math.s
-> gcc -no-pie
-> executable
- lexer/include/lexer.h
- lexer/include/token_types.h
- lexer/include/morse.h
- lexer/source/lexer.cpp
- lexer/source/morse.cpp
The current pipeline is built around these concrete data shapes:
Produced in main.cpp from:
m2c <input.cym2c> -o <output_binary>
Produced by the lexer:
struct Token
{
TokenType type;
std::string value;
int line;
};Produced by the parser inside statements.
The current parsed IR node:
PrintStringPrintValueVariableAssignmentArithmeticAssignment
- root build and run flow
- file-based lexing
- Morse decoding for quoted strings
- token stream production
- parser validation for print and assignment statements
- simple declaration-before-use checks
- pure assembly output
- runtime-backed printing and arithmetic
- automatic assembly/link step
<".... . .-.. .-.. ---">;
<x>;
<42>;
let x = 5;
let y = x;
let a = 5 + 3;
let b = a * 2;
let c = b - 4;
let d = c / 2;
bash build.shThis produces:
./m2c_bin
bash run.sh m2c_files/test_math.cym2c demo_mathOr directly:
./m2c_bin m2c_files/test_math.cym2c -o demo_mathThe generator links against:
m2c_printm2c_print_int
m2c_addm2c_subm2c_mulm2c_div
This keeps generated assembly smaller and gives the codebase real reusable assembly modules.
- deep technical walkthrough: working.md
- contributor guide: contribution.md
- alternate contributor entry: CONTRIBUTING.md
- lexer internals: lexer/readme.md
- parser internals: syntaxer/readme.md
- generator internals: generators/readme.md
- semantic-analysis plan: semanter/readme.md
- optimizer plan: optimizers/readme.md