How iaea-nds/endf-parserpy works
Project type and purpose
• This is an open-source Python toolkit (“endf-parserpy”) for reading, writing, validating, converting, and manipulating ENDF-6 nuclear data files. It exposes both a command-line interface (CLI) and a programmatic API. Internally it uses an interpreter for pure-Python parsing, a compiler layer to generate high-performance C++ parsers, and a factory pattern to select between implementations.
File structure
• Top-level:
• endf_parserpy/cli – CLI entry points (“compare”, “convert”, “validate”, etc.)
• endf_parserpy/interpreter – pure-Python parsing logic, mapping ENDF records to dictionaries
• endf_parserpy/compiler – code-generation engine that emits C++ parser/writer modules from high-level recipes
• endf_parserpy/cpp_parsers – hand-written and generated C++ sources, plus Python bindings
• endf_parserpy/endf_recipes – recipe definitions for each ENDF-6 section (MF/MT), driving both interpreter and compiler
• endf_parserpy/utils & compat_wrappers – helper util functions and back-compatibility shims
• setup.py / pyproject.toml – packaging and dependency configuration
• docs/ & tests/ – documentation and automated test suites
README for additional insights
• Confirms a dual-mode parser (Python & C++), a “ParserFactory” for instantiating either, and core use cases (read, modify, write, compare, etc.). The README mentions endf_parserpy.EndfParserFactory.create(), parser.parsefile(), parser.writefile().
Detail and essential elements
• Don’t just group everything under “library”: break out interpreter, compiler, recipes, utils
• Factory pattern, the two parsing paths (Python vs. C++), and how recipes feed both paths
• How code_generator_parsing & code_generator_writing produce C++ boilerplate and templates
• That adding a new ENDF-6 recipe is a straightforward plugin by dropping a module under endf_recipes/