AdelRizq / A3E

A3E is a simple programming language compiler similar to C++ built using Flex and Bison and a simple GUI for testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A3E Compiler

GitHub contributors GitHub issues GitHub forks GitHub stars GitHub 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: Fast Scanner Generator similar to Lex
  • 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;

  1. If-endif, if-else statements


  1. While loops


  1. For loops


  1. Repeat until


  1. Switch case


  1. 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
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.
Eman Othman
Eman Othman

Adel Rizq
Adel Rizq

Abdallah Hemdan
Abdallah Hemdan

Ahmed Mahboub
Ahmed Mahboub

License

  • This software is licensed under MIT License, See License for more information.

About

A3E is a simple programming language compiler similar to C++ built using Flex and Bison and a simple GUI for testing.

License:MIT License


Languages

Language:Yacc 72.5%Language:Python 18.3%Language:Lex 5.6%Language:C++ 3.2%Language:Batchfile 0.4%