XPathToken XPathParserTokenSource::consume(XPathTokenType type) { auto token = next_token(); if (! token.is(type)) { throw UnexpectedTokenException(); } return token; }
/********************************************************************************************** * * ReadQualifiedName * * QualifiedName = Name ? ":" ? Name ; * * Name = NameStartCharacter ( NameCharacter )* ; * * NameStartCharacter = "_" | [A-Z] | [a-z] ; * * NameCharacter = NameStartCharacter | "-" | "." | [0-9] ; * *********************************************************************************************/ QualifiedName XMLParser::ReadQualifiedName () { static const int name_charachters [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; bool first = true; bool valid = true; std::string specifier; std::string name; do { if (valid && current == ':') { if (specifier == "") { specifier = output.toString (); output.Reset (); } else { valid = false; } } else if (current == '\x20' || current == '\x9' || current == '\xD' || current == '\xA') { Position end = position; if (!valid) throw InvalidNameException (); if (first ) throw UnexpectedTokenException (); return QualifiedName (specifier, name); } else if ('\0' <= current && current < '\x7f' && name_characters [(int) current] == 1) { if ((first && '9' < current) || !first) { first = false; output.AppendIgnoreCase (current); } else { valid = false; } } else { valid = false; continue; } } while (ReadCharacter ()); return UnexpectedEndException (); }