https://github.com/tuke307/cau-simplified-c-compiler
https://github.com/tuke307/cau-simplified-c-compiler
c compiler
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/tuke307/cau-simplified-c-compiler
- Owner: tuke307
- Created: 2024-05-29T01:42:57.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-07T04:31:48.000Z (almost 2 years ago)
- Last Synced: 2025-02-14T05:41:19.138Z (over 1 year ago)
- Topics: c, compiler
- Language: Python
- Homepage:
- Size: 179 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# simplified-c-compiler
## requirements
* python 3.7
## usage
```bash
python src/syntax_analyzer.py
```
Input:
* A sequence of tokens (terminals) written in the input file (see the [example inputs](#example-input) section for more details)
Output
* accept: parse tree for the input sequence
* reject: error report
## example input
### [basic variable declaration](input/basic_variable_declaration.txt)
```c
int x;
```
### [variable assignment](input/variable_assignment.txt)
equivalent code;
```c
int x = 10;
```
### [function declaration no args](input/function_declaration_no_args.txt)
```c
int main() {
return 0;
}
```
### [function declaration args and statements](input/function_declaration_statement.txt)
```c
int func(int a, int b, int c) {
int x;
return 0;
}
```
### [if statement](input/if_statement.txt)
```c
int main() {
if (true == true) {
x = 10;
}
return x;
}
```
### [if else statement](input/if_else_statement.txt)
```c
int main() {
if (true == true) {
x = 10;
} else {
x = 20;
}
return x;
}
```
### [while loop assignment](input/while_loop_assignment.txt)
```c
int main() {
while (true) {
x = 10;
}
return x;
}
```