| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester |
| 3 | Copyright (C) 2015-2017 Dmitry Tsarkov |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU General Public License |
| 7 | as published by the Free Software Foundation; either version 2 |
| 8 | of the License, or (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, write to the Free Software |
| 17 | Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef COMPARSER_H |
| 21 | #define COMPARSER_Hcxx . . $ `FaCT++/comparser.h:21:9`! |
| 22 | |
| 23 | #include "comscanner.h"cxx . . $ `<file>/FaCT++/comscanner.h`/ |
| 24 | |
| 25 | /// generic class for parsing with usage of scanner derived from CommonScanner |
| 26 | template <typename Scanner> |
| 27 | class CommonParsercxx . . $ CommonParser# |
| 28 | { |
| 29 | protected: // members |
| 30 | /// used scanner |
| 31 | Scanner scancxx . . $ CommonParser#scan.; |
| 32 | /// last scanned token |
| 33 | GenericTokencxx . . $ `FaCT++/parser.h:24:9`! Currentcxx . . $ CommonParser#Current.; |
| 34 | |
| 35 | protected: // methods |
| 36 | /// get current token |
| 37 | GenericTokencxx . . $ `FaCT++/parser.h:24:9`! Codecxx . . $ CommonParser#Code(922db4e91ebad8cc). ( void ) const { return Currentcxx . . $ CommonParser#Current.; } |
| 38 | /// receive (and save) next token |
| 39 | void NextLexcxx . . $ CommonParser#NextLex(49f6e7a06ebc5aa8). ( void ) { Currentcxx . . $ CommonParser#Current. = scancxx . . $ CommonParser#scan..GetLex(); } |
| 40 | /// ensure that current token has given value; return error if it's not a case |
| 41 | void MustBecxx . . $ CommonParser#MustBe(9e9509433ff78145). ( GenericTokencxx . . $ `FaCT++/parser.h:24:9`! t, const char* message = nullptr ) const |
| 42 | { |
| 43 | if ( Currentcxx . . $ CommonParser#Current. != t ) |
| 44 | scancxx . . $ CommonParser#scan..error(message); |
| 45 | } |
| 46 | /// ensure that current token has given value; return error if it's not a case; get new token |
| 47 | void MustBeMcxx . . $ CommonParser#MustBeM(82d9ea22de4def4f). ( GenericTokencxx . . $ `FaCT++/parser.h:24:9`! t, const char* message = nullptr ) |
| 48 | { MustBecxx . . $ CommonParser#MustBe(9e9509433ff78145). ( t, message ); NextLexcxx . . $ CommonParser#NextLex(49f6e7a06ebc5aa8). (); } |
| 49 | /// general error message |
| 50 | [[noreturn]] void parseErrorcxx . . $ CommonParser#parseError(acfedb98bf840c77). ( const char* p ) const { scancxx . . $ CommonParser#scan..error(p); } |
| 51 | |
| 52 | public: // interface |
| 53 | /// c'tor |
| 54 | explicit CommonParsercxx . . $ CommonParser#`CommonParser<Scanner>`(6a35a7fc14119650). ( stdcxx . . $ std/::istreamcxx . . $ std/istream#* in ) : scancxx . . $ CommonParser#scan. ( in ) { NextLexcxx . . $ CommonParser#NextLex(49f6e7a06ebc5aa8). (); } |
| 55 | /// empty d'tor |
| 56 | virtual ~cxx . . $ CommonParser#`~CommonParser<Scanner>`(49f6e7a06ebc5aa8).CommonParser() = default; |
| 57 | }; // CommonParser |
| 58 | |
| 59 | #endif // _COMMON_PARSER_HPP |