Anything GenericXMLParser::ParseExternalId() { StartTrace(GenericXMLParser.ParseExternalId); String systemOrPublic = ParseName(); SkipWhitespace(); Anything result; if (systemOrPublic == "PUBLIC") { result[systemOrPublic] = ParseQuotedString(); } result[systemOrPublic].Append(ParseQuotedString()); return result; }
void DwRfc1521Tokenizer::ParseToken() { // Assume the field body has already been extracted. That is, we don't // have to watch for the end of the field body or folding. We just // treat any CRs or LFs as white space. mTokenStart = mNextStart; mTokenLength = 0; mTkType = eTkNull; if (mTokenStart >= mString.length()) { return; } // Skip leading space. Also, since control chars are not permitted // in atoms, skip these, too. while (1) { if (mTokenStart >= mString.length()) { return; } if (!isspace(mString[mTokenStart]) && !iscntrl(mString[mTokenStart])) break; ++mTokenStart; } char ch = mString[mTokenStart]; // Quoted string if (ch == '"') { mTkType = eTkQuotedString; ParseQuotedString(); } // Comment else if (ch == '(') { mTkType = eTkComment; ParseComment(); } // Domain literal else if (ch == '[') { mTkType = eTkDomainLiteral; ParseDomainLiteral(); } // Special else if (istspecial(ch)) { mTkType = eTkTspecial; mTokenLength = 1; mToken = mString.substr(mTokenStart, 1); mNextStart = mTokenStart + 1; } // Atom else { mTkType = eTkToken; ParseAtom(); } if (mDebugOut) PrintToken(mDebugOut); }
void File::ParseDefs(InputStream& s, Reference* pParentRef) { while(s.SkipWhiteSpace(L";") != '}' && s.PeekChar() != Stream::EOS) { NodePriority priority = PNormal; CAtlList<CStringW> types; CStringW name; int c = s.SkipWhiteSpace(); if(c == '*') {s.GetChar(); priority = PLow;} else if(c == '!') {s.GetChar(); priority = PHigh;} ParseTypes(s, types); if(s.SkipWhiteSpace() == '#') { s.GetChar(); ParseName(s, name); } if(types.IsEmpty()) { if(name.IsEmpty()) s.ThrowError(_T("syntax error")); types.AddTail(L"?"); } Reference* pRef = pParentRef; while(types.GetCount() > 1) pRef = CreateRef(CreateDef(pRef, types.RemoveHead())); Definition* pDef = NULL; if(!types.IsEmpty()) pDef = CreateDef(pRef, types.RemoveHead(), name, priority); c = s.SkipWhiteSpace(L":="); if(c == '"' || c == '\'') ParseQuotedString(s, pDef); else if(iswdigit(c) || c == '+' || c == '-') ParseNumber(s, pDef); else if(pDef->IsType(L"@")) ParseBlock(s, pDef); else ParseRefs(s, pDef); } s.GetChar(); }
String GenericXMLParser::ParseValue() { // Might need some fine tuning. allow non-well-formed i.e. unquoted values StartTrace(GenericXMLParser.ParseValue); String value; int c = Peek(); if ('\'' == c || '\"' == c) { // a quoted value value = ParseQuotedString(); } else if (IsValidNameChar(c)) { // a legacy non-quoted value value = ParseName(); } else if (isdigit(c)) { do { value.Append(char(Get())); c = Peek(); } while (isdigit(c) || '%' == c); // allow for legacy percentage values, without quotes } else if ('#' == c) { // allow for legacy color attributes without quotes do { value.Append(char(Get())); } while (isxdigit(Peek())); } return value; }
void DwRfc1521Tokenizer::ParseToken() { // Assume the field body has already been extracted. That is, we don't // have to watch for the end of the field body or folding. We just // treat any CRs or LFs as white space. mTokenStart = mNextStart; mTokenLength = 0; mTkType = eTkNull; // Skip leading space. Also, since control chars are not permitted // in atoms, skip these, too. while(1) { if(mTokenStart >= mString.length()) { return; } if(isnotspaceorcntrl(mString[mTokenStart])) break; ++mTokenStart; } char ch = mString[mTokenStart]; switch(ch) { // Quoted string case '"': mTkType = eTkQuotedString; ParseQuotedString(); break; // Comment case '(': mTkType = eTkComment; ParseComment(); break; // Domain literal case '[': mTkType = eTkDomainLiteral; ParseDomainLiteral(); break; // Special case ')': case '<': case '>': case '@': case ',': case ';': case ':': case '\\': case '/': case ']': case '?': case '=': mTkType = eTkTspecial; mTokenLength = 1; mToken = mString.substr(mTokenStart, 1); mNextStart = mTokenStart + 1; break; default: mTkType = eTkToken; ParseAtom(); break; } if(mDebugOut) PrintToken(mDebugOut); }