{"id":23699728,"url":"https://github.com/grachale/lr_parser_generator","last_synced_at":"2025-10-09T08:32:40.567Z","repository":{"id":269601714,"uuid":"906996039","full_name":"grachale/lr_parser_generator","owner":"grachale","description":"This project is a learning tool designed to help users understand and generate LR parsers, including LR(0), SLR(1), LALR(1), and LR(1). It provides interactive features such as grammar definition, parser construction, and input string testing, enabling users to explore the internal structures and functionality of LR parsers.","archived":false,"fork":false,"pushed_at":"2024-12-31T12:38:24.000Z","size":109,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-09T08:32:05.385Z","etag":null,"topics":["lr-parser","python","streamlit","syntax-analysis"],"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/grachale.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-22T14:23:31.000Z","updated_at":"2025-04-09T07:18:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"940a1805-ff96-492a-8013-c1e896019020","html_url":"https://github.com/grachale/lr_parser_generator","commit_stats":null,"previous_names":["grachale/lr_parser_generator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/grachale/lr_parser_generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grachale%2Flr_parser_generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grachale%2Flr_parser_generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grachale%2Flr_parser_generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grachale%2Flr_parser_generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grachale","download_url":"https://codeload.github.com/grachale/lr_parser_generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grachale%2Flr_parser_generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001051,"owners_count":26082991,"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-10-09T02:00:07.460Z","response_time":59,"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":["lr-parser","python","streamlit","syntax-analysis"],"created_at":"2024-12-30T08:14:31.936Z","updated_at":"2025-10-09T08:32:40.562Z","avatar_url":"https://github.com/grachale.png","language":"Python","readme":"# Learning Tool for LR Parsers\n\nThis project is a learning tool designed to help users understand and generate LR parsers, including LR(0), SLR(1), LALR(1), and LR(1). It provides interactive features such as grammar definition, parser construction, and input string testing, enabling users to explore the internal structures and functionality of LR parsers.\n\n---\n\n## Features\n\n- **Grammar Definition**: Define grammars using terminals, non-terminals, productions, and a start symbol.\n- **Parser Construction**:\n  - Generate ACTION and GOTO tables.\n  - Build canonical collections.\n  - Support for LR(0), SLR(1), LALR(1), and LR(1) parsers.\n- **Interactive Testing**: Test input strings and visualize parsing steps.\n- **Visualization**: View essential parsing components, such as FIRST/FOLLOW sets and canonical item sets.\n- **Modular Design**: Built for easy extension and maintenance.\n\n---\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/grachale/lr_parser_generator\n   ```\n\n2. Navigate to the project directory:\n   ```bash\n   cd lr_parser_generator\n   ```\n\n3. Install dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n---\n\n## Usage\n\n### Running the Application\n\nThe user interface is built using Streamlit. To launch the application:\n```bash\nstreamlit run run.py\n```\n\nThis will open a web-based interface where you can:\n- Define grammars.\n- Select parser types (LR(0), SLR(1), LALR(1), LR(1)).\n- Test input strings.\n- Visualize parser components.\n\n### Example Grammar Input\nDefine a grammar in the sidebar of the application:\n- **Non-terminals**: `E T F`\n- **Terminals**: `id + * ( )`\n- **Productions**:\n  ```\n  E -\u003e T E2\n  E2 -\u003e + T E2 | ε\n  T -\u003e F T2\n  T2 -\u003e * F T2 | ε\n  F -\u003e ( E ) | id\n  ```\n- **Start Symbol**: `E`\n\n---\n\n## Project Structure\n\n```plaintext\nsrc/\n├── grammars/               # Grammar classes\n│   ├── grammar.py          # Base Grammar class\n│   └── context_free_grammar.py # ContextFreeGrammar class\n├── items/                  # Item classes\n│   ├── lr0_item.py         # LR(0) Item class\n│   └── lr1_item.py         # LR(1) Item class\n├── parsers/                # Parser classes\n│   ├── lr_parser.py        # Abstract LRParser class\n│   ├── lr0_parser.py       # LR(0) parser implementation\n│   ├── slr1_parser.py      # SLR(1) parser implementation\n│   ├── lalr1_parser.py     # LALR(1) parser implementation\n│   └── lr1_parser.py       # LR(1) parser implementation\n└── ui/                     # User interface components\n    └── app.py              # Main entry point for the Streamlit app\n```\n\n---\n\n## Testing\n\nUnit tests are implemented using the [pytest](https://docs.pytest.org/) framework. Mocking is used where necessary, for example, to simulate grammar behavior in parser tests.\n\n### Running Tests\n\nTo run all tests:\n```bash\npytest\n```\n\n### Test Coverage\n- **Grammars**: Tests for grammar operations like FIRST and FOLLOW computation.\n- **Items**: Tests for LR(0) and LR(1) item functionality.\n- **Parsers**: Comprehensive tests for parser construction and parsing operations.\n\n---\n\n## Future Improvements\n\nPotential future extensions for the tool include:\n- Error recovery mechanisms.\n- Support for ambiguous grammars.\n- Enhanced graphical visualizations of parser states.\n- Improved grammar input flexibility.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrachale%2Flr_parser_generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrachale%2Flr_parser_generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrachale%2Flr_parser_generator/lists"}