GazaScript is a Basic Compiler implemented using Flex and Bison. This compiler translates custom source code written in the GazaScript language into executable instructions. The language supports basic arithmetic, logical operations, conditionals, loops, and variable assignments.
- Project Overview
- Getting Started
- Installation
- Usage
- File Structure
- Grammar Overview
- Compilation Process
- Execution Details
- Sample Programs
- License
- Acknowledgments
- Contact Information
GazaScript is designed to be a simple yet powerful language for learning the basics of compiler construction. It supports fundamental programming constructs and serves as an educational tool for understanding lexing, parsing, and abstract syntax trees.
git clone https://github.com/your-username/GazaScript.git
cd GazaScript
Make sure you have Flex and Bison installed on your system. You can install them using your package manager:
sudo apt-get install flex bison # For Ubuntu/Debian
flex 1.l
bison -d 1.y
gcc -o a.exe .\1.tab.c .\lex.yy.c .\SyntaxTree.c
a.exe
./a.exe
1.l
: Contains the lexical analyzer (Flex) definitions.1.y
: Specifies the grammar rules and actions (Bison).SyntaxTree.h
andSyntaxTree.c
: Define and implement the abstract syntax tree (AST) data structure.in.txt
: Input file for GazaScript programs. Place your source code here.out.txt
: Output file where the compiled program's result is stored.outError.txt
: Log file capturing any errors encountered during compilation or execution.tree.txt
: Text file representing the abstract syntax tree (AST) of the GazaScript program.Commands.txt
: Contains commands needed to run the GazaScript compiler and execute programs.
The GazaScript grammar includes terminals, non-terminals, rules, and semantic actions. Refer to the grammar section in the parser file (1.y
) and Syntax-Directed-translation.pdf for a detailed breakdown.
The compilation process involves using Flex to generate the lexer (lex.yy.c
) and Bison to generate the parser (parser.tab.c
). The Makefile streamlines this process.
The generated AST is traversed and executed to interpret GazaScript programs. The execute_ast
function in SyntaxTree.c
handles the interpretation logic.
This project is licensed under the MIT License - see the LICENSE file for details.
-
The creators of Flex and Bison for providing powerful tools for compiler construction.
-
Recommended Tutorials:
For issues, suggestions, or inquiries, please contact [email protected].