A Practical guide to Parsing MCNP Inputs: Lessons Learned from Implementing Context-Free Parsing in MontePy
Monte Carlo N-Particle (MCNP) is a widely used Monte Carlo transport solver that began development in the 1960’s. Due to this MCNP input files uses a custom input syntax, for which there are no off-the-shelf parsing libraries available. For MontePy to create an effective Object-Oriented interface for MCNP input files, an context-free parser was implemented to be able to fully parse the files. MontePy uses a number of shortcuts and optimizations to avoid creating a single universal input file parser. . These lessons can be applied to working with the many other custom input syntax languages persistent throughout the nuclear industry.