{"id":24762053,"url":"https://github.com/pranavh-2004/minirustlexer","last_synced_at":"2026-05-16T18:36:00.636Z","repository":{"id":261553014,"uuid":"884643919","full_name":"Pranavh-2004/MiniRustLexer","owner":"Pranavh-2004","description":"PESU Sem 3: Mini project for Automata Formal Languages and Logic","archived":false,"fork":false,"pushed_at":"2024-11-07T06:14:43.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T13:31:40.821Z","etag":null,"topics":["language-parsing","lexer-parser","ply","python","syntax-validation"],"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/Pranavh-2004.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":"2024-11-07T06:01:46.000Z","updated_at":"2025-01-05T11:07:14.000Z","dependencies_parsed_at":"2024-11-07T07:29:22.979Z","dependency_job_id":null,"html_url":"https://github.com/Pranavh-2004/MiniRustLexer","commit_stats":null,"previous_names":["pranavh-2004/minirustlexer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Pranavh-2004/MiniRustLexer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pranavh-2004%2FMiniRustLexer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pranavh-2004%2FMiniRustLexer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pranavh-2004%2FMiniRustLexer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pranavh-2004%2FMiniRustLexer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pranavh-2004","download_url":"https://codeload.github.com/Pranavh-2004/MiniRustLexer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pranavh-2004%2FMiniRustLexer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261200337,"owners_count":23123944,"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":["language-parsing","lexer-parser","ply","python","syntax-validation"],"created_at":"2025-01-28T19:28:39.885Z","updated_at":"2026-05-16T18:35:55.584Z","avatar_url":"https://github.com/Pranavh-2004.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MiniRustLexer\n\n**RustLexer** is a custom lexer and parser built with Python's [PLY (Python Lex-Yacc)](https://www.dabeaz.com/ply/) library to interpret a subset of Rust syntax. The project demonstrates how to tokenize and parse basic Rust constructs like variable declarations, mutable variables, function definitions, conditional statements, loops, and print statements in a Rust-inspired format.\n\n### Features\n\n- **Tokenizing and Parsing**:\n- **Variable Declarations**: Supports both mutable (`let mut`) and immutable (`let`) variable declarations.\n- **Function Definitions**: Recognizes simple function definitions with the `fn` keyword.\n- **Control Flow**: Parses basic control flow structures including `if-else` statements, `while` loops, and `for` loops.\n- **Print Statements**: Supports the `println!` macro for basic print functionality with expressions.\n- **Expressions**: Recognizes integers, floats, and string literals, with basic assignment operations and comparisons.\n\n### Project Structure\n\nThe project contains:\n\n- **Lexer Rules**: Rules to recognize Rust-like keywords, operators, symbols, and literals.\n- **Parser Rules**: Rules to parse and validate Rust-like statements, including conditional statements, loops, and function structures.\n- **Test Cases**: A set of Rust-like example statements to test the lexer and parser.\n\n### Usage\n\n#### Installation\n\n1. Clone this repository:\n\n   ```bash\n   git clone https://github.com/your-username/RustLexer.git\n   ```\n\n2. Navigate to the project directory:\n\n   ```bash\n   cd RustLexer\n   ```\n\n3. Ensure you have Python and the PLY library installed. Install PLY if needed:\n   ```bash\n   pip install ply\n   ```\n\n### Running the Lexer and Parser\n\n1. Run the `RustLexer.py` file to tokenize and parse the example Rust-like code:\n\n   ```bash\n   python RustLexer.py\n   ```\n\n2. You will see output indicating whether each test case is syntactically correct or not.\n\n#### Example Code Snippet\n\nHere’s an example of the Rust-like syntax that this lexer and parser can handle:\n\n```rust\nlet x = 10;\nlet mut y = 20;\nwhile (x \u003e 5) { let z = 20; }\nif (x == 15) { let z = 30; } else { let z = 40; }\nfor (let i = 0; i \u003c 10; i = i + 1) { let j = i; }\nfn main() { println!(\"Hello, world!\"); }\n```\n\nEach line in the example will be tokenized and parsed, with output indicating correct syntax or any syntax errors detected in the structure.\n\n### Project Roadmap\n\nCurrently, **RustLexer** focuses on a simplified subset of Rust syntax. Future enhancements could include:\n\n- **Support for Advanced Rust Features**: Expanding the lexer and parser to handle more complex Rust syntax, such as pattern matching, ownership and borrowing, traits, and custom data types.\n- **Detailed Error Reporting**: Improving the error-handling capabilities for more informative syntax error messages.\n- **Testing Suite**: Adding a suite of automated tests to validate the lexer and parser against a variety of Rust code examples.\n\n### License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranavh-2004%2Fminirustlexer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpranavh-2004%2Fminirustlexer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranavh-2004%2Fminirustlexer/lists"}