https://github.com/michaeltryby/epanet-parse
File parsing toolkit for EPANET
https://github.com/michaeltryby/epanet-parse
ebnf epanet input lark parse
Last synced: 5 months ago
JSON representation
File parsing toolkit for EPANET
- Host: GitHub
- URL: https://github.com/michaeltryby/epanet-parse
- Owner: michaeltryby
- License: cc0-1.0
- Created: 2024-10-15T19:28:43.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-10-16T14:19:55.000Z (12 months ago)
- Last Synced: 2025-02-17T00:49:05.238Z (8 months ago)
- Topics: ebnf, epanet, input, lark, parse
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# epanet-parse
File parsing toolkit for EPANET
## Build
Builds src and binary distributions
```
% python -m build
```## Test
Installs requirements and runs tests
```
% pip install -r test-requirements.txt
% pytest
```
## UsageConvert EPANET input into a parse tree.
```
from lark import Larkl = Lark.open_from_package(
"epanet.parse", "input-earley.lark", ("grammars",), parser="earley"
)input = """
[TITLE]
Hello EPANET!
"""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', 'EPANET!')])])])])
```