| 463 | } |
| 464 | |
| 465 | bool ParseFile::parse() { |
| 466 | FileSystem* const fileSystem = FileSystem::getInstance(); |
| 467 | CommandLineParser* clp = getCompileSourceFile()->getCommandLineParser(); |
| 468 | Precompiled* prec = Precompiled::getSingleton(); |
| 469 | bool precompiled = prec->isFilePrecompiled(m_ppFileId, getSymbolTable()); |
| 470 | |
| 471 | if (m_children.empty()) { |
| 472 | ParseCache cache(this); |
| 473 | |
| 474 | if (cache.restore()) { |
| 475 | m_usingCachedVersion = true; |
| 476 | if (debug_AstModel && !precompiled) |
| 477 | std::cout << m_fileContent->printObjects(); |
| 478 | if (clp->debugCache()) { |
| 479 | std::cout << "PARSER CACHE USED FOR: " |
| 480 | << fileSystem->toPath(getFileId(0)) << std::endl; |
| 481 | } |
| 482 | return true; |
| 483 | } |
| 484 | } else { |
| 485 | bool ok = true; |
| 486 | for (ParseFile* child : m_children) { |
| 487 | ParseCache cache(child); |
| 488 | |
| 489 | if (cache.restore()) { |
| 490 | child->m_fileContent->setParent(m_fileContent); |
| 491 | m_usingCachedVersion = true; |
| 492 | if (debug_AstModel && !precompiled) |
| 493 | std::cout << child->m_fileContent->printObjects(); |
| 494 | } else { |
| 495 | ok = false; |
| 496 | } |
| 497 | } |
| 498 | if (ok) { |
| 499 | if (clp->debugCache()) { |
| 500 | std::cout << "PARSER CACHE USED FOR: " |
| 501 | << fileSystem->toPath(getFileId(0)) << std::endl; |
| 502 | } |
| 503 | return true; |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | // This is not a parent Parser object |
| 508 | if (m_children.empty()) { |
| 509 | // std::cout << std::endl << "Parsing " << getSymbol(m_ppFileId) << " |
| 510 | // Line: " << m_offsetLine << std::endl << std::flush; |
| 511 | |
| 512 | parseOneFile_(m_ppFileId, m_offsetLine); |
| 513 | |
| 514 | // m_listener = new SV3_1aTreeShapeListener (this, |
| 515 | // m_antlrParserHandler->m_tokens, m_offsetLine); |
| 516 | // tree::ParseTreeWalker::DEFAULT.walk (m_listener, |
| 517 | // m_antlrParserHandler->m_tree); std::cout << std::endl << "End Parsing " |
| 518 | // << getSymbol(m_ppFileId) << " Line: " << m_offsetLine << std::endl << |
| 519 | // std::flush; |
| 520 | } |
| 521 | |
| 522 | // This is either a parent Parser object of this Parser object has no parent |