00001 /*************************************************************************** 00002 tag: Peter Soetens Mon Jan 19 14:11:26 CET 2004 ValueParser.hpp 00003 00004 ValueParser.hpp - description 00005 ------------------- 00006 begin : Mon January 19 2004 00007 copyright : (C) 2004 Peter Soetens 00008 email : peter.soetens@mech.kuleuven.ac.be 00009 00010 *************************************************************************** 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU General Public * 00013 * License as published by the Free Software Foundation; * 00014 * version 2 of the License. * 00015 * * 00016 * As a special exception, you may use this file as part of a free * 00017 * software library without restriction. Specifically, if other files * 00018 * instantiate templates or use macros or inline functions from this * 00019 * file, or you compile this file and link it with other files to * 00020 * produce an executable, this file does not by itself cause the * 00021 * resulting executable to be covered by the GNU General Public * 00022 * License. This exception does not however invalidate any other * 00023 * reasons why the executable file might be covered by the GNU General * 00024 * Public License. * 00025 * * 00026 * This library is distributed in the hope that it will be useful, * 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00029 * Lesser General Public License for more details. * 00030 * * 00031 * You should have received a copy of the GNU General Public * 00032 * License along with this library; if not, write to the Free Software * 00033 * Foundation, Inc., 59 Temple Place, * 00034 * Suite 330, Boston, MA 02111-1307 USA * 00035 * * 00036 ***************************************************************************/ 00037 00038 #ifndef VALUEPARSER_HPP 00039 #define VALUEPARSER_HPP 00040 00041 #include "parser-types.hpp" 00042 #include "CommonParser.hpp" 00043 #include "PeerParser.hpp" 00044 #include "PropertyParser.hpp" 00045 #include "../ConfigurationInterface.hpp" 00046 00047 #include <memory> 00048 #include <map> 00049 00050 namespace RTT 00051 { 00052 namespace scripting { 00058 class ValueParser 00059 { 00060 rule_t constant, const_float, const_double, const_int, const_uint, const_bool, named_constant, 00061 const_string, const_char, const_hex; 00062 CommonParser& commonparser; 00063 PeerParser peerparser; 00064 PropertyParser propparser; 00065 00066 // a auto_ptr used only to make sure we don't forget to delete 00067 // the TaskVariableBase it holds.. Here we store a pointer to 00068 // the TaskVariableBase for a temporary variable we've just 00069 // parsed. If we parse a non-temporary, then we don't need to 00070 // delete it, as it remains in the values map, however a 00071 // constant only gets stored temporarily in ret, so this 00072 // variable makes sure it gets deleted. 00073 //std::auto_ptr<base::AttributeBase> deleter; 00074 // the internal::DataSource we've just parsed.. we only store it and 00075 // assume that the ProgramParser will do something useful with 00076 // it. We don't ever own it, and don't delete it, or set it to 00077 // 0.. 00078 base::DataSourceBase::shared_ptr ret; 00079 // contains the string constant we're parsing ( it has to be 00080 // parsed char-by-char, because of the way c_escape_ch_p works 00081 // ).. 00082 std::string mcurstring; 00083 00084 void seennamedconstant( iter_t begin, iter_t end ); 00085 void seenboolconstant( iter_t begin, iter_t end ); 00086 void seenintconstant( int c ); 00087 void seenhexconstant( unsigned int c ); 00088 void seenuintconstant( unsigned int c ); // RobWork uint -> unsigned int 00089 void seencharconstant( iter_t c ); 00090 void seenfloatconstant( double c ); 00091 void seendoubleconstant( double c ); 00092 void push_str_char( char c ); 00093 void seenstring(); 00094 void seennull(); 00095 void seenpeer(); 00096 00097 TaskContext* context; 00098 public: 00099 ValueParser( TaskContext* tc, CommonParser& cp ); 00100 00101 ~ValueParser(); 00105 void clear(); 00106 00107 rule_t& parser(); 00108 00109 const base::DataSourceBase::shared_ptr lastParsed() const 00110 { 00111 return ret; 00112 } 00113 }; 00114 }} 00115 00116 #endif