本文整理汇总了C++中ParseError函数的典型用法代码示例。如果您正苦于以下问题:C++ ParseError函数的具体用法?C++ ParseError怎么用?C++ ParseError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ParseError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void QuantifiedRegexObject::parse(Regex* rgx)
{
regexObject = new RegexObject;
regexObject->parse(rgx);
char c = rgx->src.peek();
if (c == '+' || c == '*' || c == '?')
{
rgx->src.get();
if (c == '+') type = QuantifierType::KLEENE_PLUS;
else if (c == '*') type = QuantifierType::KLEENE_STAR;
else type = QuantifierType::QUESTION_MARK;
if (rgx->src.peek() == '?')
{
greedy = false;
rgx->src.get();
}
}
else if (c == '{')
{
char x;
int minVal, maxVal;
minVal = Utility::parseInt(rgx);
if (rgx->src.get() != ',')
{
rgx->src.moveBack();
maxVal = minVal;
}
else
{
if (Utility::isDigit(rgx->src.peek()))
{
maxVal = Utility::parseInt(rgx);
}
else
{
maxVal = oo;
}
}
if (rgx->src.get() != '}') throw ParseError("");
if (maxVal < minVal) swap(minVal, maxVal);
range = make_pair(minVal, maxVal);
type = QuantifierType::RANGED;
}
}
示例2: ParseError
/***************************************************************
* Function: Parser::parseText()
* Purpose : Parse an XML text region
* Initial : Maxime Chevalier-Boisvert on October 20, 2008
****************************************************************
Revisions and bug fixes:
*/
Text* Parser::parseText(const std::string& xmlString, size_t& charIndex, const PosVector& positions)
{
// Declare a string to store the text
std::string text;
// For each character
for (;; ++charIndex)
{
// If we are past the length of the input stream
if (charIndex >= xmlString.length())
{
// Throw an exception
throw ParseError("Unexpected end of stream in text region", positions[charIndex]);
}
// Extract the current character
char thisChar = xmlString[charIndex];
// If this character is the beggining of an escape sequence
if (thisChar == '&')
{
// Parse the escape sequence
text += parseEscapeSeq(xmlString, charIndex, positions);
// Move on to the next character
continue;
}
// If this character is the beginning of a tag
if (thisChar == '<')
{
// Move back one character
charIndex--;
// Break out of this loop
break;
}
// Add this character to the text
text += thisChar;
}
// Create and returna new text node
return new Text(text);
}
示例3: Read_termstr_rtn
void Read_termstr_rtn(P_WBXML_INFO buffer, char** result)
{
#define STRING_BLOCK_SIZE 256
int buflen = STRING_BLOCK_SIZE;
char* strbuf = (char*) malloc(buflen);
BOOL doubled = FALSE;
int i = 0;
if (!result)
ParseError(ERR_INTERNAL_BAD_PARAM);
while ( (BytesLeft(buffer) >= 1) && (*(buffer->m_curpos) != 0) )
{
if (i>=buflen)
{
buflen += STRING_BLOCK_SIZE;
strbuf = realloc(strbuf, buflen);
}
if (*(buffer->m_curpos) != '$' || doubled == TRUE)
{
strbuf[i] = *(buffer->m_curpos);
buffer->m_curpos++;
i++;
if (doubled == TRUE)
doubled = FALSE;
}
else
{
strbuf[i] = *(buffer->m_curpos);
i++;
doubled = TRUE;
}
}
strbuf[i] = 0;
buffer->m_curpos++;
if (*result)
free(*result);
*result = strbuf;
}
示例4: ParseEndIf
/* ParseEndIf - parse the 'END IF' statement */
static void ParseEndIf(ParseContext *c)
{
switch (CurrentBlockType(c)) {
case BLOCK_IF:
fixupbranch(c, c->bptr->u.IfBlock.nxt, codeaddr(c));
fixupbranch(c, c->bptr->u.IfBlock.end, codeaddr(c));
PopBlock(c);
break;
case BLOCK_ELSE:
fixupbranch(c, c->bptr->u.ElseBlock.end, codeaddr(c));
PopBlock(c);
break;
default:
ParseError(c, "END IF without a matching IF/ELSE IF/ELSE");
break;
}
FRequire(c, T_EOL);
}
示例5: ParseError
void CodeTranslator::translate(std::string str)
{
m_grammar.clear();
std::string::iterator begin = str.begin(), end = str.end();
bool success = qi::parse(begin, end, m_grammar);
if(!success || begin != end)
{
m_lbls.clear();
m_command.setOperationType(Command::NONE);
throw ParseError("stopped at: " + std::string(begin, end));
}
if(m_command.getOperationType() != Command::NONE)
checkCorrectness();
}
示例6: parse_path_absolute
// path-absolute = "/" [ segment-nz *( "/" segment ) ]
TextCursor parse_path_absolute(TextCursor cursor)
{
char c = get_char(cursor);
if (c != '/')
throw ParseError();
else
{
try
{
TextCursor cursor2(parse_segment_nz(cursor));
REPEAT_IGNORING(parse_slash_segment, cursor2);
}
catch(ParseError)
{
return cursor;
}
}
}
示例7: ParseError
// ------------------------------------------------------------------------------------------------
const std::string & ColladaModelFactory::FindAndValidateString(std::map<std::string, std::string> * stringMap, const std::string & index)
{
// if empty, just return another empty string
if (index.empty())
{
return index;
}
// look up 'index' in map
auto it = stringMap->find(index);
if (it == stringMap->end())
{
static const std::string c_emptyString;
ParseError("could not find '%s'\n", index.c_str());
return c_emptyString;
}
return it->second;
}
示例8: free
void Configuration::Assign(const string &field, const string &value)
{
map<string, char *>::const_iterator match;
match = _str_map.find(field);
if (match != _str_map.end())
{
free(_str_map[field]);
_str_map[field] = strdup(value.c_str());
}
else
{
string errmsg = "Unknown field ";
errmsg += field;
ParseError(errmsg, 0);
}
}
示例9: ParseError
VExpression* VDynamicCast::DoResolve(VEmitContext& ec)
{
if (op)
op = op->Resolve(ec);
if (!op)
{
delete this;
return NULL;
}
if (op->Type.Type != TYPE_Reference)
{
ParseError(Loc, "Bad expression, class reference required");
delete this;
return NULL;
}
Type = VFieldType(Class);
return this;
}
示例10: Parser
Parser(typename Encode<E>::PointerType input, Automata& nfa)
: reader(input)
{
nfa.clear();
if (reader.peek() == 0)
{
return;
}
auto ast = parseRE();
if (reader.peek() != 0)
{
throw ParseError();
}
State s;
State e;
ast->convertToNFA(nfa, s, e);
nfa.setStart(s);
nfa.setTerminate(e);
}
示例11: v_ProcessLibArguments
// Interpret the next argument as a path, and obtain the IShellItem for it to be consumed by the derived class.
HRESULT v_ProcessLibArguments(PCWSTR *ppszArgs, int cArgs)
{
PCWSTR pszFolderPath = CONSUME_NEXT_ARG(ppszArgs, cArgs);
HRESULT hr = pszFolderPath ? S_OK : E_INVALIDARG;
if (SUCCEEDED(hr))
{
hr = SHStrDupW(pszFolderPath, &_pszFolderPath);
if (SUCCEEDED(hr))
{
hr = SHCreateItemFromParsingName(pszFolderPath, NULL, IID_PPV_ARGS(&_psiFolder));
}
}
else
{
ParseError(L"Missing folder path argument.\n");
}
// On success, pass any remaining arguments on to the derived class.
return SUCCEEDED(hr) ? v_ProcessFolderArguments(ppszArgs, cArgs) : hr;
}
示例12: match
const Insert &insert_stmt() {
if (lookahead == INSERT) {
// insert_stmt -> INSERT INTO id L_PAREN column_list R_PAREN
// VALUES L_PAREN value_list R_PAREN SEMICOLON
match(INSERT); match(INTO);
string table_id = id();
match(L_PAREN);
vector<string> columns;
column_list(columns);
match(R_PAREN);
vector<int> values;
value_list(values);
match(R_PAREN);
match(SEMICOLON);
return Insert(table_id, columns, values);
} else {
throw ParseError("Syntax error");
}
}
示例13: load
Value load(std::istream& ss) {
// Parse a JSON entity, using the inputstream ss
parseWhitespace(ss);
switch (ss.peek()) {
case '{': return parseObject(ss);
case '[': return parseArray(ss);
case '"': return parseString(ss);
case 't': return parseTrue(ss);
case 'f': return parseFalse(ss);
case 'n': return parseNull(ss);
case '-': return parseNumber(ss);
default:
if(isdigit(ss.peek())) {
return parseNumber(ss);
} else {
throw ParseError(std::string("unexpected token: '")+char(ss.peek())+"'");
}
}
}
示例14: ParseElseIf
/* ParseElseIf - parse the 'ELSE IF' statement */
static void ParseElseIf(ParseContext *c)
{
switch (CurrentBlockType(c)) {
case BLOCK_IF:
putcbyte(c, OP_BR);
c->bptr->u.IfBlock.end = putcword(c, c->bptr->u.IfBlock.end);
fixupbranch(c, c->bptr->u.IfBlock.nxt, codeaddr(c));
c->bptr->u.IfBlock.nxt = 0;
ParseRValue(c);
FRequire(c, T_THEN);
putcbyte(c, OP_BRF);
c->bptr->u.IfBlock.nxt = putcword(c, 0);
FRequire(c, T_EOL);
break;
default:
ParseError(c, "ELSE IF without a matching IF");
break;
}
}
示例15: qDebug
void DriveManager::handleGetFileInfo ()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*> (sender ());
if (!reply)
return;
reply->deleteLater ();
bool ok = false;
const auto& res = QJson::Parser ().parse (reply->readAll (), &ok);
if (!ok)
{
qDebug () << Q_FUNC_INFO
<< "parse error";
return;
}
const QVariantMap& map = res.toMap ();
QString access_token = Reply2DownloadAccessToken_.take (reply);
if (!map.contains ("error"))
{
DriveItem it = CreateDriveItem (res);
if (it.DownloadUrl_.isEmpty ())
{
QMessageBox::warning (Core::Instance ().GetProxy ()->GetRootWindowsManager ()->GetPreferredWindow (),
"LeechCraft",
tr ("This file cannot be downloaded. Use export instead of Download or Open File action"));
DownloadsQueue_.removeFirst ();
return;
}
if (!access_token.isEmpty ())
it.DownloadUrl_.addQueryItem ("access_token", access_token);
if (!DownloadsQueue_.isEmpty ())
DownloadsQueue_.dequeue () (it.DownloadUrl_);
return;
}
ParseError (map);
}