{"id":29026349,"url":"https://github.com/mumez/tonel-smalltalk-parser","last_synced_at":"2025-06-26T05:33:01.335Z","repository":{"id":301173665,"uuid":"1008368292","full_name":"mumez/tonel-smalltalk-parser","owner":"mumez","description":"Tonel and Smalltalk BNF definitions and parsers.","archived":false,"fork":false,"pushed_at":"2025-06-25T14:18:44.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-25T14:43:31.049Z","etag":null,"topics":["bnf","parser","smalltalk","tonel"],"latest_commit_sha":null,"homepage":"","language":"Python","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/mumez.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,"zenodo":null}},"created_at":"2025-06-25T12:41:37.000Z","updated_at":"2025-06-25T14:18:47.000Z","dependencies_parsed_at":"2025-06-25T14:43:56.401Z","dependency_job_id":"fce91d32-b63d-46ea-9248-629a5ba13fd0","html_url":"https://github.com/mumez/tonel-smalltalk-parser","commit_stats":null,"previous_names":["mumez/tonel-smalltalk-parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mumez/tonel-smalltalk-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumez%2Ftonel-smalltalk-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumez%2Ftonel-smalltalk-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumez%2Ftonel-smalltalk-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumez%2Ftonel-smalltalk-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mumez","download_url":"https://codeload.github.com/mumez/tonel-smalltalk-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumez%2Ftonel-smalltalk-parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262009215,"owners_count":23244335,"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":["bnf","parser","smalltalk","tonel"],"created_at":"2025-06-26T05:31:23.462Z","updated_at":"2025-06-26T05:33:01.317Z","avatar_url":"https://github.com/mumez.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tonel and Smalltalk Parser\n\n[![Test](https://github.com/mumez/tonel-smalltalk-parser/actions/workflows/test.yml/badge.svg)](https://github.com/mumez/tonel-smalltalk-parser/actions/workflows/test.yml)\n\nA Python library for parsing Tonel-formatted Smalltalk source code with comprehensive\nBNF grammar definitions.\n\n## Features\n\n- **Tonel Format Parser**: Handles file structure, metadata (STON format), and method\n  references\n- **Smalltalk Method Body Parser**: Complete recursive descent parser for Smalltalk\n  syntax\n- **Precise Bracket Matching**: Correctly handles nested blocks and string literals\n- **Type Annotations**: Full type support for static analysis\n- **Comprehensive Testing**: Extensive test suite covering real-world scenarios\n\n## Grammar Specification\n\nThe complete BNF grammar specification is available in:\n\n- [Tonel \u0026 Smalltalk BNF Grammar](doc/tonel-and-smalltalk-bnf.md) - Comprehensive\n  grammar definition with implementation notes\n\n## Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/mumez/tonel-smalltalk-parser.git\ncd tonel-smalltalk-parser\n\n# Install dependencies with uv\nuv sync\n```\n\n## Usage\n\n### Basic Tonel Parsing\n\n```python\nfrom tonel_smalltalk_parser import TonelParser\n\n# Parse a Tonel file\nparser = TonelParser()\ntonel_content = '''\n\"A sample class for demonstration\"\nClass {\n    #name : #Counter,\n    #superclass : #Object,\n    #instVars : [ 'value' ],\n    #category : #'Demo-Core'\n}\n\n{ #category : #accessing }\nCounter \u003e\u003e value [\n    ^ value\n]\n\n{ #category : #accessing }\nCounter \u003e\u003e value: anInteger [\n    value := anInteger\n]\n'''\n\nresult = parser.parse(tonel_content)\n\n# Access parsed components\nprint(f\"Class type: {result.class_definition.type}\")\nprint(f\"Comment: {result.comment}\")\nprint(f\"Number of methods: {len(result.methods)}\")\n\nfor method in result.methods:\n    print(f\"Method: {method.class_name} \u003e\u003e {method.selector}\")\n    print(f\"Class method: {method.is_class_method}\")\n```\n\n### Smalltalk Method Body Parsing\n\n```python\nfrom tonel_smalltalk_parser import SmalltalkParser\n\n# Parse Smalltalk method body\nparser = SmalltalkParser()\nmethod_body = '''\n    | block result |\n    block := [ :x | x + 1 ].\n    result := block value: 5.\n    ^ result\n'''\n\nast = parser.parse(method_body)\nprint(f\"AST type: {type(ast).__name__}\")\n```\n\n### Working with Complex Examples\n\n```python\n# Handle methods with nested blocks and complex syntax\ncomplex_method = '''\nCounter \u003e\u003e complexCalculation: numbers [\n    | sum average |\n    sum := numbers inject: 0 into: [ :acc :each | acc + each ].\n    average := sum / numbers size.\n    ^ self\n        logResult: average;\n        updateValue: sum;\n        yourself\n]\n'''\n\nresult = parser.parse(f\"Class {{ #name : #Counter }}\\n\\n{complex_method}\")\nmethod = result.methods[0]\nprint(f\"Method body contains: {len(method.body.split())} tokens\")\n```\n\n## Development\n\n### Requirements\n\n- Python 3.10+\n- Dependencies managed with [uv](https://docs.astral.sh/uv/)\n\n### Development Commands\n\n```bash\n# Install dependencies and pre-commit hooks\nuv sync\npre-commit install\n\n# Run tests\npython -m pytest tests/\n\n# Lint and format code\nruff check src/ tests/\nruff format src/ tests/\n\n# Format markdown documentation\nmdformat README.md CLAUDE.md doc/tonel-and-smalltalk-bnf.md\n\n# Run all pre-commit hooks manually\npre-commit run --all-files\n```\n\n### Architecture\n\nThe parser implements a two-stage architecture:\n\n1. **TonelParser**: Handles the outer Tonel file structure using regex patterns and\n   precise bracket matching\n1. **SmalltalkParser**: Processes method bodies with a complete recursive descent parser\n1. **BracketParser**: Utility class for accurate bracket boundary detection\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for\ndetails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumez%2Ftonel-smalltalk-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmumez%2Ftonel-smalltalk-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumez%2Ftonel-smalltalk-parser/lists"}