Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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 Lark

l = 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!')])])])])
```