Skip to content

Commit

Permalink
datum factory: fix parsing of mphys
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun Persaud committed Nov 14, 2024
1 parent b173e94 commit 767a21f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pymcnp/files/inp/datum/factory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import sys

from .datum import DatumMnemonic, _Placeholder
from .history_cutoff import HistoryCutoff
Expand Down Expand Up @@ -86,6 +87,8 @@ def create_datum_from_mcnp(source: str, line: types.McnpInteger = None):
# Processing Suffix & Parameters
suffix = None
designator = None

datum = None
match mnemonic:
case DatumMnemonic.VOLUME:
tokens.popl()
Expand Down Expand Up @@ -617,7 +620,7 @@ def create_datum_from_mcnp(source: str, line: types.McnpInteger = None):
case DatumMnemonic.MODEL_PHYSICS_CONTROL:
tokens.popl()
if tokens:
ModelPhysicsControl(tokens.popl())
datum = ModelPhysicsControl(tokens.popl())
else:
datum = ModelPhysicsControl('off')

Expand Down Expand Up @@ -755,6 +758,10 @@ def create_datum_from_mcnp(source: str, line: types.McnpInteger = None):
if tokens:
raise errors.MCNPSyntaxError(errors.MCNPSyntaxCodes.TOOLONG_DATUM)

if datum is None:
print('Error: cannot assign a datum to tokens:', tokens, 'source:', source)
sys.exit()

datum.comment = comments

return datum

0 comments on commit 767a21f

Please sign in to comment.