Skip to content

Commit c0acc83

Browse files
wpbonelliwpbonelli
authored andcommitted
typed keystrings
1 parent 9a2095b commit c0acc83

File tree

114 files changed

+582
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+582
-335
lines changed

flopy4/mf6/codec/reader/grammar/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import jinja2
55
from modflow_devtools.dfn import Dfn, get_blocks, get_fields
66

7-
from flopy4.mf6.codec.reader.grammar.filters import field_type, record_child_type
7+
from flopy4.mf6.codec.reader.grammar.filters import (
8+
field_type,
9+
keystring_children,
10+
record_child_type,
11+
)
812

913

1014
def _get_template_env():
@@ -17,6 +21,7 @@ def _get_template_env():
1721
)
1822
env.filters["field_type"] = field_type
1923
env.filters["record_child_type"] = record_child_type
24+
env.filters["keystring_children"] = keystring_children
2025
return env
2126

2227

flopy4/mf6/codec/reader/grammar/filters.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def field_type(field: Field) -> str:
1010
case "keyword":
1111
return ""
1212
case "keystring":
13-
return "record"
13+
return "" # keystrings generate their own union rules
1414
case _:
1515
return field["type"]
1616

@@ -26,5 +26,14 @@ def record_child_type(field: Field) -> str:
2626
return "double"
2727
case "keyword":
2828
return ""
29+
case "keystring":
30+
return "" # keystrings generate their own union rules
2931
case _:
3032
return field["type"]
33+
34+
35+
def keystring_children(field: Field) -> dict:
36+
"""Get the children of a keystring field for union generation."""
37+
if field["type"] != "keystring":
38+
return {}
39+
return field.get("children", {})

flopy4/mf6/codec/reader/grammar/generated/chf-cdb.lark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ boundnames: "boundnames"i
1414
print_input: "print_input"i
1515
print_flows: "print_flows"i
1616
save_flows: "save_flows"i
17-
obs_filerecord: "obs_filerecord"i record
17+
obs_filerecord: "obs6"i "filein"i string
1818
maxbound: "maxbound"i integer
1919
idcxs: "idcxs"i list
2020
width: "width"i list

flopy4/mf6/codec/reader/grammar/generated/chf-chd.lark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ boundnames: "boundnames"i
1515
print_input: "print_input"i
1616
print_flows: "print_flows"i
1717
save_flows: "save_flows"i
18-
ts_filerecord: "ts_filerecord"i record
19-
obs_filerecord: "obs_filerecord"i record
18+
ts_filerecord: "ts6"i "filein"i string
19+
obs_filerecord: "obs6"i "filein"i string
2020
maxbound: "maxbound"i integer
2121
head: "head"i list
2222
aux: "aux"i list

flopy4/mf6/codec/reader/grammar/generated/chf-dfw.lark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ time_conversion: "time_conversion"i double precision
1313
save_flows: "save_flows"i
1414
print_flows: "print_flows"i
1515
save_velocity: "save_velocity"i
16-
obs_filerecord: "obs_filerecord"i record
16+
obs_filerecord: "obs6"i "filein"i string
1717
export_array_ascii: "export_array_ascii"i
1818
dev_swr_conductance: "dev_swr_conductance"i
1919
manningsn: "manningsn"i array

flopy4/mf6/codec/reader/grammar/generated/chf-disv1d.lark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ vertices_fields: (vertices)*
1515
cell1d_fields: (cell1d)*
1616
length_units: "length_units"i string
1717
nogrb: "nogrb"i
18-
grb_filerecord: "grb_filerecord"i record
18+
grb_filerecord: "grb6"i "fileout"i string
1919
xorigin: "xorigin"i double precision
2020
yorigin: "yorigin"i double precision
2121
angrot: "angrot"i double precision

flopy4/mf6/codec/reader/grammar/generated/chf-evp.lark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ boundnames: "boundnames"i
1515
print_input: "print_input"i
1616
print_flows: "print_flows"i
1717
save_flows: "save_flows"i
18-
ts_filerecord: "ts_filerecord"i record
19-
obs_filerecord: "obs_filerecord"i record
18+
ts_filerecord: "ts6"i "filein"i string
19+
obs_filerecord: "obs6"i "filein"i string
2020
maxbound: "maxbound"i integer
2121
evaporation: "evaporation"i list
2222
aux: "aux"i list

flopy4/mf6/codec/reader/grammar/generated/chf-flw.lark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ boundnames: "boundnames"i
1515
print_input: "print_input"i
1616
print_flows: "print_flows"i
1717
save_flows: "save_flows"i
18-
ts_filerecord: "ts_filerecord"i record
19-
obs_filerecord: "obs_filerecord"i record
18+
ts_filerecord: "ts6"i "filein"i string
19+
obs_filerecord: "obs6"i "filein"i string
2020
maxbound: "maxbound"i integer
2121
q: "q"i list
2222
aux: "aux"i list

flopy4/mf6/codec/reader/grammar/generated/chf-oc.lark

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ options_block: "begin"i "options"i options_fields "end"i "options"i
77
period_block: "begin"i "period"i period_fields "end"i "period"i
88
options_fields: (budget_filerecord | budgetcsv_filerecord | qoutflow_filerecord | stage_filerecord | qoutflowprintrecord)*
99
period_fields: (saverecord | printrecord)*
10-
budget_filerecord: "budget_filerecord"i record
11-
budgetcsv_filerecord: "budgetcsv_filerecord"i record
12-
qoutflow_filerecord: "qoutflow_filerecord"i record
13-
stage_filerecord: "stage_filerecord"i record
14-
qoutflowprintrecord: "qoutflowprintrecord"i record
15-
saverecord: "saverecord"i record
16-
printrecord: "printrecord"i record
10+
budget_filerecord: "budget"i "fileout"i string
11+
budgetcsv_filerecord: "budgetcsv"i "fileout"i string
12+
qoutflow_filerecord: "qoutflow"i "fileout"i string
13+
stage_filerecord: "stage"i "fileout"i string
14+
qoutflowprintrecord: "qoutflow"i "print_format"i
15+
saverecord: "save"i string ocsetting
16+
printrecord: "print"i string ocsetting
17+
ocsetting: ocsetting_all | ocsetting_first | ocsetting_last | ocsetting_frequency | ocsetting_steps
18+
ocsetting_all: "all"i
19+
ocsetting_first: "first"i
20+
ocsetting_last: "last"i
21+
ocsetting_frequency: "frequency"i integer
22+
ocsetting_steps: "steps"i integer
23+

flopy4/mf6/codec/reader/grammar/generated/chf-pcp.lark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ boundnames: "boundnames"i
1515
print_input: "print_input"i
1616
print_flows: "print_flows"i
1717
save_flows: "save_flows"i
18-
ts_filerecord: "ts_filerecord"i record
19-
obs_filerecord: "obs_filerecord"i record
18+
ts_filerecord: "ts6"i "filein"i string
19+
obs_filerecord: "obs6"i "filein"i string
2020
maxbound: "maxbound"i integer
2121
precipitation: "precipitation"i list
2222
aux: "aux"i list

0 commit comments

Comments
 (0)