Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions flopy4/mf6/codec/reader/grammar/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ def field_type(field: FieldV2) -> str:


def record_child_type(field: FieldV2) -> str:
"""Get the grammar type for a field within a record context."""
"""
Get the grammar type for a field within a record context.

In records, string fields should use 'word' instead of 'string'
to avoid consuming the rest of the line (since string matches token+ NEWLINE).
"""
match field.type:
case t if t in ["string", "double", "integer"]:
case "string":
return "word" # Use word for strings in records to match single tokens
case t if t in ["double", "integer"]:
return t
case "keyword":
return ""
case "union":
return "" # keystrings generate their own union rules
return "" # unions generate their own union rules
case _:
return field.type

Expand Down
3 changes: 2 additions & 1 deletion flopy4/mf6/codec/reader/grammar/generated/chf-cdb.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -27,6 +28,6 @@ boundnames: "boundnames"i
print_input: "print_input"i
print_flows: "print_flows"i
save_flows: "save_flows"i
obs_filerecord: "filein"i "obs6"i string
obs_filerecord: "obs6"i "filein"i word
maxbound: "maxbound"i integer
stress_period_data: record+
5 changes: 3 additions & 2 deletions flopy4/mf6/codec/reader/grammar/generated/chf-chd.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -28,7 +29,7 @@ boundnames: "boundnames"i
print_input: "print_input"i
print_flows: "print_flows"i
save_flows: "save_flows"i
ts_filerecord: "ts6"i "filein"i string
obs_filerecord: "filein"i "obs6"i string
ts_filerecord: "ts6"i "filein"i word
obs_filerecord: "obs6"i "filein"i word
maxbound: "maxbound"i integer
stress_period_data: record+
5 changes: 3 additions & 2 deletions flopy4/mf6/codec/reader/grammar/generated/chf-cxs.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -26,5 +27,5 @@ crosssectiondata_fields: (crosssectiondata)*
print_input: "print_input"i
nsections: "nsections"i integer
npoints: "npoints"i integer
packagedata: "packagedata"i recarray
crosssectiondata: "crosssectiondata"i recarray
packagedata: "packagedata"i list
crosssectiondata: "crosssectiondata"i list
3 changes: 2 additions & 1 deletion flopy4/mf6/codec/reader/grammar/generated/chf-dfw.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -25,7 +26,7 @@ time_conversion: "time_conversion"i double
save_flows: "save_flows"i
print_flows: "print_flows"i
save_velocity: "save_velocity"i
obs_filerecord: "obs6"i "filein"i string
obs_filerecord: "obs6"i "filein"i word
export_array_ascii: "export_array_ascii"i
dev_swr_conductance: "dev_swr_conductance"i
manningsn: "manningsn"i array
Expand Down
7 changes: 4 additions & 3 deletions flopy4/mf6/codec/reader/grammar/generated/chf-disv1d.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -27,7 +28,7 @@ vertices_fields: (vertices)*
cell1d_fields: (cell1d)*
length_units: "length_units"i string
nogrb: "nogrb"i
grb_filerecord: "grb6"i "fileout"i string
grb_filerecord: "grb6"i "fileout"i word
xorigin: "xorigin"i double
yorigin: "yorigin"i double
angrot: "angrot"i double
Expand All @@ -38,5 +39,5 @@ nvert: "nvert"i integer
width: "width"i array
bottom: "bottom"i array
idomain: "idomain"i array
vertices: "vertices"i recarray
cell1d: "cell1d"i recarray
vertices: "vertices"i list
cell1d: "cell1d"i list
5 changes: 3 additions & 2 deletions flopy4/mf6/codec/reader/grammar/generated/chf-evp.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -28,7 +29,7 @@ boundnames: "boundnames"i
print_input: "print_input"i
print_flows: "print_flows"i
save_flows: "save_flows"i
ts_filerecord: "ts6"i "filein"i string
obs_filerecord: "filein"i "obs6"i string
ts_filerecord: "ts6"i "filein"i word
obs_filerecord: "obs6"i "filein"i word
maxbound: "maxbound"i integer
stress_period_data: record+
5 changes: 3 additions & 2 deletions flopy4/mf6/codec/reader/grammar/generated/chf-flw.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -28,7 +29,7 @@ boundnames: "boundnames"i
print_input: "print_input"i
print_flows: "print_flows"i
save_flows: "save_flows"i
ts_filerecord: "ts6"i "filein"i string
obs_filerecord: "filein"i "obs6"i string
ts_filerecord: "ts6"i "filein"i word
obs_filerecord: "obs6"i "filein"i word
maxbound: "maxbound"i integer
stress_period_data: record+
1 change: 1 addition & 0 deletions flopy4/mf6/codec/reader/grammar/generated/chf-ic.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down
3 changes: 2 additions & 1 deletion flopy4/mf6/codec/reader/grammar/generated/chf-nam.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -24,4 +25,4 @@ print_input: "print_input"i
print_flows: "print_flows"i
save_flows: "save_flows"i
newtonoptions: "newton"i "under_relaxation"i
packages: "packages"i recarray
packages: "packages"i list
20 changes: 14 additions & 6 deletions flopy4/mf6/codec/reader/grammar/generated/chf-oc.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -20,10 +21,17 @@ period_block: "begin"i "period"i block_index period_fields "end"i "period"i bloc
block_index: integer
options_fields: (budget_filerecord | budgetcsv_filerecord | qoutflow_filerecord | stage_filerecord | qoutflowprintrecord)*
period_fields: (saverecord | printrecord)*
budget_filerecord: "budget"i "fileout"i string
budgetcsv_filerecord: "fileout"i "budgetcsv"i string
qoutflow_filerecord: "fileout"i "qoutflow"i string
stage_filerecord: "fileout"i "stage"i string
budget_filerecord: "budget"i "fileout"i word
budgetcsv_filerecord: "budgetcsv"i "fileout"i word
qoutflow_filerecord: "qoutflow"i "fileout"i word
stage_filerecord: "stage"i "fileout"i word
qoutflowprintrecord: "qoutflow"i "print_format"i
saverecord: "save"i string keystring
printrecord: "print"i string keystring
saverecord: "save"i word ocsetting
printrecord: "print"i word ocsetting
ocsetting: ocsetting_all | ocsetting_first | ocsetting_last | ocsetting_frequency | ocsetting_steps
ocsetting_all: "all"i
ocsetting_first: "first"i
ocsetting_last: "last"i
ocsetting_frequency: "frequency"i integer
ocsetting_steps: "steps"i integer+

5 changes: 3 additions & 2 deletions flopy4/mf6/codec/reader/grammar/generated/chf-pcp.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -28,7 +29,7 @@ boundnames: "boundnames"i
print_input: "print_input"i
print_flows: "print_flows"i
save_flows: "save_flows"i
ts_filerecord: "ts6"i "filein"i string
obs_filerecord: "filein"i "obs6"i string
ts_filerecord: "ts6"i "filein"i word
obs_filerecord: "obs6"i "filein"i word
maxbound: "maxbound"i integer
stress_period_data: record+
1 change: 1 addition & 0 deletions flopy4/mf6/codec/reader/grammar/generated/chf-sto.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down
5 changes: 3 additions & 2 deletions flopy4/mf6/codec/reader/grammar/generated/chf-zdg.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -27,7 +28,7 @@ boundnames: "boundnames"i
print_input: "print_input"i
print_flows: "print_flows"i
save_flows: "save_flows"i
ts_filerecord: "ts6"i "filein"i string
obs_filerecord: "filein"i "obs6"i string
ts_filerecord: "ts6"i "filein"i word
obs_filerecord: "obs6"i "filein"i word
maxbound: "maxbound"i integer
stress_period_data: record+
5 changes: 3 additions & 2 deletions flopy4/mf6/codec/reader/grammar/generated/exg-chfgwf.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -24,6 +25,6 @@ exchangedata_fields: (exchangedata)*
print_input: "print_input"i
print_flows: "print_flows"i
fixed_conductance: "fixed_conductance"i
obs_filerecord: "obs6"i "filein"i string
obs_filerecord: "obs6"i "filein"i word
nexg: "nexg"i integer
exchangedata: "exchangedata"i recarray
exchangedata: "exchangedata"i list
7 changes: 4 additions & 3 deletions flopy4/mf6/codec/reader/grammar/generated/exg-gwegwe.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down Expand Up @@ -31,8 +32,8 @@ save_flows: "save_flows"i
adv_scheme: "adv_scheme"i string
cnd_xt3d_off: "cnd_xt3d_off"i
cnd_xt3d_rhs: "cnd_xt3d_rhs"i
mve_filerecord: "filein"i "mve6"i string
obs_filerecord: "filein"i "obs6"i string
mve_filerecord: "mve6"i "filein"i word
obs_filerecord: "obs6"i "filein"i word
dev_interfacemodel_on: "dev_interfacemodel_on"i
nexg: "nexg"i integer
exchangedata: "exchangedata"i recarray
exchangedata: "exchangedata"i list
1 change: 1 addition & 0 deletions flopy4/mf6/codec/reader/grammar/generated/exg-gwfgwe.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down
9 changes: 5 additions & 4 deletions flopy4/mf6/codec/reader/grammar/generated/exg-gwfgwf.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -30,9 +31,9 @@ cell_averaging: "cell_averaging"i string
cvoptions: "variablecv"i "dewatered"i
newton: "newton"i
xt3d: "xt3d"i
gnc_filerecord: "filein"i "gnc6"i string
mvr_filerecord: "filein"i "mvr6"i string
obs_filerecord: "filein"i "obs6"i string
gnc_filerecord: "gnc6"i "filein"i word
mvr_filerecord: "mvr6"i "filein"i word
obs_filerecord: "obs6"i "filein"i word
dev_interfacemodel_on: "dev_interfacemodel_on"i
nexg: "nexg"i integer
exchangedata: "exchangedata"i recarray
exchangedata: "exchangedata"i list
1 change: 1 addition & 0 deletions flopy4/mf6/codec/reader/grammar/generated/exg-gwfgwt.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down
1 change: 1 addition & 0 deletions flopy4/mf6/codec/reader/grammar/generated/exg-gwfprt.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down
7 changes: 4 additions & 3 deletions flopy4/mf6/codec/reader/grammar/generated/exg-gwtgwt.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down Expand Up @@ -31,8 +32,8 @@ save_flows: "save_flows"i
adv_scheme: "adv_scheme"i string
dsp_xt3d_off: "dsp_xt3d_off"i
dsp_xt3d_rhs: "dsp_xt3d_rhs"i
mvt_filerecord: "filein"i "mvt6"i string
obs_filerecord: "filein"i "obs6"i string
mvt_filerecord: "mvt6"i "filein"i word
obs_filerecord: "obs6"i "filein"i word
dev_interfacemodel_on: "dev_interfacemodel_on"i
nexg: "nexg"i integer
exchangedata: "exchangedata"i recarray
exchangedata: "exchangedata"i list
5 changes: 3 additions & 2 deletions flopy4/mf6/codec/reader/grammar/generated/exg-olfgwf.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand All @@ -24,6 +25,6 @@ exchangedata_fields: (exchangedata)*
print_input: "print_input"i
print_flows: "print_flows"i
fixed_conductance: "fixed_conductance"i
obs_filerecord: "obs6"i "filein"i string
obs_filerecord: "obs6"i "filein"i word
nexg: "nexg"i integer
exchangedata: "exchangedata"i recarray
exchangedata: "exchangedata"i list
1 change: 1 addition & 0 deletions flopy4/mf6/codec/reader/grammar/generated/gwe-adv.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down
1 change: 1 addition & 0 deletions flopy4/mf6/codec/reader/grammar/generated/gwe-cnd.lark
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%import typed.double -> double
%import typed.number -> number
%import typed.string -> string
%import typed.word -> word
%import typed.array -> array
%import typed.record -> record
%import typed.NEWLINE -> NEWLINE
Expand Down
Loading
Loading