montepy.input_parser.data_parser module#
- class montepy.input_parser.data_parser.ClassifierParser#
Bases:
DataParser
A parser for parsing the first word or classifier of a data input.
Added in version 0.2.0: This was added with the major parser rework.
- Returns:
the classifier of the data input.
- Return type:
- classifier(p)#
The classifier of a data input.
This represents the first word of the data input. E.g.:
M4
, IMP:N,F104:p
- Return type:
- classifier_phrase(p)#
A classifier with its padding.
- Return type:
- data(p)#
- data_classifier(p)#
- data_input(p)#
- data_prefix(p)#
- debugfile = None#
- equals_sign(p)#
The seperation between a key and value for a parameter.
- Returns:
a str ValueNode
- Return type:
- errok()#
Clear the error status
- error(token)#
Default error handling.
Puts the data into a queue that can be pulled out later for one final clear debug.
- Parameters:
token (Token) – the token that broke the parsing rules.
- file_atom(p)#
- file_name(p)#
A file name.
- Return type:
str
- file_phrase(p)#
A file name with or without its padding.
- Returns:
a str ValueNode.
- Return type:
- identifier_phrase(p)#
A non-zero number with or without padding converted to int.
- Returns:
an int ValueNode
- Return type:
- index_position(value)#
- introduction(p)#
- isotope_fraction(p)#
- isotope_fractions(p)#
- kitchen_junk(p)#
- kitchen_sink(p)#
- line_position(value)#
- log = <montepy.input_parser.parser_base.SLY_Supressor object>#
- modifier(p)#
A character that modifies a classifier, e.g.,
*TR
.- Returns:
the modifier
- Return type:
str
- null_ident_phrase(p)#
A zero number with or without its padding, for identification.
- Returns:
an int ValueNode
- Return type:
- null_phrase(p)#
A zero number with or without its padding.
- Returns:
a float ValueNode
- Return type:
- number_phrase(p)#
A non-zero number with or without padding.
- Returns:
a float ValueNode
- Return type:
- numerical_phrase(p)#
Any number, including 0, with its padding.
- Returns:
a float ValueNode
- Return type:
- padding(p)#
Anything that is not semantically significant: white space, and comments.
- Returns:
All sequential padding.
- Return type:
- param_seperator(p)#
The seperation between a key and value for a parameter.
- Returns:
a str ValueNode
- Return type:
- parameter(p)#
A singular Key-value pair.
- Returns:
the parameter.
- Return type:
- parameters(p)#
A list of the parameters (key, value pairs) for this input.
- Returns:
all parameters
- Return type:
- parse(token_generator, input=None)#
Parses the token stream and returns a syntax tree.
If the parsing fails None will be returned. The error queue can be retrieved from
parser.log.clear_queue()
.- Parameters:
token_generator (generator) – the token generator from
lexer.tokenize
.input (Input) – the input that is being lexed and parsed.
- Return type:
- part(p)#
- particle_phrase(p)#
- particle_sequence(p)#
- particle_text(p)#
- particle_type(p)#
- precedence = (('left', 'SPACE'), ('left', 'TEXT'))#
- restart()#
Clears internal state information about the current parse.
Should be ran before a new object is parsed.
- shortcut_phrase(p)#
A complete shortcut, which should be used, and not shortcut_sequence.
- Returns:
the parsed shortcut.
- Return type:
- shortcut_sequence(p)#
A shortcut (repeat, multiply, interpolate, or jump).
- Returns:
the parsed shortcut.
- Return type:
- shortcut_start(p)#
- text_phrase(p)#
A string with or without its padding.
- Returns:
a str ValueNode.
- Return type:
- text_sequence(p)#
- tokens = {'COMMENT', 'COMPLEMENT', 'DOLLAR_COMMENT', 'FILE_PATH', 'INTERPOLATE', 'JUMP', 'KEYWORD', 'LIBRARY_SUFFIX', 'LOG_INTERPOLATE', 'MESSAGE', 'MULTIPLY', 'NULL', 'NUMBER', 'NUMBER_WORD', 'NUM_INTERPOLATE', 'NUM_JUMP', 'NUM_LOG_INTERPOLATE', 'NUM_MULTIPLY', 'NUM_REPEAT', 'PARTICLE', 'PARTICLE_SPECIAL', 'REPEAT', 'SOURCE_COMMENT', 'SPACE', 'SURFACE_TYPE', 'TALLY_COMMENT', 'TEXT', 'THERMAL_LAW', 'ZAID'}#
- track_positions = True#
- zaid_phrase(p)#
- class montepy.input_parser.data_parser.DataParser#
Bases:
MCNP_Parser
A parser for almost all data inputs.
Added in version 0.2.0: This was added with the major parser rework.
- Returns:
a syntax tree for the data input.
- Return type:
- classifier(p)#
The classifier of a data input.
This represents the first word of the data input. E.g.:
M4
, IMP:N,F104:p
- Return type:
- classifier_phrase(p)#
A classifier with its padding.
- Return type:
- data(p)#
- data_input(p)#
- data_prefix(p)#
- debugfile = None#
- equals_sign(p)#
The seperation between a key and value for a parameter.
- Returns:
a str ValueNode
- Return type:
- errok()#
Clear the error status
- error(token)#
Default error handling.
Puts the data into a queue that can be pulled out later for one final clear debug.
- Parameters:
token (Token) – the token that broke the parsing rules.
- file_atom(p)#
- file_name(p)#
A file name.
- Return type:
str
- file_phrase(p)#
A file name with or without its padding.
- Returns:
a str ValueNode.
- Return type:
- identifier_phrase(p)#
A non-zero number with or without padding converted to int.
- Returns:
an int ValueNode
- Return type:
- index_position(value)#
- introduction(p)#
- isotope_fraction(p)#
- isotope_fractions(p)#
- kitchen_junk(p)#
- kitchen_sink(p)#
- line_position(value)#
- log = <montepy.input_parser.parser_base.SLY_Supressor object>#
- modifier(p)#
A character that modifies a classifier, e.g.,
*TR
.- Returns:
the modifier
- Return type:
str
- null_ident_phrase(p)#
A zero number with or without its padding, for identification.
- Returns:
an int ValueNode
- Return type:
- null_phrase(p)#
A zero number with or without its padding.
- Returns:
a float ValueNode
- Return type:
- number_phrase(p)#
A non-zero number with or without padding.
- Returns:
a float ValueNode
- Return type:
- numerical_phrase(p)#
Any number, including 0, with its padding.
- Returns:
a float ValueNode
- Return type:
- padding(p)#
Anything that is not semantically significant: white space, and comments.
- Returns:
All sequential padding.
- Return type:
- param_seperator(p)#
The seperation between a key and value for a parameter.
- Returns:
a str ValueNode
- Return type:
- parameter(p)#
A singular Key-value pair.
- Returns:
the parameter.
- Return type:
- parameters(p)#
A list of the parameters (key, value pairs) for this input.
- Returns:
all parameters
- Return type:
- parse(token_generator, input=None)#
Parses the token stream and returns a syntax tree.
If the parsing fails None will be returned. The error queue can be retrieved from
parser.log.clear_queue()
.- Parameters:
token_generator (generator) – the token generator from
lexer.tokenize
.input (Input) – the input that is being lexed and parsed.
- Return type:
- part(p)#
- particle_phrase(p)#
- particle_sequence(p)#
- particle_text(p)#
- particle_type(p)#
- precedence = (('left', 'SPACE'), ('left', 'TEXT'))#
- restart()#
Clears internal state information about the current parse.
Should be ran before a new object is parsed.
- shortcut_phrase(p)#
A complete shortcut, which should be used, and not shortcut_sequence.
- Returns:
the parsed shortcut.
- Return type:
- shortcut_sequence(p)#
A shortcut (repeat, multiply, interpolate, or jump).
- Returns:
the parsed shortcut.
- Return type:
- shortcut_start(p)#
- text_phrase(p)#
A string with or without its padding.
- Returns:
a str ValueNode.
- Return type:
- text_sequence(p)#
- tokens = {'COMMENT', 'COMPLEMENT', 'DOLLAR_COMMENT', 'FILE_PATH', 'INTERPOLATE', 'JUMP', 'KEYWORD', 'LIBRARY_SUFFIX', 'LOG_INTERPOLATE', 'MESSAGE', 'MULTIPLY', 'NULL', 'NUMBER', 'NUMBER_WORD', 'NUM_INTERPOLATE', 'NUM_JUMP', 'NUM_LOG_INTERPOLATE', 'NUM_MULTIPLY', 'NUM_REPEAT', 'PARTICLE', 'PARTICLE_SPECIAL', 'REPEAT', 'SOURCE_COMMENT', 'SPACE', 'SURFACE_TYPE', 'TALLY_COMMENT', 'TEXT', 'THERMAL_LAW', 'ZAID'}#
- track_positions = True#
- zaid_phrase(p)#
- class montepy.input_parser.data_parser.ParamOnlyDataParser#
Bases:
DataParser
A parser for parsing parameter (key-value pair) only data inputs.
.e.g., SDEF
Added in version 0.3.0.
- Returns:
a syntax tree for the data input.
- Return type:
- classifier(p)#
The classifier of a data input.
This represents the first word of the data input. E.g.:
M4
, IMP:N,F104:p
- Return type:
- classifier_phrase(p)#
A classifier with its padding.
- Return type:
- data(p)#
- data_input(p)#
- data_prefix(p)#
- debugfile = None#
- equals_sign(p)#
The seperation between a key and value for a parameter.
- Returns:
a str ValueNode
- Return type:
- errok()#
Clear the error status
- error(token)#
Default error handling.
Puts the data into a queue that can be pulled out later for one final clear debug.
- Parameters:
token (Token) – the token that broke the parsing rules.
- file_atom(p)#
- file_name(p)#
A file name.
- Return type:
str
- file_phrase(p)#
A file name with or without its padding.
- Returns:
a str ValueNode.
- Return type:
- identifier_phrase(p)#
A non-zero number with or without padding converted to int.
- Returns:
an int ValueNode
- Return type:
- index_position(value)#
- introduction(p)#
- isotope_fraction(p)#
- isotope_fractions(p)#
- kitchen_junk(p)#
- kitchen_sink(p)#
- line_position(value)#
- log = <montepy.input_parser.parser_base.SLY_Supressor object>#
- modifier(p)#
A character that modifies a classifier, e.g.,
*TR
.- Returns:
the modifier
- Return type:
str
- null_ident_phrase(p)#
A zero number with or without its padding, for identification.
- Returns:
an int ValueNode
- Return type:
- null_phrase(p)#
A zero number with or without its padding.
- Returns:
a float ValueNode
- Return type:
- number_phrase(p)#
A non-zero number with or without padding.
- Returns:
a float ValueNode
- Return type:
- numerical_phrase(p)#
Any number, including 0, with its padding.
- Returns:
a float ValueNode
- Return type:
- padding(p)#
Anything that is not semantically significant: white space, and comments.
- Returns:
All sequential padding.
- Return type:
- param_data_input(p)#
- param_introduction(p)#
- param_seperator(p)#
The seperation between a key and value for a parameter.
- Returns:
a str ValueNode
- Return type:
- parameter(p)#
A singular Key-value pair.
- Returns:
the parameter.
- Return type:
- parameters(p)#
A list of the parameters (key, value pairs) for this input.
- Returns:
all parameters
- Return type:
- parse(token_generator, input=None)#
Parses the token stream and returns a syntax tree.
If the parsing fails None will be returned. The error queue can be retrieved from
parser.log.clear_queue()
.- Parameters:
token_generator (generator) – the token generator from
lexer.tokenize
.input (Input) – the input that is being lexed and parsed.
- Return type:
- part(p)#
- particle_phrase(p)#
- particle_sequence(p)#
- particle_text(p)#
- particle_type(p)#
- precedence = (('left', 'SPACE'), ('left', 'TEXT'))#
- restart()#
Clears internal state information about the current parse.
Should be ran before a new object is parsed.
- shortcut_phrase(p)#
A complete shortcut, which should be used, and not shortcut_sequence.
- Returns:
the parsed shortcut.
- Return type:
- shortcut_sequence(p)#
A shortcut (repeat, multiply, interpolate, or jump).
- Returns:
the parsed shortcut.
- Return type:
- shortcut_start(p)#
- spec_classifier(p)#
The classifier of a data input.
This represents the first word of the data input. E.g.:
M4
, IMP:N,F104:p
- Return type:
- spec_data_prefix(p)#
- spec_parameter(p)#
- spec_parameters(p)#
A list of the parameters (key, value pairs) for this input.
- Returns:
all parameters
- Return type:
- text_phrase(p)#
A string with or without its padding.
- Returns:
a str ValueNode.
- Return type:
- text_sequence(p)#
- tokens = {'COMMENT', 'COMPLEMENT', 'DOLLAR_COMMENT', 'FILE_PATH', 'INTERPOLATE', 'JUMP', 'KEYWORD', 'LIBRARY_SUFFIX', 'LOG_INTERPOLATE', 'MESSAGE', 'MULTIPLY', 'NULL', 'NUMBER', 'NUMBER_WORD', 'NUM_INTERPOLATE', 'NUM_JUMP', 'NUM_LOG_INTERPOLATE', 'NUM_MULTIPLY', 'NUM_REPEAT', 'PARTICLE', 'PARTICLE_SPECIAL', 'REPEAT', 'SOURCE_COMMENT', 'SPACE', 'SURFACE_TYPE', 'TALLY_COMMENT', 'TEXT', 'THERMAL_LAW', 'ZAID'}#
- track_positions = True#
- zaid_phrase(p)#