montepy.input_parser.mcnp_input.Input#
- class montepy.input_parser.mcnp_input.Input(input_lines, block_type, input_file=None, lineno=None)#
Bases:
ParsingNode
Represents a single MCNP “Input” e.g. a single cell definition.
- Parameters:
input_lines (list) – the lines read straight from the input file.
block_type (BlockType) – An enum showing which of three MCNP blocks this was inside of.
input_file (MCNP_InputFile) – the wrapper for the input file this is read from.
lineno (int) – the line number this input started at. 1-indexed.
Methods:
format_for_mcnp_input
(mcnp_version)Creates a string representation of this input that can be written to file.
tokenize
()Tokenizes this input as a stream of Tokens.
Attributes:
Prefixes for special comments like tally comments.
Enum representing which block of the MCNP input this came from.
The file this input file was read from.
The lines of the input read straight from the input file
The current lexer being used to parse this input.
The line number this input started on.
- format_for_mcnp_input(mcnp_version)#
Creates a string representation of this input that can be written to file.
- Parameters:
mcnp_version (tuple) – The tuple for the MCNP version that must be exported to.
- Returns:
a list of strings for the lines that this input will occupy.
- Return type:
list
- tokenize()#
Tokenizes this input as a stream of Tokens.
This is a generator of Tokens. This is context dependent based on
block_type()
.In a cell block
CellLexer
is used.In a surface block
SurfaceLexer
is used.In a data block
DataLexer
is used.
- Returns:
a generator of tokens.
- Return type:
Token
- SPECIAL_COMMENT_PREFIXES = ['fc', 'sc']#
Prefixes for special comments like tally comments.
- Return type:
list
- property block_type#
Enum representing which block of the MCNP input this came from.
- Return type:
- property input_file#
The file this input file was read from.
- Return type:
- property input_lines#
The lines of the input read straight from the input file
- Return type:
list
- property input_text#
- property lexer#
The current lexer being used to parse this input.
If not currently tokenizing this will be None.
- Return type:
- property line_number#
The line number this input started on.
This is 1-indexed.
- Return type:
int