Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

vos/corelibs/vos/parsemessage_lexer.ll

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project.
00004 
00005     Copyright (C) 2003 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <amstutz@cs.umass.edu>
00022 */
00023 %{
00024 #include <stdio.h>
00025 #include "parsemessage_parser.h"
00026 #include "msglexer.hh"
00027 #include "message.hh"
00028 #include "messageblock.hh"
00029 
00030 using namespace VOS;
00031 
00032 #define READQUOTED {                                         \
00033     if(parsestate->read_quoted) {                            \
00034         int ret;                                             \
00035         pREF(Message*, m, parsestate->m->lastMessage(),      \
00036             (m->fields.back()).quoted = true;                \
00037             std::string& target = (m->fields.back()).source; \
00038             target.resize(parsestate->read_quoted);          \
00039             int i;                                           \
00040             for(i = 0; i < yyleng; i++) {                    \
00041                 target[i] = yytext[i];                       \
00042             }                                                \
00043             for(; i < parsestate->read_quoted; i++) {        \
00044                 int c;                                       \
00045                 if((c = yyinput()) == EOF) break;            \
00046                 target[i] = c;                               \
00047             }                                                \
00048             parsestate->chars_read += i;                     \
00049             if(i != parsestate->read_quoted) ret = EOF;      \
00050             else ret = CDATA;                                \
00051         );                                                   \
00052         return ret;                                          \
00053     }                                                        \
00054 }
00055 
00056 
00057 %}
00058 /*
00059 #define cin std::cin
00060 #define cout std::cout
00061 #define istream std::istream
00062 #define ostream std::ostream
00063 */
00064 
00065 %option c++
00066 %option noyywrap
00067 %option yyclass="msgFlexLexer"
00068 %x S_TAG
00069 %x S_ATTRIBUTES
00070 %x S_EQ
00071 %x S_QUOTE
00072 %x S_QUOTESTR
00073 %x S_TAGEND
00074 %%
00075 <INITIAL>[^<]+ { READQUOTED; return CDATA; }
00076 <INITIAL>\<!--([^-]|--[^>])*--\> { READQUOTED; return COMMENT; }
00077 <INITIAL>\< { READQUOTED; BEGIN(S_TAG); return yytext[0]; }
00078 <S_TAG>\/ { return yytext[0]; }
00079 <S_TAG>messageblock { BEGIN(S_ATTRIBUTES); return MESSAGEBLOCK; }
00080 <S_TAG>[[:alnum:]][[:alnum:]:_\-]*  { BEGIN(S_ATTRIBUTES); return TAG; }
00081 <S_TAG>. { return 0; }
00082 <S_ATTRIBUTES>[[:alnum:]:]+ { BEGIN(S_EQ); return TAG; }
00083 <S_ATTRIBUTES>[[:space:]]* { return SPACE; }
00084 <S_ATTRIBUTES>\<!--([^-]|--[^>])*--\> { return COMMENT; }
00085 <S_ATTRIBUTES>\/ { BEGIN(S_TAGEND); return yytext[0]; }
00086 <S_ATTRIBUTES>\> { BEGIN(INITIAL); return yytext[0]; }
00087 <S_ATTRIBUTES>. { return 0; }
00088 <S_EQ>= { BEGIN(S_QUOTE); return yytext[0]; }
00089 <S_EQ>. { return 0; }
00090 <S_QUOTE>\" {  BEGIN(S_QUOTESTR); return yytext[0]; }
00091 <S_QUOTE>. { return 0; }
00092 <S_QUOTESTR>[^"]* { return QUOTESTR; }
00093 <S_QUOTESTR>\" { BEGIN(S_ATTRIBUTES); return yytext[0]; }
00094 <S_TAGEND>> { BEGIN(INITIAL); return yytext[0]; }
00095 <S_TAGEND>. { return 0; }
00096 %%
00097 

Generated on Tue Aug 12 03:55:41 2003 for Interreality Project - VOS by doxygen 1.3.2