From: Tom H. <tom...@us...> - 2004-07-08 02:15:44
|
Update of /cvsroot/rccparser/rccparser/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12748/src Modified Files: Makefile.am rcclexer.lpp rccparse.ypp rccparser.cpp rccparser.h Added Files: rcclexer.hpp Removed Files: rcclexer.h Log Message: 2003-07-01 Tom Howard <tom...@us...> * ./Makefile.am Corrected email addresses --- NEW FILE: rcclexer.hpp --- // -*-c++-*- /*************************************************************************** rcclexer.h Lexer for RoboCup language ------------------- begin : 24-JUNE-2002 copyright : (C) 2002 by Tom Howard email : tom...@us... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCCLEXER_H #define RCCLEXER_H #undef yyFlexLexer #define yyFlexLexer RCCFlexLexer #include <rcssbase/FlexLexer.h> #include <string> #include "rccparser.h" class RCCLexer : public yyFlexLexer { public: typedef rcc::Holder Holder; virtual int yylex(); inline int lex( Holder& holder ) { M_lexed_val = &holder; return yylex(); } private: Holder* M_lexed_val; }; namespace rcc { class Lexer : public RCCLexer { }; } #endif Index: Makefile.am =================================================================== RCS file: /cvsroot/rccparser/rccparser/src/Makefile.am,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Makefile.am 1 Jul 2003 03:44:48 -0000 1.43 --- Makefile.am 8 Jul 2004 02:15:30 -0000 1.44 *************** *** 29,33 **** rccparser.cpp ! librccparser_la_LDFLAGS = -version-info 3:0:3 # 1. Start with version information of `0:0:0' for each libtool library. # --- 29,33 ---- rccparser.cpp ! librccparser_la_LDFLAGS = -version-info 4:0:4 # 1. Start with version information of `0:0:0' for each libtool library. # *************** *** 55,63 **** pkginclude_HEADERS = \ ! rcclexer.h \ rccparser.h pkgdata_DATA = clang.data out.data ac_lib_rccparser.m4 AM_CXXFLAGS=-W --- 55,66 ---- pkginclude_HEADERS = \ ! rcclexer.hpp \ rccparser.h pkgdata_DATA = clang.data out.data ac_lib_rccparser.m4 + + + AM_CXXFLAGS=-W *************** *** 97,112 **** .lpp.cpp: $*.lpp ! $(FLEX) $(FLEXFLAGS) $(AM_FLEXFLAGS) -o$@.tmp $< ! sed 's/#include <FlexLexer\.h>/#include \"$*.h\"/;\ ! s/class istream;/#include <iosfwd>/;\ ! s/cin/std::cin/;s/cout/std::cout/;s/cerr/std::cerr/;\ ! s/ostream/std::ostream/;\ ! s/#include <istd::ostream.h>/#include <iostream>/;\ ! s/istream/std::istream/;\ ! s/std::std/std/g;\ ! s/rcclexer\.cpp\.tmp/rcclexer.cpp/;\ ! s/#include <unistd\.h>//;\ ! s/#include<unistd\.h>//' $@.tmp > $@ ! rm -f $@.tmp noinst_SCRIPTS = test_script_v7 test_script_v8 --- 100,111 ---- .lpp.cpp: $*.lpp ! $(FLEX) $(FLEXFLAGS) $(AM_FLEXFLAGS) $< ! sed 's/#include <FlexLexer\.h>/#include \"$*.hpp\"/;s/class istream;/\#include <iosfwd>\nusing namespace std;/;s/#include <iostream.h>/#include <iostream>/;s/lex\.yy\.c/$@/' lex.yy.c > $@ ! rm -f lex.yy.c ! ! .ll.cc: $*.ll ! $(FLEX) $(FLEXFLAGS) $(AM_FLEXFLAGS) $< ! sed 's/#include <FlexLexer\.h>/#include \"$*.h\"/;s/class istream;/\#include <iosfwd>\nusing namespace std;/;s/#include <iostream.h>/#include <iostream>/;s/lex\.yy\.c/$@/' lex.yy.c > $@ ! rm -f lex.yy.c noinst_SCRIPTS = test_script_v7 test_script_v8 Index: rcclexer.lpp =================================================================== RCS file: /cvsroot/rccparser/rccparser/src/rcclexer.lpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** rcclexer.lpp 30 Jun 2003 06:45:35 -0000 1.8 --- rcclexer.lpp 8 Jul 2004 02:15:30 -0000 1.9 *************** *** 20,24 **** %{ ! #include "rcclexer.h" #include "rccparse.h" #include <string> --- 20,24 ---- %{ ! #include "rcclexer.hpp" #include "rccparse.h" #include <string> Index: rccparse.ypp =================================================================== RCS file: /cvsroot/rccparser/rccparser/src/rccparse.ypp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** rccparse.ypp 30 Jun 2003 06:45:35 -0000 1.16 --- rccparse.ypp 8 Jul 2004 02:15:30 -0000 1.17 *************** *** 32,36 **** #include "rccparser.h" ! #include "rcclexer.h" --- 32,36 ---- #include "rccparser.h" ! #include "rcclexer.hpp" *************** *** 89,106 **** Parser::parseCLang( const char* message ) { #ifdef HAVE_SSTREAM ! std::istringstream strm( message ); #else ! std::istrstream strm( message ); #endif ! if( M_clang_parser.parse( strm ) ) ! { ! doParsedCLang( message ); ! return true; ! } ! else ! { ! return false; ! } } --- 89,111 ---- Parser::parseCLang( const char* message ) { + if( M_clang_parser ) + { #ifdef HAVE_SSTREAM ! std::istringstream strm( message ); #else ! std::istrstream strm( message ); #endif ! if( M_clang_parser->parse( strm ) ) ! { ! doParsedCLang( message ); ! return true; ! } ! else ! { ! return false; ! } ! } ! else ! return true; } Index: rccparser.cpp =================================================================== RCS file: /cvsroot/rccparser/rccparser/src/rccparser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rccparser.cpp 24 Mar 2003 18:15:21 -0000 1.1 --- rccparser.cpp 8 Jul 2004 02:15:30 -0000 1.2 *************** *** 21,25 **** #include "rccparser.h" ! #include "rcclexer.h" #include <algorithm> --- 21,25 ---- #include "rccparser.h" ! #include "rcclexer.hpp" #include <algorithm> Index: rccparser.h =================================================================== RCS file: /cvsroot/rccparser/rccparser/src/rccparser.h,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** rccparser.h 30 Jun 2003 06:45:35 -0000 1.38 --- rccparser.h 8 Jul 2004 02:15:30 -0000 1.39 *************** *** 278,294 **** -# rcc::Parser::doBuildInit() - You will also need to pass a rcss::Parser object (note the different - namespace) to rcc::Parser when it is - initialized. This so the rcssclangparser library that comes with rcsserver - can be used to parse CLang messages (thus making sure the CLang parsing is - always upto date). - Assuming the data to be parsed is in a char array, the following code would cause parsing to occur. \code ! rcss::clang::MsgBuilder clang_builder; ! rcss::clang::Parser clang_parser( clang_builder ); ! YourParser parser( clang_parser ); [...snip...] --- 278,286 ---- -# rcc::Parser::doBuildInit() Assuming the data to be parsed is in a char array, the following code would cause parsing to occur. \code ! YourParser parser(); [...snip...] *************** *** 302,305 **** --- 294,305 ---- \endcode + rcc::Parser does not provide parsing for CLang messages. instead + you can pass a rcss::Parser object (note the different + namespace) to rcc::Parser when it is + initialized. This will allow the rcssclangparser library that comes with rcsserver + can be used to parse CLang messages (thus making sure the CLang parsing is + always upto date). If rcc::Parser is not initialed with a CLang parsing + library then CLang messages will be ignored. + Instances of rcc::Parser derived classes can be used in a multi-threaded environment, but you will either need prevent *************** *** 1475,1483 **** void ! buildClangPlayerVersionMsg( ) { M_parser.doBuildClangPlayerVersionMsg( ); } void ! buildClangPlayerVersion( int min, int max ) { M_parser.doBuildClangPlayerVersion( min, max ); } --- 1475,1483 ---- void ! buildClangPlayerVersionMsg( ) { M_parser.doBuildClangPlayerVersionMsg( ); } void ! buildClangPlayerVersion( int min, int max ) { M_parser.doBuildClangPlayerVersion( min, max ); } *************** *** 1619,1623 **** Param M_param; ! rcss::Parser& M_clang_parser; friend int RCC_lex( rcc::Holder*, --- 1619,1623 ---- Param M_param; ! rcss::Parser* M_clang_parser; friend int RCC_lex( rcc::Holder*, *************** *** 1646,1658 **** /** Parser constructor. * ! * You will need to call this constuctor from your subclass's contructor. ! * The clang_parser parameter is a reference to another parser which will ! * be used for parsing CLang messages. This is compatible with the CLang ! * parser that is part of the simulator. * */ Parser( rcss::Parser& clang_parser ) : M_param( *this ), ! M_clang_parser( clang_parser ) {} --- 1646,1671 ---- /** Parser constructor. * ! * If you client does not need to support CLang, then you can call ! * this contructor from your subclass. This will cause all CLang ! * messages to be ignored. ! * ! */ ! Parser() ! : M_param( *this ), ! M_clang_parser( NULL ) ! {} ! ! /** Parser constructor. ! * ! * You will need to call this constuctor from your subclass's ! * contructor if you want to support CLang. The clang_parser ! * parameter is a reference to another parser which will be used for ! * parsing CLang messages. This is compatible with the CLang parser ! * that is part of the simulator. * */ Parser( rcss::Parser& clang_parser ) : M_param( *this ), ! M_clang_parser( &clang_parser ) {} *************** *** 1661,1664 **** --- 1674,1690 ---- {} + /** CLang initialisation function. + * + * If you do not, set the CLang parser during construction, you can + * specify the CLang parser at a later date by using this function. + * + */ + void + setCLangParser( rcss::Parser& clang_parser ) + { + M_clang_parser = &clang_parser; + } + + #ifdef DOXYGEN_ONLY /* The following functions are actually inherited from rcss::Parser, *************** *** 1736,1739 **** --- 1762,1769 ---- * Override this function in your subclass to * execute code \b after a CLang message has been parsed. + * + * \note this function will not be called if you have not intialized + * the parser with a CLang parser and have not set it with + * setClangParser(); * * If this function is not overridden then the default behaviour is to call --- rcclexer.h DELETED --- |