Mercurial > ~dholland > hg > ag > index.cgi
comparison tests/agcl/parsifal/good/xmlp8.h @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 #ifndef XMLP8_H | |
2 #define XMLP8_H | |
3 | |
4 #ifndef AG_OBJECT_WRAPPER_DEFINED | |
5 #define AG_OBJECT_WRAPPER_DEFINED | |
6 | |
7 #ifndef AG_PLACEMENT_DELETE_REQUIRED | |
8 #if _MSC_VER >= 1200 || __INTEL_COMPILER | |
9 #define AG_PLACEMENT_DELETE_REQUIRED 1 | |
10 #endif | |
11 #endif | |
12 | |
13 template <class Object> | |
14 class AgObjectWrapper { | |
15 Object object; | |
16 public: | |
17 void operator delete(void *) {} | |
18 void *operator new(size_t, void *p) { return p;} | |
19 #if AG_PLACEMENT_DELETE_REQUIRED | |
20 void operator delete(void *, void *) { } | |
21 #endif | |
22 AgObjectWrapper(const Object &o) : object(o) {} | |
23 ~AgObjectWrapper() {} | |
24 operator Object &() {return object;} | |
25 }; | |
26 | |
27 #endif | |
28 | |
29 typedef union { | |
30 long alignment; | |
31 char ag_vt_2[sizeof(int)]; | |
32 char ag_vt_4[sizeof(AgObjectWrapper<AttvalPair >)]; | |
33 char ag_vt_5[sizeof(AgObjectWrapper<AgString >)]; | |
34 char ag_vt_6[sizeof(AgObjectWrapper<AttvalList >)]; | |
35 char ag_vt_7[sizeof(AgObjectWrapper<Attribute >)]; | |
36 char ag_vt_8[sizeof(AgObjectWrapper<AttributeList >)]; | |
37 char ag_vt_9[sizeof(AgObjectWrapper<Default >)]; | |
38 char ag_vt_10[sizeof(Attribute::Type)]; | |
39 } parse_vs_type; | |
40 | |
41 typedef enum { | |
42 parse_document_token = 4, parse_prolog_token, parse_element_token, | |
43 parse_Misc_token, parse_eof_token = 10, parse_S_token, | |
44 parse_SpaceChar_token, parse_Name_token = 14, parse_NameChar_token = 16, | |
45 parse_Names_token, parse_Nmtoken_token, parse_Nmtokens_token = 20, | |
46 parse_EntityValue_token = 24, parse_PEReference_token = 27, | |
47 parse_Reference_token, parse_AttValue_token = 37, | |
48 parse_dq_AttValString_token, parse_sq_AttValString_token, | |
49 parse_CharRef_token = 41, parse_EntityRef_token, | |
50 parse_SystemLiteral_token = 44, parse_PubidLiteral_token = 51, | |
51 parse_PubidChar_token, parse_Comment_token = 58, | |
52 parse_comment_text_token = 60, parse_Char_token = 62, parse_PI_token, | |
53 parse_PITarget_token = 65, parse_CDSect_token = 71, parse_CDStart_token, | |
54 parse_CData_token, parse_CDEnd_token, parse_XMLDecl_token = 80, | |
55 parse_doctypedecl_token = 82, parse_VersionInfo_token = 85, | |
56 parse_VersionDecl_token, parse_EncodingDecl_token = 88, | |
57 parse_SDDecl_token, parse_Eq_token = 91, parse_VersionNum_token, | |
58 parse_ExternalID_token = 98, parse_markupdecl_token = 102, | |
59 parse_elementdecl_token = 108, parse_AttlistDecl_token, | |
60 parse_EntityDecl_token, parse_NotationDecl_token, parse_extSubset_token, | |
61 parse_TextDecl_token, parse_extSubsetDecl_token = 115, | |
62 parse_conditionalSect_token, parse_LanguageId_token = 125, | |
63 parse_Langcode_token, parse_Subcode_token = 128, | |
64 parse_ISO639Code_token = 132, parse_IanaCode_token, parse_UserCode_token, | |
65 parse_EmptyElementTag_token = 140, parse_STag_token, parse_content_token, | |
66 parse_ETag_token, parse_AttributeList_token = 145, parse_Attribute_token, | |
67 parse_content_unit_token = 148, parse_contentspec_token = 153, | |
68 parse_Mixed_token = 156, parse_Children_token, parse_choice_token, | |
69 parse_seq_token, parse_cp_token = 165, parse_AttDefs_token = 182, | |
70 parse_AttDef_token, parse_AttType_token, parse_DefaultDecl_token, | |
71 parse_StringType_token, parse_TokenizedType_token, | |
72 parse_EnumeratedType_token, parse_NotationType_token = 197, | |
73 parse_Enumeration_token, parse_includeSect_token = 209, | |
74 parse_ignoreSect_token, parse_ignoreSectContents_token = 214, | |
75 parse_Ignore_token = 217, parse_decimal_CharRef_token = 221, | |
76 parse_hex_CharRef_token = 223, parse_GEDecl_token = 230, | |
77 parse_PEDecl_token, parse_EntityDef_token = 233, parse_PEDef_token, | |
78 parse_NDataDecl_token, parse_extParsedEnt_token = 241, parse_extPE_token, | |
79 parse_EncName_token = 244, parse_PublicID_token = 251, | |
80 parse__last_token = 264 | |
81 } parse_token_type; | |
82 | |
83 typedef struct parse_pcb_struct{ | |
84 parse_token_type token_number, reduction_token, error_frame_token; | |
85 int input_code; | |
86 int input_value; | |
87 int line, column; | |
88 int ssx, sn, error_frame_ssx; | |
89 int drt, dssx, dsn; | |
90 int ss[128]; | |
91 parse_vs_type vs[128]; | |
92 int ag_ap; | |
93 const char *error_message; | |
94 char read_flag; | |
95 char exit_flag; | |
96 Context input_context; | |
97 Context cs[128]; | |
98 int bts[128], btsx; | |
99 int lab[11], rx, fx; | |
100 const unsigned char *key_sp; | |
101 int save_index, key_state; | |
102 char ag_msg[82]; | |
103 /* Line -, xmlp8.syn */ | |
104 AgStack<AgString> tagStack; | |
105 AgStack<Symtab> mapStack; | |
106 AgString textStack; | |
107 AgString spaceStack; | |
108 enum TokenType { | |
109 none, | |
110 spaceType, | |
111 textType, | |
112 commentType, | |
113 startType, | |
114 endType, | |
115 emptyType, | |
116 entityRefType, | |
117 //charRefType, | |
118 errorType | |
119 } tokenType; | |
120 AgString currentTagName; | |
121 AgString currentEntityName; | |
122 //int currentCharRef; | |
123 AgString commentString; | |
124 Symtab currentMap; | |
125 AgStack<Warning> warningList; | |
126 AgBaseMapString<Element> elementMap; | |
127 int dtdPresent; | |
128 | |
129 parse_pcb_struct(); | |
130 parse(char *input, AgString *); | |
131 void spaceChar(int); | |
132 void textChar(int); | |
133 void startTag(const Context &, const AgString &, AttvalList &); | |
134 void emptyTag(const Context &, const AgString &, AttvalList &); | |
135 void endTag(const AgString &); | |
136 void registerAttributes(const AgString &name, const AgBaseStack<Attribute> &AttributeList); | |
137 void checkAttributes(const Context &, const AgString &name, Symtab &map); | |
138 int warnAttval(const Context &context, const char *, const AttvalPair &p); | |
139 static void normalize(AgString &s); | |
140 } parse_pcb_type; | |
141 | |
142 #ifndef PRULE_CONTEXT | |
143 #define PRULE_CONTEXT(pcb) (&((pcb).cs[(pcb).ssx])) | |
144 #define PERROR_CONTEXT(pcb) ((pcb).cs[(pcb).error_frame_ssx]) | |
145 #define PCONTEXT(pcb) ((pcb).cs[(pcb).ssx]) | |
146 #endif | |
147 | |
148 #ifndef AG_RUNNING_CODE | |
149 /* PCB.exit_flag values */ | |
150 #define AG_RUNNING_CODE 0 | |
151 #define AG_SUCCESS_CODE 1 | |
152 #define AG_SYNTAX_ERROR_CODE 2 | |
153 #define AG_REDUCTION_ERROR_CODE 3 | |
154 #define AG_STACK_ERROR_CODE 4 | |
155 #define AG_SEMANTIC_ERROR_CODE 5 | |
156 #endif | |
157 void init_parse(parse_pcb_type *); | |
158 void parse(parse_pcb_type *); | |
159 #endif | |
160 |