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. | |
| Parser (const std::string &input_filename, const std::optional< std::string > &input_text={}) | |
Constructor, given a file in input_filename. | |
| void | parse () |
| Parses the inputs. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| const std::vector< std::string > | _input_filenames |
| The input file names. | |
| std::vector< std::string > | _input_text |
| The input text (may be filled during parse()) | |
| std::unique_ptr< hit::Node > | _cli_root |
| The root node for command line hit arguments. | |
| std::string | _app_type |
| The application types extracted from [Application] block. | |
| bool | _throw_on_error |
| Whether or not to throw on error. | |
| std::optional< std::vector< std::string > > | _command_line_params |
| The command line HIT parameters (if any) | |
| std::set< std::string > | _extracted_vars |
| Variables that have been extracted during brace expansion. | |
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 215 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.
|
static |
Definition at line 554 of file Parser.C.
|
static |
Helper for accumulating errors from a walker into an accumulation of errors.
Definition at line 547 of file Parser.C.
Referenced by appendErrorMessages(), Moose::Builder::errorCheck(), and parse().
|
inline |
Definition at line 179 of file Parser.h.
| hit::Node & Parser::getCommandLineRoot | ( | ) |
| const hit::Node & Parser::getCommandLineRoot | ( | ) | const |
If it doesn't exist, it means we haven't parsed yet
Definition at line 533 of file Parser.C.
Referenced by Moose::Builder::errorCheck(), parse(), and parseError().
|
inline |
These are the variables that have been used during brace expansion.
Definition at line 220 of file Parser.h.
Referenced by Moose::Builder::build().
|
inline |
|
inline |
| const std::string & Parser::getLastInputFileName | ( | ) | const |
Definition at line 358 of file Parser.C.
Referenced by getLastInputFilePath().
|
inline |
Definition at line 199 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 525 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 213 of file Parser.h.
Referenced by Moose::Builder::errorCheck().
|
static |
Helper for combining error messages into a single, newline separated message.
Definition at line 560 of file Parser.C.
Referenced by Moose::Builder::errorCheck(), and parseError().
| void Parser::parse | ( | ) |
Parses the inputs.
Definition at line 371 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 569 of file Parser.C.
Referenced by Moose::Builder::build(), Moose::Builder::errorCheck(), and parse().
|
inline |
|
inline |
If this is null, it means we haven't parsed yet
Definition at line 152 of file Parser.h.
Referenced by Moose::Builder::errorCheck(), getCommandLineRoot(), and parseError().
|
inline |
|
inline |
|
inline |
| void Parser::setCommandLineParams | ( | const std::vector< std::string > & | params | ) |
Sets the HIT parameters from the command line.
|
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 206 of file Parser.h.
|
private |
The application types extracted from [Application] block.
Definition at line 257 of file Parser.h.
Referenced by getAppType(), and setAppType().
|
private |
The root node for command line hit arguments.
Definition at line 254 of file Parser.h.
Referenced by parse(), queryCommandLineRoot(), and queryCommandLineRoot().
|
private |
The command line HIT parameters (if any)
Definition at line 263 of file Parser.h.
Referenced by parse(), and setCommandLineParams().
|
private |
Variables that have been extracted during brace expansion.
Definition at line 266 of file Parser.h.
Referenced by getExtractedVars(), and parse().
|
private |
The input file names.
Definition at line 248 of file Parser.h.
Referenced by getInputFileNames(), getLastInputFileName(), and Parser().
|
private |
The input text (may be filled during parse())
Definition at line 251 of file Parser.h.
Referenced by getInputText(), and parse().
|
private |
The root node, which owns the whole tree.
Definition at line 245 of file Parser.h.
Referenced by parse(), queryRoot(), and queryRoot().
|
private |
Whether or not to throw on error.
Definition at line 260 of file Parser.h.
Referenced by getThrowOnError(), parseError(), and setThrowOnError().