³ò àH=c@s¸dZddkZddkTeZedƒieƒieƒZdZ dZ dZ dZ d dd „ƒYZ d „Zd „Zd „Zd„Zddd„ƒYZd„Zd„ZdS(sosgmltag.py: SGML tag processing module $Revision: 1.9 $ $Date: 2002/08/01 07:15:12 $ Exports: giStartCset: a Cset object representing the characters that can be the first character of a Generic Identifier (GI) giCset: a Cset object representing the characters that can be the non-first characters of a Generic Identifier (GI) class SGMLTag: Represents one opening or closing tag def SGML_Tag_Scan(): Scans one tag from a Scan object class TagAttr: Represents one attribute of a tag def Tag_Attr_Scan(): Scans one attribute from a Scan object iÿÿÿÿN(t*s_-ttSGMLTagcBs#eZdZdd„Zd„ZRS(s¢Represents one opening or closing SGML tag. Exports: SGMLTag ( gi, isClose, attrList, text=None ): [ if (gi is the Generic Identifier as a nonempty string) and (isClose is 0 an opening tag, 1 for a closing tag) and (attrList is a list of TagAttr objects representing zero or more attributes, if not a comment, else None) and (text is a string contain the comment text, if a comment, else None) -> return a new SGMLTag with those values ] .gi: [ as passed to constructor ] .isClose: [ as passed to constructor ] .attrList: [ if the attrList argument passed to the constructor was None -> an empty list else -> as passed to constructor ] .text: [ as passed to constructor ] str(): [ returns self reconstituted as a text string ] cCs<||_||_||_|o ||_n g|_dS(N(tgitisClosettexttattrList(tselfRRRR((s$/u/john/projects/pystyler/sgmltag.pyt__init__5s     cCs­|itjodt|itfSndg}|io|idƒn|i|iƒx1|iD]&}|idƒ|it|ƒƒqfW|idƒt i |dƒS(s&Reconstitute self as a string s<%s%s%sRt/t t>t( RtSGML_COMMENT_GItSGML_COMMENT_HEADRtSGML_COMMENT_TAILRtappendRtstrtstringtjoin(RtLtattr((s$/u/john/projects/pystyler/sgmltag.pyt__str__Bs     N(t__name__t __module__t__doc__tNoneR R(((s$/u/john/projects/pystyler/sgmltag.pyRs cCsÍ|itƒpdSn|itƒot|ƒSn|idƒo d}nd}t|ƒ}|djodSn|iƒg}t||ƒ|idƒp|idƒdSnt |||ƒSdS(sBParses an SGML tag from a Scan object. [ if scan is a Scan object -> if scan starts with a syntactically valid SGML tag -> scan := scan advanced past that tag return a new SGMLTag object representing the tag else if scan appears to start with a tag but it is syntactically invalid -> scan := scan advanced past the valid-looking part, but at least one character Log() +:= error message(s) return None else -> return None ] R iiR s,Expecting the `>' at the end of an SGML tag.N( ttabMatcht SGML_TAG_OPENRRtSGML_Tag_Scan_CommenttSGML_Tag_Scan_GItdeblanktSGML_Tag_Scan_Attr_ListterrorR(tscanRRR((s$/u/john/projects/pystyler/sgmltag.pyt SGML_Tag_Scancs"      cCsæg}d}x”|i oˆ| o€|itƒ}|dj o3|i|i|ƒƒ|ittƒƒd}q|i|idƒƒ|idƒ|iƒqW|o#t t ddt i |dƒƒSn|i dtƒdSdS(sœScan an SGML comment, after the opening `