Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adelrizq/a3e
A3E is a simple programming language compiler similar to C++ built using Flex and Bison and a simple GUI for testing.
https://github.com/adelrizq/a3e
a3e bison compiler compiler-design flex lex lexical-analysis semantic-analysis yacc
Last synced: about 2 months ago
JSON representation
A3E is a simple programming language compiler similar to C++ built using Flex and Bison and a simple GUI for testing.
- Host: GitHub
- URL: https://github.com/adelrizq/a3e
- Owner: AdelRizq
- License: mit
- Created: 2022-04-16T13:17:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-13T02:46:57.000Z (over 2 years ago)
- Last Synced: 2023-04-28T08:20:01.877Z (almost 2 years ago)
- Topics: a3e, bison, compiler, compiler-design, flex, lex, lexical-analysis, semantic-analysis, yacc
- Language: Yacc
- Homepage:
- Size: 10.3 MB
- Stars: 11
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![Group 231](https://user-images.githubusercontent.com/40351413/173249976-b40968ad-c8b5-49ea-aac5-9c68692820ef.png)
A3E Compiler
[![GitHub contributors](https://img.shields.io/github/contributors/AdelRizq/A3E)](https://github.com/AdelRizq/A3E/contributors)
[![GitHub issues](https://img.shields.io/github/issues/AdelRizq/A3E)](https://github.com/AdelRizq/A3E/issues)
[![GitHub forks](https://img.shields.io/github/forks/AdelRizq/A3E)](https://github.com/AdelRizq/A3E/network)
[![GitHub stars](https://img.shields.io/github/stars/AdelRizq/A3E)](https://github.com/AdelRizq/A3E/stargazers)
[![GitHub license](https://img.shields.io/github/license/AdelRizq/A3E)](https://github.com/AdelRizq/A3E/blob/master/LICENSE)
## About The Project
> **A3E** is a simple programming language compiler similar to C++ built using Flex and Bison and a simple GUI for testing.
## Try it
- clone/download the repo `git clone https://github.com/AdelRizq/A3E`
- Open `gui.exe`
- Select your file and compile## Build with
- [Flex](http://alumni.cs.ucr.edu/~lgao/teaching/flex.html): Fast Scanner Generator similar to Lex
- [Bison](https://www.gnu.org/software/bison/): Parser Generator similar to Yacc## Screenshots
## Language Description
### Tokens
1. Variables and constants declaration
- Define variable: *datatype id = value;*
- Example: `int a = 5;`
- Define constant: *const datatype id = value;*
- Example: `const int a = 5;`
2. Mathematical and Logical expressions
- Mathematical operations
- +, -, *, /, %
- Logical operations
- ||, &&, ^, !
- \>, <, >=, <=
- Any level of parentheses/complexity.
3. Assignment statements
- Variable = expression
- Example: `a = 5 * b + c;`
4. If-endif, if-else statements5. While loops
6. For loops
7. Repeat until
8. Switch case
9. Block structures
### Quadruples
| Quadruple | Description |
|:-------------:|:-------------------------------------------------------------------------------:|
| ADD s1, s2, R | Pop the top 2 values of the stack (s1, s2) and push s1 + s2 |
| SUB s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push s1 - s2 |
| MUL s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push s1 * s2 |
| DIV s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push s1 / s2 |
| MOD s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push s1 % s2 |
| LT s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push true if s1 < s2 else false |
| GT s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push true if s1 > s2 else false |
| LE s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push true if s1 <= s2 else false |
| GE s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push true if s1 >= s2 else false |
| EQ s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push true if s1 == s2 else false |
| NE s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push true if s1 != s2 else false |
| NOT s1, r | Pop the top 2 values of the stack (s) and push !s |
| AND s1, s2, r | Pop the top 2 values of the stack (s1, s2) and push true if s1 && s2 |
|OR s1, s2, r|Pop the top 2 values of the stack (s1, s2) and push true if s1 || s2|
|XOR s1, s2, r|Pop the top 2 values of the stack (s1, s2) and push s1 ^ s2|
|PUSH value|Push value to the stack|
|POP dst|Pop the top of the stack in into dst|
|L:|Add label with number num|
|JMP L|Unconditional jump to L|
|JZ L|Jump to L if stack top == 0|
|B:|Add break label with the scope number|## Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
1. Fork the Project
2. Create your Feature Branch (`git checkout -b AmazingFeature-Feat`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin AmazingFeature-Feat`)
5. Open a Pull Request## Contributors
- Thanks goes to these awesome people in the team.
## License
- This software is licensed under **MIT License**, See [License](https://github.com/AdelRizq/A3E/blob/main/LICENSE) for more information.