本文整理汇总了C++中Statements::isEps方法的典型用法代码示例。如果您正苦于以下问题:C++ Statements::isEps方法的具体用法?C++ Statements::isEps怎么用?C++ Statements::isEps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statements
的用法示例。
在下文中一共展示了Statements::isEps方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildStatement
//.........这里部分代码省略.........
}
TokenSequence* postBrace = nullptr;
TokenSequence* statementCore = subcore0->splitOn(subcore0->getSize() - 2, &postBrace);
Statements* currentStatements = ((StatementBlock*)(*toBuild))->blockContent;
if (statementCore->getSize() != 0) {
currentStatements = new StatementsSeq();
TokenSequence* singleStatement = nullptr;
TokenSequence* rest0 = nullptr;
TokenSequence* semicolon = nullptr;
TokenSequence* otherStatements = nullptr;
do {
singleStatement = statementCore->splitOn(ParseTree::splitIndexes->pop(), &rest0);
semicolon = rest0->splitOn(0, &otherStatements);
this->buildStatement(&(((StatementsSeq*)currentStatements)->firstStatement), singleStatement);
((StatementsSeq*) currentStatements)->restOfStatements = (otherStatements->getSize() == 0 ? ((Statements*)new StatementsSeq()) : ((Statements*)new StatementsEps()));
if (singleStatement != nullptr) {
singleStatement->prepareDelete(true);
delete singleStatement;
}
if (rest0 != nullptr) {
rest0->prepareDelete(true);
delete rest0;
}
if (semicolon != nullptr) {
semicolon->prepareDelete(true);
delete semicolon;
}
if (statementCore != nullptr) {
statementCore->prepareDelete(true);
delete statementCore;
}
statementCore = otherStatements;
currentStatements = ((StatementsSeq*) currentStatements)->restOfStatements;
} while(!currentStatements->isEps());
} else {
currentStatements = new StatementsEps();
}
} else if (StatementIfElse::first()->isSet(relatedSequence->tokenAt(0, false))) {
*toBuild = new StatementIfElse();
TokenSequence* majorPrefix = nullptr;
TokenSequence* elseStatement = nullptr;
TokenSequence* elsePart = nullptr;
TokenSequence* ifAndItsStatement = nullptr;
TokenSequence* ifPart = nullptr;
TokenSequence* semiCore = nullptr;
TokenSequence* ifExpression = nullptr;
TokenSequence* endOfIf = nullptr;
TokenSequence* core = nullptr;
TokenSequence* ifStatement = nullptr;
majorPrefix = relatedSequence->splitOn(ParseTree::splitIndexes->pop(), &elseStatement);
this->buildStatement(&(((StatementIfElse*)(*toBuild))->elseCase), elseStatement);
if (elseStatement != nullptr) {
elseStatement->prepareDelete(true);
delete elseStatement;
}
ifAndItsStatement = majorPrefix->splitOn(majorPrefix->getSize() - 3, &elsePart);
if (majorPrefix != nullptr) {
majorPrefix->prepareDelete(true);
delete majorPrefix;
}
if (elsePart != nullptr) {
elsePart->prepareDelete(true);
delete elsePart;
}
ifPart = ifAndItsStatement->splitOn(1, &semiCore);
if (ifAndItsStatement != nullptr) {
示例2: parse
ParseTree* Parser::parse() {
if (this->currentCodeSnippet == nullptr) {
throw "Undefined file for parser\n";
}
if (!ProgOnly::isMatching(this->currentCodeSnippet)) {
std::cerr << "error some spot: syntax error type 2 (invalid token composition)\n";
exit(1);
}
// if it does match, the entire code (in the test file) is OK and all dynamic indexes the Parser must split the sequence on are in ParseTree::splitIndexes
ProgOnly* prog = new ProgOnly();
TokenSequence* statementPart = nullptr;
TokenSequence* declarationPart = this->currentCodeSnippet->splitOn(ParseTree::splitIndexes->pop(), &statementPart);
if (Decls::first()->isSet(this->currentCodeSnippet->tokenAt(0, false))) {
prog->declarationSegment = new DeclsSeq();
TokenSequence* singleDeclaration = nullptr;
TokenSequence* rest0 = nullptr;
TokenSequence* semicolon = nullptr;
TokenSequence* otherDeclarations = nullptr;
Decls* currentDecls = prog->declarationSegment;
do {
singleDeclaration = declarationPart->splitOn(ParseTree::splitIndexes->pop(), &rest0);
semicolon = rest0->splitOn(0, &otherDeclarations);
((DeclsSeq*) currentDecls)->firstDeclaration = new DeclOnly();
this->buildDecl(&(((DeclsSeq*)currentDecls)->firstDeclaration), singleDeclaration);
((DeclsSeq*) currentDecls)->restOfDeclarations = (otherDeclarations->getSize() == 0 ? ((Decls*)new DeclsSeq()) : ((Decls*)new DeclsEps()));
if (singleDeclaration != nullptr) {
singleDeclaration->prepareDelete(true);
delete singleDeclaration;
}
if (rest0 != nullptr) {
rest0->prepareDelete(true);
delete rest0;
}
if (semicolon != nullptr) {
semicolon->prepareDelete(true);
delete semicolon;
}
if (declarationPart != nullptr) {
declarationPart->prepareDelete(true);
delete declarationPart;
}
declarationPart = otherDeclarations;
currentDecls = ((DeclsSeq*) currentDecls)->restOfDeclarations;
} while(!currentDecls->isEps());
} else {
prog->declarationSegment = new DeclsEps();
}
if (statementPart->getSize() != 0) {
prog->statementSegment = new StatementsSeq();
TokenSequence* singleStatement = nullptr;
TokenSequence* rest0 = nullptr;
TokenSequence* semicolon = nullptr;
TokenSequence* otherStatements = nullptr;
Statements* currentStatements = prog->statementSegment;
do {
singleStatement = statementPart->splitOn(ParseTree::splitIndexes->pop(), &rest0);
semicolon = rest0->splitOn(0, &otherStatements);
this->buildStatement(&(((StatementsSeq*)currentStatements)->firstStatement), singleStatement);
((StatementsSeq*) currentStatements)->restOfStatements = (otherStatements->getSize() == 0 ? ((Statements*)new StatementsSeq()) : ((Statements*)new StatementsEps()));
if (singleStatement != nullptr) {
singleStatement->prepareDelete(true);
delete singleStatement;
}
if (rest0 != nullptr) {
rest0->prepareDelete(true);
delete rest0;
}
if (semicolon != nullptr) {
semicolon->prepareDelete(true);
delete semicolon;
}
if (statementPart != nullptr) {
statementPart->prepareDelete(true);
delete statementPart;
}
statementPart = otherStatements;
currentStatements = ((StatementsSeq*) currentStatements)->restOfStatements;
} while(!currentStatements->isEps());
} else {
prog->statementSegment = new StatementsEps();
}
if (declarationPart != nullptr) {
declarationPart->prepareDelete(true);
delete declarationPart;
}
if (statementPart != nullptr) {
statementPart->prepareDelete(true);
delete statementPart;
}
std::cout << "Parsing works\n";
return prog;
}