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 | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 13 | namespace x3 = boost::spirit::x3; |
| 14 | namespace ascii = boost::spirit::x3::ascii; |
| 15 | using Cmd = std::vector<std::string>; |
| 16 | using x3::alpha; |
| 17 | using x3::lit; |
| 18 | using x3::char_; |
| 19 | using x3::_attr; |
| 20 | using x3::lexeme; |
| 21 | using ascii::space; |
| 22 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame^] | 23 | class InvalidCommandException : public std::invalid_argument { |
| 24 | public: |
| 25 | using std::invalid_argument::invalid_argument; |
| 26 | ~InvalidCommandException() override; |
| 27 | }; |
| 28 | |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 29 | class TooManyArgumentsException : public std::invalid_argument { |
| 30 | public: |
| 31 | using std::invalid_argument::invalid_argument; |
| 32 | ~TooManyArgumentsException() override; |
| 33 | }; |
| 34 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame^] | 35 | |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 36 | class CParser { |
| 37 | public: |
| 38 | CParser(const CTree& tree); |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 39 | cd_ parseCommand(const std::string& line); |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 40 | |
| 41 | private: |
| 42 | const CTree& m_tree; |
| 43 | }; |