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> |
Václav Kubernát | 0a2a2e8 | 2018-05-11 13:59:12 +0200 | [diff] [blame] | 11 | #include "grammars.hpp" |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 12 | namespace x3 = boost::spirit::x3; |
| 13 | namespace ascii = boost::spirit::x3::ascii; |
| 14 | using Cmd = std::vector<std::string>; |
| 15 | using x3::alpha; |
| 16 | using x3::lit; |
| 17 | using x3::char_; |
| 18 | using x3::_attr; |
| 19 | using x3::lexeme; |
| 20 | using ascii::space; |
| 21 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 22 | class InvalidCommandException : public std::invalid_argument { |
| 23 | public: |
| 24 | using std::invalid_argument::invalid_argument; |
| 25 | ~InvalidCommandException() override; |
| 26 | }; |
| 27 | |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 28 | class TooManyArgumentsException : public std::invalid_argument { |
| 29 | public: |
| 30 | using std::invalid_argument::invalid_argument; |
| 31 | ~TooManyArgumentsException() override; |
| 32 | }; |
| 33 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 34 | |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 35 | class CParser { |
| 36 | public: |
| 37 | CParser(const CTree& tree); |
Václav Kubernát | 2315c73 | 2018-05-16 20:25:55 +0200 | [diff] [blame] | 38 | cd_ parseCommand(const std::string& line, std::ostream& errorStream); |
Václav Kubernát | 2a9e179 | 2018-05-28 12:53:48 +0200 | [diff] [blame^] | 39 | void changeNode(const path_& name); |
| 40 | std::string currentNode() const; |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | const CTree& m_tree; |
Václav Kubernát | 2a9e179 | 2018-05-28 12:53:48 +0200 | [diff] [blame^] | 44 | std::string m_curDir; |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 45 | }; |