{"id":30141093,"url":"https://github.com/badawy403/compilerproject","last_synced_at":"2025-10-06T18:45:48.767Z","repository":{"id":274101784,"uuid":"905871128","full_name":"Badawy403/CompilerProject","owner":"Badawy403","description":"This project involves creating a custom programming language and its compiler for a coursework project. The compiler will parse and execute code written in the new language, focusing on fundamental programming concepts like variables, conditionals, and loops. The goal is to understand language design and the compilation process.","archived":false,"fork":false,"pushed_at":"2025-01-24T21:40:16.000Z","size":32247,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T07:25:11.576Z","etag":null,"topics":["bison","c","compiler","gui","lex","lex-yacc","tkinter-python","yacc"],"latest_commit_sha":null,"homepage":"","language":"Yacc","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Badawy403.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-19T17:30:17.000Z","updated_at":"2025-01-24T21:40:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"e6c4c983-cf05-4993-bf80-d65f6dedbc4c","html_url":"https://github.com/Badawy403/CompilerProject","commit_stats":null,"previous_names":["0xbadawy/compilerproject","badawy403/compilerproject"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Badawy403/CompilerProject","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badawy403%2FCompilerProject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badawy403%2FCompilerProject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badawy403%2FCompilerProject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badawy403%2FCompilerProject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Badawy403","download_url":"https://codeload.github.com/Badawy403/CompilerProject/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badawy403%2FCompilerProject/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269830712,"owners_count":24482213,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bison","c","compiler","gui","lex","lex-yacc","tkinter-python","yacc"],"created_at":"2025-08-11T04:26:56.447Z","updated_at":"2025-10-06T18:45:43.720Z","avatar_url":"https://github.com/Badawy403.png","language":"Yacc","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compiler Project: Lex and Yacc\n\nThis project involves building a compiler using Lex and Yacc. The instructions below will guide you on how to set up, run, and use a graphical user interface (GUI) with the compiler.\n\n----\n\n## How to Run Lex and Yacc in Visual Studio Code\n\n### Step 1: Install Flex and Bison\n- Download and install Flex and Bison from [WinFlexBison](https://sourceforge.net/projects/winflexbison/) or you can download the .exe file from `Program/Program.zip` file.\n\n### Step 2: Update Environment Variables\n1. Open the Start menu and search for \"Environment Variables.\"\n2. Click on **Environment Variables**.\n3. Edit the `Path` variable by adding:\n   - The path to `flex`.\n   - The path to `gcc`.\n\n### Step 3: Create Files\n1. Create a new folder.\n2. Add the following files to the folder:\n   - `LexFile.l`\n   - `YaccFile.y`\n\n### Step 4: Install VS Code Extensions\nInstall the following extensions in Visual Studio Code:\n- [Flex Extension](https://marketplace.visualstudio.com/items?itemName=daohong-emilio.yash)\n- [Lex Extension](https://marketplace.visualstudio.com/items?itemName=luniclynx.lex)\n- [Bison Extension](https://marketplace.visualstudio.com/items?itemName=luniclynx.bison)\n\n#### How Run Lex Only ?\nRun the following command in the terminal:\n```bash\nflex LexFile.l; gcc lex.yy.c -o Lex; ./Lex.exe\n```\n\n#### How Run Lex and Yacc ?\nRun the following commands in the terminal:\n```bash\nflex LexFile.l; yacc -d YaccFile.y; gcc lex.yy.c -o lexer; gcc YaccFile.tab.c lex.yy.c -o program\n```\n\n### Step 5: Run in Visual Studio Code\n1. Open the terminal in VS Code.\n2. Execute:\n   ```bash\n   flex LexFile.l; yacc -d YaccFile.y; gcc lex.yy.c -o lexer; gcc YaccFile.tab.c lex.yy.c -o program\n   ```\n3. Run the compiled program:\n   ```bash\n   ./program.exe\n   ```\n\n![alt text](Assets/Images/Image1.png)\n\n---\n\n## How to Use GUI with Lex and Yacc\n\nThis section explains how to create and use a GUI with the compiler, leveraging the `customtkinter` Python library.\n\n### Step 1: Install Python\nDownload and install Python from [python.org](https://www.python.org/downloads/).\n\n### Step 2: Install Required Libraries\nInstall `customtkinter` (or `tkinter`) by running:\n```bash\npip install customtkinter\n```\n\n### Step 3: Create GUI File\n1. Create a new file named `GUI.py`.\n2. Import the required libraries:\n   ```python\n   import tkinter as tk\n   import customtkinter as ctk\n   import subprocess\n   import os\n   ```\n\n### Step 4: Create a Function to Run Lex and Yacc\nDefine a function `use_GUI()` to run the program and display the output:\n```python\ndef use_GUI():\n    user_input = text_input.get(\"1.0\", tk.END).strip()  \n    process = subprocess.Popen([\"program.exe\"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n    stdout, stderr = process.communicate(input=user_input.encode())  \n    result_output.delete(\"1.0\", tk.END)  \n    result_output.insert(tk.END, stdout.decode())  \n```\n- Ensure the path to `program.exe` is correct.\n- This function captures user input, executes the program, and displays the output in the GUI.\n\n### Step 5: Create the GUI Layout\nDesign the GUI:\n```python\nroot = ctk.CTk()  \nroot.title(\"Compiler\")\nroot.geometry(\"1400x800\")  \n\nroot.grid_rowconfigure(0, weight=1, minsize=5)  \nroot.grid_rowconfigure(1, weight=0, minsize=5)\nroot.grid_columnconfigure(0, weight=1, minsize=5)\nroot.grid_columnconfigure(1, weight=0, minsize=5)  \nroot.grid_columnconfigure(2, weight=1, minsize=5)\n\ntext_input = ctk.CTkTextbox(root, height=10, width=30, font=(\"Consolas\", 19, \"bold\"), wrap=tk.WORD, corner_radius=8)\ntext_input.grid(row=0, column=0, padx=20, pady=10, sticky=\"nsew\")\n\nresult_output = ctk.CTkTextbox(root, height=10, width=30, font=(\"Consolas\", 19, \"bold\"), wrap=tk.WORD, corner_radius=8)\nresult_output.grid(row=0, column=1, columnspan=3, padx=10, pady=10, sticky=\"nsew\")\n\nrun_button = ctk.CTkButton(root, text=\"Run Code\", command=use_GUI, width=200, height=40, font=(\"Consolas\", 15, \"bold\"))\nrun_button.grid(row=2, column=0, padx=20, pady=10)\n\nroot.mainloop()\n```\n\n### Step 6: Run the GUI\nRun `GUI.py` to start the graphical interface.\n\n### Notes\n- Ensure `program.exe` is in the same folder as `GUI.py`.\n- After updating the Lex or Yacc files, rebuild the program using:\n  ```bash\n  flex LexFile.l; yacc -d YaccFile.y; gcc lex.yy.c -o lexer; gcc YaccFile.tab.c lex.yy.c -o program\n  ```\n\n#### Light Mode \n![alt text](Assets/Images/image.png)\n\n#### Dark Mode\n![alt text](Assets/Images/Image2.png)\n\n### Youtube Videos \n- [How to install in VS-Code](https://www.youtube.com/watch?v=Zs99QnRUt5c\u0026t)\n- [Arabic Flex Tutorial](https://www.youtube.com/watch?v=Zs99QnRUt5c\u0026list=PLd_aE3prUmHfvPeSMzUou3dUEMWIAjT-X)\n\n\n---\n\n\n\nThis README file provides a comprehensive guide to setting up, running, and enhancing your compiler project with a GUI. Make sure to follow each step carefully for a successful implementation.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadawy403%2Fcompilerproject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadawy403%2Fcompilerproject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadawy403%2Fcompilerproject/lists"}