blob: 6db95e150c77a5e787777fb3b3e5be29cea0fc8e [file] [log] [blame]
Václav Kubernát624a8872018-03-02 17:28:47 +01001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
Václav Kubernátd6662962018-03-22 17:41:33 +01003 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
Václav Kubernát624a8872018-03-02 17:28:47 +01004 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
Václav Kubernátd6662962018-03-22 17:41:33 +01007*/
Václav Kubernát624a8872018-03-02 17:28:47 +01008
9#pragma once
10#include <boost/spirit/home/x3.hpp>
11#include "CTree.hpp"
Václav Kubernátd6662962018-03-22 17:41:33 +010012#include "ast.hpp"
Václav Kubernát624a8872018-03-02 17:28:47 +010013namespace x3 = boost::spirit::x3;
14namespace ascii = boost::spirit::x3::ascii;
15using Cmd = std::vector<std::string>;
16using x3::alpha;
17using x3::lit;
18using x3::char_;
19using x3::_attr;
20using x3::lexeme;
21using ascii::space;
22
Václav Kubernátb96eef72018-05-04 19:10:22 +020023class InvalidCommandException : public std::invalid_argument {
24public:
25 using std::invalid_argument::invalid_argument;
26 ~InvalidCommandException() override;
27};
28
Václav Kubernát624a8872018-03-02 17:28:47 +010029class TooManyArgumentsException : public std::invalid_argument {
30public:
31 using std::invalid_argument::invalid_argument;
32 ~TooManyArgumentsException() override;
33};
34
Václav Kubernátb96eef72018-05-04 19:10:22 +020035
Václav Kubernát624a8872018-03-02 17:28:47 +010036class CParser {
37public:
38 CParser(const CTree& tree);
Václav Kubernátd6662962018-03-22 17:41:33 +010039 cd_ parseCommand(const std::string& line);
Václav Kubernát624a8872018-03-02 17:28:47 +010040
41private:
42 const CTree& m_tree;
43};