Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
LhaParser Class Reference

Parser for LHA/FLHA files, producing blocks and a DBNode representation. More...

#include <LhaParser.h>

Inheritance diagram for LhaParser:
Collaboration diagram for LhaParser:

Public Member Functions

std::shared_ptr< DBNodereadFromFile (const std::string &input_file) const override
 Parses an LHA/FLHA file from disk and returns its DBNode representation.
 
std::shared_ptr< DBNodeparse (const std::string &src) const override
 Parses LHA/FLHA content from an in-memory string.
 
void writeToFile (const std::string &filename, const std::shared_ptr< DBNode > &root) const
 Serializes a DBNode structure back to an LHA-like file.
 
void set_prototypes (const std::unordered_set< Prototype > &prototypes)
 Sets the set of block prototypes used by the parser.
 
- Public Member Functions inherited from IParser
virtual ~IParser ()=default
 Virtual destructor to allow proper cleanup via base pointer.
 

Detailed Description

Parser for LHA/FLHA files, producing blocks and a DBNode representation.

LhaParser implements the IParser interface using the LHA/FLHA conventions:

  • BLOCK sections are recognized via the "Block" keyword,
  • DECAY sections are recognized via the "Decay" keyword (and currently skipped),
  • each block is associated to a Prototype (block layout),
  • each line in a block is converted into an LhaElement<T>,
  • all blocks are then converted into a top-level DBNode tree.

The set of known prototypes can be configured via set_prototypes() (e.g. using LHA_BLOCKS, SLHA_BLOCKS, FLHA_BLOCKS).

Definition at line 113 of file LhaParser.h.

Member Function Documentation

◆ parse()

std::shared_ptr< DBNode > LhaParser::parse ( const std::string &  src) const
overridevirtual

Parses LHA/FLHA content from an in-memory string.

The pipeline is:

  • tokenize(src),
  • parse_tokens(...),
  • construct LhaBlocks for all recognized blocks,
  • convert them to a DBNode via toDBNode().
Parameters
srcRaw LHA/FLHA text.
Returns
Shared pointer to the root DBNode representation.
Exceptions
std::runtime_erroron lexical or structural errors.

Implements IParser.

Definition at line 165 of file LhaParser.cpp.

◆ readFromFile()

std::shared_ptr< DBNode > LhaParser::readFromFile ( const std::string &  input_file) const
overridevirtual

Parses an LHA/FLHA file from disk and returns its DBNode representation.

This implementation:

  • loads the file into memory,
  • delegates to parse(src).
Parameters
input_filePath to the LHA/FLHA file to read.
Returns
Shared pointer to the root DBNode representation.
Exceptions
std::runtime_errorif the file cannot be opened or parsing fails.

Implements IParser.

Definition at line 158 of file LhaParser.cpp.

◆ set_prototypes()

void LhaParser::set_prototypes ( const std::unordered_set< Prototype > &  prototypes)

Sets the set of block prototypes used by the parser.

Typical usage is to pass one of the predefined sets:

  • LHA_BLOCKS,
  • SLHA_BLOCKS,
  • FLHA_BLOCKS, or their union, depending on the type of file being parsed.
Parameters
prototypesSet of Prototype objects describing known blocks.

Definition at line 177 of file LhaParser.cpp.

◆ writeToFile()

void LhaParser::writeToFile ( const std::string &  filename,
const std::shared_ptr< DBNode > &  root 
) const
virtual

Serializes a DBNode structure back to an LHA-like file.

Currently marked as TODO in the implementation. The intended design is to invert the toDBNode/LhaBlock/LhaElement pipeline in order to reconstruct a valid LHA/FLHA text file from a DBNode tree.

Parameters
filenameTarget file name.
rootRoot DBNode to serialize.

Implements IParser.

Definition at line 644 of file LhaParser.cpp.


The documentation for this class was generated from the following files: