{"id":18221192,"url":"https://github.com/thkox/uni_2021-compilers-final-assignment","last_synced_at":"2026-04-30T09:38:15.045Z","repository":{"id":253319482,"uuid":"841394487","full_name":"thkox/uni_2021-compilers-final-assignment","owner":"thkox","description":"This project is a team assignment for the \"Compilers\" course, offered in the 3rd semester of the 2021 academic year at the University of Piraeus, Department of Informatics.","archived":false,"fork":false,"pushed_at":"2024-10-19T22:31:55.000Z","size":821,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T23:19:00.888Z","etag":null,"topics":["3rd-semester","analyzer","c","cpp","department-of-informatics","flex","lex","string-generator","top-down-parser","university-of-piraeus"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thkox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-08-12T10:17:52.000Z","updated_at":"2024-10-20T00:24:33.000Z","dependencies_parsed_at":"2024-08-15T23:26:53.090Z","dependency_job_id":"72b0d1f0-c62c-40c0-90b3-7124b8e4e2d8","html_url":"https://github.com/thkox/uni_2021-compilers-final-assignment","commit_stats":null,"previous_names":["thkox/compilers_2021-final-assignment","thkox/uni_2021-compilers-final-assignment"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thkox/uni_2021-compilers-final-assignment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkox%2Funi_2021-compilers-final-assignment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkox%2Funi_2021-compilers-final-assignment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkox%2Funi_2021-compilers-final-assignment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkox%2Funi_2021-compilers-final-assignment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thkox","download_url":"https://codeload.github.com/thkox/uni_2021-compilers-final-assignment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thkox%2Funi_2021-compilers-final-assignment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32460781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"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":["3rd-semester","analyzer","c","cpp","department-of-informatics","flex","lex","string-generator","top-down-parser","university-of-piraeus"],"created_at":"2024-11-03T21:05:29.515Z","updated_at":"2026-04-30T09:38:15.029Z","avatar_url":"https://github.com/thkox.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compilers (2021) - Final Assignment\n\n## Project Overview\n\nThis project is a team assignment for the \"Compilers\" course, offered in the 3rd semester of the 2021 academic year at the University of Piraeus, Department of Informatics. The project consists of three distinct tasks, each focusing on different aspects of compiler design and implementation. The tasks were developed in C/C++ and Flex, and were aimed at demonstrating skills in string generation, syntax analysis, and lexical analysis. The tasks are:\n\n- **Thema 1:** String Generator\n- **Thema 2:** Top-Down Parser\n- **Thema 3:** Flex-based Analyzer\n\n## Course Information\n\n- **Institution:** [University of Piraeus](https://www.unipi.gr/en/)\n- **Department:** [Department of Informatics](https://cs.unipi.gr/en/)\n- **Course:** Compilers (2021)\n- **Semester:** 3rd\n\n## Technologies Used\n\n- C++\n- C\n- Flex\n\n\n## Tasks Details\n\n### Thema 1: String Generator\n\n#### Description:\n\nDesign and implement a string generator for the following grammar:\n\n```\n\u003cE\u003e::=(\u003cY\u003e)\n\u003cY\u003e::=\u003cA\u003e\u003cB\u003e\n\u003cA\u003e::=ν|\u003cE\u003e\n\u003cB\u003e::=-\u003cY\u003e|+\u003cY\u003e|ε\n```\n\n#### Requirements\n\n- Ensure the process terminates.\n- The program should print each step of the production.\n\n### Thema 2: Top-Down Parser\n\n#### Description\n\nImplement a top-down parser for the following grammar:\n\n```\nS→(Χ)\nΧ→ΥΖ\nΥ→α | β | S\nΖ→*Χ | -Χ | +Χ | ε\n```\n\n#### Requirements\n\nThe parser should:\n- Recognize valid strings.\n- Return and print the corresponding syntax tree.\n- Demonstrate the parser using the expression `((β-α)*(α+β))`.\n\n### Thema 3: Flex-based Analyzer\n\n#### Description\n\nImplement a Flex program that analyzes sentences in a subset of natural language, specifically identifying correct definitions of points, lines, triangles, etc., up to octagons.\n\n#### Requirements:\n\n- Accept only correct definitions, such as \"triangle BCD\" or \"square BCDA\".\n- Reject incorrect definitions, such as \"square AB\" or \"triangle AAD\".\n\n## Usage Examples\n\n### Thema 1: String Generator\n\nWhen the user runs the executable file, they will be greeted with the following screen:\n\n![Intro](./images/thema1_intro.png)\n\n**Note:** To make the empty symbol visible in the terminal, we decided to represent it as “^” instead of “ε” or a space.\n\nBy pressing the Enter key, the generation algorithm begins, printing the steps in the terminal as it progresses until the string contains only terminal symbols.\n\n![Thema 1 Example](./images/thema1_example.png)\n\n### Thema 2: Top-Down Parser\n\nWhen the user runs the executable file, they will be greeted with the following screen:\n\n![Thema 2 Intro](./images/thema2_intro.png)\n\n**Note:** To make the empty symbol visible in the terminal, we decided to represent it as “^” instead of “ε” or a space.\n\nThe user is prompted to enter a string for recognition:\n\nSuppose the user inputs the string `((ba)*(a+b))`.\n\n![Thema 2 Example](./images/thema2_example.png)\n\nThe program will then inform the user whether the string is accepted or not and will print the parse table and the corresponding parse tree.\n\n![Thema 2 Example 2](./images/thema2_example_2.png)\n\nTo terminate the program, the user must press the Enter key.\n\nIf the user enters an incorrect string:\n\n![Thema 2 Example Wrong](./images/thema2_example_wrong.png)\n\nOr if the user inputs a string with valid symbols but syntactically incorrect:\n\n![Thema 2 Example Wrong 2](./images/thema2_example_wrong_2.png)\n\n### Thema 3: Flex-based Analyzer\n\nWhen the file is executed, the following will appear in the terminal:\n\n![Thema 3 Intro](./images/thema3_intro.png)\n\nIf the user completely misinputs the data, the program will display a message prompting the user to enter another valid regular expression.\n\n![Thema 3 Example Wrong](./images/thema3_example_wrong.png)\n\nIn the case where the user inputs two or more vertices with the same name.\n\n![Thema 3 Example 1](./images/thema3_example_1.png)\n\nIf the user inputs correctly and the program executes as expected.\n\n![Thema 3 Example 2](./images/thema3_example_2.png)\n\n## Setup Instructions\n\n### Prerequisites\n\nBefore running the programs, ensure that you have the following installed on your system:\n\n- **C++ Compiler** (g++ for Windows/Linux/MacOS)\n- **Flex Compiler** (for `thema3.l`)\n\n### Setting Up and Running the Programs\n\n#### Thema 1: Compiling and Running the C++ Program (`thema1.cpp`)\n\n1. **Install a C++ Compiler:**\n   - **Windows:**\n     - Install [MinGW](https://sourceforge.net/projects/mingw/). During installation, select the checkbox to install the C++ compiler.\n   - **MacOS/Linux:**\n     - Most systems come with g++ pre-installed. If not, you can install it via Homebrew (MacOS) or your package manager (Linux).\n\n2. **Configure the Environment (Windows Only):**\n   - Add the path to the MinGW `bin` directory to your system’s environment variables:\n     - Go to `Advanced System Settings` → `Environment Variables` → `User Variables` → `Path` → `New`.\n     - Add the path (e.g., `C:\\MinGW\\bin`).\n\n3. **Compile the Program:**\n   - Navigate to the directory containing `thema1.cpp` in your terminal or command prompt.\n   - Run the following command:\n     ```bash\n     g++ thema1.cpp -o thema1\n     ```\n     This will create an executable file named `thema1` (or `thema1.exe` on Windows).\n\n4. **Run the Program:**\n   - **Windows:**\n     ```bash\n     thema1.exe\n     ```\n   - **MacOS/Linux:**\n     ```bash\n     ./thema1\n     ```\n\nYou can follow the same instructions for thema 2.\n\n#### Thema 3: Compiling and Running the Flex Program (`thema3.l`)\n\n1. **Install the Flex Compiler:**\n   - **MacOS/Linux:**\n     - For MacOS, install Flex using Homebrew:\n       ```bash\n       brew install flex\n       ```\n     - For Linux, use your package manager:\n       ```bash\n       sudo apt-get install flex\n       ```\n   - **Windows:**\n     - Download and install [GnuWin32 Flex](http://gnuwin32.sourceforge.net/packages/flex.htm).\n     - During installation, ensure the Flex compiler is selected.\n     - Add the path to the GnuWin32 `bin` directory (e.g., `C:\\GnuWin32\\bin`) to your system’s environment variables.\n\n2. **Compile the Flex Program:**\n   - Navigate to the directory containing `thema3.l` in your terminal or command prompt.\n   - Run the following commands:\n     ```bash\n     flex thema3.l\n     gcc lex.yy.c -o thema3\n     ```\n     This will create an executable named `thema3` (or `thema3.exe` on Windows).\n\n3. **Run the Program:**\n   - **Windows:**\n     ```bash\n     thema3.exe\n     ```\n   - **MacOS/Linux:**\n     ```bash\n     ./thema3\n     ```\n\n## Contributors\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/thkox\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/79880468?v=4\" width=\"100px;\" alt=\"Theodoros Koxanoglou\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eTheodoros Koxanoglou\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/ApostolisSiampanis\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/75365398?v=4\" width=\"100px;\" alt=\"Apostolis Siampanis\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eApostolis Siampanis\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/AimiliosKourpas\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/118211341?v=4\" width=\"100px;\" alt=\"Aimilianos Kourpas\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAimilianos Kourpas\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthkox%2Funi_2021-compilers-final-assignment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthkox%2Funi_2021-compilers-final-assignment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthkox%2Funi_2021-compilers-final-assignment/lists"}