本文整理汇总了C++中CAstStatement::SetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ CAstStatement::SetNext方法的具体用法?C++ CAstStatement::SetNext怎么用?C++ CAstStatement::SetNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAstStatement
的用法示例。
在下文中一共展示了CAstStatement::SetNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: statSequence
CAstStatement* CParser::statSequence(CAstScope *s) {
//
// statSequence ::= [ statement { ";" statement } ].
// FIRST(statement) = {tIF, tWhile, tReturn, tIdent}.
// FOLLOW(statSequence) = {tEnd, tElse}.
//
CAstStatement *head = NULL;
CAstStatement *tail = NULL;
EToken tt = _scanner->Peek().GetType();
switch(tt) {
case tIf:
case tWhile:
case tReturn:
case tIdent:
head = tail = statement(s);
assert(head != NULL);
// for multiple statements.
while(1) {
if(_scanner->Peek().GetType() == tEnd ||
_scanner->Peek().GetType() == tElse) {
break;
}
else {
Consume(tSemicolon);
CAstStatement *st = NULL;
st = statement(s);
assert(st != NULL);
tail->SetNext(st);
tail = st;
}
}
break;
default:
break;
}
return head;
}
示例2: statSequence
CAstStatement* CParser::statSequence(CAstScope *s)
{
//
// stateSequence ::= [ statement { ";" statement } ].
// statement ::= assignment | subroutineCall
// | ifStatement | whileStatement | returnStatement.
//
CAstStatement *head = NULL;
CAstStatement *tail = NULL;
CToken tt = _scanner->Peek();
while (!_abort && tt.GetType() != kEnd && tt.GetType() != kElse) {
CAstStatement *st = NULL;
// stateSequence -> ... statement ...
tt = _scanner->Peek();
switch (tt.GetType()) {
// statement -> assignment | subroutineCall
case tIdent:
{
const CSymbol *sym = s->GetSymbolTable()->FindSymbol(tt.GetValue(), sLocal);
if (!sym) sym = s->GetSymbolTable()->FindSymbol(tt.GetValue(), sGlobal);
if (!sym) SetError(tt, "undeclared variable \"" + tt.GetValue() + "\"");
ESymbolType stype = sym->GetSymbolType();
if (stype == stProcedure) st = subroutineCall(s);
else st = assignment(s);
}
break;
// statement -> ifStatement
case kIf:
st = ifStatement(s);
break;
// statement -> whileStatement
case kWhile:
st = whileStatement(s);
break;
// statement -> returnStatement
case kReturn:
st = returnStatement(s);
break;
default:
SetError(_scanner->Peek(), "statement expected.");
break;
}
assert(st);
if (!head) head = st;
else tail->SetNext(st);
tail = st;
tt = _scanner->Peek();
if (tt.GetType() == kEnd || tt.GetType() == kElse) break;
// stateSequence -> ... ";" ...
Consume(tSemicolon);
}
return head;
}