Class for parsing input files. More...
#include <Parser.h>
Classes | |
struct | Error |
Public Member Functions | |
Parser (const std::vector< std::string > &input_filenames, const std::optional< std::vector< std::string >> &input_text={}) | |
Constructor given a list of input files, given in input_filenames . More... | |
Parser (const std::string &input_filename, const std::optional< std::string > &input_text={}) | |
Constructor, given a file in input_filename . More... | |
void | parse () |
Parses the inputs. More... | |
hit::Node & | getRoot () |
const std::vector< std::string > & | getInputFileNames () const |
const std::vector< std::string > & | getInputText () const |
const std::string & | getAppType () const |
void | setAppType (const std::string &app_type) |
void | setCommandLineParams (const std::vector< std::string > ¶ms) |
Sets the HIT parameters from the command line. More... | |
const std::string & | getLastInputFileName () const |
std::filesystem::path | getLastInputFilePath () const |
void | setThrowOnError (const bool throw_on_error) |
Set whether or not to throw Parse::Error on errors. More... | |
bool | getThrowOnError () const |
const std::set< std::string > & | getExtractedVars () const |
void | parseError (std::vector< hit::ErrorMessage > messages) const |
Helper for throwing an error with the given messages. More... | |
const hit::Node * | queryRoot () const |
hit::Node * | queryRoot () |
const hit::Node * | queryCommandLineRoot () const |
hit::Node * | queryCommandLineRoot () |
const hit::Node & | getCommandLineRoot () const |
hit::Node & | getCommandLineRoot () |
Static Public Member Functions | |
static std::string | joinErrorMessages (const std::vector< hit::ErrorMessage > &error_messages) |
Helper for combining error messages into a single, newline separated message. More... | |
static void | appendErrorMessages (std::vector< hit::ErrorMessage > &to, const std::vector< hit::ErrorMessage > &from) |
Helper for accumulating errors from a walker into an accumulation of errors. More... | |
static void | appendErrorMessages (std::vector< hit::ErrorMessage > &to, const hit::Error &error) |
Private Attributes | |
std::unique_ptr< hit::Node > | _root |
The root node, which owns the whole tree. More... | |
const std::vector< std::string > | _input_filenames |
The input file names. More... | |
std::vector< std::string > | _input_text |
The input text (may be filled during parse()) More... | |
std::unique_ptr< hit::Node > | _cli_root |
The root node for command line hit arguments. More... | |
std::string | _app_type |
The application types extracted from [Application] block. More... | |
bool | _throw_on_error |
Whether or not to throw on error. More... | |
std::optional< std::vector< std::string > > | _command_line_params |
The command line HIT parameters (if any) More... | |
std::set< std::string > | _extracted_vars |
Variables that have been extracted during brace expansion. More... | |
Class for parsing input files.
This class utilizes the GetPot library for actually tokenizing and parsing files. It is not currently designed for extensibility. If you wish to build your own parser, please contact the MOOSE team for guidance.
Parser::Parser | ( | const std::vector< std::string > & | input_filenames, |
const std::optional< std::vector< std::string >> & | input_text = {} |
||
) |
Constructor given a list of input files, given in input_filenames
.
Optionally, the file contents can be provided via text in input_text
.
Definition at line 143 of file Parser.C.
Parser::Parser | ( | const std::string & | input_filename, |
const std::optional< std::string > & | input_text = {} |
||
) |
Constructor, given a file in input_filename
.
Optionally, the file contents can be provided via text in input_text
.
Definition at line 155 of file Parser.C.
|
static |
Helper for accumulating errors from a walker into an accumulation of errors.
Definition at line 471 of file Parser.C.
Referenced by appendErrorMessages(), Moose::Builder::errorCheck(), parse(), Moose::Builder::setMapParameter(), Moose::Builder::setScalarComponentParameter(), Moose::Builder::setScalarParameter(), Moose::Builder::setVectorComponentParameter(), and Moose::Builder::setVectorParameter().
|
static |
Definition at line 478 of file Parser.C.
|
inline |
Definition at line 165 of file Parser.h.
const hit::Node & Parser::getCommandLineRoot | ( | ) | const |
If it doesn't exist, it means we haven't parsed yet
Definition at line 457 of file Parser.C.
Referenced by Moose::Builder::errorCheck(), parse(), and parseError().
hit::Node & Parser::getCommandLineRoot | ( | ) |
|
inline |
These are the variables that have been used during brace expansion.
Definition at line 206 of file Parser.h.
Referenced by Moose::Builder::build().
|
inline |
Definition at line 155 of file Parser.h.
Referenced by parse().
|
inline |
Definition at line 160 of file Parser.h.
Referenced by parse().
const std::string & Parser::getLastInputFileName | ( | ) | const |
Definition at line 286 of file Parser.C.
Referenced by getLastInputFilePath().
|
inline |
Definition at line 185 of file Parser.h.
Referenced by Moose::Builder::getPrimaryFileName().
hit::Node & Parser::getRoot | ( | ) |
If it doesn't exist, it means we haven't parsed yet
Definition at line 449 of file Parser.C.
Referenced by ActionFactory::create(), and parse().
|
inline |
This is used by the MooseServer to capture errors while retaining the root if possible
Definition at line 199 of file Parser.h.
Referenced by Moose::Builder::errorCheck().
|
static |
Helper for combining error messages into a single, newline separated message.
Definition at line 484 of file Parser.C.
Referenced by Moose::Builder::errorCheck(), and parseError().
void Parser::parse | ( | ) |
Parses the inputs.
Definition at line 299 of file Parser.C.
void Parser::parseError | ( | std::vector< hit::ErrorMessage > | messages | ) | const |
Helper for throwing an error with the given messages.
If throwOnError(), throw a Parser::Error (for the MooseServer). Otherwise, use mooseError() (for standard runs).
Definition at line 493 of file Parser.C.
Referenced by Moose::Builder::build(), Moose::Builder::errorCheck(), Moose::Builder::extractParams(), and parse().
|
inline |
If this is null, it means we haven't parsed yet
Definition at line 138 of file Parser.h.
Referenced by getCommandLineRoot(), and parseError().
|
inline |
Definition at line 139 of file Parser.h.
|
inline |
If this is null, it means we haven't parsed yet
Definition at line 121 of file Parser.h.
Referenced by getRoot(), and parse().
|
inline |
Definition at line 122 of file Parser.h.
|
inline |
Definition at line 170 of file Parser.h.
Referenced by parse().
void Parser::setCommandLineParams | ( | const std::vector< std::string > & | params | ) |
Sets the HIT parameters from the command line.
Definition at line 279 of file Parser.C.
|
inline |
Set whether or not to throw Parse::Error on errors.
This is used by the MooseServer to capture errors while retaining the root if possible
Definition at line 192 of file Parser.h.
|
private |
The application types extracted from [Application] block.
Definition at line 243 of file Parser.h.
Referenced by getAppType(), and setAppType().
|
private |
The root node for command line hit arguments.
Definition at line 240 of file Parser.h.
Referenced by parse(), and queryCommandLineRoot().
|
private |
The command line HIT parameters (if any)
Definition at line 249 of file Parser.h.
Referenced by parse(), and setCommandLineParams().
|
private |
Variables that have been extracted during brace expansion.
Definition at line 252 of file Parser.h.
Referenced by getExtractedVars(), and parse().
|
private |
The input file names.
Definition at line 234 of file Parser.h.
Referenced by getInputFileNames(), getLastInputFileName(), and Parser().
|
private |
The input text (may be filled during parse())
Definition at line 237 of file Parser.h.
Referenced by getInputText(), and parse().
|
private |
The root node, which owns the whole tree.
Definition at line 231 of file Parser.h.
Referenced by parse(), and queryRoot().
|
private |
Whether or not to throw on error.
Definition at line 246 of file Parser.h.
Referenced by getThrowOnError(), parseError(), and setThrowOnError().