My Project
Loading...
Searching...
No Matches
ActionParser.hpp
1/*
2 Copyright 2019 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef ACTION_PARSER_HPP
21#define ACTION_PARSER_HPP
22
23#include <vector>
24#include <string>
25
26#include <opm/input/eclipse/Schedule/Action/ASTNode.hpp>
27#include <opm/input/eclipse/Schedule/Action/ActionValue.hpp>
28
29namespace Opm {
30
31namespace Action {
32
33struct ParseNode {
34 ParseNode(TokenType type_arg, const std::string& value_arg) :
35 type(type_arg),
36 value(value_arg)
37 {}
38
39 // Implicit converting constructor.
40 ParseNode(TokenType type_arg) : ParseNode(type_arg, "")
41 {}
42
43
44 TokenType type;
45 std::string value;
46};
47
48
49
50class Parser {
51public:
52 static Action::ASTNode parse(const std::vector<std::string>& tokens);
53 static TokenType get_type(const std::string& arg);
54 static FuncType get_func(const std::string& arg);
55
56private:
57 explicit Parser(const std::vector<std::string>& tokens);
58
59 ParseNode current() const;
60 ParseNode next();
61 size_t pos() const;
62 Action::ASTNode parse_cmp();
63 Action::ASTNode parse_op();
64 Action::ASTNode parse_left();
65 Action::ASTNode parse_right();
66 Action::ASTNode parse_and();
67 Action::ASTNode parse_or();
68
69 const std::vector<std::string>& tokens;
70 ssize_t current_pos = -1;
71};
72
73
74}
75}
76#endif
Definition ASTNode.hpp:15
Definition ActionParser.hpp:50
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition ActionParser.hpp:33