00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00060
00061
00062
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