00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 %{
00026 #define yyparse VOS::msgparse
00027 #define yylex msglex
00028 #define yyerror msgerror
00029 #define yylval msglval
00030 #define yychar msgchar
00031 #define yydebug msgdebug
00032 #define yynerrs msgnerrs
00033
00034 #define YYSTYPE char*
00035
00036 #include <vos/vosdefs.hh>
00037 #include <vos/parsemessage_parser.h>
00038 #include <vos/messageblock.hh>
00039 #include <vos/message.hh>
00040
00041 #define YYERROR_VERBOSE
00042 #define YYPARSE_PARAM extra
00043 #define YYLEX_PARAM extra
00044
00045 #undef __GNUC_MINOR__
00046 %}
00047
00048 %token TAG
00049 %token SPACE
00050 %token QUOTESTR
00051 %token CDATA
00052 %token MESSAGEBLOCK
00053 %token COMMENT
00054 %pure_parser
00055 %%
00056
00057 start: cspace messageblock { ((parse_state_t*)extra)->done=1; }
00058 | cspace message { ((parse_state_t*)extra)->done=1; }
00059 ;
00060
00061 messageblock: '<' MESSAGEBLOCK aspace options ospace '>' cspace messages cspace '<' '/' MESSAGEBLOCK '>'
00062 | '<' MESSAGEBLOCK aspace options ospace '>' cspace '<' '/' MESSAGEBLOCK '>'
00063 | '<' MESSAGEBLOCK '>' cspace messages cspace '<' '/' MESSAGEBLOCK '>'
00064 ;
00065
00066 options: option
00067 | options aspace option
00068 ;
00069
00070 option: TAG '=' '"' QUOTESTR '"' {
00071 string astr($1);
00072 if(astr == "name") {
00073 ((parse_state_t*)extra)->m->setName($4);
00074 } else if(astr == "length") {
00075 ((parse_state_t*)extra)->expected_length = abs(atoi($4));
00076 }
00077 free($1);
00078 free($4);
00079 }
00080 ;
00081
00082 messages: message
00083 | messages cspace message
00084 ;
00085
00086 message: begintag cspace params cspace endtag
00087 | begintag cspace endtag
00088 | begintagonly
00089 ;
00090
00091 tagstart: '<' TAG {
00092 pREF(VOS::Message*, m, new VOS::Message(),
00093 ((parse_state_t*)extra)->m->insertMessage(-1, m);
00094 m->setType($2);
00095 );
00096 free($2);
00097 };
00098
00099 begintag: tagstart aspace attributes ospace '>'
00100 ;
00101
00102 begintagonly: tagstart aspace attributes ospace '/' '>'
00103 ;
00104
00105 endtag: '<' '/' TAG '>' {
00106 free($3);
00107 }
00108 ;
00109
00110 attributes: attr
00111 | attributes aspace attr
00112 ;
00113
00114 attr: TAG '=' '"' QUOTESTR '"' {
00115 string astr($1);
00116 if(astr == "to") {
00117 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->setTo($4));
00118 } else if(astr == "from") {
00119 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->setFrom($4));
00120 } else if(astr == "method") {
00121 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->setMethod($4));
00122 } else if(astr == "nonce") {
00123 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->setNonce($4));
00124 } else if(astr == "length") {
00125 if(((parse_state_t*)extra)->expected_length == 0)
00126 ((parse_state_t*)extra)->expected_length = abs(atoi($4));
00127 } else if(astr == "time") {
00128 float x;
00129 sscanf($4, "%f", &x);
00130 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->setTime(x));
00131 } else if(astr == "depends") {
00132 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->setDependency($4));
00133 }
00134 free($1);
00135 free($4);
00136 }
00137 ;
00138
00139 aspace: SPACE | COMMENT aspace | SPACE aspace;
00140
00141 ospace: | COMMENT ospace | SPACE ospace
00142 ;
00143
00144 cspace: | COMMENT cspace | CDATA cspace {
00145 free($1);
00146 };
00147
00148 params: param
00149 | params cspace param
00150 ;
00151
00152 param: '<' TAG '>' CDATA '<' '/' TAG '>' {
00153 if(strcmp($2, $7)==0) {
00154 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->insertField(-1, $2, $4));
00155 }
00156 free($2);
00157 free($4);
00158 free($7);
00159 } | beginquotedparam quotedcdata endquotedparam
00160 | '<' TAG '>' '<' '/' TAG '>' {
00161 free($2);
00162 free($6);
00163 if(strcmp($2, $6)==0) {
00164 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->insertField(-1, $2, ""));
00165 }
00166 } | '<' TAG ospace '/' '>' {
00167 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(), m->insertField(-1, $2, ""));
00168 free($2);
00169 }
00170 ;
00171
00172 beginquotedparam: '<' TAG aspace TAG '=' '"' QUOTESTR '"' ospace '>' {
00173 string astr($4);
00174
00175 if(astr == "length") {
00176 pREF(VOS::Message*, m, ((parse_state_t*)extra)->m->lastMessage(),
00177 m->insertField(-1, $2, "");
00178 ((parse_state_t*)extra)->read_quoted = abs(atoi($7));
00179 );
00180 }
00181 free($2);
00182 free($4);
00183 free($7);
00184 }
00185 ;
00186
00187 quotedcdata: CDATA {
00188 ((parse_state_t*)extra)->read_quoted = 0;
00189 }
00190 ;
00191
00192 endquotedparam: '<' '/' TAG '>'
00193 ;