Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bytelex.h
r98 r115 366 366 return s3int32(x8data) == c3int32<C, '<', '!', '['>::value; 367 367 } 368 368 template<CodeUnit_Base C> 369 inline bool at_xml(unsigned char x8data[]) { 370 return (s4int32(x8data) == c4int32<C, '?', 'x', 'm', 'l'>::value); 371 } 369 372 #endif -
trunk/src/engine.c
r111 r115 324 324 ScanTo(Hyphen); 325 325 while (!at_DoubleHyphen<C>(cur())) { 326 if(at_EOF()) 327 Syntax_Error(NT_CDSect); 326 328 Advance(2); /* Skip hyphen-nonhyphen pair */ 327 329 ScanTo(Hyphen); … … 369 371 ScanTo(CD_End_check); 370 372 while (!at_CDATA_End<C>(cur())) { 373 if(at_EOF()) 374 Syntax_Error(NT_CDSect); 371 375 Advance(1); 372 376 ScanTo(CD_End_check); … … 450 454 ScanTo(QMark); 451 455 while (!at_PI_End<C>(cur())) { 456 if(at_EOF()) 457 Syntax_Error(NT_PI); 452 458 Advance(1); 453 459 ScanTo(QMark); … … 644 650 ScanTo(NonWS); 645 651 if(at_SYSTEM<C>(cur())||at_PUBLIC<C>(cur())){ 652 model_info->has_external_DTD = true; 646 653 if(old_abspos == AbsPos()) 647 654 Syntax_Error(NT_doctypedecl); 648 Parse_ExternalID(); 655 Parse_ExternalID(model_info->external_DTD_systemLiteral, model_info->external_DTD_pubidLiteral); 656 Parser_Interface * entity_parser; 657 entity_parser = ParserFactory(model_info->external_DTD_systemLiteral, model_info); 658 entity_parser->Parse_ExtSubsetDecl(); 659 entity_parser->~Parser_Interface(); 649 660 } 650 661 else model_info->has_external_DTD = false; 651 662 ScanTo(NonWS); 652 663 … … 684 695 model_info->rootModel = cre; 685 696 } 686 } 687 688 template <CodeUnit_Base C> 689 inline void ParsingEngine<C>::Parse_ExternalID (){ 690 697 else 698 Syntax_Error(NT_doctypedecl); 699 } 700 701 template <CodeUnit_Base C> 702 inline void ParsingEngine<C>::Parse_ExternalID (char *& systemLiteral, char *& pubidLiteral){ 703 int quot_start, lgth; 691 704 if(at_SYSTEM<C>(cur())){ 692 705 Advance(6); 706 pubidLiteral = NULL; 693 707 requireWS(); 694 Parse_MatchedQuote (); /* SystemLiteral */ 708 if (!AtQuote<C>(cur())) Syntax_Error(NT_ExternalID); 709 quot_start = AbsPos()+1; 710 Parse_SystemLiteral (); /* SystemLiteral */ 711 lgth = AbsPos() - quot_start - 1; 712 systemLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth); 695 713 } 696 714 else if (at_PUBLIC<C>(cur())){ 697 715 Advance(6); 698 716 requireWS(); 699 Parse_MatchedQuote ();/* PubidLiteral */ 717 if (!AtQuote<C>(cur())) Syntax_Error(NT_ExternalID); 718 quot_start = AbsPos()+1; 719 Parse_PubidLiteral ();/* PubidLiteral */ 720 lgth = AbsPos() - quot_start - 1; 721 pubidLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth); 722 systemLiteral = NULL; 723 if (AtChar<C, '>'>(cur())) return; 700 724 requireWS(); 701 Parse_MatchedQuote ();/* SystemLiteral */ 725 if (AtQuote<C>(cur())) { 726 quot_start = AbsPos()+1; 727 Parse_SystemLiteral ();/* SystemLiteral */ 728 lgth = AbsPos() - quot_start - 1; 729 systemLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth); 730 } 702 731 } 703 732 else … … 706 735 707 736 template <CodeUnit_Base C> 708 inline void ParsingEngine<C>::Parse_ MatchedQuote(){737 inline void ParsingEngine<C>::Parse_SystemLiteral (){ 709 738 unsigned char quoteCh; 710 739 if(AtQuote<C>(cur())){ 711 740 quoteCh = cur()[0]; 712 741 Advance(1); 713 } 742 } 714 743 ScanTo(Quote); 715 744 while (cur()[0] != quoteCh){ 745 if(at_EOF()) 746 Syntax_Error(NT_SystemLiteral); 747 Advance(1); 748 ScanTo(Quote); 749 } 750 Advance(1); 751 } 752 753 template <CodeUnit_Base C> 754 inline void ParsingEngine<C>::Parse_PubidLiteral (){ 755 unsigned char quoteCh; 756 if(AtQuote<C>(cur())){ 757 quoteCh = cur()[0]; 758 Advance(1); 759 } 760 ScanTo(Quote); 761 while (cur()[0] != quoteCh){ 762 if(at_EOF()) 763 Syntax_Error(NT_PubidLiteral); 716 764 Advance(1); 717 765 ScanTo(Quote); … … 732 780 733 781 if (AtChar<C,'?'>(cur())){ 734 Parse_PI(); 782 if (at_xml<C>(cur())) 783 Syntax_Error(NT_intSubset); 784 else 785 Parse_PI(); 735 786 } 736 787 else if(AtChar<C,'!'>(cur())){ … … 811 862 CM_RegExp * cre = new CM_RegExp; 812 863 cre->content_re = Parse_RemainingChildren(); 813 864 814 865 int id_count = cre->content_re->Set_IDs(0); 815 cre->content_re->Set_First_Map(); 866 cre->content_re->Set_First_Map(); 816 867 symbol_set_t * transition_map = new symbol_set_t[id_count+1]; 817 868 cre->content_re->follow_map[0] = id_count+1; … … 827 878 model_info->ContentModelData.push_back(cre); 828 879 cm = cre; 829 } 830 880 } 831 881 } 832 882 ScanTo(NonWS); 883 833 884 if (AtChar<C,'>'>(cur())) { 834 835 Advance(1); 836 837 885 Advance(1); 838 886 } 839 887 else … … 882 930 inline Content_RE * ParsingEngine<C>::Parse_RemainingChildren (){ 883 931 Content_RE * c1 = Parse_Cp(); 884 Content_RE * r ;932 Content_RE * r = c1; 885 933 ScanTo(NonWS); 886 934 if(AtChar<C,'|'>(cur())){ … … 894 942 if(AtChar<C,'|'>(cur())) 895 943 Advance(1); 944 else 945 Syntax_Error(NT_children); 896 946 ScanTo(NonWS); 897 947 rslt->subCMs.push_back(Parse_Cp()); … … 912 962 if(AtChar<C,','>(cur())) 913 963 Advance(1); 964 else 965 Syntax_Error(NT_children); 914 966 ScanTo(NonWS); 915 967 rslt->subCMs.push_back(Parse_Cp()); … … 1064 1116 1065 1117 Advance(1); 1066 AttlistDecl_action(GetCodeUnitPtr(text_or_markup_start), LengthFrom(text_or_markup_start));1067 1118 } 1068 1119 … … 1225 1276 1226 1277 requireWS(); 1227 if(at_SYSTEM<C>(cur())){ 1228 Advance(6); 1229 requireWS(); 1230 quot_start = AbsPos()+1; 1231 Parse_MatchedQuote (); /* SystemLiteral */ 1232 lgth = AbsPos() - quot_start - 1; 1233 this_info->systemLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth); 1234 this_info->is_external = true; 1235 } 1236 else if (at_PUBLIC<C>(cur())){ 1237 Advance(6); 1238 requireWS(); 1239 1240 quot_start = AbsPos()+1; 1241 Parse_MatchedQuote ();/* PubidLiteral */ 1242 lgth = AbsPos() - quot_start - 1; 1243 this_info->pubidLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth); 1244 this_info->is_external = true; 1245 1246 requireWS(); 1247 1248 quot_start = AbsPos()+1; 1249 Parse_MatchedQuote (); /* SystemLiteral */ 1250 lgth = AbsPos() - quot_start - 1; 1251 this_info->systemLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth); 1252 this_info->is_external = true; 1253 } 1254 else if(AtQuote<C>(cur())){ 1278 if(AtQuote<C>(cur())){ 1255 1279 Parse_PEntityValue(this_info); 1256 1280 this_info->is_external = false; 1257 1281 } 1258 else 1259 Syntax_Error(NT_EntityDecl); 1260 model_info->PEntityData.push_back(this_info); 1282 else { 1283 this_info->is_external = true; 1284 Parse_ExternalID(this_info->systemLiteral, this_info->pubidLiteral); 1285 if (this_info->systemLiteral == NULL) Syntax_Error(NT_EntityDecl); 1286 } 1287 model_info->PEntityData.push_back(this_info); 1261 1288 } 1262 1289 else{ … … 1280 1307 requireWS(); 1281 1308 1282 if(at_SYSTEM<C>(cur())){ 1283 Advance(6); 1284 requireWS(); 1285 quot_start = AbsPos()+1; 1286 Parse_MatchedQuote (); /* SystemLiteral */ 1287 lgth = AbsPos() - quot_start - 1; 1288 this_info->systemLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth); 1289 this_info->is_external = true; 1290 1309 if(AtQuote<C>(cur())){ 1310 Parse_GEntityValue(this_info); 1311 this_info->is_external = false; 1312 } 1313 else { 1314 this_info->is_external = true; 1315 Parse_ExternalID(this_info->systemLiteral, this_info->pubidLiteral); 1316 if (this_info->systemLiteral == NULL) Syntax_Error(NT_EntityDecl); 1291 1317 old_abspos = AbsPos(); 1292 1318 ScanTo(NonWS); … … 1303 1329 } 1304 1330 } 1305 else if (at_PUBLIC<C>(cur())){1306 Advance(6);1307 requireWS();1308 1309 quot_start = AbsPos()+1;1310 Parse_MatchedQuote ();/* PubidLiteral */1311 lgth = AbsPos() - quot_start - 1;1312 this_info->pubidLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth);1313 this_info->is_external = true;1314 1315 requireWS();1316 1317 quot_start = AbsPos()+1;1318 Parse_MatchedQuote (); /* SystemLiteral */1319 lgth = AbsPos() - quot_start - 1;1320 this_info->systemLiteral = copy_string(GetCodeUnitPtr(quot_start),lgth);1321 this_info->is_external = true;1322 1323 old_abspos = AbsPos();1324 ScanTo(NonWS);1325 if(at_NDATA<C>(cur())){1326 if(old_abspos == AbsPos())1327 Syntax_Error(NT_EntityDecl);1328 else1329 Advance(5);1330 requireWS();1331 name_start = AbsPos();1332 ScanTo(NameFollow);1333 lgth = AbsPos() - name_start;1334 this_info->NDataName = copy_string(GetCodeUnitPtr(name_start),lgth);1335 }1336 }1337 else if(AtQuote<C>(cur())){1338 Parse_GEntityValue(this_info);1339 this_info->is_external = false;1340 }1341 else1342 Syntax_Error(NT_EntityDecl);1343 1331 model_info->GEntityData.push_back(this_info); 1344 1332 } … … 1346 1334 if (AtChar<C,'>'>(cur())){ 1347 1335 Advance(1); 1348 Entitydecl_action(GetCodeUnitPtr(name_start), lgth,1349 GetCodeUnitPtr(text_or_markup_start), LengthFrom(text_or_markup_start));1350 1336 } 1351 1337 else 1352 1338 Syntax_Error(NT_EntityDecl); 1353 1339 } 1354 1340 1355 1341 template <CodeUnit_Base C> 1356 1342 inline void ParsingEngine<C>::Parse_Notationdecl (){ … … 1375 1361 else /*Duplicate notation name!*/ 1376 1362 Validity_Error(vErr_NoDuplicateTokens); 1377 1378 requireWS(); 1379 if(at_SYSTEM<C>(cur())){ 1380 Advance(6); 1381 requireWS(); 1382 Parse_MatchedQuote (); /* SystemLiteral */ 1383 } 1384 else if (at_PUBLIC<C>(cur())){ 1385 Advance(6); 1386 requireWS(); 1387 Parse_MatchedQuote (); /* PubidLiteral */ 1388 ScanTo(NonWS); 1389 if (!AtChar<C,'>'>(cur())){ 1390 if (old_abspos == AbsPos()) 1391 Syntax_Error(NT_NotationDecl); 1392 Parse_MatchedQuote (); /* SystemLiteral */ 1393 } 1394 } 1395 else 1396 Syntax_Error(NT_NotationDecl); 1363 Notation_info * this_info = new Notation_info; 1364 1365 Parse_ExternalID(this_info->systemLiteral, this_info->pubidLiteral); 1397 1366 ScanTo(NonWS); 1398 1367 if (AtChar<C,'>'>(cur())) { 1399 1368 Advance(1); 1400 Notationdecl_action(GetCodeUnitPtr(text_or_markup_start), LengthFrom(text_or_markup_start));1401 1369 } 1402 1370 else -
trunk/src/engine.h
r110 r115 99 99 /* Parsing routine for Document Type*/ 100 100 void Parse_DocType (); 101 void Parse_ExternalID (); 102 void Parse_MatchedQuote (); 101 void Parse_ExternalID (char *& SystemLiteral, char *& PubidLiteral); 102 void Parse_SystemLiteral (); 103 void Parse_PubidLiteral (); 103 104 void Parse_IntSubset (); 104 105 void Parse_PEReference (); … … 194 195 void Doctype_action(unsigned char * item, int lgth); 195 196 void PEReference_action(unsigned char * item, int lgth); 196 void AttlistDecl_action(unsigned char * item, int lgth);197 void Entitydecl_action(unsigned char * entity_name, int entity_name_lgth, unsigned char * item, int lgth);198 void Notationdecl_action(unsigned char * item, int lgth);199 197 200 198 void Prolog_action(unsigned char * item, int lgth); -
trunk/src/xmlmodel.h
r108 r115 129 129 130 130 131 class Notation_info { 132 public: 133 char * systemLiteral; 134 char * pubidLiteral; 135 }; 136 131 137 132 138 class Entity_Info { … … 161 167 Model_Info(); 162 168 ~Model_Info(); 169 bool has_external_DTD; 170 char * external_DTD_systemLiteral; 171 char * external_DTD_pubidLiteral; 172 163 173 164 174 /* Information computed from ATTLIST, ELEMENT, NOTATION and ENTITY declarations. */ … … 186 196 vector<GEntity_info *> GEntityData; 187 197 vector<PEntity_info *> PEntityData; 198 vector<Notation_info *> NotationData; 199 188 200 void SimpleEntity(char * entity_Name, char * replText); 189 201 };
Note: See TracChangeset
for help on using the changeset viewer.