C compiler written in Elixir for the Compilers class at National Autonomous University of Mexico School of Engineering.
Entire documentation:
- Elixir
- Mix
-
Clone this repository
git clone https://github.com/hiphoox/c202-assembly cd c202-assembly/assembly
-
Compile it
mix escript.build
-
Run it (just an example)
./assembly examples/test.c
Note: if you want to run your own C example just pass the path to that file after
./assembly <path-to-your-file>
-
Test it
mix test
Compilers are computer programs that translate a program written in one language into a program written in another language
[Cooper, Torczon] (pg. 1)
In this project, we will be building a C compiler written in Elixir that compiles into x86 assembly code. The compiler will recognize the following C program structure:
int main() {
return "<exp>"; //"<exp>" will be substituted by several expressions.
}
The expressions the compiler will recognize are the following:
-
Integers
int main() { return 23; }
-
Unary operators
int main() { return -23; //negation (-), bitwise complement (~), logical negation (!) }
-
Binary operators
int main() { return 2 + 3; //addition (+), multiplication (*), division (/) }
-
More binary operators
int main() { return 2 && 3; //logical AND (&&), logical OR (||), equal to (==), not equal to (!=), less than (<), less than or equal to (<=), greater than (>), greater than or equal to (>=) }
- Teams of 4 members.
- Everything delivered through Git and Github.
- 30 minute working demo to the class.
- Project manager: sets the project schedule, holds weekly meetings, mantains a project log and makes sure the project deliverables get done on time.
- System Architect: defines the compiler architecture, modules and interfaces.
- System Integrator: defines the system development platforms and tools, the integration environment, and a build file to ensure the compiler components work together -> he needs to use Git correctly.
- Tester: defines the test plan and AUTOMATED TESTS. Each team member is expected to execute the test suites as the compiler is being developed to make sure the compiler meets the language specification.
- Domain expert: helps explain compiler concepts, characteristics, how they work and the best way to interpret them.
- Customer: defines what he wants, in this specific case, the compiler features.