https://github.com/colleagueriley/c-minus
An independent C-like language compiler experiment for i386.
https://github.com/colleagueriley/c-minus
Last synced: over 1 year ago
JSON representation
An independent C-like language compiler experiment for i386.
- Host: GitHub
- URL: https://github.com/colleagueriley/c-minus
- Owner: ColleagueRiley
- License: cc0-1.0
- Created: 2025-01-26T18:56:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-27T02:56:29.000Z (over 1 year ago)
- Last Synced: 2025-01-27T03:26:06.517Z (over 1 year ago)
- Language: C
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# C-Minus

An independent C-like language compiler experiment for i386.
The purpose of this program is to have a better idea of how programming languages work under the hood. This compiler is not a real C compiler. The compiler is not, and probably will never be, compliant with the C standard. For the most part, performance and flexibility has been sacrficied for quick solutions.
Currently this compiler targets linux, as it uses linux syscalls.
# stb_c_lexer.h
C-Minus uses a modified version of `stb_c_lexer.h` for lexing C, this allows me to focus on parsing the C tokens directly to assembly. Modified aspects are labled.
# current restrictions
* Only 32bit variables are supported
* the compiler mostly uses the `eax` register.
* missing functionality (see TODO)
* max number of nested stacks: 1024
* max symbol length: 255
* max number of symbols (per stack): 1024
* max number of function arguments: 20
# supported features
* declarations
```c
int func();
int a;
```
* definitions
```c
void func() {
}
int a = 5;
int b = 5;
a = 10;
b = 9
```
* scopes
```c
int a;
int b;
void func() {
int a = b;
}
```
* functions calls
```c
int f = 9;
void func(int b, int c, int e) {
int a = b;
}
int main() {
int g = 4;
func(1, f, g);
}
```