https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Builder.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12// MOOSE includes
14#include "MooseTypes.h"
15#include "InputParameters.h"
16
17#include "hit/hit.h"
18
19#include <set>
20#include <vector>
21#include <string>
22#include <iomanip>
23#include <optional>
24
25// Forward declarations
26class ActionWarehouse;
27class SyntaxTree;
28class MooseApp;
29class Factory;
30class ActionFactory;
31class JsonSyntaxTree;
32class Parser;
33class Syntax;
34
35namespace Moose
36{
37class Builder;
38
39class UnusedWalker : public hit::Walker
40{
41public:
42 UnusedWalker(std::set<std::string> used, Builder & p) : _used(used), _builder(p) {}
43
44 void walk(const std::string & fullpath, const std::string & nodename, hit::Node * n) override;
45
46 std::vector<hit::ErrorMessage> errors;
47
48private:
49 std::set<std::string> _used;
51};
52
56class Builder : public ConsoleStreamInterface, public hit::Walker
57{
58public:
64
65 Builder(MooseApp & app, ActionWarehouse & action_wh, Parser & parser);
66 virtual ~Builder();
67
72
76 std::string getPrimaryFileName(bool stripLeadingPath = true) const;
77
82 void build();
83
90 void extractParams(const hit::Node * const section_node, InputParameters & p);
95 void extractParams(const std::string & prefix, InputParameters & p);
96
100 void initSyntaxFormatter(SyntaxFormatterType type, bool dump_mode);
101
105 void buildFullTree(const std::string & search_string);
106
110 void buildJsonSyntaxTree(JsonSyntaxTree & tree) const;
111
112 void walk(const std::string & fullpath, const std::string & nodepath, hit::Node * n);
113
114 void errorCheck(const libMesh::Parallel::Communicator & comm, bool warn_unused, bool err_unused);
115
116 std::vector<std::string> listValidParams(std::string & section_name);
117
118private:
122 bool isGlobal(const hit::Node & node) const;
123
130 const hit::Node * queryGlobalParamsNode() const;
131
145 hit::Node & _root;
146
148 std::unique_ptr<SyntaxTree> _syntax_formatter;
149
151 std::set<std::string> _extracted_vars;
152
154 std::vector<std::string> _secs_need_first;
155
157 std::vector<hit::ErrorMessage> _errors;
158
160 std::map<std::string, std::string> _deprecated_params;
161
164 mutable std::optional<const hit::Node *> _global_params_node;
165
166 void walkRaw(std::string fullpath, std::string nodepath, hit::Node * n);
167};
168}
Specialized factory for generic Action System objects.
Storage for action instances.
An inteface for the _console for outputting to the Console object.
Generic factory class for build all sorts of objects.
Definition Factory.h:29
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Holds the syntax in a Json::Value tree.
Base class for MOOSE-based applications.
Definition MooseApp.h:110
Parses MOOSE input using HIT/WASP.
Definition Builder.h:57
std::optional< const hit::Node * > _global_params_node
The hit Node for the [GlobalParams] block, if any If set (could be null), it means we have searched f...
Definition Builder.h:164
std::string getPrimaryFileName(bool stripLeadingPath=true) const
Return the primary (first) filename that was parsed.
Definition Builder.C:179
void walkRaw(std::string fullpath, std::string nodepath, hit::Node *n)
Definition Builder.C:186
std::set< std::string > _extracted_vars
The set of all variables extracted from the input file.
Definition Builder.h:151
void build()
Parse an input file (or text string if provided) consisting of hit syntax and setup objects in the MO...
Definition Builder.C:300
void buildJsonSyntaxTree(JsonSyntaxTree &tree) const
Use MOOSE Factories to construct a parameter tree for documentation or echoing input.
Definition Builder.C:417
std::map< std::string, std::string > _deprecated_params
Deprecation warnings (object type/param name) -> (message)
Definition Builder.h:160
virtual ~Builder()
Definition Builder.C:118
ActionWarehouse & _action_wh
Action warehouse that will be filled by actions.
Definition Builder.h:137
void walk(const std::string &fullpath, const std::string &nodepath, hit::Node *n)
Definition Builder.C:289
Syntax & _syntax
Reference to an object that defines input file syntax.
Definition Builder.h:141
Factory & _factory
The Factory associated with that MooseApp.
Definition Builder.h:135
ActionFactory & _action_factory
The Factory that builds actions.
Definition Builder.h:139
std::vector< hit::ErrorMessage > _errors
The errors accumulated during the walk.
Definition Builder.h:157
void errorCheck(const libMesh::Parallel::Communicator &comm, bool warn_unused, bool err_unused)
Definition Builder.C:358
const hit::Node * queryGlobalParamsNode() const
Get the [GlobalParams] section node if it exists.
Definition Builder.C:831
std::vector< std::string > _secs_need_first
The sections that we need to execute first (read during the final walk)
Definition Builder.h:154
MooseApp & _app
The MooseApp this Parser is part of.
Definition Builder.h:133
bool isGlobal(const hit::Node &node) const
Definition Builder.C:824
Parser & _parser
The front parser.
Definition Builder.h:143
std::vector< std::string > listValidParams(std::string &section_name)
Definition Builder.C:142
void initSyntaxFormatter(SyntaxFormatterType type, bool dump_mode)
Creates a syntax formatter for printing.
Definition Builder.C:400
hit::Node & _root
The root node from the Parser.
Definition Builder.h:145
void buildFullTree(const std::string &search_string)
Use MOOSE Factories to construct a full parse tree for documentation or echoing input.
Definition Builder.C:577
std::unique_ptr< SyntaxTree > _syntax_formatter
Object for holding the syntax parse tree.
Definition Builder.h:148
void extractParams(const hit::Node *const section_node, InputParameters &p)
Attempt to extract values from input starting with the section in input in section_node based on the ...
Definition Builder.C:664
static InputParameters validParams()
Parameters that are processed directly by the Parser and are valid anywhere in the input.
Definition Builder.C:121
std::vector< hit::ErrorMessage > errors
Definition Builder.h:46
std::set< std::string > _used
Definition Builder.h:49
UnusedWalker(std::set< std::string > used, Builder &p)
Definition Builder.h:42
void walk(const std::string &fullpath, const std::string &nodename, hit::Node *n) override
Definition Builder.C:159
Builder & _builder
Definition Builder.h:50
Class for parsing input files.
Definition Parser.h:102
Holding syntax for parsing input files.
Definition Syntax.h:22
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...