blob: cb92b12d718b09c7b39340efee855daaeaacde15 [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át0a2a2e82018-05-11 13:59:12 +020013#include "grammars.hpp"
Václav Kubernát624a8872018-03-02 17:28:47 +010014namespace x3 = boost::spirit::x3;
15namespace ascii = boost::spirit::x3::ascii;
16using Cmd = std::vector<std::string>;
17using x3::alpha;
18using x3::lit;
19using x3::char_;
20using x3::_attr;
21using x3::lexeme;
22using ascii::space;
23
Václav Kubernátb96eef72018-05-04 19:10:22 +020024class InvalidCommandException : public std::invalid_argument {
25public:
26 using std::invalid_argument::invalid_argument;
27 ~InvalidCommandException() override;
28};
29
Václav Kubernát624a8872018-03-02 17:28:47 +010030class TooManyArgumentsException : public std::invalid_argument {
31public:
32 using std::invalid_argument::invalid_argument;
33 ~TooManyArgumentsException() override;
34};
35
Václav Kubernátb96eef72018-05-04 19:10:22 +020036
Václav Kubernát624a8872018-03-02 17:28:47 +010037class CParser {
38public:
39 CParser(const CTree& tree);
Václav Kubernát2315c732018-05-16 20:25:55 +020040 cd_ parseCommand(const std::string& line, std::ostream& errorStream);
Václav Kubernát624a8872018-03-02 17:28:47 +010041
42private:
43 const CTree& m_tree;
44};