Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michaeltryby/swmm-parse
File parsing toolkit for SWMM
https://github.com/michaeltryby/swmm-parse
ebnf input lark parser swmm
Last synced: 14 days ago
JSON representation
File parsing toolkit for SWMM
- Host: GitHub
- URL: https://github.com/michaeltryby/swmm-parse
- Owner: michaeltryby
- License: cc0-1.0
- Created: 2024-04-25T19:42:09.000Z (9 months ago)
- Default Branch: dev
- Last Pushed: 2024-10-04T14:34:42.000Z (3 months ago)
- Last Synced: 2024-11-06T13:57:02.686Z (2 months ago)
- Topics: ebnf, input, lark, parser, swmm
- Language: Python
- Homepage:
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swmm-parse
File parsing toolkit for SWMM
## Build
Builds src and binary distributions
```
% python -m build
```## Test
Installs requirements and runs tests
```
% pip install -r test-requirements.txt
% pytest
```## Usage
Convert SWMM input into a parse tree.
```
from lark import Larkl = Lark.open_from_package(
"swmm.parse", "input-earley.lark", ("grammars",), parser="earley"
)input = """
[TITLE]
Hello SWMM!
"""print(l.parse(input))
```Output
```
Tree(Token('RULE', 'start'), [Tree(Token('RULE', 'section'), [Token('KEYWORD', 'TITLE'), Tree(Token('RULE', 'record'), [Tree('keyword', [Token('KEYWORD', 'Hello')]), Tree('name', [Token('NAME', 'SWMM!')])])])])
```