Arabic-compiler is a compiler project designed to process a programming language with Arabic-like or right-to-left (RTL) syntax. The project leverages Flex (for lexical analysis) and Bison (for parsing) to translate source code into an intermediate representation, supporting features such as symbol tables, quadruplets (for intermediate code), and control flow constructs.
- Lexical analysis using Flex (
analyseur.l) - Syntax analysis using Bison (
parser.y) - Symbol table management (
symbolTable.c,symbolTable.h) - Intermediate code generation with quadruplets (
quadruplet.c,quadruplet.h) - Stack management for expressions and control flow (
pile.c,pile.h) - Support for conditional statements, loops, functions, and logical expressions
- Test suite with various example programs in the
tests/directory
analyseur.l: Flex file for lexical analysisparser.y: Bison file for grammar and parsing rulessymbolTable.c/h: Implementation of the symbol tablequadruplet.c/h: Intermediate code (quadruplet) generation and managementpile.c/h: Stack utilities for parsing and code generationoutput.txt: Output file for generated code or resultstests/: Directory containing sample source files and test cases
- Make sure you have Flex and Bison installed on your system.
- Generate the lexer and parser:
This will produce an executable named
flex analyseur.l bison -d parser.y gcc -o Arabic-compiler lex.yy.c parser.tab.c symbolTable.c quadruplet.c pile.c -lfl
Arabic-compiler(orArabic-compiler.exeon Windows).
To compile a source file, run:
./Arabic-compiler < input_file.rtlReplace input_file.rtl with the path to your source code. Output and intermediate results will be written to output.txt.
Sample test files are available in the tests/ directory. You can try them with:
./Arabic-compiler < tests/test.txtCheck output.txt for the results.