| 1 | /* |
| 2 | * Copyright (C) 2016 Mark Roszko <[email protected]> |
| 3 | * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef SEXPR_PARSER_H_ |
| 20 | #define SEXPR_PARSER_H_ |
| 21 | |
| 22 | #include "sexpr/sexpr.h" |
| 23 | |
| 24 | #include <memory> |
| 25 | #include <string> |
| 26 | #include <vector> |
| 27 | |
| 28 | |
| 29 | namespace SEXPR |
| 30 | { |
| 31 | class PARSER |
| 32 | { |
| 33 | public: |
| 34 | PARSER(); |
| 35 | ~PARSER(); |
| 36 | std::unique_ptr<SEXPR> Parse( const std::string& aString ); |
| 37 | std::unique_ptr<SEXPR> ParseFromFile( const std::string& aFilename ); |
| 38 | static std::string GetFileContents( const std::string& aFilename ); |
| 39 | |
| 40 | private: |
| 41 | std::unique_ptr<SEXPR> parseString( |
| 42 | const std::string& aString, std::string::const_iterator& it ); |
| 43 | static const std::string whitespaceCharacters; |
| 44 | int m_lineNumber; |
| 45 | }; |
| 46 | } |
| 47 | |
| 48 | #endif |