Mercurial > ~dholland > hg > ag > index.cgi
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/agcl/parsifal/good/xmlp8.h Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,160 @@ +#ifndef XMLP8_H +#define XMLP8_H + +#ifndef AG_OBJECT_WRAPPER_DEFINED +#define AG_OBJECT_WRAPPER_DEFINED + +#ifndef AG_PLACEMENT_DELETE_REQUIRED +#if _MSC_VER >= 1200 || __INTEL_COMPILER +#define AG_PLACEMENT_DELETE_REQUIRED 1 +#endif +#endif + +template <class Object> +class AgObjectWrapper { + Object object; +public: + void operator delete(void *) {} + void *operator new(size_t, void *p) { return p;} +#if AG_PLACEMENT_DELETE_REQUIRED + void operator delete(void *, void *) { } +#endif + AgObjectWrapper(const Object &o) : object(o) {} + ~AgObjectWrapper() {} + operator Object &() {return object;} +}; + +#endif + +typedef union { + long alignment; + char ag_vt_2[sizeof(int)]; + char ag_vt_4[sizeof(AgObjectWrapper<AttvalPair >)]; + char ag_vt_5[sizeof(AgObjectWrapper<AgString >)]; + char ag_vt_6[sizeof(AgObjectWrapper<AttvalList >)]; + char ag_vt_7[sizeof(AgObjectWrapper<Attribute >)]; + char ag_vt_8[sizeof(AgObjectWrapper<AttributeList >)]; + char ag_vt_9[sizeof(AgObjectWrapper<Default >)]; + char ag_vt_10[sizeof(Attribute::Type)]; +} parse_vs_type; + +typedef enum { + parse_document_token = 4, parse_prolog_token, parse_element_token, + parse_Misc_token, parse_eof_token = 10, parse_S_token, + parse_SpaceChar_token, parse_Name_token = 14, parse_NameChar_token = 16, + parse_Names_token, parse_Nmtoken_token, parse_Nmtokens_token = 20, + parse_EntityValue_token = 24, parse_PEReference_token = 27, + parse_Reference_token, parse_AttValue_token = 37, + parse_dq_AttValString_token, parse_sq_AttValString_token, + parse_CharRef_token = 41, parse_EntityRef_token, + parse_SystemLiteral_token = 44, parse_PubidLiteral_token = 51, + parse_PubidChar_token, parse_Comment_token = 58, + parse_comment_text_token = 60, parse_Char_token = 62, parse_PI_token, + parse_PITarget_token = 65, parse_CDSect_token = 71, parse_CDStart_token, + parse_CData_token, parse_CDEnd_token, parse_XMLDecl_token = 80, + parse_doctypedecl_token = 82, parse_VersionInfo_token = 85, + parse_VersionDecl_token, parse_EncodingDecl_token = 88, + parse_SDDecl_token, parse_Eq_token = 91, parse_VersionNum_token, + parse_ExternalID_token = 98, parse_markupdecl_token = 102, + parse_elementdecl_token = 108, parse_AttlistDecl_token, + parse_EntityDecl_token, parse_NotationDecl_token, parse_extSubset_token, + parse_TextDecl_token, parse_extSubsetDecl_token = 115, + parse_conditionalSect_token, parse_LanguageId_token = 125, + parse_Langcode_token, parse_Subcode_token = 128, + parse_ISO639Code_token = 132, parse_IanaCode_token, parse_UserCode_token, + parse_EmptyElementTag_token = 140, parse_STag_token, parse_content_token, + parse_ETag_token, parse_AttributeList_token = 145, parse_Attribute_token, + parse_content_unit_token = 148, parse_contentspec_token = 153, + parse_Mixed_token = 156, parse_Children_token, parse_choice_token, + parse_seq_token, parse_cp_token = 165, parse_AttDefs_token = 182, + parse_AttDef_token, parse_AttType_token, parse_DefaultDecl_token, + parse_StringType_token, parse_TokenizedType_token, + parse_EnumeratedType_token, parse_NotationType_token = 197, + parse_Enumeration_token, parse_includeSect_token = 209, + parse_ignoreSect_token, parse_ignoreSectContents_token = 214, + parse_Ignore_token = 217, parse_decimal_CharRef_token = 221, + parse_hex_CharRef_token = 223, parse_GEDecl_token = 230, + parse_PEDecl_token, parse_EntityDef_token = 233, parse_PEDef_token, + parse_NDataDecl_token, parse_extParsedEnt_token = 241, parse_extPE_token, + parse_EncName_token = 244, parse_PublicID_token = 251, + parse__last_token = 264 +} parse_token_type; + +typedef struct parse_pcb_struct{ + parse_token_type token_number, reduction_token, error_frame_token; + int input_code; + int input_value; + int line, column; + int ssx, sn, error_frame_ssx; + int drt, dssx, dsn; + int ss[128]; + parse_vs_type vs[128]; + int ag_ap; + const char *error_message; + char read_flag; + char exit_flag; + Context input_context; + Context cs[128]; + int bts[128], btsx; + int lab[11], rx, fx; + const unsigned char *key_sp; + int save_index, key_state; + char ag_msg[82]; +/* Line -, xmlp8.syn */ + AgStack<AgString> tagStack; + AgStack<Symtab> mapStack; + AgString textStack; + AgString spaceStack; + enum TokenType { + none, + spaceType, + textType, + commentType, + startType, + endType, + emptyType, + entityRefType, + //charRefType, + errorType + } tokenType; + AgString currentTagName; + AgString currentEntityName; + //int currentCharRef; + AgString commentString; + Symtab currentMap; + AgStack<Warning> warningList; + AgBaseMapString<Element> elementMap; + int dtdPresent; + + parse_pcb_struct(); + parse(char *input, AgString *); + void spaceChar(int); + void textChar(int); + void startTag(const Context &, const AgString &, AttvalList &); + void emptyTag(const Context &, const AgString &, AttvalList &); + void endTag(const AgString &); + void registerAttributes(const AgString &name, const AgBaseStack<Attribute> &AttributeList); + void checkAttributes(const Context &, const AgString &name, Symtab &map); + int warnAttval(const Context &context, const char *, const AttvalPair &p); + static void normalize(AgString &s); + } parse_pcb_type; + +#ifndef PRULE_CONTEXT +#define PRULE_CONTEXT(pcb) (&((pcb).cs[(pcb).ssx])) +#define PERROR_CONTEXT(pcb) ((pcb).cs[(pcb).error_frame_ssx]) +#define PCONTEXT(pcb) ((pcb).cs[(pcb).ssx]) +#endif + +#ifndef AG_RUNNING_CODE +/* PCB.exit_flag values */ +#define AG_RUNNING_CODE 0 +#define AG_SUCCESS_CODE 1 +#define AG_SYNTAX_ERROR_CODE 2 +#define AG_REDUCTION_ERROR_CODE 3 +#define AG_STACK_ERROR_CODE 4 +#define AG_SEMANTIC_ERROR_CODE 5 +#endif +void init_parse(parse_pcb_type *); +void parse(parse_pcb_type *); +#endif +