00001 /* 00002 The lestes compiler suite 00003 Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy 00004 Copyright (C) 2002, 2003, 2004, 2005 Petr Zika 00005 Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala 00006 Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina 00007 Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda 00008 Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar 00009 Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; version 2 of the License. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 See the full text of the GNU General Public License version 2, and 00021 the limitations in the file doc/LICENSE. 00022 00023 By accepting the license the licensee waives any and all claims 00024 against the copyright holder(s) related in whole or in part to the 00025 work, its use, and/or the inability to use it. 00026 00027 */ 00028 #ifndef lestes__lang__cplus__syn__parse_result_type_hh__included 00029 #define lestes__lang__cplus__syn__parse_result_type_hh__included 00030 00031 /*! \file 00032 * \brief Class for holding result of a parser run: success and the final token. 00033 * 00034 * For error reporting, we want to know the token (its location, actually) on 00035 * which the parser failed. Parser's parse() method returns an instance of 00036 * parse_result_type class which contains both the bool value (success) and the 00037 * last token read by the parser. 00038 * 00039 * \author Rudo 00040 */ 00041 00042 #include <lestes/common.hh> 00043 #include <lestes/intercode/intercode.g.hh> 00044 00045 package(lestes); 00046 package(lang); 00047 package(cplus); 00048 package(syn); 00049 00050 class bison_token; 00051 00052 /*! 00053 * \brief Class that contains data about a finished parser run. 00054 * 00055 * At the moment, it holds 00056 * - a boolean success flag 00057 * - token that was lat read by the parser 00058 * - as tree of the parsed input 00059 * 00060 * The AS tree is here primarily for debugging purposes. It has broad type 00061 * (as_base) and is only set when successfully parsing for real. This means 00062 * that failed runs and even successful disambiguation runs store NULL here. 00063 * 00064 */ 00065 class parse_result_type : public ::lestes::std::object { 00066 public: 00067 bool success_get() const; 00068 ptr<bison_token> last_token_get() const; 00069 ptr< ::lestes::intercode::as_base > as_result_get() const; 00070 /*! 00071 * \brief Creates an instance of the class. 00072 * 00073 * a_as_result is not const reference, as we allow literal NULL to 00074 * be passed in. (Nobody is doing that at the moment, though.) 00075 */ 00076 static ptr<parse_result_type> create( bool a_success, 00077 const ptr<bison_token> & a_last_token, 00078 ptr< ::lestes::intercode::as_base > a_as_result ); 00079 protected: 00080 parse_result_type( bool a_success, const ptr<bison_token> & a_last_token, 00081 ptr< ::lestes::intercode::as_base > a_as_result ); 00082 virtual void gc_mark(); 00083 private: 00084 const bool success; 00085 const srp<bison_token> last_token; 00086 const srp< ::lestes::intercode::as_base > as_result; 00087 }; 00088 00089 end_package(syn); 00090 end_package(cplus); 00091 end_package(lang); 00092 end_package(lestes); 00093 00094 #endif // lestes__lang__cplus__syn__parse_result_type_hh__included
1.5.1-20070107