本文整理汇总了C++中SymbolList::add方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolList::add方法的具体用法?C++ SymbolList::add怎么用?C++ SymbolList::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolList
的用法示例。
在下文中一共展示了SymbolList::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseParameterList
SymbolArray parseParameterList(CharacterSource* source)
{
SymbolList list;
Symbol parameter = parseParameter(source);
if (!parameter.valid())
return list;
list.add(parameter);
Span span;
while (Space::parseCharacter(source, ',', &span)) {
Symbol parameter = parseParameter(source);
if (!parameter.valid())
source->location().throwError("Expected parameter");
list.add(parameter);
}
return list;
}
示例2: parseCase
Symbol parseCase(CharacterSource* source)
{
static String caseKeyword("case");
static String defaultKeyword("default");
SymbolList expressions;
bool defaultType;
Span span;
Span span2;
if (Space::parseKeyword(source, caseKeyword, &span)) {
defaultType = false;
do {
Symbol expression = parseExpressionOrFail(source);
expressions.add(expression);
if (!Space::parseCharacter(source, ',', &span2))
break;
} while (true);
}
else {
defaultType = true;
if (!Space::parseKeyword(source, defaultKeyword, &span))
source->location().throwError("Expected case or default");
}
Space::assertCharacter(source, ':', &span2);
Symbol statement = parseStatementOrFail(source);
SpanCache* cache = newSpan(span + spanOf(statement));
if (defaultType)
return Symbol(atomDefaultCase, statement, cache);
return Symbol(atomCase, SymbolArray(expressions), statement, cache);
}
示例3: parseSwitchStatement
Symbol parseSwitchStatement(CharacterSource* source)
{
Span startSpan;
static String switchKeyword("switch");
if (!Space::parseKeyword(source, switchKeyword, &startSpan))
return Symbol();
Span span;
Space::assertCharacter(source, '(', &span);
Symbol expression = parseExpressionOrFail(source);
Space::assertCharacter(source, ')', &span);
Space::assertCharacter(source, '{', &span);
Symbol defaultCase;
CharacterSource s = *source;
SymbolList cases;
do {
Symbol c = parseCase(source);
if (!c.valid())
break;
if (c.atom() == atomDefaultCase) {
if (defaultCase.valid())
s.location().throwError(
"This switch statement already has a default case");
defaultCase = c;
}
else
cases.add(c);
} while (true);
Space::assertCharacter(source, '}', &span);
return Symbol(atomSwitchStatement, expression, defaultCase,
SymbolArray(cases), newSpan(startSpan + span));
}
示例4: parseStatementSequence
SymbolArray parseStatementSequence(CharacterSource* source)
{
SymbolList list;
do {
Symbol statement = parseStatement(source);
if (!statement.valid())
return list;
list.add(statement);
} while (true);
}