Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 7 | */ |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 8 | |
| 9 | #pragma once |
| 10 | #include <boost/spirit/home/x3.hpp> |
| 11 | #include "CTree.hpp" |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 12 | #include "ast.hpp" |
Václav Kubernát | 0a2a2e8 | 2018-05-11 13:59:12 +0200 | [diff] [blame^] | 13 | #include "grammars.hpp" |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 14 | namespace x3 = boost::spirit::x3; |
| 15 | namespace ascii = boost::spirit::x3::ascii; |
| 16 | using Cmd = std::vector<std::string>; |
| 17 | using x3::alpha; |
| 18 | using x3::lit; |
| 19 | using x3::char_; |
| 20 | using x3::_attr; |
| 21 | using x3::lexeme; |
| 22 | using ascii::space; |
| 23 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 24 | class InvalidCommandException : public std::invalid_argument { |
| 25 | public: |
| 26 | using std::invalid_argument::invalid_argument; |
| 27 | ~InvalidCommandException() override; |
| 28 | }; |
| 29 | |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 30 | class TooManyArgumentsException : public std::invalid_argument { |
| 31 | public: |
| 32 | using std::invalid_argument::invalid_argument; |
| 33 | ~TooManyArgumentsException() override; |
| 34 | }; |
| 35 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 36 | |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 37 | class CParser { |
| 38 | public: |
| 39 | CParser(const CTree& tree); |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 40 | cd_ parseCommand(const std::string& line); |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | const CTree& m_tree; |
| 44 | }; |