https://github.com/swarnimwalavalkar/a-compiler
An extraordinarily simple BSAIC to C compiler
https://github.com/swarnimwalavalkar/a-compiler
c compiler python
Last synced: 2 months ago
JSON representation
An extraordinarily simple BSAIC to C compiler
- Host: GitHub
- URL: https://github.com/swarnimwalavalkar/a-compiler
- Owner: SwarnimWalavalkar
- Created: 2021-03-07T13:53:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-07T14:04:23.000Z (over 5 years ago)
- Last Synced: 2025-05-15T14:09:59.535Z (about 1 year ago)
- Topics: c, compiler, python
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A Compiler
An extraordinarily simple implementation of a BSAIC-like-dialect language to C compiler to learn the fundamentals of Compiler Design.
It supports:
- Numerical variables
- Basic arithmetic
- If statements
- While loops
- Print text and numbers
- Input numbers
- Labels and goto
- Comments
## Dependencies
- Python >= 3
- GCC >= 9
## Build an example program with build.sh
Compile:
```bash
bash build.sh ./examples/hello.a
```
Run:
```bash
./build/hello.exe
```
Expected Output:
```bash
Hello, World!
```
## Manually compile an example program
Compile into C:
```bash
python3 a.py ./examples/hello.a
```
Compile C code with your preffered C compiler:
```bash
gcc out.c
```
Run the outputted binary:
```bash
./a.exe
```
Expected Output:
```bash
Hello, World!
```