{"id":24298267,"url":"https://github.com/mdawoud27/syntax_checker","last_synced_at":"2025-03-06T09:45:29.888Z","repository":{"id":272458726,"uuid":"916658915","full_name":"mdawoud27/syntax_checker","owner":"mdawoud27","description":"This project for compiler course in my collage","archived":false,"fork":false,"pushed_at":"2025-01-14T14:36:16.000Z","size":3561,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T15:53:28.369Z","etag":null,"topics":["compiler","lexer","lexical-analysis","python3","syntax-analysis","syntax-checker","tkinter"],"latest_commit_sha":null,"homepage":"","language":"Python","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/mdawoud27.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}},"created_at":"2025-01-14T14:28:55.000Z","updated_at":"2025-01-14T14:39:03.000Z","dependencies_parsed_at":"2025-01-14T15:53:31.411Z","dependency_job_id":"207897d0-3ac9-49de-92a2-41c540782a8d","html_url":"https://github.com/mdawoud27/syntax_checker","commit_stats":null,"previous_names":["mdawoud27/compiler_project"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdawoud27%2Fsyntax_checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdawoud27%2Fsyntax_checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdawoud27%2Fsyntax_checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdawoud27%2Fsyntax_checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdawoud27","download_url":"https://codeload.github.com/mdawoud27/syntax_checker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234734586,"owners_count":18878717,"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","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":["compiler","lexer","lexical-analysis","python3","syntax-analysis","syntax-checker","tkinter"],"created_at":"2025-01-16T20:55:03.067Z","updated_at":"2025-01-20T04:24:47.162Z","avatar_url":"https://github.com/mdawoud27.png","language":"Python","readme":"# Compiler Project - Syntax Checker\n\n## Project Overview\n\nThis project implements a simple **compiler/interpreter** with a graphical user interface for a basic programming language. The project demonstrates fundamental concepts of compiler design including _lexical analysis_, _syntax analysis_, and _error handling_.\n\n## Features\n\n### 1. Language Support\n\n- Variable assignments\n- Numeric literals (integers and floating-point numbers)\n- String literals (both single and double quotes)\n- Arithmetic operations (+, -, \\*, /)\n- If-else statements\n- Comments (single-line comments with //)\n- Nested expressions with proper operator precedence\n\n### 2. Grammar Specification\n\n```bash\nProgram    -\u003e StmtList\nStmtList   -\u003e Stmt StmtList | ε\nStmt       -\u003e AssignStmt | IfStmt\nAssignStmt -\u003e id = Expr ;\nIfStmt     -\u003e if (Expr) { StmtList } else { StmtList }\nExpr       -\u003e Term ((+ | -) Term)*\nTerm       -\u003e Factor ((* | /) Factor)*\nFactor     -\u003e num | id | (Expr)\n```\n\n_For more information or explanation [check this](./grammar_rules.md)._\n\n## Technical Implementation\n\nThe project is organized into several modules, each handling a specific aspect of the compiler:\n\n### 1. Lexical Analysis (`lexer.py`)\n\n- Converts source code into tokens\n- Handles various token types:\n  - Numbers (integers and floating-point)\n  - Strings (single and double quoted)\n  - Identifiers\n  - Operators\n  - Comments\n  - Keywords\n\n### 2. Syntax Analysis (`parser.py`)\n\n- Implements recursive descent parsing\n- Comprehensive error reporting\n- Handles nested expressions and statements\n- Implements operator precedence\n\n### 3. Token Management (`token_types.py`)\n\n- Defines token types and token class\n- Manages token creation and properties\n\n### 4. Syntax Highlighting (`syntax_highlighter.py`)\n\n- Real-time syntax highlighting\n- Color coding for different language elements\n- Support for comments, strings, numbers, and keywords\n\n### 5. GUI Implementation (`gui.py`)\n\n- User-friendly interface\n- Code editor with line numbers\n- Real-time syntax highlighting\n- Error display and feedback\n- File operations (save/load)\n\n## [Example Code](./example.txt)\n\n```python\n// This is a test program demonstrating all features\n// Numbers, strings, and expressions\n\n// 1. Basic assignments with different types\nnum1 = 42;        // Integer\nnum2 = 3.14159;   // Float\nstr1 = \"Hello\";   // Double quoted string\nstr2 = 'World';   // Single quoted string\n\n// 2. Arithmetic expressions\nresult = num1 + num2 * 2;\nx = (10 + 5) * 2;\n\n// 3. Nested if statements\nif (x) {\n    y = y + 1;    // Increment\n    z = x * (y + 2.5);  // Float arithmetic\n} else {\n    y = y - 1;    // Decrement\n    z = x / 2;    // Division\n}\n```\n\n## Error Handling\n\n- Detailed error messages with line and column numbers\n- Syntax error detection\n- Type checking for operations\n- Proper error recovery\n- Visual feedback in the GUI\n\n## Project Structure\n\nThe project is organized into the following files:\n\n- `main.py`: Entry point of the application\n- `token_types.py`: Token definitions and management\n- `lexer.py`: Lexical analysis implementation\n- `parser.py`: Syntax analysis implementation\n- `syntax_highlighter.py`: Code highlighting functionality\n- `gui.py`: GUI implementation\n\n## Future Improvements\n\n1. Symbol table implementation\n2. Type checking system\n3. Function definitions and calls\n4. Loop constructs (while, for)\n5. More data types\n6. Code execution/interpretation\n7. Enhanced error recovery\n8. Code optimization\n9. Intermediate code generation\n\n## Running the Project\n\n```bash\npython3 main.py\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdawoud27%2Fsyntax_checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdawoud27%2Fsyntax_checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdawoud27%2Fsyntax_checker/lists"}