Skip to content

Commit 5b7077a

Browse files
committed
successfully parse all namefiles
1 parent 955676a commit 5b7077a

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

autotest/test_codec.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
from pprint import pprint
2+
13
import pytest
24

35
import modflow_devtools.models as models
46
from modflow_devtools.codec import make_parser
57

68
MODELS = [name for name in models.get_models().keys() if name.startswith("mf6/")]
9+
PARSER = make_parser()
710

811

912
@pytest.mark.parametrize("model_name", MODELS)
1013
def test_parser(model_name, function_tmpdir):
1114
workspace = models.copy_to(function_tmpdir, model_name)
1215
nam_path = next(iter(workspace.glob("*.nam")))
1316
text = nam_path.open().read()
14-
parser = make_parser()
15-
tree = parser.parse(text)
17+
pprint(text)
18+
tree = PARSER.parse(text)
1619
print(tree.pretty())

modflow_devtools/mf6.lark

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
start: [WS] block+ [WS]
2-
block: "begin"i CNAME _NL _content "end"i CNAME _NL
1+
start: [WS] [_NL*] (block [[WS] _NL*])+ [WS]
2+
block: "begin"i CNAME [_block_index] _NL _content "end"i CNAME [_block_index] _NL+
3+
_block_index: INT
34
_content: line* [WS]
4-
line: [WS] value* _NL
5-
value: WORD | NUMBER
5+
line: [WS] item* _NL+
6+
item: word | NUMBER
7+
word: /[a-zA-Z0-9._'~,-\\(\\)]+/
68

79
%import common.NEWLINE -> _NL
810
%import common.WS
911
%import common.WS_INLINE
1012
%import common.CNAME
1113
%import common.WORD
1214
%import common.NUMBER
15+
%import common.INT
1316
%import common.SH_COMMENT
17+
%import common._STRING_INNER
1418
%ignore WS_INLINE
1519
%ignore SH_COMMENT

0 commit comments

Comments
 (0)