Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

222 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SamCompiler

A C compiler built from scratch. Compiles a subset of the C programming language down to 32-bit Intel assembly, with a preprocessor, parser, resolver, code generator, and semantic validator.

Layout

Path What it does
main.c Driver: calls compile_file on ./test.c.
compiler.c/.h Top-level pipeline: lex -> parse -> codegen.
cprocess.c compile_process create/teardown (input/output streams).
helpers/ buffer (dynamic byte buffer), vector (dynamic array).
tests/ Bash end-to-end tests, numbered, one per meaningful step.
docs/ Chapter notes and gotchas.
docs/gotchas/ Per-bug write-ups, one file per Gxx follow-up commit.

Build

./build.sh        # clean + make
./main            # runs the compiler on ./test.c

Test

bash tests/run-all.sh

About

Developed a C compiler, implementing a custom lexer, preprocessor, recursive-descent parser, tag-union AST, semantic validator, identifier resolver, and an x86 code generator emitting NASM under cdecl. Tech: C, x86 NASM, cdecl ABI, ELF32, gcc-multilib, bash, gdb, Linux

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages