Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed parsing error with sigma baryons #673

Merged
merged 6 commits into from
Mar 3, 2025
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
7 changes: 7 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ MontePy Changelog
0.5 releases
============

#Next Version#
--------------

**Bug Fixes**

* Fixed parsing bug with sigma baryon particles (e.g., ``+/-``) (:issue:`671`).

0.5.4
--------------

Expand Down
1 change: 1 addition & 0 deletions montepy/input_parser/parser_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def file_name(self, p):
"FILE_PATH",
"NUMBER",
"PARTICLE",
"PARTICLE_SPECIAL",
"INTERPOLATE",
"JUMP",
"KEYWORD",
Expand Down
2 changes: 1 addition & 1 deletion montepy/input_parser/syntax_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ def _reverse_engineer_format(self):
if match.group(0).isupper():
upper_match += 1
total_match += 1
if upper_match / total_match >= 0.5:
if total_match and upper_match / total_match >= 0.5:
self._formatter["upper"] = True

@property
Expand Down
16 changes: 9 additions & 7 deletions montepy/input_parser/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ def _parse_shortcut(self, t):
t.type = token_type
return t

@_(r"([|+\-!<>/%^_~@\*\?\#]|\#\d*)+")
def PARTICLE_SPECIAL(self, t):
"""
Particle designators that are special characters.
"""
return t

INTERPOLATE = r"\d*I"
"""
An interpolate shortcut.
Expand Down Expand Up @@ -511,13 +518,6 @@ class DataLexer(ParticleLexer):
A keyword flag at the beginning of a input that modifies it's behavior.
"""

@_(r"([|+\-!<>/%^_~@\*\?\#]|\#\d*)+")
def PARTICLE_SPECIAL(self, t):
"""
Particle designators that are special characters.
"""
return t

@_(r"[+\-]?[0-9]*\.?[0-9]*E?[+\-]?[0-9]*[ijrml]+[a-z\./]*", r"[a-z]+[a-z\./]*")
def TEXT(self, t):
t = super().TEXT(t)
Expand Down Expand Up @@ -609,6 +609,8 @@ class SurfaceLexer(MCNP_Lexer):
All allowed surface types.
"""

PARTICLE_SPECIAL = None

@_(r"[+\-]?[0-9]*\.?[0-9]*E?[+\-]?[0-9]*[ijrml]+[a-z\./]*", r"[a-z]+[a-z\./]*")
def TEXT(self, t):
t = super().TEXT(t)
Expand Down
4 changes: 3 additions & 1 deletion tests/inputs/test_complement_edge.imcnp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ C Bounding water outer capsule
61482 0
( 6 #61440 ) : (#61461 ( 7: -8))
U=6000 IMP:N=1
imp:+,-= 0
61441 814 0.087
(-61867 61870 -61759):(-61868 61869 -61759): (-61870 61868 -61759 61758)
IMP:N=0
imp:+ = 1

1 SO 5.0
2 PZ 0.0
Expand All @@ -34,4 +36,4 @@ m814 26000.55c 5.657-2
24000.50c 1.581-2
25055.51c 1.760-3
sdef cel=2 pos=0 0 0 rad=d3 ext=d3 axs=0 0 1

mode n + -