本文整理汇总了C++中SyntaxException::SetStart方法的典型用法代码示例。如果您正苦于以下问题:C++ SyntaxException::SetStart方法的具体用法?C++ SyntaxException::SetStart怎么用?C++ SyntaxException::SetStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxException
的用法示例。
在下文中一共展示了SyntaxException::SetStart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
// Parse
void VariableNode::Parse(Parser &parser, Parser::size_type start, Parser::size_type end,
Parser::size_type v1)
{
// Check some basic syntax
if(start != end)
{
SyntaxException e;
e.SetStart(parser[start].GetStart());
e.SetEnd(parser[end].GetEnd());
throw(e);
}
// Get value list
ValueList *vlist = m_expr->GetValueList();
if(vlist == 0)
{
NoValueListException e;
e.SetStart(parser[start].GetStart());
e.SetEnd(parser[start].GetEnd());
throw(e);
}
// Get name
string ident = parser[start].GetIdentifier();
// Get address
double *vaddr = vlist->GetAddress(ident);
if(vaddr == 0)
{
// If it does not already exist, try to create it
vlist->Add(ident);
vaddr = vlist->GetAddress(ident);
}
if(vaddr == 0)
{
NotFoundException e(ident);
e.SetStart(parser[start].GetStart());
e.SetEnd(parser[start].GetEnd());
throw(e);
}
// Set information
m_var = vaddr;
}
示例2: if
// Parse a region of tokens
Node *Parser::ParseRegion(Parser::size_type start, Parser::size_type end)
{
size_type pos;
size_type fgopen = (size_type)-1;
size_type fgclose = (size_type)-1;
size_type assignindex = (size_type)-1;
size_type addsubindex = (size_type)-1;
size_type muldivindex = (size_type)-1;
size_type posnegindex = (size_type)-1;
size_type expindex = (size_type)-1;
bool multiexpr = false;
int plevel = 0;
// Check simple syntax
if(start > end)
throw(SyntaxException());
// Scan through tokens
for(pos = start; pos <= end; pos++)
{
switch(m_tokens[pos].GetType())
{
case Token::TypeOpenParenthesis:
{
plevel++;
// Opening of first group?
if(plevel == 1 && fgopen == (size_type)-1)
fgopen = pos;
break;
};
case Token::TypeCloseParenthesis:
{
plevel--;
// First group closed?
if(plevel == 0 && fgclose == (size_type)-1)
fgclose = pos;
if(plevel < 0)
{
UnmatchedParenthesisException e;
e.SetStart(m_tokens[pos].GetStart());
e.SetEnd(m_tokens[pos].GetEnd());
throw(e);
}
break;
}
case Token::TypeEqual:
{
if(plevel == 0)
{
if(assignindex == (size_type)-1)
assignindex = pos;
}
break;
}
case Token::TypeAsterisk:
case Token::TypeForwardSlash:
{
if(plevel == 0)
{
muldivindex = pos;
}
break;
}
case Token::TypeHat:
{
if(plevel == 0)
{
expindex = pos;
}
break;
}
case Token::TypePlus:
case Token::TypeHyphen:
{
if(plevel == 0)
{
if(pos == start)
{
// Positive or negative sign
if(posnegindex == (size_type)-1)
posnegindex = pos;
}
else
{
// What is before us
//.........这里部分代码省略.........