Skip to content

Commit 055992c

Browse files
committed
inp: debugged parser
1 parent a93fdd8 commit 055992c

File tree

595 files changed

+4371
-3265
lines changed

Some content is hidden

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

595 files changed

+4371
-3265
lines changed

docs/source/pymcnp/inp/data.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,17 +1153,10 @@
11531153

11541154
[bfld subpackage](data/bfld)
11551155

1156-
### ``CBuilder_0`` Class
1156+
### ``CBuilder`` Class
11571157

11581158
```{eval-rst}
1159-
.. autoclass:: pymcnp.inp.data.CBuilder_0
1160-
:members:
1161-
```
1162-
1163-
### ``CBuilder_1`` Class
1164-
1165-
```{eval-rst}
1166-
.. autoclass:: pymcnp.inp.data.CBuilder_1
1159+
.. autoclass:: pymcnp.inp.data.CBuilder
11671160
:members:
11681161
```
11691162

@@ -1984,6 +1977,20 @@
19841977
:members:
19851978
```
19861979

1980+
### ``TfBuilder_0`` Class
1981+
1982+
```{eval-rst}
1983+
.. autoclass:: pymcnp.inp.data.TfBuilder_0
1984+
:members:
1985+
```
1986+
1987+
### ``TfBuilder_1`` Class
1988+
1989+
```{eval-rst}
1990+
.. autoclass:: pymcnp.inp.data.TfBuilder_1
1991+
:members:
1992+
```
1993+
19871994
### ``TmBuilder`` Class
19881995

19891996
```{eval-rst}

docs/source/pymcnp/inp/data/stop.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
:members:
1010
```
1111

12-
### ``Fk`` Class
12+
### ``F`` Class
1313

1414
```{eval-rst}
15-
.. autoclass:: pymcnp.inp.data.stop.Fk
15+
.. autoclass:: pymcnp.inp.data.stop.F
1616
:members:
1717
```
1818

scripts/inp_code.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ def _REGEX(element):
5151

5252
if 'Tuple' in attribute.type:
5353
if 'Option' in attribute.type:
54-
o += f'((?: (?:{{{SNAKE(element.name)}.{CAMEL(element.name, "Option")}._REGEX.pattern}}))+?)'
54+
o += f'((?: (?:{{{SNAKE(element.name)}.{CAMEL(element.name, "Option")}._REGEX.pattern[2:-2]}}))+?)'
5555
else:
56-
o += f'((?: {{{attribute.type[12:-1]}._REGEX.pattern}})+?)'
56+
o += f'((?: {{{attribute.type[12:-1]}._REGEX.pattern[2:-2]}})+?)'
5757
else:
5858
if 'Option' in attribute.type:
59-
o += f'( (?:{{{SNAKE(element.name)}.{CAMEL(element.name, "Option")}._REGEX.pattern}}))'
59+
o += f'( (?:{{{SNAKE(element.name)}.{CAMEL(element.name, "Option")}._REGEX.pattern[2:-2]}}))'
6060
elif attribute.type == 'types.Boolean':
6161
o += f'( {attribute.restriction})'
6262
else:
6363
if attribute.can_quote:
64-
o += f'( \\"{{{attribute.type}._REGEX.pattern}}\\")'
64+
o += f'( \\"{{{attribute.type}._REGEX.pattern[2:-2]}}\\")'
6565
elif attribute.can_paren:
66-
o += f'( {{{attribute.type}._REGEX.pattern}}| [(]{{{attribute.type}._REGEX.pattern}}[)])'
66+
o += f'( {{{attribute.type}._REGEX.pattern[2:-2]}}| [(]{{{attribute.type}._REGEX.pattern[2:-2]}}[)])'
6767
else:
68-
o += f'( {{{attribute.type}._REGEX.pattern}})'
68+
o += f'( {{{attribute.type}._REGEX.pattern[2:-2]}})'
6969

7070
if attribute.optional:
7171
o += '?'

scripts/inp_data.py

Lines changed: 692 additions & 145 deletions
Large diffs are not rendered by default.

src/pymcnp/Inp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Inp(_object.McnpFile):
3030
"""
3131

3232
_REGEX = re.compile(
33-
r'((?:message:).+\n)?(.+(?:\n))([\s\S]+?(?:\n\n))([\s\S]+?(?:\n\n))([\s\S]+?(?:\n\n|\Z))([\S\s]+)?'
33+
r'\A((?:message:).+\n)?(.+(?:\n))([\s\S]+?(?:\n\n))([\s\S]+?(?:\n\n))([\s\S]+?(?:\n\n|\Z))([\S\s]+)?\Z'
3434
)
3535

3636
def __init__(

src/pymcnp/Meshtal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class Meshtal(_object.McnpFile):
1515
tallies: MESTHAL tallies.
1616
"""
1717

18-
_REGEX = re.compile(rf'({meshtal.Header._REGEX.pattern})((?:{meshtal.Tally._REGEX.pattern})+)')
18+
_REGEX = re.compile(
19+
rf'\A({meshtal.Header._REGEX.pattern[2:-2]})((?:{meshtal.Tally._REGEX.pattern[2:-2]})+)\Z'
20+
)
1921

2022
def __init__(
2123
self, header: meshtal.Header, tallies: typing.Generator[meshtal.Tally, None, None]

src/pymcnp/Outp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class Outp(_object.McnpFile):
2020
"""
2121

2222
_REGEX = re.compile(
23-
rf'({outp.Header._REGEX.pattern[2:-2]})'
23+
rf'\A({outp.Header._REGEX.pattern[2:-2]})'
2424
r'([\s\S]*)'
25-
rf'({outp.Footer._REGEX.pattern[2:-2]})'
25+
rf'({outp.Footer._REGEX.pattern[2:-2]})\Z'
2626
)
2727

2828
def __init__(

src/pymcnp/Ptrac.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class Ptrac(_object.McnpFile):
1616
"""
1717

1818
_REGEX = re.compile(
19-
rf'({ptrac.Header._REGEX.pattern})' rf'((?:{ptrac.History._REGEX.pattern})+)'
19+
rf'\A({ptrac.Header._REGEX.pattern[2:-2]})'
20+
rf'((?:{ptrac.History._REGEX.pattern[2:-2]})+)\Z'
2021
)
2122

2223
def __init__(

src/pymcnp/inp/Cell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Cell(Card):
2929
}
3030

3131
_REGEX = re.compile(
32-
rf'\A(\S+)( \S+)((?<! 0) \S+|(?<= 0))( [^a-z]+)( ({cell.CellOption._REGEX.pattern}))*\Z'
32+
rf'\A(\S+)( \S+)((?<! 0) \S+|(?<= 0))( [^a-z]+)( ({cell.CellOption._REGEX.pattern[2:-2]}))*\Z'
3333
)
3434

3535
def __init__(

src/pymcnp/inp/Data.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Data(Card):
1919

2020
_ATTRS = {'option': data.DataOption}
2121

22-
_REGEX = re.compile(rf'\A({data.DataOption._REGEX.pattern})\Z')
22+
_REGEX = re.compile(rf'\A({data.DataOption._REGEX.pattern[2:-2]})\Z')
2323

2424
def __init__(self, option: data.DataOption):
2525
"""
@@ -144,8 +144,7 @@ class DataBuilder:
144144
| data.EBuilder
145145
| data.TBuilder_0
146146
| data.TBuilder_1
147-
| data.CBuilder_0
148-
| data.CBuilder_1
147+
| data.CBuilder
149148
| data.FqBuilder
150149
| data.FmBuilder
151150
| data.DeBuilder
@@ -160,6 +159,8 @@ class DataBuilder:
160159
| data.SdBuilder
161160
| data.FuBuilder
162161
| data.FtBuilder
162+
| data.TfBuilder_0
163+
| data.TfBuilder_1
163164
| data.NotrnBuilder
164165
| data.PertBuilder
165166
| data.KpertBuilder
@@ -401,10 +402,8 @@ def unbuild(ast: Data):
401402
option = data.TBuilder_0.unbuild(ast.option)
402403
elif isinstance(ast.option, data.T_1):
403404
option = data.TBuilder_1.unbuild(ast.option)
404-
elif isinstance(ast.option, data.C_0):
405-
option = data.CBuilder_0.unbuild(ast.option)
406-
elif isinstance(ast.option, data.C_1):
407-
option = data.CBuilder_1.unbuild(ast.option)
405+
elif isinstance(ast.option, data.C):
406+
option = data.CBuilder.unbuild(ast.option)
408407
elif isinstance(ast.option, data.Fq):
409408
option = data.FqBuilder.unbuild(ast.option)
410409
elif isinstance(ast.option, data.Fm):
@@ -431,8 +430,8 @@ def unbuild(ast: Data):
431430
option = data.SdBuilder.unbuild(ast.option)
432431
elif isinstance(ast.option, data.Fu):
433432
option = data.FuBuilder.unbuild(ast.option)
434-
elif isinstance(ast.option, data.Ft):
435-
option = data.FtBuilder.unbuild(ast.option)
433+
elif isinstance(ast.option, data.Tf):
434+
option = data.TfBuilder.unbuild(ast.option)
436435
elif isinstance(ast.option, data.Notrn):
437436
option = data.NotrnBuilder.unbuild(ast.option)
438437
elif isinstance(ast.option, data.Pert):

0 commit comments

Comments
 (0)