diff --git a/C/API.h b/C/API.h index 1a58730c6..194cfe980 100644 --- a/C/API.h +++ b/C/API.h @@ -23,28 +23,28 @@ // From https://gcc.gnu.org/wiki/Visibility #if defined _WIN32 || defined __CYGWIN__ - #ifdef EXPORT_C_API - #ifdef __GNUC__ - #define PSY_C_API __attribute__ ((dllexport)) - #else - #define PSY_C_API __declspec(dllexport) - #endif - #else - #ifdef __GNUC__ - #define PSY_C_API __attribute__ ((dllimport)) - #else - #define PSY_C_API __declspec(dllimport) - #endif - #endif - #define PSY_C_NON_API +#ifdef EXPORT_C_API +#ifdef __GNUC__ +#define PSY_C_API __attribute__((dllexport)) #else - #if __GNUC__ >= 4 - #define PSY_C_API __attribute__ ((visibility ("default"))) - #define PSY_C_NON_API __attribute__ ((visibility ("hidden"))) - #else - #define PSY_C_API - #define PSY_C_NON_API - #endif +#define PSY_C_API __declspec(dllexport) +#endif +#else +#ifdef __GNUC__ +#define PSY_C_API __attribute__((dllimport)) +#else +#define PSY_C_API __declspec(dllimport) +#endif +#endif +#define PSY_C_NON_API +#else +#if __GNUC__ >= 4 +#define PSY_C_API __attribute__((visibility("default"))) +#define PSY_C_NON_API __attribute__((visibility("hidden"))) +#else +#define PSY_C_API +#define PSY_C_NON_API +#endif #endif #endif diff --git a/C/Fwds.h b/C/Fwds.h index 5bd53c09f..c67020c0a 100644 --- a/C/Fwds.h +++ b/C/Fwds.h @@ -189,20 +189,27 @@ class AmbiguousCastOrBinaryExpressionSyntax; class AmbiguousExpressionOrDeclarationStatementSyntax; /* Lists */ -typedef SyntaxNodePlainList DeclarationListSyntax; -typedef SyntaxNodeSeparatedList EnumeratorListSyntax; -typedef SyntaxNodeSeparatedList ParameterDeclarationListSyntax; -typedef SyntaxNodePlainList SpecifierListSyntax; -typedef SyntaxNodeSeparatedList ExtGNU_AttributeListSyntax; -typedef SyntaxNodeSeparatedList DeclaratorListSyntax; -typedef SyntaxNodePlainList DeclaratorSuffixListSyntax; -typedef SyntaxNodePlainList DesignatorListSyntax; -typedef SyntaxNodeSeparatedList InitializerListSyntax; -typedef SyntaxNodeSeparatedList ExpressionListSyntax; -typedef SyntaxNodeSeparatedList GenericAssociationListSyntax; -typedef SyntaxNodePlainList StatementListSyntax; -typedef SyntaxNodeSeparatedList ExtGNU_AsmOperandListSyntax; -typedef SyntaxNodePlainList ExtKR_ParameterDeclarationListSyntax; +typedef SyntaxNodePlainList DeclarationListSyntax; +typedef SyntaxNodeSeparatedList + EnumeratorListSyntax; +typedef SyntaxNodeSeparatedList + ParameterDeclarationListSyntax; +typedef SyntaxNodePlainList SpecifierListSyntax; +typedef SyntaxNodeSeparatedList + ExtGNU_AttributeListSyntax; +typedef SyntaxNodeSeparatedList DeclaratorListSyntax; +typedef SyntaxNodePlainList + DeclaratorSuffixListSyntax; +typedef SyntaxNodePlainList DesignatorListSyntax; +typedef SyntaxNodeSeparatedList InitializerListSyntax; +typedef SyntaxNodeSeparatedList ExpressionListSyntax; +typedef SyntaxNodeSeparatedList + GenericAssociationListSyntax; +typedef SyntaxNodePlainList StatementListSyntax; +typedef SyntaxNodeSeparatedList + ExtGNU_AsmOperandListSyntax; +typedef SyntaxNodePlainList + ExtKR_ParameterDeclarationListSyntax; //=================================================================== Semantic @@ -242,7 +249,7 @@ class Compilation; class Assembly; class SemanticModel; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/SyntaxTree.cpp b/C/SyntaxTree.cpp index 4db503d46..5da09f3b6 100644 --- a/C/SyntaxTree.cpp +++ b/C/SyntaxTree.cpp @@ -44,411 +44,363 @@ #include // Uncomment to display the sequence of lexed tokens. -//#define DEBUG_LEXED_TOKENS +// #define DEBUG_LEXED_TOKENS using namespace psy; using namespace C; -struct SyntaxTree::SyntaxTreeImpl -{ - SyntaxTreeImpl(SourceText text, - TextPreprocessingState textPPState, - TextCompleteness textCompleteness, - ParseOptions parseOptions, - const std::string& filePath) - : pool_(new MemoryPool()) - , text_(std::move(text)) - , textCompleteness_(textCompleteness) - , textPPState_(textPPState) - , parseOptions_(std::move(parseOptions)) - , filePath_(filePath) - , rootNode_(nullptr) - , parseExitedEarly_(false) - { - if (filePath_.empty()) - filePath_ = ""; - } - - std::unique_ptr pool_; - - SourceText text_; - TextCompleteness textCompleteness_; - TextPreprocessingState textPPState_; - ParseOptions parseOptions_; - std::string filePath_; - - TextElementTable identifiers_; - TextElementTable integers_; - TextElementTable floatings_; - TextElementTable imaginaryIntegers_; - TextElementTable imaginaryFloatings_; - TextElementTable characters_; - TextElementTable strings_; - - SyntaxNode* rootNode_; - - LexedTokens tokens_; - std::vector lineDirectives_; - std::vector startOfLineOffsets_; - SyntaxTree::ExpansionsTable expansions_; - - bool parseExitedEarly_; - - std::vector diagnostics_; - - std::unordered_set attachedCompilations_; +struct SyntaxTree::SyntaxTreeImpl { + SyntaxTreeImpl(SourceText text, TextPreprocessingState textPPState, + TextCompleteness textCompleteness, ParseOptions parseOptions, + const std::string &filePath) + : pool_(new MemoryPool()), text_(std::move(text)), + textCompleteness_(textCompleteness), textPPState_(textPPState), + parseOptions_(std::move(parseOptions)), filePath_(filePath), + rootNode_(nullptr), parseExitedEarly_(false) { + if (filePath_.empty()) + filePath_ = ""; + } + + std::unique_ptr pool_; + + SourceText text_; + TextCompleteness textCompleteness_; + TextPreprocessingState textPPState_; + ParseOptions parseOptions_; + std::string filePath_; + + TextElementTable identifiers_; + TextElementTable integers_; + TextElementTable floatings_; + TextElementTable imaginaryIntegers_; + TextElementTable imaginaryFloatings_; + TextElementTable characters_; + TextElementTable strings_; + + SyntaxNode *rootNode_; + + LexedTokens tokens_; + std::vector lineDirectives_; + std::vector startOfLineOffsets_; + SyntaxTree::ExpansionsTable expansions_; + + bool parseExitedEarly_; + + std::vector diagnostics_; + + std::unordered_set attachedCompilations_; }; -SyntaxTree::SyntaxTree(SourceText text, - TextPreprocessingState textPPState, +SyntaxTree::SyntaxTree(SourceText text, TextPreprocessingState textPPState, TextCompleteness textCompleteness, - ParseOptions parseOptions, - const std::string& filePath) - : P(new SyntaxTreeImpl(text, - textPPState, - textCompleteness, - parseOptions, - filePath)) -{} - -SyntaxTree::~SyntaxTree() -{ -} - -MemoryPool* SyntaxTree::unitPool() const -{ - return P->pool_.get(); -} - -std::unique_ptr SyntaxTree::parseText(SourceText text, - TextPreprocessingState textPPState, - TextCompleteness textCompleteness, - ParseOptions parseOptions, - const std::string& filePath, - SyntaxCategory syntaxCategory) -{ - std::unique_ptr tree( - new SyntaxTree(text, - textPPState, - textCompleteness, - parseOptions, - filePath)); - tree->buildFor(syntaxCategory); - return tree; + ParseOptions parseOptions, const std::string &filePath) + : P(new SyntaxTreeImpl(text, textPPState, textCompleteness, parseOptions, + filePath)) {} + +SyntaxTree::~SyntaxTree() {} + +MemoryPool *SyntaxTree::unitPool() const { return P->pool_.get(); } + +std::unique_ptr +SyntaxTree::parseText(SourceText text, TextPreprocessingState textPPState, + TextCompleteness textCompleteness, + ParseOptions parseOptions, const std::string &filePath, + SyntaxCategory syntaxCategory) { + std::unique_ptr tree(new SyntaxTree( + text, textPPState, textCompleteness, parseOptions, filePath)); + tree->buildFor(syntaxCategory); + return tree; } -std::string SyntaxTree::filePath() const -{ - return P->filePath_; -} +std::string SyntaxTree::filePath() const { return P->filePath_; } -const SourceText& SyntaxTree::text() const -{ - return P->text_; -} +const SourceText &SyntaxTree::text() const { return P->text_; } -SyntaxNode* SyntaxTree::root() const -{ - return P->rootNode_; -} +SyntaxNode *SyntaxTree::root() const { return P->rootNode_; } -bool SyntaxTree::hasTranslationUnitRoot() const -{ - return static_cast(P->rootNode_->asTranslationUnit()); +bool SyntaxTree::hasTranslationUnitRoot() const { + return static_cast(P->rootNode_->asTranslationUnit()); } -TranslationUnitSyntax* SyntaxTree::translationUnitRoot() const -{ - if (hasTranslationUnitRoot()) - return P->rootNode_->asTranslationUnit(); - return nullptr; +TranslationUnitSyntax *SyntaxTree::translationUnitRoot() const { + if (hasTranslationUnitRoot()) + return P->rootNode_->asTranslationUnit(); + return nullptr; } -std::vector SyntaxTree::diagnostics() const -{ - return P->diagnostics_; +std::vector SyntaxTree::diagnostics() const { + return P->diagnostics_; } /* Forward calls to the lexed-tokens container */ void SyntaxTree::addToken(SyntaxToken tk) { P->tokens_.add(tk); } -SyntaxToken& SyntaxTree::tokenAt(LexedTokens::IndexType tkIdx) { return P->tokens_.tokenAt(tkIdx); } -const SyntaxToken& SyntaxTree::tokenAt(LexedTokens::IndexType tkIdx) const { return P->tokens_.tokenAt(tkIdx); } -SyntaxTree::TokenSequenceType::size_type SyntaxTree::tokenCount() const { return P->tokens_.count(); } -LexedTokens::IndexType SyntaxTree::freeTokenSlot() const { return P->tokens_.freeSlot(); } - -bool SyntaxTree::parseExitedEarly() const -{ - return P->parseExitedEarly_; +SyntaxToken &SyntaxTree::tokenAt(LexedTokens::IndexType tkIdx) { + return P->tokens_.tokenAt(tkIdx); +} +const SyntaxToken &SyntaxTree::tokenAt(LexedTokens::IndexType tkIdx) const { + return P->tokens_.tokenAt(tkIdx); +} +SyntaxTree::TokenSequenceType::size_type SyntaxTree::tokenCount() const { + return P->tokens_.count(); +} +LexedTokens::IndexType SyntaxTree::freeTokenSlot() const { + return P->tokens_.freeSlot(); } -void SyntaxTree::buildFor(SyntaxCategory syntaxCategory) -{ - Lexer lexer(this); - lexer.lex(); - -#ifdef DEBUG_LEXED_TOKENS - std::cout << "\n\n" << P->text_.rawText() << std::endl; - - std::cout.setf(std::ios::left, std::ios::adjustfield); - for (auto i = 1U; i < P->lexedTokens_.size(); ++i) // Skip initial EOF marker. - { - SyntaxToken tk = P->lexedTokens_[i]; - - std::cout << " "; - std::cout.width(16); - std::cout << tk.valueText(); - - auto offset = tk.charBegin(); - - auto l = computeLineno(offset); - auto c = computeColumn(offset, l); - std::cout << " "; - std::cout.width(8); - std::cout << (std::to_string(l) + ":" + std::to_string(c)); - - std::cout << " "; - std::cout.width(8); - std::cout << (std::string("(") + std::to_string(offset) + ")"); - std::cout << " "; +bool SyntaxTree::parseExitedEarly() const { return P->parseExitedEarly_; } - std::cout.width(6); - std::cout << tk.rawKind_ << std::endl; +void SyntaxTree::buildFor(SyntaxCategory syntaxCategory) { + Lexer lexer(this); + lexer.lex(); - } - std::cout << "\n\n\n"; +#ifdef DEBUG_LEXED_TOKENS + std::cout << "\n\n" << P->text_.rawText() << std::endl; + + std::cout.setf(std::ios::left, std::ios::adjustfield); + for (auto i = 1U; i < P->lexedTokens_.size(); ++i) // Skip initial EOF marker. + { + SyntaxToken tk = P->lexedTokens_[i]; + + std::cout << " "; + std::cout.width(16); + std::cout << tk.valueText(); + + auto offset = tk.charBegin(); + + auto l = computeLineno(offset); + auto c = computeColumn(offset, l); + std::cout << " "; + std::cout.width(8); + std::cout << (std::to_string(l) + ":" + std::to_string(c)); + + std::cout << " "; + std::cout.width(8); + std::cout << (std::string("(") + std::to_string(offset) + ")"); + std::cout << " "; + + std::cout.width(6); + std::cout << tk.rawKind_ << std::endl; + } + std::cout << "\n\n\n"; #endif - Parser parser(this); - switch (syntaxCategory) { - case SyntaxCategory::Declarations: { - DeclarationSyntax* decl = nullptr; - parser.parseExternalDeclaration(decl); - P->rootNode_ = decl; - break; - } - - case SyntaxCategory::Expressions: { - ExpressionSyntax* expr = nullptr; - parser.parseExpression(expr); - P->rootNode_ = expr; - break; - } - - case SyntaxCategory::Statements: { - StatementSyntax* stmt = nullptr; - parser.parseStatement(stmt, Parser::StatementContext::None); - P->rootNode_ = stmt; - break; - } - - default: - P->rootNode_ = parser.parse(); - } - - P->parseExitedEarly_ = parser.peek().kind() != EndOfFile; - - if (!parser.detectedAnyAmbiguity()) - return; - - auto disambiguationStrategy = Reparser::DisambiguationStrategy::UNSPECIFIED; - auto permitHeuristic = false; - switch (P->parseOptions_.treatmentOfAmbiguities()) { - case ParseOptions::TreatmentOfAmbiguities::None: - return; - - case ParseOptions::TreatmentOfAmbiguities::Diagnose: - for (const auto& diag : parser.releaseRetainedAmbiguityDiags()) - newDiagnostic(diag.first, diag.second); - return; - - case ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmicallyOrHeuristically: - permitHeuristic = true; - [[fallthrough]]; - - case ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmically: { - disambiguationStrategy = P->textCompleteness_ == TextCompleteness::Full - ? Reparser::DisambiguationStrategy::TypeSynonymsVerification - : Reparser::DisambiguationStrategy::SyntaxCorrelation; - break; - } - - case ParseOptions::TreatmentOfAmbiguities::DisambiguateHeuristically: - disambiguationStrategy = Reparser::DisambiguationStrategy::GuidelineImposition; - permitHeuristic = true; - break; - - default: - PSY_ESCAPE_VIA_RETURN(); - } - - if (!P->diagnostics_.empty()) - return; - - Reparser reparser; - reparser.setDisambiguationStrategy(disambiguationStrategy); - reparser.setPermitHeuristic(permitHeuristic); - reparser.reparse(this); + Parser parser(this); + switch (syntaxCategory) { + case SyntaxCategory::Declarations: { + DeclarationSyntax *decl = nullptr; + parser.parseExternalDeclaration(decl); + P->rootNode_ = decl; + break; + } + + case SyntaxCategory::Expressions: { + ExpressionSyntax *expr = nullptr; + parser.parseExpression(expr); + P->rootNode_ = expr; + break; + } + + case SyntaxCategory::Statements: { + StatementSyntax *stmt = nullptr; + parser.parseStatement(stmt, Parser::StatementContext::None); + P->rootNode_ = stmt; + break; + } + + default: + P->rootNode_ = parser.parse(); + } + + P->parseExitedEarly_ = parser.peek().kind() != EndOfFile; + + if (!parser.detectedAnyAmbiguity()) + return; + + auto disambiguationStrategy = Reparser::DisambiguationStrategy::UNSPECIFIED; + auto permitHeuristic = false; + switch (P->parseOptions_.treatmentOfAmbiguities()) { + case ParseOptions::TreatmentOfAmbiguities::None: + return; + + case ParseOptions::TreatmentOfAmbiguities::Diagnose: + for (const auto &diag : parser.releaseRetainedAmbiguityDiags()) + newDiagnostic(diag.first, diag.second); + return; + + case ParseOptions::TreatmentOfAmbiguities:: + DisambiguateAlgorithmicallyOrHeuristically: + permitHeuristic = true; + [[fallthrough]]; + + case ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmically: { + disambiguationStrategy = + P->textCompleteness_ == TextCompleteness::Full + ? Reparser::DisambiguationStrategy::TypeSynonymsVerification + : Reparser::DisambiguationStrategy::SyntaxCorrelation; + break; + } + + case ParseOptions::TreatmentOfAmbiguities::DisambiguateHeuristically: + disambiguationStrategy = + Reparser::DisambiguationStrategy::GuidelineImposition; + permitHeuristic = true; + break; + + default: + PSY_ESCAPE_VIA_RETURN(); + } + + if (!P->diagnostics_.empty()) + return; + + Reparser reparser; + reparser.setDisambiguationStrategy(disambiguationStrategy); + reparser.setPermitHeuristic(permitHeuristic); + reparser.reparse(this); } -const ParseOptions& SyntaxTree::parseOptions() const -{ - return P->parseOptions_; +const ParseOptions &SyntaxTree::parseOptions() const { + return P->parseOptions_; } -const Identifier* SyntaxTree::identifier(const char* s, unsigned size) -{ - return P->identifiers_.findOrInsert(s, size); +const Identifier *SyntaxTree::identifier(const char *s, unsigned size) { + return P->identifiers_.findOrInsert(s, size); } -const StringLiteral* SyntaxTree::stringLiteral(const char* s, unsigned size) -{ - return P->strings_.findOrInsert(s, size); +const StringLiteral *SyntaxTree::stringLiteral(const char *s, unsigned size) { + return P->strings_.findOrInsert(s, size); } -const IntegerConstant* SyntaxTree::integerConstant(const char* s, unsigned int size) -{ - return P->integers_.findOrInsert(s, size); +const IntegerConstant *SyntaxTree::integerConstant(const char *s, + unsigned int size) { + return P->integers_.findOrInsert(s, size); } -const FloatingConstant* SyntaxTree::floatingConstant(const char* s, unsigned int size) -{ - return P->floatings_.findOrInsert(s, size); +const FloatingConstant *SyntaxTree::floatingConstant(const char *s, + unsigned int size) { + return P->floatings_.findOrInsert(s, size); } -const CharacterConstant* SyntaxTree::characterConstant(const char* s, unsigned int size) -{ - return P->characters_.findOrInsert(s, size); +const CharacterConstant *SyntaxTree::characterConstant(const char *s, + unsigned int size) { + return P->characters_.findOrInsert(s, size); } -const ImaginaryIntegerConstant* SyntaxTree::imaginaryIntegerConstant(const char* s, unsigned int size) -{ - return P->imaginaryIntegers_.findOrInsert(s, size); +const ImaginaryIntegerConstant * +SyntaxTree::imaginaryIntegerConstant(const char *s, unsigned int size) { + return P->imaginaryIntegers_.findOrInsert(s, size); } -const ImaginaryFloatingConstant* SyntaxTree::imaginaryFloatingConstant(const char* s, unsigned int size) -{ - return P->imaginaryFloatings_.findOrInsert(s, size); +const ImaginaryFloatingConstant * +SyntaxTree::imaginaryFloatingConstant(const char *s, unsigned int size) { + return P->imaginaryFloatings_.findOrInsert(s, size); } - -void SyntaxTree::relayLineStart(unsigned int offset) -{ - P->startOfLineOffsets_.push_back(offset); +void SyntaxTree::relayLineStart(unsigned int offset) { + P->startOfLineOffsets_.push_back(offset); } -void SyntaxTree::relayExpansion(unsigned int offset, std::pair p) -{ - P->expansions_.insert(std::make_pair(offset, p)); +void SyntaxTree::relayExpansion(unsigned int offset, + std::pair p) { + P->expansions_.insert(std::make_pair(offset, p)); } -void SyntaxTree::relayLineDirective(unsigned int offset, - unsigned int lineno, - const std::string& filePath) -{ - P->lineDirectives_.emplace_back(lineno, filePath, offset); +void SyntaxTree::relayLineDirective(unsigned int offset, unsigned int lineno, + const std::string &filePath) { + P->lineDirectives_.emplace_back(lineno, filePath, offset); } -LinePosition SyntaxTree::computePosition(unsigned int offset) const -{ - unsigned int lineno = 0; - unsigned int column = 0; - - auto it = P->expansions_.find(offset); - if (it != P->expansions_.end()) { - lineno = it->second.first; - column = it->second.second + 1; - } - else { - lineno = searchForLineno(offset); - column = searchForColumn(offset, lineno); - - // Take line directives into consideration. - auto lineDir = searchForLineDirective(offset); - lineno -= searchForLineno(lineDir.offset()) + 1; - lineno += lineDir.lineno(); - } - - return LinePosition(lineno, column); +LinePosition SyntaxTree::computePosition(unsigned int offset) const { + unsigned int lineno = 0; + unsigned int column = 0; + + auto it = P->expansions_.find(offset); + if (it != P->expansions_.end()) { + lineno = it->second.first; + column = it->second.second + 1; + } else { + lineno = searchForLineno(offset); + column = searchForColumn(offset, lineno); + + // Take line directives into consideration. + auto lineDir = searchForLineDirective(offset); + lineno -= searchForLineno(lineDir.offset()) + 1; + lineno += lineDir.lineno(); + } + + return LinePosition(lineno, column); } -unsigned int SyntaxTree::searchForLineno(unsigned int offset) const -{ - auto it = std::lower_bound(P->startOfLineOffsets_.begin(), - P->startOfLineOffsets_.end(), - offset); - if (it == P->startOfLineOffsets_.end()) - return P->startOfLineOffsets_.size() - 1; - - if (it != P->startOfLineOffsets_.begin()) - --it; - return std::distance(P->startOfLineOffsets_.begin(), it); +unsigned int SyntaxTree::searchForLineno(unsigned int offset) const { + auto it = std::lower_bound(P->startOfLineOffsets_.begin(), + P->startOfLineOffsets_.end(), offset); + if (it == P->startOfLineOffsets_.end()) + return P->startOfLineOffsets_.size() - 1; + + if (it != P->startOfLineOffsets_.begin()) + --it; + return std::distance(P->startOfLineOffsets_.begin(), it); } -unsigned int SyntaxTree::searchForColumn(unsigned int offset, unsigned int lineno) const -{ - if (!offset) - return 0; - return offset - P->startOfLineOffsets_[lineno]; +unsigned int SyntaxTree::searchForColumn(unsigned int offset, + unsigned int lineno) const { + if (!offset) + return 0; + return offset - P->startOfLineOffsets_[lineno]; } -LineDirective SyntaxTree::searchForLineDirective(unsigned int offset) const -{ - auto it = std::lower_bound(P->lineDirectives_.begin(), - P->lineDirectives_.end(), - offset, - [] (auto lineDir, auto value) { return lineDir.offset() < value; }); +LineDirective SyntaxTree::searchForLineDirective(unsigned int offset) const { + auto it = std::lower_bound( + P->lineDirectives_.begin(), P->lineDirectives_.end(), offset, + [](auto lineDir, auto value) { return lineDir.offset() < value; }); - if (it != P->lineDirectives_.begin()) - --it; - return *it; + if (it != P->lineDirectives_.begin()) + --it; + return *it; } void SyntaxTree::newDiagnostic(DiagnosticDescriptor descriptor, - LexedTokens::IndexType tkIdx) const -{ - newDiagnostic(descriptor, tokenAt(tkIdx)); + LexedTokens::IndexType tkIdx) const { + newDiagnostic(descriptor, tokenAt(tkIdx)); } void SyntaxTree::newDiagnostic(DiagnosticDescriptor descriptor, - SyntaxToken tk) const -{ - LinePosition start = computePosition(tk.charStart()); - LinePosition end = computePosition(tk.charEnd()); - FileLinePositionSpan line(P->filePath_, start, end); - std::string snippet; - - auto it = std::lower_bound(P->startOfLineOffsets_.begin(), P->startOfLineOffsets_.end(), tk.charStart()); - if (it != P->startOfLineOffsets_.begin()) { - --it; - - auto lineBegIt = P->text_.rawText().begin() + *it; - auto lineCurIt = lineBegIt; - while (lineCurIt != P->text_.rawText().end()) { - if (*lineCurIt == '\n') - break; - ++lineCurIt; - } - - snippet.assign(lineBegIt, lineCurIt); - std::string marker(start.character(), ' '); - marker += '^'; - snippet += "\n" + marker + "\n"; + SyntaxToken tk) const { + LinePosition start = computePosition(tk.charStart()); + LinePosition end = computePosition(tk.charEnd()); + FileLinePositionSpan line(P->filePath_, start, end); + std::string snippet; + + auto it = std::lower_bound(P->startOfLineOffsets_.begin(), + P->startOfLineOffsets_.end(), tk.charStart()); + if (it != P->startOfLineOffsets_.begin()) { + --it; + + auto lineBegIt = P->text_.rawText().begin() + *it; + auto lineCurIt = lineBegIt; + while (lineCurIt != P->text_.rawText().end()) { + if (*lineCurIt == '\n') + break; + ++lineCurIt; } - P->diagnostics_.emplace_back(descriptor, Location::create(line), snippet); + snippet.assign(lineBegIt, lineCurIt); + std::string marker(start.character(), ' '); + marker += '^'; + snippet += "\n" + marker + "\n"; + } + + P->diagnostics_.emplace_back(descriptor, Location::create(line), snippet); } -void SyntaxTree::attachCompilation(const Compilation* compilation) const -{ - P->attachedCompilations_.insert(compilation); +void SyntaxTree::attachCompilation(const Compilation *compilation) const { + P->attachedCompilations_.insert(compilation); } -void SyntaxTree::detachCompilation(const Compilation* compilation) const -{ - P->attachedCompilations_.erase(compilation); +void SyntaxTree::detachCompilation(const Compilation *compilation) const { + P->attachedCompilations_.erase(compilation); } -std::unordered_set SyntaxTree::linkedCompilations() const -{ - return P->attachedCompilations_; +std::unordered_set SyntaxTree::linkedCompilations() const { + return P->attachedCompilations_; } diff --git a/C/SyntaxTree.h b/C/SyntaxTree.h index 50098f5ef..8a9cee704 100644 --- a/C/SyntaxTree.h +++ b/C/SyntaxTree.h @@ -57,145 +57,143 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.SyntaxTree * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API SyntaxTree -{ +class PSY_C_API SyntaxTree { public: - ~SyntaxTree(); - - /** - * \brief The SyntaxCategory enumeration. - * - * The possible categories of syntax that a SyntaxTree - * may represent. If unspecified, it is assumed that - * a SyntaxTree represents a \a translation-unit. - */ - enum class SyntaxCategory : uint8_t - { - UNSPECIFIED = 0, - - Declarations, - Expressions, - Statements, - }; - - /** - * Parse the input \p text, as according to the \p syntaxCategory, - * in order to build \c this SyntaxTree. - */ - static std::unique_ptr parseText(SourceText text, - TextPreprocessingState textPPState, - TextCompleteness textCompleteness, - ParseOptions parseOptions = ParseOptions(), - const std::string& filePath = "", - SyntaxCategory syntaxCategory = SyntaxCategory::UNSPECIFIED); - - /** - * The path of the file associated to \c this SyntaxTree. - */ - std::string filePath() const; - - /** - * The SourceText associated to \c this SyntaxTree. - */ - const SourceText& text() const; - - /** - * The root node of this \c this SyntaxTree. - */ - SyntaxNode* root() const; - - /** - * Whether \c this SyntaxTree has a \c TranslationUnit as the root node. - */ - bool hasTranslationUnitRoot() const; - - /** - * The \c TranslationUnit root of \c this SyntaxTree (in one exists). - */ - TranslationUnitSyntax* translationUnitRoot() const; - - /** - * The diagnostics in \c this SyntaxTree. - */ - std::vector diagnostics() const; - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SyntaxNode); - PSY_GRANT_ACCESS(SyntaxNodeList); - PSY_GRANT_ACCESS(Lexer); - PSY_GRANT_ACCESS(Parser); - PSY_GRANT_ACCESS(Binder); - PSY_GRANT_ACCESS(Symbol); - PSY_GRANT_ACCESS(Compilation); - PSY_GRANT_ACCESS(InternalsTestSuite); - PSY_GRANT_ACCESS(SyntaxWriterDOTFormat); // TODO: Remove this grant. - - MemoryPool* unitPool() const; - - using TokenSequenceType = std::vector; - using LineColum = std::pair; - using ExpansionsTable = std::unordered_map; - - /* Lexed-tokens access and manipulation */ - void addToken(SyntaxToken tk); - SyntaxToken& tokenAt(LexedTokens::IndexType tkIdx); - const SyntaxToken& tokenAt(LexedTokens::IndexType tkIdx) const; - TokenSequenceType::size_type tokenCount() const; - LexedTokens::IndexType freeTokenSlot() const; - - bool parseExitedEarly() const; - - const Identifier* identifier(const char* s, unsigned int size); - const IntegerConstant* integerConstant(const char* s, unsigned int size); - const FloatingConstant* floatingConstant(const char* s, unsigned int size); - const ImaginaryIntegerConstant* imaginaryIntegerConstant(const char* s, unsigned int size); - const ImaginaryFloatingConstant* imaginaryFloatingConstant(const char* s, unsigned int size); - const CharacterConstant* characterConstant(const char* s, unsigned int size); - const StringLiteral* stringLiteral(const char* s, unsigned size); - - void relayLineStart(unsigned int offset); - void relayExpansion(unsigned int offset, std::pair p); - void relayLineDirective(unsigned int offset, unsigned int lineno, const std::string& filePath); - - const ParseOptions& parseOptions() const; - - LanguageDialect dialect() const { return dialect_; } - void setDialect(LanguageDialect dialect) { dialect_ = dialect; } - - void newDiagnostic(DiagnosticDescriptor descriptor, LexedTokens::IndexType tkIdx) const; - void newDiagnostic(DiagnosticDescriptor descriptor, SyntaxToken tk) const; - - void attachCompilation(const Compilation*) const; - void detachCompilation(const Compilation*) const; - std::unordered_set linkedCompilations() const; + ~SyntaxTree(); + + /** + * \brief The SyntaxCategory enumeration. + * + * The possible categories of syntax that a SyntaxTree + * may represent. If unspecified, it is assumed that + * a SyntaxTree represents a \a translation-unit. + */ + enum class SyntaxCategory : uint8_t { + UNSPECIFIED = 0, + + Declarations, + Expressions, + Statements, + }; + + /** + * Parse the input \p text, as according to the \p syntaxCategory, + * in order to build \c this SyntaxTree. + */ + static std::unique_ptr + parseText(SourceText text, TextPreprocessingState textPPState, + TextCompleteness textCompleteness, + ParseOptions parseOptions = ParseOptions(), + const std::string &filePath = "", + SyntaxCategory syntaxCategory = SyntaxCategory::UNSPECIFIED); + + /** + * The path of the file associated to \c this SyntaxTree. + */ + std::string filePath() const; + + /** + * The SourceText associated to \c this SyntaxTree. + */ + const SourceText &text() const; + + /** + * The root node of this \c this SyntaxTree. + */ + SyntaxNode *root() const; + + /** + * Whether \c this SyntaxTree has a \c TranslationUnit as the root node. + */ + bool hasTranslationUnitRoot() const; + + /** + * The \c TranslationUnit root of \c this SyntaxTree (in one exists). + */ + TranslationUnitSyntax *translationUnitRoot() const; + + /** + * The diagnostics in \c this SyntaxTree. + */ + std::vector diagnostics() const; + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SyntaxNode); + PSY_GRANT_ACCESS(SyntaxNodeList); + PSY_GRANT_ACCESS(Lexer); + PSY_GRANT_ACCESS(Parser); + PSY_GRANT_ACCESS(Binder); + PSY_GRANT_ACCESS(Symbol); + PSY_GRANT_ACCESS(Compilation); + PSY_GRANT_ACCESS(InternalsTestSuite); + PSY_GRANT_ACCESS(SyntaxWriterDOTFormat); // TODO: Remove this grant. + + MemoryPool *unitPool() const; + + using TokenSequenceType = std::vector; + using LineColum = std::pair; + using ExpansionsTable = std::unordered_map; + + /* Lexed-tokens access and manipulation */ + void addToken(SyntaxToken tk); + SyntaxToken &tokenAt(LexedTokens::IndexType tkIdx); + const SyntaxToken &tokenAt(LexedTokens::IndexType tkIdx) const; + TokenSequenceType::size_type tokenCount() const; + LexedTokens::IndexType freeTokenSlot() const; + + bool parseExitedEarly() const; + + const Identifier *identifier(const char *s, unsigned int size); + const IntegerConstant *integerConstant(const char *s, unsigned int size); + const FloatingConstant *floatingConstant(const char *s, unsigned int size); + const ImaginaryIntegerConstant *imaginaryIntegerConstant(const char *s, + unsigned int size); + const ImaginaryFloatingConstant *imaginaryFloatingConstant(const char *s, + unsigned int size); + const CharacterConstant *characterConstant(const char *s, unsigned int size); + const StringLiteral *stringLiteral(const char *s, unsigned size); + + void relayLineStart(unsigned int offset); + void relayExpansion(unsigned int offset, std::pair p); + void relayLineDirective(unsigned int offset, unsigned int lineno, + const std::string &filePath); + + const ParseOptions &parseOptions() const; + + LanguageDialect dialect() const { return dialect_; } + void setDialect(LanguageDialect dialect) { dialect_ = dialect; } + + void newDiagnostic(DiagnosticDescriptor descriptor, + LexedTokens::IndexType tkIdx) const; + void newDiagnostic(DiagnosticDescriptor descriptor, SyntaxToken tk) const; + + void attachCompilation(const Compilation *) const; + void detachCompilation(const Compilation *) const; + std::unordered_set linkedCompilations() const; private: - SyntaxTree(SourceText text, - TextPreprocessingState textPPState, - TextCompleteness textCompleteness, - ParseOptions parseOptions, - const std::string& path); + SyntaxTree(SourceText text, TextPreprocessingState textPPState, + TextCompleteness textCompleteness, ParseOptions parseOptions, + const std::string &path); - // Unavailable - SyntaxTree(const SyntaxTree&) = delete; - SyntaxTree& operator=(const SyntaxTree&) = delete; + // Unavailable + SyntaxTree(const SyntaxTree &) = delete; + SyntaxTree &operator=(const SyntaxTree &) = delete; - DECL_PIMPL(SyntaxTree) + DECL_PIMPL(SyntaxTree) - void buildFor(SyntaxCategory syntaxCategory); + void buildFor(SyntaxCategory syntaxCategory); - LinePosition computePosition(unsigned int offset) const; - unsigned int searchForLineno(unsigned int offset) const; - unsigned int searchForColumn(unsigned int offset, unsigned int lineno) const; - LineDirective searchForLineDirective(unsigned int offset) const; + LinePosition computePosition(unsigned int offset) const; + unsigned int searchForLineno(unsigned int offset) const; + unsigned int searchForColumn(unsigned int offset, unsigned int lineno) const; + LineDirective searchForLineDirective(unsigned int offset) const; - // TODO: Move to implementaiton. - LanguageDialect dialect_; - std::vector comments_; + // TODO: Move to implementaiton. + LanguageDialect dialect_; + std::vector comments_; }; -} // C -} // psy - +} // namespace C +} // namespace psy #endif diff --git a/C/binder/Binder.cpp b/C/binder/Binder.cpp index 52c01a8b7..869de4aa3 100644 --- a/C/binder/Binder.cpp +++ b/C/binder/Binder.cpp @@ -22,11 +22,11 @@ #include "SyntaxTree.h" -#include "binder/Scope.h" #include "binder/ConstraintsInDeclarations.h" +#include "binder/Scope.h" #include "compilation/SemanticModel.h" -#include "symbols/Symbol_ALL.h" #include "symbols/SymbolName_ALL.h" +#include "symbols/Symbol_ALL.h" #include "syntax/SyntaxFacts.h" #include "syntax/SyntaxNodes.h" #include "syntax/SyntaxUtilities.h" @@ -38,231 +38,233 @@ using namespace psy; using namespace C; -Binder::Binder(SemanticModel* semaModel, const SyntaxTree* tree) - : SyntaxVisitor(tree) - , semaModel_(semaModel) - , stashedScope_(nullptr) - , diagReporter_(this) -{} +Binder::Binder(SemanticModel *semaModel, const SyntaxTree *tree) + : SyntaxVisitor(tree), semaModel_(semaModel), stashedScope_(nullptr), + diagReporter_(this) {} -Binder::~Binder() -{ -} +Binder::~Binder() {} -void Binder::bind() -{ - // The outermost scope and symbol. - scopes_.push(nullptr); - syms_.push(nullptr); +void Binder::bind() { + // The outermost scope and symbol. + scopes_.push(nullptr); + syms_.push(nullptr); - visit(tree_->root()); + visit(tree_->root()); - PSY_ASSERT_W_MSG(scopes_.top() == nullptr, return, "expected outermost scope"); - scopes_.pop(); - PSY_ASSERT_W_MSG(scopes_.empty(), return, "unexpected remaining scope"); + PSY_ASSERT_W_MSG(scopes_.top() == nullptr, return, + "expected outermost scope"); + scopes_.pop(); + PSY_ASSERT_W_MSG(scopes_.empty(), return, "unexpected remaining scope"); -// PSY_ASSERT_W_MSG(symDEFs_.top() == nullptr, return, "expected outermost symbol"); - syms_.pop(); -// PSY_ASSERT_W_MSG(symDEFs_.empty(), return, "unexpected remaining symbol"); + // PSY_ASSERT_W_MSG(symDEFs_.top() == nullptr, return, "expected outermost + // symbol"); + syms_.pop(); + // PSY_ASSERT_W_MSG(symDEFs_.empty(), return, "unexpected remaining + // symbol"); } -void Binder::openScope(ScopeKind scopeK) -{ - std::unique_ptr scope(new Scope(scopeK)); - scopes_.push(scope.get()); +void Binder::openScope(ScopeKind scopeK) { + std::unique_ptr scope(new Scope(scopeK)); + scopes_.push(scope.get()); - auto enclosingScope = scopes_.top(); - enclosingScope->enclose(std::move(scope)); + auto enclosingScope = scopes_.top(); + enclosingScope->enclose(std::move(scope)); } -void Binder::reopenStashedScope() -{ - PSY_ASSERT(stashedScope_, return); +void Binder::reopenStashedScope() { + PSY_ASSERT(stashedScope_, return); - scopes_.push(stashedScope_); + scopes_.push(stashedScope_); } -void Binder::closeScope() -{ - scopes_.pop(); -} +void Binder::closeScope() { scopes_.pop(); } -void Binder::closeScopeAndStashIt() -{ - stashedScope_ = scopes_.top(); - scopes_.pop(); +void Binder::closeScopeAndStashIt() { + stashedScope_ = scopes_.top(); + scopes_.pop(); } template -SymT* Binder::pushSym(const SyntaxNode* node, std::unique_ptr sym) -{ - syms_.push(sym.get()); - return static_cast(semaModel_->storeDeclaredSym(node, std::move(sym))); +SymT *Binder::pushSym(const SyntaxNode *node, std::unique_ptr sym) { + syms_.push(sym.get()); + return static_cast( + semaModel_->storeDeclaredSym(node, std::move(sym))); } -template FunctionSymbol* Binder::pushSym(const SyntaxNode*, std::unique_ptr); -template FieldSymbol* Binder::pushSym(const SyntaxNode*, std::unique_ptr); -template EnumeratorSymbol* Binder::pushSym(const SyntaxNode*, std::unique_ptr); -template ParameterSymbol* Binder::pushSym(const SyntaxNode*, std::unique_ptr); -template VariableSymbol* Binder::pushSym(const SyntaxNode*, std::unique_ptr); -template ArrayTypeSymbol* Binder::pushSym(const SyntaxNode*, std::unique_ptr); -template NamedTypeSymbol* Binder::pushSym(const SyntaxNode*, std::unique_ptr); -template PointerTypeSymbol* Binder::pushSym(const SyntaxNode*, std::unique_ptr); - -void Binder::popSym() -{ - syms_.pop(); -} +template FunctionSymbol * +Binder::pushSym(const SyntaxNode *, + std::unique_ptr); +template FieldSymbol * +Binder::pushSym(const SyntaxNode *, std::unique_ptr); +template EnumeratorSymbol * +Binder::pushSym(const SyntaxNode *, + std::unique_ptr); +template ParameterSymbol * +Binder::pushSym(const SyntaxNode *, + std::unique_ptr); +template VariableSymbol * +Binder::pushSym(const SyntaxNode *, + std::unique_ptr); +template ArrayTypeSymbol * +Binder::pushSym(const SyntaxNode *, + std::unique_ptr); +template NamedTypeSymbol * +Binder::pushSym(const SyntaxNode *, + std::unique_ptr); +template PointerTypeSymbol * +Binder::pushSym(const SyntaxNode *, + std::unique_ptr); + +void Binder::popSym() { syms_.pop(); } template -TySymT* Binder::pushTySym(std::unique_ptr tySym) -{ - tySyms_.push(tySym.get()); - return static_cast(semaModel_->storeUsedSym(std::move(tySym))); +TySymT *Binder::pushTySym(std::unique_ptr tySym) { + tySyms_.push(tySym.get()); + return static_cast(semaModel_->storeUsedSym(std::move(tySym))); } -template ArrayTypeSymbol* Binder::pushTySym(std::unique_ptr); -template FunctionTypeSymbol* Binder::pushTySym(std::unique_ptr); -template NamedTypeSymbol* Binder::pushTySym(std::unique_ptr); -template PointerTypeSymbol* Binder::pushTySym(std::unique_ptr); +template ArrayTypeSymbol * + Binder::pushTySym(std::unique_ptr); +template FunctionTypeSymbol * + Binder::pushTySym(std::unique_ptr); +template NamedTypeSymbol * + Binder::pushTySym(std::unique_ptr); +template PointerTypeSymbol * + Binder::pushTySym(std::unique_ptr); -void Binder::popTySym() -{ - tySyms_.pop(); -} +void Binder::popTySym() { tySyms_.pop(); } - //--------------// - // Declarations // - //--------------// +//--------------// +// Declarations // +//--------------// -SyntaxVisitor::Action Binder::visitTranslationUnit(const TranslationUnitSyntax* node) -{ - makeSymAndPushIt(node); +SyntaxVisitor::Action +Binder::visitTranslationUnit(const TranslationUnitSyntax *node) { + makeSymAndPushIt(node); - openScope(ScopeKind::File); + openScope(ScopeKind::File); - for (auto declIt = node->declarations(); declIt; declIt = declIt->next) - visit(declIt->value); + for (auto declIt = node->declarations(); declIt; declIt = declIt->next) + visit(declIt->value); - closeScope(); + closeScope(); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitIncompleteDeclaration(const IncompleteDeclarationSyntax* node) -{ - ConstraintsInDeclarations::UselessDeclaration(node->lastToken(), &diagReporter_); +SyntaxVisitor::Action +Binder::visitIncompleteDeclaration(const IncompleteDeclarationSyntax *node) { + ConstraintsInDeclarations::UselessDeclaration(node->lastToken(), + &diagReporter_); - for (auto specIt = node->specifiers(); specIt; specIt = specIt->next) - ; + for (auto specIt = node->specifiers(); specIt; specIt = specIt->next) + ; - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitStructOrUnionDeclaration(const StructOrUnionDeclarationSyntax* node) -{ - return visitStructOrUnionDeclaration_AtSpecifier(node); +SyntaxVisitor::Action Binder::visitStructOrUnionDeclaration( + const StructOrUnionDeclarationSyntax *node) { + return visitStructOrUnionDeclaration_AtSpecifier(node); } -SyntaxVisitor::Action Binder::visitStructOrUnionDeclaration_DONE(const StructOrUnionDeclarationSyntax* node) -{ - return Action::Skip; +SyntaxVisitor::Action Binder::visitStructOrUnionDeclaration_DONE( + const StructOrUnionDeclarationSyntax *node) { + return Action::Skip; } -SyntaxVisitor::Action Binder::visitEnumDeclaration(const EnumDeclarationSyntax* node) -{ - return visitEnumDeclaration_AtSpecifier(node); +SyntaxVisitor::Action +Binder::visitEnumDeclaration(const EnumDeclarationSyntax *node) { + return visitEnumDeclaration_AtSpecifier(node); } -SyntaxVisitor::Action Binder::visitEnumDeclaration_DONE(const EnumDeclarationSyntax* node) -{ - return Action::Skip; +SyntaxVisitor::Action +Binder::visitEnumDeclaration_DONE(const EnumDeclarationSyntax *node) { + return Action::Skip; } SyntaxVisitor::Action Binder::visitVariableAndOrFunctionDeclaration( - const VariableAndOrFunctionDeclarationSyntax* node) -{ - return visitVariableAndOrFunctionDeclaration_AtSpecifiers(node); + const VariableAndOrFunctionDeclarationSyntax *node) { + return visitVariableAndOrFunctionDeclaration_AtSpecifiers(node); } SyntaxVisitor::Action Binder::visitVariableAndOrFunctionDeclaration_DONE( - const VariableAndOrFunctionDeclarationSyntax*) -{ - popTySym(); + const VariableAndOrFunctionDeclarationSyntax *) { + popTySym(); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitFieldDeclaration(const FieldDeclarationSyntax* node) -{ - return visitFieldDeclaration_AtSpecifiers(node); +SyntaxVisitor::Action +Binder::visitFieldDeclaration(const FieldDeclarationSyntax *node) { + return visitFieldDeclaration_AtSpecifiers(node); } -SyntaxVisitor::Action Binder::visitFieldDeclaration_DONE(const FieldDeclarationSyntax*) -{ - popTySym(); +SyntaxVisitor::Action +Binder::visitFieldDeclaration_DONE(const FieldDeclarationSyntax *) { + popTySym(); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitEnumeratorDeclaration(const EnumeratorDeclarationSyntax* node) -{ - return visitEnumeratorDeclaration_AtImplicitSpecifier(node); +SyntaxVisitor::Action +Binder::visitEnumeratorDeclaration(const EnumeratorDeclarationSyntax *node) { + return visitEnumeratorDeclaration_AtImplicitSpecifier(node); } -SyntaxVisitor::Action Binder::visitEnumeratorDeclaration_DONE(const EnumeratorDeclarationSyntax* node) -{ - popTySym(); +SyntaxVisitor::Action Binder::visitEnumeratorDeclaration_DONE( + const EnumeratorDeclarationSyntax *node) { + popTySym(); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitParameterDeclaration(const ParameterDeclarationSyntax* node) -{ - return visitParameterDeclaration_AtSpecifiers(node); +SyntaxVisitor::Action +Binder::visitParameterDeclaration(const ParameterDeclarationSyntax *node) { + return visitParameterDeclaration_AtSpecifiers(node); } -SyntaxVisitor::Action Binder::visitParameterDeclaration_DONE(const ParameterDeclarationSyntax*) -{ - return Action::Skip; +SyntaxVisitor::Action +Binder::visitParameterDeclaration_DONE(const ParameterDeclarationSyntax *) { + return Action::Skip; } -SyntaxVisitor::Action Binder::visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax*) -{ - return Action::Skip; +SyntaxVisitor::Action +Binder::visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax *) { + return Action::Skip; } -SyntaxVisitor::Action Binder::visitFunctionDefinition(const FunctionDefinitionSyntax* node) -{ - return visitFunctionDefinition_AtSpecifiers(node); +SyntaxVisitor::Action +Binder::visitFunctionDefinition(const FunctionDefinitionSyntax *node) { + return visitFunctionDefinition_AtSpecifiers(node); } -SyntaxVisitor::Action Binder::visitFunctionDefinition_DONE(const FunctionDefinitionSyntax* node) -{ - popTySym(); +SyntaxVisitor::Action +Binder::visitFunctionDefinition_DONE(const FunctionDefinitionSyntax *node) { + popTySym(); - return Action::Skip; + return Action::Skip; } - //------------// - // Statements // - //------------// +//------------// +// Statements // +//------------// -SyntaxVisitor::Action Binder::visitCompoundStatement(const CompoundStatementSyntax* node) -{ - openScope(ScopeKind::Block); +SyntaxVisitor::Action +Binder::visitCompoundStatement(const CompoundStatementSyntax *node) { + openScope(ScopeKind::Block); - for (auto stmtIt = node->statements(); stmtIt; stmtIt = stmtIt->next) - visit(stmtIt->value); + for (auto stmtIt = node->statements(); stmtIt; stmtIt = stmtIt->next) + visit(stmtIt->value); - closeScope(); + closeScope(); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitDeclarationStatement(const DeclarationStatementSyntax* node) -{ - visit(node->declaration()); +SyntaxVisitor::Action +Binder::visitDeclarationStatement(const DeclarationStatementSyntax *node) { + visit(node->declaration()); - return Action::Skip; + return Action::Skip; } diff --git a/C/binder/Binder.h b/C/binder/Binder.h index 2fe1113b2..bfb6118bf 100644 --- a/C/binder/Binder.h +++ b/C/binder/Binder.h @@ -47,167 +47,189 @@ class SemanticModel; /** * \brief The Binder class. */ -class PSY_C_NON_API Binder final : protected SyntaxVisitor -{ - friend class BinderTester; +class PSY_C_NON_API Binder final : protected SyntaxVisitor { + friend class BinderTester; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SemanticModel); - PSY_GRANT_ACCESS(ConstraintsInDeclarations); - PSY_GRANT_ACCESS(ConstraintsInTypeSpecifiers); - PSY_GRANT_ACCESS(ConstraintsInDeclarators); - PSY_GRANT_ACCESS(SemanticsOfTypeQualifiers); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SemanticModel); + PSY_GRANT_ACCESS(ConstraintsInDeclarations); + PSY_GRANT_ACCESS(ConstraintsInTypeSpecifiers); + PSY_GRANT_ACCESS(ConstraintsInDeclarators); + PSY_GRANT_ACCESS(SemanticsOfTypeQualifiers); - Binder(SemanticModel* semaModel, const SyntaxTree* tree); - ~Binder(); + Binder(SemanticModel *semaModel, const SyntaxTree *tree); + ~Binder(); - void bind(); + void bind(); private: - // Unavailable - Binder(const Binder&) = delete; - void operator=(const Binder&) = delete; - - SemanticModel* semaModel_; - - void openScope(ScopeKind scopeK); - void closeScope(); - void reopenStashedScope(); - void closeScopeAndStashIt(); - std::stack scopes_; - Scope* stashedScope_; - - template SymT* pushSym(const SyntaxNode* node, std::unique_ptr); - void popSym(); - using SymContT = std::stack; - SymContT syms_; - - template TySymT* pushTySym(std::unique_ptr); - void popTySym(); - using TySymContT = std::stack; - TySymContT tySyms_; - - std::stack pendingFunTySyms_; - - template std::unique_ptr makeSymOrTySym(SymTArgs... args); - template void makeSymAndPushIt(const SyntaxNode* node, SymTArgs... arg); - template void makeTySymAndPushIt(SymTArgs... arg); - - struct DiagnosticsReporter - { - DiagnosticsReporter(Binder* binder) - : binder_(binder) - {} - Binder* binder_; - void diagnose(DiagnosticDescriptor&& desc, SyntaxToken tk); - }; - - DiagnosticsReporter diagReporter_; - - //--------------// - // Declarations // - //--------------// - virtual Action visitTranslationUnit(const TranslationUnitSyntax*) override; - virtual Action visitIncompleteDeclaration(const IncompleteDeclarationSyntax*) override; - virtual Action visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax*) override; - - template Action visitTypeDeclaration_AtInternalDeclarations_COMMON( - const TyDeclT* node, - Action (Binder::*visit_DONE)(const TyDeclT*)); - - virtual Action visitStructOrUnionDeclaration(const StructOrUnionDeclarationSyntax*) override; - Action visitStructOrUnionDeclaration_AtSpecifier(const StructOrUnionDeclarationSyntax*); - Action visitStructOrUnionDeclaration_DONE(const StructOrUnionDeclarationSyntax*); - virtual Action visitEnumDeclaration(const EnumDeclarationSyntax*) override; - Action visitEnumDeclaration_AtSpecifier(const EnumDeclarationSyntax*); - Action visitEnumDeclaration_DONE(const EnumDeclarationSyntax*); - - template Action visitDeclaration_AtSpecifiers_COMMON( - const DeclT* node, - Action (Binder::*visit_AtDeclarators)(const DeclT*)); - template Action visitDeclaration_AtDeclarators_COMMON( - const DeclT* node, - Action (Binder::*visit_DONE)(const DeclT*)); - - virtual Action visitVariableAndOrFunctionDeclaration(const VariableAndOrFunctionDeclarationSyntax*) override; - Action visitVariableAndOrFunctionDeclaration_AtSpecifiers(const VariableAndOrFunctionDeclarationSyntax*); - Action visitVariableAndOrFunctionDeclaration_AtDeclarators(const VariableAndOrFunctionDeclarationSyntax*); - Action visitVariableAndOrFunctionDeclaration_DONE(const VariableAndOrFunctionDeclarationSyntax*); - - virtual Action visitFieldDeclaration(const FieldDeclarationSyntax*) override; - Action visitFieldDeclaration_AtSpecifiers(const FieldDeclarationSyntax*); - Action visitFieldDeclaration_AtDeclarators(const FieldDeclarationSyntax*); - Action visitFieldDeclaration_DONE(const FieldDeclarationSyntax*); - - virtual Action visitEnumeratorDeclaration(const EnumeratorDeclarationSyntax*) override; - Action visitEnumeratorDeclaration_AtImplicitSpecifier(const EnumeratorDeclarationSyntax*); - Action visitEnumeratorDeclaration_AtDeclarator(const EnumeratorDeclarationSyntax*); - Action visitEnumeratorDeclaration_DONE(const EnumeratorDeclarationSyntax*); - - virtual Action visitParameterDeclaration(const ParameterDeclarationSyntax*) override; - Action visitParameterDeclaration_AtSpecifiers(const ParameterDeclarationSyntax*); - Action visitParameterDeclaration_AtDeclarator(const ParameterDeclarationSyntax*); - Action visitParameterDeclaration_DONE(const ParameterDeclarationSyntax*); - - virtual Action visitFunctionDefinition(const FunctionDefinitionSyntax*) override; - Action visitFunctionDefinition_AtSpecifiers(const FunctionDefinitionSyntax*); - Action visitFunctionDefinition_AtDeclarator(const FunctionDefinitionSyntax*); - Action visitFunctionDefinition_DONE(const FunctionDefinitionSyntax*); - - /* Specifiers */ - virtual Action visitBuiltinTypeSpecifier(const BuiltinTypeSpecifierSyntax*) override; - virtual Action visitTagTypeSpecifier(const TagTypeSpecifierSyntax*) override; - virtual Action visitTypeDeclarationAsSpecifier(const TypeDeclarationAsSpecifierSyntax*) override; - virtual Action visitTypedefName(const TypedefNameSyntax*) override; - virtual Action visitTypeQualifier(const TypeQualifierSyntax*) override; - Action visitIfNotTypeQualifier(const SpecifierSyntax*); - Action visitIfTypeQualifier(const SpecifierSyntax*); - - /* Declarators */ - virtual Action visitArrayOrFunctionDeclarator(const ArrayOrFunctionDeclaratorSyntax*) override; - virtual Action visitPointerDeclarator(const PointerDeclaratorSyntax*) override; - virtual Action visitParenthesizedDeclarator(const ParenthesizedDeclaratorSyntax*) override; - virtual Action visitSubscriptSuffix(const SubscriptSuffixSyntax*) override; - virtual Action visitParameterSuffix(const ParameterSuffixSyntax*) override; - virtual Action visitIdentifierDeclarator(const IdentifierDeclaratorSyntax*) override; - virtual Action visitAbstractDeclarator(const AbstractDeclaratorSyntax*) override; - Action nameSymAtTop(const char* s); - Action typeSymAtTopAndPopIt(); - - template Action determineContextAndMakeSym(const DecltrT* node); - - //------------// - // Statements // - //------------// - virtual Action visitCompoundStatement(const CompoundStatementSyntax*) override; - virtual Action visitDeclarationStatement(const DeclarationStatementSyntax*) override; + // Unavailable + Binder(const Binder &) = delete; + void operator=(const Binder &) = delete; + + SemanticModel *semaModel_; + + void openScope(ScopeKind scopeK); + void closeScope(); + void reopenStashedScope(); + void closeScopeAndStashIt(); + std::stack scopes_; + Scope *stashedScope_; + + template + SymT *pushSym(const SyntaxNode *node, std::unique_ptr); + void popSym(); + using SymContT = std::stack; + SymContT syms_; + + template TySymT *pushTySym(std::unique_ptr); + void popTySym(); + using TySymContT = std::stack; + TySymContT tySyms_; + + std::stack pendingFunTySyms_; + + template + std::unique_ptr makeSymOrTySym(SymTArgs... args); + template + void makeSymAndPushIt(const SyntaxNode *node, SymTArgs... arg); + template + void makeTySymAndPushIt(SymTArgs... arg); + + struct DiagnosticsReporter { + DiagnosticsReporter(Binder *binder) : binder_(binder) {} + Binder *binder_; + void diagnose(DiagnosticDescriptor &&desc, SyntaxToken tk); + }; + + DiagnosticsReporter diagReporter_; + + //--------------// + // Declarations // + //--------------// + virtual Action visitTranslationUnit(const TranslationUnitSyntax *) override; + virtual Action + visitIncompleteDeclaration(const IncompleteDeclarationSyntax *) override; + virtual Action + visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax *) override; + + template + Action visitTypeDeclaration_AtInternalDeclarations_COMMON( + const TyDeclT *node, Action (Binder::*visit_DONE)(const TyDeclT *)); + + virtual Action visitStructOrUnionDeclaration( + const StructOrUnionDeclarationSyntax *) override; + Action visitStructOrUnionDeclaration_AtSpecifier( + const StructOrUnionDeclarationSyntax *); + Action + visitStructOrUnionDeclaration_DONE(const StructOrUnionDeclarationSyntax *); + virtual Action visitEnumDeclaration(const EnumDeclarationSyntax *) override; + Action visitEnumDeclaration_AtSpecifier(const EnumDeclarationSyntax *); + Action visitEnumDeclaration_DONE(const EnumDeclarationSyntax *); + + template + Action visitDeclaration_AtSpecifiers_COMMON( + const DeclT *node, Action (Binder::*visit_AtDeclarators)(const DeclT *)); + template + Action visitDeclaration_AtDeclarators_COMMON( + const DeclT *node, Action (Binder::*visit_DONE)(const DeclT *)); + + virtual Action visitVariableAndOrFunctionDeclaration( + const VariableAndOrFunctionDeclarationSyntax *) override; + Action visitVariableAndOrFunctionDeclaration_AtSpecifiers( + const VariableAndOrFunctionDeclarationSyntax *); + Action visitVariableAndOrFunctionDeclaration_AtDeclarators( + const VariableAndOrFunctionDeclarationSyntax *); + Action visitVariableAndOrFunctionDeclaration_DONE( + const VariableAndOrFunctionDeclarationSyntax *); + + virtual Action visitFieldDeclaration(const FieldDeclarationSyntax *) override; + Action visitFieldDeclaration_AtSpecifiers(const FieldDeclarationSyntax *); + Action visitFieldDeclaration_AtDeclarators(const FieldDeclarationSyntax *); + Action visitFieldDeclaration_DONE(const FieldDeclarationSyntax *); + + virtual Action + visitEnumeratorDeclaration(const EnumeratorDeclarationSyntax *) override; + Action visitEnumeratorDeclaration_AtImplicitSpecifier( + const EnumeratorDeclarationSyntax *); + Action + visitEnumeratorDeclaration_AtDeclarator(const EnumeratorDeclarationSyntax *); + Action visitEnumeratorDeclaration_DONE(const EnumeratorDeclarationSyntax *); + + virtual Action + visitParameterDeclaration(const ParameterDeclarationSyntax *) override; + Action + visitParameterDeclaration_AtSpecifiers(const ParameterDeclarationSyntax *); + Action + visitParameterDeclaration_AtDeclarator(const ParameterDeclarationSyntax *); + Action visitParameterDeclaration_DONE(const ParameterDeclarationSyntax *); + + virtual Action + visitFunctionDefinition(const FunctionDefinitionSyntax *) override; + Action visitFunctionDefinition_AtSpecifiers(const FunctionDefinitionSyntax *); + Action visitFunctionDefinition_AtDeclarator(const FunctionDefinitionSyntax *); + Action visitFunctionDefinition_DONE(const FunctionDefinitionSyntax *); + + /* Specifiers */ + virtual Action + visitBuiltinTypeSpecifier(const BuiltinTypeSpecifierSyntax *) override; + virtual Action visitTagTypeSpecifier(const TagTypeSpecifierSyntax *) override; + virtual Action visitTypeDeclarationAsSpecifier( + const TypeDeclarationAsSpecifierSyntax *) override; + virtual Action visitTypedefName(const TypedefNameSyntax *) override; + virtual Action visitTypeQualifier(const TypeQualifierSyntax *) override; + Action visitIfNotTypeQualifier(const SpecifierSyntax *); + Action visitIfTypeQualifier(const SpecifierSyntax *); + + /* Declarators */ + virtual Action visitArrayOrFunctionDeclarator( + const ArrayOrFunctionDeclaratorSyntax *) override; + virtual Action + visitPointerDeclarator(const PointerDeclaratorSyntax *) override; + virtual Action + visitParenthesizedDeclarator(const ParenthesizedDeclaratorSyntax *) override; + virtual Action visitSubscriptSuffix(const SubscriptSuffixSyntax *) override; + virtual Action visitParameterSuffix(const ParameterSuffixSyntax *) override; + virtual Action + visitIdentifierDeclarator(const IdentifierDeclaratorSyntax *) override; + virtual Action + visitAbstractDeclarator(const AbstractDeclaratorSyntax *) override; + Action nameSymAtTop(const char *s); + Action typeSymAtTopAndPopIt(); + + template + Action determineContextAndMakeSym(const DecltrT *node); + + //------------// + // Statements // + //------------// + virtual Action + visitCompoundStatement(const CompoundStatementSyntax *) override; + virtual Action + visitDeclarationStatement(const DeclarationStatementSyntax *) override; }; template -std::unique_ptr Binder::makeSymOrTySym(SymTArgs... args) -{ - std::unique_ptr sym(new SymT(tree_, - scopes_.top(), - syms_.top(), - std::forward(args)...)); - return sym; +std::unique_ptr Binder::makeSymOrTySym(SymTArgs... args) { + std::unique_ptr sym(new SymT(tree_, scopes_.top(), syms_.top(), + std::forward(args)...)); + return sym; } template -void Binder::makeSymAndPushIt(const SyntaxNode* node, SymTArgs... args) -{ - std::unique_ptr sym = makeSymOrTySym(std::forward(args)...); - pushSym(node, std::move(sym)); +void Binder::makeSymAndPushIt(const SyntaxNode *node, SymTArgs... args) { + std::unique_ptr sym = + makeSymOrTySym(std::forward(args)...); + pushSym(node, std::move(sym)); } template -void Binder::makeTySymAndPushIt(SymTArgs... args) -{ - std::unique_ptr sym = makeSymOrTySym(std::forward(args)...); - pushTySym(std::move(sym)); +void Binder::makeTySymAndPushIt(SymTArgs... args) { + std::unique_ptr sym = + makeSymOrTySym(std::forward(args)...); + pushTySym(std::move(sym)); } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/Binder_Declarators.cpp b/C/binder/Binder_Declarators.cpp index b14fabf3f..e7069c227 100644 --- a/C/binder/Binder_Declarators.cpp +++ b/C/binder/Binder_Declarators.cpp @@ -22,11 +22,11 @@ #include "SyntaxTree.h" -#include "binder/Scope.h" #include "binder/ConstraintsInDeclarators.h" +#include "binder/Scope.h" #include "compilation/SemanticModel.h" -#include "symbols/Symbol_ALL.h" #include "symbols/SymbolName_ALL.h" +#include "symbols/Symbol_ALL.h" #include "syntax/SyntaxFacts.h" #include "syntax/SyntaxNodes.h" #include "syntax/SyntaxUtilities.h" @@ -39,329 +39,326 @@ using namespace psy; using namespace C; -SyntaxVisitor::Action Binder::nameSymAtTop(const char* s) -{ - PSY_ASSERT(!syms_.empty(), return Action::Quit); - Symbol* sym = syms_.top(); +SyntaxVisitor::Action Binder::nameSymAtTop(const char *s) { + PSY_ASSERT(!syms_.empty(), return Action::Quit); + Symbol *sym = syms_.top(); - auto nameableSym = TypeClass_NameableSymbol::asInstance(sym); - PSY_ASSERT(nameableSym, return Action::Quit); + auto nameableSym = TypeClass_NameableSymbol::asInstance(sym); + PSY_ASSERT(nameableSym, return Action::Quit); - std::unique_ptr name; - if (s) - name.reset(new PlainSymbolName(s)); - else - name.reset(new EmptySymbolName); - nameableSym->setName(std::move(name)); + std::unique_ptr name; + if (s) + name.reset(new PlainSymbolName(s)); + else + name.reset(new EmptySymbolName); + nameableSym->setName(std::move(name)); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::typeSymAtTopAndPopIt() -{ - PSY_ASSERT(!syms_.empty(), return Action::Quit); - auto sym = syms_.top(); +SyntaxVisitor::Action Binder::typeSymAtTopAndPopIt() { + PSY_ASSERT(!syms_.empty(), return Action::Quit); + auto sym = syms_.top(); - auto typeableSym = TypeClass_TypeableSymbol::asInstance(sym); - PSY_ASSERT(typeableSym, return Action::Quit); + auto typeableSym = TypeClass_TypeableSymbol::asInstance(sym); + PSY_ASSERT(typeableSym, return Action::Quit); - PSY_ASSERT(!tySyms_.empty(), return Action::Quit); - auto tySym = tySyms_.top(); + PSY_ASSERT(!tySyms_.empty(), return Action::Quit); + auto tySym = tySyms_.top(); - if (!pendingFunTySyms_.empty()) - pendingFunTySyms_.top()->addParameter(tySym); + if (!pendingFunTySyms_.empty()) + pendingFunTySyms_.top()->addParameter(tySym); - switch (tySym->typeKind()) { - case TypeKind::Array: - case TypeKind::Function: - case TypeKind::Pointer: - popTySym(); - break; + switch (tySym->typeKind()) { + case TypeKind::Array: + case TypeKind::Function: + case TypeKind::Pointer: + popTySym(); + break; - case TypeKind::Named: - break; + case TypeKind::Named: + break; - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); + } - typeableSym->setType(tySym); + typeableSym->setType(tySym); - popSym(); + popSym(); - return Action::Skip; + return Action::Skip; } template SyntaxVisitor::Action Binder::visitDeclaration_AtDeclarators_COMMON( - const DeclT* node, - Action (Binder::*visit_DONE)(const DeclT*)) -{ - for (auto decltorIt = node->declarators(); decltorIt; decltorIt = decltorIt->next) { - visit(decltorIt->value); - typeSymAtTopAndPopIt(); - } + const DeclT *node, Action (Binder::*visit_DONE)(const DeclT *)) { + for (auto decltorIt = node->declarators(); decltorIt; + decltorIt = decltorIt->next) { + visit(decltorIt->value); + typeSymAtTopAndPopIt(); + } - return ((this)->*(visit_DONE))(node); + return ((this)->*(visit_DONE))(node); } -SyntaxVisitor::Action Binder::visitVariableAndOrFunctionDeclaration_AtDeclarators( - const VariableAndOrFunctionDeclarationSyntax* node) -{ - return visitDeclaration_AtDeclarators_COMMON( - node, - &Binder::visitVariableAndOrFunctionDeclaration_DONE); +SyntaxVisitor::Action +Binder::visitVariableAndOrFunctionDeclaration_AtDeclarators( + const VariableAndOrFunctionDeclarationSyntax *node) { + return visitDeclaration_AtDeclarators_COMMON( + node, &Binder::visitVariableAndOrFunctionDeclaration_DONE); } -SyntaxVisitor::Action Binder::visitFieldDeclaration_AtDeclarators(const FieldDeclarationSyntax* node) -{ - return visitDeclaration_AtDeclarators_COMMON( - node, - &Binder::visitFieldDeclaration_DONE); +SyntaxVisitor::Action Binder::visitFieldDeclaration_AtDeclarators( + const FieldDeclarationSyntax *node) { + return visitDeclaration_AtDeclarators_COMMON( + node, &Binder::visitFieldDeclaration_DONE); } -SyntaxVisitor::Action Binder::visitEnumeratorDeclaration_AtDeclarator(const EnumeratorDeclarationSyntax* node) -{ - determineContextAndMakeSym(node); - nameSymAtTop(node->identifierToken().valueText_c_str()); - typeSymAtTopAndPopIt(); +SyntaxVisitor::Action Binder::visitEnumeratorDeclaration_AtDeclarator( + const EnumeratorDeclarationSyntax *node) { + determineContextAndMakeSym(node); + nameSymAtTop(node->identifierToken().valueText_c_str()); + typeSymAtTopAndPopIt(); - return visitEnumeratorDeclaration_DONE(node); + return visitEnumeratorDeclaration_DONE(node); } -SyntaxVisitor::Action Binder::visitParameterDeclaration_AtDeclarator(const ParameterDeclarationSyntax* node) -{ - visit(node->declarator()); +SyntaxVisitor::Action Binder::visitParameterDeclaration_AtDeclarator( + const ParameterDeclarationSyntax *node) { + visit(node->declarator()); - typeSymAtTopAndPopIt(); + typeSymAtTopAndPopIt(); - return visitParameterDeclaration_DONE(node); + return visitParameterDeclaration_DONE(node); } -SyntaxVisitor::Action Binder::visitFunctionDefinition_AtDeclarator(const FunctionDefinitionSyntax* node) -{ - visit(node->declarator()); +SyntaxVisitor::Action Binder::visitFunctionDefinition_AtDeclarator( + const FunctionDefinitionSyntax *node) { + visit(node->declarator()); - typeSymAtTopAndPopIt(); + typeSymAtTopAndPopIt(); - reopenStashedScope(); - scopes_.top()->morphFrom_FunctionPrototype_to_Block(); + reopenStashedScope(); + scopes_.top()->morphFrom_FunctionPrototype_to_Block(); - auto body = node->body()->asCompoundStatement(); - for (auto stmtIt = body->statements(); stmtIt; stmtIt = stmtIt->next) - visit(stmtIt->value); + auto body = node->body()->asCompoundStatement(); + for (auto stmtIt = body->statements(); stmtIt; stmtIt = stmtIt->next) + visit(stmtIt->value); - closeScope(); + closeScope(); - return Binder::visitFunctionDefinition_DONE(node); + return Binder::visitFunctionDefinition_DONE(node); } -SyntaxVisitor::Action Binder::visitArrayOrFunctionDeclarator(const ArrayOrFunctionDeclaratorSyntax* node) -{ - for (auto specIt = node->attributes(); specIt; specIt = specIt->next) - visit(specIt->value); - - switch (node->suffix()->kind()) { - case SubscriptSuffix: - makeTySymAndPushIt(tySyms_.top()); - break; - - case ParameterSuffix: { - auto tySym = tySyms_.top(); - switch (tySym->typeKind()) { - case TypeKind::Function: - ConstraintsInDeclarators::FunctionReturningFunction( - node->innerDeclarator()->firstToken(), - &diagReporter_); - break; - - case TypeKind::Array: - ConstraintsInDeclarators::FunctionReturningArray( - node->innerDeclarator()->firstToken(), - &diagReporter_); - break; - - case TypeKind::Pointer: - case TypeKind::Named: - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } - makeTySymAndPushIt(tySyms_.top()); - pendingFunTySyms_.push(tySyms_.top()->asFunctionType()); - break; - } +SyntaxVisitor::Action Binder::visitArrayOrFunctionDeclarator( + const ArrayOrFunctionDeclaratorSyntax *node) { + for (auto specIt = node->attributes(); specIt; specIt = specIt->next) + visit(specIt->value); - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); + switch (node->suffix()->kind()) { + case SubscriptSuffix: + makeTySymAndPushIt(tySyms_.top()); + break; + + case ParameterSuffix: { + auto tySym = tySyms_.top(); + switch (tySym->typeKind()) { + case TypeKind::Function: + ConstraintsInDeclarators::FunctionReturningFunction( + node->innerDeclarator()->firstToken(), &diagReporter_); + break; + + case TypeKind::Array: + ConstraintsInDeclarators::FunctionReturningArray( + node->innerDeclarator()->firstToken(), &diagReporter_); + break; + + case TypeKind::Pointer: + case TypeKind::Named: + break; + + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); } + makeTySymAndPushIt(tySyms_.top()); + pendingFunTySyms_.push(tySyms_.top()->asFunctionType()); + break; + } - visit(node->innerDeclarator()); + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); + } - openScope(ScopeKind::FunctionPrototype); - visit(node->suffix()); - closeScopeAndStashIt(); + visit(node->innerDeclarator()); - if (node->suffix()->kind() == ParameterSuffix) - pendingFunTySyms_.pop(); + openScope(ScopeKind::FunctionPrototype); + visit(node->suffix()); + closeScopeAndStashIt(); - return Action::Skip; + if (node->suffix()->kind() == ParameterSuffix) + pendingFunTySyms_.pop(); + + return Action::Skip; } -SyntaxVisitor::Action Binder::visitSubscriptSuffix(const SubscriptSuffixSyntax* node) -{ - return Action::Skip; +SyntaxVisitor::Action +Binder::visitSubscriptSuffix(const SubscriptSuffixSyntax *node) { + return Action::Skip; } -SyntaxVisitor::Action Binder::visitParameterSuffix(const ParameterSuffixSyntax* node) -{ - for (auto declIt = node->parameters(); declIt; declIt = declIt->next) { - TySymContT tySyms; - std::swap(tySyms_, tySyms); - visit(declIt->value); - std::swap(tySyms_, tySyms); - } +SyntaxVisitor::Action +Binder::visitParameterSuffix(const ParameterSuffixSyntax *node) { + for (auto declIt = node->parameters(); declIt; declIt = declIt->next) { + TySymContT tySyms; + std::swap(tySyms_, tySyms); + visit(declIt->value); + std::swap(tySyms_, tySyms); + } - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitPointerDeclarator(const PointerDeclaratorSyntax* node) -{ - makeTySymAndPushIt(tySyms_.top()); +SyntaxVisitor::Action +Binder::visitPointerDeclarator(const PointerDeclaratorSyntax *node) { + makeTySymAndPushIt(tySyms_.top()); - for (auto specIt = node->qualifiersAndAttributes(); specIt; specIt = specIt->next) - visit(specIt->value); + for (auto specIt = node->qualifiersAndAttributes(); specIt; + specIt = specIt->next) + visit(specIt->value); - visit(node->innerDeclarator()); + visit(node->innerDeclarator()); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitParenthesizedDeclarator(const ParenthesizedDeclaratorSyntax* node) -{ - visit(node->innerDeclarator()); +SyntaxVisitor::Action Binder::visitParenthesizedDeclarator( + const ParenthesizedDeclaratorSyntax *node) { + visit(node->innerDeclarator()); - return Action::Skip; + return Action::Skip; } template -SyntaxVisitor::Action Binder::determineContextAndMakeSym(const DecltrT* node) -{ - switch (scopes_.top()->kind()) { - case ScopeKind::File: - case ScopeKind::Block: { - TypeSymbol* tySym = tySyms_.top(); - switch (tySym->typeKind()) { - case TypeKind::Function: - makeSymAndPushIt(node); - break; - - case TypeKind::Array: - case TypeKind::Pointer: - case TypeKind::Named: { - Symbol* sym = syms_.top(); - switch (sym->kind()) { - case SymbolKind::Type: - PSY_ASSERT(sym->asType()->asNamedType() - && sym->asType()->asNamedType()->name() - && sym->asType()->asNamedType()->name()->asTagSymbolName(), - return Action::Quit); - - switch (sym->asType()->asNamedType()->name()->asTagSymbolName()->tagChoice()) { - case TagSymbolName::TagChoice::Union: - case TagSymbolName::TagChoice::Struct: - makeSymAndPushIt(node); - break; - - case TagSymbolName::TagChoice::Enum: - makeSymAndPushIt(node); - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } - break; - - case SymbolKind::Value: - case SymbolKind::Function: - case SymbolKind::Library: - makeSymAndPushIt(node); - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } - break; - } - - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } - break; - } +SyntaxVisitor::Action Binder::determineContextAndMakeSym(const DecltrT *node) { + switch (scopes_.top()->kind()) { + case ScopeKind::File: + case ScopeKind::Block: { + TypeSymbol *tySym = tySyms_.top(); + switch (tySym->typeKind()) { + case TypeKind::Function: + makeSymAndPushIt(node); + break; + + case TypeKind::Array: + case TypeKind::Pointer: + case TypeKind::Named: { + Symbol *sym = syms_.top(); + switch (sym->kind()) { + case SymbolKind::Type: + PSY_ASSERT(sym->asType()->asNamedType() && + sym->asType()->asNamedType()->name() && + sym->asType()->asNamedType()->name()->asTagSymbolName(), + return Action::Quit); + + switch (sym->asType() + ->asNamedType() + ->name() + ->asTagSymbolName() + ->tagChoice()) { + case TagSymbolName::TagChoice::Union: + case TagSymbolName::TagChoice::Struct: + makeSymAndPushIt(node); + break; + + case TagSymbolName::TagChoice::Enum: + makeSymAndPushIt(node); + break; - case ScopeKind::Function: - break; - - case ScopeKind::FunctionPrototype: { - TypeSymbol* tySym = tySyms_.top(); - switch (tySym->typeKind()) { - case TypeKind::Array: { - /* - * 6.7.6.3-7 - * A declaration of a parameter as “array of type” - * shall be adjusted to “qualified pointer to type”... - */ - popTySym(); - makeTySymAndPushIt(tySyms_.top()); - auto ptrTySym = tySyms_.top()->asPointerType(); - ptrTySym->markAsArisingFromArrayDecay(); - break; - } - - case TypeKind::Function: { - /* - * 6.7.6.3-8 - * A declaration of a parameter as “function returning type” - * shall be adjusted to “pointer to function returning type”... - */ - makeTySymAndPushIt(tySyms_.top()); - auto ptrTySym = tySyms_.top()->asPointerType(); - ptrTySym->markAsArisingFromFunctionDecay(); - break; - } - - case TypeKind::Pointer: - case TypeKind::Named: - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } - makeSymAndPushIt(node); - break; + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); } + break; + + case SymbolKind::Value: + case SymbolKind::Function: + case SymbolKind::Library: + makeSymAndPushIt(node); + break; + + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); + } + break; + } - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); } + break; + } + + case ScopeKind::Function: + break; + + case ScopeKind::FunctionPrototype: { + TypeSymbol *tySym = tySyms_.top(); + switch (tySym->typeKind()) { + case TypeKind::Array: { + /* + * 6.7.6.3-7 + * A declaration of a parameter as “array of type” + * shall be adjusted to “qualified pointer to type”... + */ + popTySym(); + makeTySymAndPushIt(tySyms_.top()); + auto ptrTySym = tySyms_.top()->asPointerType(); + ptrTySym->markAsArisingFromArrayDecay(); + break; + } + + case TypeKind::Function: { + /* + * 6.7.6.3-8 + * A declaration of a parameter as “function returning type” + * shall be adjusted to “pointer to function returning type”... + */ + makeTySymAndPushIt(tySyms_.top()); + auto ptrTySym = tySyms_.top()->asPointerType(); + ptrTySym->markAsArisingFromFunctionDecay(); + break; + } + + case TypeKind::Pointer: + case TypeKind::Named: + break; + + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); + } + makeSymAndPushIt(node); + break; + } + + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); + } - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitIdentifierDeclarator(const IdentifierDeclaratorSyntax* node) -{ - determineContextAndMakeSym(node); - nameSymAtTop(node->identifierToken().valueText_c_str()); +SyntaxVisitor::Action +Binder::visitIdentifierDeclarator(const IdentifierDeclaratorSyntax *node) { + determineContextAndMakeSym(node); + nameSymAtTop(node->identifierToken().valueText_c_str()); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitAbstractDeclarator(const AbstractDeclaratorSyntax* node) -{ - determineContextAndMakeSym(node); - nameSymAtTop(nullptr); +SyntaxVisitor::Action +Binder::visitAbstractDeclarator(const AbstractDeclaratorSyntax *node) { + determineContextAndMakeSym(node); + nameSymAtTop(nullptr); - return Action::Skip; + return Action::Skip; } diff --git a/C/binder/Binder_Specifiers.cpp b/C/binder/Binder_Specifiers.cpp index 2a8ad4986..68d1ba61e 100644 --- a/C/binder/Binder_Specifiers.cpp +++ b/C/binder/Binder_Specifiers.cpp @@ -22,12 +22,12 @@ #include "SyntaxTree.h" +#include "binder/ConstraintsInTypeSpecifiers.h" #include "binder/Scope.h" #include "binder/SemanticsOfTypeQualifiers.h" -#include "binder/ConstraintsInTypeSpecifiers.h" #include "compilation/SemanticModel.h" -#include "symbols/Symbol_ALL.h" #include "symbols/SymbolName_ALL.h" +#include "symbols/Symbol_ALL.h" #include "syntax/SyntaxFacts.h" #include "syntax/SyntaxNodes.h" #include "syntax/SyntaxUtilities.h" @@ -40,271 +40,263 @@ using namespace psy; using namespace C; template -SyntaxVisitor::Action Binder::visitTypeDeclaration_AtInternalDeclarations_COMMON( - const TyDeclT* node, - Action (Binder::*visit_DONE)(const TyDeclT*)) -{ - for (auto declIt = node->typeSpecifier()->declarations(); declIt; declIt = declIt->next) - visit(declIt->value); +SyntaxVisitor::Action +Binder::visitTypeDeclaration_AtInternalDeclarations_COMMON( + const TyDeclT *node, Action (Binder::*visit_DONE)(const TyDeclT *)) { + for (auto declIt = node->typeSpecifier()->declarations(); declIt; + declIt = declIt->next) + visit(declIt->value); - popSym(); + popSym(); - return ((this)->*(visit_DONE))(node); + return ((this)->*(visit_DONE))(node); } SyntaxVisitor::Action Binder::visitStructOrUnionDeclaration_AtSpecifier( - const StructOrUnionDeclarationSyntax* node) -{ - const TagTypeSpecifierSyntax* tySpec = node->typeSpecifier(); - TagSymbolName::TagChoice tagChoice; - switch (tySpec->kind()) { - case StructTypeSpecifier: - tagChoice = TagSymbolName::TagChoice::Struct; - break; - - case UnionTypeSpecifier: - tagChoice = TagSymbolName::TagChoice::Union; - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } - - makeSymAndPushIt(node, - tagChoice, - tySpec->tagToken().valueText_c_str()); - - return visitTypeDeclaration_AtInternalDeclarations_COMMON( - node, - &Binder::visitStructOrUnionDeclaration_DONE); + const StructOrUnionDeclarationSyntax *node) { + const TagTypeSpecifierSyntax *tySpec = node->typeSpecifier(); + TagSymbolName::TagChoice tagChoice; + switch (tySpec->kind()) { + case StructTypeSpecifier: + tagChoice = TagSymbolName::TagChoice::Struct; + break; + + case UnionTypeSpecifier: + tagChoice = TagSymbolName::TagChoice::Union; + break; + + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); + } + + makeSymAndPushIt(node, tagChoice, + tySpec->tagToken().valueText_c_str()); + + return visitTypeDeclaration_AtInternalDeclarations_COMMON( + node, &Binder::visitStructOrUnionDeclaration_DONE); } -SyntaxVisitor::Action Binder::visitEnumDeclaration_AtSpecifier(const EnumDeclarationSyntax* node) -{ - makeSymAndPushIt(node, - TagSymbolName::TagChoice::Enum, - node->typeSpecifier()->tagToken().valueText_c_str()); +SyntaxVisitor::Action +Binder::visitEnumDeclaration_AtSpecifier(const EnumDeclarationSyntax *node) { + makeSymAndPushIt( + node, TagSymbolName::TagChoice::Enum, + node->typeSpecifier()->tagToken().valueText_c_str()); - return visitTypeDeclaration_AtInternalDeclarations_COMMON( - node, - &Binder::visitEnumDeclaration_DONE); + return visitTypeDeclaration_AtInternalDeclarations_COMMON( + node, &Binder::visitEnumDeclaration_DONE); } template SyntaxVisitor::Action Binder::visitDeclaration_AtSpecifiers_COMMON( - const DeclT* node, - Action (Binder::*visit_AtDeclarators)(const DeclT*)) -{ - for (auto specIt = node->specifiers(); specIt; specIt = specIt->next) - visitIfNotTypeQualifier(specIt->value); - - if (tySyms_.empty()) { - ConstraintsInTypeSpecifiers::TypeSpecifierMissingDefaultsToInt(node->lastToken(), &diagReporter_); - makeTySymAndPushIt(BuiltinTypeKind::Int); - } + const DeclT *node, Action (Binder::*visit_AtDeclarators)(const DeclT *)) { + for (auto specIt = node->specifiers(); specIt; specIt = specIt->next) + visitIfNotTypeQualifier(specIt->value); - for (auto specIt = node->specifiers(); specIt; specIt = specIt->next) - visitIfTypeQualifier(specIt->value); + if (tySyms_.empty()) { + ConstraintsInTypeSpecifiers::TypeSpecifierMissingDefaultsToInt( + node->lastToken(), &diagReporter_); + makeTySymAndPushIt(BuiltinTypeKind::Int); + } + + for (auto specIt = node->specifiers(); specIt; specIt = specIt->next) + visitIfTypeQualifier(specIt->value); - return ((this)->*(visit_AtDeclarators))(node); + return ((this)->*(visit_AtDeclarators))(node); } -SyntaxVisitor::Action Binder::visitVariableAndOrFunctionDeclaration_AtSpecifiers( - const VariableAndOrFunctionDeclarationSyntax* node) -{ - return visitDeclaration_AtSpecifiers_COMMON( - node, - &Binder::visitVariableAndOrFunctionDeclaration_AtDeclarators); +SyntaxVisitor::Action +Binder::visitVariableAndOrFunctionDeclaration_AtSpecifiers( + const VariableAndOrFunctionDeclarationSyntax *node) { + return visitDeclaration_AtSpecifiers_COMMON( + node, &Binder::visitVariableAndOrFunctionDeclaration_AtDeclarators); } -SyntaxVisitor::Action Binder::visitFunctionDefinition_AtSpecifiers(const FunctionDefinitionSyntax* node) -{ - return visitDeclaration_AtSpecifiers_COMMON( - node, - &Binder::visitFunctionDefinition_AtDeclarator); +SyntaxVisitor::Action Binder::visitFunctionDefinition_AtSpecifiers( + const FunctionDefinitionSyntax *node) { + return visitDeclaration_AtSpecifiers_COMMON( + node, &Binder::visitFunctionDefinition_AtDeclarator); } -SyntaxVisitor::Action Binder::visitFieldDeclaration_AtSpecifiers(const FieldDeclarationSyntax* node) -{ - return visitDeclaration_AtSpecifiers_COMMON( - node, - &Binder::visitFieldDeclaration_AtDeclarators); +SyntaxVisitor::Action +Binder::visitFieldDeclaration_AtSpecifiers(const FieldDeclarationSyntax *node) { + return visitDeclaration_AtSpecifiers_COMMON( + node, &Binder::visitFieldDeclaration_AtDeclarators); } -SyntaxVisitor::Action Binder::visitEnumeratorDeclaration_AtImplicitSpecifier(const EnumeratorDeclarationSyntax* node) -{ - makeTySymAndPushIt(BuiltinTypeKind::Int); +SyntaxVisitor::Action Binder::visitEnumeratorDeclaration_AtImplicitSpecifier( + const EnumeratorDeclarationSyntax *node) { + makeTySymAndPushIt(BuiltinTypeKind::Int); - return visitEnumeratorDeclaration_AtDeclarator(node); + return visitEnumeratorDeclaration_AtDeclarator(node); } -SyntaxVisitor::Action Binder::visitParameterDeclaration_AtSpecifiers(const ParameterDeclarationSyntax* node) -{ - return visitDeclaration_AtSpecifiers_COMMON( - node, - &Binder::visitParameterDeclaration_AtDeclarator); +SyntaxVisitor::Action Binder::visitParameterDeclaration_AtSpecifiers( + const ParameterDeclarationSyntax *node) { + return visitDeclaration_AtSpecifiers_COMMON( + node, &Binder::visitParameterDeclaration_AtDeclarator); } -SyntaxVisitor::Action Binder::visitIfNotTypeQualifier(const SpecifierSyntax* spec) -{ - if (spec->asTypeQualifier()) - return Action::Skip; +SyntaxVisitor::Action +Binder::visitIfNotTypeQualifier(const SpecifierSyntax *spec) { + if (spec->asTypeQualifier()) + return Action::Skip; - visit(spec); + visit(spec); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitIfTypeQualifier(const SpecifierSyntax* spec) -{ - if (!spec->asTypeQualifier()) - return Action::Skip; +SyntaxVisitor::Action +Binder::visitIfTypeQualifier(const SpecifierSyntax *spec) { + if (!spec->asTypeQualifier()) + return Action::Skip; - visit(spec); + visit(spec); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitBuiltinTypeSpecifier(const BuiltinTypeSpecifierSyntax* node) -{ - if (tySyms_.empty()) { - BuiltinTypeKind builtTyK; - switch (node->specifierToken().kind()) { - case Keyword_void: - builtTyK = BuiltinTypeKind::Void; - break; - case Keyword_char: - builtTyK = BuiltinTypeKind::Char; - break; - case Keyword_short: - builtTyK = BuiltinTypeKind::Short; - break; - case Keyword_int: - builtTyK = BuiltinTypeKind::Int; - break; - case Keyword_long: - builtTyK = BuiltinTypeKind::Long; - break; - case Keyword_float: - builtTyK = BuiltinTypeKind::Float; - break; - case Keyword_double: - builtTyK = BuiltinTypeKind::Double; - break; - case Keyword__Bool: - builtTyK = BuiltinTypeKind::Bool; - break; - case Keyword__Complex: - builtTyK = BuiltinTypeKind::DoubleComplex; - break; - case Keyword_signed: - builtTyK = BuiltinTypeKind::Int_S; - break; - case Keyword_unsigned: - builtTyK = BuiltinTypeKind::Int_U; - break; - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } - - makeTySymAndPushIt(builtTyK); - } - else { - NamedTypeSymbol* namedTySym = tySyms_.top()->asNamedType(); - ConstraintsInTypeSpecifiers::specify(node->specifierToken(), - namedTySym, - &diagReporter_); +SyntaxVisitor::Action +Binder::visitBuiltinTypeSpecifier(const BuiltinTypeSpecifierSyntax *node) { + if (tySyms_.empty()) { + BuiltinTypeKind builtTyK; + switch (node->specifierToken().kind()) { + case Keyword_void: + builtTyK = BuiltinTypeKind::Void; + break; + case Keyword_char: + builtTyK = BuiltinTypeKind::Char; + break; + case Keyword_short: + builtTyK = BuiltinTypeKind::Short; + break; + case Keyword_int: + builtTyK = BuiltinTypeKind::Int; + break; + case Keyword_long: + builtTyK = BuiltinTypeKind::Long; + break; + case Keyword_float: + builtTyK = BuiltinTypeKind::Float; + break; + case Keyword_double: + builtTyK = BuiltinTypeKind::Double; + break; + case Keyword__Bool: + builtTyK = BuiltinTypeKind::Bool; + break; + case Keyword__Complex: + builtTyK = BuiltinTypeKind::DoubleComplex; + break; + case Keyword_signed: + builtTyK = BuiltinTypeKind::Int_S; + break; + case Keyword_unsigned: + builtTyK = BuiltinTypeKind::Int_U; + break; + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); } - return Action::Skip; + makeTySymAndPushIt(builtTyK); + } else { + NamedTypeSymbol *namedTySym = tySyms_.top()->asNamedType(); + ConstraintsInTypeSpecifiers::specify(node->specifierToken(), namedTySym, + &diagReporter_); + } + + return Action::Skip; } -SyntaxVisitor::Action Binder::visitTagTypeSpecifier(const TagTypeSpecifierSyntax* node) -{ - if (!node->declarations()) { - TagSymbolName::TagChoice tagChoice; - switch (node->kind()) { - case StructTypeSpecifier: - tagChoice = TagSymbolName::TagChoice::Struct; - break; - - case UnionTypeSpecifier: - tagChoice = TagSymbolName::TagChoice::Union; - break; - - case EnumTypeSpecifier: - tagChoice = TagSymbolName::TagChoice::Enum; - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - return Action::Quit; - } - - makeTySymAndPushIt(tagChoice, node->tagToken().valueText_c_str()); +SyntaxVisitor::Action +Binder::visitTagTypeSpecifier(const TagTypeSpecifierSyntax *node) { + if (!node->declarations()) { + TagSymbolName::TagChoice tagChoice; + switch (node->kind()) { + case StructTypeSpecifier: + tagChoice = TagSymbolName::TagChoice::Struct; + break; + + case UnionTypeSpecifier: + tagChoice = TagSymbolName::TagChoice::Union; + break; + + case EnumTypeSpecifier: + tagChoice = TagSymbolName::TagChoice::Enum; + break; + + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); + return Action::Quit; } - for (auto attrIt = node->attributes(); attrIt; attrIt = attrIt->next) - visit(attrIt->value); + makeTySymAndPushIt(tagChoice, + node->tagToken().valueText_c_str()); + } - for (auto declIt = node->declarations(); declIt; declIt = declIt->next) { - TySymContT tySyms; - std::swap(tySyms_, tySyms); + for (auto attrIt = node->attributes(); attrIt; attrIt = attrIt->next) + visit(attrIt->value); - visit(declIt->value); + for (auto declIt = node->declarations(); declIt; declIt = declIt->next) { + TySymContT tySyms; + std::swap(tySyms_, tySyms); - std::swap(tySyms_, tySyms); - } + visit(declIt->value); - for (auto attrIt = node->attributes_PostCloseBrace(); attrIt; attrIt = attrIt->next) - visit(attrIt->value); + std::swap(tySyms_, tySyms); + } - return Action::Skip; + for (auto attrIt = node->attributes_PostCloseBrace(); attrIt; + attrIt = attrIt->next) + visit(attrIt->value); + + return Action::Skip; } -SyntaxVisitor::Action Binder::visitTypeDeclarationAsSpecifier(const TypeDeclarationAsSpecifierSyntax* node) -{ - visit(node->typeDeclaration()); +SyntaxVisitor::Action Binder::visitTypeDeclarationAsSpecifier( + const TypeDeclarationAsSpecifierSyntax *node) { + visit(node->typeDeclaration()); - const TagTypeSpecifierSyntax* tySpec = node->typeDeclaration()->typeSpecifier(); - TagSymbolName::TagChoice tagChoice; - switch (tySpec->kind()) { - case StructTypeSpecifier: - tagChoice = TagSymbolName::TagChoice::Struct; - break; + const TagTypeSpecifierSyntax *tySpec = + node->typeDeclaration()->typeSpecifier(); + TagSymbolName::TagChoice tagChoice; + switch (tySpec->kind()) { + case StructTypeSpecifier: + tagChoice = TagSymbolName::TagChoice::Struct; + break; - case UnionTypeSpecifier: - tagChoice = TagSymbolName::TagChoice::Union; - break; + case UnionTypeSpecifier: + tagChoice = TagSymbolName::TagChoice::Union; + break; - case EnumTypeSpecifier: - tagChoice = TagSymbolName::TagChoice::Enum; - break; + case EnumTypeSpecifier: + tagChoice = TagSymbolName::TagChoice::Enum; + break; - default: - PSY_ESCAPE_VIA_RETURN(Action::Quit); - } + default: + PSY_ESCAPE_VIA_RETURN(Action::Quit); + } - makeTySymAndPushIt(tagChoice, tySpec->tagToken().valueText_c_str()); + makeTySymAndPushIt(tagChoice, + tySpec->tagToken().valueText_c_str()); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitTypedefName(const TypedefNameSyntax* node) -{ - if (tySyms_.empty()) - makeTySymAndPushIt(node->identifierToken().valueText_c_str()); +SyntaxVisitor::Action Binder::visitTypedefName(const TypedefNameSyntax *node) { + if (tySyms_.empty()) + makeTySymAndPushIt( + node->identifierToken().valueText_c_str()); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Binder::visitTypeQualifier(const TypeQualifierSyntax* node) -{ - PSY_ASSERT(!tySyms_.empty(), return Action::Quit); +SyntaxVisitor::Action +Binder::visitTypeQualifier(const TypeQualifierSyntax *node) { + PSY_ASSERT(!tySyms_.empty(), return Action::Quit); - SemanticsOfTypeQualifiers::qualify(node->qualifierKeyword(), - tySyms_.top(), - &diagReporter_); + SemanticsOfTypeQualifiers::qualify(node->qualifierKeyword(), tySyms_.top(), + &diagReporter_); - return Action::Skip; + return Action::Skip; } diff --git a/C/binder/ConstraintsInDeclarations.cpp b/C/binder/ConstraintsInDeclarations.cpp index 15a0188af..9316a96fd 100644 --- a/C/binder/ConstraintsInDeclarations.cpp +++ b/C/binder/ConstraintsInDeclarations.cpp @@ -23,16 +23,15 @@ using namespace psy; using namespace C; -const std::string ConstraintsInDeclarations::ID_of_UselessDeclaration = "Binder-000"; +const std::string ConstraintsInDeclarations::ID_of_UselessDeclaration = + "Binder-000"; -void ConstraintsInDeclarations::UselessDeclaration(SyntaxToken tk, - Binder::DiagnosticsReporter* diagReporter) -{ - diagReporter->diagnose(DiagnosticDescriptor( - ID_of_UselessDeclaration, - "[[useless declaration]]", - "declaration does not declare anything", - DiagnosticSeverity::Error, - DiagnosticCategory::Binding), - tk); +void ConstraintsInDeclarations::UselessDeclaration( + SyntaxToken tk, Binder::DiagnosticsReporter *diagReporter) { + diagReporter->diagnose( + DiagnosticDescriptor(ID_of_UselessDeclaration, "[[useless declaration]]", + "declaration does not declare anything", + DiagnosticSeverity::Error, + DiagnosticCategory::Binding), + tk); } diff --git a/C/binder/ConstraintsInDeclarations.h b/C/binder/ConstraintsInDeclarations.h index f6a899f78..c3e6d9c3d 100644 --- a/C/binder/ConstraintsInDeclarations.h +++ b/C/binder/ConstraintsInDeclarations.h @@ -30,18 +30,18 @@ namespace psy { namespace C { -class PSY_C_NON_API ConstraintsInDeclarations -{ - friend class BinderTester; +class PSY_C_NON_API ConstraintsInDeclarations { + friend class BinderTester; public: - static void UselessDeclaration(SyntaxToken declTk, Binder::DiagnosticsReporter* diagReporter); + static void UselessDeclaration(SyntaxToken declTk, + Binder::DiagnosticsReporter *diagReporter); private: - static const std::string ID_of_UselessDeclaration; + static const std::string ID_of_UselessDeclaration; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/ConstraintsInDeclarators.cpp b/C/binder/ConstraintsInDeclarators.cpp index 62bdb8c35..2cea15c1e 100644 --- a/C/binder/ConstraintsInDeclarators.cpp +++ b/C/binder/ConstraintsInDeclarators.cpp @@ -23,39 +23,31 @@ using namespace psy; using namespace C; -const std::string ConstraintsInDeclarators::ID_FunctionReturningFunction = "Binder-200-6.7.6.3-1-A"; -const std::string ConstraintsInDeclarators::ID_FunctionReturningArray = "Binder-200-6.7.6.3-1-B"; +const std::string ConstraintsInDeclarators::ID_FunctionReturningFunction = + "Binder-200-6.7.6.3-1-A"; +const std::string ConstraintsInDeclarators::ID_FunctionReturningArray = + "Binder-200-6.7.6.3-1-B"; void ConstraintsInDeclarators::FunctionReturningFunction( - SyntaxToken decltorTk, - Binder::DiagnosticsReporter* diagReporter) -{ - auto s = "`" - + decltorTk.valueText() - + "' declared as function returning a function"; + SyntaxToken decltorTk, Binder::DiagnosticsReporter *diagReporter) { + auto s = "`" + decltorTk.valueText() + + "' declared as function returning a function"; - diagReporter->diagnose(DiagnosticDescriptor( - ID_FunctionReturningFunction, - "[[function returning function]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Binding), - decltorTk); + diagReporter->diagnose(DiagnosticDescriptor(ID_FunctionReturningFunction, + "[[function returning function]]", + s, DiagnosticSeverity::Error, + DiagnosticCategory::Binding), + decltorTk); } void ConstraintsInDeclarators::FunctionReturningArray( - SyntaxToken decltorTk, - Binder::DiagnosticsReporter* diagReporter) -{ - auto s = "`" - + decltorTk.valueText() - + "' declared as function returning an array"; + SyntaxToken decltorTk, Binder::DiagnosticsReporter *diagReporter) { + auto s = + "`" + decltorTk.valueText() + "' declared as function returning an array"; - diagReporter->diagnose(DiagnosticDescriptor( - ID_FunctionReturningArray, - "[[function returning array]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Binding), - decltorTk); + diagReporter->diagnose(DiagnosticDescriptor(ID_FunctionReturningArray, + "[[function returning array]]", s, + DiagnosticSeverity::Error, + DiagnosticCategory::Binding), + decltorTk); } diff --git a/C/binder/ConstraintsInDeclarators.h b/C/binder/ConstraintsInDeclarators.h index 8e34e2e9c..09c01fae2 100644 --- a/C/binder/ConstraintsInDeclarators.h +++ b/C/binder/ConstraintsInDeclarators.h @@ -32,20 +32,22 @@ namespace psy { namespace C { -class PSY_C_NON_API ConstraintsInDeclarators -{ - friend class BinderTester; +class PSY_C_NON_API ConstraintsInDeclarators { + friend class BinderTester; public: - static void FunctionReturningFunction(SyntaxToken decltorTk, Binder::DiagnosticsReporter* diagReporter); - static void FunctionReturningArray(SyntaxToken decltorTk, Binder::DiagnosticsReporter* diagReporter); + static void + FunctionReturningFunction(SyntaxToken decltorTk, + Binder::DiagnosticsReporter *diagReporter); + static void FunctionReturningArray(SyntaxToken decltorTk, + Binder::DiagnosticsReporter *diagReporter); private: - static const std::string ID_FunctionReturningFunction; - static const std::string ID_FunctionReturningArray; + static const std::string ID_FunctionReturningFunction; + static const std::string ID_FunctionReturningArray; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/ConstraintsInTypeSpecifiers.cpp b/C/binder/ConstraintsInTypeSpecifiers.cpp index 199ba6f41..4c7f457ce 100644 --- a/C/binder/ConstraintsInTypeSpecifiers.cpp +++ b/C/binder/ConstraintsInTypeSpecifiers.cpp @@ -29,154 +29,147 @@ using namespace psy; using namespace C; -const std::string ConstraintsInTypeSpecifiers::ID_TypeSpecifierMissingDefaultsToInt = +const std::string + ConstraintsInTypeSpecifiers::ID_TypeSpecifierMissingDefaultsToInt = "Binder-100-6.7.2-2-A"; -const std::string ConstraintsInTypeSpecifiers::ID_TwoOrMoreDataTypesInDeclarationSpecifiers = +const std::string + ConstraintsInTypeSpecifiers::ID_TwoOrMoreDataTypesInDeclarationSpecifiers = "Binder-100-6.7.2-2-B"; void ConstraintsInTypeSpecifiers::TypeSpecifierMissingDefaultsToInt( - SyntaxToken declTk, - Binder::DiagnosticsReporter* diagReporter) -{ - diagReporter->diagnose(DiagnosticDescriptor( - ID_TypeSpecifierMissingDefaultsToInt, - "[[type specifier missing]]", - "type specifier missing, defaults to `int'", - DiagnosticSeverity::Error, - DiagnosticCategory::Binding), - declTk); + SyntaxToken declTk, Binder::DiagnosticsReporter *diagReporter) { + diagReporter->diagnose( + DiagnosticDescriptor( + ID_TypeSpecifierMissingDefaultsToInt, "[[type specifier missing]]", + "type specifier missing, defaults to `int'", + DiagnosticSeverity::Error, DiagnosticCategory::Binding), + declTk); } void ConstraintsInTypeSpecifiers::TwoOrMoreDataTypesInDeclarationSpecifiers( - SyntaxToken builtTySpecTk, - Binder::DiagnosticsReporter* diagReporter) -{ - diagReporter->diagnose(DiagnosticDescriptor( - ID_TwoOrMoreDataTypesInDeclarationSpecifiers, - "[[two or more data types in declaration specifiers]]", - "two or more data types in declaration specifiers", - DiagnosticSeverity::Error, - DiagnosticCategory::Binding), - builtTySpecTk); + SyntaxToken builtTySpecTk, Binder::DiagnosticsReporter *diagReporter) { + diagReporter->diagnose( + DiagnosticDescriptor( + ID_TwoOrMoreDataTypesInDeclarationSpecifiers, + "[[two or more data types in declaration specifiers]]", + "two or more data types in declaration specifiers", + DiagnosticSeverity::Error, DiagnosticCategory::Binding), + builtTySpecTk); } -void ConstraintsInTypeSpecifiers::specify(SyntaxToken builtTySpecTk, - NamedTypeSymbol* namedTySym, - Binder::DiagnosticsReporter* diagReporter) -{ - auto builtTyKind = combine(builtTySpecTk, - namedTySym->builtinTypeKind(), - diagReporter); - if (builtTyKind == namedTySym->builtinTypeKind()) - return; - - namedTySym->patchBuiltinTypeKind(builtTyKind); +void ConstraintsInTypeSpecifiers::specify( + SyntaxToken builtTySpecTk, NamedTypeSymbol *namedTySym, + Binder::DiagnosticsReporter *diagReporter) { + auto builtTyKind = + combine(builtTySpecTk, namedTySym->builtinTypeKind(), diagReporter); + if (builtTyKind == namedTySym->builtinTypeKind()) + return; + + namedTySym->patchBuiltinTypeKind(builtTyKind); } -BuiltinTypeKind ConstraintsInTypeSpecifiers::combine(SyntaxToken builtTySpecTk, - BuiltinTypeKind builtTyKind, - Binder::DiagnosticsReporter* diagReporter) -{ - const auto tkK = builtTySpecTk.kind(); - switch (builtTyKind) { - case BuiltinTypeKind::UNSPECIFIED: - switch (tkK) { - case Keyword_void: - return BuiltinTypeKind::Void; - case Keyword_char: - return BuiltinTypeKind::Char; - case Keyword_short: - return BuiltinTypeKind::Short; - case Keyword_int: - return BuiltinTypeKind::Int; - case Keyword_long: - return BuiltinTypeKind::Long; - case Keyword_float: - return BuiltinTypeKind::Float; - case Keyword_double: - return BuiltinTypeKind::Double; - case Keyword__Bool: - return BuiltinTypeKind::Bool; - case Keyword__Complex: - return BuiltinTypeKind::DoubleComplex; - case Keyword_signed: - return BuiltinTypeKind::Int_S; - case Keyword_unsigned: - return BuiltinTypeKind::Int_U; - default: - PSY_ESCAPE_VIA_RETURN(builtTyKind); - } - - case BuiltinTypeKind::Void: - // report - return builtTyKind; - - case BuiltinTypeKind::Char: - switch (tkK) { - case Keyword_signed: - return BuiltinTypeKind::Char_S; - case Keyword_unsigned: - return BuiltinTypeKind::Char_U; - default: - // report - return builtTyKind; - } - case BuiltinTypeKind::Char_S: - case BuiltinTypeKind::Char_U: - // report - return builtTyKind; - - case BuiltinTypeKind::Short: - switch (tkK) { - case Keyword_signed: - return BuiltinTypeKind::Short_S; - case Keyword_unsigned: - return BuiltinTypeKind::Short_U; - default: - // report - return builtTyKind; - } - case BuiltinTypeKind::Short_S: - case BuiltinTypeKind::Short_U: - // report - return builtTyKind; - - case BuiltinTypeKind::Int: - switch (tkK) { - case Keyword_long: - return BuiltinTypeKind::Long; - case Keyword_signed: - return BuiltinTypeKind::Int_S; - case Keyword_unsigned: - return BuiltinTypeKind::Int_U; - default: - TwoOrMoreDataTypesInDeclarationSpecifiers(builtTySpecTk, diagReporter); - return builtTyKind; - } - case BuiltinTypeKind::Int_S: - case BuiltinTypeKind::Int_U: - // report - return builtTyKind; - - case BuiltinTypeKind::Long: - switch (tkK) { - case Keyword_int: - return builtTyKind; - case Keyword_signed: - return BuiltinTypeKind::Long_S; - case Keyword_unsigned: - return BuiltinTypeKind::Long_U; - default: - TwoOrMoreDataTypesInDeclarationSpecifiers(builtTySpecTk, diagReporter); - return builtTyKind; - } - case BuiltinTypeKind::Long_S: - case BuiltinTypeKind::Long_U: - // report - return builtTyKind; - - - default: - return BuiltinTypeKind::UNSPECIFIED; +BuiltinTypeKind ConstraintsInTypeSpecifiers::combine( + SyntaxToken builtTySpecTk, BuiltinTypeKind builtTyKind, + Binder::DiagnosticsReporter *diagReporter) { + const auto tkK = builtTySpecTk.kind(); + switch (builtTyKind) { + case BuiltinTypeKind::UNSPECIFIED: + switch (tkK) { + case Keyword_void: + return BuiltinTypeKind::Void; + case Keyword_char: + return BuiltinTypeKind::Char; + case Keyword_short: + return BuiltinTypeKind::Short; + case Keyword_int: + return BuiltinTypeKind::Int; + case Keyword_long: + return BuiltinTypeKind::Long; + case Keyword_float: + return BuiltinTypeKind::Float; + case Keyword_double: + return BuiltinTypeKind::Double; + case Keyword__Bool: + return BuiltinTypeKind::Bool; + case Keyword__Complex: + return BuiltinTypeKind::DoubleComplex; + case Keyword_signed: + return BuiltinTypeKind::Int_S; + case Keyword_unsigned: + return BuiltinTypeKind::Int_U; + default: + PSY_ESCAPE_VIA_RETURN(builtTyKind); + } + + case BuiltinTypeKind::Void: + // report + return builtTyKind; + + case BuiltinTypeKind::Char: + switch (tkK) { + case Keyword_signed: + return BuiltinTypeKind::Char_S; + case Keyword_unsigned: + return BuiltinTypeKind::Char_U; + default: + // report + return builtTyKind; + } + case BuiltinTypeKind::Char_S: + case BuiltinTypeKind::Char_U: + // report + return builtTyKind; + + case BuiltinTypeKind::Short: + switch (tkK) { + case Keyword_signed: + return BuiltinTypeKind::Short_S; + case Keyword_unsigned: + return BuiltinTypeKind::Short_U; + default: + // report + return builtTyKind; + } + case BuiltinTypeKind::Short_S: + case BuiltinTypeKind::Short_U: + // report + return builtTyKind; + + case BuiltinTypeKind::Int: + switch (tkK) { + case Keyword_long: + return BuiltinTypeKind::Long; + case Keyword_signed: + return BuiltinTypeKind::Int_S; + case Keyword_unsigned: + return BuiltinTypeKind::Int_U; + default: + TwoOrMoreDataTypesInDeclarationSpecifiers(builtTySpecTk, diagReporter); + return builtTyKind; + } + case BuiltinTypeKind::Int_S: + case BuiltinTypeKind::Int_U: + // report + return builtTyKind; + + case BuiltinTypeKind::Long: + switch (tkK) { + case Keyword_int: + return builtTyKind; + case Keyword_signed: + return BuiltinTypeKind::Long_S; + case Keyword_unsigned: + return BuiltinTypeKind::Long_U; + default: + TwoOrMoreDataTypesInDeclarationSpecifiers(builtTySpecTk, diagReporter); + return builtTyKind; } + case BuiltinTypeKind::Long_S: + case BuiltinTypeKind::Long_U: + // report + return builtTyKind; + + default: + return BuiltinTypeKind::UNSPECIFIED; + } } diff --git a/C/binder/ConstraintsInTypeSpecifiers.h b/C/binder/ConstraintsInTypeSpecifiers.h index 696b759f8..0bda74dd8 100644 --- a/C/binder/ConstraintsInTypeSpecifiers.h +++ b/C/binder/ConstraintsInTypeSpecifiers.h @@ -35,31 +35,29 @@ namespace C { class Binder; -class PSY_C_NON_API ConstraintsInTypeSpecifiers -{ - friend class BinderTester; +class PSY_C_NON_API ConstraintsInTypeSpecifiers { + friend class BinderTester; public: - static void TypeSpecifierMissingDefaultsToInt(SyntaxToken declTk, - Binder::DiagnosticsReporter* diagReporter); - static void TwoOrMoreDataTypesInDeclarationSpecifiers(SyntaxToken builtTySpecTk, - Binder::DiagnosticsReporter* diagReporter); + static void + TypeSpecifierMissingDefaultsToInt(SyntaxToken declTk, + Binder::DiagnosticsReporter *diagReporter); + static void TwoOrMoreDataTypesInDeclarationSpecifiers( + SyntaxToken builtTySpecTk, Binder::DiagnosticsReporter *diagReporter); - static void specify(SyntaxToken builtTySpecTk, - NamedTypeSymbol* namedTySym, - Binder::DiagnosticsReporter* diagReporter); + static void specify(SyntaxToken builtTySpecTk, NamedTypeSymbol *namedTySym, + Binder::DiagnosticsReporter *diagReporter); private: - static const std::string ID_TypeSpecifierMissingDefaultsToInt; - static const std::string ID_TwoOrMoreDataTypesInDeclarationSpecifiers; - - static BuiltinTypeKind combine(SyntaxToken builtTySpecTk, - BuiltinTypeKind builtTyK, - Binder::DiagnosticsReporter* diagReporter); + static const std::string ID_TypeSpecifierMissingDefaultsToInt; + static const std::string ID_TwoOrMoreDataTypesInDeclarationSpecifiers; + static BuiltinTypeKind combine(SyntaxToken builtTySpecTk, + BuiltinTypeKind builtTyK, + Binder::DiagnosticsReporter *diagReporter); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/DiagnosticsReporter_Binder.cpp b/C/binder/DiagnosticsReporter_Binder.cpp index 4257b849c..85c18eb1a 100644 --- a/C/binder/DiagnosticsReporter_Binder.cpp +++ b/C/binder/DiagnosticsReporter_Binder.cpp @@ -25,7 +25,7 @@ using namespace psy; using namespace C; -void Binder::DiagnosticsReporter::diagnose(DiagnosticDescriptor&& desc, SyntaxToken tk) -{ - binder_->tree_->newDiagnostic(desc, tk); +void Binder::DiagnosticsReporter::diagnose(DiagnosticDescriptor &&desc, + SyntaxToken tk) { + binder_->tree_->newDiagnostic(desc, tk); }; diff --git a/C/binder/NameSpace.h b/C/binder/NameSpace.h index 0f3df6486..51c936a39 100644 --- a/C/binder/NameSpace.h +++ b/C/binder/NameSpace.h @@ -36,24 +36,20 @@ namespace C { * * \remark 6.2.3 */ -class PSY_C_API NameSpace -{ +class PSY_C_API NameSpace { public: - /** - * The NameSpaceKind of \c this NameSpace. - */ - NameSpaceKind kind() const { return nsK_; } + /** + * The NameSpaceKind of \c this NameSpace. + */ + NameSpaceKind kind() const { return nsK_; } -PSY_INTERNAL_AND_RESTRICTED: - NameSpace(NameSpaceKind nsK) - : nsK_(nsK) - {} + PSY_INTERNAL_AND_RESTRICTED : NameSpace(NameSpaceKind nsK) : nsK_(nsK) {} private: - NameSpaceKind nsK_; + NameSpaceKind nsK_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/NameSpaceKind.h b/C/binder/NameSpaceKind.h index 31e029135..33c7b080d 100644 --- a/C/binder/NameSpaceKind.h +++ b/C/binder/NameSpaceKind.h @@ -39,34 +39,32 @@ namespace C { * \remark 6.2.3-1 * \remark Footnote 32 */ -enum class PSY_C_API NameSpaceKind : std::uint8_t -{ - UNSPECIFIED = 0, +enum class PSY_C_API NameSpaceKind : std::uint8_t { + UNSPECIFIED = 0, - Labels, - Tags, - Members, - Ordinary, + Labels, + Tags, + Members, + Ordinary, }; -inline std::string PSY_C_API to_string(NameSpaceKind nsK) -{ - switch (nsK) { - case NameSpaceKind::Labels: - return "Labels"; - case NameSpaceKind::Tags: - return "Tags"; - case NameSpaceKind::Members: - return "Members"; - case NameSpaceKind::Ordinary: - return "Ordinary"; +inline std::string PSY_C_API to_string(NameSpaceKind nsK) { + switch (nsK) { + case NameSpaceKind::Labels: + return "Labels"; + case NameSpaceKind::Tags: + return "Tags"; + case NameSpaceKind::Members: + return "Members"; + case NameSpaceKind::Ordinary: + return "Ordinary"; - default: - PSY_ESCAPE_VIA_RETURN(""); - } + default: + PSY_ESCAPE_VIA_RETURN(""); + } } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/NameSpaces.h b/C/binder/NameSpaces.h index 92a9fe5bb..d0c439ad6 100644 --- a/C/binder/NameSpaces.h +++ b/C/binder/NameSpaces.h @@ -27,13 +27,12 @@ namespace psy { namespace C { -class PSY_C_API NameSpaces -{ +class PSY_C_API NameSpaces { private: - NameSpaces(); + NameSpaces(); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/Scope.cpp b/C/binder/Scope.cpp index 7a463f74d..8bb85c5f9 100644 --- a/C/binder/Scope.cpp +++ b/C/binder/Scope.cpp @@ -25,26 +25,18 @@ using namespace psy; using namespace C; -Scope::Scope(ScopeKind kind) - : kind_(kind) -{} +Scope::Scope(ScopeKind kind) : kind_(kind) {} -ScopeKind Scope::kind() const -{ - return kind_; -} +ScopeKind Scope::kind() const { return kind_; } -void Scope::enclose(std::unique_ptr scope) -{ - enclosedScopes_.push_back(std::move(scope)); +void Scope::enclose(std::unique_ptr scope) { + enclosedScopes_.push_back(std::move(scope)); } -void Scope::morphFrom_FunctionPrototype_to_Block() -{ - PSY_ASSERT(kind_ == ScopeKind::FunctionPrototype, return); +void Scope::morphFrom_FunctionPrototype_to_Block() { + PSY_ASSERT(kind_ == ScopeKind::FunctionPrototype, return); - kind_ = ScopeKind::Block; + kind_ = ScopeKind::Block; } -Scope::~Scope() -{} +Scope::~Scope() {} diff --git a/C/binder/Scope.h b/C/binder/Scope.h index 29625897d..61493109d 100644 --- a/C/binder/Scope.h +++ b/C/binder/Scope.h @@ -28,8 +28,8 @@ #include "../common/infra/InternalAccess.h" -#include #include +#include #include #include @@ -41,30 +41,28 @@ namespace C { * * \remark 6.2.1 */ -class PSY_C_API Scope -{ +class PSY_C_API Scope { public: - virtual ~Scope(); + virtual ~Scope(); - /** - * The Kind of \c this Scope. - */ - ScopeKind kind() const; + /** + * The Kind of \c this Scope. + */ + ScopeKind kind() const; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); - Scope(ScopeKind kind); + Scope(ScopeKind kind); - void enclose(std::unique_ptr scope); - void morphFrom_FunctionPrototype_to_Block(); + void enclose(std::unique_ptr scope); + void morphFrom_FunctionPrototype_to_Block(); private: - ScopeKind kind_; - std::vector> enclosedScopes_; + ScopeKind kind_; + std::vector> enclosedScopes_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/ScopeKind.h b/C/binder/ScopeKind.h index b7816abb3..b44512e58 100644 --- a/C/binder/ScopeKind.h +++ b/C/binder/ScopeKind.h @@ -37,33 +37,31 @@ namespace C { * * \remark 6.2.1-4 */ -enum class PSY_C_API ScopeKind : uint8_t -{ - UNSPECIFIED = 0, +enum class PSY_C_API ScopeKind : uint8_t { + UNSPECIFIED = 0, - File, - Function, - FunctionPrototype, - Block + File, + Function, + FunctionPrototype, + Block }; -inline std::string PSY_C_API to_string(ScopeKind scopeK) -{ - switch (scopeK) { - case ScopeKind::File: - return "File"; - case ScopeKind::Function: - return "Function"; - case ScopeKind::FunctionPrototype: - return "FunctionPrototype"; - case ScopeKind::Block: - return "Block"; - default: - PSY_ESCAPE_VIA_RETURN(""); - } +inline std::string PSY_C_API to_string(ScopeKind scopeK) { + switch (scopeK) { + case ScopeKind::File: + return "File"; + case ScopeKind::Function: + return "Function"; + case ScopeKind::FunctionPrototype: + return "FunctionPrototype"; + case ScopeKind::Block: + return "Block"; + default: + PSY_ESCAPE_VIA_RETURN(""); + } } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/SemanticsOfTypeQualifiers.cpp b/C/binder/SemanticsOfTypeQualifiers.cpp index 8ed04bc4c..c2f075462 100644 --- a/C/binder/SemanticsOfTypeQualifiers.cpp +++ b/C/binder/SemanticsOfTypeQualifiers.cpp @@ -29,17 +29,16 @@ using namespace psy; using namespace C; -void SemanticsOfTypeQualifiers::qualify(SyntaxToken tyQualTk, - TypeSymbol* tySym, - Binder::DiagnosticsReporter* diagReporter) -{ - const auto tkK = tyQualTk.kind(); - switch (tkK) { - case Keyword_const: - tySym->qualifyWithConst(); - break; +void SemanticsOfTypeQualifiers::qualify( + SyntaxToken tyQualTk, TypeSymbol *tySym, + Binder::DiagnosticsReporter *diagReporter) { + const auto tkK = tyQualTk.kind(); + switch (tkK) { + case Keyword_const: + tySym->qualifyWithConst(); + break; - default: - PSY_ESCAPE_VIA_BREAK; - } + default: + PSY_ESCAPE_VIA_BREAK; + } } diff --git a/C/binder/SemanticsOfTypeQualifiers.h b/C/binder/SemanticsOfTypeQualifiers.h index 4c2a665a8..5d53c70b7 100644 --- a/C/binder/SemanticsOfTypeQualifiers.h +++ b/C/binder/SemanticsOfTypeQualifiers.h @@ -35,15 +35,13 @@ namespace C { class Binder; -class PSY_C_NON_API SemanticsOfTypeQualifiers -{ +class PSY_C_NON_API SemanticsOfTypeQualifiers { public: - static void qualify(SyntaxToken tyQualTk, - TypeSymbol* tySym, - Binder::DiagnosticsReporter* diagReporter); + static void qualify(SyntaxToken tyQualTk, TypeSymbol *tySym, + Binder::DiagnosticsReporter *diagReporter); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/binder/TypeChecker.h b/C/binder/TypeChecker.h index 88069f0c3..2b4e5bc81 100644 --- a/C/binder/TypeChecker.h +++ b/C/binder/TypeChecker.h @@ -28,11 +28,9 @@ namespace psy { namespace C { -class TypeChecker final : protected SyntaxVisitor -{ -}; +class TypeChecker final : protected SyntaxVisitor {}; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/compilation/Assembly.cpp b/C/compilation/Assembly.cpp index 69910181e..e63384156 100644 --- a/C/compilation/Assembly.cpp +++ b/C/compilation/Assembly.cpp @@ -25,19 +25,15 @@ using namespace psy; using namespace C; -std::vector Assembly::symbols() const -{ - std::vector syms; - std::transform(symDEFs_.begin(), - symDEFs_.end(), - std::back_inserter(syms), - [] (auto& sym) { return sym.get();}); - return syms; +std::vector Assembly::symbols() const { + std::vector syms; + std::transform(symDEFs_.begin(), symDEFs_.end(), std::back_inserter(syms), + [](auto &sym) { return sym.get(); }); + return syms; } -Symbol* Assembly::findSymDEF(std::function&)> pred) const -{ - auto it = std::find_if(symDEFs_.begin(), symDEFs_.end(), pred); - return it == symDEFs_.end() ? nullptr - : it->get(); +Symbol *Assembly::findSymDEF( + std::function &)> pred) const { + auto it = std::find_if(symDEFs_.begin(), symDEFs_.end(), pred); + return it == symDEFs_.end() ? nullptr : it->get(); } diff --git a/C/compilation/Assembly.h b/C/compilation/Assembly.h index e4b9931b3..b46c869ab 100644 --- a/C/compilation/Assembly.h +++ b/C/compilation/Assembly.h @@ -40,27 +40,26 @@ namespace C { * * An assembly is the result produced by a Compilation. */ -class PSY_C_API Assembly -{ - friend class InternalsTestSuite; +class PSY_C_API Assembly { + friend class InternalsTestSuite; public: - /** - * The Symbols defined in \c this Assembly. - */ - std::vector symbols() const; + /** + * The Symbols defined in \c this Assembly. + */ + std::vector symbols() const; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SemanticModel); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SemanticModel); - Symbol* findSymDEF(std::function&)> pred) const; + Symbol * + findSymDEF(std::function &)> pred) const; private: - std::unordered_set> symDEFs_; - std::vector> symUSEs_; + std::unordered_set> symDEFs_; + std::vector> symUSEs_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/compilation/Compilation.cpp b/C/compilation/Compilation.cpp index dd6064e25..2c40af3ef 100644 --- a/C/compilation/Compilation.cpp +++ b/C/compilation/Compilation.cpp @@ -31,88 +31,71 @@ using namespace psy; using namespace C; -struct Compilation::CompilationImpl -{ - CompilationImpl(Compilation* q) - : Q_(q) - , assembly_(new Assembly) - {} - - Compilation* Q_; - std::string id_; - std::unique_ptr assembly_; - std::unordered_map isDirty_; - std::unordered_map> semaModels_; +struct Compilation::CompilationImpl { + CompilationImpl(Compilation *q) : Q_(q), assembly_(new Assembly) {} + + Compilation *Q_; + std::string id_; + std::unique_ptr assembly_; + std::unordered_map isDirty_; + std::unordered_map> + semaModels_; }; -Compilation::Compilation() - : P(new CompilationImpl(this)) -{} +Compilation::Compilation() : P(new CompilationImpl(this)) {} -Compilation::~Compilation() -{ - for (const auto& kv : P->semaModels_) { - auto tree = kv.first; +Compilation::~Compilation() { + for (const auto &kv : P->semaModels_) { + auto tree = kv.first; - auto it = P->semaModels_.find(tree); - if (it == P->semaModels_.end()) - continue; - tree->detachCompilation(this); - } + auto it = P->semaModels_.find(tree); + if (it == P->semaModels_.end()) + continue; + tree->detachCompilation(this); + } } -std::unique_ptr Compilation::create(const std::string& id) -{ - std::unique_ptr compilation(new Compilation); - compilation->P->id_ = id; - return compilation; +std::unique_ptr Compilation::create(const std::string &id) { + std::unique_ptr compilation(new Compilation); + compilation->P->id_ = id; + return compilation; } -const Assembly* Compilation::assembly() const -{ - return P->assembly_.get(); -} +const Assembly *Compilation::assembly() const { return P->assembly_.get(); } -Assembly* Compilation::assembly() -{ - return P->assembly_.get(); -} +Assembly *Compilation::assembly() { return P->assembly_.get(); } -void Compilation::addSyntaxTree(const SyntaxTree* tree) -{ - auto it = P->semaModels_.find(tree); - if (it != P->semaModels_.end()) - return; +void Compilation::addSyntaxTree(const SyntaxTree *tree) { + auto it = P->semaModels_.find(tree); + if (it != P->semaModels_.end()) + return; - P->semaModels_.insert(it, std::make_pair(tree, nullptr)); - P->isDirty_[tree] = true; - tree->attachCompilation(this); + P->semaModels_.insert(it, std::make_pair(tree, nullptr)); + P->isDirty_[tree] = true; + tree->attachCompilation(this); } -void Compilation::addSyntaxTrees(std::vector trees) -{ - for (auto tree : trees) - addSyntaxTree(tree); +void Compilation::addSyntaxTrees(std::vector trees) { + for (auto tree : trees) + addSyntaxTree(tree); } -std::vector Compilation::syntaxTrees() const -{ - std::vector trees(P->semaModels_.size()); - std::transform(P->semaModels_.begin(), - P->semaModels_.end(), - std::back_inserter(trees), - [] (const auto& kv) { return kv.first; }); - return trees; +std::vector Compilation::syntaxTrees() const { + std::vector trees(P->semaModels_.size()); + std::transform(P->semaModels_.begin(), P->semaModels_.end(), + std::back_inserter(trees), + [](const auto &kv) { return kv.first; }); + return trees; } -const SemanticModel* Compilation::semanticModel(const SyntaxTree* tree) const -{ - if (P->isDirty_[tree]) { - // TODO: Remove from the assembly the symbols associated - // with the given syntax tree. - P->semaModels_[tree].reset(new SemanticModel(tree, const_cast(this))); - P->isDirty_[tree] = false; - } +const SemanticModel *Compilation::semanticModel(const SyntaxTree *tree) const { + if (P->isDirty_[tree]) { + // TODO: Remove from the assembly the symbols associated + // with the given syntax tree. + P->semaModels_[tree].reset( + new SemanticModel(tree, const_cast(this))); + P->isDirty_[tree] = false; + } - return P->semaModels_[tree].get(); + return P->semaModels_[tree].get(); } diff --git a/C/compilation/Compilation.h b/C/compilation/Compilation.h index a5849690c..83f6c2fbd 100644 --- a/C/compilation/Compilation.h +++ b/C/compilation/Compilation.h @@ -44,59 +44,57 @@ class SemanticModel; * This API is inspired by that of \c Microsoft.CodeAnalysis.Compilation * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API Compilation -{ - friend class InternalsTestSuite; +class PSY_C_API Compilation { + friend class InternalsTestSuite; public: - ~Compilation(); + ~Compilation(); - /** - * Create an empty compilation identified by \p id with SyntaxTree \p tree. - */ - static std::unique_ptr create(const std::string& id); + /** + * Create an empty compilation identified by \p id with SyntaxTree \p tree. + */ + static std::unique_ptr create(const std::string &id); - /** - * The Assembly produced by \c this Compilation. - */ - const Assembly* assembly() const; + /** + * The Assembly produced by \c this Compilation. + */ + const Assembly *assembly() const; - /** - * Add a SyntaxTree to \c this Compilation. - */ - void addSyntaxTree(const SyntaxTree* tree); + /** + * Add a SyntaxTree to \c this Compilation. + */ + void addSyntaxTree(const SyntaxTree *tree); - /** - * Add SyntaxTrees to \c this Compilation. - */ - void addSyntaxTrees(std::vector trees); + /** + * Add SyntaxTrees to \c this Compilation. + */ + void addSyntaxTrees(std::vector trees); - /** - * The SyntaxTrees in \c this Compilation. - */ - std::vector syntaxTrees() const; + /** + * The SyntaxTrees in \c this Compilation. + */ + std::vector syntaxTrees() const; - /** - * The SemanticModel for the SyntaxTree \p tree in \c this Compilation. - */ - const SemanticModel* semanticModel(const SyntaxTree* tree) const; + /** + * The SemanticModel for the SyntaxTree \p tree in \c this Compilation. + */ + const SemanticModel *semanticModel(const SyntaxTree *tree) const; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SemanticModel); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SemanticModel); - Assembly* assembly(); + Assembly *assembly(); private: - Compilation(); + Compilation(); - // Unavailable - Compilation(const Compilation&) = delete; - Compilation& operator=(const Compilation&) = delete; + // Unavailable + Compilation(const Compilation &) = delete; + Compilation &operator=(const Compilation &) = delete; - DECL_PIMPL(Compilation); + DECL_PIMPL(Compilation); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/compilation/SemanticModel.cpp b/C/compilation/SemanticModel.cpp index e02215287..e1d6a4f0e 100644 --- a/C/compilation/SemanticModel.cpp +++ b/C/compilation/SemanticModel.cpp @@ -24,9 +24,9 @@ #include "Compilation.h" #include "binder/Binder.h" +#include "symbols/Symbol_ALL.h" #include "syntax/SyntaxNodes.h" #include "syntax/SyntaxUtilities.h" -#include "symbols/Symbol_ALL.h" #include "../common/infra/Assertions.h" #include "../common/infra/Escape.h" @@ -38,202 +38,192 @@ using namespace psy; using namespace C; -struct SemanticModel::SemanticModelImpl -{ - SemanticModelImpl(const SyntaxTree* tree, Compilation* compilation) - : expectValidSyms_(true) - , tree_(tree) - , compilation_(compilation) - {} - - bool expectValidSyms_; - const SyntaxTree* tree_; - Compilation* compilation_; - std::unordered_map declSyms_; +struct SemanticModel::SemanticModelImpl { + SemanticModelImpl(const SyntaxTree *tree, Compilation *compilation) + : expectValidSyms_(true), tree_(tree), compilation_(compilation) {} + + bool expectValidSyms_; + const SyntaxTree *tree_; + Compilation *compilation_; + std::unordered_map declSyms_; }; -SemanticModel::SemanticModel(const SyntaxTree* tree, Compilation* compilation) - : P(new SemanticModelImpl(tree, compilation)) -{ - Binder binder(this, tree); - binder.bind(); +SemanticModel::SemanticModel(const SyntaxTree *tree, Compilation *compilation) + : P(new SemanticModelImpl(tree, compilation)) { + Binder binder(this, tree); + binder.bind(); } -SemanticModel::~SemanticModel() -{} +SemanticModel::~SemanticModel() {} -const SyntaxTree* SemanticModel::syntaxTree() const -{ - return P->tree_; -} +const SyntaxTree *SemanticModel::syntaxTree() const { return P->tree_; } -const Compilation* SemanticModel::compilation() const -{ - return P->compilation_; +const Compilation *SemanticModel::compilation() const { + return P->compilation_; } template -const SymCastT* SemanticModel::castSym(const SymOriT* symOri, - const SymCastT* (SymOriT::*cast)() const) const -{ - auto symCast = ((symOri)->*(cast))(); - if (!symCast) { - PSY_ASSERT_NO_STMT(!P->expectValidSyms_); - return nullptr; - } - - return symCast; +const SymCastT *SemanticModel::castSym(const SymOriT *symOri, + const SymCastT *(SymOriT::*cast)() + const) const { + auto symCast = ((symOri)->*(cast))(); + if (!symCast) { + PSY_ASSERT_NO_STMT(!P->expectValidSyms_); + return nullptr; + } + + return symCast; } -const LibrarySymbol* SemanticModel::declaredSymbol(const TranslationUnitSyntax* node) const -{ - auto it = P->declSyms_.find(node); - if (it == P->declSyms_.end()) { - PSY_ASSERT_NO_STMT(!P->expectValidSyms_); - return nullptr; - } +const LibrarySymbol * +SemanticModel::declaredSymbol(const TranslationUnitSyntax *node) const { + auto it = P->declSyms_.find(node); + if (it == P->declSyms_.end()) { + PSY_ASSERT_NO_STMT(!P->expectValidSyms_); + return nullptr; + } - auto libSym = castSym(it->second, &Symbol::asLibrary); - if (!libSym) - return nullptr; + auto libSym = castSym(it->second, &Symbol::asLibrary); + if (!libSym) + return nullptr; - return libSym; + return libSym; } -const FunctionSymbol* SemanticModel::declaredSymbol(const FunctionDefinitionSyntax* node) const -{ - auto sym = declaredSymbol(node->declarator()); - if (!sym) - return nullptr; +const FunctionSymbol * +SemanticModel::declaredSymbol(const FunctionDefinitionSyntax *node) const { + auto sym = declaredSymbol(node->declarator()); + if (!sym) + return nullptr; - auto funcSym = castSym(sym, &Symbol::asFunction); - if (!funcSym) - return nullptr; + auto funcSym = castSym(sym, &Symbol::asFunction); + if (!funcSym) + return nullptr; - return funcSym; + return funcSym; } -const ParameterSymbol* SemanticModel::declaredSymbol(const ParameterDeclarationSyntax* node) const -{ - auto sym = declaredSymbol(node->declarator()); - if (!sym) - return nullptr; +const ParameterSymbol * +SemanticModel::declaredSymbol(const ParameterDeclarationSyntax *node) const { + auto sym = declaredSymbol(node->declarator()); + if (!sym) + return nullptr; - auto valSym = castSym(sym, &Symbol::asValue); - if (!valSym) - return nullptr; + auto valSym = castSym(sym, &Symbol::asValue); + if (!valSym) + return nullptr; - auto parmSym = castSym(valSym, &ValueSymbol::asParameter); - if (!parmSym) - return nullptr; + auto parmSym = castSym(valSym, &ValueSymbol::asParameter); + if (!parmSym) + return nullptr; - return parmSym; + return parmSym; } -const NamedTypeSymbol* SemanticModel::declaredSymbol(const TypeDeclarationSyntax* node) const -{ - auto it = P->declSyms_.find(node); - if (it == P->declSyms_.end()) { - PSY_ASSERT_NO_STMT(!P->expectValidSyms_); - return nullptr; - } +const NamedTypeSymbol * +SemanticModel::declaredSymbol(const TypeDeclarationSyntax *node) const { + auto it = P->declSyms_.find(node); + if (it == P->declSyms_.end()) { + PSY_ASSERT_NO_STMT(!P->expectValidSyms_); + return nullptr; + } - auto tySym = castSym(it->second, &Symbol::asType); - if (!tySym) - return nullptr; + auto tySym = castSym(it->second, &Symbol::asType); + if (!tySym) + return nullptr; - auto namedTySym = castSym(tySym, &TypeSymbol::asNamedType); - if (!namedTySym) - return nullptr; + auto namedTySym = castSym(tySym, &TypeSymbol::asNamedType); + if (!namedTySym) + return nullptr; - return namedTySym; + return namedTySym; } -const EnumeratorSymbol* SemanticModel::declaredSymbol(const EnumeratorDeclarationSyntax* node) const -{ - auto it = P->declSyms_.find(node); - if (it == P->declSyms_.end()) { - PSY_ASSERT_NO_STMT(!P->expectValidSyms_); - return nullptr; - } +const EnumeratorSymbol * +SemanticModel::declaredSymbol(const EnumeratorDeclarationSyntax *node) const { + auto it = P->declSyms_.find(node); + if (it == P->declSyms_.end()) { + PSY_ASSERT_NO_STMT(!P->expectValidSyms_); + return nullptr; + } - auto valSym = castSym(it->second, &Symbol::asValue); - if (!valSym) - return nullptr; + auto valSym = castSym(it->second, &Symbol::asValue); + if (!valSym) + return nullptr; - auto enumtrSym = castSym(valSym, &ValueSymbol::asEnumerator); - if (!enumtrSym) - return nullptr; + auto enumtrSym = castSym(valSym, &ValueSymbol::asEnumerator); + if (!enumtrSym) + return nullptr; - return enumtrSym; + return enumtrSym; } -std::vector SemanticModel::declaredSymbols(const FieldDeclarationSyntax* node) const -{ - std::vector fldSyms; - for (auto decltorIt = node->declarators(); decltorIt; decltorIt = decltorIt->next) { - auto sym = declaredSymbol(decltorIt->value); - if (!sym) - continue; +std::vector +SemanticModel::declaredSymbols(const FieldDeclarationSyntax *node) const { + std::vector fldSyms; + for (auto decltorIt = node->declarators(); decltorIt; + decltorIt = decltorIt->next) { + auto sym = declaredSymbol(decltorIt->value); + if (!sym) + continue; - auto valSym = castSym(sym, &Symbol::asValue); - if (!valSym) - continue; + auto valSym = castSym(sym, &Symbol::asValue); + if (!valSym) + continue; - auto fldSym = castSym(valSym, &ValueSymbol::asField); - if (!fldSym) - continue; + auto fldSym = castSym(valSym, &ValueSymbol::asField); + if (!fldSym) + continue; - fldSyms.push_back(fldSym); - } - return fldSyms; + fldSyms.push_back(fldSym); + } + return fldSyms; } -std::vector SemanticModel::declaredSymbols( - const VariableAndOrFunctionDeclarationSyntax* node) const -{ - std::vector syms; - for (auto decltorIt = node->declarators(); decltorIt; decltorIt = decltorIt->next) { - auto sym = declaredSymbol(decltorIt->value); - if (!sym) { - PSY_ASSERT_NO_STMT(!P->expectValidSyms_); - continue; - } - - syms.push_back(sym); +std::vector SemanticModel::declaredSymbols( + const VariableAndOrFunctionDeclarationSyntax *node) const { + std::vector syms; + for (auto decltorIt = node->declarators(); decltorIt; + decltorIt = decltorIt->next) { + auto sym = declaredSymbol(decltorIt->value); + if (!sym) { + PSY_ASSERT_NO_STMT(!P->expectValidSyms_); + continue; } - return syms; + + syms.push_back(sym); + } + return syms; } -const Symbol* SemanticModel::declaredSymbol(const DeclaratorSyntax* node) const -{ - auto node_P = SyntaxUtilities::strippedDeclaratorOrSelf(node); - auto node_PP = SyntaxUtilities::innermostDeclaratorOrSelf(node_P); +const Symbol * +SemanticModel::declaredSymbol(const DeclaratorSyntax *node) const { + auto node_P = SyntaxUtilities::strippedDeclaratorOrSelf(node); + auto node_PP = SyntaxUtilities::innermostDeclaratorOrSelf(node_P); - auto it = P->declSyms_.find(node_PP); - if (it == P->declSyms_.end()) { - PSY_ASSERT_NO_STMT(!P->expectValidSyms_); - return nullptr; - } + auto it = P->declSyms_.find(node_PP); + if (it == P->declSyms_.end()) { + PSY_ASSERT_NO_STMT(!P->expectValidSyms_); + return nullptr; + } - return it->second; + return it->second; } -Symbol* SemanticModel::storeDeclaredSym(const SyntaxNode* node, std::unique_ptr sym) -{ - auto& allSyms = P->compilation_->assembly()->symDEFs_; - auto [it, _] = allSyms.insert(std::move(sym)); - Symbol* rawSym = it->get(); +Symbol *SemanticModel::storeDeclaredSym(const SyntaxNode *node, + std::unique_ptr sym) { + auto &allSyms = P->compilation_->assembly()->symDEFs_; + auto [it, _] = allSyms.insert(std::move(sym)); + Symbol *rawSym = it->get(); - PSY_ASSERT(P->declSyms_.count(node) == 0, return rawSym); - P->declSyms_[node] = rawSym; + PSY_ASSERT(P->declSyms_.count(node) == 0, return rawSym); + P->declSyms_[node] = rawSym; - return rawSym; + return rawSym; } -Symbol* SemanticModel::storeUsedSym(std::unique_ptr sym) -{ - auto& syms = P->compilation_->assembly()->symUSEs_; - syms.emplace_back(sym.release()); - return syms.back().get(); +Symbol *SemanticModel::storeUsedSym(std::unique_ptr sym) { + auto &syms = P->compilation_->assembly()->symUSEs_; + syms.emplace_back(sym.release()); + return syms.back().get(); } diff --git a/C/compilation/SemanticModel.h b/C/compilation/SemanticModel.h index 514328e48..00ec401ee 100644 --- a/C/compilation/SemanticModel.h +++ b/C/compilation/SemanticModel.h @@ -41,69 +41,73 @@ class Binder; * This API is inspired by that of \c Microsoft.CodeAnalysis.SemanticModel * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API SemanticModel -{ +class PSY_C_API SemanticModel { public: - ~SemanticModel(); - - /** - * The SyntaxTree from which \c this SemanticModel was computed. - */ - const SyntaxTree* syntaxTree() const; - - /** - * The Compilation from which \c this SemanticModel was computed. - */ - const Compilation* compilation() const; - - //!@{ - /** - * The Symbol declared by TranslationUnitSyntax \p node. - */ - const LibrarySymbol* declaredSymbol(const TranslationUnitSyntax* node) const; - - /** - * The Symbol declared by DeclarationSyntax \p node. - */ - const FunctionSymbol* declaredSymbol(const FunctionDefinitionSyntax* node) const; - const ParameterSymbol* declaredSymbol(const ParameterDeclarationSyntax* node) const; - const NamedTypeSymbol* declaredSymbol(const TypeDeclarationSyntax* node) const; - const EnumeratorSymbol* declaredSymbol(const EnumeratorDeclarationSyntax* node) const; - - /** - * The Symbol(s) declared by DeclarationSyntax \p node. - */ - std::vector declaredSymbols(const VariableAndOrFunctionDeclarationSyntax* node) const; - std::vector declaredSymbols(const FieldDeclarationSyntax* node) const; - - /** - * The Symbol declared by DeclaratorSyntax \p node. - */ - const Symbol* declaredSymbol(const DeclaratorSyntax* node) const; - //!@} - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); - PSY_GRANT_ACCESS(Compilation); - - SemanticModel(const SyntaxTree* tree, Compilation* compilation); - - Symbol* storeDeclaredSym(const SyntaxNode* node, std::unique_ptr sym); - Symbol* storeUsedSym(std::unique_ptr sym); - - template const SymCastT* castSym( - const SymOriT* sym, - const SymCastT* (SymOriT::*cast)() const) const; + ~SemanticModel(); + + /** + * The SyntaxTree from which \c this SemanticModel was computed. + */ + const SyntaxTree *syntaxTree() const; + + /** + * The Compilation from which \c this SemanticModel was computed. + */ + const Compilation *compilation() const; + + //!@{ + /** + * The Symbol declared by TranslationUnitSyntax \p node. + */ + const LibrarySymbol *declaredSymbol(const TranslationUnitSyntax *node) const; + + /** + * The Symbol declared by DeclarationSyntax \p node. + */ + const FunctionSymbol * + declaredSymbol(const FunctionDefinitionSyntax *node) const; + const ParameterSymbol * + declaredSymbol(const ParameterDeclarationSyntax *node) const; + const NamedTypeSymbol * + declaredSymbol(const TypeDeclarationSyntax *node) const; + const EnumeratorSymbol * + declaredSymbol(const EnumeratorDeclarationSyntax *node) const; + + /** + * The Symbol(s) declared by DeclarationSyntax \p node. + */ + std::vector + declaredSymbols(const VariableAndOrFunctionDeclarationSyntax *node) const; + std::vector + declaredSymbols(const FieldDeclarationSyntax *node) const; + + /** + * The Symbol declared by DeclaratorSyntax \p node. + */ + const Symbol *declaredSymbol(const DeclaratorSyntax *node) const; + //!@} + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); + PSY_GRANT_ACCESS(Compilation); + + SemanticModel(const SyntaxTree *tree, Compilation *compilation); + + Symbol *storeDeclaredSym(const SyntaxNode *node, std::unique_ptr sym); + Symbol *storeUsedSym(std::unique_ptr sym); + + template + const SymCastT *castSym(const SymOriT *sym, + const SymCastT *(SymOriT::*cast)() const) const; private: - // Unavailable - SemanticModel(const SemanticModel&) = delete; - SemanticModel& operator=(const SemanticModel&) = delete; + // Unavailable + SemanticModel(const SemanticModel &) = delete; + SemanticModel &operator=(const SemanticModel &) = delete; - DECL_PIMPL(SemanticModel) + DECL_PIMPL(SemanticModel) }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/infra/List.h b/C/infra/List.h index 99e497c0b..520264ace 100644 --- a/C/infra/List.h +++ b/C/infra/List.h @@ -34,51 +34,41 @@ namespace C { * * A singly linked-list. */ -template -class PSY_C_NON_API List : public Managed -{ +template +class PSY_C_NON_API List : public Managed { public: - List() - : value(ValueT()) - , next(nullptr) - {} + List() : value(ValueT()), next(nullptr) {} - List(const ValueT& value) - : value(value) - , next(nullptr) - {} + List(const ValueT &value) : value(value), next(nullptr) {} - DerivedListT** skipToLast() - { - DerivedListT** cur = &next; - while (*cur) - cur = &(*cur)->next; - return &(*cur); - } + DerivedListT **skipToLast() { + DerivedListT **cur = &next; + while (*cur) + cur = &(*cur)->next; + return &(*cur); + } - ValueT lastValue() const - { - ValueT v = nullptr; - for (auto it = const_cast(static_cast(this)); - it; - it = it->next) { - if (it->value) - v = it->value; - } - return v; + ValueT lastValue() const { + ValueT v = nullptr; + for (auto it = const_cast( + static_cast(this)); + it; it = it->next) { + if (it->value) + v = it->value; } + return v; + } - ValueT value; - DerivedListT* next; + ValueT value; + DerivedListT *next; private: - // Unavailable - List(const List&) = delete; - List& operator=(const List&) = delete; + // Unavailable + List(const List &) = delete; + List &operator=(const List &) = delete; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/infra/Managed.cpp b/C/infra/Managed.cpp index a5610eb46..2089da633 100644 --- a/C/infra/Managed.cpp +++ b/C/infra/Managed.cpp @@ -26,19 +26,14 @@ using namespace psy; using namespace C; -Managed::Managed() -{} +Managed::Managed() {} -Managed::~Managed() -{} +Managed::~Managed() {} -void* Managed::operator new(size_t size, MemoryPool* pool) -{ - return pool->allocate(size); +void *Managed::operator new(size_t size, MemoryPool *pool) { + return pool->allocate(size); } -void Managed::operator delete(void*) -{} +void Managed::operator delete(void *) {} -void Managed::operator delete(void*, MemoryPool*) -{} +void Managed::operator delete(void *, MemoryPool *) {} diff --git a/C/infra/Managed.h b/C/infra/Managed.h index 05ea7dfa1..7f2e4bcd4 100644 --- a/C/infra/Managed.h +++ b/C/infra/Managed.h @@ -32,22 +32,21 @@ namespace C { class MemoryPool; -class PSY_C_NON_API Managed -{ +class PSY_C_NON_API Managed { public: - Managed(); - virtual ~Managed(); + Managed(); + virtual ~Managed(); - // Unavailable - Managed(const Managed&) = delete; - Managed& operator=(const Managed&) = delete; + // Unavailable + Managed(const Managed &) = delete; + Managed &operator=(const Managed &) = delete; - void* operator new(size_t size, MemoryPool* pool); - void operator delete(void*); - void operator delete(void*, MemoryPool*); + void *operator new(size_t size, MemoryPool *pool); + void operator delete(void *); + void operator delete(void *, MemoryPool *); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/infra/MemoryPool.cpp b/C/infra/MemoryPool.cpp index ec0b6ab6d..a739eeaea 100644 --- a/C/infra/MemoryPool.cpp +++ b/C/infra/MemoryPool.cpp @@ -28,53 +28,45 @@ using namespace psy; using namespace C; MemoryPool::MemoryPool() - : blocks_(0) - , allocatedBlocks_(0) - , blockCount_(-1) - , ptr_(0)\ - , end_(0) -{} + : blocks_(0), allocatedBlocks_(0), blockCount_(-1), ptr_(0), end_(0) {} -MemoryPool::~MemoryPool() -{ - if (blocks_) { - for (int i = 0; i < allocatedBlocks_; ++i) { - if (char* b = blocks_[i]) - std::free(b); - } - std::free(blocks_); +MemoryPool::~MemoryPool() { + if (blocks_) { + for (int i = 0; i < allocatedBlocks_; ++i) { + if (char *b = blocks_[i]) + std::free(b); } + std::free(blocks_); + } } -void MemoryPool::reset() -{ - blockCount_ = -1; - ptr_ = end_ = 0; +void MemoryPool::reset() { + blockCount_ = -1; + ptr_ = end_ = 0; } -void* MemoryPool::allocate_helper(size_t size) -{ - if (++blockCount_ == allocatedBlocks_) { - if (!allocatedBlocks_) - allocatedBlocks_ = DEFAULT_BLOCK_COUNT; - else - allocatedBlocks_ *= 2; +void *MemoryPool::allocate_helper(size_t size) { + if (++blockCount_ == allocatedBlocks_) { + if (!allocatedBlocks_) + allocatedBlocks_ = DEFAULT_BLOCK_COUNT; + else + allocatedBlocks_ *= 2; - blocks_ = (char**)realloc(blocks_, sizeof(char*) * allocatedBlocks_); + blocks_ = (char **)realloc(blocks_, sizeof(char *) * allocatedBlocks_); - for (int index = blockCount_; index < allocatedBlocks_; ++index) - blocks_[index] = 0; - } + for (int index = blockCount_; index < allocatedBlocks_; ++index) + blocks_[index] = 0; + } - char*& block = blocks_[blockCount_]; - if (!block) - block = (char *) std::malloc(BLOCK_SIZE); + char *&block = blocks_[blockCount_]; + if (!block) + block = (char *)std::malloc(BLOCK_SIZE); - ptr_ = block; - end_ = ptr_ + BLOCK_SIZE; + ptr_ = block; + end_ = ptr_ + BLOCK_SIZE; - void* addr = ptr_; - ptr_ += size; + void *addr = ptr_; + ptr_ += size; - return addr; + return addr; } diff --git a/C/infra/MemoryPool.h b/C/infra/MemoryPool.h index 3ca8f686d..d7177c5ce 100644 --- a/C/infra/MemoryPool.h +++ b/C/infra/MemoryPool.h @@ -29,46 +29,40 @@ namespace psy { namespace C { -class PSY_C_NON_API MemoryPool -{ +class PSY_C_NON_API MemoryPool { public: - MemoryPool(); - ~MemoryPool(); + MemoryPool(); + ~MemoryPool(); - // Unavailable - MemoryPool(const MemoryPool&) = delete; - void operator=(const MemoryPool&) = delete; + // Unavailable + MemoryPool(const MemoryPool &) = delete; + void operator=(const MemoryPool &) = delete; - void reset(); + void reset(); - void* allocate(size_t size) - { - size = (size + 7) & ~7; - if (ptr_ && (ptr_ + size < end_)) { - void *addr = ptr_; - ptr_ += size; - return addr; - } - return allocate_helper(size); + void *allocate(size_t size) { + size = (size + 7) & ~7; + if (ptr_ && (ptr_ + size < end_)) { + void *addr = ptr_; + ptr_ += size; + return addr; } + return allocate_helper(size); + } private: - void* allocate_helper(size_t size); + void *allocate_helper(size_t size); - char** blocks_; - int allocatedBlocks_; - int blockCount_; - char* ptr_; - char* end_; + char **blocks_; + int allocatedBlocks_; + int blockCount_; + char *ptr_; + char *end_; - enum - { - BLOCK_SIZE = 8 * 1024, - DEFAULT_BLOCK_COUNT = 8 - }; + enum { BLOCK_SIZE = 8 * 1024, DEFAULT_BLOCK_COUNT = 8 }; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/DiagnosticsReporter_Lexer.cpp b/C/parser/DiagnosticsReporter_Lexer.cpp index ee68790ce..10206fe99 100644 --- a/C/parser/DiagnosticsReporter_Lexer.cpp +++ b/C/parser/DiagnosticsReporter_Lexer.cpp @@ -27,31 +27,28 @@ using namespace psy; using namespace C; -const std::string Lexer::DiagnosticsReporter::ID_of_IncompatibleLanguageDialect = "Lexer-001"; -const std::string Lexer::DiagnosticsReporter::ID_of_IncompatibleLanguageExtension = "Lexer-002"; +const std::string + Lexer::DiagnosticsReporter::ID_of_IncompatibleLanguageDialect = "Lexer-001"; +const std::string + Lexer::DiagnosticsReporter::ID_of_IncompatibleLanguageExtension = + "Lexer-002"; void Lexer::DiagnosticsReporter::IncompatibleLanguageDialect( - const std::string& feature, - LanguageDialect::Std expectedStd) -{ - DiagnosticDescriptor descriptor(ID_of_IncompatibleLanguageDialect, - "Incompatible language dialect", - feature + " is available in " + to_string(expectedStd), - DiagnosticSeverity::Warning, - DiagnosticCategory::Syntax); - - lexer_->tree_->newDiagnostic(descriptor, lexer_->tree_->freeTokenSlot()); + const std::string &feature, LanguageDialect::Std expectedStd) { + DiagnosticDescriptor descriptor( + ID_of_IncompatibleLanguageDialect, "Incompatible language dialect", + feature + " is available in " + to_string(expectedStd), + DiagnosticSeverity::Warning, DiagnosticCategory::Syntax); + + lexer_->tree_->newDiagnostic(descriptor, lexer_->tree_->freeTokenSlot()); } void Lexer::DiagnosticsReporter::IncompatibleLanguageExtension( - const std::string& feature, - LanguageExtensions::Ext expectedExt) -{ - DiagnosticDescriptor descriptor(ID_of_IncompatibleLanguageExtension, - "Incompatible language extension", - feature + " is available in " + to_string(expectedExt), - DiagnosticSeverity::Warning, - DiagnosticCategory::Syntax); - - lexer_->tree_->newDiagnostic(descriptor, lexer_->tree_->freeTokenSlot()); + const std::string &feature, LanguageExtensions::Ext expectedExt) { + DiagnosticDescriptor descriptor( + ID_of_IncompatibleLanguageExtension, "Incompatible language extension", + feature + " is available in " + to_string(expectedExt), + DiagnosticSeverity::Warning, DiagnosticCategory::Syntax); + + lexer_->tree_->newDiagnostic(descriptor, lexer_->tree_->freeTokenSlot()); } diff --git a/C/parser/DiagnosticsReporter_Parser.cpp b/C/parser/DiagnosticsReporter_Parser.cpp index ab3c03699..974dfbb6d 100644 --- a/C/parser/DiagnosticsReporter_Parser.cpp +++ b/C/parser/DiagnosticsReporter_Parser.cpp @@ -24,496 +24,456 @@ using namespace psy; using namespace C; /* General */ -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFeature = "Parser-000"; +const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFeature = + "Parser-000"; /* Terminal */ -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedToken = "Parser-101"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedTokenWithin = "Parser-102"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryConstant = "Parser-104"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryStringLiteral = "Parser-105"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryIdentifier = "Parser-106"; +const std::string Parser::DiagnosticsReporter::ID_of_ExpectedToken = + "Parser-101"; +const std::string Parser::DiagnosticsReporter::ID_of_ExpectedTokenWithin = + "Parser-102"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryConstant = + "Parser-104"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryStringLiteral = + "Parser-105"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryIdentifier = + "Parser-106"; /* Non-terminal */ -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression = "Parser-200-6.5"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofEnumerationConstant= "Parser-201-6.7.2.2"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator = "Parser-202-6.7.6"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofParameterDeclaration = "Parser-203-6.7.6.3"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofSpecifierQualifier = "Parser-204-6.7.2.1"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDesignatedInitializer = "Parser-205-6.7.9"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator = "Parser-206-6.7.6"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclaratorAndInitializer = "Parser-207"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructOrUnionOrEnum = "Parser-208-6.7.2.1"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructDeclarator = "Parser-209-6.7.2.1-9"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofEnum = "Parser-210-6.7.2.1"; +const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression = + "Parser-200-6.5"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofEnumerationConstant = + "Parser-201-6.7.2.2"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator = + "Parser-202-6.7.6"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofParameterDeclaration = + "Parser-203-6.7.6.3"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofSpecifierQualifier = + "Parser-204-6.7.2.1"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDesignatedInitializer = + "Parser-205-6.7.9"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator = + "Parser-206-6.7.6"; +const std::string Parser::DiagnosticsReporter:: + ID_of_ExpectedFOLLOWofDeclaratorAndInitializer = "Parser-207"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructOrUnionOrEnum = + "Parser-208-6.7.2.1"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructDeclarator = + "Parser-209-6.7.2.1-9"; +const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofEnum = + "Parser-210-6.7.2.1"; /* Detailed */ -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFieldName = "Parser-300-6.5.2"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedBraceEnclosedInitializerList = "Parser-301-6.7.9"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFieldDesignator = "Parser-302-6.7.9"; -const std::string Parser::DiagnosticsReporter::ID_of_UnexpectedInitializerOfDeclarator = "Parser-303-6.7.9"; -const std::string Parser::DiagnosticsReporter::ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator = "Parser-304-6.7.6"; -const std::string Parser::DiagnosticsReporter::ID_of_UnexpectedPointerInArrayDeclarator = "Parser-305-6.7.6"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedNamedParameterBeforeEllipsis = "Parser-306-6.7.6.3"; -const std::string Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier = "Parser-307-6.7"; -const std::string Parser::DiagnosticsReporter::ID_of_UnexpectedCaseLabelOutsideSwitch = "Parser-308-6.8.1-2"; -const std::string Parser::DiagnosticsReporter::ID_of_UnexpectedDefaultLabelOutsideSwitch = "Parser-309-6.8.1-2"; -const std::string Parser::DiagnosticsReporter::ID_of_UnexpectedContinueOutsideLoop = "Parser-310-6.8.6.2-1"; -const std::string Parser::DiagnosticsReporter::ID_of_UnexpectedBreakOutsideSwitchOrLoop = "Parser-311-6.8.6.3-1"; -const std::string Parser::DiagnosticsReporter::ID_of_UnexpectedGNUExtensionFlag = "Parser-312-GNU"; +const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFieldName = + "Parser-300-6.5.2"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedBraceEnclosedInitializerList = + "Parser-301-6.7.9"; +const std::string Parser::DiagnosticsReporter::ID_of_ExpectedFieldDesignator = + "Parser-302-6.7.9"; +const std::string + Parser::DiagnosticsReporter::ID_of_UnexpectedInitializerOfDeclarator = + "Parser-303-6.7.9"; +const std::string Parser::DiagnosticsReporter:: + ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator = "Parser-304-6.7.6"; +const std::string + Parser::DiagnosticsReporter::ID_of_UnexpectedPointerInArrayDeclarator = + "Parser-305-6.7.6"; +const std::string + Parser::DiagnosticsReporter::ID_of_ExpectedNamedParameterBeforeEllipsis = + "Parser-306-6.7.6.3"; +const std::string Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier = + "Parser-307-6.7"; +const std::string + Parser::DiagnosticsReporter::ID_of_UnexpectedCaseLabelOutsideSwitch = + "Parser-308-6.8.1-2"; +const std::string + Parser::DiagnosticsReporter::ID_of_UnexpectedDefaultLabelOutsideSwitch = + "Parser-309-6.8.1-2"; +const std::string + Parser::DiagnosticsReporter::ID_of_UnexpectedContinueOutsideLoop = + "Parser-310-6.8.6.2-1"; +const std::string + Parser::DiagnosticsReporter::ID_of_UnexpectedBreakOutsideSwitchOrLoop = + "Parser-311-6.8.6.3-1"; +const std::string + Parser::DiagnosticsReporter::ID_of_UnexpectedGNUExtensionFlag = + "Parser-312-GNU"; /* Ambiguities */ -const std::string Parser::DiagnosticsReporter::ID_of_AmbiguousTypeNameOrExpressionAsTypeReference = "Parser-A1"; -const std::string Parser::DiagnosticsReporter::ID_of_AmbiguousCastOrBinaryExpression = "Parser-A2"; -const std::string Parser::DiagnosticsReporter::ID_of_AmbiguousExpressionOrDeclarationStatement = "Parser-A3"; - - -std::string Parser::DiagnosticsReporter::joinTokenNames(const std::vector& validTkKinds) -{ - std::string s; - if (!validTkKinds.empty()) { - auto tkK = validTkKinds.front(); - auto tkCat = SyntaxToken::category(tkK); - if (tkCat == SyntaxToken::Category::Keywords - || tkCat == SyntaxToken::Category::Punctuators) - s += "`"; - s += to_string(tkK); - if (tkCat == SyntaxToken::Category::Keywords - || tkCat == SyntaxToken::Category::Punctuators) - s += "'"; - } - - for (std::vector::size_type i = 1; i < validTkKinds.size(); ++i) { - auto tkK = validTkKinds[i]; - auto tkCat = SyntaxToken::category(tkK); - s += " or "; - if (tkCat == SyntaxToken::Category::Keywords - || tkCat == SyntaxToken::Category::Punctuators) - s += "`"; - s += to_string(tkK); - if (tkCat == SyntaxToken::Category::Keywords - || tkCat == SyntaxToken::Category::Punctuators) - s += "'"; - } - s += " "; - - return s; -} - -void Parser::DiagnosticsReporter::diagnose(DiagnosticDescriptor&& desc) -{ - if (parser_->mightBacktrack()) - return; - - if (IDsForDelay_.find(desc.id()) != IDsForDelay_.end()) - delayedDiags_.push_back(std::make_pair(desc, parser_->curTkIdx_)); - else - parser_->tree_->newDiagnostic(desc, parser_->curTkIdx_); -} - -void Parser::DiagnosticsReporter::diagnoseDelayed() -{ - for (const auto& p : delayedDiags_) - parser_->tree_->newDiagnostic(p.first, p.second); -} - -void Parser::DiagnosticsReporter::diagnoseAmbiguityButRetainIt(DiagnosticDescriptor&& desc) -{ - retainedAmbiguityDiags_.push_back(std::make_pair(desc, parser_->curTkIdx_ - 1)); +const std::string Parser::DiagnosticsReporter:: + ID_of_AmbiguousTypeNameOrExpressionAsTypeReference = "Parser-A1"; +const std::string + Parser::DiagnosticsReporter::ID_of_AmbiguousCastOrBinaryExpression = + "Parser-A2"; +const std::string Parser::DiagnosticsReporter:: + ID_of_AmbiguousExpressionOrDeclarationStatement = "Parser-A3"; + +std::string Parser::DiagnosticsReporter::joinTokenNames( + const std::vector &validTkKinds) { + std::string s; + if (!validTkKinds.empty()) { + auto tkK = validTkKinds.front(); + auto tkCat = SyntaxToken::category(tkK); + if (tkCat == SyntaxToken::Category::Keywords || + tkCat == SyntaxToken::Category::Punctuators) + s += "`"; + s += to_string(tkK); + if (tkCat == SyntaxToken::Category::Keywords || + tkCat == SyntaxToken::Category::Punctuators) + s += "'"; + } + + for (std::vector::size_type i = 1; i < validTkKinds.size(); ++i) { + auto tkK = validTkKinds[i]; + auto tkCat = SyntaxToken::category(tkK); + s += " or "; + if (tkCat == SyntaxToken::Category::Keywords || + tkCat == SyntaxToken::Category::Punctuators) + s += "`"; + s += to_string(tkK); + if (tkCat == SyntaxToken::Category::Keywords || + tkCat == SyntaxToken::Category::Punctuators) + s += "'"; + } + s += " "; + + return s; +} + +void Parser::DiagnosticsReporter::diagnose(DiagnosticDescriptor &&desc) { + if (parser_->mightBacktrack()) + return; + + if (IDsForDelay_.find(desc.id()) != IDsForDelay_.end()) + delayedDiags_.push_back(std::make_pair(desc, parser_->curTkIdx_)); + else + parser_->tree_->newDiagnostic(desc, parser_->curTkIdx_); +} + +void Parser::DiagnosticsReporter::diagnoseDelayed() { + for (const auto &p : delayedDiags_) + parser_->tree_->newDiagnostic(p.first, p.second); +} + +void Parser::DiagnosticsReporter::diagnoseAmbiguityButRetainIt( + DiagnosticDescriptor &&desc) { + retainedAmbiguityDiags_.push_back( + std::make_pair(desc, parser_->curTkIdx_ - 1)); } /* Generic */ -void Parser::DiagnosticsReporter::ExpectedFeature(const std::string& name) -{ - diagnose(DiagnosticDescriptor(ID_of_ExpectedFeature, - "[[unexpected extension or C dialect]]", - name + " is either an extension or unsupported in this dialect", - DiagnosticSeverity::Warning, - DiagnosticCategory::Syntax)); +void Parser::DiagnosticsReporter::ExpectedFeature(const std::string &name) { + diagnose(DiagnosticDescriptor( + ID_of_ExpectedFeature, "[[unexpected extension or C dialect]]", + name + " is either an extension or unsupported in this dialect", + DiagnosticSeverity::Warning, DiagnosticCategory::Syntax)); } -void Parser::DiagnosticsReporter::ExpectedToken(SyntaxKind tkK) -{ - auto s = "expected `" - + to_string(tkK) - + "', got `" - + parser_->peek().valueText_c_str() - + "'"; +void Parser::DiagnosticsReporter::ExpectedToken(SyntaxKind tkK) { + auto s = "expected `" + to_string(tkK) + "', got `" + + parser_->peek().valueText_c_str() + "'"; - diagnose(DiagnosticDescriptor(ID_of_ExpectedToken, - "[[expected token]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); + diagnose(DiagnosticDescriptor(ID_of_ExpectedToken, "[[expected token]]", s, + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); } -void Parser::DiagnosticsReporter::ExpectedTokenWithin(const std::vector& validTkKinds) -{ - std::string s = "expected " - + joinTokenNames(validTkKinds) - + ", got `" - + parser_->peek().valueText() - + "'"; +void Parser::DiagnosticsReporter::ExpectedTokenWithin( + const std::vector &validTkKinds) { + std::string s = "expected " + joinTokenNames(validTkKinds) + ", got `" + + parser_->peek().valueText() + "'"; - diagnose(DiagnosticDescriptor(ID_of_ExpectedTokenWithin, - "[[expected one of tokens]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); + diagnose(DiagnosticDescriptor( + ID_of_ExpectedTokenWithin, "[[expected one of tokens]]", s, + DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); } -void Parser::DiagnosticsReporter::ExpectedTokenOfCategory(SyntaxToken::Category category, - const std::string& id) -{ - std::string s = "expected " - + to_string(category) - + " got `" - + parser_->peek().valueText() + "'"; +void Parser::DiagnosticsReporter::ExpectedTokenOfCategory( + SyntaxToken::Category category, const std::string &id) { + std::string s = "expected " + to_string(category) + " got `" + + parser_->peek().valueText() + "'"; - diagnose(DiagnosticDescriptor(id, - "[[expected token of category]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); + diagnose(DiagnosticDescriptor(id, "[[expected token of category]]", s, + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); } -void Parser::DiagnosticsReporter::ExpectedTokenOfCategoryIdentifier() -{ - ExpectedTokenOfCategory(SyntaxToken::Category::Constants, ID_of_ExpectedTokenOfCategoryIdentifier); +void Parser::DiagnosticsReporter::ExpectedTokenOfCategoryIdentifier() { + ExpectedTokenOfCategory(SyntaxToken::Category::Constants, + ID_of_ExpectedTokenOfCategoryIdentifier); } -void Parser::DiagnosticsReporter::ExpectedTokenOfCategoryConstant() -{ - ExpectedTokenOfCategory(SyntaxToken::Category::Constants, ID_of_ExpectedTokenOfCategoryConstant); +void Parser::DiagnosticsReporter::ExpectedTokenOfCategoryConstant() { + ExpectedTokenOfCategory(SyntaxToken::Category::Constants, + ID_of_ExpectedTokenOfCategoryConstant); } -void Parser::DiagnosticsReporter::ExpectedTokenOfCategoryStringLiteral() -{ - ExpectedTokenOfCategory(SyntaxToken::Category::StringLiterals, ID_of_ExpectedTokenOfCategoryStringLiteral); +void Parser::DiagnosticsReporter::ExpectedTokenOfCategoryStringLiteral() { + ExpectedTokenOfCategory(SyntaxToken::Category::StringLiterals, + ID_of_ExpectedTokenOfCategoryStringLiteral); } /* Expressions, declarations, and statements */ -void Parser::DiagnosticsReporter::ExpectedFIRSTof(const std::string& rule, - const std::string& id) -{ - std::string s = "expected " - + rule - + " got `" - + parser_->peek().valueText() + "'"; - - diagnose(DiagnosticDescriptor(id, - "[[expected FIRST of]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); - -} - -void Parser::DiagnosticsReporter::ExpectedFIRSTofExpression() -{ - return ExpectedFIRSTof("expression", ID_of_ExpectedFIRSTofExpression); -} - -void Parser::DiagnosticsReporter::ExpectedFIRSTofEnumerationConstant() -{ - return ExpectedFIRSTof("enumeration-constant", ID_of_ExpectedFIRSTofEnumerationConstant); -} - -void Parser::DiagnosticsReporter::ExpectedFieldName() -{ - auto s = "expected field name, got `" - + parser_->peek().valueText() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFieldName, - "[[expected field name]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedBraceEnclosedInitializerList() -{ - diagnose(DiagnosticDescriptor(ID_of_ExpectedBraceEnclosedInitializerList, - "[[unexpected empty brace-enclosed initializer]]", - "ISO C forbids empty initializer braces", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFieldDesignator() -{ - auto s = "expected field designator, got `" - + parser_->peek().valueText() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFieldDesignator, - "[[expected field designator]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::UnexpectedInitializerOfDeclarator() -{ - diagnose(DiagnosticDescriptor(ID_of_UnexpectedInitializerOfDeclarator, - "[[unexpected initializer for declarator]]", - "declarator may not be initialized", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFOLLOWofDesignatedInitializer() -{ - diagnose(DiagnosticDescriptor(ID_of_ExpectedFOLLOWofDesignatedInitializer, - "[[obsolete array designator syntax]]", - "obsolete array designator without `='", - DiagnosticSeverity::Warning, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::UnexpectedStaticOrTypeQualifiersInArrayDeclarator() -{ - diagnose(DiagnosticDescriptor(ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator, - "[[unexpected static or type qualifier in array declarator]]", - "`static' and type-qualifiers are only allowed in array declarators " - "within function parameters", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::UnexpectedPointerInArrayDeclarator() -{ - diagnose(DiagnosticDescriptor(ID_of_UnexpectedPointerInArrayDeclarator, - "[[unexpected pointer in array declarator]]", - "`*' is only allowed in array declarators " - "within function parameters", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFOLLOWofDeclarator() -{ - auto validTkKinds = { CommaToken, - SemicolonToken, - EqualsToken }; - - std::string s = "expected " - + joinTokenNames(validTkKinds) - + "after declarator, got `" - + parser_->peek().valueText_c_str() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFOLLOWofDeclarator, - "[[unexpected FOLLOW of declarator]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFOLLOWofStructDeclarator() -{ - auto validTkKinds = { CommaToken, - SemicolonToken, - ColonToken }; - - std::string s = "expected " - + joinTokenNames(validTkKinds) - + "after field declarator, got `" - + parser_->peek().valueText_c_str() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFOLLOWofStructDeclarator, - "[[unexpected FOLLOW of field declarator]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFOLLOWofDeclaratorAndInitializer() -{ - auto validTkKinds = { CommaToken, - SemicolonToken }; - - std::string s = "expected " - + joinTokenNames(validTkKinds) - + "after initialized declarator, got `" - + parser_->peek().valueText_c_str() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFOLLOWofDeclaratorAndInitializer, - "[[unexpected FOLLOW of initialized declarator]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFIRSTofDirectDeclarator() -{ - auto validTkKinds = { IdentifierToken, - OpenParenToken }; - - std::string s = "expected " - + joinTokenNames(validTkKinds) - + "starting direct-declarator, got `" - + parser_->peek().valueText_c_str() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFIRSTofDirectDeclarator, - "[[unexpected FIRST of direct-declarator]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFIRSTofParameterDeclaration() -{ - std::string s = "expected declaration specifiers or '...', got `" - + parser_->peek().valueText() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFIRSTofParameterDeclaration, - "[[unexpected FIRST of parameter-declaration]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFIRSTofSpecifierQualifier() -{ - std::string s = "expected specifier-qualifier-list, got `" - + parser_->peek().valueText() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFIRSTofSpecifierQualifier, - "[[unexpected FIRST of specifier-qualifier-list]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedFOLLOWofStructOrUnionOrEnum() -{ - auto validTkKinds = { IdentifierToken, - OpenBraceToken }; - - std::string s = "expected " - + joinTokenNames(validTkKinds) - + "following struct-or-union or enum, got `" - + parser_->peek().valueText_c_str() - + "'"; - - diagnose(DiagnosticDescriptor(ID_of_ExpectedFOLLOWofStructOrUnionOrEnum, - "[[unexpected struct-or-union or enum FOLLOW]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedNamedParameterBeforeEllipsis() -{ - diagnose(DiagnosticDescriptor(ID_of_ExpectedNamedParameterBeforeEllipsis, - "[[unexpected ellipsis before named parameter]]", - "ISO C requires a named parameter before `...'", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::ExpectedTypeSpecifier() -{ - diagnose(DiagnosticDescriptor(ID_of_ExpectedTypeSpecifier, - "[[declaration without type specifier]]", - "missing type specifier, assume `int'", - DiagnosticSeverity::Warning, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::UnexpectedCaseLabelOutsideSwitch() -{ - diagnose(DiagnosticDescriptor(ID_of_UnexpectedCaseLabelOutsideSwitch, - "[[case label outside switch-statement]]", - "`case' label not within a switch", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::UnexpectedDefaultLabelOutsideSwitch() -{ - diagnose(DiagnosticDescriptor(ID_of_UnexpectedDefaultLabelOutsideSwitch, - "[[default label outside switch-statement]]", - "`default' label not within a switch", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::UnexpectedContinueOutsideLoop() -{ - diagnose(DiagnosticDescriptor(ID_of_UnexpectedContinueOutsideLoop, - "[[continue outside iteration-statement]]", - "`continue' not within a loop", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::UnexpectedBreakOutsideSwitchOrLoop() -{ - diagnose(DiagnosticDescriptor(ID_of_UnexpectedBreakOutsideSwitchOrLoop, - "[[break outside iteration- or switch-statement]]", - "`break' not within a loop or switch", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::UnexpectedGNUExtensionFlag() -{ - diagnose(DiagnosticDescriptor(ID_of_UnexpectedGNUExtensionFlag, - "[[unexpected `__extension__']]", - "unrecognized `__extension__'", - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); +void Parser::DiagnosticsReporter::ExpectedFIRSTof(const std::string &rule, + const std::string &id) { + std::string s = + "expected " + rule + " got `" + parser_->peek().valueText() + "'"; + + diagnose(DiagnosticDescriptor(id, "[[expected FIRST of]]", s, + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFIRSTofExpression() { + return ExpectedFIRSTof("expression", ID_of_ExpectedFIRSTofExpression); +} + +void Parser::DiagnosticsReporter::ExpectedFIRSTofEnumerationConstant() { + return ExpectedFIRSTof("enumeration-constant", + ID_of_ExpectedFIRSTofEnumerationConstant); +} + +void Parser::DiagnosticsReporter::ExpectedFieldName() { + auto s = "expected field name, got `" + parser_->peek().valueText() + "'"; + + diagnose(DiagnosticDescriptor( + ID_of_ExpectedFieldName, "[[expected field name]]", s, + DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedBraceEnclosedInitializerList() { + diagnose(DiagnosticDescriptor( + ID_of_ExpectedBraceEnclosedInitializerList, + "[[unexpected empty brace-enclosed initializer]]", + "ISO C forbids empty initializer braces", DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFieldDesignator() { + auto s = + "expected field designator, got `" + parser_->peek().valueText() + "'"; + + diagnose(DiagnosticDescriptor( + ID_of_ExpectedFieldDesignator, "[[expected field designator]]", s, + DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::UnexpectedInitializerOfDeclarator() { + diagnose(DiagnosticDescriptor(ID_of_UnexpectedInitializerOfDeclarator, + "[[unexpected initializer for declarator]]", + "declarator may not be initialized", + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFOLLOWofDesignatedInitializer() { + diagnose(DiagnosticDescriptor(ID_of_ExpectedFOLLOWofDesignatedInitializer, + "[[obsolete array designator syntax]]", + "obsolete array designator without `='", + DiagnosticSeverity::Warning, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter:: + UnexpectedStaticOrTypeQualifiersInArrayDeclarator() { + diagnose(DiagnosticDescriptor( + ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator, + "[[unexpected static or type qualifier in array declarator]]", + "`static' and type-qualifiers are only allowed in array declarators " + "within function parameters", + DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::UnexpectedPointerInArrayDeclarator() { + diagnose(DiagnosticDescriptor(ID_of_UnexpectedPointerInArrayDeclarator, + "[[unexpected pointer in array declarator]]", + "`*' is only allowed in array declarators " + "within function parameters", + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFOLLOWofDeclarator() { + auto validTkKinds = {CommaToken, SemicolonToken, EqualsToken}; + + std::string s = "expected " + joinTokenNames(validTkKinds) + + "after declarator, got `" + + parser_->peek().valueText_c_str() + "'"; + + diagnose(DiagnosticDescriptor( + ID_of_ExpectedFOLLOWofDeclarator, "[[unexpected FOLLOW of declarator]]", + s, DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFOLLOWofStructDeclarator() { + auto validTkKinds = {CommaToken, SemicolonToken, ColonToken}; + + std::string s = "expected " + joinTokenNames(validTkKinds) + + "after field declarator, got `" + + parser_->peek().valueText_c_str() + "'"; + + diagnose(DiagnosticDescriptor(ID_of_ExpectedFOLLOWofStructDeclarator, + "[[unexpected FOLLOW of field declarator]]", s, + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFOLLOWofDeclaratorAndInitializer() { + auto validTkKinds = {CommaToken, SemicolonToken}; + + std::string s = "expected " + joinTokenNames(validTkKinds) + + "after initialized declarator, got `" + + parser_->peek().valueText_c_str() + "'"; + + diagnose(DiagnosticDescriptor( + ID_of_ExpectedFOLLOWofDeclaratorAndInitializer, + "[[unexpected FOLLOW of initialized declarator]]", s, + DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFIRSTofDirectDeclarator() { + auto validTkKinds = {IdentifierToken, OpenParenToken}; + + std::string s = "expected " + joinTokenNames(validTkKinds) + + "starting direct-declarator, got `" + + parser_->peek().valueText_c_str() + "'"; + + diagnose(DiagnosticDescriptor(ID_of_ExpectedFIRSTofDirectDeclarator, + "[[unexpected FIRST of direct-declarator]]", s, + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFIRSTofParameterDeclaration() { + std::string s = "expected declaration specifiers or '...', got `" + + parser_->peek().valueText() + "'"; + + diagnose(DiagnosticDescriptor(ID_of_ExpectedFIRSTofParameterDeclaration, + "[[unexpected FIRST of parameter-declaration]]", + s, DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFIRSTofSpecifierQualifier() { + std::string s = "expected specifier-qualifier-list, got `" + + parser_->peek().valueText() + "'"; + + diagnose(DiagnosticDescriptor( + ID_of_ExpectedFIRSTofSpecifierQualifier, + "[[unexpected FIRST of specifier-qualifier-list]]", s, + DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedFOLLOWofStructOrUnionOrEnum() { + auto validTkKinds = {IdentifierToken, OpenBraceToken}; + + std::string s = "expected " + joinTokenNames(validTkKinds) + + "following struct-or-union or enum, got `" + + parser_->peek().valueText_c_str() + "'"; + + diagnose(DiagnosticDescriptor(ID_of_ExpectedFOLLOWofStructOrUnionOrEnum, + "[[unexpected struct-or-union or enum FOLLOW]]", + s, DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedNamedParameterBeforeEllipsis() { + diagnose(DiagnosticDescriptor( + ID_of_ExpectedNamedParameterBeforeEllipsis, + "[[unexpected ellipsis before named parameter]]", + "ISO C requires a named parameter before `...'", + DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::ExpectedTypeSpecifier() { + diagnose(DiagnosticDescriptor( + ID_of_ExpectedTypeSpecifier, "[[declaration without type specifier]]", + "missing type specifier, assume `int'", DiagnosticSeverity::Warning, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::UnexpectedCaseLabelOutsideSwitch() { + diagnose(DiagnosticDescriptor(ID_of_UnexpectedCaseLabelOutsideSwitch, + "[[case label outside switch-statement]]", + "`case' label not within a switch", + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::UnexpectedDefaultLabelOutsideSwitch() { + diagnose(DiagnosticDescriptor(ID_of_UnexpectedDefaultLabelOutsideSwitch, + "[[default label outside switch-statement]]", + "`default' label not within a switch", + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::UnexpectedContinueOutsideLoop() { + diagnose(DiagnosticDescriptor(ID_of_UnexpectedContinueOutsideLoop, + "[[continue outside iteration-statement]]", + "`continue' not within a loop", + DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::UnexpectedBreakOutsideSwitchOrLoop() { + diagnose(DiagnosticDescriptor( + ID_of_UnexpectedBreakOutsideSwitchOrLoop, + "[[break outside iteration- or switch-statement]]", + "`break' not within a loop or switch", DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::UnexpectedGNUExtensionFlag() { + diagnose(DiagnosticDescriptor( + ID_of_UnexpectedGNUExtensionFlag, "[[unexpected `__extension__']]", + "unrecognized `__extension__'", DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); } /* Ambiguities */ -void Parser::DiagnosticsReporter::AmbiguousTypeNameOrExpressionAsTypeReference() -{ - std::string s = "ambiguous type name or expression `" - + parser_->peek().valueText() - + "'"; - - diagnoseAmbiguityButRetainIt( - DiagnosticDescriptor(ID_of_AmbiguousTypeNameOrExpressionAsTypeReference, - "[[ambiguous type name or expression]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::AmbiguousCastOrBinaryExpression() -{ - std::string s = "ambiguous cast or binary expression `" - + parser_->peek().valueText() - + "'"; - - diagnoseAmbiguityButRetainIt( - DiagnosticDescriptor(ID_of_AmbiguousCastOrBinaryExpression, - "[[ambiguous cast or binary expression]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); -} - -void Parser::DiagnosticsReporter::AmbiguousExpressionOrDeclarationStatement() -{ - std::string s = "ambiguous expression- or declaration-statement `" - + parser_->peek().valueText() - + "'"; - - diagnoseAmbiguityButRetainIt( - DiagnosticDescriptor(ID_of_AmbiguousExpressionOrDeclarationStatement, - "[[ambiguous expression- or declaration-statement]]", - s, - DiagnosticSeverity::Error, - DiagnosticCategory::Syntax)); +void Parser::DiagnosticsReporter:: + AmbiguousTypeNameOrExpressionAsTypeReference() { + std::string s = + "ambiguous type name or expression `" + parser_->peek().valueText() + "'"; + + diagnoseAmbiguityButRetainIt(DiagnosticDescriptor( + ID_of_AmbiguousTypeNameOrExpressionAsTypeReference, + "[[ambiguous type name or expression]]", s, DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::AmbiguousCastOrBinaryExpression() { + std::string s = "ambiguous cast or binary expression `" + + parser_->peek().valueText() + "'"; + + diagnoseAmbiguityButRetainIt(DiagnosticDescriptor( + ID_of_AmbiguousCastOrBinaryExpression, + "[[ambiguous cast or binary expression]]", s, DiagnosticSeverity::Error, + DiagnosticCategory::Syntax)); +} + +void Parser::DiagnosticsReporter::AmbiguousExpressionOrDeclarationStatement() { + std::string s = "ambiguous expression- or declaration-statement `" + + parser_->peek().valueText() + "'"; + + diagnoseAmbiguityButRetainIt(DiagnosticDescriptor( + ID_of_AmbiguousExpressionOrDeclarationStatement, + "[[ambiguous expression- or declaration-statement]]", s, + DiagnosticSeverity::Error, DiagnosticCategory::Syntax)); } diff --git a/C/parser/Keywords.cpp b/C/parser/Keywords.cpp index ab719788b..cd8ed5c1d 100644 --- a/C/parser/Keywords.cpp +++ b/C/parser/Keywords.cpp @@ -21,1678 +21,1588 @@ #include "Lexer.h" -#include "syntax/SyntaxKind.h" #include "parser/ParseOptions.h" +#include "syntax/SyntaxKind.h" #include namespace psy { namespace C { -static inline SyntaxKind classify2(const char* s, const ParseOptions& opts) -{ - if (s[0] == 'd') { - if (s[1] == 'o') { - return Keyword_do; - } +static inline SyntaxKind classify2(const char *s, const ParseOptions &opts) { + if (s[0] == 'd') { + if (s[1] == 'o') { + return Keyword_do; } - else if (s[0] == 'i') { - if (s[1] == 'f') { - return Keyword_if; - } + } else if (s[0] == 'i') { + if (s[1] == 'f') { + return Keyword_if; } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify3(const char* s, const ParseOptions& opts) -{ - if (s[0] == 'a') { - if (s[1] == 's') { - if (s[2] == 'm') { - return KeywordAlias_asm; - } - } +static inline SyntaxKind classify3(const char *s, const ParseOptions &opts) { + if (s[0] == 'a') { + if (s[1] == 's') { + if (s[2] == 'm') { + return KeywordAlias_asm; + } } - else if (s[0] == 'f') { - if (s[1] == 'o') { - if (s[2] == 'r') { - return Keyword_for; - } - } + } else if (s[0] == 'f') { + if (s[1] == 'o') { + if (s[2] == 'r') { + return Keyword_for; + } } - else if (s[0] == 'i') { - if (s[1] == 'n') { - if (s[2] == 't') { - return Keyword_int; - } - } + } else if (s[0] == 'i') { + if (s[1] == 'n') { + if (s[2] == 't') { + return Keyword_int; + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify4(const char* s, const ParseOptions& opts) -{ - if (s[0] == 'a') { - if (s[1] == 'u') { - if (s[2] == 't') { - if (s[3] == 'o') { - return Keyword_auto; - } - } - } +static inline SyntaxKind classify4(const char *s, const ParseOptions &opts) { + if (s[0] == 'a') { + if (s[1] == 'u') { + if (s[2] == 't') { + if (s[3] == 'o') { + return Keyword_auto; + } + } } - else if (s[0] == 'b' - && opts.extensions().translations().isEnabled_Translate_bool_AsKeyword()) { - if (s[1] == 'o') { - if (s[2] == 'o') { - if (s[3] == 'l') { - return KeywordAlias_Bool; - } - } - } + } else if (s[0] == 'b' && opts.extensions() + .translations() + .isEnabled_Translate_bool_AsKeyword()) { + if (s[1] == 'o') { + if (s[2] == 'o') { + if (s[3] == 'l') { + return KeywordAlias_Bool; + } + } } - else if (s[0] == 'c') { - if (s[1] == 'a') { - if (s[2] == 's') { - if (s[3] == 'e') { - return Keyword_case; - } - } - } - else if (s[1] == 'h') { - if (s[2] == 'a') { - if (s[3] == 'r') { - return Keyword_char; - } - } - } + } else if (s[0] == 'c') { + if (s[1] == 'a') { + if (s[2] == 's') { + if (s[3] == 'e') { + return Keyword_case; + } + } + } else if (s[1] == 'h') { + if (s[2] == 'a') { + if (s[3] == 'r') { + return Keyword_char; + } + } } - else if (s[0] == 'e') { - if (s[1] == 'l') { - if (s[2] == 's') { - if (s[3] == 'e') { - return Keyword_else; - } - } - } - else if (s[1] == 'n') { - if (s[2] == 'u') { - if (s[3] == 'm') { - return Keyword_enum; - } - } - } + } else if (s[0] == 'e') { + if (s[1] == 'l') { + if (s[2] == 's') { + if (s[3] == 'e') { + return Keyword_else; + } + } + } else if (s[1] == 'n') { + if (s[2] == 'u') { + if (s[3] == 'm') { + return Keyword_enum; + } + } } - else if (s[0] == 'g') { - if (s[1] == 'o') { - if (s[2] == 't') { - if (s[3] == 'o') { - return Keyword_goto; - } - } + } else if (s[0] == 'g') { + if (s[1] == 'o') { + if (s[2] == 't') { + if (s[3] == 'o') { + return Keyword_goto; } + } } - else if (s[0] == 'l') { - if (s[1] == 'o') { - if (s[2] == 'n') { - if (s[3] == 'g') { - return Keyword_long; - } - } + } else if (s[0] == 'l') { + if (s[1] == 'o') { + if (s[2] == 'n') { + if (s[3] == 'g') { + return Keyword_long; } + } } - else if (s[0] == 'N' - && opts.extensions().isEnabled_NULLAsBuiltin()) { - if (s[1] == 'U') { - if (s[2] == 'L') { - if (s[3] == 'L') { - return Keyword_Ext_NULL; - } - } + } else if (s[0] == 'N' && opts.extensions().isEnabled_NULLAsBuiltin()) { + if (s[1] == 'U') { + if (s[2] == 'L') { + if (s[3] == 'L') { + return Keyword_Ext_NULL; } + } } - else if (s[0] == 't' - && opts.extensions().isEnabled_NativeBooleans()) { - if (s[1] == 'r') { - if (s[2] == 'u') { - if (s[3] == 'e') { - return Keyword_Ext_true; - } - } + } else if (s[0] == 't' && opts.extensions().isEnabled_NativeBooleans()) { + if (s[1] == 'r') { + if (s[2] == 'u') { + if (s[3] == 'e') { + return Keyword_Ext_true; } + } } - else if (s[0] == 'v') { - if (s[1] == 'o') { - if (s[2] == 'i') { - if (s[3] == 'd') { - return Keyword_void; - } - } + } else if (s[0] == 'v') { + if (s[1] == 'o') { + if (s[2] == 'i') { + if (s[3] == 'd') { + return Keyword_void; } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify5(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_') { - if (s[2] == 'a') { - if (s[3] == 's') { - if (s[4] == 'm') { - return KeywordAlias___asm; - } - } - } - } - else if (s[1] == 'B' - && opts.extensions().translations().isEnabled_Translate_bool_AsKeyword()) { - if (s[2] == 'o') { - if (s[3] == 'o') { - if (s[4] == 'l') { - return Keyword__Bool; - } - } - } - } - } - else if (s[0] == 'b') { - if (s[1] == 'r') { - if (s[2] == 'e') { - if (s[3] == 'a') { - if (s[4] == 'k') { - return Keyword_break; - } - } - } - } - } - else if (s[0] == 'c') { - if (s[1] == 'o') { - if (s[2] == 'n') { - if (s[3] == 's') { - if (s[4] == 't') { - return Keyword_const; - } - } - } - } - } - else if (s[0] == 'f') { - if (s[1] == 'a' - && opts.extensions().isEnabled_NativeBooleans()) { - if (s[2] == 'l') { - if (s[3] == 's') { - if (s[4] == 'e') { - return Keyword_Ext_false; - } - } - } - } - else if (s[1] == 'l') { - if (s[2] == 'o') { - if (s[3] == 'a') { - if (s[4] == 't') { - return Keyword_float; - } - } - } - } +static inline SyntaxKind classify5(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_') { + if (s[2] == 'a') { + if (s[3] == 's') { + if (s[4] == 'm') { + return KeywordAlias___asm; + } + } + } + } else if (s[1] == 'B' && opts.extensions() + .translations() + .isEnabled_Translate_bool_AsKeyword()) { + if (s[2] == 'o') { + if (s[3] == 'o') { + if (s[4] == 'l') { + return Keyword__Bool; + } + } + } } - else if (s[0] == 's') { - if (s[1] == 'h') { - if (s[2] == 'o') { - if (s[3] == 'r') { - if (s[4] == 't') { - return Keyword_short; - } - } - } - } + } else if (s[0] == 'b') { + if (s[1] == 'r') { + if (s[2] == 'e') { + if (s[3] == 'a') { + if (s[4] == 'k') { + return Keyword_break; + } + } + } } - else if (s[0] == 'u') { - if (s[1] == 'n') { - if (s[2] == 'i') { - if (s[3] == 'o') { - if (s[4] == 'n') { - return Keyword_union; - } - } - } - } + } else if (s[0] == 'c') { + if (s[1] == 'o') { + if (s[2] == 'n') { + if (s[3] == 's') { + if (s[4] == 't') { + return Keyword_const; + } + } + } } - else if (s[0] == 'w') { - if (s[1] == 'h') { - if (s[2] == 'i') { - if (s[3] == 'l') { - if (s[4] == 'e') { - return Keyword_while; - } - } - } - } + } else if (s[0] == 'f') { + if (s[1] == 'a' && opts.extensions().isEnabled_NativeBooleans()) { + if (s[2] == 'l') { + if (s[3] == 's') { + if (s[4] == 'e') { + return Keyword_Ext_false; + } + } + } + } else if (s[1] == 'l') { + if (s[2] == 'o') { + if (s[3] == 'a') { + if (s[4] == 't') { + return Keyword_float; + } + } + } } - return IdentifierToken; -} - -static inline SyntaxKind classify6(const char* s, const ParseOptions& opts) -{ - if (s[0] == 'd') { - if (s[1] == 'o') { - if (s[2] == 'u') { - if (s[3] == 'b') { - if (s[4] == 'l') { - if (s[5] == 'e') { - return Keyword_double; - } - } - } - } - } - } - else if (s[0] == 'e') { - if (s[1] == 'x') { - if (s[2] == 't') { - if (s[3] == 'e') { - if (s[4] == 'r') { - if (s[5] == 'n') { - return Keyword_extern; - } - } - } - } - } - } - else if (s[0] == 'i' - && opts.dialect().std() >= LanguageDialect::Std::C99) { - if (s[1] == 'n') { - if (s[2] == 'l') { - if (s[3] == 'i') { - if (s[4] == 'n') { - if (s[5] == 'e') { - return Keyword_inline; - } - } - } - } - } - } - else if (s[0] == 'r') { - if (s[1] == 'e') { - if (s[2] == 't') { - if (s[3] == 'u') { - if (s[4] == 'r') { - if (s[5] == 'n') { - return Keyword_return; - } - } - } - } - } - } - else if (s[0] == 's') { - if (s[1] == 'i') { - if (s[2] == 'g') { - if (s[3] == 'n') { - if (s[4] == 'e') { - if (s[5] == 'd') { - return Keyword_signed; - } - } - } - } - else if (s[2] == 'z') { - if (s[3] == 'e') { - if (s[4] == 'o') { - if (s[5] == 'f') { - return Keyword_sizeof; - } - } - } - } - } - else if (s[1] == 't') { - if (s[2] == 'a') { - if (s[3] == 't') { - if (s[4] == 'i') { - if (s[5] == 'c') { - return Keyword_static; - } - } - } - } - else if (s[2] == 'r') { - if (s[3] == 'u') { - if (s[4] == 'c') { - if (s[5] == 't') { - return Keyword_struct; - } - } - } - } - } - else if (s[1] == 'w') { - if (s[2] == 'i') { - if (s[3] == 't') { - if (s[4] == 'c') { - if (s[5] == 'h') { - return Keyword_switch; - } - } - } - } - } - } - else if (s[0] == 't') { - if (s[1] == 'y') { - if (s[2] == 'p') { - if (s[3] == 'e') { - if (s[4] == 'o') { - if (s[5] == 'f') { - return KeywordAlias_typeof; - } - } - } - } - } - } - else if (s[0] == 'v' - && opts.extensions().translations().isEnabled_Translate_va_arg_AsKeyword()) { - if (s[1] == 'a') { - if (s[2] == '_') { - if (s[3] == 'a') { - if (s[4] == 'r') { - if (s[5] == 'g') { - return Keyword_MacroStd_va_arg; - } - } - } - } - } - } - return IdentifierToken; -} - -static inline SyntaxKind classify7(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_') { - if (s[2] == 'a') { - if (s[3] == 's') { - if (s[4] == 'm') { - if (s[5] == '_') { - if (s[6] == '_') { - return Keyword_ExtGNU___asm__; - } - } - } - } - } - else if (s[2] == 'c') { - if (s[3] == 'o') { - if (s[4] == 'n') { - if (s[5] == 's') { - if (s[6] == 't') { - return KeywordAlias___const; - } - } - } - } - } - } - else if (s[1] == 'A' - && opts.dialect().std() >= LanguageDialect::Std::C11) { - if (s[2] == 't') { - if (s[3] == 'o') { - if (s[4] == 'm') { - if (s[5] == 'i') { - if (s[6] == 'c') { - return Keyword__Atomic; - } - } - } - } - } - } - else if (s[1] == 'F' - && opts.extensions().isEnabled_ExtPSY_Generics()) { - if (s[2] == 'o') { - if (s[3] == 'r') { - if (s[4] == 'a') { - if (s[5] == 'l') { - if (s[6] == 'l') { - return Keyword_ExtPSY__Forall; - } - } - } - } - } - } - else if (s[1] == 'E' - && opts.extensions().isEnabled_ExtPSY_Generics()) { - if (s[2] == 'x') { - if (s[3] == 'i') { - if (s[4] == 's') { - if (s[5] == 't') { - if (s[6] == 's') { - return Keyword_ExtPSY__Exists; - } - } - } - } - } - } - } - else if (s[0] == 'a' - && opts.dialect().std() >= LanguageDialect::Std::C11) { - if (s[1] == 'l') { - if (s[2] == 'i') { - if (s[3] == 'g') { - if (s[4] == 'n') { - if (s[5] == 'a') { - if (s[6] == 's' - && opts.extensions().translations().isEnabled_Translate_alignas_AsKeyword()) { - return Keyword__Alignas; - } - } - else if (s[5] == 'o') { - if (s[6] == 'f' - && opts.extensions().translations().isEnabled_Translate_alignof_AsKeyword()) { - return Keyword__Alignof; - } - } - } - } - } - } - } - else if (s[0] == 'd') { - if (s[1] == 'e') { - if (s[2] == 'f') { - if (s[3] == 'a') { - if (s[4] == 'u') { - if (s[5] == 'l') { - if (s[6] == 't') { - return Keyword_default; - } - } - } - } - } - } - } - else if (s[0] == 'n' - && opts.extensions().isEnabled_CPP_nullptr()) { - if (s[1] == 'u') { - if (s[2] == 'l') { - if (s[3] == 'l') { - if (s[4] == 'p') { - if (s[5] == 't') { - if (s[6] == 'r') { - return Keyword_Ext_nullptr; - } - } - } - } - } - } - } - else if (s[0] == 't') { - if (s[1] == 'y') { - if (s[2] == 'p') { - if (s[3] == 'e') { - if (s[4] == 'd') { - if (s[5] == 'e') { - if (s[6] == 'f') { - return Keyword_typedef; - } - } - } - } - } - } - } - else if (s[0] == 'w') { - if (s[1] == 'c') { - if (s[2] == 'h') { - if (s[3] == 'a') { - if (s[4] == 'r') { - if (s[5] == '_') { - if (s[6] == 't') { - return Keyword_Ext_wchar_t; - } - } - } - } - } - } - } - return IdentifierToken; -} - -static inline SyntaxKind classify8(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_' - && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { - if (s[2] == 'i') { - if (s[3] == 'n') { - if (s[4] == 'l') { - if (s[5] == 'i') { - if (s[6] == 'n') { - if (s[7] == 'e') { - return KeywordAlias___inline; - } - } - } - } - } - else if (s[3] == 'm' - && opts.extensions().isEnabled_ExtGNU_Complex()) { - if (s[4] == 'a') { - if (s[5] == 'g') { - if (s[6] == '_') { - if (s[7] == '_') { - return Keyword_ExtGNU___imag__; - } - } - } - } - } - } - else if (s[2] == 'f' - && opts.dialect().std() >= LanguageDialect::Std::C99) { - if (s[3] == 'u') { - if (s[4] == 'n') { - if (s[5] == 'c') { - if (s[6] == '_') { - if (s[7] == '_') { - return Keyword___func__; - } - } - } - } - } - } - else if (s[2] == 't') { - if (s[3] == 'y') { - if (s[4] == 'p') { - if (s[5] == 'e') { - if (s[6] == 'o') { - if (s[7] == 'f') { - return KeywordAlias___typeof; - } - } - } - } - } - else if (s[3] == 'h') { - if (s[4] == 'r') { - if (s[5] == 'e') { - if (s[6] == 'a') { - if (s[7] == 'd') { - return Keyword_ExtGNU___thread; - } - } - } - } - } - } - else if (s[2] == 'r' - && opts.extensions().isEnabled_ExtGNU_Complex()) { - if (s[3] == 'e') { - if (s[4] == 'a') { - if (s[5] == 'l') { - if (s[6] == '_') { - if (s[7] == '_') { - return Keyword_ExtGNU___real__; - } - } - } - } - } - } - else if (s[2] == 's' - && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { - if (s[3] == 'i') { - if (s[4] == 'g') { - if (s[5] == 'n') { - if (s[6] == 'e') { - if (s[7] == 'd') { - return KeywordAlias___signed; - } - } - } - } - } - } - } - else if (s[1] == 'A' - && opts.dialect().std() >= LanguageDialect::Std::C11) { - if (s[2] == 'l') { - if (s[3] == 'i') { - if (s[4] == 'g') { - if (s[5] == 'n') { - if (s[6] == 'a') { - if (s[7] == 's') { - return Keyword__Alignas; - } - } - else if (s[6] == 'o') { - if (s[7] == 'f') { - return Keyword__Alignof; - } - } - } - } - } - } - } - else if (s[1] == 'C' - && opts.dialect().std() >= LanguageDialect::Std::C99) { - if (s[2] == 'o') { - if (s[3] == 'm') { - if (s[4] == 'p') { - if (s[5] == 'l') { - if (s[6] == 'e') { - if (s[7] == 'x') { - return Keyword__Complex; - } - } - } - } - } - } - } - else if (s[1] == 'G' - && opts.dialect().std() >= LanguageDialect::Std::C11) { - if (s[2] == 'e') { - if (s[3] == 'n') { - if (s[4] == 'e') { - if (s[5] == 'r') { - if (s[6] == 'i') { - if (s[7] == 'c') { - return Keyword__Generic; - } - } - } - } - } - } - } - } - else if (s[0] == 'c') { - if (s[1] == 'o') { - if (s[2] == 'n') { - if (s[3] == 't') { - if (s[4] == 'i') { - if (s[5] == 'n') { - if (s[6] == 'u') { - if (s[7] == 'e') { - return Keyword_continue; - } - } - } - } - } - } - } - else if (s[1] == 'h') { - if (s[2] == 'a') { - if (s[3] == 'r') { - if (s[4] == '1') { - if (s[5] == '6') { - if (s[6] == '_') { - if (s[7] == 't') { - return Keyword_Ext_char16_t; - } - } - } - } else if (s[4] == '3') { - if (s[5] == '2') { - if (s[6] == '_') { - if (s[7] == 't') { - return Keyword_Ext_char32_t; - } - } - } - } - } - } - } - } - else if (s[0] == 'o' - && opts.extensions().translations().isEnabled_Translate_offsetof_AsKeyword()) { - if (s[1] == 'f') { - if (s[2] == 'f') { - if (s[3] == 's') { - if (s[4] == 'e') { - if (s[5] == 't') { - if (s[6] == 'o') { - if (s[7] == 'f') { - return Keyword_MacroStd_offsetof; - } - } - } - } - } - } - } - } - else if (s[0] == 'r') { - if (s[1] == 'e') { - if (s[2] == 'g') { - if (s[3] == 'i') { - if (s[4] == 's') { - if (s[5] == 't') { - if (s[6] == 'e') { - if (s[7] == 'r') { - return Keyword_register; - } - } - } - } - } - } else if (s[2] == 's') { - if (s[3] == 't') { - if (s[4] == 'r') { - if (s[5] == 'i') { - if (s[6] == 'c') { - if (s[7] == 't') { - return Keyword_restrict; - } - } - } - } - } + } else if (s[0] == 's') { + if (s[1] == 'h') { + if (s[2] == 'o') { + if (s[3] == 'r') { + if (s[4] == 't') { + return Keyword_short; + } + } + } + } + } else if (s[0] == 'u') { + if (s[1] == 'n') { + if (s[2] == 'i') { + if (s[3] == 'o') { + if (s[4] == 'n') { + return Keyword_union; + } + } + } + } + } else if (s[0] == 'w') { + if (s[1] == 'h') { + if (s[2] == 'i') { + if (s[3] == 'l') { + if (s[4] == 'e') { + return Keyword_while; + } + } + } + } + } + return IdentifierToken; +} + +static inline SyntaxKind classify6(const char *s, const ParseOptions &opts) { + if (s[0] == 'd') { + if (s[1] == 'o') { + if (s[2] == 'u') { + if (s[3] == 'b') { + if (s[4] == 'l') { + if (s[5] == 'e') { + return Keyword_double; + } + } + } + } + } + } else if (s[0] == 'e') { + if (s[1] == 'x') { + if (s[2] == 't') { + if (s[3] == 'e') { + if (s[4] == 'r') { + if (s[5] == 'n') { + return Keyword_extern; } + } } + } } - else if (s[0] == 'u') { - if (s[1] == 'n') { - if (s[2] == 's') { - if (s[3] == 'i') { - if (s[4] == 'g') { - if (s[5] == 'n') { - if (s[6] == 'e') { - if (s[7] == 'd') { - return Keyword_unsigned; - } - } - } - } - } + } else if (s[0] == 'i' && opts.dialect().std() >= LanguageDialect::Std::C99) { + if (s[1] == 'n') { + if (s[2] == 'l') { + if (s[3] == 'i') { + if (s[4] == 'n') { + if (s[5] == 'e') { + return Keyword_inline; } + } } + } } - else if (s[0] == 'v') { - if (s[1] == 'o') { - if (s[2] == 'l') { - if (s[3] == 'a') { - if (s[4] == 't') { - if (s[5] == 'i') { - if (s[6] == 'l') { - if (s[7] == 'e') { - return Keyword_volatile; - } - } - } - } - } + } else if (s[0] == 'r') { + if (s[1] == 'e') { + if (s[2] == 't') { + if (s[3] == 'u') { + if (s[4] == 'r') { + if (s[5] == 'n') { + return Keyword_return; } + } } + } } - return IdentifierToken; + } else if (s[0] == 's') { + if (s[1] == 'i') { + if (s[2] == 'g') { + if (s[3] == 'n') { + if (s[4] == 'e') { + if (s[5] == 'd') { + return Keyword_signed; + } + } + } + } else if (s[2] == 'z') { + if (s[3] == 'e') { + if (s[4] == 'o') { + if (s[5] == 'f') { + return Keyword_sizeof; + } + } + } + } + } else if (s[1] == 't') { + if (s[2] == 'a') { + if (s[3] == 't') { + if (s[4] == 'i') { + if (s[5] == 'c') { + return Keyword_static; + } + } + } + } else if (s[2] == 'r') { + if (s[3] == 'u') { + if (s[4] == 'c') { + if (s[5] == 't') { + return Keyword_struct; + } + } + } + } + } else if (s[1] == 'w') { + if (s[2] == 'i') { + if (s[3] == 't') { + if (s[4] == 'c') { + if (s[5] == 'h') { + return Keyword_switch; + } + } + } + } + } + } else if (s[0] == 't') { + if (s[1] == 'y') { + if (s[2] == 'p') { + if (s[3] == 'e') { + if (s[4] == 'o') { + if (s[5] == 'f') { + return KeywordAlias_typeof; + } + } + } + } + } + } else if (s[0] == 'v' && opts.extensions() + .translations() + .isEnabled_Translate_va_arg_AsKeyword()) { + if (s[1] == 'a') { + if (s[2] == '_') { + if (s[3] == 'a') { + if (s[4] == 'r') { + if (s[5] == 'g') { + return Keyword_MacroStd_va_arg; + } + } + } + } + } + } + return IdentifierToken; } -static inline SyntaxKind classify9(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == 'N' - && opts.dialect().std() >= LanguageDialect::Std::C11) { - if (s[2] == 'o') { - if (s[3] == 'r') { - if (s[4] == 'e') { - if (s[5] == 't') { - if (s[6] == 'u') { - if (s[7] == 'r') { - if (s[8] == 'n') { - return Keyword__Noreturn; - } - } - } - } - } +static inline SyntaxKind classify7(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_') { + if (s[2] == 'a') { + if (s[3] == 's') { + if (s[4] == 'm') { + if (s[5] == '_') { + if (s[6] == '_') { + return Keyword_ExtGNU___asm__; + } + } + } + } + } else if (s[2] == 'c') { + if (s[3] == 'o') { + if (s[4] == 'n') { + if (s[5] == 's') { + if (s[6] == 't') { + return KeywordAlias___const; + } + } + } + } + } + } else if (s[1] == 'A' && + opts.dialect().std() >= LanguageDialect::Std::C11) { + if (s[2] == 't') { + if (s[3] == 'o') { + if (s[4] == 'm') { + if (s[5] == 'i') { + if (s[6] == 'c') { + return Keyword__Atomic; + } + } + } + } + } + } else if (s[1] == 'F' && opts.extensions().isEnabled_ExtPSY_Generics()) { + if (s[2] == 'o') { + if (s[3] == 'r') { + if (s[4] == 'a') { + if (s[5] == 'l') { + if (s[6] == 'l') { + return Keyword_ExtPSY__Forall; + } + } + } + } + } + } else if (s[1] == 'E' && opts.extensions().isEnabled_ExtPSY_Generics()) { + if (s[2] == 'x') { + if (s[3] == 'i') { + if (s[4] == 's') { + if (s[5] == 't') { + if (s[6] == 's') { + return Keyword_ExtPSY__Exists; + } + } + } + } + } + } + } else if (s[0] == 'a' && opts.dialect().std() >= LanguageDialect::Std::C11) { + if (s[1] == 'l') { + if (s[2] == 'i') { + if (s[3] == 'g') { + if (s[4] == 'n') { + if (s[5] == 'a') { + if (s[6] == 's' && opts.extensions() + .translations() + .isEnabled_Translate_alignas_AsKeyword()) { + return Keyword__Alignas; + } + } else if (s[5] == 'o') { + if (s[6] == 'f' && opts.extensions() + .translations() + .isEnabled_Translate_alignof_AsKeyword()) { + return Keyword__Alignof; + } + } + } + } + } + } + } else if (s[0] == 'd') { + if (s[1] == 'e') { + if (s[2] == 'f') { + if (s[3] == 'a') { + if (s[4] == 'u') { + if (s[5] == 'l') { + if (s[6] == 't') { + return Keyword_default; + } + } + } + } + } + } + } else if (s[0] == 'n' && opts.extensions().isEnabled_CPP_nullptr()) { + if (s[1] == 'u') { + if (s[2] == 'l') { + if (s[3] == 'l') { + if (s[4] == 'p') { + if (s[5] == 't') { + if (s[6] == 'r') { + return Keyword_Ext_nullptr; + } + } + } + } + } + } + } else if (s[0] == 't') { + if (s[1] == 'y') { + if (s[2] == 'p') { + if (s[3] == 'e') { + if (s[4] == 'd') { + if (s[5] == 'e') { + if (s[6] == 'f') { + return Keyword_typedef; + } + } + } + } + } + } + } else if (s[0] == 'w') { + if (s[1] == 'c') { + if (s[2] == 'h') { + if (s[3] == 'a') { + if (s[4] == 'r') { + if (s[5] == '_') { + if (s[6] == 't') { + return Keyword_Ext_wchar_t; + } + } + } + } + } + } + } + return IdentifierToken; +} + +static inline SyntaxKind classify8(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_' && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { + if (s[2] == 'i') { + if (s[3] == 'n') { + if (s[4] == 'l') { + if (s[5] == 'i') { + if (s[6] == 'n') { + if (s[7] == 'e') { + return KeywordAlias___inline; + } + } + } + } + } else if (s[3] == 'm' && + opts.extensions().isEnabled_ExtGNU_Complex()) { + if (s[4] == 'a') { + if (s[5] == 'g') { + if (s[6] == '_') { + if (s[7] == '_') { + return Keyword_ExtGNU___imag__; + } + } + } + } + } + } else if (s[2] == 'f' && + opts.dialect().std() >= LanguageDialect::Std::C99) { + if (s[3] == 'u') { + if (s[4] == 'n') { + if (s[5] == 'c') { + if (s[6] == '_') { + if (s[7] == '_') { + return Keyword___func__; + } + } + } + } + } + } else if (s[2] == 't') { + if (s[3] == 'y') { + if (s[4] == 'p') { + if (s[5] == 'e') { + if (s[6] == 'o') { + if (s[7] == 'f') { + return KeywordAlias___typeof; + } + } + } + } + } else if (s[3] == 'h') { + if (s[4] == 'r') { + if (s[5] == 'e') { + if (s[6] == 'a') { + if (s[7] == 'd') { + return Keyword_ExtGNU___thread; + } + } + } + } + } + } else if (s[2] == 'r' && opts.extensions().isEnabled_ExtGNU_Complex()) { + if (s[3] == 'e') { + if (s[4] == 'a') { + if (s[5] == 'l') { + if (s[6] == '_') { + if (s[7] == '_') { + return Keyword_ExtGNU___real__; + } + } + } + } + } + } else if (s[2] == 's' && + opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { + if (s[3] == 'i') { + if (s[4] == 'g') { + if (s[5] == 'n') { + if (s[6] == 'e') { + if (s[7] == 'd') { + return KeywordAlias___signed; + } + } + } + } + } + } + } else if (s[1] == 'A' && + opts.dialect().std() >= LanguageDialect::Std::C11) { + if (s[2] == 'l') { + if (s[3] == 'i') { + if (s[4] == 'g') { + if (s[5] == 'n') { + if (s[6] == 'a') { + if (s[7] == 's') { + return Keyword__Alignas; + } + } else if (s[6] == 'o') { + if (s[7] == 'f') { + return Keyword__Alignof; + } + } + } + } + } + } + } else if (s[1] == 'C' && + opts.dialect().std() >= LanguageDialect::Std::C99) { + if (s[2] == 'o') { + if (s[3] == 'm') { + if (s[4] == 'p') { + if (s[5] == 'l') { + if (s[6] == 'e') { + if (s[7] == 'x') { + return Keyword__Complex; + } + } + } + } + } + } + } else if (s[1] == 'G' && + opts.dialect().std() >= LanguageDialect::Std::C11) { + if (s[2] == 'e') { + if (s[3] == 'n') { + if (s[4] == 'e') { + if (s[5] == 'r') { + if (s[6] == 'i') { + if (s[7] == 'c') { + return Keyword__Generic; + } + } + } + } + } + } + } + } else if (s[0] == 'c') { + if (s[1] == 'o') { + if (s[2] == 'n') { + if (s[3] == 't') { + if (s[4] == 'i') { + if (s[5] == 'n') { + if (s[6] == 'u') { + if (s[7] == 'e') { + return Keyword_continue; + } + } + } + } + } + } + } else if (s[1] == 'h') { + if (s[2] == 'a') { + if (s[3] == 'r') { + if (s[4] == '1') { + if (s[5] == '6') { + if (s[6] == '_') { + if (s[7] == 't') { + return Keyword_Ext_char16_t; + } + } + } + } else if (s[4] == '3') { + if (s[5] == '2') { + if (s[6] == '_') { + if (s[7] == 't') { + return Keyword_Ext_char32_t; + } + } + } + } + } + } + } + } else if (s[0] == 'o' && opts.extensions() + .translations() + .isEnabled_Translate_offsetof_AsKeyword()) { + if (s[1] == 'f') { + if (s[2] == 'f') { + if (s[3] == 's') { + if (s[4] == 'e') { + if (s[5] == 't') { + if (s[6] == 'o') { + if (s[7] == 'f') { + return Keyword_MacroStd_offsetof; + } + } + } + } + } + } + } + } else if (s[0] == 'r') { + if (s[1] == 'e') { + if (s[2] == 'g') { + if (s[3] == 'i') { + if (s[4] == 's') { + if (s[5] == 't') { + if (s[6] == 'e') { + if (s[7] == 'r') { + return Keyword_register; } + } } + } } - if (s[1] == '_') { - if (s[2] == 'c') { - if (s[3] == 'o') { - if (s[4] == 'n') { - if (s[5] == 's') { - if (s[6] == 't') { - if (s[7] == '_') { - if (s[8] == '_') { - return KeywordAlias___const__; - } - } - } - } - } + } else if (s[2] == 's') { + if (s[3] == 't') { + if (s[4] == 'r') { + if (s[5] == 'i') { + if (s[6] == 'c') { + if (s[7] == 't') { + return Keyword_restrict; } + } } - else if (s[2] == 'a' - && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { - if (s[3] == 'l') { - if (s[4] == 'i') { - if (s[5] == 'g') { - if (s[6] == 'n') { - if (s[7] == 'o') { - if (s[8] == 'f') { - return KeywordAlias___alignof; - } - } - else if (s[7] == 'a') { - if (s[8] == 's') { - return KeywordAlias___alignas; - } - } - } - } - } + } + } + } + } + } else if (s[0] == 'u') { + if (s[1] == 'n') { + if (s[2] == 's') { + if (s[3] == 'i') { + if (s[4] == 'g') { + if (s[5] == 'n') { + if (s[6] == 'e') { + if (s[7] == 'd') { + return Keyword_unsigned; } + } } + } } - else if(s[1] == 'T' - && opts.extensions().isEnabled_ExtPSY_Generics()) { - if (s[2] == 'e') { - if (s[3] == 'm') { - if (s[4] == 'p') { - if (s[5] == 'l') { - if (s[6] == 'a') { - if (s[7] == 't') { - if (s[8] == 'e') { - return Keyword_ExtPSY__Template; - } - } - } - } - } + } + } + } else if (s[0] == 'v') { + if (s[1] == 'o') { + if (s[2] == 'l') { + if (s[3] == 'a') { + if (s[4] == 't') { + if (s[5] == 'i') { + if (s[6] == 'l') { + if (s[7] == 'e') { + return Keyword_volatile; } + } } + } } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify10(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_') { - if (s[2] == 'i') { - if (s[3] == 'n') { - if (s[4] == 'l') { - if (s[5] == 'i') { - if (s[6] == 'n') { - if (s[7] == 'e') { - if (s[8] == '_') { - if (s[9] == '_') { - return KeywordAlias___inline__; - } - } - } - } - } - } - } - } - else if (s[2] == 'r') { - if (s[3] == 'e') { - if (s[4] == 's') { - if (s[5] == 't') { - if (s[6] == 'r') { - if (s[7] == 'i') { - if (s[8] == 'c') { - if (s[9] == 't') { - return KeywordAlias___restrict; - } - } - } - } - } - } - } - } - else if (s[2] == 't') { - if (s[3] == 'y') { - if (s[4] == 'p') { - if (s[5] == 'e') { - if (s[6] == 'o') { - if (s[7] == 'f') { - if (s[8] == '_') { - if (s[9] == '_') { - return Keyword_ExtGNU___typeof__; - } - } - } - } - } - } - } - } - else if (s[2] == 's' - && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { - if (s[3] == 'i') { - if (s[4] == 'g') { - if (s[5] == 'n') { - if (s[6] == 'e') { - if (s[7] == 'd') { - if (s[8] == '_') { - if (s[9] == '_') { - return KeywordAlias___signed__; - } - } - } - } - } - } - } - } - else if (s[2] == 'v') { - if (s[3] == 'o') { - if (s[4] == 'l') { - if (s[5] == 'a') { - if (s[6] == 't') { - if (s[7] == 'i') { - if (s[8] == 'l') { - if (s[9] == 'e') { - return KeywordAlias___volatile; - } - } - } - } - } - } - } - } - } +static inline SyntaxKind classify9(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == 'N' && opts.dialect().std() >= LanguageDialect::Std::C11) { + if (s[2] == 'o') { + if (s[3] == 'r') { + if (s[4] == 'e') { + if (s[5] == 't') { + if (s[6] == 'u') { + if (s[7] == 'r') { + if (s[8] == 'n') { + return Keyword__Noreturn; + } + } + } + } + } + } + } } - return IdentifierToken; + if (s[1] == '_') { + if (s[2] == 'c') { + if (s[3] == 'o') { + if (s[4] == 'n') { + if (s[5] == 's') { + if (s[6] == 't') { + if (s[7] == '_') { + if (s[8] == '_') { + return KeywordAlias___const__; + } + } + } + } + } + } + } else if (s[2] == 'a' && + opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { + if (s[3] == 'l') { + if (s[4] == 'i') { + if (s[5] == 'g') { + if (s[6] == 'n') { + if (s[7] == 'o') { + if (s[8] == 'f') { + return KeywordAlias___alignof; + } + } else if (s[7] == 'a') { + if (s[8] == 's') { + return KeywordAlias___alignas; + } + } + } + } + } + } + } + } else if (s[1] == 'T' && opts.extensions().isEnabled_ExtPSY_Generics()) { + if (s[2] == 'e') { + if (s[3] == 'm') { + if (s[4] == 'p') { + if (s[5] == 'l') { + if (s[6] == 'a') { + if (s[7] == 't') { + if (s[8] == 'e') { + return Keyword_ExtPSY__Template; + } + } + } + } + } + } + } + } + } + return IdentifierToken; } -static inline SyntaxKind classify11(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_') { - if (s[2] == 'a') { - if (s[3] == 't') { - if (s[4] == 't') { - if (s[5] == 'r') { - if (s[6] == 'i') { - if (s[7] == 'b') { - if (s[8] == 'u') { - if (s[9] == 't') { - if (s[10] == 'e') { - return KeywordAlias___attribute; - } - } - } - } - } - } - } - } - else if (s[3] == 'l') { - if (s[4] == 'i') { - if (s[5] == 'g') { - if (s[6] == 'n') { - if (s[7] == 'o') { - if (s[8] == 'f') { - if (s[9] == '_') { - if (s[10] == '_') { - return KeywordAlias___alignof__; - } - } - } - } - } - } - } - } - } - else if (s[2] == 'c' - && opts.extensions().isEnabled_ExtGNU_Complex()) { - if (s[3] == 'o') { - if (s[4] == 'm') { - if (s[5] == 'p') { - if (s[6] == 'l') { - if (s[7] == 'e') { - if (s[8] == 'x') { - if (s[9] == '_') { - if (s[10] == '_') { - return Keyword_ExtGNU___complex__; - } - } - } - } - } - } - } - } - } - } +static inline SyntaxKind classify10(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_') { + if (s[2] == 'i') { + if (s[3] == 'n') { + if (s[4] == 'l') { + if (s[5] == 'i') { + if (s[6] == 'n') { + if (s[7] == 'e') { + if (s[8] == '_') { + if (s[9] == '_') { + return KeywordAlias___inline__; + } + } + } + } + } + } + } + } else if (s[2] == 'r') { + if (s[3] == 'e') { + if (s[4] == 's') { + if (s[5] == 't') { + if (s[6] == 'r') { + if (s[7] == 'i') { + if (s[8] == 'c') { + if (s[9] == 't') { + return KeywordAlias___restrict; + } + } + } + } + } + } + } + } else if (s[2] == 't') { + if (s[3] == 'y') { + if (s[4] == 'p') { + if (s[5] == 'e') { + if (s[6] == 'o') { + if (s[7] == 'f') { + if (s[8] == '_') { + if (s[9] == '_') { + return Keyword_ExtGNU___typeof__; + } + } + } + } + } + } + } + } else if (s[2] == 's' && + opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { + if (s[3] == 'i') { + if (s[4] == 'g') { + if (s[5] == 'n') { + if (s[6] == 'e') { + if (s[7] == 'd') { + if (s[8] == '_') { + if (s[9] == '_') { + return KeywordAlias___signed__; + } + } + } + } + } + } + } + } else if (s[2] == 'v') { + if (s[3] == 'o') { + if (s[4] == 'l') { + if (s[5] == 'a') { + if (s[6] == 't') { + if (s[7] == 'i') { + if (s[8] == 'l') { + if (s[9] == 'e') { + return KeywordAlias___volatile; + } + } + } + } + } + } + } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify12(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_' - && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { - if (s[2] == 'v') { - if (s[3] == 'o') { - if (s[4] == 'l') { - if (s[5] == 'a') { - if (s[6] == 't') { - if (s[7] == 'i') { - if (s[8] == 'l') { - if (s[9] == 'e') { - if (s[10] == '_') { - if (s[11] == '_') { - return KeywordAlias___volatile__; - } - } - } - } - } - } - } - } - } - } - else if (s[2] == 'r') { - if (s[3] == 'e') { - if (s[4] == 's') { - if (s[5] == 't') { - if (s[6] == 'r') { - if (s[7] == 'i') { - if (s[8] == 'c') { - if (s[9] == 't') { - if (s[10] == '_') { - if (s[11] == '_') { - return KeywordAlias___restrict__; - } - } - } - } - } - } - } - } - } - } - else if (s[2] == 'F' - && opts.extensions().isEnabled_ExtGNU_FunctionNames()) { - if (s[3] == 'U') { - if (s[4] == 'N') { - if (s[5] == 'C') { - if (s[6] == 'T') { - if (s[7] == 'I') { - if (s[8] == 'O') { - if (s[9] == 'N') { - if (s[10] == '_') { - if (s[11] == '_') { - return Keyword_ExtGNU___FUNCTION__; - } - } - } - } - } - } - } - } - } - } - } - else if (s[1] == 't' - && opts.extensions().translations().isEnabled_Translate_thread_local_AsKeyword()) { - if (s[2] == 'h') { - if (s[3] == 'r') { - if (s[4] == 'e') { - if (s[5] == 'a') { - if (s[6] == 'd') { - if (s[7] == '_') { - if (s[8] == 'l') { - if (s[9] == 'o') { - if (s[10] == 'c') { - if (s[11] == 'a') { - if (s[12] == 'l') { - return Keyword__Thread_local; - } - } - } - } - } - } - } - } - } - } - } - } +static inline SyntaxKind classify11(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_') { + if (s[2] == 'a') { + if (s[3] == 't') { + if (s[4] == 't') { + if (s[5] == 'r') { + if (s[6] == 'i') { + if (s[7] == 'b') { + if (s[8] == 'u') { + if (s[9] == 't') { + if (s[10] == 'e') { + return KeywordAlias___attribute; + } + } + } + } + } + } + } + } else if (s[3] == 'l') { + if (s[4] == 'i') { + if (s[5] == 'g') { + if (s[6] == 'n') { + if (s[7] == 'o') { + if (s[8] == 'f') { + if (s[9] == '_') { + if (s[10] == '_') { + return KeywordAlias___alignof__; + } + } + } + } + } + } + } + } + } else if (s[2] == 'c' && opts.extensions().isEnabled_ExtGNU_Complex()) { + if (s[3] == 'o') { + if (s[4] == 'm') { + if (s[5] == 'p') { + if (s[6] == 'l') { + if (s[7] == 'e') { + if (s[8] == 'x') { + if (s[9] == '_') { + if (s[10] == '_') { + return Keyword_ExtGNU___complex__; + } + } + } + } + } + } + } + } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify13(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_' - && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { - if (s[2] == 'a') { - if (s[3] == 't') { - if (s[4] == 't') { - if (s[5] == 'r') { - if (s[6] == 'i') { - if (s[7] == 'b') { - if (s[8] == 'u') { - if (s[9] == 't') { - if (s[10] == 'e') { - if (s[11] == '_') { - if (s[12] == '_') { - return Keyword_ExtGNU___attribute__; - } - } - } - } - } - } - } - } - } - } - } - else if (s[2] == 'e' - && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { - if (s[3] == 'x') { - if (s[4] == 't') { - if (s[5] == 'e') { - if (s[6] == 'n') { - if (s[7] == 's') { - if (s[8] == 'i') { - if (s[9] == 'o') { - if (s[10] == 'n') { - if (s[11] == '_') { - if (s[12] == '_') { - return Keyword_ExtGNU___extension__; - } - } - } - } - } - } - } - } - } - } - } - } - else if (s[1] == 'T' - && opts.dialect().std() >= LanguageDialect::Std::C11) { - if (s[2] == 'h') { - if (s[3] == 'r') { - if (s[4] == 'e') { - if (s[5] == 'a') { - if (s[6] == 'd') { - if (s[7] == '_') { - if (s[8] == 'l') { - if (s[9] == 'o') { - if (s[10] == 'c') { - if (s[11] == 'a') { - if (s[12] == 'l') { - return Keyword__Thread_local; - } - } - } - } - } - } - } - } - } - } - } - } +static inline SyntaxKind classify12(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_' && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { + if (s[2] == 'v') { + if (s[3] == 'o') { + if (s[4] == 'l') { + if (s[5] == 'a') { + if (s[6] == 't') { + if (s[7] == 'i') { + if (s[8] == 'l') { + if (s[9] == 'e') { + if (s[10] == '_') { + if (s[11] == '_') { + return KeywordAlias___volatile__; + } + } + } + } + } + } + } + } + } + } else if (s[2] == 'r') { + if (s[3] == 'e') { + if (s[4] == 's') { + if (s[5] == 't') { + if (s[6] == 'r') { + if (s[7] == 'i') { + if (s[8] == 'c') { + if (s[9] == 't') { + if (s[10] == '_') { + if (s[11] == '_') { + return KeywordAlias___restrict__; + } + } + } + } + } + } + } + } + } + } else if (s[2] == 'F' && + opts.extensions().isEnabled_ExtGNU_FunctionNames()) { + if (s[3] == 'U') { + if (s[4] == 'N') { + if (s[5] == 'C') { + if (s[6] == 'T') { + if (s[7] == 'I') { + if (s[8] == 'O') { + if (s[9] == 'N') { + if (s[10] == '_') { + if (s[11] == '_') { + return Keyword_ExtGNU___FUNCTION__; + } + } + } + } + } + } + } + } + } + } + } else if (s[1] == 't' && + opts.extensions() + .translations() + .isEnabled_Translate_thread_local_AsKeyword()) { + if (s[2] == 'h') { + if (s[3] == 'r') { + if (s[4] == 'e') { + if (s[5] == 'a') { + if (s[6] == 'd') { + if (s[7] == '_') { + if (s[8] == 'l') { + if (s[9] == 'o') { + if (s[10] == 'c') { + if (s[11] == 'a') { + if (s[12] == 'l') { + return Keyword__Thread_local; + } + } + } + } + } + } + } + } + } + } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify14(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_' - && opts.dialect().std() >= LanguageDialect::Std::C11) { - if (s[1] == 'S') { - if (s[2] == 't') { - if (s[3] == 'a') { - if (s[4] == 't') { - if (s[5] == 'i') { - if (s[6] == 'c') { - if (s[7] == '_') { - if (s[8] == 'a') { - if (s[9] == 's') { - if (s[10] == 's') { - if (s[11] == 'e') { - if (s[12] == 'r') { - if (s[13] == 't') { - return Keyword__Static_assert; - } - } - } - } - } - } - } +static inline SyntaxKind classify13(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_' && opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { + if (s[2] == 'a') { + if (s[3] == 't') { + if (s[4] == 't') { + if (s[5] == 'r') { + if (s[6] == 'i') { + if (s[7] == 'b') { + if (s[8] == 'u') { + if (s[9] == 't') { + if (s[10] == 'e') { + if (s[11] == '_') { + if (s[12] == '_') { + return Keyword_ExtGNU___attribute__; + } + } + } + } + } + } + } + } + } + } + } else if (s[2] == 'e' && + opts.extensions().isEnabled_ExtGNU_AlternateKeywords()) { + if (s[3] == 'x') { + if (s[4] == 't') { + if (s[5] == 'e') { + if (s[6] == 'n') { + if (s[7] == 's') { + if (s[8] == 'i') { + if (s[9] == 'o') { + if (s[10] == 'n') { + if (s[11] == '_') { + if (s[12] == '_') { + return Keyword_ExtGNU___extension__; + } + } + } + } + } + } + } + } + } + } + } + } else if (s[1] == 'T' && + opts.dialect().std() >= LanguageDialect::Std::C11) { + if (s[2] == 'h') { + if (s[3] == 'r') { + if (s[4] == 'e') { + if (s[5] == 'a') { + if (s[6] == 'd') { + if (s[7] == '_') { + if (s[8] == 'l') { + if (s[9] == 'o') { + if (s[10] == 'c') { + if (s[11] == 'a') { + if (s[12] == 'l') { + return Keyword__Thread_local; + } + } + } + } + } + } + } + } + } + } + } + } + } + return IdentifierToken; +} + +static inline SyntaxKind classify14(const char *s, const ParseOptions &opts) { + if (s[0] == '_' && opts.dialect().std() >= LanguageDialect::Std::C11) { + if (s[1] == 'S') { + if (s[2] == 't') { + if (s[3] == 'a') { + if (s[4] == 't') { + if (s[5] == 'i') { + if (s[6] == 'c') { + if (s[7] == '_') { + if (s[8] == 'a') { + if (s[9] == 's') { + if (s[10] == 's') { + if (s[11] == 'e') { + if (s[12] == 'r') { + if (s[13] == 't') { + return Keyword__Static_assert; } + } } + } } - + } } + } } + } } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify15(const char* s, const ParseOptions& opts) -{ - return IdentifierToken; +static inline SyntaxKind classify15(const char *s, const ParseOptions &opts) { + return IdentifierToken; } -static inline SyntaxKind classify16(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_' - && opts.extensions().isEnabled_ExtGNU_InternalBuiltins()) { - if (s[1] == '_') { - if (s[2] == 'b') { - if (s[3] == 'u') { - if (s[4] == 'i') { - if (s[5] == 'l') { - if (s[6] == 't') { - if (s[7] == 'i') { - if (s[8] == 'n') { - if (s[9] == '_') { - if (s[10] == 'v') { - if (s[11] == 'a') { - if (s[12] == '_') { - if (s[13] == 'a') { - if (s[14] == 'r') { - if (s[15] == 'g') { - return Keyword_ExtGNU___builtin_va_arg; - } - } - } - } - } - } - } - } +static inline SyntaxKind classify16(const char *s, const ParseOptions &opts) { + if (s[0] == '_' && opts.extensions().isEnabled_ExtGNU_InternalBuiltins()) { + if (s[1] == '_') { + if (s[2] == 'b') { + if (s[3] == 'u') { + if (s[4] == 'i') { + if (s[5] == 'l') { + if (s[6] == 't') { + if (s[7] == 'i') { + if (s[8] == 'n') { + if (s[9] == '_') { + if (s[10] == 'v') { + if (s[11] == 'a') { + if (s[12] == '_') { + if (s[13] == 'a') { + if (s[14] == 'r') { + if (s[15] == 'g') { + return Keyword_ExtGNU___builtin_va_arg; } + } } - } - } - } - } - } - else if (s[1] == '_') { - if (s[2] == 'b') { - if (s[3] == 'u') { - if (s[4] == 'i') { - if (s[5] == 'l') { - if (s[6] == 't') { - if (s[7] == 'i') { - if (s[8] == 'n') { - if (s[9] == '_') { - if (s[10] == 't') { - if (s[11] == 'g') { - if (s[12] == 'm') { - if (s[13] == 'a') { - if (s[14] == 't') { - if (s[15] == 'h') { - return Keyword_ExtGNU___builtin_tgmath; - } - } - } - } - } - } - } - } + } + } + } + } + } + } + } + } + } + } + } + } else if (s[1] == '_') { + if (s[2] == 'b') { + if (s[3] == 'u') { + if (s[4] == 'i') { + if (s[5] == 'l') { + if (s[6] == 't') { + if (s[7] == 'i') { + if (s[8] == 'n') { + if (s[9] == '_') { + if (s[10] == 't') { + if (s[11] == 'g') { + if (s[12] == 'm') { + if (s[13] == 'a') { + if (s[14] == 't') { + if (s[15] == 'h') { + return Keyword_ExtGNU___builtin_tgmath; } + } } + } } + } } + } } + } } + } } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify17(const char* s, const ParseOptions& opts) -{ - return IdentifierToken; +static inline SyntaxKind classify17(const char *s, const ParseOptions &opts) { + return IdentifierToken; } -static inline SyntaxKind classify18(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_' - && opts.extensions().isEnabled_ExtGNU_InternalBuiltins()) { - if (s[1] == '_') { - if (s[2] == 'b') { - if (s[3] == 'u') { - if (s[4] == 'i') { - if (s[5] == 'l') { - if (s[6] == 't') { - if (s[7] == 'i') { - if (s[8] == 'n') { - if (s[9] == '_') { - if (s[10] == 'o') { - if (s[11] == 'f') { - if (s[12] == 'f') { - if (s[13] == 's') { - if (s[14] == 'e') { - if (s[15] == 't') { - if (s[16] == 'o') { - if (s[17] == 'f') { - return Keyword_ExtGNU___builtin_offsetof; - } - } - } - } - } - } - } - } - } +static inline SyntaxKind classify18(const char *s, const ParseOptions &opts) { + if (s[0] == '_' && opts.extensions().isEnabled_ExtGNU_InternalBuiltins()) { + if (s[1] == '_') { + if (s[2] == 'b') { + if (s[3] == 'u') { + if (s[4] == 'i') { + if (s[5] == 'l') { + if (s[6] == 't') { + if (s[7] == 'i') { + if (s[8] == 'n') { + if (s[9] == '_') { + if (s[10] == 'o') { + if (s[11] == 'f') { + if (s[12] == 'f') { + if (s[13] == 's') { + if (s[14] == 'e') { + if (s[15] == 't') { + if (s[16] == 'o') { + if (s[17] == 'f') { + return Keyword_ExtGNU___builtin_offsetof; } + } } + } } + } } + } } + } } + } } + } } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classify19(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_') { - if (s[2] == 'P' - && opts.extensions().isEnabled_ExtGNU_FunctionNames()) { - if (s[3] == 'R') { - if (s[4] == 'E') { - if (s[5] == 'T') { - if (s[6] == 'T') { - if (s[7] == 'Y') { - if (s[8] == '_') { - if (s[9] == 'F') { - if (s[10] == 'U') { - if (s[11] == 'N') { - if (s[12] == 'C') { - if (s[13] == 'T') { - if (s[14] == 'I') { - if (s[15] == 'O') { - if (s[16] == 'N') { - if (s[17] == '_') { - if (s[18] == '_') { - return Keyword_ExtGNU___PRETTY_FUNCTION__; - } - } - } - } - } - } - } - } - } - } +static inline SyntaxKind classify19(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_') { + if (s[2] == 'P' && opts.extensions().isEnabled_ExtGNU_FunctionNames()) { + if (s[3] == 'R') { + if (s[4] == 'E') { + if (s[5] == 'T') { + if (s[6] == 'T') { + if (s[7] == 'Y') { + if (s[8] == '_') { + if (s[9] == 'F') { + if (s[10] == 'U') { + if (s[11] == 'N') { + if (s[12] == 'C') { + if (s[13] == 'T') { + if (s[14] == 'I') { + if (s[15] == 'O') { + if (s[16] == 'N') { + if (s[17] == '_') { + if (s[18] == '_') { + return Keyword_ExtGNU___PRETTY_FUNCTION__; + } } + } } + } } + } } + } } + } } + } } + } } + } } + } - return IdentifierToken; + return IdentifierToken; } -static inline SyntaxKind classify21(const char* s, const ParseOptions& opts) -{ - if (s[0] == '_') { - if (s[1] == '_') { - if (s[2] == 'b' - && opts.extensions().isEnabled_ExtGNU_InternalBuiltins()) { - if (s[3] == 'u') { - if (s[4] == 'i') { - if (s[5] == 'l') { - if (s[6] == 't') { - if (s[7] == 'i') { - if (s[8] == 'n') { - if (s[9] == '_') { - if (s[10] == 'c') { - if (s[11] == 'h') { - if (s[12] == 'o') { - if (s[13] == 'o') { - if (s[14] == 's') { - if (s[15] == 'e') { - if (s[16] == '_') { - if (s[17] == 'e') { - if (s[18] == 'x') { - if (s[19] == 'p') { - if (s[20] == 'r') { - return Keyword_ExtGNU___builtin_choose_expr; - } - } - } - } - } - } - } - } - } - } - } +static inline SyntaxKind classify21(const char *s, const ParseOptions &opts) { + if (s[0] == '_') { + if (s[1] == '_') { + if (s[2] == 'b' && + opts.extensions().isEnabled_ExtGNU_InternalBuiltins()) { + if (s[3] == 'u') { + if (s[4] == 'i') { + if (s[5] == 'l') { + if (s[6] == 't') { + if (s[7] == 'i') { + if (s[8] == 'n') { + if (s[9] == '_') { + if (s[10] == 'c') { + if (s[11] == 'h') { + if (s[12] == 'o') { + if (s[13] == 'o') { + if (s[14] == 's') { + if (s[15] == 'e') { + if (s[16] == '_') { + if (s[17] == 'e') { + if (s[18] == 'x') { + if (s[19] == 'p') { + if (s[20] == 'r') { + return Keyword_ExtGNU___builtin_choose_expr; + } } + } } + } } + } } + } } + } } + } } + } } + } } + } } - return IdentifierToken; + } + return IdentifierToken; } -SyntaxKind Lexer::classify(const char* s, int n, const ParseOptions& opts) -{ - switch (n) { - case 2: return classify2(s, opts); - case 3: return classify3(s, opts); - case 4: return classify4(s, opts); - case 5: return classify5(s, opts); - case 6: return classify6(s, opts); - case 7: return classify7(s, opts); - case 8: return classify8(s, opts); - case 9: return classify9(s, opts); - case 10: return classify10(s, opts); - case 11: return classify11(s, opts); - case 12: return classify12(s, opts); - case 13: return classify13(s, opts); - case 14: return classify14(s, opts); - case 15: return classify15(s, opts); - case 16: return classify16(s, opts); - case 17: return classify17(s, opts); - case 18: return classify18(s, opts); - case 19: return classify19(s, opts); - case 21: return classify21(s, opts); - default: return IdentifierToken; - } +SyntaxKind Lexer::classify(const char *s, int n, const ParseOptions &opts) { + switch (n) { + case 2: + return classify2(s, opts); + case 3: + return classify3(s, opts); + case 4: + return classify4(s, opts); + case 5: + return classify5(s, opts); + case 6: + return classify6(s, opts); + case 7: + return classify7(s, opts); + case 8: + return classify8(s, opts); + case 9: + return classify9(s, opts); + case 10: + return classify10(s, opts); + case 11: + return classify11(s, opts); + case 12: + return classify12(s, opts); + case 13: + return classify13(s, opts); + case 14: + return classify14(s, opts); + case 15: + return classify15(s, opts); + case 16: + return classify16(s, opts); + case 17: + return classify17(s, opts); + case 18: + return classify18(s, opts); + case 19: + return classify19(s, opts); + case 21: + return classify21(s, opts); + default: + return IdentifierToken; + } } -static inline SyntaxKind classifyOperator2(const char* s) -{ - if (s[0] == 'o') { - if (s[1] == 'r') { - return OperatorName_ORToken; - } +static inline SyntaxKind classifyOperator2(const char *s) { + if (s[0] == 'o') { + if (s[1] == 'r') { + return OperatorName_ORToken; } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classifyOperator3(const char* s) -{ - if (s[0] == 'a') { - if (s[1] == 'n') { - if (s[2] == 'd') { - return OperatorName_ANDToken; - } - } +static inline SyntaxKind classifyOperator3(const char *s) { + if (s[0] == 'a') { + if (s[1] == 'n') { + if (s[2] == 'd') { + return OperatorName_ANDToken; + } } - else if (s[0] == 'n') { - if (s[1] == 'o') { - if (s[2] == 't') { - return OperatorName_NOTToken; - } - } + } else if (s[0] == 'n') { + if (s[1] == 'o') { + if (s[2] == 't') { + return OperatorName_NOTToken; + } } - else if (s[0] == 'x') { - if (s[1] == 'o') { - if (s[2] == 'r') { - return OperatorName_XORToken; - } - } + } else if (s[0] == 'x') { + if (s[1] == 'o') { + if (s[2] == 'r') { + return OperatorName_XORToken; + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classifyOperator5(const char* s) -{ - if (s[0] == 'b') { - if (s[1] == 'i') { - if (s[2] == 't') { - if (s[3] == 'o') { - if (s[4] == 'r') { - return OperatorName_BITORToken; - } - } - } - } +static inline SyntaxKind classifyOperator5(const char *s) { + if (s[0] == 'b') { + if (s[1] == 'i') { + if (s[2] == 't') { + if (s[3] == 'o') { + if (s[4] == 'r') { + return OperatorName_BITORToken; + } + } + } } - else if (s[0] == 'c') { - if (s[1] == 'o') { - if (s[2] == 'm') { - if (s[3] == 'p') { - if (s[4] == 'l') { - return OperatorName_COMPLToken; - } - } - } - } + } else if (s[0] == 'c') { + if (s[1] == 'o') { + if (s[2] == 'm') { + if (s[3] == 'p') { + if (s[4] == 'l') { + return OperatorName_COMPLToken; + } + } + } } - else if (s[0] == 'o') { - if (s[1] == 'r') { - if (s[2] == '_') { - if (s[3] == 'e') { - if (s[4] == 'q') { - return OperatorName_OREQToken; - } - } - } - } + } else if (s[0] == 'o') { + if (s[1] == 'r') { + if (s[2] == '_') { + if (s[3] == 'e') { + if (s[4] == 'q') { + return OperatorName_OREQToken; + } + } + } } - return IdentifierToken; + } + return IdentifierToken; } -static inline SyntaxKind classifyOperator6(const char* s) -{ - if (s[0] == 'a') { - if (s[1] == 'n') { - if (s[2] == 'd') { - if (s[3] == '_') { - if (s[4] == 'e') { - if (s[5] == 'q') { - return OperatorName_ANDEQToken; - } - } - } - } - } +static inline SyntaxKind classifyOperator6(const char *s) { + if (s[0] == 'a') { + if (s[1] == 'n') { + if (s[2] == 'd') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return OperatorName_ANDEQToken; + } + } + } + } } - else if (s[0] == 'b') { - if (s[1] == 'i') { - if (s[2] == 't') { - if (s[3] == 'a') { - if (s[4] == 'n') { - if (s[5] == 'd') { - return OperatorName_BITANDToken; - } - } - } + } else if (s[0] == 'b') { + if (s[1] == 'i') { + if (s[2] == 't') { + if (s[3] == 'a') { + if (s[4] == 'n') { + if (s[5] == 'd') { + return OperatorName_BITANDToken; } + } } + } } - else if (s[0] == 'n') { - if (s[1] == 'o') { - if (s[2] == 't') { - if (s[3] == '_') { - if (s[4] == 'e') { - if (s[5] == 'q') { - return OperatorName_NOTEQToken; - } - } - } + } else if (s[0] == 'n') { + if (s[1] == 'o') { + if (s[2] == 't') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return OperatorName_NOTEQToken; } + } } + } } - else if (s[0] == 'x') { - if (s[1] == 'o') { - if (s[2] == 'r') { - if (s[3] == '_') { - if (s[4] == 'e') { - if (s[5] == 'q') { - return OperatorName_XOREQToken; - } - } - } + } else if (s[0] == 'x') { + if (s[1] == 'o') { + if (s[2] == 'r') { + if (s[3] == '_') { + if (s[4] == 'e') { + if (s[5] == 'q') { + return OperatorName_XOREQToken; } + } } + } } - return IdentifierToken; + } + return IdentifierToken; } -SyntaxKind Lexer::classifyOperator(const char* s, int n, const ParseOptions& opts) -{ - if (!opts.extensions().translations().isEnabled_Translate_operatorNames()) - return IdentifierToken; +SyntaxKind Lexer::classifyOperator(const char *s, int n, + const ParseOptions &opts) { + if (!opts.extensions().translations().isEnabled_Translate_operatorNames()) + return IdentifierToken; - switch (n) { - case 2: return classifyOperator2(s); - case 3: return classifyOperator3(s); - case 5: return classifyOperator5(s); - case 6: return classifyOperator6(s); - default: return IdentifierToken; - } + switch (n) { + case 2: + return classifyOperator2(s); + case 3: + return classifyOperator3(s); + case 5: + return classifyOperator5(s); + case 6: + return classifyOperator6(s); + default: + return IdentifierToken; + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/parser/LanguageDialect.cpp b/C/parser/LanguageDialect.cpp index b34550646..1fc1cc3fc 100644 --- a/C/parser/LanguageDialect.cpp +++ b/C/parser/LanguageDialect.cpp @@ -28,57 +28,50 @@ namespace psy { namespace C { -bool operator==(LanguageDialect::Std a, LanguageDialect::Std b) -{ - return std::underlying_type::type(a) - == std::underlying_type::type(b); +bool operator==(LanguageDialect::Std a, LanguageDialect::Std b) { + return std::underlying_type::type(a) == + std::underlying_type::type(b); } -bool operator!=(LanguageDialect::Std a, LanguageDialect::Std b) -{ - return !(a == b); +bool operator!=(LanguageDialect::Std a, LanguageDialect::Std b) { + return !(a == b); } -bool operator<(LanguageDialect::Std a, LanguageDialect::Std b) -{ - return std::underlying_type::type(a) - < std::underlying_type::type(b); +bool operator<(LanguageDialect::Std a, LanguageDialect::Std b) { + return std::underlying_type::type(a) < + std::underlying_type::type(b); } -bool operator<=(LanguageDialect::Std a, LanguageDialect::Std b) -{ - return a < b || a == b; +bool operator<=(LanguageDialect::Std a, LanguageDialect::Std b) { + return a < b || a == b; } -bool operator>(LanguageDialect::Std a, LanguageDialect::Std b) -{ - return !(a < b) && !(a == b); +bool operator>(LanguageDialect::Std a, LanguageDialect::Std b) { + return !(a < b) && !(a == b); } -bool operator>=(LanguageDialect::Std a, LanguageDialect::Std b) -{ - return !(a < b); +bool operator>=(LanguageDialect::Std a, LanguageDialect::Std b) { + return !(a < b); } -std::string to_string(LanguageDialect::Std std) -{ - switch (std) { - case LanguageDialect::Std::C89_90: - return "c89"; +std::string to_string(LanguageDialect::Std std) { + switch (std) { + case LanguageDialect::Std::C89_90: + return "c89"; - case LanguageDialect::Std::C99: - return "c99"; + case LanguageDialect::Std::C99: + return "c99"; - case LanguageDialect::Std::C11: - return "c11"; + case LanguageDialect::Std::C11: + return "c11"; - case LanguageDialect::Std::C17_18: - return "c17"; + case LanguageDialect::Std::C17_18: + return "c17"; - default: - PSY_ASSERT_W_MSG(false, return "", ""); - } + default: + PSY_ASSERT_W_MSG(false, return "", ""); + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/parser/LanguageDialect.h b/C/parser/LanguageDialect.h index 3a11261d6..5570f6be0 100644 --- a/C/parser/LanguageDialect.h +++ b/C/parser/LanguageDialect.h @@ -38,33 +38,25 @@ namespace C { * The C dialectd, based on the Standard version: C89/90, C99, C11, or C17/18. * * \note - * Additional information at https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html. + * Additional information at + * https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html. */ -class PSY_C_API LanguageDialect -{ +class PSY_C_API LanguageDialect { public: - /** - * \brief The C Standard enumeration. - */ - enum class Std : std::uint8_t - { - C89_90, - C99, - C11, - C17_18 - }; + /** + * \brief The C Standard enumeration. + */ + enum class Std : std::uint8_t { C89_90, C99, C11, C17_18 }; - LanguageDialect(Std std = Std::C11) - : std_(std) - {} + LanguageDialect(Std std = Std::C11) : std_(std) {} - /** - * The C Standard of \c this LanguageDialect. - */ - Std std() const { return std_; } + /** + * The C Standard of \c this LanguageDialect. + */ + Std std() const { return std_; } private: - Std std_; + Std std_; }; bool PSY_C_API operator==(LanguageDialect::Std a, LanguageDialect::Std b); @@ -76,7 +68,7 @@ bool PSY_C_API operator>=(LanguageDialect::Std a, LanguageDialect::Std b); std::string PSY_C_API to_string(LanguageDialect::Std std); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/LanguageExtensions.cpp b/C/parser/LanguageExtensions.cpp index d0459ba70..cbd8e36d3 100644 --- a/C/parser/LanguageExtensions.cpp +++ b/C/parser/LanguageExtensions.cpp @@ -25,36 +25,33 @@ #include -#define DEFINE_ENABLE_ISENABLED(FLAG) \ - LanguageExtensions& LanguageExtensions::enable_##FLAG(bool enable) \ - { BF_.FLAG##_ = enable; return *this; } \ - bool LanguageExtensions::isEnabled_##FLAG() const \ - { return BF_.FLAG##_; } +#define DEFINE_ENABLE_ISENABLED(FLAG) \ + LanguageExtensions &LanguageExtensions::enable_##FLAG(bool enable) { \ + BF_.FLAG##_ = enable; \ + return *this; \ + } \ + bool LanguageExtensions::isEnabled_##FLAG() const { return BF_.FLAG##_; } using namespace psy; using namespace C; LanguageExtensions::LanguageExtensions() - : LanguageExtensions(MacroTranslations()) -{} + : LanguageExtensions(MacroTranslations()) {} LanguageExtensions::LanguageExtensions(MacroTranslations translations) - : translations_(std::move(translations)) - , BF_all_(~0) -{ - /* Psyche */ - BF_.ExtPSY_Generics_ = false; + : translations_(std::move(translations)), BF_all_(~0) { + /* Psyche */ + BF_.ExtPSY_Generics_ = false; - /* C++ */ - BF_.CPP_nullptr_ = false; + /* C++ */ + BF_.CPP_nullptr_ = false; - /* Custom */ - BF_.NativeBooleans_ = false; + /* Custom */ + BF_.NativeBooleans_ = false; } -const MacroTranslations& LanguageExtensions::translations() const -{ - return translations_; +const MacroTranslations &LanguageExtensions::translations() const { + return translations_; } DEFINE_ENABLE_ISENABLED(ExtGNU_AlternateKeywords) @@ -82,65 +79,64 @@ DEFINE_ENABLE_ISENABLED(NULLAsBuiltin) namespace psy { namespace C { -std::string PSY_C_API to_string(LanguageExtensions::Ext ext) -{ - switch (ext) { - /* GNU */ - case LanguageExtensions::Ext::GNU_AlternateKeywords: - return "GNU Alternate Keywords"; +std::string PSY_C_API to_string(LanguageExtensions::Ext ext) { + switch (ext) { + /* GNU */ + case LanguageExtensions::Ext::GNU_AlternateKeywords: + return "GNU Alternate Keywords"; - case LanguageExtensions::Ext::GNU_AttributeSpecifiers: - return "GNU Attribute Specifiers"; + case LanguageExtensions::Ext::GNU_AttributeSpecifiers: + return "GNU Attribute Specifiers"; - case LanguageExtensions::Ext::GNU_Alignment: - return "GNU Alignment"; + case LanguageExtensions::Ext::GNU_Alignment: + return "GNU Alignment"; - case LanguageExtensions::Ext::GNU_CompoundLiterals: - return "GNU Compound Literals"; + case LanguageExtensions::Ext::GNU_CompoundLiterals: + return "GNU Compound Literals"; - case LanguageExtensions::Ext::GNU_Conditionals: - return "GNU Conditionals"; + case LanguageExtensions::Ext::GNU_Conditionals: + return "GNU Conditionals"; - case LanguageExtensions::Ext::GNU_DesignatedInitializers: - return "GNU Designated Initializers"; + case LanguageExtensions::Ext::GNU_DesignatedInitializers: + return "GNU Designated Initializers"; - case LanguageExtensions::Ext::GNU_FunctionNames: - return "GNU Function Names"; + case LanguageExtensions::Ext::GNU_FunctionNames: + return "GNU Function Names"; - case LanguageExtensions::Ext::GNU_Complex: - return "GNU Complex"; + case LanguageExtensions::Ext::GNU_Complex: + return "GNU Complex"; - case LanguageExtensions::Ext::GNU_StatementExpressions: - return "GNU Statement Expressions"; + case LanguageExtensions::Ext::GNU_StatementExpressions: + return "GNU Statement Expressions"; - case LanguageExtensions::Ext::GNU_Asm: - return "GNU Asm"; + case LanguageExtensions::Ext::GNU_Asm: + return "GNU Asm"; - case LanguageExtensions::Ext::GNU_InternalBuiltins: - return "GNU Internal Builtins"; + case LanguageExtensions::Ext::GNU_InternalBuiltins: + return "GNU Internal Builtins"; - case LanguageExtensions::Ext::GNU_AttributeSpecifiersLLVM: - return "GNU Attribute Specifiers LLVM"; + case LanguageExtensions::Ext::GNU_AttributeSpecifiersLLVM: + return "GNU Attribute Specifiers LLVM"; - /* Psyche */ - case LanguageExtensions::Ext::PSY_Generics: - return "PSY Generics"; + /* Psyche */ + case LanguageExtensions::Ext::PSY_Generics: + return "PSY Generics"; - /* C++ */ - case LanguageExtensions::Ext::CPP_nullptr: - return "CPP nullptr"; + /* C++ */ + case LanguageExtensions::Ext::CPP_nullptr: + return "CPP nullptr"; - /* Custom */ - case LanguageExtensions::Ext::NativeBooleans: - return "Native Booleans"; + /* Custom */ + case LanguageExtensions::Ext::NativeBooleans: + return "Native Booleans"; - case LanguageExtensions::Ext::NULLAsBuiltin: - return "NULL As Builtin"; + case LanguageExtensions::Ext::NULLAsBuiltin: + return "NULL As Builtin"; - default: - PSY_ASSERT_W_MSG(false, return "", ""); - } + default: + PSY_ASSERT_W_MSG(false, return "", ""); + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/parser/LanguageExtensions.h b/C/parser/LanguageExtensions.h index 0e50e2270..ffe9135ac 100644 --- a/C/parser/LanguageExtensions.h +++ b/C/parser/LanguageExtensions.h @@ -37,246 +37,242 @@ namespace C { /** * \brief The LanguageExtensions class. */ -class PSY_C_API LanguageExtensions final -{ +class PSY_C_API LanguageExtensions final { public: - //!@{ - /** - * Create LanguageExtensions. - */ - LanguageExtensions(); - LanguageExtensions(MacroTranslations translations); - //!@} - - /** - * The MacroTranslations of \c this LanguageExtensions. - */ - const MacroTranslations& translations() const; - - /** - * \brief The C language extensions enumeration. - */ - enum class Ext : std::uint8_t - { - /* GNU */ - GNU_AlternateKeywords, - GNU_AttributeSpecifiers, - GNU_Alignment, - GNU_CompoundLiterals, - GNU_Conditionals, - GNU_DesignatedInitializers, - GNU_FunctionNames, - GNU_Complex, - GNU_StatementExpressions, - GNU_Asm, - GNU_InternalBuiltins, - GNU_AttributeSpecifiersLLVM, - - /* Psyche */ - PSY_Generics, - - /* C++ */ - CPP_nullptr, - - /* Custom */ - NativeBooleans, - NULLAsBuiltin, - }; - - //!@{ - /** - * Whether to enable GNU keywords: - * - * https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html - */ - LanguageExtensions& enable_ExtGNU_AlternateKeywords(bool enable); - bool isEnabled_ExtGNU_AlternateKeywords() const; - //!@} - - //!@{ - /** - * Whether to enable GNU attributes: - * - * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html - */ - LanguageExtensions& enable_ExtGNU_AttributeSpecifiers(bool enable); - bool isEnabled_ExtGNU_AttributeSpecifiers() const; - //!@} - - //!@{ - /** - * Whether to enable GNU's alignment: - * - * https://gcc.gnu.org/onlinedocs/gcc/Alignment.html - */ - LanguageExtensions& enable_ExtGNU_Alignment(bool enable); - bool isEnabled_ExtGNU_Alignment() const; - //!@} - - //!@{ - /** - * Whether to enable GNU compound literals. - * - * https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html - */ - LanguageExtensions& enable_ExtGNU_CompoundLiterals(bool enable); - bool isEnabled_ExtGNU_CompoundLiterals() const; - //!@} - - //!@{ - /** - * Whether to enable GNU conditionals. - * - * https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html - */ - LanguageExtensions& enable_ExtGNU_Conditionals(bool enable); - bool isEnabled_ExtGNU_Conditionals() const; - //!@} - - //!@{ - /** - * Whether to enable GNU designated initializers: - * - * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html - */ - LanguageExtensions& enable_ExtGNU_DesignatedInitializers(bool enable); - bool isEnabled_ExtGNU_DesignatedInitializers() const; - //!@} - - //!@{ - /** - * Whether to enable GNU function names as strings: - * - * https://gcc.gnu.org/onlinedocs/gcc/Function-Names.html - */ - LanguageExtensions& enable_ExtGNU_FunctionNames(bool enable); - bool isEnabled_ExtGNU_FunctionNames() const; - //!@} - - //!@{ - /** - * Whether to enable GNU complex numbers extension: - * - * https://gcc.gnu.org/onlinedocs/gcc/Complex.html - */ - LanguageExtensions& enable_ExtGNU_Complex(bool enable); - bool isEnabled_ExtGNU_Complex() const; - //!@} - - //!@{ - /** - * Whether to enable GNU statement expressions. - * - * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html - */ - LanguageExtensions& enable_ExtGNU_StatementExpressions(bool enable); - bool isEnabled_ExtGNU_StatementExpressions() const; - //!@} - - //!@{ - /** - * Whether to enable GNU assembly in C. - * - * https://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html - */ - LanguageExtensions& enable_ExtGNU_Asm(bool enable); - bool isEnabled_ExtGNU_Asm() const; - //!@} - - //!@{ - /** - * Whether to enable GNU internal builtins (with the \c __builtin prefix). - * - * https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html - * https://gcc.gnu.org/onlinedocs/gcc/Offsetof.html - * https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html - */ - LanguageExtensions& enable_ExtGNU_InternalBuiltins(bool enable); - bool isEnabled_ExtGNU_InternalBuiltins() const; - //!@} - - //!@{ - /** - * Whether to enable LLVM/Clang extensions of GNU attribute: - * - * https://clang.llvm.org/docs/AttributeReference.html#availability - */ - LanguageExtensions& enable_ExtGNU_AttributeSpecifiersLLVM(bool enable); - bool isEnabled_ExtGNU_AttributeSpecifiersLLVM() const; - //!@} - - //!@{ - /** - * Whether to recognize the \c nullptr pointer literal from C++. - */ - LanguageExtensions& enable_CPP_nullptr(bool recognize); - bool isEnabled_CPP_nullptr() const; - //!@} - - //!@{ - /** - * Whether to allow boolean types natively (even in non-C99 standard), - * including keywords \c bool, \c false, and \c true, - */ - LanguageExtensions& enable_NativeBooleans(bool allow); - bool isEnabled_NativeBooleans() const; - //!@} - - //!@{ - /** - * Whether to threat \c NULL as a builtin. - */ - LanguageExtensions& enable_NULLAsBuiltin(bool treat); - bool isEnabled_NULLAsBuiltin() const; - //!@} - - //!@{ - /** - * Whether to set experimental generics from Psyche. - */ - LanguageExtensions& enable_ExtPSY_Generics(bool yes); - bool isEnabled_ExtPSY_Generics() const; - //!@} + //!@{ + /** + * Create LanguageExtensions. + */ + LanguageExtensions(); + LanguageExtensions(MacroTranslations translations); + //!@} + + /** + * The MacroTranslations of \c this LanguageExtensions. + */ + const MacroTranslations &translations() const; + + /** + * \brief The C language extensions enumeration. + */ + enum class Ext : std::uint8_t { + /* GNU */ + GNU_AlternateKeywords, + GNU_AttributeSpecifiers, + GNU_Alignment, + GNU_CompoundLiterals, + GNU_Conditionals, + GNU_DesignatedInitializers, + GNU_FunctionNames, + GNU_Complex, + GNU_StatementExpressions, + GNU_Asm, + GNU_InternalBuiltins, + GNU_AttributeSpecifiersLLVM, + + /* Psyche */ + PSY_Generics, + + /* C++ */ + CPP_nullptr, + + /* Custom */ + NativeBooleans, + NULLAsBuiltin, + }; + + //!@{ + /** + * Whether to enable GNU keywords: + * + * https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html + */ + LanguageExtensions &enable_ExtGNU_AlternateKeywords(bool enable); + bool isEnabled_ExtGNU_AlternateKeywords() const; + //!@} + + //!@{ + /** + * Whether to enable GNU attributes: + * + * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html + */ + LanguageExtensions &enable_ExtGNU_AttributeSpecifiers(bool enable); + bool isEnabled_ExtGNU_AttributeSpecifiers() const; + //!@} + + //!@{ + /** + * Whether to enable GNU's alignment: + * + * https://gcc.gnu.org/onlinedocs/gcc/Alignment.html + */ + LanguageExtensions &enable_ExtGNU_Alignment(bool enable); + bool isEnabled_ExtGNU_Alignment() const; + //!@} + + //!@{ + /** + * Whether to enable GNU compound literals. + * + * https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html + */ + LanguageExtensions &enable_ExtGNU_CompoundLiterals(bool enable); + bool isEnabled_ExtGNU_CompoundLiterals() const; + //!@} + + //!@{ + /** + * Whether to enable GNU conditionals. + * + * https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html + */ + LanguageExtensions &enable_ExtGNU_Conditionals(bool enable); + bool isEnabled_ExtGNU_Conditionals() const; + //!@} + + //!@{ + /** + * Whether to enable GNU designated initializers: + * + * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html + */ + LanguageExtensions &enable_ExtGNU_DesignatedInitializers(bool enable); + bool isEnabled_ExtGNU_DesignatedInitializers() const; + //!@} + + //!@{ + /** + * Whether to enable GNU function names as strings: + * + * https://gcc.gnu.org/onlinedocs/gcc/Function-Names.html + */ + LanguageExtensions &enable_ExtGNU_FunctionNames(bool enable); + bool isEnabled_ExtGNU_FunctionNames() const; + //!@} + + //!@{ + /** + * Whether to enable GNU complex numbers extension: + * + * https://gcc.gnu.org/onlinedocs/gcc/Complex.html + */ + LanguageExtensions &enable_ExtGNU_Complex(bool enable); + bool isEnabled_ExtGNU_Complex() const; + //!@} + + //!@{ + /** + * Whether to enable GNU statement expressions. + * + * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html + */ + LanguageExtensions &enable_ExtGNU_StatementExpressions(bool enable); + bool isEnabled_ExtGNU_StatementExpressions() const; + //!@} + + //!@{ + /** + * Whether to enable GNU assembly in C. + * + * https://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html + */ + LanguageExtensions &enable_ExtGNU_Asm(bool enable); + bool isEnabled_ExtGNU_Asm() const; + //!@} + + //!@{ + /** + * Whether to enable GNU internal builtins (with the \c __builtin prefix). + * + * https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html + * https://gcc.gnu.org/onlinedocs/gcc/Offsetof.html + * https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html + */ + LanguageExtensions &enable_ExtGNU_InternalBuiltins(bool enable); + bool isEnabled_ExtGNU_InternalBuiltins() const; + //!@} + + //!@{ + /** + * Whether to enable LLVM/Clang extensions of GNU attribute: + * + * https://clang.llvm.org/docs/AttributeReference.html#availability + */ + LanguageExtensions &enable_ExtGNU_AttributeSpecifiersLLVM(bool enable); + bool isEnabled_ExtGNU_AttributeSpecifiersLLVM() const; + //!@} + + //!@{ + /** + * Whether to recognize the \c nullptr pointer literal from C++. + */ + LanguageExtensions &enable_CPP_nullptr(bool recognize); + bool isEnabled_CPP_nullptr() const; + //!@} + + //!@{ + /** + * Whether to allow boolean types natively (even in non-C99 standard), + * including keywords \c bool, \c false, and \c true, + */ + LanguageExtensions &enable_NativeBooleans(bool allow); + bool isEnabled_NativeBooleans() const; + //!@} + + //!@{ + /** + * Whether to threat \c NULL as a builtin. + */ + LanguageExtensions &enable_NULLAsBuiltin(bool treat); + bool isEnabled_NULLAsBuiltin() const; + //!@} + + //!@{ + /** + * Whether to set experimental generics from Psyche. + */ + LanguageExtensions &enable_ExtPSY_Generics(bool yes); + bool isEnabled_ExtPSY_Generics() const; + //!@} private: - MacroTranslations translations_; - - struct BitFields - { - /* GNU */ - std::uint64_t ExtGNU_AlternateKeywords_ : 1; - std::uint64_t ExtGNU_Asm_: 1; - std::uint64_t ExtGNU_AttributeSpecifiers_ : 1; - std::uint64_t ExtGNU_AttributeSpecifiersLLVM_ : 1; - std::uint64_t ExtGNU_Alignment_ : 1; - std::uint64_t ExtGNU_CompoundLiterals_ : 1; - std::uint64_t ExtGNU_Conditionals_ : 1; - std::uint64_t ExtGNU_DesignatedInitializers_ : 1; - std::uint64_t ExtGNU_StatementExpressions_ : 1; - std::uint64_t ExtGNU_InternalBuiltins_ : 1; - std::uint64_t ExtGNU_FunctionNames_ : 1; - std::uint64_t ExtGNU_Complex_ : 1; - - /* Psyche */ - std::uint64_t ExtPSY_Generics_ : 1; - - /* C++ */ - std::uint64_t CPP_nullptr_ : 1; - - /* Custom */ - std::uint64_t NativeBooleans_ : 1; - std::uint64_t NULLAsBuiltin_ : 1; - }; - union - { - std::uint64_t BF_all_; - BitFields BF_; - }; + MacroTranslations translations_; + + struct BitFields { + /* GNU */ + std::uint64_t ExtGNU_AlternateKeywords_ : 1; + std::uint64_t ExtGNU_Asm_ : 1; + std::uint64_t ExtGNU_AttributeSpecifiers_ : 1; + std::uint64_t ExtGNU_AttributeSpecifiersLLVM_ : 1; + std::uint64_t ExtGNU_Alignment_ : 1; + std::uint64_t ExtGNU_CompoundLiterals_ : 1; + std::uint64_t ExtGNU_Conditionals_ : 1; + std::uint64_t ExtGNU_DesignatedInitializers_ : 1; + std::uint64_t ExtGNU_StatementExpressions_ : 1; + std::uint64_t ExtGNU_InternalBuiltins_ : 1; + std::uint64_t ExtGNU_FunctionNames_ : 1; + std::uint64_t ExtGNU_Complex_ : 1; + + /* Psyche */ + std::uint64_t ExtPSY_Generics_ : 1; + + /* C++ */ + std::uint64_t CPP_nullptr_ : 1; + + /* Custom */ + std::uint64_t NativeBooleans_ : 1; + std::uint64_t NULLAsBuiltin_ : 1; + }; + union { + std::uint64_t BF_all_; + BitFields BF_; + }; }; std::string PSY_C_API to_string(LanguageExtensions::Ext ext); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/LexedTokens.cpp b/C/parser/LexedTokens.cpp index 8f07f5d42..66a52df90 100644 --- a/C/parser/LexedTokens.cpp +++ b/C/parser/LexedTokens.cpp @@ -23,32 +23,18 @@ using namespace psy; using namespace C; -void LexedTokens::add(SyntaxToken tk) -{ - tks_.emplace_back(tk); -} +void LexedTokens::add(SyntaxToken tk) { tks_.emplace_back(tk); } -SyntaxToken& LexedTokens::tokenAt(LexedTokens::IndexType tkIdx) -{ - return tks_[tkIdx]; +SyntaxToken &LexedTokens::tokenAt(LexedTokens::IndexType tkIdx) { + return tks_[tkIdx]; } -LexedTokens::IndexType LexedTokens::freeSlot() const -{ - return IndexType(tks_.size() - 1); +LexedTokens::IndexType LexedTokens::freeSlot() const { + return IndexType(tks_.size() - 1); } -LexedTokens::SizeType LexedTokens::count() const -{ - return tks_.size(); -} +LexedTokens::SizeType LexedTokens::count() const { return tks_.size(); } -void LexedTokens::clear() -{ - tks_.clear(); -} +void LexedTokens::clear() { tks_.clear(); } -LexedTokens::IndexType LexedTokens::invalidIndex() -{ - return 0; -} +LexedTokens::IndexType LexedTokens::invalidIndex() { return 0; } diff --git a/C/parser/LexedTokens.h b/C/parser/LexedTokens.h index 7dc3b9e8d..8bbc53827 100644 --- a/C/parser/LexedTokens.h +++ b/C/parser/LexedTokens.h @@ -37,30 +37,28 @@ namespace C { * * The container of all tokens lexed by the Lexer. */ -class PSY_C_NON_API LexedTokens -{ +class PSY_C_NON_API LexedTokens { public: - using SizeType = std::vector::size_type; - using IndexType = SizeType; + using SizeType = std::vector::size_type; + using IndexType = SizeType; - SyntaxToken& tokenAt(IndexType tkIdx); - SizeType count() const; + SyntaxToken &tokenAt(IndexType tkIdx); + SizeType count() const; - static IndexType invalidIndex(); + static IndexType invalidIndex(); -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SyntaxTree); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SyntaxTree); - IndexType freeSlot() const; - void add(SyntaxToken tk); + IndexType freeSlot() const; + void add(SyntaxToken tk); private: - std::vector tks_; + std::vector tks_; - void clear(); + void clear(); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/Lexer.cpp b/C/parser/Lexer.cpp index e7db3930e..425ee584a 100644 --- a/C/parser/Lexer.cpp +++ b/C/parser/Lexer.cpp @@ -31,11 +31,11 @@ #include #ifndef UNLIKELY - #ifdef __GNUC__ - #define UNLIKELY(expr) __builtin_expect(!!(expr), false) - #else - #define UNLIKELY(expr) (expr) - #endif +#ifdef __GNUC__ +#define UNLIKELY(expr) __builtin_expect(!!(expr), false) +#else +#define UNLIKELY(expr) (expr) +#endif #endif using namespace psy; @@ -43,740 +43,659 @@ using namespace C; namespace { -const char* const kLine = "line"; +const char *const kLine = "line"; // These are markers that Qt Creator's preprocessor creates (well... at least // in some in the past) to keep track of macros; so keeping them for now. -const char* const kBegin = "begin"; -const char* const kEnd = "end"; -const char* const kExpansion = "expansion"; - -} // anonymous - -Lexer::Lexer(SyntaxTree* tree) - : tree_(tree) - , text_(tree->text().rawText()) - , c_strBeg_(text_.c_str()) - , c_strEnd_(text_.c_str() + text_.size()) - , yytext_(c_strBeg_ - 1) - , yy_(yytext_) - , yychar_('\n') - , yylineno_(1) - , yycolumn_(0) - , offset_(~0) // Start immediately "before" 0. - , withinLogicalLine_(false) - , rawSyntaxK_splitTk(0) - , diagReporter_(this) -{} - -Lexer::~Lexer() -{} +const char *const kBegin = "begin"; +const char *const kEnd = "end"; +const char *const kExpansion = "expansion"; + +} // namespace + +Lexer::Lexer(SyntaxTree *tree) + : tree_(tree), text_(tree->text().rawText()), c_strBeg_(text_.c_str()), + c_strEnd_(text_.c_str() + text_.size()), yytext_(c_strBeg_ - 1), + yy_(yytext_), yychar_('\n'), yylineno_(1), yycolumn_(0), + offset_(~0) // Start immediately "before" 0. + , + withinLogicalLine_(false), rawSyntaxK_splitTk(0), diagReporter_(this) {} + +Lexer::~Lexer() {} namespace { -bool isByteOfMultiByteCP(unsigned char byte) -{ - // Check if most significant bit is set - return byte & 0x80; +bool isByteOfMultiByteCP(unsigned char byte) { + // Check if most significant bit is set + return byte & 0x80; } -bool isRawStringLiteral(std::uint16_t rawSyntaxK) -{ - switch (rawSyntaxK) { - case StringLiteral_R_Token: - case StringLiteral_LR_Token: - case StringLiteral_u8R_Token: - case StringLiteral_uR_Token: - case StringLiteral_UR_Token: - return true; - default: - return false; - } +bool isRawStringLiteral(std::uint16_t rawSyntaxK) { + switch (rawSyntaxK) { + case StringLiteral_R_Token: + case StringLiteral_LR_Token: + case StringLiteral_u8R_Token: + case StringLiteral_uR_Token: + case StringLiteral_UR_Token: + return true; + default: + return false; + } } -bool isMultiLineToken(std::uint16_t rawSyntaxK) -{ - return rawSyntaxK == EndOfFile - || rawSyntaxK == MultiLineCommentTrivia - || rawSyntaxK == MultiLineDocumentationCommentTrivia - || rawSyntaxK == Keyword_ExtPSY_omission - || isRawStringLiteral(rawSyntaxK); +bool isMultiLineToken(std::uint16_t rawSyntaxK) { + return rawSyntaxK == EndOfFile || rawSyntaxK == MultiLineCommentTrivia || + rawSyntaxK == MultiLineDocumentationCommentTrivia || + rawSyntaxK == Keyword_ExtPSY_omission || + isRawStringLiteral(rawSyntaxK); } -} // anonymous +} // namespace -void Lexer::lex() -{ - // Marker (invalid) token. - tree_->addToken(SyntaxToken(nullptr)); +void Lexer::lex() { + // Marker (invalid) token. + tree_->addToken(SyntaxToken(nullptr)); - // Line and column... - tree_->relayLineDirective(0, 1, tree_->filePath()); - tree_->relayLineStart(0); - std::vector> expansions; - unsigned int curExpansionIdx = 0; + // Line and column... + tree_->relayLineDirective(0, 1, tree_->filePath()); + tree_->relayLineStart(0); + std::vector> expansions; + unsigned int curExpansionIdx = 0; - // Open/close brace tracking. - std::stack braces; + // Open/close brace tracking. + std::stack braces; - SyntaxToken tk(tree_); + SyntaxToken tk(tree_); - do { + do { + yylex(&tk); + + LexEntry: + if (tk.isAtStartOfLine() && tk.isKind(HashToken)) { + auto offset = tk.charOffset_; + yylex(&tk); + + if (!tk.isAtStartOfLine() && tk.isKind(IdentifierToken) && + !strcmp(tk.identifier_->c_str(), kExpansion)) { + // A Qt Creator-specific macro mark. yylex(&tk); -LexEntry: - if (tk.isAtStartOfLine() && tk.isKind(HashToken)) { - auto offset = tk.charOffset_; + if (!tk.isAtStartOfLine() && tk.isKind(IdentifierToken)) { + if (!strcmp(tk.identifier_->c_str(), kBegin)) { + // The start of an expansion section. yylex(&tk); - if (!tk.isAtStartOfLine() - && tk.isKind(IdentifierToken) - && !strcmp(tk.identifier_->c_str(), kExpansion)) { - // A Qt Creator-specific macro mark. + // Gather where it happens and its length. + yylex(&tk); + yylex(&tk); // Skip the separating comma. + yylex(&tk); + + // Gather the real line and column from the upcoming tokens; only + // relevant for tokens which are expanded but not generated. + while (!tk.isKind(EndOfFile) && !tk.isAtStartOfLine()) { + // A ~ means that the a number of generated tokens follows; + // otherwise, what follows is data. + if (tk.isKind(TildeToken)) { yylex(&tk); - if (!tk.isAtStartOfLine() && tk.isKind(IdentifierToken)) { - if (!strcmp(tk.identifier_->c_str(), kBegin)) { - // The start of an expansion section. - yylex(&tk); - - // Gather where it happens and its length. - yylex(&tk); - yylex(&tk); // Skip the separating comma. - yylex(&tk); - - // Gather the real line and column from the upcoming tokens; only - // relevant for tokens which are expanded but not generated. - while (!tk.isKind(EndOfFile) - && !tk.isAtStartOfLine()) { - // A ~ means that the a number of generated tokens follows; - // otherwise, what follows is data. - if (tk.isKind(TildeToken)) { - yylex(&tk); - - // Get the total number of generated tokens and specify "null" - // information for them. - auto all = strtoul(tk.valueText_c_str(), 0, 0); - auto prevSize = expansions.size(); - expansions.resize(prevSize + all); - std::fill(expansions.begin() + prevSize, - expansions.end(), - std::make_pair(0, 0)); - - yylex(&tk); - } - else if (tk.isKind(IntegerConstantToken)) { - auto lineno = strtoul(tk.valueText_c_str(), 0, 0); - yylex(&tk); - yylex(&tk); // Skip the separating colon. - auto column = strtoul(tk.valueText_c_str(), 0, 0); - yylex(&tk); - - // Store line and column for this non-generated token. - expansions.push_back(std::make_pair(lineno, column)); - } - } - } - else if (!strcmp(tk.identifier_->c_str(), kEnd)) { - // The end of an expansion section. - expansions.clear(); - curExpansionIdx = 0; - yylex(&tk); - } - } - } - else { - // A regular preprocessor directive. - if (!tk.isAtStartOfLine() - && tk.isKind(IdentifierToken) - && !strcmp(tk.identifier_->c_str(), kLine)) { - yylex(&tk); - } - - if (!tk.isAtStartOfLine() - && tk.isKind(IntegerConstantToken)) { - auto lineno = strtoul(tk.valueText_c_str(), 0, 0); - yylex(&tk); - - if (!tk.isAtStartOfLine() - && tk.isKind(StringLiteralToken)) { - auto fileName = tree_->stringLiteral(tk.string_->c_str(), tk.string_->size()); - tree_->relayLineDirective(offset, lineno, fileName->c_str()); - yylex(&tk); - } - } - - while (!tk.isAtStartOfLine() && !tk.isKind(EndOfFile)) { - // Skip the remaining of the line, ignoring a possible include. - yylex(&tk); - } + // Get the total number of generated tokens and specify "null" + // information for them. + auto all = strtoul(tk.valueText_c_str(), 0, 0); + auto prevSize = expansions.size(); + expansions.resize(prevSize + all); + std::fill(expansions.begin() + prevSize, expansions.end(), + std::make_pair(0, 0)); + + yylex(&tk); + } else if (tk.isKind(IntegerConstantToken)) { + auto lineno = strtoul(tk.valueText_c_str(), 0, 0); + yylex(&tk); + yylex(&tk); // Skip the separating colon. + auto column = strtoul(tk.valueText_c_str(), 0, 0); + yylex(&tk); + + // Store line and column for this non-generated token. + expansions.push_back(std::make_pair(lineno, column)); + } } - goto LexEntry; - } - else if (tk.kind() == OpenBraceToken) { - braces.push(tree_->tokenCount()); - } - else if (tk.kind() == CloseBraceToken && !braces.empty()) { - auto idx = braces.top(); - braces.pop(); - if (idx < tree_->tokenCount()) - tree_->tokenAt(idx).matchingBracket_ = tree_->tokenCount(); + } else if (!strcmp(tk.identifier_->c_str(), kEnd)) { + // The end of an expansion section. + expansions.clear(); + curExpansionIdx = 0; + yylex(&tk); + } } - else if (tk.isComment()) { - tree_->comments_.push_back(tk); - if (tk.kind() != Keyword_ExtPSY_omission) - continue; + } else { + // A regular preprocessor directive. + if (!tk.isAtStartOfLine() && tk.isKind(IdentifierToken) && + !strcmp(tk.identifier_->c_str(), kLine)) { + yylex(&tk); } - bool isExpanded = false; - bool isGenerated = false; - if (!expansions.empty() && curExpansionIdx < expansions.size()) { - isExpanded = true; - const std::pair& p = expansions[curExpansionIdx]; - if (p.first) - tree_->relayExpansion(tk.charStart(), p); - else - isGenerated = true; - ++curExpansionIdx; - } - tk.BF_.expanded_ = isExpanded; - tk.BF_.generated_ = isGenerated; + if (!tk.isAtStartOfLine() && tk.isKind(IntegerConstantToken)) { + auto lineno = strtoul(tk.valueText_c_str(), 0, 0); + yylex(&tk); - tree_->addToken(tk); - } - while (tk.kind()); + if (!tk.isAtStartOfLine() && tk.isKind(StringLiteralToken)) { + auto fileName = + tree_->stringLiteral(tk.string_->c_str(), tk.string_->size()); + tree_->relayLineDirective(offset, lineno, fileName->c_str()); + yylex(&tk); + } + } - for (; !braces.empty(); braces.pop()) { - auto idx = braces.top(); + while (!tk.isAtStartOfLine() && !tk.isKind(EndOfFile)) { + // Skip the remaining of the line, ignoring a possible include. + yylex(&tk); + } + } + goto LexEntry; + } else if (tk.kind() == OpenBraceToken) { + braces.push(tree_->tokenCount()); + } else if (tk.kind() == CloseBraceToken && !braces.empty()) { + auto idx = braces.top(); + braces.pop(); + if (idx < tree_->tokenCount()) tree_->tokenAt(idx).matchingBracket_ = tree_->tokenCount(); + } else if (tk.isComment()) { + tree_->comments_.push_back(tk); + if (tk.kind() != Keyword_ExtPSY_omission) + continue; } -} -void Lexer::yylex_core(SyntaxToken* tk) -{ -LexEntry: - while (yychar_ && std::isspace(yychar_)) { - if (yychar_ == '\n') { - tk->BF_.atStartOfLine_ = !withinLogicalLine_; - tk->BF_.joined_ = withinLogicalLine_; - - if (withinLogicalLine_) - withinLogicalLine_ = false; - else if (!isMultiLineToken(rawSyntaxK_splitTk)) - withinLogicalLine_ = 0; - } - else { - tk->BF_.hasLeadingWS_ = true; - } - yyinput(); + bool isExpanded = false; + bool isGenerated = false; + if (!expansions.empty() && curExpansionIdx < expansions.size()) { + isExpanded = true; + const std::pair &p = + expansions[curExpansionIdx]; + if (p.first) + tree_->relayExpansion(tk.charStart(), p); + else + isGenerated = true; + ++curExpansionIdx; } + tk.BF_.expanded_ = isExpanded; + tk.BF_.generated_ = isGenerated; + + tree_->addToken(tk); + } while (tk.kind()); - yy_ = yytext_; + for (; !braces.empty(); braces.pop()) { + auto idx = braces.top(); + tree_->tokenAt(idx).matchingBracket_ = tree_->tokenCount(); + } +} - tk->lineno_ = yylineno_; - tk->column_ = yycolumn_ - 1; - tk->byteOffset_ = yytext_ - c_strBeg_; - tk->charOffset_ = offset_; +void Lexer::yylex_core(SyntaxToken *tk) { +LexEntry: + while (yychar_ && std::isspace(yychar_)) { + if (yychar_ == '\n') { + tk->BF_.atStartOfLine_ = !withinLogicalLine_; + tk->BF_.joined_ = withinLogicalLine_; - if (yychar_) + if (withinLogicalLine_) withinLogicalLine_ = false; - else if (rawSyntaxK_splitTk) { - tk->rawSyntaxK_ = EndOfFile; - return; + else if (!isMultiLineToken(rawSyntaxK_splitTk)) + withinLogicalLine_ = 0; + } else { + tk->BF_.hasLeadingWS_ = true; } - - if (rawSyntaxK_splitTk == MultiLineCommentTrivia - || rawSyntaxK_splitTk == MultiLineDocumentationCommentTrivia - || rawSyntaxK_splitTk == Keyword_ExtPSY_omission) { - auto tkRawKind = rawSyntaxK_splitTk; - while (yychar_) { - if (yychar_ != '*') - yyinput(); - else { - yyinput(); - if (yychar_ == '/') { - yyinput(); - withinLogicalLine_ = 0; - break; - } - } + yyinput(); + } + + yy_ = yytext_; + + tk->lineno_ = yylineno_; + tk->column_ = yycolumn_ - 1; + tk->byteOffset_ = yytext_ - c_strBeg_; + tk->charOffset_ = offset_; + + if (yychar_) + withinLogicalLine_ = false; + else if (rawSyntaxK_splitTk) { + tk->rawSyntaxK_ = EndOfFile; + return; + } + + if (rawSyntaxK_splitTk == MultiLineCommentTrivia || + rawSyntaxK_splitTk == MultiLineDocumentationCommentTrivia || + rawSyntaxK_splitTk == Keyword_ExtPSY_omission) { + auto tkRawKind = rawSyntaxK_splitTk; + while (yychar_) { + if (yychar_ != '*') + yyinput(); + else { + yyinput(); + if (yychar_ == '/') { + yyinput(); + withinLogicalLine_ = 0; + break; } - - if (tree_->parseOptions().treatmentOfComments() == ParseOptions::TreatmentOfComments::None) - goto LexEntry; - - tk->rawSyntaxK_ = tkRawKind; - return; + } } - if (rawSyntaxK_splitTk == SingleLineCommentTrivia - || rawSyntaxK_splitTk == SingleLineDocumentationCommentTrivia) { - auto syntaxK = rawSyntaxK_splitTk; - tk->BF_.joined_ = true; - if (tree_->parseOptions().treatmentOfComments() != ParseOptions::TreatmentOfComments::None) - tk->rawSyntaxK_ = syntaxK; - withinLogicalLine_ = false; - lexSingleLineComment(syntaxK); - return; + if (tree_->parseOptions().treatmentOfComments() == + ParseOptions::TreatmentOfComments::None) + goto LexEntry; + + tk->rawSyntaxK_ = tkRawKind; + return; + } + + if (rawSyntaxK_splitTk == SingleLineCommentTrivia || + rawSyntaxK_splitTk == SingleLineDocumentationCommentTrivia) { + auto syntaxK = rawSyntaxK_splitTk; + tk->BF_.joined_ = true; + if (tree_->parseOptions().treatmentOfComments() != + ParseOptions::TreatmentOfComments::None) + tk->rawSyntaxK_ = syntaxK; + withinLogicalLine_ = false; + lexSingleLineComment(syntaxK); + return; + } + + if (isRawStringLiteral(rawSyntaxK_splitTk)) { + tk->rawSyntaxK_ = rawSyntaxK_splitTk; + if (lexContinuedRawStringLiteral()) + withinLogicalLine_ = false; + return; + } + + if (rawSyntaxK_splitTk != EndOfFile) { + tk->BF_.joined_ = true; + tk->rawSyntaxK_ = rawSyntaxK_splitTk; + withinLogicalLine_ = false; + lexUntilQuote(tk, '"', 1); + return; + } + + if (!yychar_) { + tk->rawSyntaxK_ = EndOfFile; + return; + } + + unsigned char ch = yychar_; + yyinput(); + + switch (ch) { + case '\\': + withinLogicalLine_ = true; + goto LexEntry; + + case '"': + lexStringLiteral(tk); + break; + + case '\'': + lexCharacterConstant(tk); + break; + + case '{': + tk->rawSyntaxK_ = OpenBraceToken; + break; + + case '}': + tk->rawSyntaxK_ = CloseBraceToken; + break; + + case '[': + tk->rawSyntaxK_ = OpenBracketToken; + break; + + case ']': + tk->rawSyntaxK_ = CloseBracketToken; + break; + + case '#': + if (yychar_ == '#') { + tk->rawSyntaxK_ = HashHashToken; + yyinput(); + } else { + tk->rawSyntaxK_ = HashToken; } - - if (isRawStringLiteral(rawSyntaxK_splitTk)) { - tk->rawSyntaxK_ = rawSyntaxK_splitTk; - if (lexContinuedRawStringLiteral()) - withinLogicalLine_ = false; - return; + break; + + case '(': + tk->rawSyntaxK_ = OpenParenToken; + break; + + case ')': + tk->rawSyntaxK_ = CloseParenToken; + break; + + case ';': + tk->rawSyntaxK_ = SemicolonToken; + break; + + case ':': + if (yychar_ == '>') { + // Digraph: 6.4.6-3. + tk->rawSyntaxK_ = CloseBracketToken; + yyinput(); + } else { + tk->rawSyntaxK_ = ColonToken; } + break; - if (rawSyntaxK_splitTk != EndOfFile) { - tk->BF_.joined_ = true; - tk->rawSyntaxK_ = rawSyntaxK_splitTk; - withinLogicalLine_ = false; - lexUntilQuote(tk, '"', 1); - return; + case '.': + if (yychar_ == '.') { + yyinput(); + if (yychar_ == '.') { + tk->rawSyntaxK_ = EllipsisToken; + yyinput(); + } else { + tk->rawSyntaxK_ = Error; + } + } else if (std::isdigit(yychar_)) { + lexFloatingOrImaginaryFloating_AtFollowOfPeriod(tk, 1); + } else { + tk->rawSyntaxK_ = DotToken; } + break; - if (!yychar_) { - tk->rawSyntaxK_ = EndOfFile; - return; + case '?': + if (yychar_ == '?') { + yyinput(); + if (yychar_ == '(') { + tk->rawSyntaxK_ = OpenBracketToken; + yyinput(); + } else if (yychar_ == ')') { + tk->rawSyntaxK_ = CloseBracketToken; + yyinput(); + } else if (yychar_ == '<') { + tk->rawSyntaxK_ = OpenBraceToken; + yyinput(); + } else if (yychar_ == '>') { + tk->rawSyntaxK_ = CloseBraceToken; + yyinput(); + } + } else { + tk->rawSyntaxK_ = QuestionToken; } + break; + + case '+': + if (yychar_ == '+') { + tk->rawSyntaxK_ = PlusPlusToken; + yyinput(); + } else if (yychar_ == '=') { + tk->rawSyntaxK_ = PlusEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = PlusToken; + } + break; + + case '-': + if (yychar_ == '-') { + tk->rawSyntaxK_ = MinusMinusToken; + yyinput(); + } else if (yychar_ == '=') { + tk->rawSyntaxK_ = MinusEqualsToken; + yyinput(); + } else if (yychar_ == '>') { + tk->rawSyntaxK_ = ArrowToken; + yyinput(); + } else { + tk->rawSyntaxK_ = MinusToken; + } + break; + + case '*': + if (yychar_ == '=') { + tk->rawSyntaxK_ = AsteriskEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = AsteriskToken; + } + break; - unsigned char ch = yychar_; - yyinput(); - - switch (ch) { - case '\\': - withinLogicalLine_ = true; - goto LexEntry; - - case '"': - lexStringLiteral(tk); - break; - - case '\'': - lexCharacterConstant(tk); - break; - - case '{': - tk->rawSyntaxK_ = OpenBraceToken; - break; - - case '}': - tk->rawSyntaxK_ = CloseBraceToken; - break; - - case '[': - tk->rawSyntaxK_ = OpenBracketToken; - break; - - case ']': - tk->rawSyntaxK_ = CloseBracketToken; - break; - - case '#': - if (yychar_ == '#') { - tk->rawSyntaxK_ = HashHashToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = HashToken; - } - break; - - case '(': - tk->rawSyntaxK_ = OpenParenToken; - break; - - case ')': - tk->rawSyntaxK_ = CloseParenToken; - break; - - case ';': - tk->rawSyntaxK_ = SemicolonToken; - break; - - case ':': - if (yychar_ == '>') { - // Digraph: 6.4.6-3. - tk->rawSyntaxK_ = CloseBracketToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = ColonToken; - } - break; - - case '.': - if (yychar_ == '.') { - yyinput(); - if (yychar_ == '.') { - tk->rawSyntaxK_ = EllipsisToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = Error; - } - } - else if (std::isdigit(yychar_)) { - lexFloatingOrImaginaryFloating_AtFollowOfPeriod(tk, 1); - } - else { - tk->rawSyntaxK_ = DotToken; - } - break; - - case '?': - if (yychar_ == '?') { - yyinput(); - if (yychar_ == '(') { - tk->rawSyntaxK_ = OpenBracketToken; - yyinput(); - } - else if (yychar_ == ')') { - tk->rawSyntaxK_ = CloseBracketToken; - yyinput(); - } - else if (yychar_ == '<') { - tk->rawSyntaxK_ = OpenBraceToken; - yyinput(); - } - else if (yychar_ == '>') { - tk->rawSyntaxK_ = CloseBraceToken; - yyinput(); - } - } - else { - tk->rawSyntaxK_ = QuestionToken; - } - break; - - case '+': - if (yychar_ == '+') { - tk->rawSyntaxK_ = PlusPlusToken; - yyinput(); - } - else if (yychar_ == '=') { - tk->rawSyntaxK_ = PlusEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = PlusToken; - } - break; - - case '-': - if (yychar_ == '-') { - tk->rawSyntaxK_ = MinusMinusToken; - yyinput(); - } - else if (yychar_ == '=') { - tk->rawSyntaxK_ = MinusEqualsToken; - yyinput(); - } - else if (yychar_ == '>') { - tk->rawSyntaxK_ = ArrowToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = MinusToken; - } - break; - - case '*': - if (yychar_ == '=') { - tk->rawSyntaxK_ = AsteriskEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = AsteriskToken; - } - break; - - case '/': - if (yychar_ == '/') { - SyntaxKind syntaxK = SingleLineCommentTrivia; - - yyinput(); - if (yychar_ == '/' || yychar_ == '!') { - yyinput(); - syntaxK = SingleLineDocumentationCommentTrivia; - } - lexSingleLineComment(syntaxK); - - if (tree_->parseOptions().treatmentOfComments() == ParseOptions::TreatmentOfComments::None) - goto LexEntry; - - tk->rawSyntaxK_ = syntaxK; - } - else if (yychar_ == '*') { - SyntaxKind syntaxK = MultiLineCommentTrivia; - - yyinput(); - if (yychar_ == '*' || yychar_ == '!') { - const char ch = yychar_; - yyinput(); - if (ch == '*' && yychar_ == '/') - goto LocalExit; - - if (yychar_ == '<') - yyinput(); - - if (!yychar_ || std::isspace(yychar_)) - syntaxK = MultiLineDocumentationCommentTrivia; - } - else if (yychar_ == '.') { - do { - yyinput(); - } - while (yychar_ == '.'); - syntaxK = Keyword_ExtPSY_omission; - } - - while (yychar_) { - if (yychar_ != '*') { - yyinput(); - } - else { - yyinput(); - if (yychar_ == '/') - break; - } - } - -LocalExit: - if (yychar_) - yyinput(); - else - rawSyntaxK_splitTk = syntaxK; - - if (tree_->parseOptions().treatmentOfComments() == ParseOptions::TreatmentOfComments::None) - goto LexEntry; - - tk->rawSyntaxK_ = syntaxK; - } - else if (yychar_ == '=') { - tk->rawSyntaxK_ = SlashEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = SlashToken; - } - break; + case '/': + if (yychar_ == '/') { + SyntaxKind syntaxK = SingleLineCommentTrivia; - case '%': - if (yychar_ == '=') { - tk->rawSyntaxK_ = PercentEqualsToken; - yyinput(); - } - else if (yychar_ == '>') { - // Digraph: 6.4.6-3. - tk->rawSyntaxK_ = CloseBraceToken; - yyinput(); - } - else if (yychar_ == ':') { - // Digraph: 6.4.6-3. - tk->rawSyntaxK_ = HashToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = PercentToken; - } - break; + yyinput(); + if (yychar_ == '/' || yychar_ == '!') { + yyinput(); + syntaxK = SingleLineDocumentationCommentTrivia; + } + lexSingleLineComment(syntaxK); - case '^': - if (yychar_ == '=') { - tk->rawSyntaxK_ = CaretEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = CaretToken; - } - break; + if (tree_->parseOptions().treatmentOfComments() == + ParseOptions::TreatmentOfComments::None) + goto LexEntry; - case '&': - if (yychar_ == '&') { - tk->rawSyntaxK_ = AmpersandAmpersandToken; - yyinput(); - } - else if (yychar_ == '=') { - tk->rawSyntaxK_ = AmpersandEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = AmpersandToken; - } - break; + tk->rawSyntaxK_ = syntaxK; + } else if (yychar_ == '*') { + SyntaxKind syntaxK = MultiLineCommentTrivia; - case '|': - if (yychar_ == '|') { - tk->rawSyntaxK_ = BarBarToken; - yyinput(); - } - else if (yychar_ == '=') { - tk->rawSyntaxK_ = BarEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = BarToken; - } - break; + yyinput(); + if (yychar_ == '*' || yychar_ == '!') { + const char ch = yychar_; + yyinput(); + if (ch == '*' && yychar_ == '/') + goto LocalExit; - case '~': - tk->rawSyntaxK_ = TildeToken; - break; + if (yychar_ == '<') + yyinput(); - case '!': - if (yychar_ == '=') { - tk->rawSyntaxK_ = ExclamationEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = ExclamationToken; - } + if (!yychar_ || std::isspace(yychar_)) + syntaxK = MultiLineDocumentationCommentTrivia; + } else if (yychar_ == '.') { + do { + yyinput(); + } while (yychar_ == '.'); + syntaxK = Keyword_ExtPSY_omission; + } + + while (yychar_) { + if (yychar_ != '*') { + yyinput(); + } else { + yyinput(); + if (yychar_ == '/') break; + } + } - case '=': - if (yychar_ == '=') { - tk->rawSyntaxK_ = EqualsEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = EqualsToken; - } - break; + LocalExit: + if (yychar_) + yyinput(); + else + rawSyntaxK_splitTk = syntaxK; + + if (tree_->parseOptions().treatmentOfComments() == + ParseOptions::TreatmentOfComments::None) + goto LexEntry; + + tk->rawSyntaxK_ = syntaxK; + } else if (yychar_ == '=') { + tk->rawSyntaxK_ = SlashEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = SlashToken; + } + break; + + case '%': + if (yychar_ == '=') { + tk->rawSyntaxK_ = PercentEqualsToken; + yyinput(); + } else if (yychar_ == '>') { + // Digraph: 6.4.6-3. + tk->rawSyntaxK_ = CloseBraceToken; + yyinput(); + } else if (yychar_ == ':') { + // Digraph: 6.4.6-3. + tk->rawSyntaxK_ = HashToken; + yyinput(); + } else { + tk->rawSyntaxK_ = PercentToken; + } + break; + + case '^': + if (yychar_ == '=') { + tk->rawSyntaxK_ = CaretEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = CaretToken; + } + break; + + case '&': + if (yychar_ == '&') { + tk->rawSyntaxK_ = AmpersandAmpersandToken; + yyinput(); + } else if (yychar_ == '=') { + tk->rawSyntaxK_ = AmpersandEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = AmpersandToken; + } + break; + + case '|': + if (yychar_ == '|') { + tk->rawSyntaxK_ = BarBarToken; + yyinput(); + } else if (yychar_ == '=') { + tk->rawSyntaxK_ = BarEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = BarToken; + } + break; + + case '~': + tk->rawSyntaxK_ = TildeToken; + break; + + case '!': + if (yychar_ == '=') { + tk->rawSyntaxK_ = ExclamationEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = ExclamationToken; + } + break; + + case '=': + if (yychar_ == '=') { + tk->rawSyntaxK_ = EqualsEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = EqualsToken; + } + break; - case '<': - if (yychar_ == '<') { - yyinput(); - if (yychar_ == '=') { - tk->rawSyntaxK_ = LessThanLessThanEqualsToken; - yyinput(); - } - else - tk->rawSyntaxK_ = LessThanLessThanToken; - } - else if (yychar_ == '=') { - tk->rawSyntaxK_ = LessThanEqualsToken; - yyinput(); - } - else if (yychar_ == ':') { - // Digraph: 6.4.6-3. - tk->rawSyntaxK_ = OpenBracketToken; - yyinput(); - } - else if (yychar_ == '%') { - // Digraph: 6.4.6-3. - tk->rawSyntaxK_ = OpenBraceToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = LessThanToken; - } - break; + case '<': + if (yychar_ == '<') { + yyinput(); + if (yychar_ == '=') { + tk->rawSyntaxK_ = LessThanLessThanEqualsToken; + yyinput(); + } else + tk->rawSyntaxK_ = LessThanLessThanToken; + } else if (yychar_ == '=') { + tk->rawSyntaxK_ = LessThanEqualsToken; + yyinput(); + } else if (yychar_ == ':') { + // Digraph: 6.4.6-3. + tk->rawSyntaxK_ = OpenBracketToken; + yyinput(); + } else if (yychar_ == '%') { + // Digraph: 6.4.6-3. + tk->rawSyntaxK_ = OpenBraceToken; + yyinput(); + } else { + tk->rawSyntaxK_ = LessThanToken; + } + break; - case '>': - if (yychar_ == '>') { - yyinput(); - if (yychar_ == '=') { - yyinput(); - tk->rawSyntaxK_ = GreaterThanGreaterThanEqualsToken; - } - else - tk->rawSyntaxK_ = LessThanLessThanToken; - tk->rawSyntaxK_ = GreaterThanGreaterThanToken; - } - else if (yychar_ == '=') { - tk->rawSyntaxK_ = GreaterThanEqualsToken; - yyinput(); - } - else { - tk->rawSyntaxK_ = GreaterThanToken; - } - break; + case '>': + if (yychar_ == '>') { + yyinput(); + if (yychar_ == '=') { + yyinput(); + tk->rawSyntaxK_ = GreaterThanGreaterThanEqualsToken; + } else + tk->rawSyntaxK_ = LessThanLessThanToken; + tk->rawSyntaxK_ = GreaterThanGreaterThanToken; + } else if (yychar_ == '=') { + tk->rawSyntaxK_ = GreaterThanEqualsToken; + yyinput(); + } else { + tk->rawSyntaxK_ = GreaterThanToken; + } + break; - case ',': - tk->rawSyntaxK_ = CommaToken; - break; + case ',': + tk->rawSyntaxK_ = CommaToken; + break; - default: { - if (ch == 'L' - || ch == 'u' - || ch == 'U' - || ch == 'R') { - if (yychar_ == '"') { - yyinput(); - if (ch == 'R') - lexRawStringLiteral(tk); - else - lexStringLiteral(tk, ch); - } - else if (yychar_ == '\'') { - yyinput(); - lexCharacterConstant(tk, ch); - } - else if (ch != 'R' - && yychar_ == 'R') { - yyinput(); - if (yychar_ == '"') { - yyinput(); - lexRawStringLiteral(tk, ch); - } - else { - lexIdentifier(tk, 1); - } - } - else if (ch == 'u' - && yychar_ == '8') { - yyinput(); - if (yychar_ == '"') { - yyinput(); - lexStringLiteral(tk, '8'); - } - else if (yychar_ == '\'') { - yyinput(); - lexCharacterConstant(tk, '8'); - } - else if (yychar_ == 'R') { - yyinput(); - if (yychar_ == '"') { - yyinput(); - lexRawStringLiteral(tk, '8'); - } else { - lexIdentifier(tk, 2); - } - } - else { - lexIdentifier(tk, 1); - } - } - else { - lexIdentifier(tk); - } - } - else if (std::isalpha(ch) - || ch == '_' - || ch == '$' - || isByteOfMultiByteCP(ch)) { - lexIdentifier(tk, yytext_ - yy_ - 1); - } - else if (std::isdigit(ch)) { - lexIntegerOrFloatingConstant(tk); - } - else { - tk->rawSyntaxK_ = Error; - } - break; + default: { + if (ch == 'L' || ch == 'u' || ch == 'U' || ch == 'R') { + if (yychar_ == '"') { + yyinput(); + if (ch == 'R') + lexRawStringLiteral(tk); + else + lexStringLiteral(tk, ch); + } else if (yychar_ == '\'') { + yyinput(); + lexCharacterConstant(tk, ch); + } else if (ch != 'R' && yychar_ == 'R') { + yyinput(); + if (yychar_ == '"') { + yyinput(); + lexRawStringLiteral(tk, ch); + } else { + lexIdentifier(tk, 1); + } + } else if (ch == 'u' && yychar_ == '8') { + yyinput(); + if (yychar_ == '"') { + yyinput(); + lexStringLiteral(tk, '8'); + } else if (yychar_ == '\'') { + yyinput(); + lexCharacterConstant(tk, '8'); + } else if (yychar_ == 'R') { + yyinput(); + if (yychar_ == '"') { + yyinput(); + lexRawStringLiteral(tk, '8'); + } else { + lexIdentifier(tk, 2); + } + } else { + lexIdentifier(tk, 1); } + } else { + lexIdentifier(tk); + } + } else if (std::isalpha(ch) || ch == '_' || ch == '$' || + isByteOfMultiByteCP(ch)) { + lexIdentifier(tk, yytext_ - yy_ - 1); + } else if (std::isdigit(ch)) { + lexIntegerOrFloatingConstant(tk); + } else { + tk->rawSyntaxK_ = Error; } + break; + } + } } -void Lexer::yylex(SyntaxToken* tk) -{ - tk->setup(); +void Lexer::yylex(SyntaxToken *tk) { + tk->setup(); - yylex_core(tk); + yylex_core(tk); - tk->byteSize_ = yytext_ - yy_; - tk->charSize_ = offset_ - tk->charOffset_; + tk->byteSize_ = yytext_ - yy_; + tk->charSize_ = offset_ - tk->charOffset_; } /** @@ -785,41 +704,36 @@ void Lexer::yylex(SyntaxToken* tk) * to the value pointed by the updated \c yychar; \c offset will be * incremented by the number of UTF-16 code units that were needed. */ -void Lexer::yyinput_core(const char*& yy, - unsigned char& yychar, - unsigned int& yycolumn, - unsigned int& offset) -{ - ++yycolumn; - ++offset; - - if (UNLIKELY(isByteOfMultiByteCP(yychar))) { - // Process multi-byte UTF-8 code point. - unsigned int trailBytesCurCP = 1; - for (unsigned char c = yychar << 2; isByteOfMultiByteCP(c); c <<= 1) - ++trailBytesCurCP; - - // Code points >= 0x00010000 are represented by two UTF-16 code units. - if (trailBytesCurCP >= 3) { - ++yycolumn; - ++offset; - } - - yychar = *(yy += trailBytesCurCP + 1); - } - else { - yychar = *++yy; +void Lexer::yyinput_core(const char *&yy, unsigned char &yychar, + unsigned int &yycolumn, unsigned int &offset) { + ++yycolumn; + ++offset; + + if (UNLIKELY(isByteOfMultiByteCP(yychar))) { + // Process multi-byte UTF-8 code point. + unsigned int trailBytesCurCP = 1; + for (unsigned char c = yychar << 2; isByteOfMultiByteCP(c); c <<= 1) + ++trailBytesCurCP; + + // Code points >= 0x00010000 are represented by two UTF-16 code units. + if (trailBytesCurCP >= 3) { + ++yycolumn; + ++offset; } + + yychar = *(yy += trailBytesCurCP + 1); + } else { + yychar = *++yy; + } } -void Lexer::yyinput() -{ - yyinput_core(yytext_, yychar_, yycolumn_, offset_); +void Lexer::yyinput() { + yyinput_core(yytext_, yychar_, yycolumn_, offset_); - if (UNLIKELY(yychar_ == '\n')) { - ++yylineno_; - tree_->relayLineStart(offset_ + 1); - } + if (UNLIKELY(yychar_ == '\n')) { + ++yylineno_; + tree_->relayLineStart(offset_ + 1); + } } /** @@ -827,30 +741,26 @@ void Lexer::yyinput() * * \remark 6.4.2.1 */ -void Lexer::lexIdentifier(SyntaxToken* tk, int advanced) -{ - const char* yytext = yytext_ - 1 - advanced; - - while (std::isalnum(yychar_) - || yychar_ == '_' - || yychar_ == '$' - || isByteOfMultiByteCP(yychar_)) { - yyinput(); - } +void Lexer::lexIdentifier(SyntaxToken *tk, int advanced) { + const char *yytext = yytext_ - 1 - advanced; - int yyleng = yytext_ - yytext; + while (std::isalnum(yychar_) || yychar_ == '_' || yychar_ == '$' || + isByteOfMultiByteCP(yychar_)) { + yyinput(); + } - if (tree_->parseOptions().treatmentOfIdentifiers() == ParseOptions - ::TreatmentOfIdentifiers::Classify) { - tk->rawSyntaxK_ = classify(yytext, yyleng, tree_->parseOptions()); - } - else - tk->rawSyntaxK_ = IdentifierToken; + int yyleng = yytext_ - yytext; - if (tk->rawSyntaxK_ == IdentifierToken) { - tk->rawSyntaxK_ = classifyOperator(yytext, yyleng, tree_->parseOptions()); - tk->identifier_ = tree_->identifier(yytext, yyleng); - } + if (tree_->parseOptions().treatmentOfIdentifiers() == + ParseOptions ::TreatmentOfIdentifiers::Classify) { + tk->rawSyntaxK_ = classify(yytext, yyleng, tree_->parseOptions()); + } else + tk->rawSyntaxK_ = IdentifierToken; + + if (tk->rawSyntaxK_ == IdentifierToken) { + tk->rawSyntaxK_ = classifyOperator(yytext, yyleng, tree_->parseOptions()); + tk->identifier_ = tree_->identifier(yytext, yyleng); + } } /** @@ -858,111 +768,103 @@ void Lexer::lexIdentifier(SyntaxToken* tk, int advanced) * * \remark 6.4.4.1, and 6.4.4.2 */ -void Lexer::lexIntegerOrFloatingConstant(SyntaxToken* tk) -{ - const char* yytext = yytext_ - 1; +void Lexer::lexIntegerOrFloatingConstant(SyntaxToken *tk) { + const char *yytext = yytext_ - 1; - if (*yytext == '0' && yychar_) { - if (yychar_ == 'x'|| yychar_ == 'X') { - yyinput(); - lexHexadecimalDigitSequence(); - - if (yychar_ == '.') { - tk->rawSyntaxK_ = FloatingConstantToken; - yyinput(); - - if (tree_->parseOptions().dialect().std() < LanguageDialect::Std::C99) { - diagReporter_.IncompatibleLanguageDialect( - "hexadecimal floating-point constant", - LanguageDialect::Std::C99); - } - - lexHexadecimalDigitSequence(); - lexBinaryExponentPart(); - lexFloatingOrImaginaryFloatingSuffix(tk, yytext_ - yytext); - return; - } - lexIntegerOrImaginaryIntegerSuffix(tk, yytext_ - yytext); - return; - } + if (*yytext == '0' && yychar_) { + if (yychar_ == 'x' || yychar_ == 'X') { + yyinput(); + lexHexadecimalDigitSequence(); - if (yychar_ == 'b' || yychar_ == 'B') { - yyinput(); - while (yychar_ == '0' || yychar_ == '1') - yyinput(); - lexIntegerOrImaginaryIntegerSuffix(tk, yytext_ - yytext); - return; + if (yychar_ == '.') { + tk->rawSyntaxK_ = FloatingConstantToken; + yyinput(); + + if (tree_->parseOptions().dialect().std() < LanguageDialect::Std::C99) { + diagReporter_.IncompatibleLanguageDialect( + "hexadecimal floating-point constant", LanguageDialect::Std::C99); } - if (yychar_ >= '0' && yychar_ <= '7') { - do { - yyinput(); - } - while (yychar_ >= '0' && yychar_ <= '7'); + lexHexadecimalDigitSequence(); + lexBinaryExponentPart(); + lexFloatingOrImaginaryFloatingSuffix(tk, yytext_ - yytext); + return; + } + lexIntegerOrImaginaryIntegerSuffix(tk, yytext_ - yytext); + return; + } - lexIntegerOrImaginaryIntegerSuffix(tk, yytext_ - yytext); - return; - } + if (yychar_ == 'b' || yychar_ == 'B') { + yyinput(); + while (yychar_ == '0' || yychar_ == '1') + yyinput(); + lexIntegerOrImaginaryIntegerSuffix(tk, yytext_ - yytext); + return; } - while (yychar_) { - if (yychar_ == '.') { - yyinput(); - lexFloatingOrImaginaryFloating_AtFollowOfPeriod(tk, yytext_ - yytext); - return; - } + if (yychar_ >= '0' && yychar_ <= '7') { + do { + yyinput(); + } while (yychar_ >= '0' && yychar_ <= '7'); - if (yychar_ == 'e' || yychar_ == 'E') { - lexFloatingOrImaginaryFloating_AtExponent(tk, yytext_ - yytext); - return; - } + lexIntegerOrImaginaryIntegerSuffix(tk, yytext_ - yytext); + return; + } + } - if (!std::isdigit(yychar_)) - break; - yyinput(); + while (yychar_) { + if (yychar_ == '.') { + yyinput(); + lexFloatingOrImaginaryFloating_AtFollowOfPeriod(tk, yytext_ - yytext); + return; } - lexIntegerOrImaginaryIntegerSuffix(tk, yytext_ - yytext); + if (yychar_ == 'e' || yychar_ == 'E') { + lexFloatingOrImaginaryFloating_AtExponent(tk, yytext_ - yytext); + return; + } + + if (!std::isdigit(yychar_)) + break; + yyinput(); + } + + lexIntegerOrImaginaryIntegerSuffix(tk, yytext_ - yytext); } -void Lexer::lexIntegerOrFloating_AtFollowOfSuffix(SyntaxToken* tk, - std::function makeLexeme) -{ - if (std::isalnum(yychar_) || yychar_ == '_') { - tk->rawSyntaxK_ = Error; - do { - yyinput(); - } - while (std::isalnum(yychar_) || yychar_ == '_'); - return; - } +void Lexer::lexIntegerOrFloating_AtFollowOfSuffix( + SyntaxToken *tk, std::function makeLexeme) { + if (std::isalnum(yychar_) || yychar_ == '_') { + tk->rawSyntaxK_ = Error; + do { + yyinput(); + } while (std::isalnum(yychar_) || yychar_ == '_'); + return; + } - makeLexeme(); + makeLexeme(); } -void Lexer::lexIntegerOrImaginaryIntegerSuffix(SyntaxToken* tk, unsigned int accLeng) -{ - const char* yytext = yytext_ - accLeng; - if (yychar_ == 'i' || yychar_ == 'j') { - lexImaginaryIntegerSuffix_AtFirst(tk); - lexIntegerSuffix(); +void Lexer::lexIntegerOrImaginaryIntegerSuffix(SyntaxToken *tk, + unsigned int accLeng) { + const char *yytext = yytext_ - accLeng; + if (yychar_ == 'i' || yychar_ == 'j') { + lexImaginaryIntegerSuffix_AtFirst(tk); + lexIntegerSuffix(); + } else { + lexIntegerSuffix(); + lexImaginaryIntegerSuffix(tk); + } + + lexIntegerOrFloating_AtFollowOfSuffix(tk, [&]() { + if (tk->rawSyntaxK_ == ImaginaryIntegerConstantToken) { + tk->imaginaryInteger_ = + tree_->imaginaryIntegerConstant(yytext, yytext_ - yytext); + } else { + tk->rawSyntaxK_ = IntegerConstantToken; + tk->integer_ = tree_->integerConstant(yytext, yytext_ - yytext); } - else { - lexIntegerSuffix(); - lexImaginaryIntegerSuffix(tk); - } - - lexIntegerOrFloating_AtFollowOfSuffix( - tk, - [&] () { - if (tk->rawSyntaxK_ == ImaginaryIntegerConstantToken) { - tk->imaginaryInteger_ = tree_->imaginaryIntegerConstant(yytext, yytext_ - yytext); - } - else { - tk->rawSyntaxK_ = IntegerConstantToken; - tk->integer_ = tree_->integerConstant(yytext, yytext_ - yytext); - } - }); + }); } /** @@ -970,122 +872,112 @@ void Lexer::lexIntegerOrImaginaryIntegerSuffix(SyntaxToken* tk, unsigned int acc * * \remark 6.4.4.1 */ -void Lexer::lexIntegerSuffix(int suffixCnt) -{ - if (!suffixCnt) - return; +void Lexer::lexIntegerSuffix(int suffixCnt) { + if (!suffixCnt) + return; - switch(yychar_) { - case 'u': - case 'U': - yyinput(); - switch (yychar_) { - case 'l': - case 'L': - lexIntegerSuffix(--suffixCnt); - break; - } - break; + switch (yychar_) { + case 'u': + case 'U': + yyinput(); + switch (yychar_) { + case 'l': + case 'L': + lexIntegerSuffix(--suffixCnt); + break; + } + break; - case 'l': - yyinput(); - if (yychar_ == 'l') - yyinput(); - switch (yychar_) { - case 'u': - case 'U': - lexIntegerSuffix(--suffixCnt); - break; - } - break; + case 'l': + yyinput(); + if (yychar_ == 'l') + yyinput(); + switch (yychar_) { + case 'u': + case 'U': + lexIntegerSuffix(--suffixCnt); + break; + } + break; - case 'L': - yyinput(); - if (yychar_ == 'L') - yyinput(); - switch (yychar_) { - case 'u': - case 'U': - lexIntegerSuffix(--suffixCnt); - break; - } - break; + case 'L': + yyinput(); + if (yychar_ == 'L') + yyinput(); + switch (yychar_) { + case 'u': + case 'U': + lexIntegerSuffix(--suffixCnt); + break; } + break; + } } -void Lexer::lexImaginaryIntegerSuffix(SyntaxToken* tk) -{ - if (yychar_ == 'i' || yychar_ == 'j') - lexImaginaryIntegerSuffix_AtFirst(tk); +void Lexer::lexImaginaryIntegerSuffix(SyntaxToken *tk) { + if (yychar_ == 'i' || yychar_ == 'j') + lexImaginaryIntegerSuffix_AtFirst(tk); } -void Lexer::lexImaginaryIntegerSuffix_AtFirst(SyntaxToken* tk) -{ - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_Complex()) { - diagReporter_.IncompatibleLanguageExtension( - "imaginary constant", - LanguageExtensions::Ext::GNU_Complex); - } +void Lexer::lexImaginaryIntegerSuffix_AtFirst(SyntaxToken *tk) { + if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_Complex()) { + diagReporter_.IncompatibleLanguageExtension( + "imaginary constant", LanguageExtensions::Ext::GNU_Complex); + } - yyinput(); - tk->rawSyntaxK_ = ImaginaryIntegerConstantToken; + yyinput(); + tk->rawSyntaxK_ = ImaginaryIntegerConstantToken; } -void Lexer::lexFloatingOrImaginaryFloating_AtFollowOfPeriod(SyntaxToken* tk, unsigned int accLeng) -{ - const char* yytext = yytext_ - accLeng; - lexDigitSequence(); - lexFloatingOrImaginaryFloating_AtExponent(tk, yytext_ - yytext); +void Lexer::lexFloatingOrImaginaryFloating_AtFollowOfPeriod( + SyntaxToken *tk, unsigned int accLeng) { + const char *yytext = yytext_ - accLeng; + lexDigitSequence(); + lexFloatingOrImaginaryFloating_AtExponent(tk, yytext_ - yytext); } -void Lexer::lexFloatingOrImaginaryFloating_AtExponent(SyntaxToken* tk, unsigned int accLeng) -{ - const char* yytext = yytext_ - accLeng; - lexExponentPart(); - lexFloatingOrImaginaryFloatingSuffix(tk, yytext_ - yytext); +void Lexer::lexFloatingOrImaginaryFloating_AtExponent(SyntaxToken *tk, + unsigned int accLeng) { + const char *yytext = yytext_ - accLeng; + lexExponentPart(); + lexFloatingOrImaginaryFloatingSuffix(tk, yytext_ - yytext); } -void Lexer::lexFloatingOrImaginaryFloatingSuffix(SyntaxToken* tk, unsigned int accLeng) -{ - const char* yytext = yytext_ - accLeng; - if (yychar_ == 'i' || yychar_ == 'j') { - lexImaginaryFloatingSuffix_AtFirst(tk); - lexFloatingSuffix(); +void Lexer::lexFloatingOrImaginaryFloatingSuffix(SyntaxToken *tk, + unsigned int accLeng) { + const char *yytext = yytext_ - accLeng; + if (yychar_ == 'i' || yychar_ == 'j') { + lexImaginaryFloatingSuffix_AtFirst(tk); + lexFloatingSuffix(); + } else { + lexFloatingSuffix(); + lexImaginaryFloatingSuffix(tk); + } + + lexIntegerOrFloating_AtFollowOfSuffix(tk, [&]() { + if (tk->rawSyntaxK_ == ImaginaryFloatingConstantToken) { + tk->imaginaryFloating_ = + tree_->imaginaryFloatingConstant(yytext, yytext_ - yytext); + } else { + tk->rawSyntaxK_ = FloatingConstantToken; + tk->floating_ = tree_->floatingConstant(yytext, yytext_ - yytext); } - else { - lexFloatingSuffix(); - lexImaginaryFloatingSuffix(tk); - } - - lexIntegerOrFloating_AtFollowOfSuffix( - tk, - [&] () { - if (tk->rawSyntaxK_ == ImaginaryFloatingConstantToken) { - tk->imaginaryFloating_ = tree_->imaginaryFloatingConstant(yytext, yytext_ - yytext); - } - else { - tk->rawSyntaxK_ = FloatingConstantToken; - tk->floating_ = tree_->floatingConstant(yytext, yytext_ - yytext); - } - }); + }); } -void Lexer::lexImaginaryFloatingSuffix(SyntaxToken* tk) -{ - if (yychar_ == 'i' || yychar_ == 'j') - lexImaginaryFloatingSuffix_AtFirst(tk); +void Lexer::lexImaginaryFloatingSuffix(SyntaxToken *tk) { + if (yychar_ == 'i' || yychar_ == 'j') + lexImaginaryFloatingSuffix_AtFirst(tk); } -void Lexer::lexImaginaryFloatingSuffix_AtFirst(SyntaxToken* tk) -{ - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_Complex()) { - diagReporter_.IncompatibleLanguageExtension( - "imaginary constant", - LanguageExtensions::Ext::GNU_Complex); - } +void Lexer::lexImaginaryFloatingSuffix_AtFirst(SyntaxToken *tk) { + if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_Complex()) { + diagReporter_.IncompatibleLanguageExtension( + "imaginary constant", LanguageExtensions::Ext::GNU_Complex); + } - yyinput(); - tk->rawSyntaxK_ = ImaginaryFloatingConstantToken; + yyinput(); + tk->rawSyntaxK_ = ImaginaryFloatingConstantToken; } /** @@ -1093,14 +985,13 @@ void Lexer::lexImaginaryFloatingSuffix_AtFirst(SyntaxToken* tk) * * \remark 6.4.4.2 */ -void Lexer::lexDigitSequence() -{ - if (!std::isdigit(yychar_)) - return; +void Lexer::lexDigitSequence() { + if (!std::isdigit(yychar_)) + return; + yyinput(); + while (std::isdigit(yychar_)) yyinput(); - while (std::isdigit(yychar_)) - yyinput(); } /** @@ -1108,13 +999,12 @@ void Lexer::lexDigitSequence() * * \remark 6.4.4.2 */ -void Lexer::lexExponentPart() -{ - if (yychar_ == 'e' || yychar_ == 'E') { - yyinput(); - lexSign(); - lexDigitSequence(); - } +void Lexer::lexExponentPart() { + if (yychar_ == 'e' || yychar_ == 'E') { + yyinput(); + lexSign(); + lexDigitSequence(); + } } /** @@ -1122,13 +1012,12 @@ void Lexer::lexExponentPart() * * \remark 6.4.4.2 */ -void Lexer::lexBinaryExponentPart() -{ - if (yychar_ == 'p' || yychar_ == 'P') { - yyinput(); - lexSign(); - lexDigitSequence(); - } +void Lexer::lexBinaryExponentPart() { + if (yychar_ == 'p' || yychar_ == 'P') { + yyinput(); + lexSign(); + lexDigitSequence(); + } } /** @@ -1136,10 +1025,9 @@ void Lexer::lexBinaryExponentPart() * * \remark 6.4.4.2 */ -void Lexer::lexSign() -{ - if (yychar_ == '+' || yychar_ == '-') - yyinput(); +void Lexer::lexSign() { + if (yychar_ == '+' || yychar_ == '-') + yyinput(); } /** @@ -1147,14 +1035,10 @@ void Lexer::lexSign() * * \remark 6.4.4.2 */ -void Lexer::lexFloatingSuffix() -{ - if (yychar_ == 'f' - || yychar_ == 'l' - || yychar_ == 'F' - || yychar_ == 'L') { - yyinput(); - } +void Lexer::lexFloatingSuffix() { + if (yychar_ == 'f' || yychar_ == 'l' || yychar_ == 'F' || yychar_ == 'L') { + yyinput(); + } } /** @@ -1162,13 +1046,11 @@ void Lexer::lexFloatingSuffix() * * \remark 6.4.4.2 */ -void Lexer::lexHexadecimalDigitSequence() -{ - while (std::isdigit(yychar_) - || (yychar_ >= 'a' && yychar_ <= 'f') - || (yychar_ >= 'A' && yychar_ <= 'F')) { - yyinput(); - } +void Lexer::lexHexadecimalDigitSequence() { + while (std::isdigit(yychar_) || (yychar_ >= 'a' && yychar_ <= 'f') || + (yychar_ >= 'A' && yychar_ <= 'F')) { + yyinput(); + } } /** @@ -1176,21 +1058,20 @@ void Lexer::lexHexadecimalDigitSequence() * * \remark 6.4.4.4 */ -void Lexer::lexCharacterConstant(SyntaxToken* tk, unsigned char prefix) -{ - unsigned int prefixSize = 1; - if (prefix == 'L') - tk->rawSyntaxK_ = CharacterConstant_L_Token; - else if (prefix == 'U') - tk->rawSyntaxK_ = CharacterConstant_U_Token; - else if (prefix == 'u') - tk->rawSyntaxK_ = CharacterConstant_u_Token; - else { - tk->rawSyntaxK_ = CharacterConstantToken; - prefixSize = 0; - } - - lexUntilQuote(tk, '\'', prefixSize); +void Lexer::lexCharacterConstant(SyntaxToken *tk, unsigned char prefix) { + unsigned int prefixSize = 1; + if (prefix == 'L') + tk->rawSyntaxK_ = CharacterConstant_L_Token; + else if (prefix == 'U') + tk->rawSyntaxK_ = CharacterConstant_U_Token; + else if (prefix == 'u') + tk->rawSyntaxK_ = CharacterConstant_u_Token; + else { + tk->rawSyntaxK_ = CharacterConstantToken; + prefixSize = 0; + } + + lexUntilQuote(tk, '\'', prefixSize); } /** @@ -1198,172 +1079,160 @@ void Lexer::lexCharacterConstant(SyntaxToken* tk, unsigned char prefix) * * \remark 6.4.5 */ -void Lexer::lexStringLiteral(SyntaxToken* tk, unsigned char prefix) -{ - unsigned int prefixSize = 1; - if (prefix == 'L') - tk->rawSyntaxK_ = StringLiteral_L_Token; - else if (prefix == 'U') - tk->rawSyntaxK_ = StringLiteral_U_Token; - else if (prefix == 'u') - tk->rawSyntaxK_ = StringLiteral_u_Token; - else if (prefix == '8') - tk->rawSyntaxK_ = StringLiteral_u8_Token; - else { - tk->rawSyntaxK_ = StringLiteralToken; - prefixSize = 0; - } - - lexUntilQuote(tk, '"', prefixSize); +void Lexer::lexStringLiteral(SyntaxToken *tk, unsigned char prefix) { + unsigned int prefixSize = 1; + if (prefix == 'L') + tk->rawSyntaxK_ = StringLiteral_L_Token; + else if (prefix == 'U') + tk->rawSyntaxK_ = StringLiteral_U_Token; + else if (prefix == 'u') + tk->rawSyntaxK_ = StringLiteral_u_Token; + else if (prefix == '8') + tk->rawSyntaxK_ = StringLiteral_u8_Token; + else { + tk->rawSyntaxK_ = StringLiteralToken; + prefixSize = 0; + } + + lexUntilQuote(tk, '"', prefixSize); } -void Lexer::lexRawStringLiteral(SyntaxToken* tk, unsigned char prefix) -{ - const char* yytext = yytext_; - int delimLeng = -1; - const char* delimCandidate = nullptr; - - while (yychar_) { - if (yychar_ == '(' && delimLeng == -1) { - delimLeng = yytext_ - yytext; - yyinput(); - } - else if (yychar_ == ')') { - yyinput(); - if (delimLeng == -1) - break; - delimCandidate = yytext_; - } - else { - if (delimLeng == -1) { - if (yychar_ == '\\' || std::isspace(yychar_)) - break; - yyinput(); - } - else { - if (!delimCandidate) { - yyinput(); - } - else { - if (yychar_ == '"') { - if (delimLeng == yytext_ - delimCandidate) { - // Got a matching closing delimiter. - break; - } - } - - // Make sure this continues to be a valid candidate. - if (yychar_ != *(yytext + (yytext_ - delimCandidate))) - delimCandidate = nullptr; - - yyinput(); - } +void Lexer::lexRawStringLiteral(SyntaxToken *tk, unsigned char prefix) { + const char *yytext = yytext_; + int delimLeng = -1; + const char *delimCandidate = nullptr; + + while (yychar_) { + if (yychar_ == '(' && delimLeng == -1) { + delimLeng = yytext_ - yytext; + yyinput(); + } else if (yychar_ == ')') { + yyinput(); + if (delimLeng == -1) + break; + delimCandidate = yytext_; + } else { + if (delimLeng == -1) { + if (yychar_ == '\\' || std::isspace(yychar_)) + break; + yyinput(); + } else { + if (!delimCandidate) { + yyinput(); + } else { + if (yychar_ == '"') { + if (delimLeng == yytext_ - delimCandidate) { + // Got a matching closing delimiter. + break; } - } - } + } - int yyleng = yytext_ - yytext; + // Make sure this continues to be a valid candidate. + if (yychar_ != *(yytext + (yytext_ - delimCandidate))) + delimCandidate = nullptr; - if (yychar_ == '"') - yyinput(); + yyinput(); + } + } + } + } - tk->string_ = tree_->stringLiteral(yytext, yyleng); + int yyleng = yytext_ - yytext; - if (prefix == 'L') - tk->rawSyntaxK_ = StringLiteral_LR_Token; - else if (prefix == 'U') - tk->rawSyntaxK_ = StringLiteral_UR_Token; - else if (prefix == 'u') - tk->rawSyntaxK_ = StringLiteral_uR_Token; - else if (prefix == '8') - tk->rawSyntaxK_ = StringLiteral_u8R_Token; - else - tk->rawSyntaxK_ = StringLiteral_R_Token; + if (yychar_ == '"') + yyinput(); - if (!yychar_) - rawSyntaxK_splitTk = tk->rawSyntaxK_; + tk->string_ = tree_->stringLiteral(yytext, yyleng); + + if (prefix == 'L') + tk->rawSyntaxK_ = StringLiteral_LR_Token; + else if (prefix == 'U') + tk->rawSyntaxK_ = StringLiteral_UR_Token; + else if (prefix == 'u') + tk->rawSyntaxK_ = StringLiteral_uR_Token; + else if (prefix == '8') + tk->rawSyntaxK_ = StringLiteral_u8R_Token; + else + tk->rawSyntaxK_ = StringLiteral_R_Token; + + if (!yychar_) + rawSyntaxK_splitTk = tk->rawSyntaxK_; } -bool Lexer::lexContinuedRawStringLiteral() -{ - bool closeParen = false; +bool Lexer::lexContinuedRawStringLiteral() { + bool closeParen = false; - while (yychar_) { - if (yychar_ == ')') { - yyinput(); - closeParen = true; - } - else { - if (closeParen && yychar_ == '"') { - yyinput(); - return true; - } - yyinput(); - } + while (yychar_) { + if (yychar_ == ')') { + yyinput(); + closeParen = true; + } else { + if (closeParen && yychar_ == '"') { + yyinput(); + return true; + } + yyinput(); } + } - return false; + return false; } -void Lexer::lexBackslash(std::uint16_t rawSyntaxK) -{ +void Lexer::lexBackslash(std::uint16_t rawSyntaxK) { + yyinput(); + if (yychar_ && !std::isspace(yychar_)) { yyinput(); - if (yychar_ && !std::isspace(yychar_)) { - yyinput(); - return; - } + return; + } - while (yychar_ != '\n' && std::isspace(yychar_)) - yyinput(); + while (yychar_ != '\n' && std::isspace(yychar_)) + yyinput(); - if (!yychar_) { - rawSyntaxK_splitTk = rawSyntaxK; - withinLogicalLine_ = true; - return; - } + if (!yychar_) { + rawSyntaxK_splitTk = rawSyntaxK; + withinLogicalLine_ = true; + return; + } - if (yychar_ == '\n') { - yyinput(); - while (yychar_ != '\n' && std::isspace(yychar_)) - yyinput(); + if (yychar_ == '\n') { + yyinput(); + while (yychar_ != '\n' && std::isspace(yychar_)) + yyinput(); - if (!yychar_) - rawSyntaxK_splitTk = rawSyntaxK; - } + if (!yychar_) + rawSyntaxK_splitTk = rawSyntaxK; + } } -void Lexer::lexUntilQuote(SyntaxToken* tk, unsigned char quote, unsigned int accLeng) -{ - const char* yytext = yytext_ - 1; - yytext -= accLeng; +void Lexer::lexUntilQuote(SyntaxToken *tk, unsigned char quote, + unsigned int accLeng) { + const char *yytext = yytext_ - 1; + yytext -= accLeng; - while (yychar_ - && yychar_ != quote - && yychar_ != '\n') { - if (yychar_ == '\\') - lexBackslash(tk->rawSyntaxK_); - else - yyinput(); - } + while (yychar_ && yychar_ != quote && yychar_ != '\n') { + if (yychar_ == '\\') + lexBackslash(tk->rawSyntaxK_); + else + yyinput(); + } - int yyleng = yytext_ - yytext + 1; - yyleng += accLeng; + int yyleng = yytext_ - yytext + 1; + yyleng += accLeng; - if (yychar_ == quote) - yyinput(); + if (yychar_ == quote) + yyinput(); - if (quote == '\'') - tk->character_ = tree_->characterConstant(yytext, yyleng); - else - tk->string_ = tree_->stringLiteral(yytext, yyleng); + if (quote == '\'') + tk->character_ = tree_->characterConstant(yytext, yyleng); + else + tk->string_ = tree_->stringLiteral(yytext, yyleng); } -void Lexer::lexSingleLineComment(std::uint16_t rawSyntaxK) -{ - while (yychar_ && yychar_ != '\n') { - if (yychar_ == '\\') - lexBackslash(rawSyntaxK); - else if (yychar_) - yyinput(); - } +void Lexer::lexSingleLineComment(std::uint16_t rawSyntaxK) { + while (yychar_ && yychar_ != '\n') { + if (yychar_ == '\\') + lexBackslash(rawSyntaxK); + else if (yychar_) + yyinput(); + } } diff --git a/C/parser/Lexer.h b/C/parser/Lexer.h index 94f5b42a9..33b889497 100644 --- a/C/parser/Lexer.h +++ b/C/parser/Lexer.h @@ -41,110 +41,111 @@ class ParseOptions; /** * \brief The C Lexer class. */ -class PSY_C_NON_API Lexer -{ +class PSY_C_NON_API Lexer { public: - ~Lexer(); + ~Lexer(); - void lex(); + void lex(); -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SyntaxTree); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SyntaxTree); - Lexer(SyntaxTree* tree); + Lexer(SyntaxTree *tree); private: - // Unavailable - Lexer(const Lexer&) = delete; - void operator=(const Lexer&) = delete; - - void yylex(SyntaxToken* tk); - void yylex_core(SyntaxToken* tk); - void yyinput(); - void yyinput_core(const char*& yy, - unsigned char& yychar, - unsigned int& yycolumn, - unsigned int& offset); - - /* 6.4.2 Identifiers */ - void lexIdentifier(SyntaxToken* tk, int advanced = 0); - - /* 6.4.4 Constants */ - void lexCharacterConstant(SyntaxToken* tk, unsigned char prefix = 0); - - void lexIntegerOrFloatingConstant(SyntaxToken* tk); - void lexIntegerOrFloating_AtFollowOfSuffix(SyntaxToken* tk, std::function); - - void lexIntegerOrImaginaryIntegerSuffix(SyntaxToken* tk, unsigned int accLeng); - void lexIntegerSuffix(int suffixCnt = 2); - void lexImaginaryIntegerSuffix(SyntaxToken* tk); - void lexImaginaryIntegerSuffix_AtFirst(SyntaxToken* tk); - - void lexFloatingOrImaginaryFloating_AtFollowOfPeriod(SyntaxToken* tk, unsigned int accLeng); - void lexFloatingOrImaginaryFloating_AtExponent(SyntaxToken* tk, unsigned int accLeng); - void lexFloatingOrImaginaryFloatingSuffix(SyntaxToken* tk, unsigned int accLeng); - void lexFloatingSuffix(); - void lexImaginaryFloatingSuffix(SyntaxToken* tk); - void lexImaginaryFloatingSuffix_AtFirst(SyntaxToken* tk); - - void lexDigitSequence(); - void lexHexadecimalDigitSequence(); - void lexExponentPart(); - void lexBinaryExponentPart(); - void lexSign(); - - /* 6.4.5 String literals */ - void lexStringLiteral(SyntaxToken* tk, unsigned char prefix = 0); - void lexRawStringLiteral(SyntaxToken* tk, unsigned char prefix = 0); - bool lexContinuedRawStringLiteral(); - - void lexUntilQuote(SyntaxToken* tk, unsigned char quote, unsigned int accLeng); - void lexBackslash(std::uint16_t rawSyntaxK); - void lexSingleLineComment(std::uint16_t rawSyntaxK); - - static SyntaxKind classify(const char* ident, - int size, - const ParseOptions& options); - static SyntaxKind classifyOperator(const char* indent, - int size, - const ParseOptions& options); - - SyntaxTree* tree_; - std::string text_; - const char* c_strBeg_; - const char* c_strEnd_; - - const char* yytext_; - const char* yy_; - unsigned char yychar_; - unsigned int yylineno_; - unsigned int yycolumn_; - - unsigned int offset_; - unsigned int offsetMarker_; - - // Line breaks and continuations aren't strictly correct... (see quirks - // at https://gcc.gnu.org/onlinedocs/cppinternals/Lexer.html). - bool withinLogicalLine_; - std::uint16_t rawSyntaxK_splitTk; - - struct DiagnosticsReporter - { - DiagnosticsReporter(Lexer* lexer) : lexer_(lexer) {} - Lexer* lexer_; - - void IncompatibleLanguageDialect(const std::string& feature, LanguageDialect::Std expectedStd); - void IncompatibleLanguageExtension(const std::string& feature, LanguageExtensions::Ext expectedExt); - - static const std::string ID_of_IncompatibleLanguageDialect; - static const std::string ID_of_IncompatibleLanguageExtension; - }; - friend struct DiagnosticsReporter; - - DiagnosticsReporter diagReporter_; + // Unavailable + Lexer(const Lexer &) = delete; + void operator=(const Lexer &) = delete; + + void yylex(SyntaxToken *tk); + void yylex_core(SyntaxToken *tk); + void yyinput(); + void yyinput_core(const char *&yy, unsigned char &yychar, + unsigned int &yycolumn, unsigned int &offset); + + /* 6.4.2 Identifiers */ + void lexIdentifier(SyntaxToken *tk, int advanced = 0); + + /* 6.4.4 Constants */ + void lexCharacterConstant(SyntaxToken *tk, unsigned char prefix = 0); + + void lexIntegerOrFloatingConstant(SyntaxToken *tk); + void lexIntegerOrFloating_AtFollowOfSuffix(SyntaxToken *tk, + std::function); + + void lexIntegerOrImaginaryIntegerSuffix(SyntaxToken *tk, + unsigned int accLeng); + void lexIntegerSuffix(int suffixCnt = 2); + void lexImaginaryIntegerSuffix(SyntaxToken *tk); + void lexImaginaryIntegerSuffix_AtFirst(SyntaxToken *tk); + + void lexFloatingOrImaginaryFloating_AtFollowOfPeriod(SyntaxToken *tk, + unsigned int accLeng); + void lexFloatingOrImaginaryFloating_AtExponent(SyntaxToken *tk, + unsigned int accLeng); + void lexFloatingOrImaginaryFloatingSuffix(SyntaxToken *tk, + unsigned int accLeng); + void lexFloatingSuffix(); + void lexImaginaryFloatingSuffix(SyntaxToken *tk); + void lexImaginaryFloatingSuffix_AtFirst(SyntaxToken *tk); + + void lexDigitSequence(); + void lexHexadecimalDigitSequence(); + void lexExponentPart(); + void lexBinaryExponentPart(); + void lexSign(); + + /* 6.4.5 String literals */ + void lexStringLiteral(SyntaxToken *tk, unsigned char prefix = 0); + void lexRawStringLiteral(SyntaxToken *tk, unsigned char prefix = 0); + bool lexContinuedRawStringLiteral(); + + void lexUntilQuote(SyntaxToken *tk, unsigned char quote, + unsigned int accLeng); + void lexBackslash(std::uint16_t rawSyntaxK); + void lexSingleLineComment(std::uint16_t rawSyntaxK); + + static SyntaxKind classify(const char *ident, int size, + const ParseOptions &options); + static SyntaxKind classifyOperator(const char *indent, int size, + const ParseOptions &options); + + SyntaxTree *tree_; + std::string text_; + const char *c_strBeg_; + const char *c_strEnd_; + + const char *yytext_; + const char *yy_; + unsigned char yychar_; + unsigned int yylineno_; + unsigned int yycolumn_; + + unsigned int offset_; + unsigned int offsetMarker_; + + // Line breaks and continuations aren't strictly correct... (see quirks + // at https://gcc.gnu.org/onlinedocs/cppinternals/Lexer.html). + bool withinLogicalLine_; + std::uint16_t rawSyntaxK_splitTk; + + struct DiagnosticsReporter { + DiagnosticsReporter(Lexer *lexer) : lexer_(lexer) {} + Lexer *lexer_; + + void IncompatibleLanguageDialect(const std::string &feature, + LanguageDialect::Std expectedStd); + void IncompatibleLanguageExtension(const std::string &feature, + LanguageExtensions::Ext expectedExt); + + static const std::string ID_of_IncompatibleLanguageDialect; + static const std::string ID_of_IncompatibleLanguageExtension; + }; + friend struct DiagnosticsReporter; + + DiagnosticsReporter diagReporter_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/LineDirective.cpp b/C/parser/LineDirective.cpp index 1a92a7dcc..eb875642c 100644 --- a/C/parser/LineDirective.cpp +++ b/C/parser/LineDirective.cpp @@ -24,25 +24,12 @@ using namespace psy; using namespace C; -LineDirective::LineDirective(unsigned int lineno, - const std::string& fileName, +LineDirective::LineDirective(unsigned int lineno, const std::string &fileName, unsigned int offset) - : lineno_(lineno) - , fileName_(fileName) - , offset_(offset) -{} + : lineno_(lineno), fileName_(fileName), offset_(offset) {} -std::string LineDirective::fileName() const -{ - return fileName_; -} +std::string LineDirective::fileName() const { return fileName_; } -unsigned int LineDirective::lineno() const -{ - return lineno_; -} +unsigned int LineDirective::lineno() const { return lineno_; } -unsigned int LineDirective::offset() const -{ - return offset_; -} +unsigned int LineDirective::offset() const { return offset_; } diff --git a/C/parser/LineDirective.h b/C/parser/LineDirective.h index 928788834..3c319a1cd 100644 --- a/C/parser/LineDirective.h +++ b/C/parser/LineDirective.h @@ -34,35 +34,33 @@ namespace C { /** * \brief The LineDirective class. */ -class PSY_C_NON_API LineDirective -{ +class PSY_C_NON_API LineDirective { public: - LineDirective(unsigned int lineno, - const std::string& fileName, - unsigned int offset); + LineDirective(unsigned int lineno, const std::string &fileName, + unsigned int offset); - /** - * The file name. - */ - std::string fileName() const; + /** + * The file name. + */ + std::string fileName() const; - /** - * The line number. - */ - unsigned int lineno() const; + /** + * The line number. + */ + unsigned int lineno() const; - /** - * The offset in the file. - */ - unsigned int offset() const; + /** + * The offset in the file. + */ + unsigned int offset() const; private: - unsigned int lineno_; - std::string fileName_; - unsigned int offset_; + unsigned int lineno_; + std::string fileName_; + unsigned int offset_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/MacroTranslations.cpp b/C/parser/MacroTranslations.cpp index b90afc71b..e224e6e17 100644 --- a/C/parser/MacroTranslations.cpp +++ b/C/parser/MacroTranslations.cpp @@ -20,18 +20,17 @@ #include "MacroTranslations.h" -#define DEFINE_ENABLE_ISENABLED(FLAG) \ - MacroTranslations& MacroTranslations::enable_##FLAG(bool enable) \ - { BF_.FLAG##_ = enable; return *this; } \ - bool MacroTranslations::isEnabled_##FLAG() const \ - { return BF_.FLAG##_; } +#define DEFINE_ENABLE_ISENABLED(FLAG) \ + MacroTranslations &MacroTranslations::enable_##FLAG(bool enable) { \ + BF_.FLAG##_ = enable; \ + return *this; \ + } \ + bool MacroTranslations::isEnabled_##FLAG() const { return BF_.FLAG##_; } using namespace psy; using namespace C; -MacroTranslations::MacroTranslations() - : BF_all_(~0) -{} +MacroTranslations::MacroTranslations() : BF_all_(~0) {} DEFINE_ENABLE_ISENABLED(Translate_static_assert_AsKeyword) DEFINE_ENABLE_ISENABLED(Translate_complex_AsKeyword) diff --git a/C/parser/MacroTranslations.h b/C/parser/MacroTranslations.h index a87f2a489..4695db5ea 100644 --- a/C/parser/MacroTranslations.h +++ b/C/parser/MacroTranslations.h @@ -33,136 +33,133 @@ namespace C { /** * \brief The MacroTranslations class. */ -class PSY_C_API MacroTranslations final -{ +class PSY_C_API MacroTranslations final { public: - //!@{ - /** - * Create MacroTranslations. - */ - MacroTranslations(); - //!@} - - //!@{ - /** - * Whether to translate macro \c static_assert as \c _Static_assert. - * From header . - * - * \remark 7.2 - */ - MacroTranslations& enable_Translate_static_assert_AsKeyword(bool expand); - bool isEnabled_Translate_static_assert_AsKeyword() const; - //!@} - - //!@{ - /** - * Whether to translate macro \c complex as \c _Complex. - * From header . - * - * \remark 7.3 - */ - MacroTranslations& enable_Translate_complex_AsKeyword(bool expand); - bool isEnabled_Translate_complex_AsKeyword() const; - //!@} - - //!@{ - /** - * Whether to translate operators names. - * From header . - * - * \remark 7.9 - */ - MacroTranslations& enable_Translate_operatorNames(bool expand); - bool isEnabled_Translate_operatorNames() const; - //!@} - - //!@{ - /** - * Whether to translate macro \c alignas as \c _Alignas. - * From header . - * - * \remark 7.15 - */ - MacroTranslations& enable_Translate_alignas_AsKeyword(bool expand); - bool isEnabled_Translate_alignas_AsKeyword() const; - //!@} - - //!@{ - /** - * Whether to translate macro \c alignof as \c _Alignof. - * From header . - * - * \remark 7.15 - */ - MacroTranslations& enable_Translate_alignof_AsKeyword(bool expand); - bool isEnabled_Translate_alignof_AsKeyword() const; - //!@} - - //!@{ - /** - * Whether to translate macro \c va_arg as an internal builtin. - * From header . - * - * \remark 7.16 - */ - MacroTranslations& enable_Translate_va_arg_AsKeyword(bool expand); - bool isEnabled_Translate_va_arg_AsKeyword() const; - //!@} - - //!@{ - /** - * Whether to translate macro \c offsetof as an internal builtin. - * From header - * - * \remark 7.19 - */ - MacroTranslations& enable_Translate_offsetof_AsKeyword(bool expand); - bool isEnabled_Translate_offsetof_AsKeyword() const; - //!@} - - //!@{ - /** - * Whether to translate macro \c bool as \c _Bool. - * From header . - * - * \remark 7.18 - */ - MacroTranslations& enable_Translate_bool_AsKeyword(bool expand); - bool isEnabled_Translate_bool_AsKeyword() const; - //!@} - - //!@{ - /** - * Whether to translate macro \c thread_local as \c _Thread_local. - * From header . - * - * \remark 7.26 - */ - MacroTranslations& enable_Translate_thread_local_AsKeyword(bool expand); - bool isEnabled_Translate_thread_local_AsKeyword() const; - //!@} + //!@{ + /** + * Create MacroTranslations. + */ + MacroTranslations(); + //!@} + + //!@{ + /** + * Whether to translate macro \c static_assert as \c _Static_assert. + * From header . + * + * \remark 7.2 + */ + MacroTranslations &enable_Translate_static_assert_AsKeyword(bool expand); + bool isEnabled_Translate_static_assert_AsKeyword() const; + //!@} + + //!@{ + /** + * Whether to translate macro \c complex as \c _Complex. + * From header . + * + * \remark 7.3 + */ + MacroTranslations &enable_Translate_complex_AsKeyword(bool expand); + bool isEnabled_Translate_complex_AsKeyword() const; + //!@} + + //!@{ + /** + * Whether to translate operators names. + * From header . + * + * \remark 7.9 + */ + MacroTranslations &enable_Translate_operatorNames(bool expand); + bool isEnabled_Translate_operatorNames() const; + //!@} + + //!@{ + /** + * Whether to translate macro \c alignas as \c _Alignas. + * From header . + * + * \remark 7.15 + */ + MacroTranslations &enable_Translate_alignas_AsKeyword(bool expand); + bool isEnabled_Translate_alignas_AsKeyword() const; + //!@} + + //!@{ + /** + * Whether to translate macro \c alignof as \c _Alignof. + * From header . + * + * \remark 7.15 + */ + MacroTranslations &enable_Translate_alignof_AsKeyword(bool expand); + bool isEnabled_Translate_alignof_AsKeyword() const; + //!@} + + //!@{ + /** + * Whether to translate macro \c va_arg as an internal builtin. + * From header . + * + * \remark 7.16 + */ + MacroTranslations &enable_Translate_va_arg_AsKeyword(bool expand); + bool isEnabled_Translate_va_arg_AsKeyword() const; + //!@} + + //!@{ + /** + * Whether to translate macro \c offsetof as an internal builtin. + * From header + * + * \remark 7.19 + */ + MacroTranslations &enable_Translate_offsetof_AsKeyword(bool expand); + bool isEnabled_Translate_offsetof_AsKeyword() const; + //!@} + + //!@{ + /** + * Whether to translate macro \c bool as \c _Bool. + * From header . + * + * \remark 7.18 + */ + MacroTranslations &enable_Translate_bool_AsKeyword(bool expand); + bool isEnabled_Translate_bool_AsKeyword() const; + //!@} + + //!@{ + /** + * Whether to translate macro \c thread_local as \c _Thread_local. + * From header . + * + * \remark 7.26 + */ + MacroTranslations &enable_Translate_thread_local_AsKeyword(bool expand); + bool isEnabled_Translate_thread_local_AsKeyword() const; + //!@} private: - struct BitFields - { - std::uint64_t Translate_static_assert_AsKeyword_: 1; - std::uint64_t Translate_complex_AsKeyword_: 1; - std::uint64_t Translate_operatorNames_ : 1; - std::uint64_t Translate_alignas_AsKeyword_ : 1; - std::uint64_t Translate_alignof_AsKeyword_ : 1; - std::uint64_t Translate_va_arg_AsKeyword_ : 1; - std::uint64_t Translate_offsetof_AsKeyword_ : 1; - std::uint64_t Translate_bool_AsKeyword_ : 1; - std::uint64_t Translate_thread_local_AsKeyword_ : 1; - }; - union - { - std::uint64_t BF_all_; - BitFields BF_; - }; + struct BitFields { + std::uint64_t Translate_static_assert_AsKeyword_ : 1; + std::uint64_t Translate_complex_AsKeyword_ : 1; + std::uint64_t Translate_operatorNames_ : 1; + std::uint64_t Translate_alignas_AsKeyword_ : 1; + std::uint64_t Translate_alignof_AsKeyword_ : 1; + std::uint64_t Translate_va_arg_AsKeyword_ : 1; + std::uint64_t Translate_offsetof_AsKeyword_ : 1; + std::uint64_t Translate_bool_AsKeyword_ : 1; + std::uint64_t Translate_thread_local_AsKeyword_ : 1; + }; + union { + std::uint64_t BF_all_; + BitFields BF_; + }; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/ParseOptions.cpp b/C/parser/ParseOptions.cpp index 0b7d17eff..4f9cc28fa 100644 --- a/C/parser/ParseOptions.cpp +++ b/C/parser/ParseOptions.cpp @@ -25,60 +25,52 @@ using namespace psy; using namespace C; ParseOptions::ParseOptions() - : ParseOptions(LanguageDialect(), - LanguageExtensions()) -{} + : ParseOptions(LanguageDialect(), LanguageExtensions()) {} ParseOptions::ParseOptions(LanguageDialect dialect, LanguageExtensions extensions) - : dialect_(std::move(dialect)) - , extensions_(std::move(extensions)) - , bits_(0) -{ - setTreatmentOfIdentifiers(TreatmentOfIdentifiers::Classify); - setTreatmentOfComments(TreatmentOfComments::None); - setTreatmentOfAmbiguities(TreatmentOfAmbiguities::DisambiguateAlgorithmicallyOrHeuristically); + : dialect_(std::move(dialect)), extensions_(std::move(extensions)), + bits_(0) { + setTreatmentOfIdentifiers(TreatmentOfIdentifiers::Classify); + setTreatmentOfComments(TreatmentOfComments::None); + setTreatmentOfAmbiguities( + TreatmentOfAmbiguities::DisambiguateAlgorithmicallyOrHeuristically); } -const LanguageDialect& ParseOptions::dialect() const -{ - return dialect_; -} +const LanguageDialect &ParseOptions::dialect() const { return dialect_; } -const LanguageExtensions& ParseOptions::extensions() const -{ - return extensions_; +const LanguageExtensions &ParseOptions::extensions() const { + return extensions_; } -ParseOptions& ParseOptions::setTreatmentOfIdentifiers(TreatmentOfIdentifiers treatOfIdent) -{ - BF_.treatmentOfIdentifiers_ = static_cast(treatOfIdent); - return *this; +ParseOptions & +ParseOptions::setTreatmentOfIdentifiers(TreatmentOfIdentifiers treatOfIdent) { + BF_.treatmentOfIdentifiers_ = static_cast(treatOfIdent); + return *this; } -ParseOptions::TreatmentOfIdentifiers ParseOptions::treatmentOfIdentifiers() const -{ - return static_cast(BF_.treatmentOfIdentifiers_); +ParseOptions::TreatmentOfIdentifiers +ParseOptions::treatmentOfIdentifiers() const { + return static_cast(BF_.treatmentOfIdentifiers_); } -ParseOptions& ParseOptions::setTreatmentOfComments(TreatmentOfComments treatOfComments) -{ - BF_.treatmentOfComments_ = static_cast(treatOfComments); - return *this; +ParseOptions & +ParseOptions::setTreatmentOfComments(TreatmentOfComments treatOfComments) { + BF_.treatmentOfComments_ = static_cast(treatOfComments); + return *this; } -ParseOptions::TreatmentOfComments ParseOptions::treatmentOfComments() const -{ - return static_cast(BF_.treatmentOfComments_); +ParseOptions::TreatmentOfComments ParseOptions::treatmentOfComments() const { + return static_cast(BF_.treatmentOfComments_); } -ParseOptions &ParseOptions::setTreatmentOfAmbiguities(TreatmentOfAmbiguities treatOfAmbigs) -{ - BF_.treatmentOfAmbiguities_ = static_cast(treatOfAmbigs); - return *this; +ParseOptions & +ParseOptions::setTreatmentOfAmbiguities(TreatmentOfAmbiguities treatOfAmbigs) { + BF_.treatmentOfAmbiguities_ = static_cast(treatOfAmbigs); + return *this; } -ParseOptions::TreatmentOfAmbiguities ParseOptions::treatmentOfAmbiguities() const -{ - return static_cast(BF_.treatmentOfAmbiguities_); +ParseOptions::TreatmentOfAmbiguities +ParseOptions::treatmentOfAmbiguities() const { + return static_cast(BF_.treatmentOfAmbiguities_); } diff --git a/C/parser/ParseOptions.h b/C/parser/ParseOptions.h index 861eae0d8..ac83de9a1 100644 --- a/C/parser/ParseOptions.h +++ b/C/parser/ParseOptions.h @@ -39,98 +39,95 @@ namespace C { * * Options to the lexer are also specified through this class. */ -class PSY_C_API ParseOptions -{ +class PSY_C_API ParseOptions { public: - //!@{ - /** - * Create ParseOptions. - */ - ParseOptions(); - ParseOptions(LanguageDialect dialect, - LanguageExtensions extensions); - //!@} - - /** - * The LanguageDialect of \c this ParseOptions. - */ - const LanguageDialect& dialect() const; - - /** - * The LanguageExtensions of \c this ParseOptions. - */ - const LanguageExtensions& extensions() const; - - //!@{ - /** - * \brief The alternatives for TreatmentOfIdentifiers during parse. - */ - enum class TreatmentOfIdentifiers : std::uint8_t - { - None, /**< No special treatment. */ - Classify /**< Classify into keywords and non-keywords ("plain identifiers"). */ - }; - /** - * The TreatmentOfIdentifiers of \c this ParserOptions. - */ - ParseOptions& setTreatmentOfIdentifiers(TreatmentOfIdentifiers treatOfIdent); - TreatmentOfIdentifiers treatmentOfIdentifiers() const; - //!@} - - //!@{ - /** - * \brief The alternatives for TreatmentOfComments during parse. - */ - enum class TreatmentOfComments : std::uint8_t - { - None, /**< No special treatment. */ - Keep, /**< Keep comments. */ - KeepDocumentationOnly /**< Keep documentation comments only. */ - }; - /** - * The TreatmentOfComments of \c this ParserOptions. - */ - ParseOptions& setTreatmentOfComments(TreatmentOfComments treatOfComments); - TreatmentOfComments treatmentOfComments() const; - //!@} - - //!@{ - /** - * * \brief The alternatives for TreatmentOfAmbiguities during parse. - */ - enum class TreatmentOfAmbiguities : std::uint8_t - { - None, /**< No special treatment (ambiguities are preserved). */ - Diagnose, /**< Diagnose ambiguities. */ - DisambiguateAlgorithmically, /**< Disambiguate ambiguities algorithmically. */ - DisambiguateAlgorithmicallyOrHeuristically, /**< Disambiguate ambiguities algorithmically/heristically. */ - DisambiguateHeuristically, /**< Disambiguate ambiguities heuristically. */ - }; - /** - * The TreatmentOfAmbiguities of \c this ParserOptions. - */ - ParseOptions& setTreatmentOfAmbiguities(TreatmentOfAmbiguities treatOfAmbigs); - TreatmentOfAmbiguities treatmentOfAmbiguities() const; - //!@} + //!@{ + /** + * Create ParseOptions. + */ + ParseOptions(); + ParseOptions(LanguageDialect dialect, LanguageExtensions extensions); + //!@} + + /** + * The LanguageDialect of \c this ParseOptions. + */ + const LanguageDialect &dialect() const; + + /** + * The LanguageExtensions of \c this ParseOptions. + */ + const LanguageExtensions &extensions() const; + + //!@{ + /** + * \brief The alternatives for TreatmentOfIdentifiers during parse. + */ + enum class TreatmentOfIdentifiers : std::uint8_t { + None, /**< No special treatment. */ + Classify /**< Classify into keywords and non-keywords ("plain identifiers"). + */ + }; + /** + * The TreatmentOfIdentifiers of \c this ParserOptions. + */ + ParseOptions &setTreatmentOfIdentifiers(TreatmentOfIdentifiers treatOfIdent); + TreatmentOfIdentifiers treatmentOfIdentifiers() const; + //!@} + + //!@{ + /** + * \brief The alternatives for TreatmentOfComments during parse. + */ + enum class TreatmentOfComments : std::uint8_t { + None, /**< No special treatment. */ + Keep, /**< Keep comments. */ + KeepDocumentationOnly /**< Keep documentation comments only. */ + }; + /** + * The TreatmentOfComments of \c this ParserOptions. + */ + ParseOptions &setTreatmentOfComments(TreatmentOfComments treatOfComments); + TreatmentOfComments treatmentOfComments() const; + //!@} + + //!@{ + /** + * * \brief The alternatives for TreatmentOfAmbiguities during parse. + */ + enum class TreatmentOfAmbiguities : std::uint8_t { + None, /**< No special treatment (ambiguities are preserved). */ + Diagnose, /**< Diagnose ambiguities. */ + DisambiguateAlgorithmically, /**< Disambiguate ambiguities algorithmically. + */ + DisambiguateAlgorithmicallyOrHeuristically, /**< Disambiguate ambiguities + algorithmically/heristically. + */ + DisambiguateHeuristically, /**< Disambiguate ambiguities heuristically. */ + }; + /** + * The TreatmentOfAmbiguities of \c this ParserOptions. + */ + ParseOptions &setTreatmentOfAmbiguities(TreatmentOfAmbiguities treatOfAmbigs); + TreatmentOfAmbiguities treatmentOfAmbiguities() const; + //!@} private: - LanguageDialect dialect_; - LanguageExtensions extensions_; - - struct BitFields - { - std::uint16_t treatmentOfIdentifiers_ : 2; - std::uint16_t treatmentOfComments_ : 2; - std::uint16_t treatmentOfAmbiguities_ : 2; - }; - union - { - BitFields BF_; - std::uint16_t bits_; - }; + LanguageDialect dialect_; + LanguageExtensions extensions_; + + struct BitFields { + std::uint16_t treatmentOfIdentifiers_ : 2; + std::uint16_t treatmentOfComments_ : 2; + std::uint16_t treatmentOfAmbiguities_ : 2; + }; + union { + BitFields BF_; + std::uint16_t bits_; + }; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/Parser.cpp b/C/parser/Parser.cpp index 63d89358c..5faa2001a 100644 --- a/C/parser/Parser.cpp +++ b/C/parser/Parser.cpp @@ -28,309 +28,274 @@ int depth_ = 0; /* Backtracker */ -Parser::Backtracker::Backtracker(Parser* parser, LexedTokens::IndexType tkIdx) - : parser_(parser) - , refTkIdx_(tkIdx == 0 ? parser->curTkIdx_ : tkIdx) - , done_(false) -{ - if (parser_->backtracker_) - chained_.push(parser_->backtracker_); - parser_->backtracker_ = this; +Parser::Backtracker::Backtracker(Parser *parser, LexedTokens::IndexType tkIdx) + : parser_(parser), refTkIdx_(tkIdx == 0 ? parser->curTkIdx_ : tkIdx), + done_(false) { + if (parser_->backtracker_) + chained_.push(parser_->backtracker_); + parser_->backtracker_ = this; } -Parser::Backtracker::~Backtracker() -{ - if (!done_) - discard(); +Parser::Backtracker::~Backtracker() { + if (!done_) + discard(); } -void Parser::Backtracker::discard() -{ - if (done_) - return; +void Parser::Backtracker::discard() { + if (done_) + return; - if (!chained_.empty()) { - parser_->backtracker_ = chained_.top(); - chained_.pop(); - } - else - parser_->backtracker_ = nullptr; - done_ = true; + if (!chained_.empty()) { + parser_->backtracker_ = chained_.top(); + chained_.pop(); + } else + parser_->backtracker_ = nullptr; + done_ = true; } -void Parser::Backtracker::backtrack() -{ - if (parser_->curTkIdx_ == refTkIdx_) { - discard(); - return; - } +void Parser::Backtracker::backtrack() { + if (parser_->curTkIdx_ == refTkIdx_) { + discard(); + return; + } #ifdef DEBUG_RULE - std::cerr << std::string(depth_ * 4, ' ') - << "BACKTRACKING from " - << "`" << parser_->peek().valueText() << "' " - << parser_->curTkIdx_ << " to "; + std::cerr << std::string(depth_ * 4, ' ') << "BACKTRACKING from " + << "`" << parser_->peek().valueText() << "' " << parser_->curTkIdx_ + << " to "; #endif - auto tkCnt = parser_->tree_->tokenCount(); - if (parser_->curTkIdx_ < tkCnt) - parser_->curTkIdx_ = refTkIdx_; - else - parser_->curTkIdx_ = tkCnt - 1; + auto tkCnt = parser_->tree_->tokenCount(); + if (parser_->curTkIdx_ < tkCnt) + parser_->curTkIdx_ = refTkIdx_; + else + parser_->curTkIdx_ = tkCnt - 1; #ifdef DEBUG_RULE - std::cerr << "`" << parser_->peek().valueText() << "' " - << parser_->curTkIdx_ << std::endl; + std::cerr << "`" << parser_->peek().valueText() << "' " << parser_->curTkIdx_ + << std::endl; #endif - discard(); + discard(); } /* DepthControl */ -Parser::DepthControl::DepthControl(int& depth) - : depth_(depth) -{ - if (depth_ > MAX_DEPTH_OF_STMTS) - throw std::runtime_error("maximum depth of statements reached"); - ++depth_; +Parser::DepthControl::DepthControl(int &depth) : depth_(depth) { + if (depth_ > MAX_DEPTH_OF_STMTS) + throw std::runtime_error("maximum depth of statements reached"); + ++depth_; } -Parser::DepthControl::~DepthControl() -{ - --depth_; -} +Parser::DepthControl::~DepthControl() { --depth_; } /* Parser */ -Parser::Parser(SyntaxTree* tree) - : pool_(tree->unitPool()) - , tree_(tree) - , backtracker_(nullptr) - , diagReporter_(this) - , curTkIdx_(1) - , DEPTH_OF_EXPRS_(0) - , DEPTH_OF_STMTS_(0) -{ - depth_ = 0; +Parser::Parser(SyntaxTree *tree) + : pool_(tree->unitPool()), tree_(tree), backtracker_(nullptr), + diagReporter_(this), curTkIdx_(1), DEPTH_OF_EXPRS_(0), + DEPTH_OF_STMTS_(0) { + depth_ = 0; } -Parser::~Parser() -{} +Parser::~Parser() {} -const SyntaxToken& Parser::peek(unsigned int LA) const -{ - return tree_->tokenAt(curTkIdx_ + LA - 1); +const SyntaxToken &Parser::peek(unsigned int LA) const { + return tree_->tokenAt(curTkIdx_ + LA - 1); } -LexedTokens::IndexType Parser::consume() -{ - return curTkIdx_++; -} +LexedTokens::IndexType Parser::consume() { return curTkIdx_++; } /** * Match a token of the given kind. */ -bool Parser::match(SyntaxKind expectedTkK, LexedTokens::IndexType* tkIdx) -{ - auto curTkK = peek().kind(); - if (curTkK == expectedTkK) - { - *tkIdx = consume(); - return true; - } - - diagReporter_.ExpectedToken(SyntaxKind(expectedTkK)); - - if (curTkK != EndOfFile) - consume(); - *tkIdx = LexedTokens::invalidIndex(); - return false; +bool Parser::match(SyntaxKind expectedTkK, LexedTokens::IndexType *tkIdx) { + auto curTkK = peek().kind(); + if (curTkK == expectedTkK) { + *tkIdx = consume(); + return true; + } + + diagReporter_.ExpectedToken(SyntaxKind(expectedTkK)); + + if (curTkK != EndOfFile) + consume(); + *tkIdx = LexedTokens::invalidIndex(); + return false; } /** * Match a token of the given kind;; if the match was not successful, * skip until a token of the given kind is found. */ -bool Parser::matchOrSkipTo(SyntaxKind expectedTkK, LexedTokens::IndexType* tkIdx) -{ - if (match(expectedTkK, tkIdx)) - return true; - skipTo(expectedTkK); - return false; +bool Parser::matchOrSkipTo(SyntaxKind expectedTkK, + LexedTokens::IndexType *tkIdx) { + if (match(expectedTkK, tkIdx)) + return true; + skipTo(expectedTkK); + return false; } /** * Skip until a token of the given kind is found. */ -void Parser::skipTo(SyntaxKind tkK) -{ - auto curTkK = peek().kind(); - while (curTkK != tkK) { - if (curTkK == EndOfFile) - return; - consume(); - curTkK = peek().kind(); - } +void Parser::skipTo(SyntaxKind tkK) { + auto curTkK = peek().kind(); + while (curTkK != tkK) { + if (curTkK == EndOfFile) + return; + consume(); + curTkK = peek().kind(); + } } /** * Whether the parser is in backtracking mode. */ -bool Parser::mightBacktrack() const -{ - return static_cast(backtracker_); -} +bool Parser::mightBacktrack() const { return static_cast(backtracker_); } /** - * Parse the syntax associated to the SyntaxTree used to construct \c this Parser. + * Parse the syntax associated to the SyntaxTree used to construct \c this + * Parser. * * \return a TranslationUnitSyntax. */ -TranslationUnitSyntax* Parser::parse() -{ - auto unit = makeNode(); - parseTranslationUnit(unit); - return unit; +TranslationUnitSyntax *Parser::parse() { + auto unit = makeNode(); + parseTranslationUnit(unit); + return unit; } -bool Parser::detectedAnyAmbiguity() const -{ - return !diagReporter_.retainedAmbiguityDiags_.empty(); +bool Parser::detectedAnyAmbiguity() const { + return !diagReporter_.retainedAmbiguityDiags_.empty(); } -std::vector< - std::pair> Parser::releaseRetainedAmbiguityDiags() const -{ - return std::move(diagReporter_.retainedAmbiguityDiags_); +std::vector> +Parser::releaseRetainedAmbiguityDiags() const { + return std::move(diagReporter_.retainedAmbiguityDiags_); } -bool Parser::ignoreDeclarator() -{ - while (true) { - switch (peek().kind()) { - // Just return. - case EndOfFile: - case CommaToken: - case IdentifierToken: - case AsteriskToken: - return false; - - // Skip and return. - case SemicolonToken: - case CloseBraceToken: - consume(); - return false; - - // Skip. - default: - consume(); - } +bool Parser::ignoreDeclarator() { + while (true) { + switch (peek().kind()) { + // Just return. + case EndOfFile: + case CommaToken: + case IdentifierToken: + case AsteriskToken: + return false; + + // Skip and return. + case SemicolonToken: + case CloseBraceToken: + consume(); + return false; + + // Skip. + default: + consume(); } + } } -bool Parser::ignoreDeclarationOrDefinition() -{ - while (true) { - switch (peek().kind()) { - // Just return. - case EndOfFile: - case Keyword_typedef: - case Keyword_extern: - case Keyword_static: - case Keyword__Thread_local: - case Keyword_ExtGNU___thread: - case Keyword_auto: - case Keyword_register: - case Keyword_inline: - case Keyword__Noreturn: - case Keyword_struct: - case Keyword_union: - case Keyword_enum: - case Keyword__Static_assert: - case Keyword_ExtGNU___asm__: - return false; - - // Skip and return. - case SemicolonToken: - case CloseBraceToken: - consume(); - return false; - - // Skip. - default: - consume(); - } +bool Parser::ignoreDeclarationOrDefinition() { + while (true) { + switch (peek().kind()) { + // Just return. + case EndOfFile: + case Keyword_typedef: + case Keyword_extern: + case Keyword_static: + case Keyword__Thread_local: + case Keyword_ExtGNU___thread: + case Keyword_auto: + case Keyword_register: + case Keyword_inline: + case Keyword__Noreturn: + case Keyword_struct: + case Keyword_union: + case Keyword_enum: + case Keyword__Static_assert: + case Keyword_ExtGNU___asm__: + return false; + + // Skip and return. + case SemicolonToken: + case CloseBraceToken: + consume(); + return false; + + // Skip. + default: + consume(); } + } } -bool Parser::ignoreMemberDeclaration() -{ - while (true) { - switch (peek().kind()) { - // Just return. - case EndOfFile: - case Keyword_typedef: - case Keyword_extern: - case Keyword_static: - case Keyword__Thread_local: - case Keyword_ExtGNU___thread: - case Keyword_auto: - case Keyword_register: - case Keyword_inline: - case Keyword__Noreturn: - case Keyword_struct: - case Keyword_union: - case Keyword_enum: - case Keyword__Static_assert: - case Keyword_ExtGNU___asm__: - return false; - - // Skip and return. - case CommaToken: - case SemicolonToken: - consume(); - return false; - - // Skip. - default: - consume(); - } +bool Parser::ignoreMemberDeclaration() { + while (true) { + switch (peek().kind()) { + // Just return. + case EndOfFile: + case Keyword_typedef: + case Keyword_extern: + case Keyword_static: + case Keyword__Thread_local: + case Keyword_ExtGNU___thread: + case Keyword_auto: + case Keyword_register: + case Keyword_inline: + case Keyword__Noreturn: + case Keyword_struct: + case Keyword_union: + case Keyword_enum: + case Keyword__Static_assert: + case Keyword_ExtGNU___asm__: + return false; + + // Skip and return. + case CommaToken: + case SemicolonToken: + consume(); + return false; + + // Skip. + default: + consume(); } + } } -bool Parser::ignoreStatement() -{ - while (true) { - switch (peek().kind()) { - // Just return. - case EndOfFile: - case Keyword_typedef: - case Keyword_extern: - case Keyword_static: - case Keyword__Thread_local: - case Keyword_ExtGNU___thread: - case Keyword_auto: - case Keyword_register: - case Keyword_inline: - case Keyword__Noreturn: - case Keyword_struct: - case Keyword_union: - case Keyword_enum: - case Keyword__Static_assert: - case Keyword_ExtGNU___asm__: - return false; - - // Skip and return. - case CloseBraceToken: - case SemicolonToken: - consume(); - return false; - - // Skip. - default: - consume(); - } +bool Parser::ignoreStatement() { + while (true) { + switch (peek().kind()) { + // Just return. + case EndOfFile: + case Keyword_typedef: + case Keyword_extern: + case Keyword_static: + case Keyword__Thread_local: + case Keyword_ExtGNU___thread: + case Keyword_auto: + case Keyword_register: + case Keyword_inline: + case Keyword__Noreturn: + case Keyword_struct: + case Keyword_union: + case Keyword_enum: + case Keyword__Static_assert: + case Keyword_ExtGNU___asm__: + return false; + + // Skip and return. + case CloseBraceToken: + case SemicolonToken: + consume(); + return false; + + // Skip. + default: + consume(); } + } } diff --git a/C/parser/Parser.h b/C/parser/Parser.h index f4937c96a..ab7ad8744 100644 --- a/C/parser/Parser.h +++ b/C/parser/Parser.h @@ -25,8 +25,8 @@ #include "API.h" #include "Fwds.h" -#include "SyntaxTree.h" #include "LexedTokens.h" +#include "SyntaxTree.h" #include "infra/MemoryPool.h" #include "syntax/SyntaxToken.h" @@ -36,9 +36,9 @@ #include #include #include -#include #include #include +#include namespace psy { namespace C { @@ -48,466 +48,448 @@ class Lexer; /** * \brief The C Parser class. */ -class PSY_C_NON_API Parser -{ - friend class ParserTester; +class PSY_C_NON_API Parser { + friend class ParserTester; public: - ~Parser(); + ~Parser(); -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SyntaxTree); - PSY_GRANT_ACCESS(DebugRule); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SyntaxTree); + PSY_GRANT_ACCESS(DebugRule); - Parser(SyntaxTree* tree); + Parser(SyntaxTree *tree); - TranslationUnitSyntax* parse(); + TranslationUnitSyntax *parse(); - bool detectedAnyAmbiguity() const; + bool detectedAnyAmbiguity() const; private: - // Unavailable - Parser(const Parser&) = delete; - void operator=(const Parser&) = delete; - - MemoryPool* pool_; - SyntaxTree* tree_; - - // While the parser is in backtracking mode, diagnostics are disabled. - // To avoid unintended omission of syntax errors, the backtracker - // should be discarded immediately after use, either explicitly or - // implicitly; the latter happens either upon the object destruction - // or after a single backtracking operation. - struct Backtracker - { - Backtracker(Parser* parser, LexedTokens::IndexType tkIdx = 0); - ~Backtracker(); - void discard(); - void backtrack(); - - Parser* parser_; - LexedTokens::IndexType refTkIdx_; - bool done_; - std::stack chained_; - }; - friend struct Backtracker; - const Backtracker* backtracker_; - bool mightBacktrack() const; - - struct DiagnosticsReporter - { - DiagnosticsReporter(Parser* parser) - : parser_(parser) - , IDsForDelay_(false) - {} - Parser* parser_; - - static std::string joinTokenNames(const std::vector& validTkKinds); - - std::unordered_set IDsForDelay_; - std::vector> delayedDiags_; - std::vector> retainedAmbiguityDiags_; - - void diagnose(DiagnosticDescriptor&& desc); - void diagnoseDelayed(); - void diagnoseAmbiguityButRetainIt(DiagnosticDescriptor&& desc); - - /* General */ - void ExpectedFeature(const std::string& name); - - static const std::string ID_of_ExpectedFeature; - - /* Terminal */ - void ExpectedToken(SyntaxKind syntaxK); - void ExpectedTokenWithin(const std::vector& validTokens); - void ExpectedTokenOfCategory(SyntaxToken::Category category, const std::string& id); - void ExpectedTokenOfCategoryIdentifier(); - void ExpectedTokenOfCategoryConstant(); - void ExpectedTokenOfCategoryStringLiteral(); - - static const std::string ID_of_ExpectedToken; - static const std::string ID_of_ExpectedTokenWithin; - static const std::string ID_of_ExpectedTokenOfCategoryIdentifier; - static const std::string ID_of_ExpectedTokenOfCategoryConstant; - static const std::string ID_of_ExpectedTokenOfCategoryStringLiteral; - - /* Non-terminal */ - void ExpectedFIRSTof(const std::string& rule, const std::string& id); - void ExpectedFIRSTofExpression(); - void ExpectedFIRSTofEnumerationConstant(); - void ExpectedFIRSTofDirectDeclarator(); - void ExpectedFIRSTofParameterDeclaration(); - void ExpectedFIRSTofSpecifierQualifier(); - void ExpectedFOLLOWofDesignatedInitializer(); - void ExpectedFOLLOWofDeclarator(); - void ExpectedFOLLOWofStructDeclarator(); - void ExpectedFOLLOWofDeclaratorAndInitializer(); - void ExpectedFOLLOWofStructOrUnionOrEnum(); - void ExpectedFOLLOWofEnum(); - - static const std::string ID_of_ExpectedFIRSTofExpression; - static const std::string ID_of_ExpectedFIRSTofEnumerationConstant; - static const std::string ID_of_ExpectedFIRSTofDirectDeclarator; - static const std::string ID_of_ExpectedFIRSTofParameterDeclaration; - static const std::string ID_of_ExpectedFIRSTofSpecifierQualifier; - static const std::string ID_of_ExpectedFOLLOWofDesignatedInitializer; - static const std::string ID_of_ExpectedFOLLOWofDeclarator; - static const std::string ID_of_ExpectedFOLLOWofStructDeclarator; - static const std::string ID_of_ExpectedFOLLOWofDeclaratorAndInitializer; - static const std::string ID_of_ExpectedFOLLOWofStructOrUnionOrEnum; - static const std::string ID_of_ExpectedFOLLOWofEnum; - - /* Detailed */ - void ExpectedFieldName(); - void ExpectedBraceEnclosedInitializerList(); - void ExpectedFieldDesignator(); - void UnexpectedInitializerOfDeclarator(); - void UnexpectedStaticOrTypeQualifiersInArrayDeclarator(); - void UnexpectedPointerInArrayDeclarator(); - void ExpectedNamedParameterBeforeEllipsis(); - void ExpectedTypeSpecifier(); - void UnexpectedCaseLabelOutsideSwitch(); - void UnexpectedDefaultLabelOutsideSwitch(); - void UnexpectedContinueOutsideLoop(); - void UnexpectedBreakOutsideSwitchOrLoop(); - void UnexpectedGNUExtensionFlag(); - - static const std::string ID_of_ExpectedFieldName; - static const std::string ID_of_ExpectedBraceEnclosedInitializerList; - static const std::string ID_of_ExpectedFieldDesignator; - static const std::string ID_of_UnexpectedInitializerOfDeclarator; - static const std::string ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator; - static const std::string ID_of_UnexpectedPointerInArrayDeclarator; - static const std::string ID_of_ExpectedNamedParameterBeforeEllipsis; - static const std::string ID_of_ExpectedTypeSpecifier; - static const std::string ID_of_UnexpectedCaseLabelOutsideSwitch; - static const std::string ID_of_UnexpectedDefaultLabelOutsideSwitch; - static const std::string ID_of_UnexpectedContinueOutsideLoop; - static const std::string ID_of_UnexpectedBreakOutsideSwitchOrLoop; - static const std::string ID_of_UnexpectedGNUExtensionFlag; - - /* Ambiguities */ - void AmbiguousTypeNameOrExpressionAsTypeReference(); - void AmbiguousCastOrBinaryExpression(); - void AmbiguousExpressionOrDeclarationStatement(); - - static const std::string ID_of_AmbiguousTypeNameOrExpressionAsTypeReference; - static const std::string ID_of_AmbiguousCastOrBinaryExpression; - static const std::string ID_of_AmbiguousExpressionOrDeclarationStatement; - }; - friend struct DiagnosticsReporter; - - DiagnosticsReporter diagReporter_; - - std::vector< - std::pair> releaseRetainedAmbiguityDiags() const; - - struct DiagnosticsReporterDelayer - { - DiagnosticsReporterDelayer(DiagnosticsReporter* diagReporter, - const std::string& diagID) - : diagReporter_(diagReporter) - , diagID_(diagID) - { - diagReporter_->IDsForDelay_.insert(diagID); - } - - ~DiagnosticsReporterDelayer() - { - diagReporter_->IDsForDelay_.erase(diagID_); - } - - DiagnosticsReporter* diagReporter_; - std::string diagID_; - }; - - const SyntaxToken& peek(unsigned int LA = 1) const; - LexedTokens::IndexType consume(); - bool match(SyntaxKind expectedTkK, LexedTokens::IndexType* tkIdx); - bool matchOrSkipTo(SyntaxKind expectedTkK, LexedTokens::IndexType* tkIdx); - void skipTo(SyntaxKind tkK); - unsigned int curTkIdx_; - - int DEPTH_OF_EXPRS_; - int DEPTH_OF_STMTS_; - - struct DepthControl - { - DepthControl(int& depth); - ~DepthControl(); - int depth_; - }; - friend struct DepthControl; - - /** - * \brief The scope of a declaration. - * - * \remark 6.2.1-4 - */ - enum class DeclarationScope : uint8_t - { - File, - Block, - FunctionPrototype - }; - - enum class DeclaratorVariety : uint8_t - { - Named, - Abstract - }; - - enum class IdentifierRole : uint8_t - { - AsDeclarator, - AsTypedefName - }; - - enum class StatementContext : uint8_t - { - None, - Switch, - Loop, - SwitchAndLoop - }; - - friend StatementContext operator+(StatementContext a, StatementContext b); - - template NodeT* makeNode(Args&&... args) const; - - //--------------// - // Declarations // - //--------------// - void parseTranslationUnit(TranslationUnitSyntax*& unit); - bool parseExternalDeclaration(DeclarationSyntax*& decl); - void parseIncompleteDeclaration_AtFirst(DeclarationSyntax*& decl, - const SpecifierListSyntax* specList = nullptr); - bool parseStaticAssertDeclaration_AtFirst(DeclarationSyntax*& decl); - bool parseExtGNU_AsmStatementDeclaration_AtFirst(DeclarationSyntax*& decl); - bool parseDeclaration( - DeclarationSyntax*& decl, - bool (Parser::*parseSpecifiers)(DeclarationSyntax*&, SpecifierListSyntax*&), - bool (Parser::*parse_AtFollowOfSpecifiers)(DeclarationSyntax*&, const SpecifierListSyntax*), - DeclarationScope declScope); - bool parseDeclarationOrFunctionDefinition(DeclarationSyntax*& decl); - bool parseDeclarationOrFunctionDefinition_AtFollowOfSpecifiers( - DeclarationSyntax*& decl, - const SpecifierListSyntax* specList); - bool parseFunctionDefinition_AtOpenBrace( - DeclarationSyntax*& decl, - const SpecifierListSyntax* specList, - DeclaratorSyntax*& decltor, - ExtKR_ParameterDeclarationListSyntax* paramKRList); - bool parseStructDeclaration(DeclarationSyntax*& decl); - bool parseStructDeclaration_AtFollowOfSpecifierQualifierList( - DeclarationSyntax*& decl, - const SpecifierListSyntax* specList); - bool parseEnumerator(DeclarationSyntax*& decl); - bool parseParameterDeclarationListAndOrEllipsis(ParameterSuffixSyntax*& paramDecltorSfx); - bool parseParameterDeclarationList(ParameterDeclarationListSyntax*& paramList); - bool parseParameterDeclaration(ParameterDeclarationSyntax*& paramDecl); - bool parseExtPSY_TemplateDeclaration_AtFirst(DeclarationSyntax*& decl); - bool parseExtKR_ParameterDeclarationList(ExtKR_ParameterDeclarationListSyntax*& paramList); - bool parseExtKR_ParameterDeclaration(ExtKR_ParameterDeclarationSyntax*& paramDecl); - - bool ignoreDeclarator(); - bool ignoreDeclarationOrDefinition(); - bool ignoreMemberDeclaration(); - bool ignoreStatement(); - - /* Specifiers */ - bool parseDeclarationSpecifiers(DeclarationSyntax*& decl, SpecifierListSyntax*& specList); - bool parseSpecifierQualifierList(DeclarationSyntax*& decl, SpecifierListSyntax*& specList); - template void parseTrivialSpecifier_AtFirst( - SpecifierSyntax*& spec, - SyntaxKind specK); - bool parseAlignmentSpecifier_AtFirst(SpecifierSyntax*& spec); - bool parseExtGNU_Typeof_AtFirst(SpecifierSyntax*& spec); - void parseTypedefName_AtFirst(SpecifierSyntax*& spec); - bool parseAtomiceTypeSpecifier_AtFirst(SpecifierSyntax*& spec); - template bool parseTagTypeSpecifier_AtFirst( - DeclarationSyntax*& decl, - SpecifierSyntax*& spec, - SyntaxKind declK, - SyntaxKind specK, - bool (Parser::*parseMember)(DeclarationSyntax*&)); - bool parseExtGNU_AttributeSpecifierList_AtFirst(SpecifierListSyntax*& specList); - bool parseExtGNU_AttributeSpecifier_AtFirst(SpecifierSyntax*& spec); - bool parseExtGNU_AttributeList(ExtGNU_AttributeListSyntax*& attrList); - bool parseExtGNU_Attribute(ExtGNU_AttributeSyntax*& attr); - bool parseExtGNU_AttributeArguments(ExpressionListSyntax*& exprList); - bool parseExtGNU_AttributeArgumentsLLVM(ExpressionListSyntax*& exprList); - bool parseExtGNU_AsmLabel_AtFirst(SpecifierSyntax*& attr); - bool parseExtPSY_QuantifiedTypeSpecifier_AtFirst(SpecifierSyntax*& spec); - - IdentifierRole determineIdentifierRole(bool seenType) const; - - /* Declarators */ - bool parseAbstractDeclarator(DeclaratorSyntax*& decltor); - bool parseDeclarator(DeclaratorSyntax*& decltor, DeclarationScope declScope); - bool parseDeclarator(DeclaratorSyntax*& decltor, - DeclarationScope declScope, - DeclaratorVariety decltorVariety); - bool parseDirectDeclarator(DeclaratorSyntax*& decltor, - DeclarationScope declScope, - DeclaratorVariety decltorVariety, - SpecifierListSyntax* attrList); - bool parseDirectDeclaratorSuffix(DeclaratorSyntax*& decltor, - DeclarationScope declScope, - DeclaratorVariety decltorVariety, - SpecifierListSyntax* attrList, - DeclaratorSyntax* innerDecltor); - bool parseTypeQualifiersAndAttributes(SpecifierListSyntax*& specList); - - /* Initializers */ - bool parseInitializer(InitializerSyntax*& init); - bool parseExpressionInitializer(InitializerSyntax*& init); - bool parseBraceEnclosedInitializer_AtFirst(InitializerSyntax*& init); - bool parseInitializerList(InitializerListSyntax*& initList); - bool parseInitializerListItem(InitializerSyntax*& init, InitializerListSyntax*& initList); - bool parseDesignatedInitializer_AtFirst( - InitializerSyntax*& init, - bool (Parser::*parseDesig)(DesignatorSyntax*& desig)); - bool parseDesignatorList_AtFirst( - DesignatorListSyntax*& desigList, - bool (Parser::*parseDesig)(DesignatorSyntax*& desig)); - bool parseFieldDesignator_AtFirst(DesignatorSyntax*& desig); - bool parseArrayDesignator_AtFirst(DesignatorSyntax*& desig); - - bool parseOffsetOfDesignator(DesignatorSyntax*& desig); - - //-------------// - // Expressions // - //-------------// - bool parseExpression(ExpressionSyntax*& expr); - bool parseIdentifierName(ExpressionSyntax*& expr); - void parseIdentifierName_AtFirst(ExpressionSyntax*& expr); - void parsePredefinedName_AtFirst(ExpressionSyntax*& expr); - template bool parseConstant(ExpressionSyntax*& expr, SyntaxKind exprK); - template void parseConstant_AtFirst(ExpressionSyntax*& expr, SyntaxKind exprK); - bool parseStringLiteral(ExpressionSyntax*& expr); - void parseStringLiteral_AtFirst(ExpressionSyntax*& expr); - bool parseParenthesizedExpression_AtFirst(ExpressionSyntax*& expr); - bool parseGenericSelectionExpression_AtFirst(ExpressionSyntax*& expr); - bool parseGenericAssociationList(GenericAssociationListSyntax*& assocList); - bool parseGenericAssociation(GenericAssociationSyntax*& assoc, - GenericAssociationListSyntax*& assocList); - bool parseExtGNU_StatementExpression_AtFirst(ExpressionSyntax*& expr); - bool parseExtGNU_ComplexValuedExpression_AtFirst(ExpressionSyntax*& expr, SyntaxKind exprK); - - /* Postfix */ - bool parseExpressionWithPrecedencePostfix(ExpressionSyntax*& expr); - bool parsePostfixExpression_AtFollowOfPrimary(ExpressionSyntax*& expr); - template bool parsePostfixExpression_AtFollowOfPrimary( - ExpressionSyntax*& expr, - SyntaxKind exprK, - std::function parsePostfix); - bool parseCallArguments(ExpressionListSyntax*& exprList); - bool parseCallArgument(ExpressionSyntax*& expr, ExpressionListSyntax*& exprList); - bool parseCompoundLiteral_AtOpenParen(ExpressionSyntax*& expr); - bool parseCompoundLiteral_AtOpenBrace( - ExpressionSyntax*& expr, - LexedTokens::IndexType openParenTkIdx, - TypeNameSyntax* typeName, - LexedTokens::IndexType closeParenTkIdx); - bool parseVAArgumentExpression_AtFirst(ExpressionSyntax*& expr); - bool parseOffsetOfExpression_AtFirst(ExpressionSyntax*& expr); - bool parseExtGNU_ChooseExpression_AtFirst(ExpressionSyntax*& expr); - - /* Unary */ - bool parseExpressionWithPrecedenceUnary(ExpressionSyntax*& expr); - bool parsePrefixUnaryExpression_AtFirst( - ExpressionSyntax*& expr, - SyntaxKind exprK, - bool (Parser::*parseOperand)(ExpressionSyntax*&)); - bool parseTypeTraitExpression_AtFirst(ExpressionSyntax*& expr, SyntaxKind exprK); - - /* Cast */ - bool parseExpressionWithPrecedenceCast(ExpressionSyntax*& expr); - bool parseCompoundLiteralOrCastExpression_AtFirst(ExpressionSyntax*& expr); - void maybeAmbiguateCastExpression(ExpressionSyntax*& expr); - - /* N-ary */ - bool parseExpressionWithPrecedenceMultiplicative(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceAdditive(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceShift(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceRelational(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceEquality(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceBitwiseAND(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceBitwiseXOR(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceBitwiseOR(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceLogicalAND(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceLogicalOR(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceConditional(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceAssignment(ExpressionSyntax*& expr); - bool parseExpressionWithPrecedenceComma(ExpressionSyntax*& expr); - bool parseNAryExpression(ExpressionSyntax*& expr, std::uint8_t cutoffPrecedence); - bool parseNAryExpression_AtOperator(ExpressionSyntax*& baseExpr, - std::uint8_t cutoffPrecedence); - - template NodeT* fill_LeftOperandInfixOperatorRightOperand_MIXIN( - NodeT* expr, - ExpressionSyntax* left, - LexedTokens::IndexType opTkIdx, - ExpressionSyntax* right); - - //------------// - // Statements // - //------------// - bool parseStatement(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseCompoundStatement_AtFirst( - StatementSyntax*& stmt, - StatementContext stmtCtx); - bool parseDeclarationStatement( - StatementSyntax*& stmt, - bool (Parser::*parseDecl)(DeclarationSyntax*&)); - bool parseExpressionStatement(StatementSyntax*& stmt); - bool parseLabeledStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseIfStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseSwitchStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseWhileStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseDoStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseForStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseGotoStatement_AtFirst(StatementSyntax*& stmt); - bool parseContinueStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseBreakStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx); - bool parseReturnStatement_AtFirst(StatementSyntax*& stmt); - bool parseExtGNU_AsmStatement(StatementSyntax*& stmt); - void parseExtGNU_AsmQualifiers(SpecifierListSyntax*& specList); - bool parseExtGNU_AsmOperands(ExtGNU_AsmOperandListSyntax*& asmOprdsList); - bool parseExtGNU_AsmOutputOperand_AtFirst( - ExtGNU_AsmOperandSyntax*& asmOprd, - ExtGNU_AsmOperandListSyntax*&); - bool parseExtGNU_AsmInputOperand_AtFirst( - ExtGNU_AsmOperandSyntax*& asmOprd, - ExtGNU_AsmOperandListSyntax*&); - bool parseExtGNU_AsmOperand_AtFirst( - ExtGNU_AsmOperandSyntax*& asmOprd, - SyntaxKind oprdK); - bool parseExtGNU_AsmClobbers(ExpressionListSyntax*& clobList); - bool parseExtGNU_AsmClobber_AtFirst( - ExpressionSyntax*& clob, - ExpressionListSyntax*& clobList); - bool parseExtGNU_AsmGotoLabels(ExpressionListSyntax*& labelList); - bool parseExtGNU_AsmGotoLabel_AtFirst( - ExpressionSyntax*& label, - ExpressionListSyntax*&); - void maybeAmbiguateStatement(StatementSyntax*& stmt); - bool checkStatementParse(bool stmtParsed); - - //--------// - // Common // - //--------// - template bool parseCommaSeparatedItems( - NodeListT*& nodeList, - bool (Parser::*parseItem)(NodeT*& node, NodeListT*& nodeList)); - bool parseTypeName(TypeNameSyntax*& typeName); - bool parseParenthesizedTypeNameOrExpression(TypeReferenceSyntax*& tyRef); - void maybeAmbiguateTypeReference(TypeReferenceSyntax*& tyRef); + // Unavailable + Parser(const Parser &) = delete; + void operator=(const Parser &) = delete; + + MemoryPool *pool_; + SyntaxTree *tree_; + + // While the parser is in backtracking mode, diagnostics are disabled. + // To avoid unintended omission of syntax errors, the backtracker + // should be discarded immediately after use, either explicitly or + // implicitly; the latter happens either upon the object destruction + // or after a single backtracking operation. + struct Backtracker { + Backtracker(Parser *parser, LexedTokens::IndexType tkIdx = 0); + ~Backtracker(); + void discard(); + void backtrack(); + + Parser *parser_; + LexedTokens::IndexType refTkIdx_; + bool done_; + std::stack chained_; + }; + friend struct Backtracker; + const Backtracker *backtracker_; + bool mightBacktrack() const; + + struct DiagnosticsReporter { + DiagnosticsReporter(Parser *parser) + : parser_(parser), IDsForDelay_(false) {} + Parser *parser_; + + static std::string + joinTokenNames(const std::vector &validTkKinds); + + std::unordered_set IDsForDelay_; + std::vector> + delayedDiags_; + std::vector> + retainedAmbiguityDiags_; + + void diagnose(DiagnosticDescriptor &&desc); + void diagnoseDelayed(); + void diagnoseAmbiguityButRetainIt(DiagnosticDescriptor &&desc); + + /* General */ + void ExpectedFeature(const std::string &name); + + static const std::string ID_of_ExpectedFeature; + + /* Terminal */ + void ExpectedToken(SyntaxKind syntaxK); + void ExpectedTokenWithin(const std::vector &validTokens); + void ExpectedTokenOfCategory(SyntaxToken::Category category, + const std::string &id); + void ExpectedTokenOfCategoryIdentifier(); + void ExpectedTokenOfCategoryConstant(); + void ExpectedTokenOfCategoryStringLiteral(); + + static const std::string ID_of_ExpectedToken; + static const std::string ID_of_ExpectedTokenWithin; + static const std::string ID_of_ExpectedTokenOfCategoryIdentifier; + static const std::string ID_of_ExpectedTokenOfCategoryConstant; + static const std::string ID_of_ExpectedTokenOfCategoryStringLiteral; + + /* Non-terminal */ + void ExpectedFIRSTof(const std::string &rule, const std::string &id); + void ExpectedFIRSTofExpression(); + void ExpectedFIRSTofEnumerationConstant(); + void ExpectedFIRSTofDirectDeclarator(); + void ExpectedFIRSTofParameterDeclaration(); + void ExpectedFIRSTofSpecifierQualifier(); + void ExpectedFOLLOWofDesignatedInitializer(); + void ExpectedFOLLOWofDeclarator(); + void ExpectedFOLLOWofStructDeclarator(); + void ExpectedFOLLOWofDeclaratorAndInitializer(); + void ExpectedFOLLOWofStructOrUnionOrEnum(); + void ExpectedFOLLOWofEnum(); + + static const std::string ID_of_ExpectedFIRSTofExpression; + static const std::string ID_of_ExpectedFIRSTofEnumerationConstant; + static const std::string ID_of_ExpectedFIRSTofDirectDeclarator; + static const std::string ID_of_ExpectedFIRSTofParameterDeclaration; + static const std::string ID_of_ExpectedFIRSTofSpecifierQualifier; + static const std::string ID_of_ExpectedFOLLOWofDesignatedInitializer; + static const std::string ID_of_ExpectedFOLLOWofDeclarator; + static const std::string ID_of_ExpectedFOLLOWofStructDeclarator; + static const std::string ID_of_ExpectedFOLLOWofDeclaratorAndInitializer; + static const std::string ID_of_ExpectedFOLLOWofStructOrUnionOrEnum; + static const std::string ID_of_ExpectedFOLLOWofEnum; + + /* Detailed */ + void ExpectedFieldName(); + void ExpectedBraceEnclosedInitializerList(); + void ExpectedFieldDesignator(); + void UnexpectedInitializerOfDeclarator(); + void UnexpectedStaticOrTypeQualifiersInArrayDeclarator(); + void UnexpectedPointerInArrayDeclarator(); + void ExpectedNamedParameterBeforeEllipsis(); + void ExpectedTypeSpecifier(); + void UnexpectedCaseLabelOutsideSwitch(); + void UnexpectedDefaultLabelOutsideSwitch(); + void UnexpectedContinueOutsideLoop(); + void UnexpectedBreakOutsideSwitchOrLoop(); + void UnexpectedGNUExtensionFlag(); + + static const std::string ID_of_ExpectedFieldName; + static const std::string ID_of_ExpectedBraceEnclosedInitializerList; + static const std::string ID_of_ExpectedFieldDesignator; + static const std::string ID_of_UnexpectedInitializerOfDeclarator; + static const std::string + ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator; + static const std::string ID_of_UnexpectedPointerInArrayDeclarator; + static const std::string ID_of_ExpectedNamedParameterBeforeEllipsis; + static const std::string ID_of_ExpectedTypeSpecifier; + static const std::string ID_of_UnexpectedCaseLabelOutsideSwitch; + static const std::string ID_of_UnexpectedDefaultLabelOutsideSwitch; + static const std::string ID_of_UnexpectedContinueOutsideLoop; + static const std::string ID_of_UnexpectedBreakOutsideSwitchOrLoop; + static const std::string ID_of_UnexpectedGNUExtensionFlag; + + /* Ambiguities */ + void AmbiguousTypeNameOrExpressionAsTypeReference(); + void AmbiguousCastOrBinaryExpression(); + void AmbiguousExpressionOrDeclarationStatement(); + + static const std::string ID_of_AmbiguousTypeNameOrExpressionAsTypeReference; + static const std::string ID_of_AmbiguousCastOrBinaryExpression; + static const std::string ID_of_AmbiguousExpressionOrDeclarationStatement; + }; + friend struct DiagnosticsReporter; + + DiagnosticsReporter diagReporter_; + + std::vector> + releaseRetainedAmbiguityDiags() const; + + struct DiagnosticsReporterDelayer { + DiagnosticsReporterDelayer(DiagnosticsReporter *diagReporter, + const std::string &diagID) + : diagReporter_(diagReporter), diagID_(diagID) { + diagReporter_->IDsForDelay_.insert(diagID); + } + + ~DiagnosticsReporterDelayer() { + diagReporter_->IDsForDelay_.erase(diagID_); + } + + DiagnosticsReporter *diagReporter_; + std::string diagID_; + }; + + const SyntaxToken &peek(unsigned int LA = 1) const; + LexedTokens::IndexType consume(); + bool match(SyntaxKind expectedTkK, LexedTokens::IndexType *tkIdx); + bool matchOrSkipTo(SyntaxKind expectedTkK, LexedTokens::IndexType *tkIdx); + void skipTo(SyntaxKind tkK); + unsigned int curTkIdx_; + + int DEPTH_OF_EXPRS_; + int DEPTH_OF_STMTS_; + + struct DepthControl { + DepthControl(int &depth); + ~DepthControl(); + int depth_; + }; + friend struct DepthControl; + + /** + * \brief The scope of a declaration. + * + * \remark 6.2.1-4 + */ + enum class DeclarationScope : uint8_t { File, Block, FunctionPrototype }; + + enum class DeclaratorVariety : uint8_t { Named, Abstract }; + + enum class IdentifierRole : uint8_t { AsDeclarator, AsTypedefName }; + + enum class StatementContext : uint8_t { None, Switch, Loop, SwitchAndLoop }; + + friend StatementContext operator+(StatementContext a, StatementContext b); + + template NodeT *makeNode(Args &&...args) const; + + //--------------// + // Declarations // + //--------------// + void parseTranslationUnit(TranslationUnitSyntax *&unit); + bool parseExternalDeclaration(DeclarationSyntax *&decl); + void parseIncompleteDeclaration_AtFirst( + DeclarationSyntax *&decl, const SpecifierListSyntax *specList = nullptr); + bool parseStaticAssertDeclaration_AtFirst(DeclarationSyntax *&decl); + bool parseExtGNU_AsmStatementDeclaration_AtFirst(DeclarationSyntax *&decl); + bool parseDeclaration(DeclarationSyntax *&decl, + bool (Parser::*parseSpecifiers)(DeclarationSyntax *&, + SpecifierListSyntax *&), + bool (Parser::*parse_AtFollowOfSpecifiers)( + DeclarationSyntax *&, const SpecifierListSyntax *), + DeclarationScope declScope); + bool parseDeclarationOrFunctionDefinition(DeclarationSyntax *&decl); + bool parseDeclarationOrFunctionDefinition_AtFollowOfSpecifiers( + DeclarationSyntax *&decl, const SpecifierListSyntax *specList); + bool parseFunctionDefinition_AtOpenBrace( + DeclarationSyntax *&decl, const SpecifierListSyntax *specList, + DeclaratorSyntax *&decltor, + ExtKR_ParameterDeclarationListSyntax *paramKRList); + bool parseStructDeclaration(DeclarationSyntax *&decl); + bool parseStructDeclaration_AtFollowOfSpecifierQualifierList( + DeclarationSyntax *&decl, const SpecifierListSyntax *specList); + bool parseEnumerator(DeclarationSyntax *&decl); + bool parseParameterDeclarationListAndOrEllipsis( + ParameterSuffixSyntax *¶mDecltorSfx); + bool + parseParameterDeclarationList(ParameterDeclarationListSyntax *¶mList); + bool parseParameterDeclaration(ParameterDeclarationSyntax *¶mDecl); + bool parseExtPSY_TemplateDeclaration_AtFirst(DeclarationSyntax *&decl); + bool parseExtKR_ParameterDeclarationList( + ExtKR_ParameterDeclarationListSyntax *¶mList); + bool + parseExtKR_ParameterDeclaration(ExtKR_ParameterDeclarationSyntax *¶mDecl); + + bool ignoreDeclarator(); + bool ignoreDeclarationOrDefinition(); + bool ignoreMemberDeclaration(); + bool ignoreStatement(); + + /* Specifiers */ + bool parseDeclarationSpecifiers(DeclarationSyntax *&decl, + SpecifierListSyntax *&specList); + bool parseSpecifierQualifierList(DeclarationSyntax *&decl, + SpecifierListSyntax *&specList); + template + void parseTrivialSpecifier_AtFirst(SpecifierSyntax *&spec, SyntaxKind specK); + bool parseAlignmentSpecifier_AtFirst(SpecifierSyntax *&spec); + bool parseExtGNU_Typeof_AtFirst(SpecifierSyntax *&spec); + void parseTypedefName_AtFirst(SpecifierSyntax *&spec); + bool parseAtomiceTypeSpecifier_AtFirst(SpecifierSyntax *&spec); + template + bool parseTagTypeSpecifier_AtFirst( + DeclarationSyntax *&decl, SpecifierSyntax *&spec, SyntaxKind declK, + SyntaxKind specK, bool (Parser::*parseMember)(DeclarationSyntax *&)); + bool + parseExtGNU_AttributeSpecifierList_AtFirst(SpecifierListSyntax *&specList); + bool parseExtGNU_AttributeSpecifier_AtFirst(SpecifierSyntax *&spec); + bool parseExtGNU_AttributeList(ExtGNU_AttributeListSyntax *&attrList); + bool parseExtGNU_Attribute(ExtGNU_AttributeSyntax *&attr); + bool parseExtGNU_AttributeArguments(ExpressionListSyntax *&exprList); + bool parseExtGNU_AttributeArgumentsLLVM(ExpressionListSyntax *&exprList); + bool parseExtGNU_AsmLabel_AtFirst(SpecifierSyntax *&attr); + bool parseExtPSY_QuantifiedTypeSpecifier_AtFirst(SpecifierSyntax *&spec); + + IdentifierRole determineIdentifierRole(bool seenType) const; + + /* Declarators */ + bool parseAbstractDeclarator(DeclaratorSyntax *&decltor); + bool parseDeclarator(DeclaratorSyntax *&decltor, DeclarationScope declScope); + bool parseDeclarator(DeclaratorSyntax *&decltor, DeclarationScope declScope, + DeclaratorVariety decltorVariety); + bool parseDirectDeclarator(DeclaratorSyntax *&decltor, + DeclarationScope declScope, + DeclaratorVariety decltorVariety, + SpecifierListSyntax *attrList); + bool parseDirectDeclaratorSuffix(DeclaratorSyntax *&decltor, + DeclarationScope declScope, + DeclaratorVariety decltorVariety, + SpecifierListSyntax *attrList, + DeclaratorSyntax *innerDecltor); + bool parseTypeQualifiersAndAttributes(SpecifierListSyntax *&specList); + + /* Initializers */ + bool parseInitializer(InitializerSyntax *&init); + bool parseExpressionInitializer(InitializerSyntax *&init); + bool parseBraceEnclosedInitializer_AtFirst(InitializerSyntax *&init); + bool parseInitializerList(InitializerListSyntax *&initList); + bool parseInitializerListItem(InitializerSyntax *&init, + InitializerListSyntax *&initList); + bool parseDesignatedInitializer_AtFirst( + InitializerSyntax *&init, + bool (Parser::*parseDesig)(DesignatorSyntax *&desig)); + bool parseDesignatorList_AtFirst( + DesignatorListSyntax *&desigList, + bool (Parser::*parseDesig)(DesignatorSyntax *&desig)); + bool parseFieldDesignator_AtFirst(DesignatorSyntax *&desig); + bool parseArrayDesignator_AtFirst(DesignatorSyntax *&desig); + + bool parseOffsetOfDesignator(DesignatorSyntax *&desig); + + //-------------// + // Expressions // + //-------------// + bool parseExpression(ExpressionSyntax *&expr); + bool parseIdentifierName(ExpressionSyntax *&expr); + void parseIdentifierName_AtFirst(ExpressionSyntax *&expr); + void parsePredefinedName_AtFirst(ExpressionSyntax *&expr); + template + bool parseConstant(ExpressionSyntax *&expr, SyntaxKind exprK); + template + void parseConstant_AtFirst(ExpressionSyntax *&expr, SyntaxKind exprK); + bool parseStringLiteral(ExpressionSyntax *&expr); + void parseStringLiteral_AtFirst(ExpressionSyntax *&expr); + bool parseParenthesizedExpression_AtFirst(ExpressionSyntax *&expr); + bool parseGenericSelectionExpression_AtFirst(ExpressionSyntax *&expr); + bool parseGenericAssociationList(GenericAssociationListSyntax *&assocList); + bool parseGenericAssociation(GenericAssociationSyntax *&assoc, + GenericAssociationListSyntax *&assocList); + bool parseExtGNU_StatementExpression_AtFirst(ExpressionSyntax *&expr); + bool parseExtGNU_ComplexValuedExpression_AtFirst(ExpressionSyntax *&expr, + SyntaxKind exprK); + + /* Postfix */ + bool parseExpressionWithPrecedencePostfix(ExpressionSyntax *&expr); + bool parsePostfixExpression_AtFollowOfPrimary(ExpressionSyntax *&expr); + template + bool parsePostfixExpression_AtFollowOfPrimary( + ExpressionSyntax *&expr, SyntaxKind exprK, + std::function parsePostfix); + bool parseCallArguments(ExpressionListSyntax *&exprList); + bool parseCallArgument(ExpressionSyntax *&expr, + ExpressionListSyntax *&exprList); + bool parseCompoundLiteral_AtOpenParen(ExpressionSyntax *&expr); + bool parseCompoundLiteral_AtOpenBrace(ExpressionSyntax *&expr, + LexedTokens::IndexType openParenTkIdx, + TypeNameSyntax *typeName, + LexedTokens::IndexType closeParenTkIdx); + bool parseVAArgumentExpression_AtFirst(ExpressionSyntax *&expr); + bool parseOffsetOfExpression_AtFirst(ExpressionSyntax *&expr); + bool parseExtGNU_ChooseExpression_AtFirst(ExpressionSyntax *&expr); + + /* Unary */ + bool parseExpressionWithPrecedenceUnary(ExpressionSyntax *&expr); + bool parsePrefixUnaryExpression_AtFirst( + ExpressionSyntax *&expr, SyntaxKind exprK, + bool (Parser::*parseOperand)(ExpressionSyntax *&)); + bool parseTypeTraitExpression_AtFirst(ExpressionSyntax *&expr, + SyntaxKind exprK); + + /* Cast */ + bool parseExpressionWithPrecedenceCast(ExpressionSyntax *&expr); + bool parseCompoundLiteralOrCastExpression_AtFirst(ExpressionSyntax *&expr); + void maybeAmbiguateCastExpression(ExpressionSyntax *&expr); + + /* N-ary */ + bool parseExpressionWithPrecedenceMultiplicative(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceAdditive(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceShift(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceRelational(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceEquality(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceBitwiseAND(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceBitwiseXOR(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceBitwiseOR(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceLogicalAND(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceLogicalOR(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceConditional(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceAssignment(ExpressionSyntax *&expr); + bool parseExpressionWithPrecedenceComma(ExpressionSyntax *&expr); + bool parseNAryExpression(ExpressionSyntax *&expr, + std::uint8_t cutoffPrecedence); + bool parseNAryExpression_AtOperator(ExpressionSyntax *&baseExpr, + std::uint8_t cutoffPrecedence); + + template + NodeT *fill_LeftOperandInfixOperatorRightOperand_MIXIN( + NodeT *expr, ExpressionSyntax *left, LexedTokens::IndexType opTkIdx, + ExpressionSyntax *right); + + //------------// + // Statements // + //------------// + bool parseStatement(StatementSyntax *&stmt, StatementContext stmtCtx); + bool parseCompoundStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool + parseDeclarationStatement(StatementSyntax *&stmt, + bool (Parser::*parseDecl)(DeclarationSyntax *&)); + bool parseExpressionStatement(StatementSyntax *&stmt); + bool parseLabeledStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool parseIfStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool parseSwitchStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool parseWhileStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool parseDoStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool parseForStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool parseGotoStatement_AtFirst(StatementSyntax *&stmt); + bool parseContinueStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool parseBreakStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx); + bool parseReturnStatement_AtFirst(StatementSyntax *&stmt); + bool parseExtGNU_AsmStatement(StatementSyntax *&stmt); + void parseExtGNU_AsmQualifiers(SpecifierListSyntax *&specList); + bool parseExtGNU_AsmOperands(ExtGNU_AsmOperandListSyntax *&asmOprdsList); + bool parseExtGNU_AsmOutputOperand_AtFirst(ExtGNU_AsmOperandSyntax *&asmOprd, + ExtGNU_AsmOperandListSyntax *&); + bool parseExtGNU_AsmInputOperand_AtFirst(ExtGNU_AsmOperandSyntax *&asmOprd, + ExtGNU_AsmOperandListSyntax *&); + bool parseExtGNU_AsmOperand_AtFirst(ExtGNU_AsmOperandSyntax *&asmOprd, + SyntaxKind oprdK); + bool parseExtGNU_AsmClobbers(ExpressionListSyntax *&clobList); + bool parseExtGNU_AsmClobber_AtFirst(ExpressionSyntax *&clob, + ExpressionListSyntax *&clobList); + bool parseExtGNU_AsmGotoLabels(ExpressionListSyntax *&labelList); + bool parseExtGNU_AsmGotoLabel_AtFirst(ExpressionSyntax *&label, + ExpressionListSyntax *&); + void maybeAmbiguateStatement(StatementSyntax *&stmt); + bool checkStatementParse(bool stmtParsed); + + //--------// + // Common // + //--------// + template + bool parseCommaSeparatedItems( + NodeListT *&nodeList, + bool (Parser::*parseItem)(NodeT *&node, NodeListT *&nodeList)); + bool parseTypeName(TypeNameSyntax *&typeName); + bool parseParenthesizedTypeNameOrExpression(TypeReferenceSyntax *&tyRef); + void maybeAmbiguateTypeReference(TypeReferenceSyntax *&tyRef); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/parser/Parser_Common.cpp b/C/parser/Parser_Common.cpp index 8aab77888..26625b42b 100644 --- a/C/parser/Parser_Common.cpp +++ b/C/parser/Parser_Common.cpp @@ -38,85 +38,84 @@ using namespace C; * * \remark 6.7.7. */ -bool Parser::parseTypeName(TypeNameSyntax*& typeName) -{ - DEBUG_THIS_RULE(); +bool Parser::parseTypeName(TypeNameSyntax *&typeName) { + DEBUG_THIS_RULE(); - DeclarationSyntax* decl = nullptr; - SpecifierListSyntax* specList = nullptr; - if (!parseSpecifierQualifierList(decl, specList)) - return false; + DeclarationSyntax *decl = nullptr; + SpecifierListSyntax *specList = nullptr; + if (!parseSpecifierQualifierList(decl, specList)) + return false; - typeName = makeNode(); - typeName->specs_ = specList; - return parseAbstractDeclarator(typeName->decltor_); + typeName = makeNode(); + typeName->specs_ = specList; + return parseAbstractDeclarator(typeName->decltor_); } -bool Parser::parseParenthesizedTypeNameOrExpression(TypeReferenceSyntax*& tyRef) -{ - switch (peek().kind()) { - case OpenParenToken: { - Backtracker BT(this); - ExpressionSyntax* expr = nullptr; - if (parseExpressionWithPrecedenceUnary(expr)) { - auto exprAsTyRef = makeNode(); - tyRef = exprAsTyRef; - exprAsTyRef->expr_ = expr; - if (expr->kind() == ParenthesizedExpression) - maybeAmbiguateTypeReference(tyRef); - return true; - } +bool Parser::parseParenthesizedTypeNameOrExpression( + TypeReferenceSyntax *&tyRef) { + switch (peek().kind()) { + case OpenParenToken: { + Backtracker BT(this); + ExpressionSyntax *expr = nullptr; + if (parseExpressionWithPrecedenceUnary(expr)) { + auto exprAsTyRef = makeNode(); + tyRef = exprAsTyRef; + exprAsTyRef->expr_ = expr; + if (expr->kind() == ParenthesizedExpression) + maybeAmbiguateTypeReference(tyRef); + return true; + } - BT.backtrack(); - auto openParenTkIdx = consume(); - TypeNameSyntax* typeName = nullptr; - if (!parseTypeName(typeName)) - return false; + BT.backtrack(); + auto openParenTkIdx = consume(); + TypeNameSyntax *typeName = nullptr; + if (!parseTypeName(typeName)) + return false; - auto nameAsTyRef = makeNode(); - tyRef = nameAsTyRef; - nameAsTyRef->openParenTkIdx_ = openParenTkIdx; - nameAsTyRef->typeName_ = typeName; - return matchOrSkipTo(CloseParenToken, &nameAsTyRef->closeParenTkIdx_); - } + auto nameAsTyRef = makeNode(); + tyRef = nameAsTyRef; + nameAsTyRef->openParenTkIdx_ = openParenTkIdx; + nameAsTyRef->typeName_ = typeName; + return matchOrSkipTo(CloseParenToken, &nameAsTyRef->closeParenTkIdx_); + } - default: { - ExpressionSyntax* unaryExpr = nullptr; - if (!parseExpressionWithPrecedenceUnary(unaryExpr)) - return false; - auto exprAsTyRef = makeNode(); - tyRef = exprAsTyRef; - exprAsTyRef->expr_ = unaryExpr; - return true; - } - } + default: { + ExpressionSyntax *unaryExpr = nullptr; + if (!parseExpressionWithPrecedenceUnary(unaryExpr)) + return false; + auto exprAsTyRef = makeNode(); + tyRef = exprAsTyRef; + exprAsTyRef->expr_ = unaryExpr; + return true; + } + } } -void Parser::maybeAmbiguateTypeReference(TypeReferenceSyntax*& tyRef) -{ - PSY_ASSERT_W_MSG(tyRef->kind() == ExpressionAsTypeReference - && (tyRef->asExpressionAsTypeReference()->expr_->kind() - == ParenthesizedExpression), - return, ""); +void Parser::maybeAmbiguateTypeReference(TypeReferenceSyntax *&tyRef) { + PSY_ASSERT_W_MSG(tyRef->kind() == ExpressionAsTypeReference && + (tyRef->asExpressionAsTypeReference()->expr_->kind() == + ParenthesizedExpression), + return, ""); - auto exprAsTyRef = tyRef->asExpressionAsTypeReference(); - auto parenExpr = exprAsTyRef->expr_->asParenthesizedExpression(); - if (!parenExpr->expr_->asIdentifierName()) - return; + auto exprAsTyRef = tyRef->asExpressionAsTypeReference(); + auto parenExpr = exprAsTyRef->expr_->asParenthesizedExpression(); + if (!parenExpr->expr_->asIdentifierName()) + return; - auto tyDefName = makeNode(); - tyDefName->identTkIdx_ = parenExpr->expr_->asIdentifierName()->identTkIdx_; - auto tyName = makeNode(); - tyName->specs_ = makeNode(tyDefName); - auto tyNameAsTyRef = makeNode(); - tyNameAsTyRef->openParenTkIdx_ = parenExpr->openParenTkIdx_; - tyNameAsTyRef->typeName_ = tyName; - tyNameAsTyRef->closeParenTkIdx_ = parenExpr->closeParenTkIdx_; + auto tyDefName = makeNode(); + tyDefName->identTkIdx_ = parenExpr->expr_->asIdentifierName()->identTkIdx_; + auto tyName = makeNode(); + tyName->specs_ = makeNode(tyDefName); + auto tyNameAsTyRef = makeNode(); + tyNameAsTyRef->openParenTkIdx_ = parenExpr->openParenTkIdx_; + tyNameAsTyRef->typeName_ = tyName; + tyNameAsTyRef->closeParenTkIdx_ = parenExpr->closeParenTkIdx_; - auto ambiTyRef = makeNode(); - tyRef = ambiTyRef; - ambiTyRef->exprAsTyRef_ = exprAsTyRef; - ambiTyRef->tyNameAsTyRef_ = tyNameAsTyRef; + auto ambiTyRef = + makeNode(); + tyRef = ambiTyRef; + ambiTyRef->exprAsTyRef_ = exprAsTyRef; + ambiTyRef->tyNameAsTyRef_ = tyNameAsTyRef; - diagReporter_.AmbiguousTypeNameOrExpressionAsTypeReference(); + diagReporter_.AmbiguousTypeNameOrExpressionAsTypeReference(); } diff --git a/C/parser/Parser_Declarations.cpp b/C/parser/Parser_Declarations.cpp index f90066aac..2253b3d11 100644 --- a/C/parser/Parser_Declarations.cpp +++ b/C/parser/Parser_Declarations.cpp @@ -30,39 +30,39 @@ using namespace C; /** * Parse a \a translation-unit. */ -void Parser::parseTranslationUnit(TranslationUnitSyntax*& unit) -{ - DEBUG_THIS_RULE(); - - DeclarationListSyntax** declList_cur = &unit->decls_; - - while (true) { - DeclarationSyntax* decl = nullptr; - switch (peek().kind()) { - case EndOfFile: - return; - - case Keyword_ExtGNU___extension__: { - auto extKwTkIdx = consume(); - if (!parseExternalDeclaration(decl)) - break;; - PSY_ASSERT_W_MSG(decl, break, "invalid declaration"); - decl->extKwTkIdx_ = extKwTkIdx; - break; - } - - default: - if (parseExternalDeclaration(decl)) - break; - ignoreDeclarationOrDefinition(); - continue; - } +void Parser::parseTranslationUnit(TranslationUnitSyntax *&unit) { + DEBUG_THIS_RULE(); + + DeclarationListSyntax **declList_cur = &unit->decls_; + + while (true) { + DeclarationSyntax *decl = nullptr; + switch (peek().kind()) { + case EndOfFile: + return; + + case Keyword_ExtGNU___extension__: { + auto extKwTkIdx = consume(); + if (!parseExternalDeclaration(decl)) + break; + ; + PSY_ASSERT_W_MSG(decl, break, "invalid declaration"); + decl->extKwTkIdx_ = extKwTkIdx; + break; + } - *declList_cur = makeNode(decl); - declList_cur = &(*declList_cur)->next; + default: + if (parseExternalDeclaration(decl)) + break; + ignoreDeclarationOrDefinition(); + continue; } - diagReporter_.diagnoseDelayed(); + *declList_cur = makeNode(decl); + declList_cur = &(*declList_cur)->next; + } + + diagReporter_.diagnoseDelayed(); } /** @@ -76,44 +76,41 @@ void Parser::parseTranslationUnit(TranslationUnitSyntax*& unit) * * \remark 6.9 */ -bool Parser::parseExternalDeclaration(DeclarationSyntax*& decl) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExternalDeclaration(DeclarationSyntax *&decl) { + DEBUG_THIS_RULE(); - switch (peek().kind()) { - case SemicolonToken: - parseIncompleteDeclaration_AtFirst(decl); - break; + switch (peek().kind()) { + case SemicolonToken: + parseIncompleteDeclaration_AtFirst(decl); + break; - case Keyword__Static_assert: - return parseStaticAssertDeclaration_AtFirst(decl); + case Keyword__Static_assert: + return parseStaticAssertDeclaration_AtFirst(decl); - case Keyword_ExtGNU___asm__: - return parseExtGNU_AsmStatementDeclaration_AtFirst(decl); + case Keyword_ExtGNU___asm__: + return parseExtGNU_AsmStatementDeclaration_AtFirst(decl); - case Keyword_ExtPSY__Template: - parseExtPSY_TemplateDeclaration_AtFirst(decl); - break; + case Keyword_ExtPSY__Template: + parseExtPSY_TemplateDeclaration_AtFirst(decl); + break; - default: - return parseDeclarationOrFunctionDefinition(decl); - } + default: + return parseDeclarationOrFunctionDefinition(decl); + } - return true; + return true; } -void Parser::parseIncompleteDeclaration_AtFirst(DeclarationSyntax*& decl, - const SpecifierListSyntax* specList) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == SemicolonToken, - return, - "assert failure: `;'"); - - auto incompDecl = makeNode(); - decl = incompDecl; - incompDecl->specs_ = specList; - incompDecl->semicolonTkIdx_ = consume(); +void Parser::parseIncompleteDeclaration_AtFirst( + DeclarationSyntax *&decl, const SpecifierListSyntax *specList) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == SemicolonToken, return, + "assert failure: `;'"); + + auto incompDecl = makeNode(); + decl = incompDecl; + incompDecl->specs_ = specList; + incompDecl->semicolonTkIdx_ = consume(); } /** @@ -126,104 +123,99 @@ void Parser::parseIncompleteDeclaration_AtFirst(DeclarationSyntax*& decl, * * \remark 6.7.10 */ -bool Parser::parseStaticAssertDeclaration_AtFirst(DeclarationSyntax*& decl) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword__Static_assert, - return false, - "assert failure: `_Static_assert'"); - - auto assertDecl = makeNode(); - decl = assertDecl; - assertDecl->staticAssertKwTkIdx_ = consume(); - - if (match(OpenParenToken, &assertDecl->openParenTkIdx_) - && parseExpressionWithPrecedenceConditional(assertDecl->expr_) - && match(CommaToken, &assertDecl->commaTkIdx_) - && parseStringLiteral(assertDecl->strLit_) - && match(CloseParenToken, &assertDecl->closeParenTkIdx_) - && match(SemicolonToken, &assertDecl->semicolonTkIdx_)) - return true; +bool Parser::parseStaticAssertDeclaration_AtFirst(DeclarationSyntax *&decl) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword__Static_assert, return false, + "assert failure: `_Static_assert'"); + + auto assertDecl = makeNode(); + decl = assertDecl; + assertDecl->staticAssertKwTkIdx_ = consume(); + + if (match(OpenParenToken, &assertDecl->openParenTkIdx_) && + parseExpressionWithPrecedenceConditional(assertDecl->expr_) && + match(CommaToken, &assertDecl->commaTkIdx_) && + parseStringLiteral(assertDecl->strLit_) && + match(CloseParenToken, &assertDecl->closeParenTkIdx_) && + match(SemicolonToken, &assertDecl->semicolonTkIdx_)) + return true; - skipTo(ColonToken); - return false; + skipTo(ColonToken); + return false; } /** * Parse a GNU extension file-scope assembly \a statement as a \a declaration, * with LA(1) at FIRST. */ -bool Parser::parseExtGNU_AsmStatementDeclaration_AtFirst(DeclarationSyntax*& decl) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___asm__, - return false, - "assert failure: `asm'"); - - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_Asm()) - diagReporter_.ExpectedFeature("GNU assembly in C"); - - auto asmDecl = makeNode(); - decl = asmDecl; - asmDecl->asmTkIdx_ = consume(); - - if (match(OpenParenToken, &asmDecl->openParenTkIdx_) - && parseStringLiteral(asmDecl->strLit_) - && match(CloseParenToken, &asmDecl->closeParenTkIdx_)) - return true; +bool Parser::parseExtGNU_AsmStatementDeclaration_AtFirst( + DeclarationSyntax *&decl) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___asm__, return false, + "assert failure: `asm'"); + + if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_Asm()) + diagReporter_.ExpectedFeature("GNU assembly in C"); + + auto asmDecl = makeNode(); + decl = asmDecl; + asmDecl->asmTkIdx_ = consume(); + + if (match(OpenParenToken, &asmDecl->openParenTkIdx_) && + parseStringLiteral(asmDecl->strLit_) && + match(CloseParenToken, &asmDecl->closeParenTkIdx_)) + return true; - skipTo(CloseParenToken); - return false; + skipTo(CloseParenToken); + return false; } bool Parser::parseDeclaration( - DeclarationSyntax*& decl, - bool (Parser::*parseSpecifiers)(DeclarationSyntax*&, SpecifierListSyntax*&), - bool (Parser::*parse_AtFollowOfSpecifiers)(DeclarationSyntax*&, const SpecifierListSyntax*), - DeclarationScope declScope) -{ - SpecifierListSyntax* specList = nullptr; - if (!((this)->*(parseSpecifiers))( - decl, - specList)) - return false; - - if (peek().kind() == SemicolonToken) { - if (decl) { - auto tyDecl = static_cast(decl); - tyDecl->semicolonTkIdx_ = consume(); - } - else - parseIncompleteDeclaration_AtFirst(decl, specList); - return true; - } + DeclarationSyntax *&decl, + bool (Parser::*parseSpecifiers)(DeclarationSyntax *&, + SpecifierListSyntax *&), + bool (Parser::*parse_AtFollowOfSpecifiers)(DeclarationSyntax *&, + const SpecifierListSyntax *), + DeclarationScope declScope) { + SpecifierListSyntax *specList = nullptr; + if (!((this)->*(parseSpecifiers))(decl, specList)) + return false; + if (peek().kind() == SemicolonToken) { if (decl) { - auto tyDeclSpec = makeNode(); - tyDeclSpec->typeDecl_ = static_cast(decl); - decl = nullptr; - - if (!specList) - specList = makeNode(tyDeclSpec); - else { - for (auto iter = specList; iter; iter = iter->next) { - if (iter->value->asTagTypeSpecifier() - && iter->value == tyDeclSpec->typeDecl_->typeSpec_) { - iter->value = tyDeclSpec; - break; - } - } + auto tyDecl = static_cast(decl); + tyDecl->semicolonTkIdx_ = consume(); + } else + parseIncompleteDeclaration_AtFirst(decl, specList); + return true; + } + + if (decl) { + auto tyDeclSpec = makeNode(); + tyDeclSpec->typeDecl_ = static_cast(decl); + decl = nullptr; + + if (!specList) + specList = makeNode(tyDeclSpec); + else { + for (auto iter = specList; iter; iter = iter->next) { + if (iter->value->asTagTypeSpecifier() && + iter->value == tyDeclSpec->typeDecl_->typeSpec_) { + iter->value = tyDeclSpec; + break; } + } } + } - if (!specList) { - if (declScope == DeclarationScope::File) - diagReporter_.ExpectedTypeSpecifier(); - else if (declScope == DeclarationScope::Block) - diagReporter_.ExpectedFIRSTofSpecifierQualifier(); - } + if (!specList) { + if (declScope == DeclarationScope::File) + diagReporter_.ExpectedTypeSpecifier(); + else if (declScope == DeclarationScope::Block) + diagReporter_.ExpectedFIRSTofSpecifierQualifier(); + } - return ((this)->*(parse_AtFollowOfSpecifiers))(decl, specList); + return ((this)->*(parse_AtFollowOfSpecifiers))(decl, specList); } /** @@ -240,360 +232,350 @@ bool Parser::parseDeclaration( * * \remark 6.7, 6.9.1 */ -bool Parser::parseDeclarationOrFunctionDefinition(DeclarationSyntax*& decl) -{ - return parseDeclaration( - decl, - &Parser::parseDeclarationSpecifiers, - &Parser::parseDeclarationOrFunctionDefinition_AtFollowOfSpecifiers, - DeclarationScope::File); +bool Parser::parseDeclarationOrFunctionDefinition(DeclarationSyntax *&decl) { + return parseDeclaration( + decl, &Parser::parseDeclarationSpecifiers, + &Parser::parseDeclarationOrFunctionDefinition_AtFollowOfSpecifiers, + DeclarationScope::File); } bool Parser::parseDeclarationOrFunctionDefinition_AtFollowOfSpecifiers( - DeclarationSyntax*& decl, - const SpecifierListSyntax* specList) -{ - DeclaratorListSyntax* decltorList = nullptr; - DeclaratorListSyntax** decltorList_cur = &decltorList; + DeclarationSyntax *&decl, const SpecifierListSyntax *specList) { + DeclaratorListSyntax *decltorList = nullptr; + DeclaratorListSyntax **decltorList_cur = &decltorList; + + while (true) { + DeclaratorSyntax *decltor = nullptr; + if (!parseDeclarator(decltor, DeclarationScope::File)) + return false; + + *decltorList_cur = makeNode(decltor); + + InitializerSyntax **init = nullptr; + if (peek().kind() == EqualsToken) { + DeclaratorSyntax *stripDecltor = const_cast( + SyntaxUtilities::strippedDeclaratorOrSelf(decltor)); + switch (stripDecltor->kind()) { + case IdentifierDeclarator: { + auto identDecltor = stripDecltor->asIdentifierDeclarator(); + identDecltor->equalsTkIdx_ = consume(); + init = &identDecltor->init_; + break; + } + + case PointerDeclarator: { + auto ptrDecltor = stripDecltor->asPointerDeclarator(); + ptrDecltor->equalsTkIdx_ = consume(); + init = &ptrDecltor->init_; + break; + } + + case ArrayDeclarator: { + auto arrDecltor = stripDecltor->asArrayOrFunctionDeclarator(); + arrDecltor->equalsTkIdx_ = consume(); + init = &arrDecltor->init_; + break; + } + + case FunctionDeclarator: { + auto funcDecltor = stripDecltor->asArrayOrFunctionDeclarator(); + if (funcDecltor->innerDecltor_) { + auto stripInnerDecltor = const_cast( + SyntaxUtilities::strippedDeclaratorOrSelf( + funcDecltor->innerDecltor_)); + if (stripInnerDecltor->kind() == PointerDeclarator) { + funcDecltor->equalsTkIdx_ = consume(); + init = &funcDecltor->init_; + break; + } + } + [[fallthrough]]; + } + + default: + diagReporter_.UnexpectedInitializerOfDeclarator(); + return ignoreDeclarator(); + } + if (!parseInitializer(*init)) + return false; + } - while (true) { - DeclaratorSyntax* decltor = nullptr; - if (!parseDeclarator(decltor, DeclarationScope::File)) - return false; + switch (peek().kind()) { + case CommaToken: + (*decltorList_cur)->delimTkIdx_ = consume(); + break; + + case SemicolonToken: { + auto nameDecl = makeNode(); + decl = nameDecl; + nameDecl->semicolonTkIdx_ = consume(); + nameDecl->specs_ = const_cast(specList); + nameDecl->decltors_ = decltorList; + return true; + } - *decltorList_cur = makeNode(decltor); - - InitializerSyntax** init = nullptr; - if (peek().kind() == EqualsToken) { - DeclaratorSyntax* stripDecltor = const_cast( - SyntaxUtilities::strippedDeclaratorOrSelf(decltor)); - switch (stripDecltor->kind()) { - case IdentifierDeclarator: { - auto identDecltor = stripDecltor->asIdentifierDeclarator(); - identDecltor->equalsTkIdx_ = consume(); - init = &identDecltor->init_; - break; - } - - case PointerDeclarator: { - auto ptrDecltor = stripDecltor->asPointerDeclarator(); - ptrDecltor->equalsTkIdx_ = consume(); - init = &ptrDecltor->init_; - break; - } - - case ArrayDeclarator: { - auto arrDecltor = stripDecltor->asArrayOrFunctionDeclarator(); - arrDecltor->equalsTkIdx_ = consume(); - init = &arrDecltor->init_; - break; - } - - case FunctionDeclarator: { - auto funcDecltor = stripDecltor->asArrayOrFunctionDeclarator(); - if (funcDecltor->innerDecltor_) { - auto stripInnerDecltor = const_cast( - SyntaxUtilities::strippedDeclaratorOrSelf(funcDecltor->innerDecltor_)); - if (stripInnerDecltor->kind() == PointerDeclarator) { - funcDecltor->equalsTkIdx_ = consume(); - init = &funcDecltor->init_; - break; - } - } - [[fallthrough]]; - } - - default: - diagReporter_.UnexpectedInitializerOfDeclarator(); - return ignoreDeclarator(); - } - if (!parseInitializer(*init)) - return false; - } + case OpenBraceToken: + if (parseFunctionDefinition_AtOpenBrace(decl, specList, decltor, nullptr)) + return true; + [[fallthrough]]; - switch (peek().kind()) { - case CommaToken: - (*decltorList_cur)->delimTkIdx_ = consume(); - break; - - case SemicolonToken: { - auto nameDecl = makeNode(); - decl = nameDecl; - nameDecl->semicolonTkIdx_ = consume(); - nameDecl->specs_ = const_cast(specList); - nameDecl->decltors_ = decltorList; - return true; - } - - case OpenBraceToken: - if (parseFunctionDefinition_AtOpenBrace(decl, specList, decltor, nullptr)) - return true; - [[fallthrough]]; - - default: { - if (init) { - diagReporter_.ExpectedFOLLOWofDeclaratorAndInitializer(); - return false; - } - - Backtracker BT(this); - ExtKR_ParameterDeclarationListSyntax* paramKRList = nullptr; - if (parseExtKR_ParameterDeclarationList(paramKRList)) { - BT.discard(); - if (parseFunctionDefinition_AtOpenBrace(decl, specList, decltor, paramKRList)) { - diagReporter_.delayedDiags_.clear(); - return true; - } - return false; - } - BT.backtrack(); - - diagReporter_.ExpectedFOLLOWofDeclarator(); - return false; - } + default: { + if (init) { + diagReporter_.ExpectedFOLLOWofDeclaratorAndInitializer(); + return false; + } + + Backtracker BT(this); + ExtKR_ParameterDeclarationListSyntax *paramKRList = nullptr; + if (parseExtKR_ParameterDeclarationList(paramKRList)) { + BT.discard(); + if (parseFunctionDefinition_AtOpenBrace(decl, specList, decltor, + paramKRList)) { + diagReporter_.delayedDiags_.clear(); + return true; } + return false; + } + BT.backtrack(); - decltorList_cur = &(*decltorList_cur)->next; + diagReporter_.ExpectedFOLLOWofDeclarator(); + return false; + } } + + decltorList_cur = &(*decltorList_cur)->next; + } } bool Parser::parseFunctionDefinition_AtOpenBrace( - DeclarationSyntax*& decl, - const SpecifierListSyntax* specList, - DeclaratorSyntax*& decltor, - ExtKR_ParameterDeclarationListSyntax* paramKRList) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenBraceToken, - return false, - "assert failure: `{'"); - - const DeclaratorSyntax* prevDecltor = nullptr; - const DeclaratorSyntax* outerDecltor = - SyntaxUtilities::strippedDeclaratorOrSelf(decltor); - while (outerDecltor) { - const DeclaratorSyntax* innerDecltor = - SyntaxUtilities::innerDeclaratorOrSelf(outerDecltor); - if (innerDecltor == outerDecltor) - break; - prevDecltor = outerDecltor; - outerDecltor = SyntaxUtilities::strippedDeclaratorOrSelf(innerDecltor); - } - - if (prevDecltor - && prevDecltor->kind() == FunctionDeclarator - && outerDecltor->kind() == IdentifierDeclarator) { - auto funcDef = makeNode(); - decl = funcDef; - funcDef->specs_ = const_cast(specList); - funcDef->decltor_ = decltor; - funcDef->extKR_params_ = paramKRList; - parseCompoundStatement_AtFirst(funcDef->body_, StatementContext::None); - return true; - } + DeclarationSyntax *&decl, const SpecifierListSyntax *specList, + DeclaratorSyntax *&decltor, + ExtKR_ParameterDeclarationListSyntax *paramKRList) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenBraceToken, return false, + "assert failure: `{'"); + + const DeclaratorSyntax *prevDecltor = nullptr; + const DeclaratorSyntax *outerDecltor = + SyntaxUtilities::strippedDeclaratorOrSelf(decltor); + while (outerDecltor) { + const DeclaratorSyntax *innerDecltor = + SyntaxUtilities::innerDeclaratorOrSelf(outerDecltor); + if (innerDecltor == outerDecltor) + break; + prevDecltor = outerDecltor; + outerDecltor = SyntaxUtilities::strippedDeclaratorOrSelf(innerDecltor); + } + + if (prevDecltor && prevDecltor->kind() == FunctionDeclarator && + outerDecltor->kind() == IdentifierDeclarator) { + auto funcDef = makeNode(); + decl = funcDef; + funcDef->specs_ = const_cast(specList); + funcDef->decltor_ = decltor; + funcDef->extKR_params_ = paramKRList; + parseCompoundStatement_AtFirst(funcDef->body_, StatementContext::None); + return true; + } - return false; + return false; } -Parser::IdentifierRole Parser::determineIdentifierRole(bool seenType) const -{ - /* - Upon an identifier, when parsing a declaration, we can't - tell whether the identifier is or a - . Only a "type seen" flag isn't enough to - help distinguishing the meaning of such identifier: e.g., - in `x;', where `x' doesn't name a type, `x' is the - of a variable implicitly typed with `int' - (a warning is diagnosed, though), but in `x;', given a - previous `typedef int x;', `x' is a of an - empty declaration (again, a warning is diagnosed). - - The way out of this situation, yet allowing valid code - to be parsed correctly, without an error, is to look - further ahead for another identifier: if one is found, - and a has already been (potentially) - seen, the found identifier must be a ; - however, if a hasn't yet been seen, or - if an additional identifier wasn't found, then we base - the decision on other tokens that might be valid within - a declarator. - */ - - auto parenCnt = 0; - auto LA = 2; - bool maybeKR = false; - while (true) { - switch (peek(LA).kind()) { - case IdentifierToken: - if (!maybeKR) { - if (seenType) - return IdentifierRole::AsDeclarator; - if (!parenCnt) - return IdentifierRole::AsTypedefName; - seenType = true; - } - ++LA; - continue; - - // type-specifier - case Keyword_void: - case Keyword_char: - case Keyword_short: - case Keyword_int: - case Keyword_long: - case Keyword_float: - case Keyword_double: - case Keyword__Bool: - case Keyword__Complex: - case Keyword_signed: - case Keyword_unsigned: - case Keyword_Ext_char16_t: - case Keyword_Ext_char32_t: - case Keyword_Ext_wchar_t: - case Keyword_struct: - case Keyword_union: - case Keyword_enum: - case Keyword_ExtGNU___complex__: - if (!maybeKR) { - if (seenType) - return IdentifierRole::AsDeclarator; - seenType = true; - } - ++LA; - continue; - - // storage-class-specifier - case Keyword_typedef: - case Keyword_extern: - case Keyword_static: - case Keyword_auto: - case Keyword_register: - case Keyword__Thread_local: - case Keyword_ExtGNU___thread: - ++LA; - continue; - - // type-qualifier - case Keyword_const: - case Keyword_volatile: - case Keyword_restrict: - case Keyword__Atomic: - ++LA; - continue; - - // function-specifier - case Keyword_inline: - case Keyword__Noreturn: - ++LA; - continue; - - // alignment-specifier - case Keyword__Alignas: - ++LA; - continue; - - // attribute-specifier - case Keyword_ExtGNU___attribute__: - if (!maybeKR && !parenCnt) - return IdentifierRole::AsTypedefName; - ++LA; - continue; - - // pointer-declarator - case AsteriskToken: - if (!parenCnt) - return IdentifierRole::AsTypedefName; - ++LA; - continue; - - case OpenParenToken: - ++parenCnt; - ++LA; - continue; - - case CloseParenToken: - --parenCnt; - if (!maybeKR) { - if (!parenCnt) { - if (seenType) - return IdentifierRole::AsTypedefName; - return IdentifierRole::AsDeclarator; - } - } - else { - if (peek(LA + 1).kind() == SemicolonToken) - return IdentifierRole::AsTypedefName; - return IdentifierRole::AsDeclarator; - } - ++LA; - continue; - - case CommaToken: - if (!parenCnt) { - if (seenType) - return IdentifierRole::AsTypedefName; - maybeKR = true; - ++LA; - continue; - } - if (parenCnt < 0) - return IdentifierRole::AsTypedefName; - return IdentifierRole::AsDeclarator; - - case SemicolonToken: - if (parenCnt < 0) - return IdentifierRole::AsTypedefName; - return IdentifierRole::AsDeclarator; - - case EndOfFile: - if (seenType) - return IdentifierRole::AsDeclarator; - return IdentifierRole::AsTypedefName; - - default: - if (!maybeKR) - return IdentifierRole::AsDeclarator; - ++LA; - continue; +Parser::IdentifierRole Parser::determineIdentifierRole(bool seenType) const { + /* + Upon an identifier, when parsing a declaration, we can't + tell whether the identifier is or a + . Only a "type seen" flag isn't enough to + help distinguishing the meaning of such identifier: e.g., + in `x;', where `x' doesn't name a type, `x' is the + of a variable implicitly typed with `int' + (a warning is diagnosed, though), but in `x;', given a + previous `typedef int x;', `x' is a of an + empty declaration (again, a warning is diagnosed). + + The way out of this situation, yet allowing valid code + to be parsed correctly, without an error, is to look + further ahead for another identifier: if one is found, + and a has already been (potentially) + seen, the found identifier must be a ; + however, if a hasn't yet been seen, or + if an additional identifier wasn't found, then we base + the decision on other tokens that might be valid within + a declarator. + */ + + auto parenCnt = 0; + auto LA = 2; + bool maybeKR = false; + while (true) { + switch (peek(LA).kind()) { + case IdentifierToken: + if (!maybeKR) { + if (seenType) + return IdentifierRole::AsDeclarator; + if (!parenCnt) + return IdentifierRole::AsTypedefName; + seenType = true; + } + ++LA; + continue; + + // type-specifier + case Keyword_void: + case Keyword_char: + case Keyword_short: + case Keyword_int: + case Keyword_long: + case Keyword_float: + case Keyword_double: + case Keyword__Bool: + case Keyword__Complex: + case Keyword_signed: + case Keyword_unsigned: + case Keyword_Ext_char16_t: + case Keyword_Ext_char32_t: + case Keyword_Ext_wchar_t: + case Keyword_struct: + case Keyword_union: + case Keyword_enum: + case Keyword_ExtGNU___complex__: + if (!maybeKR) { + if (seenType) + return IdentifierRole::AsDeclarator; + seenType = true; + } + ++LA; + continue; + + // storage-class-specifier + case Keyword_typedef: + case Keyword_extern: + case Keyword_static: + case Keyword_auto: + case Keyword_register: + case Keyword__Thread_local: + case Keyword_ExtGNU___thread: + ++LA; + continue; + + // type-qualifier + case Keyword_const: + case Keyword_volatile: + case Keyword_restrict: + case Keyword__Atomic: + ++LA; + continue; + + // function-specifier + case Keyword_inline: + case Keyword__Noreturn: + ++LA; + continue; + + // alignment-specifier + case Keyword__Alignas: + ++LA; + continue; + + // attribute-specifier + case Keyword_ExtGNU___attribute__: + if (!maybeKR && !parenCnt) + return IdentifierRole::AsTypedefName; + ++LA; + continue; + + // pointer-declarator + case AsteriskToken: + if (!parenCnt) + return IdentifierRole::AsTypedefName; + ++LA; + continue; + + case OpenParenToken: + ++parenCnt; + ++LA; + continue; + + case CloseParenToken: + --parenCnt; + if (!maybeKR) { + if (!parenCnt) { + if (seenType) + return IdentifierRole::AsTypedefName; + return IdentifierRole::AsDeclarator; } + } else { + if (peek(LA + 1).kind() == SemicolonToken) + return IdentifierRole::AsTypedefName; + return IdentifierRole::AsDeclarator; + } + ++LA; + continue; + + case CommaToken: + if (!parenCnt) { + if (seenType) + return IdentifierRole::AsTypedefName; + maybeKR = true; + ++LA; + continue; + } + if (parenCnt < 0) + return IdentifierRole::AsTypedefName; + return IdentifierRole::AsDeclarator; + + case SemicolonToken: + if (parenCnt < 0) + return IdentifierRole::AsTypedefName; + return IdentifierRole::AsDeclarator; + + case EndOfFile: + if (seenType) + return IdentifierRole::AsDeclarator; + return IdentifierRole::AsTypedefName; + + default: + if (!maybeKR) + return IdentifierRole::AsDeclarator; + ++LA; + continue; } + } } bool Parser::parseStructDeclaration_AtFollowOfSpecifierQualifierList( - DeclarationSyntax*& decl, - const SpecifierListSyntax* specList) -{ - DeclaratorListSyntax* decltorList = nullptr; - DeclaratorListSyntax** decltorList_cur = &decltorList; + DeclarationSyntax *&decl, const SpecifierListSyntax *specList) { + DeclaratorListSyntax *decltorList = nullptr; + DeclaratorListSyntax **decltorList_cur = &decltorList; - while (true) { - DeclaratorSyntax* decltor = nullptr; - if (!parseDeclarator(decltor, DeclarationScope::Block)) - return false; + while (true) { + DeclaratorSyntax *decltor = nullptr; + if (!parseDeclarator(decltor, DeclarationScope::Block)) + return false; - *decltorList_cur = makeNode(decltor); - - switch (peek().kind()) { - case CommaToken: - (*decltorList_cur)->delimTkIdx_ = consume(); - break; - - case SemicolonToken: { - auto memberDecl = makeNode(); - decl = memberDecl; - memberDecl->semicolonTkIdx_ = consume(); - memberDecl->specs_ = const_cast(specList); - memberDecl->decltors_ = decltorList; - return true; - } - - default: - diagReporter_.ExpectedFOLLOWofStructDeclarator(); - return false; - } + *decltorList_cur = makeNode(decltor); + + switch (peek().kind()) { + case CommaToken: + (*decltorList_cur)->delimTkIdx_ = consume(); + break; + + case SemicolonToken: { + auto memberDecl = makeNode(); + decl = memberDecl; + memberDecl->semicolonTkIdx_ = consume(); + memberDecl->specs_ = const_cast(specList); + memberDecl->decltors_ = decltorList; + return true; + } - decltorList_cur = &(*decltorList_cur)->next; + default: + diagReporter_.ExpectedFOLLOWofStructDeclarator(); + return false; } + + decltorList_cur = &(*decltorList_cur)->next; + } } /** @@ -607,34 +589,31 @@ bool Parser::parseStructDeclaration_AtFollowOfSpecifierQualifierList( * * \remark 6.7.2.1 */ -bool Parser::parseStructDeclaration(DeclarationSyntax*& decl) -{ - DEBUG_THIS_RULE(); - - switch (peek().kind()) { - case Keyword__Static_assert: - return parseStaticAssertDeclaration_AtFirst(decl); - - case Keyword_ExtGNU___extension__: { - auto extKwTkIdx = consume(); - if (!parseDeclaration( - decl, - &Parser::parseSpecifierQualifierList, - &Parser::parseStructDeclaration_AtFollowOfSpecifierQualifierList, - DeclarationScope::Block)) - return false; - PSY_ASSERT_W_MSG(decl, return false, "invalid declaration"); - decl->extKwTkIdx_ = extKwTkIdx; - return true; - } +bool Parser::parseStructDeclaration(DeclarationSyntax *&decl) { + DEBUG_THIS_RULE(); + + switch (peek().kind()) { + case Keyword__Static_assert: + return parseStaticAssertDeclaration_AtFirst(decl); + + case Keyword_ExtGNU___extension__: { + auto extKwTkIdx = consume(); + if (!parseDeclaration( + decl, &Parser::parseSpecifierQualifierList, + &Parser::parseStructDeclaration_AtFollowOfSpecifierQualifierList, + DeclarationScope::Block)) + return false; + PSY_ASSERT_W_MSG(decl, return false, "invalid declaration"); + decl->extKwTkIdx_ = extKwTkIdx; + return true; + } - default: - return parseDeclaration( - decl, - &Parser::parseSpecifierQualifierList, - &Parser::parseStructDeclaration_AtFollowOfSpecifierQualifierList, - DeclarationScope::Block); - } + default: + return parseDeclaration( + decl, &Parser::parseSpecifierQualifierList, + &Parser::parseStructDeclaration_AtFollowOfSpecifierQualifierList, + DeclarationScope::Block); + } } /** @@ -648,46 +627,45 @@ bool Parser::parseStructDeclaration(DeclarationSyntax*& decl) * * \remark 6.7.2.2 */ -bool Parser::parseEnumerator(DeclarationSyntax*& decl) -{ - DEBUG_THIS_RULE(); +bool Parser::parseEnumerator(DeclarationSyntax *&decl) { + DEBUG_THIS_RULE(); - EnumeratorDeclarationSyntax* enumMembDecl = nullptr; + EnumeratorDeclarationSyntax *enumMembDecl = nullptr; - switch (peek().kind()) { - case IdentifierToken: { - enumMembDecl = makeNode(); - decl = enumMembDecl; - enumMembDecl->identTkIdx_ = consume(); - break; - } + switch (peek().kind()) { + case IdentifierToken: { + enumMembDecl = makeNode(); + decl = enumMembDecl; + enumMembDecl->identTkIdx_ = consume(); + break; + } - default: - diagReporter_.ExpectedFIRSTofEnumerationConstant(); - return false; - } + default: + diagReporter_.ExpectedFIRSTofEnumerationConstant(); + return false; + } - if (peek().kind() == Keyword_ExtGNU___attribute__) - parseExtGNU_AttributeSpecifierList_AtFirst(enumMembDecl->attrs_); + if (peek().kind() == Keyword_ExtGNU___attribute__) + parseExtGNU_AttributeSpecifierList_AtFirst(enumMembDecl->attrs_); - switch (peek().kind()) { - case EqualsToken: - enumMembDecl->equalsTkIdx_ = consume(); - if (!parseExpressionWithPrecedenceConditional(enumMembDecl->expr_)) - return false; - if (peek().kind() != CommaToken) - break; - [[fallthrough]]; - - case CommaToken: - enumMembDecl->commaTkIdx_ = consume(); - [[fallthrough]]; - - default: - break; - } + switch (peek().kind()) { + case EqualsToken: + enumMembDecl->equalsTkIdx_ = consume(); + if (!parseExpressionWithPrecedenceConditional(enumMembDecl->expr_)) + return false; + if (peek().kind() != CommaToken) + break; + [[fallthrough]]; - return true; + case CommaToken: + enumMembDecl->commaTkIdx_ = consume(); + [[fallthrough]]; + + default: + break; + } + + return true; } /** @@ -702,41 +680,41 @@ bool Parser::parseEnumerator(DeclarationSyntax*& decl) * * \remark 6.7.6 */ -bool Parser::parseParameterDeclarationListAndOrEllipsis(ParameterSuffixSyntax*& paramDecltorSfx) -{ - DEBUG_THIS_RULE(); +bool Parser::parseParameterDeclarationListAndOrEllipsis( + ParameterSuffixSyntax *¶mDecltorSfx) { + DEBUG_THIS_RULE(); - switch (peek().kind()) { - case CloseParenToken: - break; + switch (peek().kind()) { + case CloseParenToken: + break; - case EllipsisToken: - if (!paramDecltorSfx->decls_) - diagReporter_.ExpectedNamedParameterBeforeEllipsis(); - paramDecltorSfx->ellipsisTkIdx_ = consume(); - break; + case EllipsisToken: + if (!paramDecltorSfx->decls_) + diagReporter_.ExpectedNamedParameterBeforeEllipsis(); + paramDecltorSfx->ellipsisTkIdx_ = consume(); + break; - default: - if (!parseParameterDeclarationList(paramDecltorSfx->decls_)) - return false; + default: + if (!parseParameterDeclarationList(paramDecltorSfx->decls_)) + return false; - switch (peek().kind()) { - case CommaToken: - paramDecltorSfx->decls_->delimTkIdx_ = consume(); - match(EllipsisToken, ¶mDecltorSfx->ellipsisTkIdx_); - break; + switch (peek().kind()) { + case CommaToken: + paramDecltorSfx->decls_->delimTkIdx_ = consume(); + match(EllipsisToken, ¶mDecltorSfx->ellipsisTkIdx_); + break; - case EllipsisToken: - paramDecltorSfx->ellipsisTkIdx_ = consume(); - [[fallthrough]]; + case EllipsisToken: + paramDecltorSfx->ellipsisTkIdx_ = consume(); + [[fallthrough]]; - default: - break; - } - break; + default: + break; } + break; + } - return true; + return true; } /** @@ -751,38 +729,38 @@ bool Parser::parseParameterDeclarationListAndOrEllipsis(ParameterSuffixSyntax*& * * \remark 6.7.6 */ -bool Parser::parseParameterDeclarationList(ParameterDeclarationListSyntax*& paramList) -{ - DEBUG_THIS_RULE(); +bool Parser::parseParameterDeclarationList( + ParameterDeclarationListSyntax *¶mList) { + DEBUG_THIS_RULE(); - DiagnosticsReporterDelayer DRD(&diagReporter_, - DiagnosticsReporter::ID_of_ExpectedTypeSpecifier); + DiagnosticsReporterDelayer DRD( + &diagReporter_, DiagnosticsReporter::ID_of_ExpectedTypeSpecifier); - ParameterDeclarationListSyntax** paramList_cur = ¶mList; + ParameterDeclarationListSyntax **paramList_cur = ¶mList; - ParameterDeclarationSyntax* paramDecl = nullptr; - if (!parseParameterDeclaration(paramDecl)) - return false; + ParameterDeclarationSyntax *paramDecl = nullptr; + if (!parseParameterDeclaration(paramDecl)) + return false; - *paramList_cur = makeNode(paramDecl); + *paramList_cur = makeNode(paramDecl); - while (peek().kind() == CommaToken) { - (*paramList_cur)->delimTkIdx_ = consume(); - paramList_cur = &(*paramList_cur)->next; + while (peek().kind() == CommaToken) { + (*paramList_cur)->delimTkIdx_ = consume(); + paramList_cur = &(*paramList_cur)->next; - switch (peek().kind()) { - case EllipsisToken: - return true; + switch (peek().kind()) { + case EllipsisToken: + return true; - default: - *paramList_cur = makeNode(); - if (!parseParameterDeclaration((*paramList_cur)->value)) - return false; - break; - } + default: + *paramList_cur = makeNode(); + if (!parseParameterDeclaration((*paramList_cur)->value)) + return false; + break; } + } - return true; + return true; } /** @@ -796,113 +774,111 @@ bool Parser::parseParameterDeclarationList(ParameterDeclarationListSyntax*& para * * \remark 6.7.6 */ -bool Parser::parseParameterDeclaration(ParameterDeclarationSyntax*& paramDecl) -{ - DEBUG_THIS_RULE(); +bool Parser::parseParameterDeclaration(ParameterDeclarationSyntax *¶mDecl) { + DEBUG_THIS_RULE(); - DeclarationSyntax* decl = nullptr; - SpecifierListSyntax* specList = nullptr; - if (!parseDeclarationSpecifiers(decl, specList)) - return false; + DeclarationSyntax *decl = nullptr; + SpecifierListSyntax *specList = nullptr; + if (!parseDeclarationSpecifiers(decl, specList)) + return false; - if (!specList) { - switch (peek().kind()) { - case IdentifierToken: - diagReporter_.ExpectedTypeSpecifier(); - break; + if (!specList) { + switch (peek().kind()) { + case IdentifierToken: + diagReporter_.ExpectedTypeSpecifier(); + break; - default: - diagReporter_.ExpectedFIRSTofParameterDeclaration(); - return false; - } + default: + diagReporter_.ExpectedFIRSTofParameterDeclaration(); + return false; } + } - paramDecl = makeNode(); - paramDecl->specs_ = specList; + paramDecl = makeNode(); + paramDecl->specs_ = specList; - Backtracker BT(this); - if (!parseDeclarator(paramDecl->decltor_, DeclarationScope::FunctionPrototype)) { - BT.backtrack(); - return parseAbstractDeclarator(paramDecl->decltor_); - } - BT.discard(); + Backtracker BT(this); + if (!parseDeclarator(paramDecl->decltor_, + DeclarationScope::FunctionPrototype)) { + BT.backtrack(); + return parseAbstractDeclarator(paramDecl->decltor_); + } + BT.discard(); - return true; + return true; } -bool Parser::parseExtPSY_TemplateDeclaration_AtFirst(DeclarationSyntax*& decl) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtPSY__Template, - return false, - "assert failure: `_Template'"); +bool Parser::parseExtPSY_TemplateDeclaration_AtFirst(DeclarationSyntax *&decl) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtPSY__Template, return false, + "assert failure: `_Template'"); - auto tmplDecl = makeNode(); - decl = tmplDecl; - tmplDecl->templateTkIdx_ = consume(); + auto tmplDecl = makeNode(); + decl = tmplDecl; + tmplDecl->templateTkIdx_ = consume(); - return parseDeclarationOrFunctionDefinition(tmplDecl->decl_); + return parseDeclarationOrFunctionDefinition(tmplDecl->decl_); } bool Parser::parseExtKR_ParameterDeclarationList( - ExtKR_ParameterDeclarationListSyntax *¶mList) -{ - DEBUG_THIS_RULE(); + ExtKR_ParameterDeclarationListSyntax *¶mList) { + DEBUG_THIS_RULE(); - ExtKR_ParameterDeclarationListSyntax** paramList_cur = ¶mList; + ExtKR_ParameterDeclarationListSyntax **paramList_cur = ¶mList; - ExtKR_ParameterDeclarationSyntax* paramDecl = nullptr; - if (!parseExtKR_ParameterDeclaration(paramDecl)) - return false; + ExtKR_ParameterDeclarationSyntax *paramDecl = nullptr; + if (!parseExtKR_ParameterDeclaration(paramDecl)) + return false; - *paramList_cur = makeNode(paramDecl); + *paramList_cur = makeNode(paramDecl); - while (peek().kind() != OpenBraceToken) { - paramList_cur = &(*paramList_cur)->next; + while (peek().kind() != OpenBraceToken) { + paramList_cur = &(*paramList_cur)->next; - ExtKR_ParameterDeclarationSyntax* nextParamDecl = nullptr; - if (!parseExtKR_ParameterDeclaration(nextParamDecl)) - return false; + ExtKR_ParameterDeclarationSyntax *nextParamDecl = nullptr; + if (!parseExtKR_ParameterDeclaration(nextParamDecl)) + return false; - *paramList_cur = makeNode(nextParamDecl); - } + *paramList_cur = + makeNode(nextParamDecl); + } - return true; + return true; } -bool Parser::parseExtKR_ParameterDeclaration(ExtKR_ParameterDeclarationSyntax*& paramDecl) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExtKR_ParameterDeclaration( + ExtKR_ParameterDeclarationSyntax *¶mDecl) { + DEBUG_THIS_RULE(); - DeclarationSyntax* decl = nullptr; - SpecifierListSyntax* specList = nullptr; - if (!parseDeclarationSpecifiers(decl, specList)) - return false; + DeclarationSyntax *decl = nullptr; + SpecifierListSyntax *specList = nullptr; + if (!parseDeclarationSpecifiers(decl, specList)) + return false; - paramDecl = makeNode(); - paramDecl->specs_ = specList; + paramDecl = makeNode(); + paramDecl->specs_ = specList; - DeclaratorListSyntax** decltorList_cur = ¶mDecl->decltors_; - while (true) { - DeclaratorSyntax* decltor = nullptr; - if (!parseDeclarator(decltor, DeclarationScope::FunctionPrototype)) - return false; + DeclaratorListSyntax **decltorList_cur = ¶mDecl->decltors_; + while (true) { + DeclaratorSyntax *decltor = nullptr; + if (!parseDeclarator(decltor, DeclarationScope::FunctionPrototype)) + return false; - *decltorList_cur = makeNode(decltor); - switch (peek().kind()) { - case CommaToken: - (*decltorList_cur)->delimTkIdx_ = consume(); - decltorList_cur = &(*decltorList_cur)->next; - break; + *decltorList_cur = makeNode(decltor); + switch (peek().kind()) { + case CommaToken: + (*decltorList_cur)->delimTkIdx_ = consume(); + decltorList_cur = &(*decltorList_cur)->next; + break; - case SemicolonToken: - paramDecl->semicolonTkIdx_ = consume(); - return true; + case SemicolonToken: + paramDecl->semicolonTkIdx_ = consume(); + return true; - default: - return false; - } + default: + return false; } + } } /* Specifiers */ @@ -920,206 +896,180 @@ bool Parser::parseExtKR_ParameterDeclaration(ExtKR_ParameterDeclarationSyntax*& * * \remark 6.7.1, 6.7.2, 6.7.3, 6.7.4, and 6.7.5 */ -bool Parser::parseDeclarationSpecifiers(DeclarationSyntax*& decl, - SpecifierListSyntax*& specList) -{ - DEBUG_THIS_RULE(); - - SpecifierListSyntax** specList_cur = &specList; - bool seenType = false; - - while (true) { - SpecifierSyntax* spec = nullptr; - switch (peek().kind()) { - // declaration-specifiers -> storage-class-specifier - case Keyword_typedef: - parseTrivialSpecifier_AtFirst( - spec, - TypedefStorageClass); - break; - - case Keyword_extern: - parseTrivialSpecifier_AtFirst( - spec, - ExternStorageClass); - break; - - case Keyword_static: - parseTrivialSpecifier_AtFirst( - spec, - StaticStorageClass); - break; - - case Keyword_auto: - parseTrivialSpecifier_AtFirst( - spec, - AutoStorageClass); - break; - - case Keyword_register: - parseTrivialSpecifier_AtFirst( - spec, - RegisterStorageClass); - break; - - case Keyword__Thread_local: - case Keyword_ExtGNU___thread: - parseTrivialSpecifier_AtFirst( - spec, - ThreadLocalStorageClass); - break; - - // declaration-specifiers -> type-qualifier - case Keyword_const: - parseTrivialSpecifier_AtFirst( - spec, - ConstQualifier); - break; - - case Keyword_volatile: - parseTrivialSpecifier_AtFirst( - spec, - VolatileQualifier); - break; - - case Keyword_restrict: - parseTrivialSpecifier_AtFirst( - spec, - RestrictQualifier); - break; - - // declaration-specifiers -> type-qualifier -> `_Atomic' - // declaration-specifiers -> type-specifier -> `_Atomic' `(' - case Keyword__Atomic: - if (peek(2).kind() == OpenParenToken) { - if (!parseAtomiceTypeSpecifier_AtFirst(spec)) - return false; - } - else - parseTrivialSpecifier_AtFirst( - spec, - AtomicQualifier); - break; - - // declaration-specifiers -> function-specifier - case Keyword_inline: - parseTrivialSpecifier_AtFirst( - spec, - InlineSpecifier); - break; - - case Keyword__Noreturn: - parseTrivialSpecifier_AtFirst( - spec, - NoReturnSpecifier); - break; - - // declaration-specifiers -> type-specifier -> "builtins" - case Keyword_void: - case Keyword_char: - case Keyword_short: - case Keyword_int: - case Keyword_long: - case Keyword_float: - case Keyword_double: - case Keyword__Bool: - case Keyword__Complex: - case Keyword_signed: - case Keyword_unsigned: - case Keyword_Ext_char16_t: - case Keyword_Ext_char32_t: - case Keyword_Ext_wchar_t: - case Keyword_ExtGNU___complex__: - seenType = true; - parseTrivialSpecifier_AtFirst( - spec, - BuiltinTypeSpecifier); - break; - - // declaration-specifiers -> type-specifier ->* `struct' - case Keyword_struct: - seenType = true; - if (!parseTagTypeSpecifier_AtFirst( - decl, - spec, - StructDeclaration, - StructTypeSpecifier, - &Parser::parseStructDeclaration)) - return false; - break; - - // declaration-specifiers -> type-specifier ->* `union' - case Keyword_union: - seenType = true; - if (!parseTagTypeSpecifier_AtFirst( - decl, - spec, - UnionDeclaration, - UnionTypeSpecifier, - &Parser::parseStructDeclaration)) - return false; - break; - - // declaration-specifiers -> type-specifier -> enum-specifier - case Keyword_enum: - seenType = true; - if (!parseTagTypeSpecifier_AtFirst( - decl, - spec, - EnumDeclaration, - EnumTypeSpecifier, - &Parser::parseEnumerator)) - return false; - break; - - // declaration-specifiers -> type-specifier -> typedef-name - case IdentifierToken: { - if (seenType) - return true; - - if (determineIdentifierRole(seenType) == IdentifierRole::AsDeclarator) - return true; - - seenType = true; - parseTypedefName_AtFirst(spec); - break; - } - - // declaration-specifiers -> alignment-specifier - case Keyword__Alignas: - if (!parseAlignmentSpecifier_AtFirst(spec)) - return false; - break; - - // declaration-specifiers -> GNU-attribute-specifier - case Keyword_ExtGNU___attribute__: - if (!parseExtGNU_AttributeSpecifier_AtFirst(spec)) - return false; - break; - - // declaration-specifiers -> GNU-typeof-specifier - case Keyword_ExtGNU___typeof__: - if (!parseExtGNU_Typeof_AtFirst(spec)) - return false; - break; - - // declaration-specifiers -> PsycheC - case Keyword_ExtPSY__Forall: - case Keyword_ExtPSY__Exists: - if (!parseExtPSY_QuantifiedTypeSpecifier_AtFirst(spec)) - return false; - break; - - default: - return true; - } +bool Parser::parseDeclarationSpecifiers(DeclarationSyntax *&decl, + SpecifierListSyntax *&specList) { + DEBUG_THIS_RULE(); - *specList_cur = makeNode(spec); - specList_cur = &(*specList_cur)->next; + SpecifierListSyntax **specList_cur = &specList; + bool seenType = false; - if (decl) - return parseTypeQualifiersAndAttributes(*specList_cur); + while (true) { + SpecifierSyntax *spec = nullptr; + switch (peek().kind()) { + // declaration-specifiers -> storage-class-specifier + case Keyword_typedef: + parseTrivialSpecifier_AtFirst(spec, + TypedefStorageClass); + break; + + case Keyword_extern: + parseTrivialSpecifier_AtFirst(spec, + ExternStorageClass); + break; + + case Keyword_static: + parseTrivialSpecifier_AtFirst(spec, + StaticStorageClass); + break; + + case Keyword_auto: + parseTrivialSpecifier_AtFirst(spec, AutoStorageClass); + break; + + case Keyword_register: + parseTrivialSpecifier_AtFirst(spec, + RegisterStorageClass); + break; + + case Keyword__Thread_local: + case Keyword_ExtGNU___thread: + parseTrivialSpecifier_AtFirst( + spec, ThreadLocalStorageClass); + break; + + // declaration-specifiers -> type-qualifier + case Keyword_const: + parseTrivialSpecifier_AtFirst(spec, ConstQualifier); + break; + + case Keyword_volatile: + parseTrivialSpecifier_AtFirst(spec, + VolatileQualifier); + break; + + case Keyword_restrict: + parseTrivialSpecifier_AtFirst(spec, + RestrictQualifier); + break; + + // declaration-specifiers -> type-qualifier -> `_Atomic' + // declaration-specifiers -> type-specifier -> `_Atomic' `(' + case Keyword__Atomic: + if (peek(2).kind() == OpenParenToken) { + if (!parseAtomiceTypeSpecifier_AtFirst(spec)) + return false; + } else + parseTrivialSpecifier_AtFirst(spec, + AtomicQualifier); + break; + + // declaration-specifiers -> function-specifier + case Keyword_inline: + parseTrivialSpecifier_AtFirst(spec, + InlineSpecifier); + break; + + case Keyword__Noreturn: + parseTrivialSpecifier_AtFirst(spec, + NoReturnSpecifier); + break; + + // declaration-specifiers -> type-specifier -> "builtins" + case Keyword_void: + case Keyword_char: + case Keyword_short: + case Keyword_int: + case Keyword_long: + case Keyword_float: + case Keyword_double: + case Keyword__Bool: + case Keyword__Complex: + case Keyword_signed: + case Keyword_unsigned: + case Keyword_Ext_char16_t: + case Keyword_Ext_char32_t: + case Keyword_Ext_wchar_t: + case Keyword_ExtGNU___complex__: + seenType = true; + parseTrivialSpecifier_AtFirst( + spec, BuiltinTypeSpecifier); + break; + + // declaration-specifiers -> type-specifier ->* `struct' + case Keyword_struct: + seenType = true; + if (!parseTagTypeSpecifier_AtFirst( + decl, spec, StructDeclaration, StructTypeSpecifier, + &Parser::parseStructDeclaration)) + return false; + break; + + // declaration-specifiers -> type-specifier ->* `union' + case Keyword_union: + seenType = true; + if (!parseTagTypeSpecifier_AtFirst( + decl, spec, UnionDeclaration, UnionTypeSpecifier, + &Parser::parseStructDeclaration)) + return false; + break; + + // declaration-specifiers -> type-specifier -> enum-specifier + case Keyword_enum: + seenType = true; + if (!parseTagTypeSpecifier_AtFirst( + decl, spec, EnumDeclaration, EnumTypeSpecifier, + &Parser::parseEnumerator)) + return false; + break; + + // declaration-specifiers -> type-specifier -> typedef-name + case IdentifierToken: { + if (seenType) + return true; + + if (determineIdentifierRole(seenType) == IdentifierRole::AsDeclarator) + return true; + + seenType = true; + parseTypedefName_AtFirst(spec); + break; + } + + // declaration-specifiers -> alignment-specifier + case Keyword__Alignas: + if (!parseAlignmentSpecifier_AtFirst(spec)) + return false; + break; + + // declaration-specifiers -> GNU-attribute-specifier + case Keyword_ExtGNU___attribute__: + if (!parseExtGNU_AttributeSpecifier_AtFirst(spec)) + return false; + break; + + // declaration-specifiers -> GNU-typeof-specifier + case Keyword_ExtGNU___typeof__: + if (!parseExtGNU_Typeof_AtFirst(spec)) + return false; + break; + + // declaration-specifiers -> PsycheC + case Keyword_ExtPSY__Forall: + case Keyword_ExtPSY__Exists: + if (!parseExtPSY_QuantifiedTypeSpecifier_AtFirst(spec)) + return false; + break; + + default: + return true; } + + *specList_cur = makeNode(spec); + specList_cur = &(*specList_cur)->next; + + if (decl) + return parseTypeQualifiersAndAttributes(*specList_cur); + } } /** @@ -1133,149 +1083,132 @@ bool Parser::parseDeclarationSpecifiers(DeclarationSyntax*& decl, * * \remark 6.7.2.1 */ -bool Parser::parseSpecifierQualifierList(DeclarationSyntax*& decl, - SpecifierListSyntax*& specList) -{ - DEBUG_THIS_RULE(); - - SpecifierListSyntax** specList_cur = &specList; - bool seenType = false; - - while (true) { - SpecifierSyntax* spec = nullptr; - switch (peek().kind()) { - // declaration-specifiers -> type-qualifier - case Keyword_const: - parseTrivialSpecifier_AtFirst( - spec, - ConstQualifier); - break; - - case Keyword_volatile: - parseTrivialSpecifier_AtFirst( - spec, - VolatileQualifier); - break; - - case Keyword_restrict: - parseTrivialSpecifier_AtFirst( - spec, - RestrictQualifier); - break; - - // declaration-specifiers -> type-qualifier -> `_Atomic' - // declaration-specifiers -> type-specifier -> `_Atomic' `(' - case Keyword__Atomic: - if (peek(2).kind() == OpenParenToken) { - if (!parseAtomiceTypeSpecifier_AtFirst(spec)) - return false; - } - else - parseTrivialSpecifier_AtFirst( - spec, - AtomicQualifier); - break; - - // declaration-specifiers -> type-specifier -> "builtins" - case Keyword_void: - case Keyword_char: - case Keyword_short: - case Keyword_int: - case Keyword_long: - case Keyword_float: - case Keyword_double: - case Keyword__Bool: - case Keyword__Complex: - case Keyword_signed: - case Keyword_unsigned: - case Keyword_Ext_char16_t: - case Keyword_Ext_char32_t: - case Keyword_Ext_wchar_t: - case Keyword_ExtGNU___complex__: - seenType = true; - parseTrivialSpecifier_AtFirst( - spec, - BuiltinTypeSpecifier); - break; - - // declaration-specifiers -> type-specifier ->* `struct' - case Keyword_struct: - seenType = true; - if (!parseTagTypeSpecifier_AtFirst( - decl, - spec, - StructDeclaration, - StructTypeSpecifier, - &Parser::parseStructDeclaration)) - return false; - break; - - // declaration-specifiers -> type-specifier ->* `union' - case Keyword_union: - seenType = true; - if (!parseTagTypeSpecifier_AtFirst( - decl, - spec, - UnionDeclaration, - UnionTypeSpecifier, - &Parser::parseStructDeclaration)) - return false; - break; - - // declaration-specifiers -> type-specifier -> enum-specifier - case Keyword_enum: - seenType = true; - if (!parseTagTypeSpecifier_AtFirst( - decl, - spec, - EnumDeclaration, - EnumTypeSpecifier, - &Parser::parseEnumerator)) - return false; - break; - - // declaration-specifiers -> type-specifier -> typedef-name - case IdentifierToken: { - if (seenType) - return true; - - seenType = true; - parseTypedefName_AtFirst(spec); - break; - } - - // declaration-specifiers -> alignment-specifier - case Keyword__Alignas: - if (!parseAlignmentSpecifier_AtFirst(spec)) - return false; - break; - - // declaration-specifiers -> GNU-attribute-specifier - case Keyword_ExtGNU___attribute__: - if (!parseExtGNU_AttributeSpecifier_AtFirst(spec)) - return false; - break; - - // declaration-specifiers -> GNU-typeof-specifier - case Keyword_ExtGNU___typeof__: - if (!parseExtGNU_Typeof_AtFirst(spec)) - return false; - break; - - default: - if (specList_cur == &specList) { - diagReporter_.ExpectedFIRSTofSpecifierQualifier(); - return false; - } - return true; - } +bool Parser::parseSpecifierQualifierList(DeclarationSyntax *&decl, + SpecifierListSyntax *&specList) { + DEBUG_THIS_RULE(); + + SpecifierListSyntax **specList_cur = &specList; + bool seenType = false; - *specList_cur = makeNode(spec); - specList_cur = &(*specList_cur)->next; + while (true) { + SpecifierSyntax *spec = nullptr; + switch (peek().kind()) { + // declaration-specifiers -> type-qualifier + case Keyword_const: + parseTrivialSpecifier_AtFirst(spec, ConstQualifier); + break; + + case Keyword_volatile: + parseTrivialSpecifier_AtFirst(spec, + VolatileQualifier); + break; + + case Keyword_restrict: + parseTrivialSpecifier_AtFirst(spec, + RestrictQualifier); + break; + + // declaration-specifiers -> type-qualifier -> `_Atomic' + // declaration-specifiers -> type-specifier -> `_Atomic' `(' + case Keyword__Atomic: + if (peek(2).kind() == OpenParenToken) { + if (!parseAtomiceTypeSpecifier_AtFirst(spec)) + return false; + } else + parseTrivialSpecifier_AtFirst(spec, + AtomicQualifier); + break; + + // declaration-specifiers -> type-specifier -> "builtins" + case Keyword_void: + case Keyword_char: + case Keyword_short: + case Keyword_int: + case Keyword_long: + case Keyword_float: + case Keyword_double: + case Keyword__Bool: + case Keyword__Complex: + case Keyword_signed: + case Keyword_unsigned: + case Keyword_Ext_char16_t: + case Keyword_Ext_char32_t: + case Keyword_Ext_wchar_t: + case Keyword_ExtGNU___complex__: + seenType = true; + parseTrivialSpecifier_AtFirst( + spec, BuiltinTypeSpecifier); + break; + + // declaration-specifiers -> type-specifier ->* `struct' + case Keyword_struct: + seenType = true; + if (!parseTagTypeSpecifier_AtFirst( + decl, spec, StructDeclaration, StructTypeSpecifier, + &Parser::parseStructDeclaration)) + return false; + break; + + // declaration-specifiers -> type-specifier ->* `union' + case Keyword_union: + seenType = true; + if (!parseTagTypeSpecifier_AtFirst( + decl, spec, UnionDeclaration, UnionTypeSpecifier, + &Parser::parseStructDeclaration)) + return false; + break; + + // declaration-specifiers -> type-specifier -> enum-specifier + case Keyword_enum: + seenType = true; + if (!parseTagTypeSpecifier_AtFirst( + decl, spec, EnumDeclaration, EnumTypeSpecifier, + &Parser::parseEnumerator)) + return false; + break; + + // declaration-specifiers -> type-specifier -> typedef-name + case IdentifierToken: { + if (seenType) + return true; - if (decl) - return parseTypeQualifiersAndAttributes(*specList_cur); + seenType = true; + parseTypedefName_AtFirst(spec); + break; } + + // declaration-specifiers -> alignment-specifier + case Keyword__Alignas: + if (!parseAlignmentSpecifier_AtFirst(spec)) + return false; + break; + + // declaration-specifiers -> GNU-attribute-specifier + case Keyword_ExtGNU___attribute__: + if (!parseExtGNU_AttributeSpecifier_AtFirst(spec)) + return false; + break; + + // declaration-specifiers -> GNU-typeof-specifier + case Keyword_ExtGNU___typeof__: + if (!parseExtGNU_Typeof_AtFirst(spec)) + return false; + break; + + default: + if (specList_cur == &specList) { + diagReporter_.ExpectedFIRSTofSpecifierQualifier(); + return false; + } + return true; + } + + *specList_cur = makeNode(spec); + specList_cur = &(*specList_cur)->next; + + if (decl) + return parseTypeQualifiersAndAttributes(*specList_cur); + } } /** @@ -1290,28 +1223,29 @@ bool Parser::parseSpecifierQualifierList(DeclarationSyntax*& decl, * \remark 6.7.1, 6.7.2, 6.7.3, and 6.7.4 */ template -void Parser::parseTrivialSpecifier_AtFirst(SpecifierSyntax*& spec, SyntaxKind specK) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(SyntaxFacts::isStorageClassToken(peek().kind()) - || SyntaxFacts::isBuiltinTypeSpecifierToken(peek().kind()) - || SyntaxFacts::isTypeQualifierToken(peek().kind()) - || SyntaxFacts::isFunctionSpecifierToken(peek().kind()) - || SyntaxFacts::isExtGNU_AsmQualifierToken(peek().kind()), - return, - "assert failure: , " - "(builtin) , " - ", " - ", or" - ""); - - auto trivSpec = makeNode(specK); - spec = trivSpec; - trivSpec->specTkIdx_ = consume(); +void Parser::parseTrivialSpecifier_AtFirst(SpecifierSyntax *&spec, + SyntaxKind specK) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG( + SyntaxFacts::isStorageClassToken(peek().kind()) || + SyntaxFacts::isBuiltinTypeSpecifierToken(peek().kind()) || + SyntaxFacts::isTypeQualifierToken(peek().kind()) || + SyntaxFacts::isFunctionSpecifierToken(peek().kind()) || + SyntaxFacts::isExtGNU_AsmQualifierToken(peek().kind()), + return, + "assert failure: , " + "(builtin) , " + ", " + ", or" + ""); + + auto trivSpec = makeNode(specK); + spec = trivSpec; + trivSpec->specTkIdx_ = consume(); } -template void Parser::parseTrivialSpecifier_AtFirst -(SpecifierSyntax*& spec, SyntaxKind specK); +template void Parser::parseTrivialSpecifier_AtFirst( + SpecifierSyntax *&spec, SyntaxKind specK); /** * Parse an \a alignment-specifier. @@ -1324,33 +1258,29 @@ template void Parser::parseTrivialSpecifier_AtFirst * * \remark 6.7.5 */ -bool Parser::parseAlignmentSpecifier_AtFirst(SpecifierSyntax*& spec) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword__Alignas, - return false, - "assert failure: `_Alignas'"); - - auto alignSpec = makeNode(); - spec = alignSpec; - alignSpec->alignasKwTkIdx_ = consume(); - return parseParenthesizedTypeNameOrExpression(alignSpec->tyRef_); +bool Parser::parseAlignmentSpecifier_AtFirst(SpecifierSyntax *&spec) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword__Alignas, return false, + "assert failure: `_Alignas'"); + + auto alignSpec = makeNode(); + spec = alignSpec; + alignSpec->alignasKwTkIdx_ = consume(); + return parseParenthesizedTypeNameOrExpression(alignSpec->tyRef_); } /** * Parse a GNU extension \c typeof \a specifier. */ -bool Parser::parseExtGNU_Typeof_AtFirst(SpecifierSyntax*& spec) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___typeof__, - return false, - "assert failure: `typeof'"); - - auto typeofSpec = makeNode(); - spec = typeofSpec; - typeofSpec->typeofKwTkIdx_ = consume(); - return parseParenthesizedTypeNameOrExpression(typeofSpec->tyRef_); +bool Parser::parseExtGNU_Typeof_AtFirst(SpecifierSyntax *&spec) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___typeof__, return false, + "assert failure: `typeof'"); + + auto typeofSpec = makeNode(); + spec = typeofSpec; + typeofSpec->typeofKwTkIdx_ = consume(); + return parseParenthesizedTypeNameOrExpression(typeofSpec->tyRef_); } /** @@ -1358,16 +1288,14 @@ bool Parser::parseExtGNU_Typeof_AtFirst(SpecifierSyntax*& spec) * * \remark 6.7.8 */ -void Parser::parseTypedefName_AtFirst(SpecifierSyntax*& spec) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == IdentifierToken, - return, - "assert failure: "); - - auto tyDefName = makeNode(); - spec = tyDefName; - tyDefName->identTkIdx_ = consume(); +void Parser::parseTypedefName_AtFirst(SpecifierSyntax *&spec) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == IdentifierToken, return, + "assert failure: "); + + auto tyDefName = makeNode(); + spec = tyDefName; + tyDefName->identTkIdx_ = consume(); } /** @@ -1375,20 +1303,18 @@ void Parser::parseTypedefName_AtFirst(SpecifierSyntax*& spec) * * \remark 6.7.2.4 */ -bool Parser::parseAtomiceTypeSpecifier_AtFirst(SpecifierSyntax*& spec) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword__Atomic, - return false, - "assert failure: `_Atomic'"); - - auto atomTySpec = makeNode(); - spec = atomTySpec; - atomTySpec->atomicKwTkIdx_ = consume(); - - return match(OpenParenToken, &atomTySpec->openParenTkIdx_) - && parseTypeName(atomTySpec->typeName_) - && matchOrSkipTo(CloseParenToken, &atomTySpec->closeParenTkIdx_); +bool Parser::parseAtomiceTypeSpecifier_AtFirst(SpecifierSyntax *&spec) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword__Atomic, return false, + "assert failure: `_Atomic'"); + + auto atomTySpec = makeNode(); + spec = atomTySpec; + atomTySpec->atomicKwTkIdx_ = consume(); + + return match(OpenParenToken, &atomTySpec->openParenTkIdx_) && + parseTypeName(atomTySpec->typeName_) && + matchOrSkipTo(CloseParenToken, &atomTySpec->closeParenTkIdx_); } /** @@ -1418,234 +1344,214 @@ bool Parser::parseAtomiceTypeSpecifier_AtFirst(SpecifierSyntax*& spec) */ template bool Parser::parseTagTypeSpecifier_AtFirst( - DeclarationSyntax*& decl, - SpecifierSyntax*& spec, - SyntaxKind declK, - SyntaxKind specK, - bool (Parser::*parseMember)(DeclarationSyntax*&)) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_struct - || peek().kind() == Keyword_union - || peek().kind() == Keyword_enum - && (declK == StructDeclaration - || declK == UnionDeclaration - || declK == EnumDeclaration) - && (specK == StructTypeSpecifier - || specK == UnionTypeSpecifier - || specK == EnumTypeSpecifier), - return false, - "assert failure: `struct', `union', or `enum'"); - - auto tySpec = makeNode(specK); - spec = tySpec; - tySpec->kwTkIdx_ = consume(); - - if (peek().kind() == Keyword_ExtGNU___attribute__) - parseExtGNU_AttributeSpecifierList_AtFirst(tySpec->attrs1_); - - auto wrapTySpecInTyDecl = [&]() { - auto tyDecl = makeNode(declK); - decl = tyDecl; - tyDecl->typeSpec_ = tySpec; - }; - + DeclarationSyntax *&decl, SpecifierSyntax *&spec, SyntaxKind declK, + SyntaxKind specK, bool (Parser::*parseMember)(DeclarationSyntax *&)) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG( + peek().kind() == Keyword_struct || peek().kind() == Keyword_union || + peek().kind() == Keyword_enum && + (declK == StructDeclaration || declK == UnionDeclaration || + declK == EnumDeclaration) && + (specK == StructTypeSpecifier || specK == UnionTypeSpecifier || + specK == EnumTypeSpecifier), + return false, "assert failure: `struct', `union', or `enum'"); + + auto tySpec = makeNode(specK); + spec = tySpec; + tySpec->kwTkIdx_ = consume(); + + if (peek().kind() == Keyword_ExtGNU___attribute__) + parseExtGNU_AttributeSpecifierList_AtFirst(tySpec->attrs1_); + + auto wrapTySpecInTyDecl = [&]() { + auto tyDecl = makeNode(declK); + decl = tyDecl; + tyDecl->typeSpec_ = tySpec; + }; + + switch (peek().kind()) { + case OpenBraceToken: + tySpec->openBraceTkIdx_ = consume(); + break; + + case IdentifierToken: + tySpec->tagTkIdx_ = consume(); switch (peek().kind()) { - case OpenBraceToken: - tySpec->openBraceTkIdx_ = consume(); - break; + case OpenBraceToken: + tySpec->openBraceTkIdx_ = consume(); + break; - case IdentifierToken: - tySpec->tagTkIdx_ = consume(); - switch (peek().kind()) { - case OpenBraceToken: - tySpec->openBraceTkIdx_ = consume(); - break; - - case SemicolonToken: - if (specK == StructTypeSpecifier - || specK == UnionTypeSpecifier) { - wrapTySpecInTyDecl(); - return true; - } - [[fallthrough]]; - - default: - return true; - } - break; + case SemicolonToken: + if (specK == StructTypeSpecifier || specK == UnionTypeSpecifier) { + wrapTySpecInTyDecl(); + return true; + } + [[fallthrough]]; - default: - diagReporter_.ExpectedFOLLOWofStructOrUnionOrEnum(); - return false; + default: + return true; } + break; - wrapTySpecInTyDecl(); + default: + diagReporter_.ExpectedFOLLOWofStructOrUnionOrEnum(); + return false; + } - DeclarationListSyntax** declList_cur = &tySpec->decls_; + wrapTySpecInTyDecl(); - while (true) { - DeclarationSyntax* memberDecl = nullptr; - switch (peek().kind()) { - case CloseBraceToken: - tySpec->closeBraceTkIdx_ = consume(); - goto MembersParsed; + DeclarationListSyntax **declList_cur = &tySpec->decls_; - default: - if (!((this)->*(parseMember))(memberDecl)) { - ignoreMemberDeclaration(); - if (peek().kind() == EndOfFile) - return false; - } - break; - } - *declList_cur = makeNode(memberDecl); - declList_cur = &(*declList_cur)->next; + while (true) { + DeclarationSyntax *memberDecl = nullptr; + switch (peek().kind()) { + case CloseBraceToken: + tySpec->closeBraceTkIdx_ = consume(); + goto MembersParsed; + + default: + if (!((this)->*(parseMember))(memberDecl)) { + ignoreMemberDeclaration(); + if (peek().kind() == EndOfFile) + return false; + } + break; } + *declList_cur = makeNode(memberDecl); + declList_cur = &(*declList_cur)->next; + } MembersParsed: - if (peek().kind() == Keyword_ExtGNU___attribute__) - parseExtGNU_AttributeSpecifierList_AtFirst(tySpec->attrs2_); + if (peek().kind() == Keyword_ExtGNU___attribute__) + parseExtGNU_AttributeSpecifierList_AtFirst(tySpec->attrs2_); - return true; + return true; } /** * Parse a GNU extension \a attribute-specifier list. */ -bool Parser::parseExtGNU_AttributeSpecifierList_AtFirst(SpecifierListSyntax*& specList) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___attribute__, - return false, - "assert failure: `__attribute__'"); +bool Parser::parseExtGNU_AttributeSpecifierList_AtFirst( + SpecifierListSyntax *&specList) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___attribute__, return false, + "assert failure: `__attribute__'"); - SpecifierListSyntax** specList_cur = &specList; + SpecifierListSyntax **specList_cur = &specList; - do { - SpecifierSyntax* spec = nullptr; - if (!parseExtGNU_AttributeSpecifier_AtFirst(spec)) - return false; + do { + SpecifierSyntax *spec = nullptr; + if (!parseExtGNU_AttributeSpecifier_AtFirst(spec)) + return false; - *specList_cur = makeNode(spec); - specList_cur = &(*specList_cur)->next; - } - while (peek().kind() == Keyword_ExtGNU___attribute__); + *specList_cur = makeNode(spec); + specList_cur = &(*specList_cur)->next; + } while (peek().kind() == Keyword_ExtGNU___attribute__); - return true; + return true; } /** * Parse an a GNU extension \a attribute-specifier. */ -bool Parser::parseExtGNU_AttributeSpecifier_AtFirst(SpecifierSyntax*& spec) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___attribute__, - return false, - "assert failure: `__attribute__'"); - - auto attrSpec = makeNode(); - spec = attrSpec; - attrSpec->attrKwTkIdx_ = consume(); - - if (match(OpenParenToken, &attrSpec->openOuterParenTkIdx_) - && match(OpenParenToken, &attrSpec->openInnerParenTkIdx_) - && parseExtGNU_AttributeList(attrSpec->attrs_) - && match(CloseParenToken, &attrSpec->closeInnerParenTkIdx_) - && match(CloseParenToken, &attrSpec->closeOuterParenTkIdx_)) - return true; +bool Parser::parseExtGNU_AttributeSpecifier_AtFirst(SpecifierSyntax *&spec) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___attribute__, return false, + "assert failure: `__attribute__'"); + + auto attrSpec = makeNode(); + spec = attrSpec; + attrSpec->attrKwTkIdx_ = consume(); + + if (match(OpenParenToken, &attrSpec->openOuterParenTkIdx_) && + match(OpenParenToken, &attrSpec->openInnerParenTkIdx_) && + parseExtGNU_AttributeList(attrSpec->attrs_) && + match(CloseParenToken, &attrSpec->closeInnerParenTkIdx_) && + match(CloseParenToken, &attrSpec->closeOuterParenTkIdx_)) + return true; - skipTo(CloseParenToken); - return false; + skipTo(CloseParenToken); + return false; } /** * Parse an \a attribute-list of GNU extension \a attribute-specifier. */ -bool Parser::parseExtGNU_AttributeList(ExtGNU_AttributeListSyntax*& attrList) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExtGNU_AttributeList(ExtGNU_AttributeListSyntax *&attrList) { + DEBUG_THIS_RULE(); - ExtGNU_AttributeListSyntax** attrList_cur = &attrList; + ExtGNU_AttributeListSyntax **attrList_cur = &attrList; - while (true) { - ExtGNU_AttributeSyntax* attr = nullptr; - if (!parseExtGNU_Attribute(attr)) - return false; + while (true) { + ExtGNU_AttributeSyntax *attr = nullptr; + if (!parseExtGNU_Attribute(attr)) + return false; - *attrList_cur = makeNode(attr); + *attrList_cur = makeNode(attr); - switch (peek().kind()) { - case CommaToken: - (*attrList_cur)->delimTkIdx_ = consume(); - attrList_cur = &(*attrList_cur)->next; - break; + switch (peek().kind()) { + case CommaToken: + (*attrList_cur)->delimTkIdx_ = consume(); + attrList_cur = &(*attrList_cur)->next; + break; - case CloseParenToken: - return true; + case CloseParenToken: + return true; - default: - diagReporter_.ExpectedTokenWithin( - { CommaToken, - CloseParenToken }); - return false; - } + default: + diagReporter_.ExpectedTokenWithin({CommaToken, CloseParenToken}); + return false; } - return true; + } + return true; } /** * Parse a GNU extension \a attribute. */ -bool Parser::parseExtGNU_Attribute(ExtGNU_AttributeSyntax*& attr) -{ - DEBUG_THIS_RULE(); - - switch (peek().kind()) { - case IdentifierToken: - case Keyword_const: - attr = makeNode(); - attr->kwOrIdentTkIdx_ = consume(); - break; +bool Parser::parseExtGNU_Attribute(ExtGNU_AttributeSyntax *&attr) { + DEBUG_THIS_RULE(); + + switch (peek().kind()) { + case IdentifierToken: + case Keyword_const: + attr = makeNode(); + attr->kwOrIdentTkIdx_ = consume(); + break; + + case CommaToken: + case CloseParenToken: + // An empty attribute is valid. + attr = makeNode(); + return true; - case CommaToken: - case CloseParenToken: - // An empty attribute is valid. - attr = makeNode(); - return true; - - default: - diagReporter_.ExpectedTokenWithin( - { IdentifierToken, - Keyword_const, - CommaToken, - CloseParenToken }); - return false; - } + default: + diagReporter_.ExpectedTokenWithin( + {IdentifierToken, Keyword_const, CommaToken, CloseParenToken}); + return false; + } - if (peek().kind() != OpenParenToken) - return true; + if (peek().kind() != OpenParenToken) + return true; - attr->openParenTkIdx_ = consume(); + attr->openParenTkIdx_ = consume(); - auto ident = tree_->tokenAt(attr->kwOrIdentTkIdx_).identifier_; - bool (Parser::*parseAttrArg)(ExpressionListSyntax*&); - if (ident && !strcmp(ident->c_str(), "availability")) - parseAttrArg = &Parser::parseExtGNU_AttributeArgumentsLLVM; - else - parseAttrArg = &Parser::parseExtGNU_AttributeArguments; + auto ident = tree_->tokenAt(attr->kwOrIdentTkIdx_).identifier_; + bool (Parser::*parseAttrArg)(ExpressionListSyntax *&); + if (ident && !strcmp(ident->c_str(), "availability")) + parseAttrArg = &Parser::parseExtGNU_AttributeArgumentsLLVM; + else + parseAttrArg = &Parser::parseExtGNU_AttributeArguments; - return ((this->*(parseAttrArg))(attr->exprs_)) - && matchOrSkipTo(CloseParenToken, &attr->closeParenTkIdx_); + return ((this->*(parseAttrArg))(attr->exprs_)) && + matchOrSkipTo(CloseParenToken, &attr->closeParenTkIdx_); } /** * Parse the arguments of a GNU extension \a attribute. */ -bool Parser::parseExtGNU_AttributeArguments(ExpressionListSyntax*& exprList) -{ - return parseCallArguments(exprList); +bool Parser::parseExtGNU_AttributeArguments(ExpressionListSyntax *&exprList) { + return parseCallArguments(exprList); } /** @@ -1663,317 +1569,289 @@ bool Parser::parseExtGNU_AttributeArguments(ExpressionListSyntax*& exprList) * * \see https://clang.llvm.org/docs/AttributeReference.html#availability */ -bool Parser::parseExtGNU_AttributeArgumentsLLVM(ExpressionListSyntax*& exprList) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExtGNU_AttributeArgumentsLLVM( + ExpressionListSyntax *&exprList) { + DEBUG_THIS_RULE(); - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_AttributeSpecifiersLLVM()) - diagReporter_.ExpectedFeature("GNU attributes of LLVM"); + if (!tree_->parseOptions() + .extensions() + .isEnabled_ExtGNU_AttributeSpecifiersLLVM()) + diagReporter_.ExpectedFeature("GNU attributes of LLVM"); - ExpressionListSyntax** exprList_cur = &exprList; + ExpressionListSyntax **exprList_cur = &exprList; - ExpressionSyntax* platName = nullptr; - if (!parseIdentifierName(platName)) - return false; + ExpressionSyntax *platName = nullptr; + if (!parseIdentifierName(platName)) + return false; - *exprList_cur = makeNode(platName); + *exprList_cur = makeNode(platName); - while (peek().kind() == CommaToken) { - (*exprList_cur)->delimTkIdx_ = consume(); - exprList_cur = &(*exprList_cur)->next; + while (peek().kind() == CommaToken) { + (*exprList_cur)->delimTkIdx_ = consume(); + exprList_cur = &(*exprList_cur)->next; - ExpressionSyntax* expr = nullptr; - if (!parseIdentifierName(expr)) - return false; + ExpressionSyntax *expr = nullptr; + if (!parseIdentifierName(expr)) + return false; - switch (peek().kind()) { - case EqualsToken: { - auto equalsTkIdx_ = consume(); - ExpressionSyntax* versionExpr = nullptr; - if (peek().kind() == StringLiteralToken) - parseStringLiteral_AtFirst(versionExpr); - else { - if (!parseConstant( - versionExpr, - FloatingConstantExpression)) - return false; - - // Discard any (possible) "patch" component of a version. - if (peek().kind() == IntegerConstantToken) - consume(); - } - - auto assign = makeNode(BasicAssignmentExpression); - assign->leftExpr_ = expr; - assign->oprtrTkIdx_ = equalsTkIdx_; - assign->rightExpr_ = versionExpr; - expr = assign; - break; - } - - default: - break; - } - *exprList_cur = makeNode(expr); + switch (peek().kind()) { + case EqualsToken: { + auto equalsTkIdx_ = consume(); + ExpressionSyntax *versionExpr = nullptr; + if (peek().kind() == StringLiteralToken) + parseStringLiteral_AtFirst(versionExpr); + else { + if (!parseConstant( + versionExpr, FloatingConstantExpression)) + return false; + + // Discard any (possible) "patch" component of a version. + if (peek().kind() == IntegerConstantToken) + consume(); + } + + auto assign = makeNode(BasicAssignmentExpression); + assign->leftExpr_ = expr; + assign->oprtrTkIdx_ = equalsTkIdx_; + assign->rightExpr_ = versionExpr; + expr = assign; + break; } - return true; + default: + break; + } + *exprList_cur = makeNode(expr); + } + + return true; } -bool Parser::parseExtGNU_AsmLabel_AtFirst(SpecifierSyntax*& attr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___asm__, - return false, - "assert failure: `asm'"); - - auto asmAttr = makeNode(); - attr = asmAttr; - asmAttr->asmKwTkIdx_ = consume(); - - if (match(OpenParenToken, &asmAttr->openParenTkIdx_) - && parseStringLiteral(asmAttr->strLit_) - && match(CloseParenToken, &asmAttr->closeParenTkIdx_)) - return true; +bool Parser::parseExtGNU_AsmLabel_AtFirst(SpecifierSyntax *&attr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___asm__, return false, + "assert failure: `asm'"); - return false; + auto asmAttr = makeNode(); + attr = asmAttr; + asmAttr->asmKwTkIdx_ = consume(); + + if (match(OpenParenToken, &asmAttr->openParenTkIdx_) && + parseStringLiteral(asmAttr->strLit_) && + match(CloseParenToken, &asmAttr->closeParenTkIdx_)) + return true; + + return false; } -bool Parser::parseExtPSY_QuantifiedTypeSpecifier_AtFirst(SpecifierSyntax*& spec) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtPSY__Exists - || peek().kind() == Keyword_ExtPSY__Forall, - return false, - "assert failure: `_Exists' or `_Forall'"); - - auto typeSpec = makeNode(); - spec = typeSpec; - typeSpec->quantifierTkIdx_ = consume(); - - if (match(OpenParenToken, &typeSpec->openParenTkIdx_) - && match(IdentifierToken, &typeSpec->identTkIdx_) - && match(CloseParenToken, &typeSpec->closeParenTkIdx_)) - return true; +bool Parser::parseExtPSY_QuantifiedTypeSpecifier_AtFirst( + SpecifierSyntax *&spec) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtPSY__Exists || + peek().kind() == Keyword_ExtPSY__Forall, + return false, "assert failure: `_Exists' or `_Forall'"); - return false; + auto typeSpec = makeNode(); + spec = typeSpec; + typeSpec->quantifierTkIdx_ = consume(); + + if (match(OpenParenToken, &typeSpec->openParenTkIdx_) && + match(IdentifierToken, &typeSpec->identTkIdx_) && + match(CloseParenToken, &typeSpec->closeParenTkIdx_)) + return true; + + return false; } /* Declarators */ -bool Parser::parseAbstractDeclarator(DeclaratorSyntax*& decltor) -{ - DEBUG_THIS_RULE(); +bool Parser::parseAbstractDeclarator(DeclaratorSyntax *&decltor) { + DEBUG_THIS_RULE(); - return parseDeclarator(decltor, - DeclarationScope::FunctionPrototype, - DeclaratorVariety::Abstract); + return parseDeclarator(decltor, DeclarationScope::FunctionPrototype, + DeclaratorVariety::Abstract); } -bool Parser::parseDeclarator(DeclaratorSyntax*& decltor, - DeclarationScope declScope) -{ - DEBUG_THIS_RULE(); +bool Parser::parseDeclarator(DeclaratorSyntax *&decltor, + DeclarationScope declScope) { + DEBUG_THIS_RULE(); - return parseDeclarator(decltor, declScope, DeclaratorVariety::Named); + return parseDeclarator(decltor, declScope, DeclaratorVariety::Named); } -bool Parser::parseDeclarator(DeclaratorSyntax*& decltor, +bool Parser::parseDeclarator(DeclaratorSyntax *&decltor, DeclarationScope declScope, DeclaratorVariety decltorVariety) { - DEBUG_THIS_RULE(); - - SpecifierListSyntax* attrList = nullptr; - if (peek().kind() == Keyword_ExtGNU___attribute__) - parseExtGNU_AttributeSpecifierList_AtFirst(attrList); - - if (peek().kind() == AsteriskToken) { - auto ptrDecltor = makeNode(); - decltor = ptrDecltor; - ptrDecltor->attrs_ = attrList; - ptrDecltor->asteriskTkIdx_ = consume(); - if (!parseTypeQualifiersAndAttributes(ptrDecltor->qualsAndAttrs_)) - return false; - return parseDeclarator(ptrDecltor->innerDecltor_, declScope, decltorVariety); - } - - return parseDirectDeclarator(decltor, declScope, decltorVariety, attrList); + DEBUG_THIS_RULE(); + + SpecifierListSyntax *attrList = nullptr; + if (peek().kind() == Keyword_ExtGNU___attribute__) + parseExtGNU_AttributeSpecifierList_AtFirst(attrList); + + if (peek().kind() == AsteriskToken) { + auto ptrDecltor = makeNode(); + decltor = ptrDecltor; + ptrDecltor->attrs_ = attrList; + ptrDecltor->asteriskTkIdx_ = consume(); + if (!parseTypeQualifiersAndAttributes(ptrDecltor->qualsAndAttrs_)) + return false; + return parseDeclarator(ptrDecltor->innerDecltor_, declScope, + decltorVariety); + } + + return parseDirectDeclarator(decltor, declScope, decltorVariety, attrList); } -bool Parser::parseDirectDeclarator(DeclaratorSyntax*& decltor, +bool Parser::parseDirectDeclarator(DeclaratorSyntax *&decltor, DeclarationScope declScope, DeclaratorVariety decltorVariety, - SpecifierListSyntax* attrList) -{ - DEBUG_THIS_RULE(); + SpecifierListSyntax *attrList) { + DEBUG_THIS_RULE(); + + switch (peek().kind()) { + case IdentifierToken: { + if (decltorVariety == DeclaratorVariety::Abstract) + return false; + + auto identDecltor = makeNode(); + decltor = identDecltor; + identDecltor->identTkIdx_ = consume(); + identDecltor->attrs1_ = attrList; + if (!parseDirectDeclaratorSuffix(decltor, declScope, decltorVariety, + attrList, identDecltor)) + return false; + + SpecifierListSyntax **specList_cur = &identDecltor->attrs2_; switch (peek().kind()) { - case IdentifierToken: { - if (decltorVariety == DeclaratorVariety::Abstract) - return false; - - auto identDecltor = makeNode(); - decltor = identDecltor; - identDecltor->identTkIdx_ = consume(); - identDecltor->attrs1_ = attrList; - if (!parseDirectDeclaratorSuffix( - decltor, - declScope, - decltorVariety, - attrList, - identDecltor)) - return false; - - SpecifierListSyntax** specList_cur = &identDecltor->attrs2_; - - switch (peek().kind()) { - case Keyword_ExtGNU___asm__: { - SpecifierSyntax* spec = nullptr; - if (!parseExtGNU_AsmLabel_AtFirst(spec)) - return false; - - *specList_cur = makeNode(spec); - specList_cur = &(*specList_cur)->next; - - if (peek().kind() != Keyword_ExtGNU___attribute__) - break; - [[fallthrough]]; - } - - case Keyword_ExtGNU___attribute__: - if (!parseExtGNU_AttributeSpecifierList_AtFirst(*specList_cur)) - return false; - break; - - default: - break; - } - break; - } + case Keyword_ExtGNU___asm__: { + SpecifierSyntax *spec = nullptr; + if (!parseExtGNU_AsmLabel_AtFirst(spec)) + return false; - case OpenParenToken: { - if (decltorVariety == DeclaratorVariety::Abstract) { - if (peek(2).kind() == CloseParenToken) { - if (!parseDirectDeclaratorSuffix( - decltor, - declScope, - decltorVariety, - attrList, - nullptr)) - return false; - break; - } - else { - Backtracker BT(this); - auto openParenTkIdx = consume(); - DeclaratorSyntax* innerDecltor = nullptr; - if (!parseAbstractDeclarator(innerDecltor) - || peek().kind() != CloseParenToken) { - BT.backtrack(); - auto absDecltor = makeNode(); - decltor = absDecltor; - absDecltor->attrs_ = attrList; - if (!parseDirectDeclaratorSuffix( - decltor, - declScope, - decltorVariety, - attrList, - absDecltor)) - return false; - break; - } - BT.discard(); - - auto parenDecltor = makeNode(); - decltor = parenDecltor; - parenDecltor->openParenTkIdx_ = openParenTkIdx; - parenDecltor->innerDecltor_ = innerDecltor; - parenDecltor->closeParenTkIdx_ = consume(); - if (!parseDirectDeclaratorSuffix( - decltor, - declScope, - decltorVariety, - attrList, - parenDecltor)) - return false; - break; - } - } - - auto parenDecltor = makeNode(); - parenDecltor->openParenTkIdx_ = consume(); - if (!parseDeclarator(parenDecltor->innerDecltor_, declScope, decltorVariety) - || !match(CloseParenToken, &parenDecltor->closeParenTkIdx_) - || !parseDirectDeclaratorSuffix(decltor, - declScope, - decltorVariety, - attrList, - parenDecltor)) - return false; - - if (!decltor) - decltor = parenDecltor; - break; - } + *specList_cur = makeNode(spec); + specList_cur = &(*specList_cur)->next; - case OpenBracketToken: - if (decltorVariety == DeclaratorVariety::Abstract) { - auto absDecltor = makeNode(); - decltor = absDecltor; - absDecltor->attrs_ = attrList; - if (!parseDirectDeclaratorSuffix( - decltor, - declScope, - decltorVariety, - attrList, - absDecltor)) - return false; - break; - } - diagReporter_.ExpectedFIRSTofDirectDeclarator(); - return false; + if (peek().kind() != Keyword_ExtGNU___attribute__) + break; + [[fallthrough]]; + } - case ColonToken: - if (decltorVariety == DeclaratorVariety::Named - && declScope == DeclarationScope::Block) { - auto bitFldDecltor = makeNode(); - decltor = bitFldDecltor; - bitFldDecltor->colonTkIdx_ = consume(); - if (!parseExpressionWithPrecedenceConditional(bitFldDecltor->expr_)) - return false; - break; - } - [[fallthrough]]; - - default: { - if (decltorVariety == DeclaratorVariety::Abstract) { - auto absDecltor = makeNode(); - decltor = absDecltor; - absDecltor->attrs_ = attrList; - break; - } - diagReporter_.ExpectedFIRSTofDirectDeclarator(); + case Keyword_ExtGNU___attribute__: + if (!parseExtGNU_AttributeSpecifierList_AtFirst(*specList_cur)) + return false; + break; + + default: + break; + } + break; + } + + case OpenParenToken: { + if (decltorVariety == DeclaratorVariety::Abstract) { + if (peek(2).kind() == CloseParenToken) { + if (!parseDirectDeclaratorSuffix(decltor, declScope, decltorVariety, + attrList, nullptr)) + return false; + break; + } else { + Backtracker BT(this); + auto openParenTkIdx = consume(); + DeclaratorSyntax *innerDecltor = nullptr; + if (!parseAbstractDeclarator(innerDecltor) || + peek().kind() != CloseParenToken) { + BT.backtrack(); + auto absDecltor = makeNode(); + decltor = absDecltor; + absDecltor->attrs_ = attrList; + if (!parseDirectDeclaratorSuffix(decltor, declScope, decltorVariety, + attrList, absDecltor)) return false; + break; } + BT.discard(); + + auto parenDecltor = makeNode(); + decltor = parenDecltor; + parenDecltor->openParenTkIdx_ = openParenTkIdx; + parenDecltor->innerDecltor_ = innerDecltor; + parenDecltor->closeParenTkIdx_ = consume(); + if (!parseDirectDeclaratorSuffix(decltor, declScope, decltorVariety, + attrList, parenDecltor)) + return false; + break; + } } - if (peek().kind() == ColonToken - && decltorVariety == DeclaratorVariety::Named - && declScope == DeclarationScope::Block) { - auto bitFldDecltor = makeNode(); - bitFldDecltor->innerDecltor_ = decltor; - decltor = bitFldDecltor; - bitFldDecltor->colonTkIdx_ = consume(); - if (!parseExpressionWithPrecedenceConditional(bitFldDecltor->expr_)) - return false; + auto parenDecltor = makeNode(); + parenDecltor->openParenTkIdx_ = consume(); + if (!parseDeclarator(parenDecltor->innerDecltor_, declScope, + decltorVariety) || + !match(CloseParenToken, &parenDecltor->closeParenTkIdx_) || + !parseDirectDeclaratorSuffix(decltor, declScope, decltorVariety, + attrList, parenDecltor)) + return false; + + if (!decltor) + decltor = parenDecltor; + break; + } + + case OpenBracketToken: + if (decltorVariety == DeclaratorVariety::Abstract) { + auto absDecltor = makeNode(); + decltor = absDecltor; + absDecltor->attrs_ = attrList; + if (!parseDirectDeclaratorSuffix(decltor, declScope, decltorVariety, + attrList, absDecltor)) + return false; + break; + } + diagReporter_.ExpectedFIRSTofDirectDeclarator(); + return false; - if (peek().kind() == Keyword_ExtGNU___attribute__) - parseExtGNU_AttributeSpecifierList_AtFirst(bitFldDecltor->attrs_); + case ColonToken: + if (decltorVariety == DeclaratorVariety::Named && + declScope == DeclarationScope::Block) { + auto bitFldDecltor = makeNode(); + decltor = bitFldDecltor; + bitFldDecltor->colonTkIdx_ = consume(); + if (!parseExpressionWithPrecedenceConditional(bitFldDecltor->expr_)) + return false; + break; } + [[fallthrough]]; + + default: { + if (decltorVariety == DeclaratorVariety::Abstract) { + auto absDecltor = makeNode(); + decltor = absDecltor; + absDecltor->attrs_ = attrList; + break; + } + diagReporter_.ExpectedFIRSTofDirectDeclarator(); + return false; + } + } + + if (peek().kind() == ColonToken && + decltorVariety == DeclaratorVariety::Named && + declScope == DeclarationScope::Block) { + auto bitFldDecltor = makeNode(); + bitFldDecltor->innerDecltor_ = decltor; + decltor = bitFldDecltor; + bitFldDecltor->colonTkIdx_ = consume(); + if (!parseExpressionWithPrecedenceConditional(bitFldDecltor->expr_)) + return false; - return true; + if (peek().kind() == Keyword_ExtGNU___attribute__) + parseExtGNU_AttributeSpecifierList_AtFirst(bitFldDecltor->attrs_); + } + + return true; } /** @@ -1989,182 +1867,179 @@ bool Parser::parseDirectDeclarator(DeclaratorSyntax*& decltor, * * \remark 6.7.6 */ -bool Parser::parseDirectDeclaratorSuffix(DeclaratorSyntax*& decltor, +bool Parser::parseDirectDeclaratorSuffix(DeclaratorSyntax *&decltor, DeclarationScope declScope, DeclaratorVariety decltorVariety, - SpecifierListSyntax* attrList, - DeclaratorSyntax* innerDecltor) -{ - auto validateContext = - [this, declScope] (void (Parser::DiagnosticsReporter::*report)()) { - if (declScope != DeclarationScope::FunctionPrototype) { - ((diagReporter_).*(report))(); - skipTo(CloseBracketToken); - return false; - } - return true; - }; - - auto checkDialect = - [this] () { - if (tree_->dialect().std() < LanguageDialect::Std::C99) { - diagReporter_.ExpectedFeature( - "C99 array declarators with `*', `static', and type-qualifiers " - "within function parameters"); - } - }; - - switch (peek().kind()) { - case OpenParenToken: { - auto funcDecltorSfx = makeNode(); - funcDecltorSfx->openParenTkIdx_ = consume(); - if (!parseParameterDeclarationListAndOrEllipsis(funcDecltorSfx) - || !match(CloseParenToken, &funcDecltorSfx->closeParenTkIdx_)) - return false; - - if (peek().kind() == Keyword_ExtPSY_omission) - funcDecltorSfx->psyOmitTkIdx_ = consume(); - - decltor = makeNode(FunctionDeclarator); - decltor->asArrayOrFunctionDeclarator()->suffix_ = funcDecltorSfx; - break; - } - - case OpenBracketToken: { - auto arrDecltorSx = makeNode(); - arrDecltorSx->openBracketTkIdx_ = consume(); - switch (peek().kind()) { - case CloseBracketToken: - break; - - case AsteriskToken: - checkDialect(); - if (!validateContext(&Parser::DiagnosticsReporter:: - UnexpectedPointerInArrayDeclarator)) { - skipTo(CloseBracketToken); - return false; - } - arrDecltorSx->asteriskTkIdx_ = consume(); - break; - - case Keyword_const: - case Keyword_volatile: - case Keyword_restrict: - case Keyword__Atomic: - case Keyword_ExtGNU___attribute__: { - checkDialect(); - if (!validateContext(&Parser::DiagnosticsReporter:: - UnexpectedStaticOrTypeQualifiersInArrayDeclarator) - || !parseTypeQualifiersAndAttributes(arrDecltorSx->qualsAndAttrs1_)) { - skipTo(CloseBracketToken); - return false; - } - - auto tkK = peek().kind(); - if (tkK == AsteriskToken) { - arrDecltorSx->asteriskTkIdx_ = consume(); - break; - } - else if (tkK != Keyword_static) { - if (!parseExpressionWithPrecedenceAssignment(arrDecltorSx->expr_)) { - skipTo(CloseBracketToken); - return false; - } - break; - } - [[fallthrough]]; - } - - case Keyword_static: - checkDialect(); - if (!validateContext(&Parser::DiagnosticsReporter:: - UnexpectedStaticOrTypeQualifiersInArrayDeclarator)) { - skipTo(CloseBracketToken); - return false; - } - - arrDecltorSx->staticKwTkIdx_ = consume(); - switch (peek().kind()) { - case Keyword_const: - case Keyword_volatile: - case Keyword_restrict: - case Keyword_ExtGNU___attribute__: - if (!parseTypeQualifiersAndAttributes(arrDecltorSx->qualsAndAttrs2_)) { - skipTo(CloseBracketToken); - return false; - } - [[fallthrough]]; - - default: - break; - } - [[fallthrough]]; - - default: - if (!parseExpressionWithPrecedenceAssignment(arrDecltorSx->expr_)) { - skipTo(CloseBracketToken); - return false; - } - break; - } - - if (!matchOrSkipTo(CloseBracketToken, &arrDecltorSx->closeBracketTkIdx_)) - return false; - - decltor = makeNode(ArrayDeclarator); - decltor->asArrayOrFunctionDeclarator()->suffix_ = arrDecltorSx; - break; + SpecifierListSyntax *attrList, + DeclaratorSyntax *innerDecltor) { + auto validateContext = + [this, declScope](void (Parser::DiagnosticsReporter::*report)()) { + if (declScope != DeclarationScope::FunctionPrototype) { + ((diagReporter_).*(report))(); + skipTo(CloseBracketToken); + return false; } + return true; + }; - default: - return true; + auto checkDialect = [this]() { + if (tree_->dialect().std() < LanguageDialect::Std::C99) { + diagReporter_.ExpectedFeature( + "C99 array declarators with `*', `static', and type-qualifiers " + "within function parameters"); } - - auto arrayOrFuncDecltor = static_cast(decltor); - arrayOrFuncDecltor->attrs1_ = attrList; - arrayOrFuncDecltor->innerDecltor_ = innerDecltor; - - SpecifierListSyntax** specList_cur = &arrayOrFuncDecltor->attrs2_; - + }; + + switch (peek().kind()) { + case OpenParenToken: { + auto funcDecltorSfx = makeNode(); + funcDecltorSfx->openParenTkIdx_ = consume(); + if (!parseParameterDeclarationListAndOrEllipsis(funcDecltorSfx) || + !match(CloseParenToken, &funcDecltorSfx->closeParenTkIdx_)) + return false; + + if (peek().kind() == Keyword_ExtPSY_omission) + funcDecltorSfx->psyOmitTkIdx_ = consume(); + + decltor = makeNode(FunctionDeclarator); + decltor->asArrayOrFunctionDeclarator()->suffix_ = funcDecltorSfx; + break; + } + + case OpenBracketToken: { + auto arrDecltorSx = makeNode(); + arrDecltorSx->openBracketTkIdx_ = consume(); switch (peek().kind()) { - case Keyword_ExtGNU___asm__: { - SpecifierSyntax* spec = nullptr; - if (!parseExtGNU_AsmLabel_AtFirst(spec)) - return false; - - *specList_cur = makeNode(spec); - specList_cur = &(*specList_cur)->next; + case CloseBracketToken: + break; + + case AsteriskToken: + checkDialect(); + if (!validateContext(&Parser::DiagnosticsReporter:: + UnexpectedPointerInArrayDeclarator)) { + skipTo(CloseBracketToken); + return false; + } + arrDecltorSx->asteriskTkIdx_ = consume(); + break; + + case Keyword_const: + case Keyword_volatile: + case Keyword_restrict: + case Keyword__Atomic: + case Keyword_ExtGNU___attribute__: { + checkDialect(); + if (!validateContext( + &Parser::DiagnosticsReporter:: + UnexpectedStaticOrTypeQualifiersInArrayDeclarator) || + !parseTypeQualifiersAndAttributes(arrDecltorSx->qualsAndAttrs1_)) { + skipTo(CloseBracketToken); + return false; + } + + auto tkK = peek().kind(); + if (tkK == AsteriskToken) { + arrDecltorSx->asteriskTkIdx_ = consume(); + break; + } else if (tkK != Keyword_static) { + if (!parseExpressionWithPrecedenceAssignment(arrDecltorSx->expr_)) { + skipTo(CloseBracketToken); + return false; + } + break; + } + [[fallthrough]]; + } - if (peek().kind() != Keyword_ExtGNU___attribute__) - break; - [[fallthrough]]; + case Keyword_static: + checkDialect(); + if (!validateContext( + &Parser::DiagnosticsReporter:: + UnexpectedStaticOrTypeQualifiersInArrayDeclarator)) { + skipTo(CloseBracketToken); + return false; + } + + arrDecltorSx->staticKwTkIdx_ = consume(); + switch (peek().kind()) { + case Keyword_const: + case Keyword_volatile: + case Keyword_restrict: + case Keyword_ExtGNU___attribute__: + if (!parseTypeQualifiersAndAttributes(arrDecltorSx->qualsAndAttrs2_)) { + skipTo(CloseBracketToken); + return false; } + [[fallthrough]]; - case Keyword_ExtGNU___attribute__: - if (!parseExtGNU_AttributeSpecifierList_AtFirst(*specList_cur)) - return false; - break; + default: + break; + } + [[fallthrough]]; - default: - break; + default: + if (!parseExpressionWithPrecedenceAssignment(arrDecltorSx->expr_)) { + skipTo(CloseBracketToken); + return false; + } + break; } - switch (peek().kind()) { - case OpenParenToken: - case OpenBracketToken: { - innerDecltor = decltor; - return parseDirectDeclaratorSuffix(decltor, - declScope, - decltorVariety, - nullptr, - innerDecltor); - } + if (!matchOrSkipTo(CloseBracketToken, &arrDecltorSx->closeBracketTkIdx_)) + return false; - default: - return true; - } + decltor = makeNode(ArrayDeclarator); + decltor->asArrayOrFunctionDeclarator()->suffix_ = arrDecltorSx; + break; + } + default: + return true; + } + + auto arrayOrFuncDecltor = + static_cast(decltor); + arrayOrFuncDecltor->attrs1_ = attrList; + arrayOrFuncDecltor->innerDecltor_ = innerDecltor; + + SpecifierListSyntax **specList_cur = &arrayOrFuncDecltor->attrs2_; + + switch (peek().kind()) { + case Keyword_ExtGNU___asm__: { + SpecifierSyntax *spec = nullptr; + if (!parseExtGNU_AsmLabel_AtFirst(spec)) + return false; + + *specList_cur = makeNode(spec); + specList_cur = &(*specList_cur)->next; + + if (peek().kind() != Keyword_ExtGNU___attribute__) + break; + [[fallthrough]]; + } + + case Keyword_ExtGNU___attribute__: + if (!parseExtGNU_AttributeSpecifierList_AtFirst(*specList_cur)) + return false; + break; + + default: + break; + } + + switch (peek().kind()) { + case OpenParenToken: + case OpenBracketToken: { + innerDecltor = decltor; + return parseDirectDeclaratorSuffix(decltor, declScope, decltorVariety, + nullptr, innerDecltor); + } + + default: return true; + } + + return true; } /** @@ -2178,54 +2053,47 @@ bool Parser::parseDirectDeclaratorSuffix(DeclaratorSyntax*& decltor, * * \remark 6.7.6.1. */ -bool Parser::parseTypeQualifiersAndAttributes(SpecifierListSyntax*& specList) -{ - DEBUG_THIS_RULE(); - - SpecifierListSyntax** specList_cur = &specList; - - while (true) { - SpecifierSyntax* spec = nullptr; - switch (peek().kind()) { - case Keyword_ExtGNU___attribute__: - return parseExtGNU_AttributeSpecifierList_AtFirst(specList); - - case Keyword_ExtGNU___asm__: - if (parseExtGNU_AsmLabel_AtFirst(spec)) - return false; - break; - - case Keyword_const: - parseTrivialSpecifier_AtFirst( - spec, - ConstQualifier); - break; - - case Keyword_volatile: - parseTrivialSpecifier_AtFirst( - spec, - VolatileQualifier); - break; - - case Keyword_restrict: - parseTrivialSpecifier_AtFirst( - spec, - RestrictQualifier); - break; - - case Keyword__Atomic: - parseTrivialSpecifier_AtFirst( - spec, - AtomicQualifier); - break; - - default: - return true; - } +bool Parser::parseTypeQualifiersAndAttributes(SpecifierListSyntax *&specList) { + DEBUG_THIS_RULE(); + + SpecifierListSyntax **specList_cur = &specList; + + while (true) { + SpecifierSyntax *spec = nullptr; + switch (peek().kind()) { + case Keyword_ExtGNU___attribute__: + return parseExtGNU_AttributeSpecifierList_AtFirst(specList); + + case Keyword_ExtGNU___asm__: + if (parseExtGNU_AsmLabel_AtFirst(spec)) + return false; + break; + + case Keyword_const: + parseTrivialSpecifier_AtFirst(spec, ConstQualifier); + break; + + case Keyword_volatile: + parseTrivialSpecifier_AtFirst(spec, + VolatileQualifier); + break; + + case Keyword_restrict: + parseTrivialSpecifier_AtFirst(spec, + RestrictQualifier); + break; - *specList_cur = makeNode(spec); - specList_cur = &(*specList_cur)->next; + case Keyword__Atomic: + parseTrivialSpecifier_AtFirst(spec, AtomicQualifier); + break; + + default: + return true; } + + *specList_cur = makeNode(spec); + specList_cur = &(*specList_cur)->next; + } } /* Initializers */ @@ -2250,17 +2118,16 @@ bool Parser::parseTypeQualifiersAndAttributes(SpecifierListSyntax*& specList) * * \remark 6.7.9 */ -bool Parser::parseInitializer(InitializerSyntax*& init) -{ - DEBUG_THIS_RULE(); +bool Parser::parseInitializer(InitializerSyntax *&init) { + DEBUG_THIS_RULE(); - switch (peek().kind()) { - case OpenBraceToken: - return parseBraceEnclosedInitializer_AtFirst(init); + switch (peek().kind()) { + case OpenBraceToken: + return parseBraceEnclosedInitializer_AtFirst(init); - default: - return parseExpressionInitializer(init); - } + default: + return parseExpressionInitializer(init); + } } /** @@ -2273,16 +2140,15 @@ bool Parser::parseInitializer(InitializerSyntax*& init) assignment-expression \endverbatim */ -bool Parser::parseExpressionInitializer(InitializerSyntax*& init) -{ - ExpressionSyntax* expr = nullptr; - if (!parseExpressionWithPrecedenceAssignment(expr)) - return false; +bool Parser::parseExpressionInitializer(InitializerSyntax *&init) { + ExpressionSyntax *expr = nullptr; + if (!parseExpressionWithPrecedenceAssignment(expr)) + return false; - auto exprInit = makeNode(); - init = exprInit; - exprInit->expr_ = expr; - return true; + auto exprInit = makeNode(); + init = exprInit; + exprInit->expr_ = expr; + return true; } /** @@ -2296,208 +2162,200 @@ bool Parser::parseExpressionInitializer(InitializerSyntax*& init) { initializer-list, } \endverbatim */ -bool Parser::parseBraceEnclosedInitializer_AtFirst(InitializerSyntax*& init) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenBraceToken, - return false, - "expected `{'"); - - auto braceInit = makeNode(); - init = braceInit; - braceInit->openBraceTkIdx_ = consume(); - - if (peek().kind() == CloseBraceToken) { - diagReporter_.ExpectedBraceEnclosedInitializerList(); - braceInit->closeBraceTkIdx_ = consume(); - return true; - } +bool Parser::parseBraceEnclosedInitializer_AtFirst(InitializerSyntax *&init) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenBraceToken, return false, + "expected `{'"); + + auto braceInit = makeNode(); + init = braceInit; + braceInit->openBraceTkIdx_ = consume(); + + if (peek().kind() == CloseBraceToken) { + diagReporter_.ExpectedBraceEnclosedInitializerList(); + braceInit->closeBraceTkIdx_ = consume(); + return true; + } - if (!parseInitializerList(braceInit->initList_)) { - skipTo(CloseBraceToken); - consume(); - return false; - } + if (!parseInitializerList(braceInit->initList_)) { + skipTo(CloseBraceToken); + consume(); + return false; + } - return matchOrSkipTo(CloseBraceToken, &braceInit->closeBraceTkIdx_); + return matchOrSkipTo(CloseBraceToken, &braceInit->closeBraceTkIdx_); } -bool Parser::parseInitializerList(InitializerListSyntax*& initList) -{ - DEBUG_THIS_RULE(); +bool Parser::parseInitializerList(InitializerListSyntax *&initList) { + DEBUG_THIS_RULE(); - return parseCommaSeparatedItems( - initList, - &Parser::parseInitializerListItem); + return parseCommaSeparatedItems( + initList, &Parser::parseInitializerListItem); } -bool Parser::parseInitializerListItem(InitializerSyntax*& init, InitializerListSyntax*& initList) -{ - DEBUG_THIS_RULE(); +bool Parser::parseInitializerListItem(InitializerSyntax *&init, + InitializerListSyntax *&initList) { + DEBUG_THIS_RULE(); - switch (peek().kind()) { - case CloseBraceToken: - return true; - - case CommaToken: - if (peek(2).kind() == CloseBraceToken) { - initList->delimTkIdx_ = consume(); - return true; - } - diagReporter_.ExpectedFIRSTofExpression(); - return false; + switch (peek().kind()) { + case CloseBraceToken: + return true; + + case CommaToken: + if (peek(2).kind() == CloseBraceToken) { + initList->delimTkIdx_ = consume(); + return true; + } + diagReporter_.ExpectedFIRSTofExpression(); + return false; - case DotToken: - return parseDesignatedInitializer_AtFirst( - init, - &Parser::parseFieldDesignator_AtFirst); + case DotToken: + return parseDesignatedInitializer_AtFirst( + init, &Parser::parseFieldDesignator_AtFirst); - case OpenBracketToken: - return parseDesignatedInitializer_AtFirst( - init, - &Parser::parseArrayDesignator_AtFirst); + case OpenBracketToken: + return parseDesignatedInitializer_AtFirst( + init, &Parser::parseArrayDesignator_AtFirst); - case OpenBraceToken: - return parseBraceEnclosedInitializer_AtFirst(init); + case OpenBraceToken: + return parseBraceEnclosedInitializer_AtFirst(init); - default: - return parseExpressionInitializer(init); - } + default: + return parseExpressionInitializer(init); + } } -bool Parser::parseDesignatedInitializer_AtFirst(InitializerSyntax*& init, - bool (Parser::*parseDesig)(DesignatorSyntax*& desig)) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == DotToken - || peek().kind() == OpenBracketToken, - return false, - "assert failure: `.' or `['"); - - if (tree_->dialect().std() < LanguageDialect::Std::C99 - && !tree_->parseOptions().extensions().isEnabled_ExtGNU_DesignatedInitializers()) - diagReporter_.ExpectedFeature("GNU/C99 designated initializers"); - - DesignatorListSyntax* desigList = nullptr; - if (!parseDesignatorList_AtFirst(desigList, parseDesig)) - return false; +bool Parser::parseDesignatedInitializer_AtFirst( + InitializerSyntax *&init, + bool (Parser::*parseDesig)(DesignatorSyntax *&desig)) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == DotToken || + peek().kind() == OpenBracketToken, + return false, "assert failure: `.' or `['"); + + if (tree_->dialect().std() < LanguageDialect::Std::C99 && + !tree_->parseOptions() + .extensions() + .isEnabled_ExtGNU_DesignatedInitializers()) + diagReporter_.ExpectedFeature("GNU/C99 designated initializers"); + + DesignatorListSyntax *desigList = nullptr; + if (!parseDesignatorList_AtFirst(desigList, parseDesig)) + return false; - auto desigInit = makeNode(); - init = desigInit; - desigInit->desigs_ = desigList; + auto desigInit = makeNode(); + init = desigInit; + desigInit->desigs_ = desigList; - switch (peek().kind()) { - case EqualsToken: - desigInit->equalsTkIdx_ = consume(); - return parseInitializer(desigInit->init_); + switch (peek().kind()) { + case EqualsToken: + desigInit->equalsTkIdx_ = consume(); + return parseInitializer(desigInit->init_); - default: - diagReporter_.ExpectedFOLLOWofDesignatedInitializer(); - return parseInitializer(desigInit->init_); - } + default: + diagReporter_.ExpectedFOLLOWofDesignatedInitializer(); + return parseInitializer(desigInit->init_); + } } -bool Parser::parseDesignatorList_AtFirst(DesignatorListSyntax*& desigList, - bool (Parser::*parseDesig)(DesignatorSyntax*& desig)) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == DotToken - || peek().kind() == OpenBracketToken, - return false, - "assert failure: `.' or `['"); +bool Parser::parseDesignatorList_AtFirst( + DesignatorListSyntax *&desigList, + bool (Parser::*parseDesig)(DesignatorSyntax *&desig)) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == DotToken || + peek().kind() == OpenBracketToken, + return false, "assert failure: `.' or `['"); - DesignatorListSyntax** desigs_cur = &desigList; + DesignatorListSyntax **desigs_cur = &desigList; - while (true) { - DesignatorSyntax* desig = nullptr; - if (!(((this)->*(parseDesig))(desig))) - return false; + while (true) { + DesignatorSyntax *desig = nullptr; + if (!(((this)->*(parseDesig))(desig))) + return false; - *desigs_cur = makeNode(desig); - desigs_cur = &(*desigs_cur)->next; + *desigs_cur = makeNode(desig); + desigs_cur = &(*desigs_cur)->next; - switch (peek().kind()) { - case DotToken: - parseDesig = &Parser::parseFieldDesignator_AtFirst; - break; + switch (peek().kind()) { + case DotToken: + parseDesig = &Parser::parseFieldDesignator_AtFirst; + break; - case OpenBracketToken: - parseDesig = &Parser::parseArrayDesignator_AtFirst; - break; + case OpenBracketToken: + parseDesig = &Parser::parseArrayDesignator_AtFirst; + break; - default: - return true; - } + default: + return true; } + } } -bool Parser::parseFieldDesignator_AtFirst(DesignatorSyntax*& desig) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == DotToken, - return false, - "assert failure: `.'"); +bool Parser::parseFieldDesignator_AtFirst(DesignatorSyntax *&desig) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == DotToken, return false, + "assert failure: `.'"); - auto fldDesig = makeNode(); - desig = fldDesig; - fldDesig->dotTkIdx_ = consume(); + auto fldDesig = makeNode(); + desig = fldDesig; + fldDesig->dotTkIdx_ = consume(); - if (peek().kind() == IdentifierToken) { - fldDesig->identTkIdx_ = consume(); - return true; - } + if (peek().kind() == IdentifierToken) { + fldDesig->identTkIdx_ = consume(); + return true; + } - diagReporter_.ExpectedFieldDesignator(); - return false; + diagReporter_.ExpectedFieldDesignator(); + return false; } -bool Parser::parseArrayDesignator_AtFirst(DesignatorSyntax*& desig) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenBracketToken, - return false, - "assert failure: `['"); +bool Parser::parseArrayDesignator_AtFirst(DesignatorSyntax *&desig) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenBracketToken, return false, + "assert failure: `['"); - auto arrDesig = makeNode(); - desig = arrDesig; - arrDesig->openBracketTkIdx_ = consume(); + auto arrDesig = makeNode(); + desig = arrDesig; + arrDesig->openBracketTkIdx_ = consume(); - return parseExpressionWithPrecedenceConditional(arrDesig->expr_) - && matchOrSkipTo(CloseBracketToken, &arrDesig->closeBracketTkIdx_); + return parseExpressionWithPrecedenceConditional(arrDesig->expr_) && + matchOrSkipTo(CloseBracketToken, &arrDesig->closeBracketTkIdx_); } /** - * Parse Standard's \c offsetof and GNU's \c __builtin_offsetof \a member-designator. + * Parse Standard's \c offsetof and GNU's \c __builtin_offsetof \a + * member-designator. */ -bool Parser::parseOffsetOfDesignator(DesignatorSyntax*& desig) -{ - DEBUG_THIS_RULE(); - - if (peek().kind() != SyntaxKind::IdentifierToken) { - diagReporter_.ExpectedTokenOfCategoryIdentifier(); - return false; - } +bool Parser::parseOffsetOfDesignator(DesignatorSyntax *&desig) { + DEBUG_THIS_RULE(); - auto offsetOfDesig = makeNode(); - desig = offsetOfDesig; - offsetOfDesig->identTkIdx_ = consume(); - - DesignatorListSyntax* desigList = nullptr; - switch (peek().kind()) { - case DotToken: - if (!parseDesignatorList_AtFirst(desigList, &Parser::parseFieldDesignator_AtFirst)) - return false; - break; - - case OpenBracketToken: - if (!parseDesignatorList_AtFirst(desigList, &Parser::parseArrayDesignator_AtFirst)) - return false; - break; - - default: - return true; - } - - offsetOfDesig->desigs_ = desigList; + if (peek().kind() != SyntaxKind::IdentifierToken) { + diagReporter_.ExpectedTokenOfCategoryIdentifier(); + return false; + } + + auto offsetOfDesig = makeNode(); + desig = offsetOfDesig; + offsetOfDesig->identTkIdx_ = consume(); + + DesignatorListSyntax *desigList = nullptr; + switch (peek().kind()) { + case DotToken: + if (!parseDesignatorList_AtFirst(desigList, + &Parser::parseFieldDesignator_AtFirst)) + return false; + break; + + case OpenBracketToken: + if (!parseDesignatorList_AtFirst(desigList, + &Parser::parseArrayDesignator_AtFirst)) + return false; + break; + + default: return true; + } + + offsetOfDesig->desigs_ = desigList; + return true; } diff --git a/C/parser/Parser_Expressions.cpp b/C/parser/Parser_Expressions.cpp index 5d9c1c86d..c6ced20f1 100644 --- a/C/parser/Parser_Expressions.cpp +++ b/C/parser/Parser_Expressions.cpp @@ -30,7 +30,8 @@ using namespace C; /** * Parse an \a expression. - * + * * This table * * describes the choices taken by the parser as according to the grammar rules. @@ -55,12 +56,11 @@ using namespace C; * \a cast-expression may actually derive an \a constant, whose node is a * ConstantExpressionSyntax. */ -bool Parser::parseExpression(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpression(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - DepthControl _(DEPTH_OF_EXPRS_); - return parseExpressionWithPrecedenceComma(expr); + DepthControl _(DEPTH_OF_EXPRS_); + return parseExpressionWithPrecedenceComma(expr); } /** @@ -68,17 +68,16 @@ bool Parser::parseExpression(ExpressionSyntax*& expr) * * \remark 6.4.2 and 6.5.1 */ -bool Parser::parseIdentifierName(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseIdentifierName(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - if (peek().kind() != SyntaxKind::IdentifierToken) { - diagReporter_.ExpectedTokenOfCategoryIdentifier(); - return false; - } + if (peek().kind() != SyntaxKind::IdentifierToken) { + diagReporter_.ExpectedTokenOfCategoryIdentifier(); + return false; + } - parseIdentifierName_AtFirst(expr); - return true; + parseIdentifierName_AtFirst(expr); + return true; } /** @@ -86,31 +85,27 @@ bool Parser::parseIdentifierName(ExpressionSyntax*& expr) * * \remark 6.4.2 and 6.5.1 */ -void Parser::parseIdentifierName_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == IdentifierToken, - return, - "assert failure: "); - - auto identExpr = makeNode(); - expr = identExpr; - identExpr->identTkIdx_ = consume(); +void Parser::parseIdentifierName_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == IdentifierToken, return, + "assert failure: "); + + auto identExpr = makeNode(); + expr = identExpr; + identExpr->identTkIdx_ = consume(); } /** * Parse a \a predefined name as an \a expression, with LA(1) at first. */ -void Parser::parsePredefinedName_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(SyntaxFacts::isPredefinedToken(peek().kind()), - return, - "assert failure: "); - - auto predefExpr = makeNode(); - expr = predefExpr; - predefExpr->predefTkIdx_ = consume(); +void Parser::parsePredefinedName_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(SyntaxFacts::isPredefinedToken(peek().kind()), return, + "assert failure: "); + + auto predefExpr = makeNode(); + expr = predefExpr; + predefExpr->predefTkIdx_ = consume(); } /** @@ -119,21 +114,21 @@ void Parser::parsePredefinedName_AtFirst(ExpressionSyntax*& expr) * \remark 6.4.4 and 6.5.1 */ template -bool Parser::parseConstant(ExpressionSyntax*& expr, SyntaxKind exprK) -{ - DEBUG_THIS_RULE(); +bool Parser::parseConstant(ExpressionSyntax *&expr, SyntaxKind exprK) { + DEBUG_THIS_RULE(); - if (!SyntaxFacts::isConstantToken(peek().kind())) { - diagReporter_.ExpectedTokenOfCategoryConstant(); - return false; - } + if (!SyntaxFacts::isConstantToken(peek().kind())) { + diagReporter_.ExpectedTokenOfCategoryConstant(); + return false; + } - parseConstant_AtFirst(expr, exprK); - return true; + parseConstant_AtFirst(expr, exprK); + return true; } -template bool Parser::parseConstant -(ExpressionSyntax*& expr, SyntaxKind exprK); +template bool +Parser::parseConstant(ExpressionSyntax *&expr, + SyntaxKind exprK); /** * Parse a \a constant, with LA(1) at FIRST. @@ -141,35 +136,33 @@ template bool Parser::parseConstant * \remark 6.4.4 and 6.5.1 */ template -void Parser::parseConstant_AtFirst(ExpressionSyntax*& expr, SyntaxKind exprK) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(SyntaxFacts::isConstantToken(peek().kind()), - return, - "assert failure: "); - - auto constExpr = makeNode(exprK); - expr = constExpr; - constExpr->constantTkIdx_ = consume(); +void Parser::parseConstant_AtFirst(ExpressionSyntax *&expr, SyntaxKind exprK) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(SyntaxFacts::isConstantToken(peek().kind()), return, + "assert failure: "); + + auto constExpr = makeNode(exprK); + expr = constExpr; + constExpr->constantTkIdx_ = consume(); } -template void Parser::parseConstant_AtFirst -(ExpressionSyntax*& expr, SyntaxKind exprK); +template void +Parser::parseConstant_AtFirst(ExpressionSyntax *&expr, + SyntaxKind exprK); /** * Parse a \a string-literal. */ -bool Parser::parseStringLiteral(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseStringLiteral(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - if (!SyntaxFacts::isStringLiteralToken(peek().kind())) { - diagReporter_.ExpectedTokenOfCategoryStringLiteral(); - return false; - } + if (!SyntaxFacts::isStringLiteralToken(peek().kind())) { + diagReporter_.ExpectedTokenOfCategoryStringLiteral(); + return false; + } - parseStringLiteral_AtFirst(expr); - return true; + parseStringLiteral_AtFirst(expr); + return true; } /** @@ -177,24 +170,21 @@ bool Parser::parseStringLiteral(ExpressionSyntax*& expr) * * \remark 6.4.5 and 6.5.1 */ -void Parser::parseStringLiteral_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(SyntaxFacts::isStringLiteralToken(peek().kind()), - return, - "assert failure: "); - - StringLiteralExpressionSyntax* strLit = nullptr; - StringLiteralExpressionSyntax** strLit_cur = &strLit; - - do { - *strLit_cur = makeNode(); - (*strLit_cur)->litTkIdx_ = consume(); - strLit_cur = &(*strLit_cur)->adjacent_; - } - while (SyntaxFacts::isStringLiteralToken(peek().kind())); +void Parser::parseStringLiteral_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(SyntaxFacts::isStringLiteralToken(peek().kind()), return, + "assert failure: "); - expr = strLit; + StringLiteralExpressionSyntax *strLit = nullptr; + StringLiteralExpressionSyntax **strLit_cur = &strLit; + + do { + *strLit_cur = makeNode(); + (*strLit_cur)->litTkIdx_ = consume(); + strLit_cur = &(*strLit_cur)->adjacent_; + } while (SyntaxFacts::isStringLiteralToken(peek().kind())); + + expr = strLit; } /** @@ -202,18 +192,16 @@ void Parser::parseStringLiteral_AtFirst(ExpressionSyntax*& expr) * * \remark 6.5.1 */ -bool Parser::parseParenthesizedExpression_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenParenToken, - return false, - "assert failure: `('"); - - auto parenExpr = makeNode(); - expr = parenExpr; - parenExpr->openParenTkIdx_ = consume(); - return parseExpression(parenExpr->expr_) - && matchOrSkipTo(CloseParenToken, &parenExpr->closeParenTkIdx_); +bool Parser::parseParenthesizedExpression_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenParenToken, return false, + "assert failure: `('"); + + auto parenExpr = makeNode(); + expr = parenExpr; + parenExpr->openParenTkIdx_ = consume(); + return parseExpression(parenExpr->expr_) && + matchOrSkipTo(CloseParenToken, &parenExpr->closeParenTkIdx_); } /** @@ -222,26 +210,26 @@ bool Parser::parseParenthesizedExpression_AtFirst(ExpressionSyntax*& expr) * * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs */ -bool Parser::parseExtGNU_StatementExpression_AtFirst(ExpressionSyntax *&expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenParenToken - && peek(2).kind() == OpenBraceToken, - return false, - "assert failure: `(' then `{'"); - - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_StatementExpressions()) - diagReporter_.ExpectedFeature("GNU statement expressions"); - - auto gnuExpr = makeNode(); - expr = gnuExpr; - gnuExpr->openParenTkIdx_ = consume(); - - StatementSyntax* statement = nullptr; - parseCompoundStatement_AtFirst(statement, StatementContext::None); - if (statement->asCompoundStatement()) - gnuExpr->stmt_ = statement->asCompoundStatement(); - return matchOrSkipTo(CloseParenToken, &gnuExpr->closeParenTkIdx_); +bool Parser::parseExtGNU_StatementExpression_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenParenToken && + peek(2).kind() == OpenBraceToken, + return false, "assert failure: `(' then `{'"); + + if (!tree_->parseOptions() + .extensions() + .isEnabled_ExtGNU_StatementExpressions()) + diagReporter_.ExpectedFeature("GNU statement expressions"); + + auto gnuExpr = makeNode(); + expr = gnuExpr; + gnuExpr->openParenTkIdx_ = consume(); + + StatementSyntax *statement = nullptr; + parseCompoundStatement_AtFirst(statement, StatementContext::None); + if (statement->asCompoundStatement()) + gnuExpr->stmt_ = statement->asCompoundStatement(); + return matchOrSkipTo(CloseParenToken, &gnuExpr->closeParenTkIdx_); } /** @@ -254,22 +242,20 @@ bool Parser::parseExtGNU_StatementExpression_AtFirst(ExpressionSyntax *&expr) * * \remark 6.5.1.1 */ -bool Parser::parseGenericSelectionExpression_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword__Generic, - return false, - "assert failure: `_Generic'"); - - auto selExpr = makeNode(); - expr = selExpr; - selExpr->genericKwTkIdx_ = consume(); - - return match(OpenParenToken, &selExpr->openParenTkIdx_) - && parseExpressionWithPrecedenceAssignment(selExpr->expr_) - && match(CommaToken, &selExpr->commaTkIdx_) - && parseGenericAssociationList(selExpr->assocs_) - && matchOrSkipTo(CloseParenToken, &selExpr->closeParenTkIdx_); +bool Parser::parseGenericSelectionExpression_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword__Generic, return false, + "assert failure: `_Generic'"); + + auto selExpr = makeNode(); + expr = selExpr; + selExpr->genericKwTkIdx_ = consume(); + + return match(OpenParenToken, &selExpr->openParenTkIdx_) && + parseExpressionWithPrecedenceAssignment(selExpr->expr_) && + match(CommaToken, &selExpr->commaTkIdx_) && + parseGenericAssociationList(selExpr->assocs_) && + matchOrSkipTo(CloseParenToken, &selExpr->closeParenTkIdx_); } /** @@ -283,13 +269,12 @@ bool Parser::parseGenericSelectionExpression_AtFirst(ExpressionSyntax*& expr) * * \remark 6.5.1.1 */ -bool Parser::parseGenericAssociationList(GenericAssociationListSyntax*& assocList) -{ - DEBUG_THIS_RULE(); +bool Parser::parseGenericAssociationList( + GenericAssociationListSyntax *&assocList) { + DEBUG_THIS_RULE(); - return parseCommaSeparatedItems( - assocList, - &Parser::parseGenericAssociation); + return parseCommaSeparatedItems( + assocList, &Parser::parseGenericAssociation); } /** @@ -303,38 +288,38 @@ bool Parser::parseGenericAssociationList(GenericAssociationListSyntax*& assocLis * * \remark 6.5.1.1 */ -bool Parser::parseGenericAssociation(GenericAssociationSyntax*& assoc, - GenericAssociationListSyntax*&) -{ - DEBUG_THIS_RULE(); - - switch (peek().kind()) { - case Keyword_default: { - assoc = makeNode(DefaultGenericAssociation); - auto defExpr = makeNode(); - defExpr->identTkIdx_ = consume(); - assoc->typeName_or_default_ = defExpr; - break; - } - - default: { - TypeNameSyntax* typeName = nullptr; - if (!parseTypeName(typeName)) - return false; - assoc = makeNode(TypedGenericAssociation); - assoc->typeName_or_default_ = typeName; - break; - } - } - - return match(ColonToken, &assoc->colonTkIdx_) - && parseExpressionWithPrecedenceAssignment(assoc->expr_); +bool Parser::parseGenericAssociation(GenericAssociationSyntax *&assoc, + GenericAssociationListSyntax *&) { + DEBUG_THIS_RULE(); + + switch (peek().kind()) { + case Keyword_default: { + assoc = makeNode(DefaultGenericAssociation); + auto defExpr = makeNode(); + defExpr->identTkIdx_ = consume(); + assoc->typeName_or_default_ = defExpr; + break; + } + + default: { + TypeNameSyntax *typeName = nullptr; + if (!parseTypeName(typeName)) + return false; + assoc = makeNode(TypedGenericAssociation); + assoc->typeName_or_default_ = typeName; + break; + } + } + + return match(ColonToken, &assoc->colonTkIdx_) && + parseExpressionWithPrecedenceAssignment(assoc->expr_); } /* Postfix */ /** - * Parse a \a postfix-expression, or any expression that is subsumed by such rule. + * Parse a \a postfix-expression, or any expression that is subsumed by such + rule. * * See note about naming convention in Parser::parseExpression. * @@ -369,175 +354,167 @@ bool Parser::parseGenericAssociation(GenericAssociationSyntax*& assoc, * * \remark 6.5.2 */ -bool Parser::parseExpressionWithPrecedencePostfix(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedencePostfix(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + + switch (peek().kind()) { + case OpenParenToken: + // postfix-expression -> primary-expression -> `(' expression `)' + // | `(' type-name `)' `{' initializer-list `}' + // | `(' `{' ... `}' `)' + switch (peek(2).kind()) { + // type-name ->* type-qualifier + case Keyword_const: + case Keyword_volatile: + case Keyword_restrict: + case Keyword__Atomic: + + // type-name ->* alignment-specifier + case Keyword__Alignas: + + // type-name ->* GNU-typeof-specifier + case Keyword_ExtGNU___typeof__: + + // type-name ->* type-specifier + case Keyword_void: + case Keyword_char: + case Keyword_short: + case Keyword_int: + case Keyword_long: + case Keyword_float: + case Keyword_double: + case Keyword__Bool: + case Keyword__Complex: + case Keyword_signed: + case Keyword_unsigned: + case Keyword_Ext_char16_t: + case Keyword_Ext_char32_t: + case Keyword_Ext_wchar_t: + case Keyword_struct: + case Keyword_union: + case Keyword_enum: + case Keyword_ExtGNU___complex__: + return parseCompoundLiteral_AtOpenParen(expr); + + // GNU + case OpenBraceToken: + return parseExtGNU_StatementExpression_AtFirst(expr); + + // type-name ->* typedef-name -> identifier + // expression ->* identifier + case IdentifierToken: { + Backtracker BT(this); + auto openParenTkIdx = consume(); + TypeNameSyntax *typeName = nullptr; + if (parseTypeName(typeName) && peek().kind() == CloseParenToken && + peek(2).kind() == OpenBraceToken) { + auto closeParenTkIdx = consume(); + return parseCompoundLiteral_AtOpenBrace(expr, openParenTkIdx, typeName, + closeParenTkIdx); + } + BT.backtrack(); + [[fallthrough]]; + } - switch (peek().kind()) { - case OpenParenToken: - // postfix-expression -> primary-expression -> `(' expression `)' - // | `(' type-name `)' `{' initializer-list `}' - // | `(' `{' ... `}' `)' - switch (peek(2).kind()) { - // type-name ->* type-qualifier - case Keyword_const: - case Keyword_volatile: - case Keyword_restrict: - case Keyword__Atomic: - - // type-name ->* alignment-specifier - case Keyword__Alignas: - - // type-name ->* GNU-typeof-specifier - case Keyword_ExtGNU___typeof__: - - // type-name ->* type-specifier - case Keyword_void: - case Keyword_char: - case Keyword_short: - case Keyword_int: - case Keyword_long: - case Keyword_float: - case Keyword_double: - case Keyword__Bool: - case Keyword__Complex: - case Keyword_signed: - case Keyword_unsigned: - case Keyword_Ext_char16_t: - case Keyword_Ext_char32_t: - case Keyword_Ext_wchar_t: - case Keyword_struct: - case Keyword_union: - case Keyword_enum: - case Keyword_ExtGNU___complex__: - return parseCompoundLiteral_AtOpenParen(expr); - - // GNU - case OpenBraceToken: - return parseExtGNU_StatementExpression_AtFirst(expr); - - // type-name ->* typedef-name -> identifier - // expression ->* identifier - case IdentifierToken: { - Backtracker BT(this); - auto openParenTkIdx = consume(); - TypeNameSyntax* typeName = nullptr; - if (parseTypeName(typeName) - && peek().kind() == CloseParenToken - && peek(2).kind() == OpenBraceToken) { - auto closeParenTkIdx = consume(); - return parseCompoundLiteral_AtOpenBrace(expr, - openParenTkIdx, - typeName, - closeParenTkIdx); - } - BT.backtrack(); - [[fallthrough]]; - } + default: + return parseParenthesizedExpression_AtFirst(expr) && + parsePostfixExpression_AtFollowOfPrimary(expr); + ; + } - default: - return parseParenthesizedExpression_AtFirst(expr) - && parsePostfixExpression_AtFollowOfPrimary(expr);; - } - - case IdentifierToken: - parseIdentifierName_AtFirst(expr); - break; - - case IntegerConstantToken: - parseConstant_AtFirst( - expr, - IntegerConstantExpression); - break; - - case FloatingConstantToken: - parseConstant_AtFirst( - expr, - FloatingConstantExpression); - break; - - case ImaginaryIntegerConstantToken: - parseConstant_AtFirst( - expr, - ImaginaryIntegerConstantExpression); - break; - - case ImaginaryFloatingConstantToken: - parseConstant_AtFirst( - expr, - ImaginaryFloatingConstantExpression); - break; - - case CharacterConstantToken: - case CharacterConstant_L_Token: - case CharacterConstant_u_Token: - case CharacterConstant_U_Token: - parseConstant_AtFirst( - expr, - CharacterConstantExpression); - break; - - case Keyword_Ext_true: - case Keyword_Ext_false: - parseConstant_AtFirst( - expr, - BooleanConstantExpression); - break; - - case Keyword_Ext_NULL: - case Keyword_Ext_nullptr: - parseConstant_AtFirst( - expr, - NULL_ConstantExpression); - break; - - case StringLiteralToken: - case StringLiteral_L_Token: - case StringLiteral_u8_Token: - case StringLiteral_u_Token: - case StringLiteral_U_Token: - case StringLiteral_R_Token: - case StringLiteral_LR_Token: - case StringLiteral_u8R_Token: - case StringLiteral_uR_Token: - case StringLiteral_UR_Token: - parseStringLiteral_AtFirst(expr); - break; - - case Keyword__Generic: - if (!parseGenericSelectionExpression_AtFirst(expr)) - return false; - break; + case IdentifierToken: + parseIdentifierName_AtFirst(expr); + break; + + case IntegerConstantToken: + parseConstant_AtFirst(expr, + IntegerConstantExpression); + break; + + case FloatingConstantToken: + parseConstant_AtFirst(expr, + FloatingConstantExpression); + break; + + case ImaginaryIntegerConstantToken: + parseConstant_AtFirst( + expr, ImaginaryIntegerConstantExpression); + break; + + case ImaginaryFloatingConstantToken: + parseConstant_AtFirst( + expr, ImaginaryFloatingConstantExpression); + break; + + case CharacterConstantToken: + case CharacterConstant_L_Token: + case CharacterConstant_u_Token: + case CharacterConstant_U_Token: + parseConstant_AtFirst( + expr, CharacterConstantExpression); + break; + + case Keyword_Ext_true: + case Keyword_Ext_false: + parseConstant_AtFirst(expr, + BooleanConstantExpression); + break; + + case Keyword_Ext_NULL: + case Keyword_Ext_nullptr: + parseConstant_AtFirst(expr, + NULL_ConstantExpression); + break; + + case StringLiteralToken: + case StringLiteral_L_Token: + case StringLiteral_u8_Token: + case StringLiteral_u_Token: + case StringLiteral_U_Token: + case StringLiteral_R_Token: + case StringLiteral_LR_Token: + case StringLiteral_u8R_Token: + case StringLiteral_uR_Token: + case StringLiteral_UR_Token: + parseStringLiteral_AtFirst(expr); + break; - case Keyword_ExtGNU___builtin_va_arg: - case Keyword_MacroStd_va_arg: - return parseVAArgumentExpression_AtFirst(expr); + case Keyword__Generic: + if (!parseGenericSelectionExpression_AtFirst(expr)) + return false; + break; - case Keyword_ExtGNU___builtin_offsetof: - case Keyword_MacroStd_offsetof: - return parseOffsetOfExpression_AtFirst(expr); + case Keyword_ExtGNU___builtin_va_arg: + case Keyword_MacroStd_va_arg: + return parseVAArgumentExpression_AtFirst(expr); - case Keyword_ExtGNU___builtin_choose_expr: - return parseExtGNU_ChooseExpression_AtFirst(expr); + case Keyword_ExtGNU___builtin_offsetof: + case Keyword_MacroStd_offsetof: + return parseOffsetOfExpression_AtFirst(expr); - case Keyword___func__: - case Keyword_ExtGNU___FUNCTION__: - case Keyword_ExtGNU___PRETTY_FUNCTION__: - parsePredefinedName_AtFirst(expr); - break; + case Keyword_ExtGNU___builtin_choose_expr: + return parseExtGNU_ChooseExpression_AtFirst(expr); - case Keyword_ExtGNU___real__: - return parseExtGNU_ComplexValuedExpression_AtFirst(expr, ExtGNU_RealExpression); + case Keyword___func__: + case Keyword_ExtGNU___FUNCTION__: + case Keyword_ExtGNU___PRETTY_FUNCTION__: + parsePredefinedName_AtFirst(expr); + break; - case Keyword_ExtGNU___imag__: - return parseExtGNU_ComplexValuedExpression_AtFirst(expr, ExtGNU_ImagExpression); + case Keyword_ExtGNU___real__: + return parseExtGNU_ComplexValuedExpression_AtFirst(expr, + ExtGNU_RealExpression); - default: - diagReporter_.ExpectedFIRSTofExpression(); - return false; - } + case Keyword_ExtGNU___imag__: + return parseExtGNU_ComplexValuedExpression_AtFirst(expr, + ExtGNU_ImagExpression); + + default: + diagReporter_.ExpectedFIRSTofExpression(); + return false; + } - return parsePostfixExpression_AtFollowOfPrimary(expr); + return parsePostfixExpression_AtFollowOfPrimary(expr); } /** @@ -558,97 +535,94 @@ bool Parser::parseExpressionWithPrecedencePostfix(ExpressionSyntax*& expr) * \remark 6.5.2 */ -bool Parser::parsePostfixExpression_AtFollowOfPrimary(ExpressionSyntax*& expr) -{ - while (true) { - SyntaxKind exprK = UnknownSyntax; - switch (peek().kind()) { - /* 6.5.2.1 */ - case OpenBracketToken: { - if (!parsePostfixExpression_AtFollowOfPrimary( - expr, - ElementAccessExpression, - [this] (ArraySubscriptExpressionSyntax*& arrExpr) { - arrExpr->openBracketTkIdx_ = consume(); - return parseExpression(arrExpr->arg_) - && matchOrSkipTo(CloseBracketToken, &arrExpr->closeBracketTkIdx_); - })) { - return false; - } - break; - } - - /* 6.5.2.2 */ - case OpenParenToken: { - if (!parsePostfixExpression_AtFollowOfPrimary( - expr, - CallExpression, - [this] (CallExpressionSyntax*& callExpr) { - callExpr->openParenTkIdx_ = consume(); - if (peek().kind() == CloseParenToken) { - callExpr->closeParenTkIdx_ = consume(); - return true; - } - return parseCallArguments(callExpr->args_) - && matchOrSkipTo(CloseParenToken, &callExpr->closeParenTkIdx_); - })) { - return false; - } - break; - } - - /* 6.5.2.3 */ - case DotToken: - exprK = DirectMemberAccessExpression; - [[fallthrough]]; - - case ArrowToken: { - if (exprK == UnknownSyntax) - exprK = IndirectMemberAccessExpression; - if (!parsePostfixExpression_AtFollowOfPrimary( - expr, - exprK, - [this] (MemberAccessExpressionSyntax*& membAccess) { - membAccess->oprtrTkIdx_ = consume(); - if (peek().kind() == IdentifierToken) { - ExpressionSyntax* identExpr = nullptr; - parseIdentifierName_AtFirst(identExpr); - membAccess->identExpr_ = identExpr->asIdentifierName(); - return true; - } - - diagReporter_.ExpectedFieldName(); - return false; - })) { - return false; +bool Parser::parsePostfixExpression_AtFollowOfPrimary(ExpressionSyntax *&expr) { + while (true) { + SyntaxKind exprK = UnknownSyntax; + switch (peek().kind()) { + /* 6.5.2.1 */ + case OpenBracketToken: { + if (!parsePostfixExpression_AtFollowOfPrimary< + ArraySubscriptExpressionSyntax>( + expr, ElementAccessExpression, + [this](ArraySubscriptExpressionSyntax *&arrExpr) { + arrExpr->openBracketTkIdx_ = consume(); + return parseExpression(arrExpr->arg_) && + matchOrSkipTo(CloseBracketToken, + &arrExpr->closeBracketTkIdx_); + })) { + return false; + } + break; + } + + /* 6.5.2.2 */ + case OpenParenToken: { + if (!parsePostfixExpression_AtFollowOfPrimary( + expr, CallExpression, [this](CallExpressionSyntax *&callExpr) { + callExpr->openParenTkIdx_ = consume(); + if (peek().kind() == CloseParenToken) { + callExpr->closeParenTkIdx_ = consume(); + return true; } - break; - } - - /* 6.5.2.4 */ - case PlusPlusToken: - exprK = PostIncrementExpression; - [[fallthrough]]; - - case MinusMinusToken: { - if (exprK == UnknownSyntax) - exprK = PostDecrementExpression; - if (!parsePostfixExpression_AtFollowOfPrimary( - expr, - exprK, - [this] (PostfixUnaryExpressionSyntax*& incDecExpr) { - incDecExpr->oprtrTkIdx_ = consume(); - return true; - })) { - return false; + return parseCallArguments(callExpr->args_) && + matchOrSkipTo(CloseParenToken, + &callExpr->closeParenTkIdx_); + })) { + return false; + } + break; + } + + /* 6.5.2.3 */ + case DotToken: + exprK = DirectMemberAccessExpression; + [[fallthrough]]; + + case ArrowToken: { + if (exprK == UnknownSyntax) + exprK = IndirectMemberAccessExpression; + if (!parsePostfixExpression_AtFollowOfPrimary< + MemberAccessExpressionSyntax>( + expr, exprK, [this](MemberAccessExpressionSyntax *&membAccess) { + membAccess->oprtrTkIdx_ = consume(); + if (peek().kind() == IdentifierToken) { + ExpressionSyntax *identExpr = nullptr; + parseIdentifierName_AtFirst(identExpr); + membAccess->identExpr_ = identExpr->asIdentifierName(); + return true; } - break; - } - default: + diagReporter_.ExpectedFieldName(); + return false; + })) { + return false; + } + break; + } + + /* 6.5.2.4 */ + case PlusPlusToken: + exprK = PostIncrementExpression; + [[fallthrough]]; + + case MinusMinusToken: { + if (exprK == UnknownSyntax) + exprK = PostDecrementExpression; + if (!parsePostfixExpression_AtFollowOfPrimary< + PostfixUnaryExpressionSyntax>( + expr, exprK, [this](PostfixUnaryExpressionSyntax *&incDecExpr) { + incDecExpr->oprtrTkIdx_ = consume(); return true; - } + })) { + return false; + } + break; } + + default: + return true; + } + } } /** @@ -667,24 +641,20 @@ bool Parser::parsePostfixExpression_AtFollowOfPrimary(ExpressionSyntax*& expr) \endverbatim */ template -bool Parser::parsePostfixExpression_AtFollowOfPrimary(ExpressionSyntax*& expr, - SyntaxKind exprK, - std::function parsePostfix) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenBracketToken - || peek().kind() == OpenParenToken - || peek().kind() == DotToken - || peek().kind() == ArrowToken - || peek().kind() == PlusPlusToken - || peek().kind() == MinusMinusToken, - return false, - "assert failure: `[', `(', `.', `->', '++', or `--'"); - - auto postfixExpr = makeNode(exprK); - postfixExpr->expr_ = expr; - expr = postfixExpr; - return parsePostfix(postfixExpr); +bool Parser::parsePostfixExpression_AtFollowOfPrimary( + ExpressionSyntax *&expr, SyntaxKind exprK, + std::function parsePostfix) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG( + peek().kind() == OpenBracketToken || peek().kind() == OpenParenToken || + peek().kind() == DotToken || peek().kind() == ArrowToken || + peek().kind() == PlusPlusToken || peek().kind() == MinusMinusToken, + return false, "assert failure: `[', `(', `.', `->', '++', or `--'"); + + auto postfixExpr = makeNode(exprK); + postfixExpr->expr_ = expr; + expr = postfixExpr; + return parsePostfix(postfixExpr); } /** @@ -698,18 +668,16 @@ bool Parser::parsePostfixExpression_AtFollowOfPrimary(ExpressionSyntax*& expr, * * \remark 6.5.2 */ -bool Parser::parseCallArguments(ExpressionListSyntax*& exprList) -{ - DEBUG_THIS_RULE(); +bool Parser::parseCallArguments(ExpressionListSyntax *&exprList) { + DEBUG_THIS_RULE(); - return parseCommaSeparatedItems( - exprList, - &Parser::parseCallArgument); + return parseCommaSeparatedItems(exprList, + &Parser::parseCallArgument); } -bool Parser::parseCallArgument(ExpressionSyntax*&expr, ExpressionListSyntax*&) -{ - return parseExpressionWithPrecedenceAssignment(expr); +bool Parser::parseCallArgument(ExpressionSyntax *&expr, + ExpressionListSyntax *&) { + return parseExpressionWithPrecedenceAssignment(expr); } /** @@ -717,92 +685,86 @@ bool Parser::parseCallArgument(ExpressionSyntax*&expr, ExpressionListSyntax*&) * * \remark 7.16.1.1 */ -bool Parser::parseVAArgumentExpression_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___builtin_va_arg - || peek().kind() == Keyword_MacroStd_va_arg, - return false, - "assert failure: `__builtin_va_arg'"); - - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_InternalBuiltins()) - diagReporter_.ExpectedFeature("GNU internal builtins"); - - auto vaArgExpr = makeNode(); - expr = vaArgExpr; - vaArgExpr->kwTkIdx_ = consume(); - return match(OpenParenToken, &vaArgExpr->openParenTkIdx_) - && parseExpressionWithPrecedenceAssignment(vaArgExpr->expr_) - && match(CommaToken, &vaArgExpr->commaTkIdx_) - && parseTypeName(vaArgExpr->typeName_) - && match(CloseParenToken, &vaArgExpr->closeParenTkIdx_); +bool Parser::parseVAArgumentExpression_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___builtin_va_arg || + peek().kind() == Keyword_MacroStd_va_arg, + return false, "assert failure: `__builtin_va_arg'"); + + if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_InternalBuiltins()) + diagReporter_.ExpectedFeature("GNU internal builtins"); + + auto vaArgExpr = makeNode(); + expr = vaArgExpr; + vaArgExpr->kwTkIdx_ = consume(); + return match(OpenParenToken, &vaArgExpr->openParenTkIdx_) && + parseExpressionWithPrecedenceAssignment(vaArgExpr->expr_) && + match(CommaToken, &vaArgExpr->commaTkIdx_) && + parseTypeName(vaArgExpr->typeName_) && + match(CloseParenToken, &vaArgExpr->closeParenTkIdx_); } /** * Parse GNU's \c __builtin_offsetof and Standard \c offsetof. */ -bool Parser::parseOffsetOfExpression_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___builtin_offsetof - || peek().kind() == Keyword_MacroStd_offsetof, - return false, - "assert failure: `__builtin_offsetof'"); - - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_InternalBuiltins()) - diagReporter_.ExpectedFeature("GNU internal builtins"); - - auto offsetOfExpr = makeNode(); - expr = offsetOfExpr; - offsetOfExpr->kwTkIdx_ = consume(); - return match(OpenParenToken, &offsetOfExpr->openParenTkIdx_) - && parseTypeName(offsetOfExpr->typeName_) - && match(CommaToken, &offsetOfExpr->commaTkIdx_) - && parseOffsetOfDesignator(offsetOfExpr->offsetOfDesignator_) - && match(CloseParenToken, &offsetOfExpr->closeParenTkIdx_); +bool Parser::parseOffsetOfExpression_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___builtin_offsetof || + peek().kind() == Keyword_MacroStd_offsetof, + return false, "assert failure: `__builtin_offsetof'"); + + if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_InternalBuiltins()) + diagReporter_.ExpectedFeature("GNU internal builtins"); + + auto offsetOfExpr = makeNode(); + expr = offsetOfExpr; + offsetOfExpr->kwTkIdx_ = consume(); + return match(OpenParenToken, &offsetOfExpr->openParenTkIdx_) && + parseTypeName(offsetOfExpr->typeName_) && + match(CommaToken, &offsetOfExpr->commaTkIdx_) && + parseOffsetOfDesignator(offsetOfExpr->offsetOfDesignator_) && + match(CloseParenToken, &offsetOfExpr->closeParenTkIdx_); } /** * Parse the GNU built-in function \c __builtin_choose_expr. * */ -bool Parser::parseExtGNU_ChooseExpression_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___builtin_choose_expr, - return false, - "assert failure: `__builtin_choose_expr'"); - - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_InternalBuiltins()) - diagReporter_.ExpectedFeature("GNU internal builtins"); - - auto chooseExpr = makeNode(); - expr = chooseExpr; - chooseExpr->kwTkIdx_ = consume(); - return match(OpenParenToken, &chooseExpr->openParenTkIdx_) - && parseConstant(chooseExpr->constExpr_, IntegerConstantExpression) - && match(CommaToken, &chooseExpr->commaTkIdx1_) - && parseExpressionWithPrecedenceAssignment(chooseExpr->expr1_) - && match(CommaToken, &chooseExpr->commaTkIdx2_) - && parseExpressionWithPrecedenceAssignment(chooseExpr->expr2_) - && match(CloseParenToken, &chooseExpr->closeParenTkIdx_); +bool Parser::parseExtGNU_ChooseExpression_AtFirst(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___builtin_choose_expr, + return false, "assert failure: `__builtin_choose_expr'"); + + if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_InternalBuiltins()) + diagReporter_.ExpectedFeature("GNU internal builtins"); + + auto chooseExpr = makeNode(); + expr = chooseExpr; + chooseExpr->kwTkIdx_ = consume(); + return match(OpenParenToken, &chooseExpr->openParenTkIdx_) && + parseConstant(chooseExpr->constExpr_, + IntegerConstantExpression) && + match(CommaToken, &chooseExpr->commaTkIdx1_) && + parseExpressionWithPrecedenceAssignment(chooseExpr->expr1_) && + match(CommaToken, &chooseExpr->commaTkIdx2_) && + parseExpressionWithPrecedenceAssignment(chooseExpr->expr2_) && + match(CloseParenToken, &chooseExpr->closeParenTkIdx_); } /** * Parse the GNU __real__ and __imag__ expressions. */ -bool Parser::parseExtGNU_ComplexValuedExpression_AtFirst(ExpressionSyntax*& expr, SyntaxKind exprK) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___real__ - || peek().kind() == Keyword_ExtGNU___imag__, - return false, - "assert failure: `__real__' or `__imag__'"); - - auto complexValExpr = makeNode(exprK); - expr = complexValExpr; - complexValExpr->oprtrTkIdx_ = consume(); - return parseExpressionWithPrecedenceAssignment(complexValExpr->expr_); +bool Parser::parseExtGNU_ComplexValuedExpression_AtFirst( + ExpressionSyntax *&expr, SyntaxKind exprK) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___real__ || + peek().kind() == Keyword_ExtGNU___imag__, + return false, "assert failure: `__real__' or `__imag__'"); + + auto complexValExpr = makeNode(exprK); + expr = complexValExpr; + complexValExpr->oprtrTkIdx_ = consume(); + return parseExpressionWithPrecedenceAssignment(complexValExpr->expr_); } /** @@ -816,28 +778,27 @@ bool Parser::parseExtGNU_ComplexValuedExpression_AtFirst(ExpressionSyntax*& expr ( type-name ) compound-literal-at-open-brace \endverbatim */ -bool Parser::parseCompoundLiteral_AtOpenParen(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenParenToken, - return false, - "assert failure: `('"); - - auto openParenTkIdx = consume(); - TypeNameSyntax* typeName = nullptr; - if (!parseTypeName(typeName)) - return false; - - auto closeParenTkIdx = LexedTokens::invalidIndex(); - if (!match(CloseParenToken, &closeParenTkIdx)) - return false; - - if (peek().kind() != OpenBraceToken) { - diagReporter_.ExpectedToken(OpenBraceToken); - return false; - } - - return parseCompoundLiteral_AtOpenBrace(expr, openParenTkIdx, typeName, closeParenTkIdx); +bool Parser::parseCompoundLiteral_AtOpenParen(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenParenToken, return false, + "assert failure: `('"); + + auto openParenTkIdx = consume(); + TypeNameSyntax *typeName = nullptr; + if (!parseTypeName(typeName)) + return false; + + auto closeParenTkIdx = LexedTokens::invalidIndex(); + if (!match(CloseParenToken, &closeParenTkIdx)) + return false; + + if (peek().kind() != OpenBraceToken) { + diagReporter_.ExpectedToken(OpenBraceToken); + return false; + } + + return parseCompoundLiteral_AtOpenBrace(expr, openParenTkIdx, typeName, + closeParenTkIdx); } /** @@ -853,27 +814,23 @@ bool Parser::parseCompoundLiteral_AtOpenParen(ExpressionSyntax*& expr) \endverbatim */ bool Parser::parseCompoundLiteral_AtOpenBrace( - ExpressionSyntax*& expr, - LexedTokens::IndexType openParenTkIdx, - TypeNameSyntax* typeName, - LexedTokens::IndexType closeParenTkIdx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenBraceToken, - return false, - "assert failure: `{'"); - - if (tree_->dialect().std() < LanguageDialect::Std::C99 - && !tree_->parseOptions().extensions().isEnabled_ExtGNU_CompoundLiterals()) - diagReporter_.ExpectedFeature("GNU/C99 compound literals"); - - auto compLit = makeNode(); - expr = compLit; - compLit->openParenTkIdx_ = openParenTkIdx; - compLit->typeName_ = typeName; - compLit->closeParenTkIdx_ = closeParenTkIdx; - return parseInitializer(compLit->init_) - && parsePostfixExpression_AtFollowOfPrimary(expr); + ExpressionSyntax *&expr, LexedTokens::IndexType openParenTkIdx, + TypeNameSyntax *typeName, LexedTokens::IndexType closeParenTkIdx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenBraceToken, return false, + "assert failure: `{'"); + + if (tree_->dialect().std() < LanguageDialect::Std::C99 && + !tree_->parseOptions().extensions().isEnabled_ExtGNU_CompoundLiterals()) + diagReporter_.ExpectedFeature("GNU/C99 compound literals"); + + auto compLit = makeNode(); + expr = compLit; + compLit->openParenTkIdx_ = openParenTkIdx; + compLit->typeName_ = typeName; + compLit->closeParenTkIdx_ = closeParenTkIdx; + return parseInitializer(compLit->init_) && + parsePostfixExpression_AtFollowOfPrimary(expr); } /* Unary */ @@ -908,72 +865,58 @@ bool Parser::parseCompoundLiteral_AtOpenBrace( * * \remark 6.5.3 */ -bool Parser::parseExpressionWithPrecedenceUnary(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - - switch (peek().kind()) { - /* 6.5.3.1 */ - case PlusPlusToken: - return parsePrefixUnaryExpression_AtFirst( - expr, - PreIncrementExpression, - &Parser::parseExpressionWithPrecedenceUnary); - - case MinusMinusToken: - return parsePrefixUnaryExpression_AtFirst( - expr, - PreDecrementExpression, - &Parser::parseExpressionWithPrecedenceUnary); - - /* 6.5.3.2 */ - case AmpersandToken: - return parsePrefixUnaryExpression_AtFirst( - expr, - AddressOfExpression, - &Parser::parseExpressionWithPrecedenceCast); - - case AsteriskToken: - return parsePrefixUnaryExpression_AtFirst( - expr, - PointerIndirectionExpression, - &Parser::parseExpressionWithPrecedenceCast); - - /* 6.5.3.3 */ - case PlusToken: - return parsePrefixUnaryExpression_AtFirst( - expr, - UnaryPlusExpression, - &Parser::parseExpressionWithPrecedenceCast); - - case MinusToken: - return parsePrefixUnaryExpression_AtFirst( - expr, - UnaryMinusExpression, - &Parser::parseExpressionWithPrecedenceCast); - - case TildeToken: - return parsePrefixUnaryExpression_AtFirst( - expr, - BitwiseNotExpression, - &Parser::parseExpressionWithPrecedenceCast); - - case ExclamationToken: - return parsePrefixUnaryExpression_AtFirst( - expr, - LogicalNotExpression, - &Parser::parseExpressionWithPrecedenceCast); - - /* 6.5.3.4 */ - case Keyword_sizeof: - return parseTypeTraitExpression_AtFirst(expr, SizeofExpression); - - case Keyword__Alignof: - return parseTypeTraitExpression_AtFirst(expr, AlignofExpression); - - default: - return parseExpressionWithPrecedencePostfix(expr); - } +bool Parser::parseExpressionWithPrecedenceUnary(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + + switch (peek().kind()) { + /* 6.5.3.1 */ + case PlusPlusToken: + return parsePrefixUnaryExpression_AtFirst( + expr, PreIncrementExpression, + &Parser::parseExpressionWithPrecedenceUnary); + + case MinusMinusToken: + return parsePrefixUnaryExpression_AtFirst( + expr, PreDecrementExpression, + &Parser::parseExpressionWithPrecedenceUnary); + + /* 6.5.3.2 */ + case AmpersandToken: + return parsePrefixUnaryExpression_AtFirst( + expr, AddressOfExpression, &Parser::parseExpressionWithPrecedenceCast); + + case AsteriskToken: + return parsePrefixUnaryExpression_AtFirst( + expr, PointerIndirectionExpression, + &Parser::parseExpressionWithPrecedenceCast); + + /* 6.5.3.3 */ + case PlusToken: + return parsePrefixUnaryExpression_AtFirst( + expr, UnaryPlusExpression, &Parser::parseExpressionWithPrecedenceCast); + + case MinusToken: + return parsePrefixUnaryExpression_AtFirst( + expr, UnaryMinusExpression, &Parser::parseExpressionWithPrecedenceCast); + + case TildeToken: + return parsePrefixUnaryExpression_AtFirst( + expr, BitwiseNotExpression, &Parser::parseExpressionWithPrecedenceCast); + + case ExclamationToken: + return parsePrefixUnaryExpression_AtFirst( + expr, LogicalNotExpression, &Parser::parseExpressionWithPrecedenceCast); + + /* 6.5.3.4 */ + case Keyword_sizeof: + return parseTypeTraitExpression_AtFirst(expr, SizeofExpression); + + case Keyword__Alignof: + return parseTypeTraitExpression_AtFirst(expr, AlignofExpression); + + default: + return parseExpressionWithPrecedencePostfix(expr); + } } /** @@ -994,26 +937,20 @@ bool Parser::parseExpressionWithPrecedenceUnary(ExpressionSyntax*& expr) * \remark 6.5.3 */ bool Parser::parsePrefixUnaryExpression_AtFirst( - ExpressionSyntax*& expr, - SyntaxKind exprK, - bool (Parser::*parseOperand)(ExpressionSyntax*&)) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == PlusPlusToken - || peek().kind() == MinusMinusToken - || peek().kind() == AmpersandToken - || peek().kind() == AsteriskToken - || peek().kind() == PlusToken - || peek().kind() == MinusToken - || peek().kind() == TildeToken - || peek().kind() == ExclamationToken, - return false, - "expected `[', `(', `.', `->', '++', or `--'"); - - auto unaryExpr = makeNode(exprK); - expr = unaryExpr; - unaryExpr->oprtrTkIdx_ = consume(); - return ((this)->*parseOperand)(unaryExpr->expr_); + ExpressionSyntax *&expr, SyntaxKind exprK, + bool (Parser::*parseOperand)(ExpressionSyntax *&)) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG( + peek().kind() == PlusPlusToken || peek().kind() == MinusMinusToken || + peek().kind() == AmpersandToken || peek().kind() == AsteriskToken || + peek().kind() == PlusToken || peek().kind() == MinusToken || + peek().kind() == TildeToken || peek().kind() == ExclamationToken, + return false, "expected `[', `(', `.', `->', '++', or `--'"); + + auto unaryExpr = makeNode(exprK); + expr = unaryExpr; + unaryExpr->oprtrTkIdx_ = consume(); + return ((this)->*parseOperand)(unaryExpr->expr_); } /** @@ -1031,19 +968,18 @@ bool Parser::parsePrefixUnaryExpression_AtFirst( * * \remark 6.5.3 */ -bool Parser::parseTypeTraitExpression_AtFirst(ExpressionSyntax*& expr, SyntaxKind exprK) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_sizeof - || peek().kind() == Keyword__Alignof, - return false, - "assert failure: `sizeof' or `_Alignof'"); - - auto traitExpr = makeNode(exprK); - expr = traitExpr; - traitExpr->oprtrTkIdx_ = consume(); - - return parseParenthesizedTypeNameOrExpression(traitExpr->tyRef_); +bool Parser::parseTypeTraitExpression_AtFirst(ExpressionSyntax *&expr, + SyntaxKind exprK) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_sizeof || + peek().kind() == Keyword__Alignof, + return false, "assert failure: `sizeof' or `_Alignof'"); + + auto traitExpr = makeNode(exprK); + expr = traitExpr; + traitExpr->oprtrTkIdx_ = consume(); + + return parseParenthesizedTypeNameOrExpression(traitExpr->tyRef_); } /* Cast */ @@ -1061,271 +997,262 @@ bool Parser::parseTypeTraitExpression_AtFirst(ExpressionSyntax*& expr, SyntaxKin * * \remark 6.5.4 */ -bool Parser::parseExpressionWithPrecedenceCast(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - - switch (peek().kind()) { - case OpenParenToken: { - // cast-expression -> unary-expression ->* `(' expression `)' - // | `(' type-name `)' cast-expression - switch (peek(2).kind()) { - // type-name ->* type-qualifier - case Keyword_const: - case Keyword_volatile: - case Keyword_restrict: - case Keyword__Atomic: - - // type-name ->* alignment-specifier - case Keyword__Alignas: - - // type-name ->* GNU-typeof-specifier -> - case Keyword_ExtGNU___typeof__: - - // // type-name ->* type-specifier - case Keyword_void: - case Keyword_char: - case Keyword_short: - case Keyword_int: - case Keyword_long: - case Keyword_float: - case Keyword_double: - case Keyword__Bool: - case Keyword__Complex: - case Keyword_signed: - case Keyword_unsigned: - case Keyword_Ext_char16_t: - case Keyword_Ext_char32_t: - case Keyword_Ext_wchar_t: - case Keyword_struct: - case Keyword_union: - case Keyword_enum: - case Keyword_ExtGNU___complex__: - return parseCompoundLiteralOrCastExpression_AtFirst(expr); - - // type-name ->* typedef-name -> identifier - // expression ->* identifier - case IdentifierToken: { - Backtracker BT(this); - if (parseCompoundLiteralOrCastExpression_AtFirst(expr)) { - if (expr->kind() == CastExpression) - maybeAmbiguateCastExpression(expr); - return true; - } - BT.backtrack(); - [[fallthrough]]; - } - - default: - return parseExpressionWithPrecedenceUnary(expr); - } - } - - case Keyword_ExtGNU___extension__: { - auto extKwTkIdx = consume(); - if (!parseExpressionWithPrecedenceCast(expr)) - return false; - PSY_ASSERT_W_MSG(expr, return false, "invalid expression"); - expr->extKwTkIdx_ = extKwTkIdx; - return true; - } - - default: - return parseExpressionWithPrecedenceUnary(expr); +bool Parser::parseExpressionWithPrecedenceCast(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + + switch (peek().kind()) { + case OpenParenToken: { + // cast-expression -> unary-expression ->* `(' expression `)' + // | `(' type-name `)' cast-expression + switch (peek(2).kind()) { + // type-name ->* type-qualifier + case Keyword_const: + case Keyword_volatile: + case Keyword_restrict: + case Keyword__Atomic: + + // type-name ->* alignment-specifier + case Keyword__Alignas: + + // type-name ->* GNU-typeof-specifier -> + case Keyword_ExtGNU___typeof__: + + // // type-name ->* type-specifier + case Keyword_void: + case Keyword_char: + case Keyword_short: + case Keyword_int: + case Keyword_long: + case Keyword_float: + case Keyword_double: + case Keyword__Bool: + case Keyword__Complex: + case Keyword_signed: + case Keyword_unsigned: + case Keyword_Ext_char16_t: + case Keyword_Ext_char32_t: + case Keyword_Ext_wchar_t: + case Keyword_struct: + case Keyword_union: + case Keyword_enum: + case Keyword_ExtGNU___complex__: + return parseCompoundLiteralOrCastExpression_AtFirst(expr); + + // type-name ->* typedef-name -> identifier + // expression ->* identifier + case IdentifierToken: { + Backtracker BT(this); + if (parseCompoundLiteralOrCastExpression_AtFirst(expr)) { + if (expr->kind() == CastExpression) + maybeAmbiguateCastExpression(expr); + return true; + } + BT.backtrack(); + [[fallthrough]]; } -} -bool Parser::parseCompoundLiteralOrCastExpression_AtFirst(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenParenToken, - return false, - "assert failure: `('"); - - auto openParenTkIdx = consume(); - TypeNameSyntax* typeName = nullptr; - if (!parseTypeName(typeName)) - return false; - - LexedTokens::IndexType closeParenTkIdx; - if (!match(CloseParenToken, &closeParenTkIdx)) - return false; + default: + return parseExpressionWithPrecedenceUnary(expr); + } + } - if (peek().kind() == OpenBraceToken) - return parseCompoundLiteral_AtOpenBrace(expr, - openParenTkIdx, - typeName, - closeParenTkIdx); + case Keyword_ExtGNU___extension__: { + auto extKwTkIdx = consume(); + if (!parseExpressionWithPrecedenceCast(expr)) + return false; + PSY_ASSERT_W_MSG(expr, return false, "invalid expression"); + expr->extKwTkIdx_ = extKwTkIdx; + return true; + } - auto castExpr = makeNode(); - expr = castExpr; - castExpr->openParenTkIdx_ = openParenTkIdx; - castExpr->typeName_ = typeName; - castExpr->closeParenTkIdx_ = closeParenTkIdx; - return parseExpressionWithPrecedenceCast(castExpr->expr_); + default: + return parseExpressionWithPrecedenceUnary(expr); + } } -void Parser::maybeAmbiguateCastExpression(ExpressionSyntax*& expr) -{ - PSY_ASSERT_W_MSG(expr->kind() == CastExpression, - return, ""); - - auto castExpr = expr->asCastExpression(); - auto prefixExpr = castExpr->expr_->asPrefixUnaryExpression(); - if (!(prefixExpr->asPrefixUnaryExpression() - && (prefixExpr->kind() == AddressOfExpression - || prefixExpr->kind() == PointerIndirectionExpression - || prefixExpr->kind() == UnaryPlusExpression - || prefixExpr->kind() == UnaryMinusExpression))) - return; - - TypeNameSyntax* typeName = castExpr->typeName_; - if (!(typeName->specs_ - && typeName->specs_->value->kind() == TypedefName - && !typeName->specs_->next - && typeName->decltor_ - && typeName->decltor_->kind() == AbstractDeclarator)) - return; - - SyntaxKind binExprK; - switch (prefixExpr->kind()) { - case AddressOfExpression: - binExprK = BitwiseANDExpression; - break; - - case PointerIndirectionExpression: - binExprK = MultiplyExpression; - break; - - case UnaryPlusExpression: - binExprK = AddExpression; - break; - - case UnaryMinusExpression: - binExprK = SubstractExpression; - break; - - default: - PSY_ASSERT_W_MSG(false, return, ""); - } +bool Parser::parseCompoundLiteralOrCastExpression_AtFirst( + ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenParenToken, return false, + "assert failure: `('"); + + auto openParenTkIdx = consume(); + TypeNameSyntax *typeName = nullptr; + if (!parseTypeName(typeName)) + return false; + + LexedTokens::IndexType closeParenTkIdx; + if (!match(CloseParenToken, &closeParenTkIdx)) + return false; + + if (peek().kind() == OpenBraceToken) + return parseCompoundLiteral_AtOpenBrace(expr, openParenTkIdx, typeName, + closeParenTkIdx); + + auto castExpr = makeNode(); + expr = castExpr; + castExpr->openParenTkIdx_ = openParenTkIdx; + castExpr->typeName_ = typeName; + castExpr->closeParenTkIdx_ = closeParenTkIdx; + return parseExpressionWithPrecedenceCast(castExpr->expr_); +} - auto nameExpr = makeNode(); - nameExpr->identTkIdx_ = - typeName->specs_->value->asTypedefName()->identTkIdx_; - auto parenExpr = makeNode(); - parenExpr->expr_ = nameExpr; - parenExpr->openParenTkIdx_ = castExpr->openParenTkIdx_; - auto binExpr = makeNode(binExprK); - binExpr->leftExpr_ = parenExpr; - parenExpr->closeParenTkIdx_ = castExpr->closeParenTkIdx_; - binExpr->oprtrTkIdx_ = prefixExpr->oprtrTkIdx_; - binExpr->rightExpr_ = prefixExpr->expr_; - - auto ambiExpr = makeNode(AmbiguousCastOrBinaryExpression); - expr = ambiExpr; - ambiExpr->castExpr_ = castExpr; - ambiExpr->binExpr_ = binExpr; - - diagReporter_.AmbiguousCastOrBinaryExpression(); +void Parser::maybeAmbiguateCastExpression(ExpressionSyntax *&expr) { + PSY_ASSERT_W_MSG(expr->kind() == CastExpression, return, ""); + + auto castExpr = expr->asCastExpression(); + auto prefixExpr = castExpr->expr_->asPrefixUnaryExpression(); + if (!(prefixExpr->asPrefixUnaryExpression() && + (prefixExpr->kind() == AddressOfExpression || + prefixExpr->kind() == PointerIndirectionExpression || + prefixExpr->kind() == UnaryPlusExpression || + prefixExpr->kind() == UnaryMinusExpression))) + return; + + TypeNameSyntax *typeName = castExpr->typeName_; + if (!(typeName->specs_ && typeName->specs_->value->kind() == TypedefName && + !typeName->specs_->next && typeName->decltor_ && + typeName->decltor_->kind() == AbstractDeclarator)) + return; + + SyntaxKind binExprK; + switch (prefixExpr->kind()) { + case AddressOfExpression: + binExprK = BitwiseANDExpression; + break; + + case PointerIndirectionExpression: + binExprK = MultiplyExpression; + break; + + case UnaryPlusExpression: + binExprK = AddExpression; + break; + + case UnaryMinusExpression: + binExprK = SubstractExpression; + break; + + default: + PSY_ASSERT_W_MSG(false, return, ""); + } + + auto nameExpr = makeNode(); + nameExpr->identTkIdx_ = typeName->specs_->value->asTypedefName()->identTkIdx_; + auto parenExpr = makeNode(); + parenExpr->expr_ = nameExpr; + parenExpr->openParenTkIdx_ = castExpr->openParenTkIdx_; + auto binExpr = makeNode(binExprK); + binExpr->leftExpr_ = parenExpr; + parenExpr->closeParenTkIdx_ = castExpr->closeParenTkIdx_; + binExpr->oprtrTkIdx_ = prefixExpr->oprtrTkIdx_; + binExpr->rightExpr_ = prefixExpr->expr_; + + auto ambiExpr = makeNode( + AmbiguousCastOrBinaryExpression); + expr = ambiExpr; + ambiExpr->castExpr_ = castExpr; + ambiExpr->binExpr_ = binExpr; + + diagReporter_.AmbiguousCastOrBinaryExpression(); } /* N-ary */ namespace NAryPrecedence { -enum : std::uint8_t -{ - Undefined = 0, - Sequencing, - Assignment, - Conditional, - LogicalOR, - LogicalAND, - BitwiseOR, - BitwiseXOR, - BitwiseAND, - Equality, - Relational, - Shift, - Additive, - Multiplicative +enum : std::uint8_t { + Undefined = 0, + Sequencing, + Assignment, + Conditional, + LogicalOR, + LogicalAND, + BitwiseOR, + BitwiseXOR, + BitwiseAND, + Equality, + Relational, + Shift, + Additive, + Multiplicative }; -} // NAryPrecedence - -std::uint8_t precedenceOf(SyntaxKind tkK) -{ - switch (tkK) { - case CommaToken: - return NAryPrecedence::Sequencing; - - case EqualsToken: - case PlusEqualsToken: - case MinusEqualsToken: - case AsteriskEqualsToken: - case SlashEqualsToken: - case PercentEqualsToken: - case LessThanLessThanEqualsToken: - case GreaterThanGreaterThanEqualsToken: - case AmpersandEqualsToken: - case CaretEqualsToken: - case BarEqualsToken: - return NAryPrecedence::Assignment; - - case QuestionToken: - return NAryPrecedence::Conditional; - - case BarBarToken: - return NAryPrecedence::LogicalOR; - - case AmpersandAmpersandToken: - return NAryPrecedence::LogicalAND; - - case BarToken: - return NAryPrecedence::BitwiseOR; - - case CaretToken: - return NAryPrecedence::BitwiseXOR; - - case AmpersandToken: - return NAryPrecedence::BitwiseAND; - - case EqualsEqualsToken: - case ExclamationEqualsToken: - return NAryPrecedence::Equality; - - case GreaterThanToken: - case LessThanToken: - case LessThanEqualsToken: - case GreaterThanEqualsToken: - return NAryPrecedence::Relational; - - case LessThanLessThanToken: - case GreaterThanGreaterThanToken: - return NAryPrecedence::Shift; - - case PlusToken: - case MinusToken: - return NAryPrecedence::Additive; - - case AsteriskToken: - case SlashToken: - case PercentToken: - return NAryPrecedence::Multiplicative; - - default: - return NAryPrecedence::Undefined; - } +} // namespace NAryPrecedence + +std::uint8_t precedenceOf(SyntaxKind tkK) { + switch (tkK) { + case CommaToken: + return NAryPrecedence::Sequencing; + + case EqualsToken: + case PlusEqualsToken: + case MinusEqualsToken: + case AsteriskEqualsToken: + case SlashEqualsToken: + case PercentEqualsToken: + case LessThanLessThanEqualsToken: + case GreaterThanGreaterThanEqualsToken: + case AmpersandEqualsToken: + case CaretEqualsToken: + case BarEqualsToken: + return NAryPrecedence::Assignment; + + case QuestionToken: + return NAryPrecedence::Conditional; + + case BarBarToken: + return NAryPrecedence::LogicalOR; + + case AmpersandAmpersandToken: + return NAryPrecedence::LogicalAND; + + case BarToken: + return NAryPrecedence::BitwiseOR; + + case CaretToken: + return NAryPrecedence::BitwiseXOR; + + case AmpersandToken: + return NAryPrecedence::BitwiseAND; + + case EqualsEqualsToken: + case ExclamationEqualsToken: + return NAryPrecedence::Equality; + + case GreaterThanToken: + case LessThanToken: + case LessThanEqualsToken: + case GreaterThanEqualsToken: + return NAryPrecedence::Relational; + + case LessThanLessThanToken: + case GreaterThanGreaterThanToken: + return NAryPrecedence::Shift; + + case PlusToken: + case MinusToken: + return NAryPrecedence::Additive; + + case AsteriskToken: + case SlashToken: + case PercentToken: + return NAryPrecedence::Multiplicative; + + default: + return NAryPrecedence::Undefined; + } } -bool isRightAssociative(SyntaxKind tkK) -{ - auto prec = precedenceOf(tkK); - return prec == NAryPrecedence::Conditional || prec == NAryPrecedence::Assignment; +bool isRightAssociative(SyntaxKind tkK) { + auto prec = precedenceOf(tkK); + return prec == NAryPrecedence::Conditional || + prec == NAryPrecedence::Assignment; } /** - * Parse a \a multiplicative-expression, or any expression that is subsumed by such rule. + * Parse a \a multiplicative-expression, or any expression that is subsumed by + such rule. * * See note about naming convention in Parser::parseExpression. * @@ -1339,15 +1266,16 @@ bool isRightAssociative(SyntaxKind tkK) * * \remark 6.5.5 */ -bool Parser::parseExpressionWithPrecedenceMultiplicative(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceMultiplicative( + ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::Multiplicative); + return parseNAryExpression(expr, NAryPrecedence::Multiplicative); } /** - * Parse a \a additive-expression, or any expression that is subsumed by such rule. + * Parse a \a additive-expression, or any expression that is subsumed by such + rule. * * See note about naming convention in Parser::parseExpression. * @@ -1360,11 +1288,10 @@ bool Parser::parseExpressionWithPrecedenceMultiplicative(ExpressionSyntax*& expr * * \remark 6.5.6 */ -bool Parser::parseExpressionWithPrecedenceAdditive(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceAdditive(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::Additive); + return parseNAryExpression(expr, NAryPrecedence::Additive); } /** @@ -1381,15 +1308,15 @@ bool Parser::parseExpressionWithPrecedenceAdditive(ExpressionSyntax*& expr) * * \remark 6.5.7 */ -bool Parser::parseExpressionWithPrecedenceShift(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceShift(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::Shift); + return parseNAryExpression(expr, NAryPrecedence::Shift); } /** - * Parse a \a relational-expression, or any expression that is subsumed by such rule. + * Parse a \a relational-expression, or any expression that is subsumed by such + rule. * * See note about naming convention in Parser::parseExpression. * @@ -1404,15 +1331,15 @@ bool Parser::parseExpressionWithPrecedenceShift(ExpressionSyntax*& expr) * * \remark 6.5.8 */ -bool Parser::parseExpressionWithPrecedenceRelational(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceRelational(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::Relational); + return parseNAryExpression(expr, NAryPrecedence::Relational); } /** - * Parse a \a multiplicative-expression, or any expression that is subsumed by such rule. + * Parse a \a multiplicative-expression, or any expression that is subsumed by + such rule. * * See note about naming convention in Parser::parseExpression. * @@ -1425,11 +1352,10 @@ bool Parser::parseExpressionWithPrecedenceRelational(ExpressionSyntax*& expr) * * \remark 6.5.9 */ -bool Parser::parseExpressionWithPrecedenceEquality(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceEquality(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::Equality); + return parseNAryExpression(expr, NAryPrecedence::Equality); } /** @@ -1445,15 +1371,15 @@ bool Parser::parseExpressionWithPrecedenceEquality(ExpressionSyntax*& expr) * * \remark 6.5.10 */ -bool Parser::parseExpressionWithPrecedenceBitwiseAND(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceBitwiseAND(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::BitwiseAND); + return parseNAryExpression(expr, NAryPrecedence::BitwiseAND); } /** - * Parse a \a exclusive-OR-expression, or any expression that is subsumed by such rule. + * Parse a \a exclusive-OR-expression, or any expression that is subsumed by + such rule. * * See note about naming convention in Parser::parseExpression. * @@ -1465,15 +1391,15 @@ bool Parser::parseExpressionWithPrecedenceBitwiseAND(ExpressionSyntax*& expr) * * \remark 6.5.11 */ -bool Parser::parseExpressionWithPrecedenceBitwiseXOR(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceBitwiseXOR(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::BitwiseXOR); + return parseNAryExpression(expr, NAryPrecedence::BitwiseXOR); } /** - * Parse a \a inclusive-OR-expression, or any expression that is subsumed by such rule. + * Parse a \a inclusive-OR-expression, or any expression that is subsumed by + such rule. * * See note about naming convention in Parser::parseExpression. * @@ -1485,15 +1411,15 @@ bool Parser::parseExpressionWithPrecedenceBitwiseXOR(ExpressionSyntax*& expr) * * \remark 6.5.12 */ -bool Parser::parseExpressionWithPrecedenceBitwiseOR(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceBitwiseOR(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::BitwiseOR); + return parseNAryExpression(expr, NAryPrecedence::BitwiseOR); } /** - * Parse a \a logical-AND-expression, or any expression that is subsumed by such rule. + * Parse a \a logical-AND-expression, or any expression that is subsumed by such + rule. * * See note about naming convention in Parser::parseExpression. * @@ -1505,15 +1431,15 @@ bool Parser::parseExpressionWithPrecedenceBitwiseOR(ExpressionSyntax*& expr) * * \remark 6.5.13 */ -bool Parser::parseExpressionWithPrecedenceLogicalAND(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceLogicalAND(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::LogicalAND); + return parseNAryExpression(expr, NAryPrecedence::LogicalAND); } /** - * Parse a \a logical-OR-expression, or any expression that is subsumed by such rule. + * Parse a \a logical-OR-expression, or any expression that is subsumed by such + rule. * * See note about naming convention in Parser::parseExpression. * @@ -1525,15 +1451,15 @@ bool Parser::parseExpressionWithPrecedenceLogicalAND(ExpressionSyntax*& expr) * * \remark 6.5.14 */ -bool Parser::parseExpressionWithPrecedenceLogicalOR(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceLogicalOR(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::LogicalOR); + return parseNAryExpression(expr, NAryPrecedence::LogicalOR); } /** - * Parse a \a conditional-expression, or any expression that is subsumed by such rule. + * Parse a \a conditional-expression, or any expression that is subsumed by such + rule. * * See note about naming convention in Parser::parseExpression. * @@ -1545,15 +1471,15 @@ bool Parser::parseExpressionWithPrecedenceLogicalOR(ExpressionSyntax*& expr) * * \remark 6.5.15 */ -bool Parser::parseExpressionWithPrecedenceConditional(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceConditional(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::Conditional); + return parseNAryExpression(expr, NAryPrecedence::Conditional); } /** - * Parse a \a assignment-expression, or any expression that is subsumed by such rule. + * Parse a \a assignment-expression, or any expression that is subsumed by such + rule. * * See note about naming convention in Parser::parseExpression. * @@ -1568,11 +1494,10 @@ bool Parser::parseExpressionWithPrecedenceConditional(ExpressionSyntax*& expr) * * \remark 6.5.16 */ -bool Parser::parseExpressionWithPrecedenceAssignment(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceAssignment(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::Assignment); + return parseNAryExpression(expr, NAryPrecedence::Assignment); } /** @@ -1581,124 +1506,110 @@ bool Parser::parseExpressionWithPrecedenceAssignment(ExpressionSyntax*& expr) * \remark 6.5.17 * \remark Parser::parseExpression */ -bool Parser::parseExpressionWithPrecedenceComma(ExpressionSyntax*& expr) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExpressionWithPrecedenceComma(ExpressionSyntax *&expr) { + DEBUG_THIS_RULE(); - return parseNAryExpression(expr, NAryPrecedence::Sequencing); + return parseNAryExpression(expr, NAryPrecedence::Sequencing); } -bool Parser::parseNAryExpression(ExpressionSyntax*& expr, std::uint8_t cutoffPrecedence) -{ - DEBUG_THIS_RULE(); +bool Parser::parseNAryExpression(ExpressionSyntax *&expr, + std::uint8_t cutoffPrecedence) { + DEBUG_THIS_RULE(); - if (!parseExpressionWithPrecedenceCast(expr)) - return false; + if (!parseExpressionWithPrecedenceCast(expr)) + return false; - return parseNAryExpression_AtOperator(expr, cutoffPrecedence); + return parseNAryExpression_AtOperator(expr, cutoffPrecedence); } -bool Parser::parseNAryExpression_AtOperator(ExpressionSyntax*& baseExpr, - std::uint8_t cutoffPrecedence) -{ - DEBUG_THIS_RULE(); - - auto CUR_DEPTH_OF_EXPR = DEPTH_OF_EXPRS_; - - while (precedenceOf(peek().kind()) >= cutoffPrecedence) { - if (++CUR_DEPTH_OF_EXPR > MAX_DEPTH_OF_EXPRS) - throw std::runtime_error("maximum depth of expressions reached"); - - auto tkK = peek().kind(); - auto exprK = SyntaxFacts::NAryExpressionKind(tkK); - auto oprtrTkIdx = consume(); - - ConditionalExpressionSyntax* condExpr = nullptr; - if (tkK == QuestionToken) { - condExpr = makeNode(); - condExpr->questionTkIdx_ = oprtrTkIdx; - - if (peek().kind() == ColonToken) { - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_StatementExpressions()) - diagReporter_.ExpectedFeature("GNU conditionals"); - - condExpr->whenTrueExpr_ = nullptr; - } - else { - parseExpression(condExpr->whenTrueExpr_); - } - match(ColonToken, &condExpr->colonTkIdx_); - } - - ExpressionSyntax* nextExpr = nullptr; - if (!parseExpressionWithPrecedenceCast(nextExpr)) - return false; - - auto prevPrec = precedenceOf(tkK); - tkK = peek().kind(); - auto precAhead = precedenceOf(tkK); - - while ((precAhead > prevPrec - && SyntaxFacts::isNAryOperatorToken(tkK)) - || (precAhead == prevPrec - && isRightAssociative(tkK))) { - if (!parseNAryExpression_AtOperator(nextExpr, precAhead)) - return false; +bool Parser::parseNAryExpression_AtOperator(ExpressionSyntax *&baseExpr, + std::uint8_t cutoffPrecedence) { + DEBUG_THIS_RULE(); + + auto CUR_DEPTH_OF_EXPR = DEPTH_OF_EXPRS_; + + while (precedenceOf(peek().kind()) >= cutoffPrecedence) { + if (++CUR_DEPTH_OF_EXPR > MAX_DEPTH_OF_EXPRS) + throw std::runtime_error("maximum depth of expressions reached"); + + auto tkK = peek().kind(); + auto exprK = SyntaxFacts::NAryExpressionKind(tkK); + auto oprtrTkIdx = consume(); - tkK = peek().kind(); - precAhead = precedenceOf(tkK); - } - - /* - * An "usual" N-ary expression E can be produced with a FIRST that is another N-ary - * expression with same precedence of E or a tighter one. An assignment expression - * is different in that its LHS may not be a N-ary expression: it must a unary one. - */ - if (precAhead == NAryPrecedence::Assignment && prevPrec > precAhead) - return false; - - if (condExpr) { - condExpr->condExpr_ = baseExpr; - condExpr->whenFalseExpr_ = nextExpr; - baseExpr = condExpr; - } - else { - if (SyntaxFacts::isAssignmentExpression(exprK)) { - baseExpr = fill_LeftOperandInfixOperatorRightOperand_MIXIN( - makeNode(exprK), - baseExpr, - oprtrTkIdx, - nextExpr); - } - else if (SyntaxFacts::isBinaryExpression(exprK)) { - baseExpr = fill_LeftOperandInfixOperatorRightOperand_MIXIN( - makeNode(exprK), - baseExpr, - oprtrTkIdx, - nextExpr); - } - else { - baseExpr = fill_LeftOperandInfixOperatorRightOperand_MIXIN( - makeNode(), - baseExpr, - oprtrTkIdx, - nextExpr); - } - } + ConditionalExpressionSyntax *condExpr = nullptr; + if (tkK == QuestionToken) { + condExpr = makeNode(); + condExpr->questionTkIdx_ = oprtrTkIdx; + + if (peek().kind() == ColonToken) { + if (!tree_->parseOptions() + .extensions() + .isEnabled_ExtGNU_StatementExpressions()) + diagReporter_.ExpectedFeature("GNU conditionals"); + + condExpr->whenTrueExpr_ = nullptr; + } else { + parseExpression(condExpr->whenTrueExpr_); + } + match(ColonToken, &condExpr->colonTkIdx_); } - return true; + ExpressionSyntax *nextExpr = nullptr; + if (!parseExpressionWithPrecedenceCast(nextExpr)) + return false; + + auto prevPrec = precedenceOf(tkK); + tkK = peek().kind(); + auto precAhead = precedenceOf(tkK); + + while ((precAhead > prevPrec && SyntaxFacts::isNAryOperatorToken(tkK)) || + (precAhead == prevPrec && isRightAssociative(tkK))) { + if (!parseNAryExpression_AtOperator(nextExpr, precAhead)) + return false; + + tkK = peek().kind(); + precAhead = precedenceOf(tkK); + } + + /* + * An "usual" N-ary expression E can be produced with a FIRST that is + * another N-ary expression with same precedence of E or a tighter one. An + * assignment expression is different in that its LHS may not be a N-ary + * expression: it must a unary one. + */ + if (precAhead == NAryPrecedence::Assignment && prevPrec > precAhead) + return false; + + if (condExpr) { + condExpr->condExpr_ = baseExpr; + condExpr->whenFalseExpr_ = nextExpr; + baseExpr = condExpr; + } else { + if (SyntaxFacts::isAssignmentExpression(exprK)) { + baseExpr = fill_LeftOperandInfixOperatorRightOperand_MIXIN( + makeNode(exprK), baseExpr, oprtrTkIdx, + nextExpr); + } else if (SyntaxFacts::isBinaryExpression(exprK)) { + baseExpr = fill_LeftOperandInfixOperatorRightOperand_MIXIN( + makeNode(exprK), baseExpr, oprtrTkIdx, + nextExpr); + } else { + baseExpr = fill_LeftOperandInfixOperatorRightOperand_MIXIN( + makeNode(), baseExpr, oprtrTkIdx, + nextExpr); + } + } + } + + return true; } template -NodeT* Parser::fill_LeftOperandInfixOperatorRightOperand_MIXIN( - NodeT* expr, - ExpressionSyntax* left, - LexedTokens::IndexType opTkIdx, - ExpressionSyntax* right) -{ - expr->leftExpr_ = left; - expr->oprtrTkIdx_ = opTkIdx; - expr->rightExpr_ = right; - return expr; +NodeT *Parser::fill_LeftOperandInfixOperatorRightOperand_MIXIN( + NodeT *expr, ExpressionSyntax *left, LexedTokens::IndexType opTkIdx, + ExpressionSyntax *right) { + expr->leftExpr_ = left; + expr->oprtrTkIdx_ = opTkIdx; + expr->rightExpr_ = right; + return expr; } diff --git a/C/parser/Parser_Statements.cpp b/C/parser/Parser_Statements.cpp index 7cd53cdc7..e996728e2 100644 --- a/C/parser/Parser_Statements.cpp +++ b/C/parser/Parser_Statements.cpp @@ -33,251 +33,240 @@ using namespace C; * * \remark 6.8 */ -bool Parser::parseStatement(StatementSyntax*& stmt, StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - - switch (peek().kind()) { - case Keyword__Static_assert: - return parseDeclarationStatement( - stmt, - &Parser::parseStaticAssertDeclaration_AtFirst); - - // storage-class-specifier - case Keyword_typedef: - case Keyword_extern: - case Keyword_static: - case Keyword_auto: - case Keyword_register: - case Keyword__Thread_local: - case Keyword_ExtGNU___thread: - - // type-qualifier - case Keyword_const: - case Keyword_volatile: - case Keyword_restrict: - case Keyword__Atomic: - - // function-specifier - case Keyword_inline: - case Keyword__Noreturn: - - // type-specifier - case Keyword_void: - case Keyword_char: - case Keyword_short: - case Keyword_int: - case Keyword_long: - case Keyword_float: - case Keyword_double: - case Keyword__Bool: - case Keyword__Complex: - case Keyword_signed: - case Keyword_unsigned: - case Keyword_Ext_char16_t: - case Keyword_Ext_char32_t: - case Keyword_Ext_wchar_t: - case Keyword_struct: - case Keyword_union: - case Keyword_enum: - case Keyword_ExtGNU___typeof__: - case Keyword_ExtGNU___complex__: - return parseDeclarationStatement( - stmt, - &Parser::parseDeclarationOrFunctionDefinition); - - case IdentifierToken: { - if (peek(2).kind() == ColonToken) - return parseLabeledStatement_AtFirst(stmt, stmtCtx); - - Backtracker BT(this); - if (!parseExpressionStatement(stmt)) { - BT.backtrack(); - return parseDeclarationStatement( - stmt, - &Parser::parseDeclarationOrFunctionDefinition); - } - maybeAmbiguateStatement(stmt); - return true; - } - - case OpenBraceToken: - return parseCompoundStatement_AtFirst(stmt, stmtCtx); - - case Keyword_if: - return parseIfStatement_AtFirst(stmt, stmtCtx); - - case Keyword_switch: - return parseSwitchStatement_AtFirst(stmt, stmtCtx); - - case Keyword_case: - if (stmtCtx != StatementContext::Switch - && stmtCtx != StatementContext::SwitchAndLoop) - diagReporter_.UnexpectedCaseLabelOutsideSwitch(); - return parseLabeledStatement_AtFirst(stmt, stmtCtx); - - case Keyword_default: - if (stmtCtx != StatementContext::Switch - && stmtCtx != StatementContext::SwitchAndLoop) - diagReporter_.UnexpectedDefaultLabelOutsideSwitch(); - return parseLabeledStatement_AtFirst(stmt, stmtCtx); - - case Keyword_while: - return parseWhileStatement_AtFirst(stmt, stmtCtx); - - case Keyword_do: - return parseDoStatement_AtFirst(stmt, stmtCtx); - - case Keyword_for: - return parseForStatement_AtFirst(stmt, stmtCtx); - - case Keyword_goto: - return parseGotoStatement_AtFirst(stmt); - - case Keyword_continue: - if (stmtCtx != StatementContext::Loop - && stmtCtx != StatementContext::SwitchAndLoop) - diagReporter_.UnexpectedContinueOutsideLoop(); - return parseContinueStatement_AtFirst(stmt, stmtCtx); - - case Keyword_break: - if (stmtCtx == StatementContext::None) - diagReporter_.UnexpectedBreakOutsideSwitchOrLoop(); - return parseBreakStatement_AtFirst(stmt, stmtCtx); - - case Keyword_return: - return parseReturnStatement_AtFirst(stmt); - - case SemicolonToken: { - auto exprStmt = makeNode(); - stmt = exprStmt; - exprStmt->semicolonTkIdx_ = consume(); - return true; - } - - case Keyword_ExtGNU___asm__: - return parseExtGNU_AsmStatement(stmt); - - case Keyword_ExtGNU___extension__: { - auto extKwTkIdx = consume(); - if (!parseStatement(stmt, stmtCtx)) - return false; - - PSY_ASSERT_W_MSG(stmt, return false, "invalid declaration"); - switch (stmt->kind()) { - case ExpressionStatement: - PSY_ASSERT_W_MSG(stmt->asExpressionStatement(), - return false, - "invalid expression-statement"); - stmt->asExpressionStatement()->expr_->extKwTkIdx_ = extKwTkIdx; - break; - - case DeclarationStatement: - PSY_ASSERT_W_MSG(stmt->asDeclarationStatement(), - return false, - "invalid expression-statement"); - stmt->asDeclarationStatement()->decl_->extKwTkIdx_ = extKwTkIdx; - break; - - default: - diagReporter_.UnexpectedGNUExtensionFlag(); - return false; - } - return true; - } - - default: - return parseExpressionStatement(stmt); +bool Parser::parseStatement(StatementSyntax *&stmt, StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + + switch (peek().kind()) { + case Keyword__Static_assert: + return parseDeclarationStatement( + stmt, &Parser::parseStaticAssertDeclaration_AtFirst); + + // storage-class-specifier + case Keyword_typedef: + case Keyword_extern: + case Keyword_static: + case Keyword_auto: + case Keyword_register: + case Keyword__Thread_local: + case Keyword_ExtGNU___thread: + + // type-qualifier + case Keyword_const: + case Keyword_volatile: + case Keyword_restrict: + case Keyword__Atomic: + + // function-specifier + case Keyword_inline: + case Keyword__Noreturn: + + // type-specifier + case Keyword_void: + case Keyword_char: + case Keyword_short: + case Keyword_int: + case Keyword_long: + case Keyword_float: + case Keyword_double: + case Keyword__Bool: + case Keyword__Complex: + case Keyword_signed: + case Keyword_unsigned: + case Keyword_Ext_char16_t: + case Keyword_Ext_char32_t: + case Keyword_Ext_wchar_t: + case Keyword_struct: + case Keyword_union: + case Keyword_enum: + case Keyword_ExtGNU___typeof__: + case Keyword_ExtGNU___complex__: + return parseDeclarationStatement( + stmt, &Parser::parseDeclarationOrFunctionDefinition); + + case IdentifierToken: { + if (peek(2).kind() == ColonToken) + return parseLabeledStatement_AtFirst(stmt, stmtCtx); + + Backtracker BT(this); + if (!parseExpressionStatement(stmt)) { + BT.backtrack(); + return parseDeclarationStatement( + stmt, &Parser::parseDeclarationOrFunctionDefinition); } -} + maybeAmbiguateStatement(stmt); + return true; + } -bool Parser::parseDeclarationStatement(StatementSyntax*& stmt, - bool (Parser::*parseDecl)(DeclarationSyntax*& )) -{ - auto declStmt = makeNode(); - stmt = declStmt; - return ((this)->*(parseDecl))(declStmt->decl_); -} + case OpenBraceToken: + return parseCompoundStatement_AtFirst(stmt, stmtCtx); + + case Keyword_if: + return parseIfStatement_AtFirst(stmt, stmtCtx); + + case Keyword_switch: + return parseSwitchStatement_AtFirst(stmt, stmtCtx); + + case Keyword_case: + if (stmtCtx != StatementContext::Switch && + stmtCtx != StatementContext::SwitchAndLoop) + diagReporter_.UnexpectedCaseLabelOutsideSwitch(); + return parseLabeledStatement_AtFirst(stmt, stmtCtx); + + case Keyword_default: + if (stmtCtx != StatementContext::Switch && + stmtCtx != StatementContext::SwitchAndLoop) + diagReporter_.UnexpectedDefaultLabelOutsideSwitch(); + return parseLabeledStatement_AtFirst(stmt, stmtCtx); + + case Keyword_while: + return parseWhileStatement_AtFirst(stmt, stmtCtx); -void Parser::maybeAmbiguateStatement(StatementSyntax*& stmt) -{ - PSY_ASSERT_W_MSG(stmt->kind() == ExpressionStatement, - return, - to_string(stmt->kind())); - - auto exprStmt = stmt->asExpressionStatement(); - auto expr = exprStmt->expr_; - if (!(expr->kind() == MultiplyExpression - || expr->kind() == CallExpression)) - return; - - SyntaxKind stmtK; - TypedefNameSyntax* typedefName; - DeclaratorSyntax* decltor; - switch (expr->kind()) { - case MultiplyExpression: { - auto binExpr = expr->asBinaryExpression(); - if (!(binExpr->leftExpr_->kind() == IdentifierName - && binExpr->rightExpr_->kind() == IdentifierName)) - return; - - stmtK = AmbiguousMultiplicationOrPointerDeclaration; - typedefName = makeNode(); - typedefName->identTkIdx_ = - binExpr->leftExpr_->asIdentifierName()->identTkIdx_; - - auto identDecltor = makeNode(); - identDecltor->identTkIdx_ = - binExpr->rightExpr_->asIdentifierName()->identTkIdx_; - auto ptrDecltor = makeNode(); - decltor = ptrDecltor; - ptrDecltor->asteriskTkIdx_ = binExpr->oprtrTkIdx_; - ptrDecltor->innerDecltor_ = identDecltor; - break; - } - - case CallExpression: { - auto callExpr = expr->asCallExpression(); - if (!(callExpr->expr_->kind() == IdentifierName - && callExpr->args_ - && callExpr->args_->value->kind() == IdentifierName - && !callExpr->args_->next)) - return; - - stmtK = AmbiguousCallOrVariableDeclaration; - typedefName = makeNode(); - typedefName->identTkIdx_ = - callExpr->expr_->asIdentifierName()->identTkIdx_; - - auto identDecltor = makeNode(); - identDecltor->identTkIdx_ = - callExpr->args_->value->asIdentifierName()->identTkIdx_; - auto parenDecltor = makeNode(); - decltor = parenDecltor; - parenDecltor->openParenTkIdx_ = callExpr->openParenTkIdx_; - parenDecltor->innerDecltor_ = identDecltor; - parenDecltor->closeParenTkIdx_ = callExpr->closeParenTkIdx_; - break; - } - - default: - PSY_ASSERT_W_MSG(false, return, ""); + case Keyword_do: + return parseDoStatement_AtFirst(stmt, stmtCtx); + + case Keyword_for: + return parseForStatement_AtFirst(stmt, stmtCtx); + + case Keyword_goto: + return parseGotoStatement_AtFirst(stmt); + + case Keyword_continue: + if (stmtCtx != StatementContext::Loop && + stmtCtx != StatementContext::SwitchAndLoop) + diagReporter_.UnexpectedContinueOutsideLoop(); + return parseContinueStatement_AtFirst(stmt, stmtCtx); + + case Keyword_break: + if (stmtCtx == StatementContext::None) + diagReporter_.UnexpectedBreakOutsideSwitchOrLoop(); + return parseBreakStatement_AtFirst(stmt, stmtCtx); + + case Keyword_return: + return parseReturnStatement_AtFirst(stmt); + + case SemicolonToken: { + auto exprStmt = makeNode(); + stmt = exprStmt; + exprStmt->semicolonTkIdx_ = consume(); + return true; + } + + case Keyword_ExtGNU___asm__: + return parseExtGNU_AsmStatement(stmt); + + case Keyword_ExtGNU___extension__: { + auto extKwTkIdx = consume(); + if (!parseStatement(stmt, stmtCtx)) + return false; + + PSY_ASSERT_W_MSG(stmt, return false, "invalid declaration"); + switch (stmt->kind()) { + case ExpressionStatement: + PSY_ASSERT_W_MSG(stmt->asExpressionStatement(), return false, + "invalid expression-statement"); + stmt->asExpressionStatement()->expr_->extKwTkIdx_ = extKwTkIdx; + break; + + case DeclarationStatement: + PSY_ASSERT_W_MSG(stmt->asDeclarationStatement(), return false, + "invalid expression-statement"); + stmt->asDeclarationStatement()->decl_->extKwTkIdx_ = extKwTkIdx; + break; + + default: + diagReporter_.UnexpectedGNUExtensionFlag(); + return false; } + return true; + } - VariableAndOrFunctionDeclarationSyntax* varDecl = nullptr; - varDecl = makeNode(); - varDecl->specs_ = makeNode(typedefName); - varDecl->semicolonTkIdx_ = exprStmt->semicolonTkIdx_; - varDecl->decltors_ = makeNode(decltor); + default: + return parseExpressionStatement(stmt); + } +} - auto ambiStmt = makeNode(stmtK); - stmt = ambiStmt; - ambiStmt->exprStmt_ = exprStmt; - auto declStmt = makeNode(); - declStmt->decl_ = varDecl; - ambiStmt->declStmt_ = declStmt; +bool Parser::parseDeclarationStatement( + StatementSyntax *&stmt, bool (Parser::*parseDecl)(DeclarationSyntax *&)) { + auto declStmt = makeNode(); + stmt = declStmt; + return ((this)->*(parseDecl))(declStmt->decl_); +} - diagReporter_.AmbiguousExpressionOrDeclarationStatement(); +void Parser::maybeAmbiguateStatement(StatementSyntax *&stmt) { + PSY_ASSERT_W_MSG(stmt->kind() == ExpressionStatement, return, + to_string(stmt->kind())); + + auto exprStmt = stmt->asExpressionStatement(); + auto expr = exprStmt->expr_; + if (!(expr->kind() == MultiplyExpression || expr->kind() == CallExpression)) + return; + + SyntaxKind stmtK; + TypedefNameSyntax *typedefName; + DeclaratorSyntax *decltor; + switch (expr->kind()) { + case MultiplyExpression: { + auto binExpr = expr->asBinaryExpression(); + if (!(binExpr->leftExpr_->kind() == IdentifierName && + binExpr->rightExpr_->kind() == IdentifierName)) + return; + + stmtK = AmbiguousMultiplicationOrPointerDeclaration; + typedefName = makeNode(); + typedefName->identTkIdx_ = + binExpr->leftExpr_->asIdentifierName()->identTkIdx_; + + auto identDecltor = makeNode(); + identDecltor->identTkIdx_ = + binExpr->rightExpr_->asIdentifierName()->identTkIdx_; + auto ptrDecltor = makeNode(); + decltor = ptrDecltor; + ptrDecltor->asteriskTkIdx_ = binExpr->oprtrTkIdx_; + ptrDecltor->innerDecltor_ = identDecltor; + break; + } + + case CallExpression: { + auto callExpr = expr->asCallExpression(); + if (!(callExpr->expr_->kind() == IdentifierName && callExpr->args_ && + callExpr->args_->value->kind() == IdentifierName && + !callExpr->args_->next)) + return; + + stmtK = AmbiguousCallOrVariableDeclaration; + typedefName = makeNode(); + typedefName->identTkIdx_ = callExpr->expr_->asIdentifierName()->identTkIdx_; + + auto identDecltor = makeNode(); + identDecltor->identTkIdx_ = + callExpr->args_->value->asIdentifierName()->identTkIdx_; + auto parenDecltor = makeNode(); + decltor = parenDecltor; + parenDecltor->openParenTkIdx_ = callExpr->openParenTkIdx_; + parenDecltor->innerDecltor_ = identDecltor; + parenDecltor->closeParenTkIdx_ = callExpr->closeParenTkIdx_; + break; + } + + default: + PSY_ASSERT_W_MSG(false, return, ""); + } + + VariableAndOrFunctionDeclarationSyntax *varDecl = nullptr; + varDecl = makeNode(); + varDecl->specs_ = makeNode(typedefName); + varDecl->semicolonTkIdx_ = exprStmt->semicolonTkIdx_; + varDecl->decltors_ = makeNode(decltor); + + auto ambiStmt = + makeNode(stmtK); + stmt = ambiStmt; + ambiStmt->exprStmt_ = exprStmt; + auto declStmt = makeNode(); + declStmt->decl_ = varDecl; + ambiStmt->declStmt_ = declStmt; + + diagReporter_.AmbiguousExpressionOrDeclarationStatement(); } /** @@ -285,47 +274,45 @@ void Parser::maybeAmbiguateStatement(StatementSyntax*& stmt) * * \remark 6.8.2 */ -bool Parser::parseCompoundStatement_AtFirst(StatementSyntax*& stmt, - StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == OpenBraceToken, - return false, - "assert failure: `{'"); - - DepthControl _(DEPTH_OF_STMTS_); - - auto block = makeNode(); - stmt = block; - block->openBraceTkIdx_ = consume(); - - StatementListSyntax** stmtList_cur = &block->stmts_; - - while (true) { - StatementSyntax* innerStmt = nullptr; - switch (peek().kind()) { - case EndOfFile: - diagReporter_.ExpectedToken(CloseBraceToken); - return false; - - case CloseBraceToken: - block->closeBraceTkIdx_ = consume(); - return true; - - default: { - if (!parseStatement(innerStmt, stmtCtx)) { - skipTo(CloseBraceToken); - continue; - } - break; - } - } - - *stmtList_cur = makeNode(innerStmt); - stmtList_cur = &(*stmtList_cur)->next; +bool Parser::parseCompoundStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == OpenBraceToken, return false, + "assert failure: `{'"); + + DepthControl _(DEPTH_OF_STMTS_); + + auto block = makeNode(); + stmt = block; + block->openBraceTkIdx_ = consume(); + + StatementListSyntax **stmtList_cur = &block->stmts_; + + while (true) { + StatementSyntax *innerStmt = nullptr; + switch (peek().kind()) { + case EndOfFile: + diagReporter_.ExpectedToken(CloseBraceToken); + return false; + + case CloseBraceToken: + block->closeBraceTkIdx_ = consume(); + return true; + + default: { + if (!parseStatement(innerStmt, stmtCtx)) { + skipTo(CloseBraceToken); + continue; + } + break; + } } - return matchOrSkipTo(CloseBraceToken, &block->closeBraceTkIdx_); + *stmtList_cur = makeNode(innerStmt); + stmtList_cur = &(*stmtList_cur)->next; + } + + return matchOrSkipTo(CloseBraceToken, &block->closeBraceTkIdx_); } /** @@ -333,26 +320,25 @@ bool Parser::parseCompoundStatement_AtFirst(StatementSyntax*& stmt, * * \remark 6.8.3 */ -bool Parser::parseExpressionStatement(StatementSyntax*& stmt) -{ - DEBUG_THIS_RULE(); - - if (peek().kind() == SemicolonToken) { - auto exprStmt = makeNode(); - stmt = exprStmt; - exprStmt->semicolonTkIdx_ = consume(); - return true; - } - - ExpressionSyntax* expr = nullptr; - if (!parseExpression(expr)) - return false; +bool Parser::parseExpressionStatement(StatementSyntax *&stmt) { + DEBUG_THIS_RULE(); + if (peek().kind() == SemicolonToken) { auto exprStmt = makeNode(); stmt = exprStmt; - exprStmt->expr_ = expr; + exprStmt->semicolonTkIdx_ = consume(); + return true; + } + + ExpressionSyntax *expr = nullptr; + if (!parseExpression(expr)) + return false; - return matchOrSkipTo(SemicolonToken, &exprStmt->semicolonTkIdx_); + auto exprStmt = makeNode(); + stmt = exprStmt; + exprStmt->expr_ = expr; + + return matchOrSkipTo(SemicolonToken, &exprStmt->semicolonTkIdx_); } /** @@ -361,30 +347,28 @@ bool Parser::parseExpressionStatement(StatementSyntax*& stmt) * * \remark 6.8.4.1 */ -bool Parser::parseIfStatement_AtFirst(StatementSyntax*& stmt, StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_if, - return false, - "assert failure: `if'"); - - auto ifStmt = makeNode(); - stmt = ifStmt; - ifStmt->ifKwTkIdx_ = consume(); - - if (!(match(OpenParenToken, &ifStmt->openParenTkIdx_) - && parseExpression(ifStmt->cond_) - && match(CloseParenToken, &ifStmt->closeParenTkIdx_) - && parseStatement(ifStmt->stmt_, stmtCtx))) { - return ignoreStatement(); - } - - if (peek().kind() == Keyword_else) { - ifStmt->elseKwTkIdx_ = consume(); - return checkStatementParse( - parseStatement(ifStmt->elseStmt_, stmtCtx)); - } - return true; +bool Parser::parseIfStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_if, return false, + "assert failure: `if'"); + + auto ifStmt = makeNode(); + stmt = ifStmt; + ifStmt->ifKwTkIdx_ = consume(); + + if (!(match(OpenParenToken, &ifStmt->openParenTkIdx_) && + parseExpression(ifStmt->cond_) && + match(CloseParenToken, &ifStmt->closeParenTkIdx_) && + parseStatement(ifStmt->stmt_, stmtCtx))) { + return ignoreStatement(); + } + + if (peek().kind() == Keyword_else) { + ifStmt->elseKwTkIdx_ = consume(); + return checkStatementParse(parseStatement(ifStmt->elseStmt_, stmtCtx)); + } + return true; } /** @@ -393,24 +377,21 @@ bool Parser::parseIfStatement_AtFirst(StatementSyntax*& stmt, StatementContext s * * \remark 6.8.4.2 */ -bool Parser::parseSwitchStatement_AtFirst(StatementSyntax*& stmt, - StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_switch, - return false, - "assert failure: `switch'"); - - auto switchStmt = makeNode(); - stmt = switchStmt; - switchStmt->switchKwTkIdx_ = consume(); - - return checkStatementParse( - match(OpenParenToken, &switchStmt->openParenTkIdx_) - && parseExpression(switchStmt->cond_) - && match(CloseParenToken, &switchStmt->closeParenTkIdx_) - && parseStatement(switchStmt->stmt_, - stmtCtx + StatementContext::Switch)); +bool Parser::parseSwitchStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_switch, return false, + "assert failure: `switch'"); + + auto switchStmt = makeNode(); + stmt = switchStmt; + switchStmt->switchKwTkIdx_ = consume(); + + return checkStatementParse( + match(OpenParenToken, &switchStmt->openParenTkIdx_) && + parseExpression(switchStmt->cond_) && + match(CloseParenToken, &switchStmt->closeParenTkIdx_) && + parseStatement(switchStmt->stmt_, stmtCtx + StatementContext::Switch)); } /** @@ -418,53 +399,49 @@ bool Parser::parseSwitchStatement_AtFirst(StatementSyntax*& stmt, * * \remark 6.8.1 */ -bool Parser::parseLabeledStatement_AtFirst(StatementSyntax*& stmt, - StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == IdentifierToken - || peek().kind() == Keyword_case - || peek().kind() == Keyword_default, - return false, - "assert failure: , `case', or `default'"); - - LabeledStatementSyntax* labelStmt = nullptr; - - switch (peek().kind()) { - case IdentifierToken: - PSY_ASSERT_W_MSG(peek(2).kind() == ColonToken, - return false, - "assert failure: `:'"); - - labelStmt = makeNode(IdentifierLabelStatement); - stmt = labelStmt; - labelStmt->labelTkIdx_ = consume(); - labelStmt->colonTkIdx_ = consume(); - break; - - case Keyword_default: - labelStmt = makeNode(DefaultLabelStatement); - stmt = labelStmt; - labelStmt->labelTkIdx_ = consume(); - if (!match(ColonToken, &labelStmt->colonTkIdx_)) - return false; - break; - - case Keyword_case: - labelStmt = makeNode(DefaultLabelStatement); - stmt = labelStmt; - labelStmt->labelTkIdx_ = consume(); - if (!(parseExpressionWithPrecedenceConditional(labelStmt->expr_) - && match(ColonToken, &labelStmt->colonTkIdx_))) - return false; - break; - - default: - break; - } - - return checkStatementParse( - parseStatement(labelStmt->stmt_, stmtCtx)); +bool Parser::parseLabeledStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG( + peek().kind() == IdentifierToken || peek().kind() == Keyword_case || + peek().kind() == Keyword_default, + return false, "assert failure: , `case', or `default'"); + + LabeledStatementSyntax *labelStmt = nullptr; + + switch (peek().kind()) { + case IdentifierToken: + PSY_ASSERT_W_MSG(peek(2).kind() == ColonToken, return false, + "assert failure: `:'"); + + labelStmt = makeNode(IdentifierLabelStatement); + stmt = labelStmt; + labelStmt->labelTkIdx_ = consume(); + labelStmt->colonTkIdx_ = consume(); + break; + + case Keyword_default: + labelStmt = makeNode(DefaultLabelStatement); + stmt = labelStmt; + labelStmt->labelTkIdx_ = consume(); + if (!match(ColonToken, &labelStmt->colonTkIdx_)) + return false; + break; + + case Keyword_case: + labelStmt = makeNode(DefaultLabelStatement); + stmt = labelStmt; + labelStmt->labelTkIdx_ = consume(); + if (!(parseExpressionWithPrecedenceConditional(labelStmt->expr_) && + match(ColonToken, &labelStmt->colonTkIdx_))) + return false; + break; + + default: + break; + } + + return checkStatementParse(parseStatement(labelStmt->stmt_, stmtCtx)); } /** @@ -473,24 +450,21 @@ bool Parser::parseLabeledStatement_AtFirst(StatementSyntax*& stmt, * * \remark 6.8.5.1 */ -bool Parser::parseWhileStatement_AtFirst(StatementSyntax*& stmt, - StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_while, - return false, - "assert failure: `while'"); - - auto whileStmt = makeNode(); - stmt = whileStmt; - whileStmt->whileKwTkIdx_ = consume(); - - return checkStatementParse( - match(OpenParenToken, &whileStmt->openParenTkIdx_) - && parseExpression(whileStmt->cond_) - && match(CloseParenToken, &whileStmt->closeParenTkIdx_) - && parseStatement(whileStmt->stmt_, - stmtCtx + StatementContext::Loop)); +bool Parser::parseWhileStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_while, return false, + "assert failure: `while'"); + + auto whileStmt = makeNode(); + stmt = whileStmt; + whileStmt->whileKwTkIdx_ = consume(); + + return checkStatementParse( + match(OpenParenToken, &whileStmt->openParenTkIdx_) && + parseExpression(whileStmt->cond_) && + match(CloseParenToken, &whileStmt->closeParenTkIdx_) && + parseStatement(whileStmt->stmt_, stmtCtx + StatementContext::Loop)); } /** @@ -499,26 +473,23 @@ bool Parser::parseWhileStatement_AtFirst(StatementSyntax*& stmt, * * \remark 6.8.5.2 */ -bool Parser::parseDoStatement_AtFirst(StatementSyntax*& stmt, - StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_do, - return false, - "assert failure: `do'"); - - auto doStmt = makeNode(); - stmt = doStmt; - doStmt->doKwTkIdx_ = consume(); - - return checkStatementParse( - parseStatement(doStmt->stmt_, - stmtCtx + StatementContext::Loop) - && match(Keyword_while, &doStmt->whileKwTkIdx_) - && match(OpenParenToken, &doStmt->openParenTkIdx_) - && parseExpression(doStmt->cond_) - && match(CloseParenToken, &doStmt->closeParenTkIdx_) - && match(SemicolonToken, &doStmt->semicolonTkIdx_)); +bool Parser::parseDoStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_do, return false, + "assert failure: `do'"); + + auto doStmt = makeNode(); + stmt = doStmt; + doStmt->doKwTkIdx_ = consume(); + + return checkStatementParse( + parseStatement(doStmt->stmt_, stmtCtx + StatementContext::Loop) && + match(Keyword_while, &doStmt->whileKwTkIdx_) && + match(OpenParenToken, &doStmt->openParenTkIdx_) && + parseExpression(doStmt->cond_) && + match(CloseParenToken, &doStmt->closeParenTkIdx_) && + match(SemicolonToken, &doStmt->semicolonTkIdx_)); } /** @@ -527,114 +498,110 @@ bool Parser::parseDoStatement_AtFirst(StatementSyntax*& stmt, * * \remark 6.8.5.3 */ -bool Parser::parseForStatement_AtFirst(StatementSyntax*& stmt, - StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_for, - return false, - "assert failure: `for'"); - - auto forStmt = makeNode(); - stmt = forStmt; - forStmt->forKwTkIdx_ = consume(); - - if (!match(OpenParenToken, &forStmt->openParenTkIdx_)) { - skipTo(CloseParenToken); - return false; +bool Parser::parseForStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_for, return false, + "assert failure: `for'"); + + auto forStmt = makeNode(); + stmt = forStmt; + forStmt->forKwTkIdx_ = consume(); + + if (!match(OpenParenToken, &forStmt->openParenTkIdx_)) { + skipTo(CloseParenToken); + return false; + } + + if (peek().kind() == Keyword_ExtGNU___extension__) + forStmt->extKwTkIdx_ = consume(); + + switch (peek().kind()) { + // storage-class-specifier + case Keyword_typedef: + case Keyword_extern: + case Keyword_static: + case Keyword_auto: + case Keyword_register: + case Keyword__Thread_local: + case Keyword_ExtGNU___thread: + + // type-qualifier + case Keyword_const: + case Keyword_volatile: + case Keyword_restrict: + case Keyword__Atomic: + + // function-specifier + case Keyword_inline: + case Keyword__Noreturn: + + // type-specifier + case Keyword_void: + case Keyword_char: + case Keyword_short: + case Keyword_int: + case Keyword_long: + case Keyword_float: + case Keyword_double: + case Keyword__Bool: + case Keyword__Complex: + case Keyword_signed: + case Keyword_unsigned: + case Keyword_Ext_char16_t: + case Keyword_Ext_char32_t: + case Keyword_Ext_wchar_t: + case Keyword_struct: + case Keyword_union: + case Keyword_enum: + case Keyword_ExtGNU___complex__: + if (!parseDeclarationStatement( + forStmt->initStmt_, + &Parser::parseDeclarationOrFunctionDefinition)) { + skipTo(CloseParenToken); + return false; } - - if (peek().kind() == Keyword_ExtGNU___extension__) - forStmt->extKwTkIdx_ = consume(); - - switch (peek().kind()) { - // storage-class-specifier - case Keyword_typedef: - case Keyword_extern: - case Keyword_static: - case Keyword_auto: - case Keyword_register: - case Keyword__Thread_local: - case Keyword_ExtGNU___thread: - - // type-qualifier - case Keyword_const: - case Keyword_volatile: - case Keyword_restrict: - case Keyword__Atomic: - - // function-specifier - case Keyword_inline: - case Keyword__Noreturn: - - // type-specifier - case Keyword_void: - case Keyword_char: - case Keyword_short: - case Keyword_int: - case Keyword_long: - case Keyword_float: - case Keyword_double: - case Keyword__Bool: - case Keyword__Complex: - case Keyword_signed: - case Keyword_unsigned: - case Keyword_Ext_char16_t: - case Keyword_Ext_char32_t: - case Keyword_Ext_wchar_t: - case Keyword_struct: - case Keyword_union: - case Keyword_enum: - case Keyword_ExtGNU___complex__: - if (!parseDeclarationStatement( - forStmt->initStmt_, - &Parser::parseDeclarationOrFunctionDefinition)) { - skipTo(CloseParenToken); - return false; - } - break; - - case IdentifierToken: { - Backtracker BT(this); - if (!parseExpressionStatement(forStmt->initStmt_)) { - BT.backtrack(); - if (parseDeclarationStatement( - forStmt->initStmt_, - &Parser::parseDeclarationOrFunctionDefinition)) { - break; - } - skipTo(CloseParenToken); - return false; - } - maybeAmbiguateStatement(forStmt->initStmt_); - break; - } - - default: - if (!parseExpressionStatement(forStmt->initStmt_)) { - skipTo(CloseParenToken); - return false; - } + break; + + case IdentifierToken: { + Backtracker BT(this); + if (!parseExpressionStatement(forStmt->initStmt_)) { + BT.backtrack(); + if (parseDeclarationStatement( + forStmt->initStmt_, + &Parser::parseDeclarationOrFunctionDefinition)) { + break; + } + skipTo(CloseParenToken); + return false; } - - if (peek().kind() != SemicolonToken - && !parseExpression(forStmt->cond_)) { - skipTo(CloseParenToken); - return false; + maybeAmbiguateStatement(forStmt->initStmt_); + break; + } + + default: + if (!parseExpressionStatement(forStmt->initStmt_)) { + skipTo(CloseParenToken); + return false; } - - forStmt->semicolonTkIdx_ = consume(); - if (peek().kind() == CloseParenToken) - forStmt->closeParenTkIdx_ = consume(); - else if (!(parseExpression(forStmt->expr_) - && match(CloseParenToken, &forStmt->closeParenTkIdx_))) { - skipTo(CloseParenToken); - return false; - } - - return checkStatementParse( - parseStatement(forStmt->stmt_, - stmtCtx + StatementContext::Loop)); + } + + if (peek().kind() != SemicolonToken && !parseExpression(forStmt->cond_)) { + skipTo(CloseParenToken); + return false; + } + + forStmt->semicolonTkIdx_ = consume(); + if (peek().kind() == CloseParenToken) + forStmt->closeParenTkIdx_ = consume(); + else if (!(parseExpression(forStmt->expr_) && + match(CloseParenToken, &forStmt->closeParenTkIdx_))) { + skipTo(CloseParenToken); + return false; + } + + return checkStatementParse( + parseStatement(forStmt->stmt_, stmtCtx + StatementContext::Loop)); } /** @@ -643,26 +610,23 @@ bool Parser::parseForStatement_AtFirst(StatementSyntax*& stmt, * * \remark 6.8.6.1 */ -bool Parser::parseGotoStatement_AtFirst(StatementSyntax*& stmt) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_goto, - return false, - "assert failure: `goto'"); - - auto gotoStmt = makeNode(); - stmt = gotoStmt; - gotoStmt->gotoKwTkIdx_ = consume(); - - if (peek().kind() != IdentifierToken) { - diagReporter_.ExpectedTokenOfCategoryIdentifier(); - return ignoreStatement(); - } +bool Parser::parseGotoStatement_AtFirst(StatementSyntax *&stmt) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_goto, return false, + "assert failure: `goto'"); + + auto gotoStmt = makeNode(); + stmt = gotoStmt; + gotoStmt->gotoKwTkIdx_ = consume(); + + if (peek().kind() != IdentifierToken) { + diagReporter_.ExpectedTokenOfCategoryIdentifier(); + return ignoreStatement(); + } - gotoStmt->identTkIdx_ = consume(); + gotoStmt->identTkIdx_ = consume(); - return checkStatementParse( - match(SemicolonToken, &gotoStmt->semicolonTkIdx_)); + return checkStatementParse(match(SemicolonToken, &gotoStmt->semicolonTkIdx_)); } /** @@ -671,20 +635,18 @@ bool Parser::parseGotoStatement_AtFirst(StatementSyntax*& stmt) * * \remark 6.8.6.2 */ -bool Parser::parseContinueStatement_AtFirst(StatementSyntax*& stmt, - StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_continue, - return false, - "assert failure: `continue'"); - - auto continueStmt = makeNode(); - stmt = continueStmt; - continueStmt->continueKwTkIdx_ = consume(); - - return checkStatementParse( - match(SemicolonToken, &continueStmt->semicolonTkIdx_)); +bool Parser::parseContinueStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_continue, return false, + "assert failure: `continue'"); + + auto continueStmt = makeNode(); + stmt = continueStmt; + continueStmt->continueKwTkIdx_ = consume(); + + return checkStatementParse( + match(SemicolonToken, &continueStmt->semicolonTkIdx_)); } /** @@ -693,20 +655,18 @@ bool Parser::parseContinueStatement_AtFirst(StatementSyntax*& stmt, * * \remark 6.8.6.3 */ -bool Parser::parseBreakStatement_AtFirst(StatementSyntax*& stmt, - StatementContext stmtCtx) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_break, - return false, - "assert failure: `break'"); - - auto breakStmt = makeNode(); - stmt = breakStmt; - breakStmt->breakKwTkIdx_ = consume(); - - return checkStatementParse( - match(SemicolonToken, &breakStmt->semicolonTkIdx_)); +bool Parser::parseBreakStatement_AtFirst(StatementSyntax *&stmt, + StatementContext stmtCtx) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_break, return false, + "assert failure: `break'"); + + auto breakStmt = makeNode(); + stmt = breakStmt; + breakStmt->breakKwTkIdx_ = consume(); + + return checkStatementParse( + match(SemicolonToken, &breakStmt->semicolonTkIdx_)); } /** @@ -715,22 +675,20 @@ bool Parser::parseBreakStatement_AtFirst(StatementSyntax*& stmt, * * \remark 6.8.6.4 */ -bool Parser::parseReturnStatement_AtFirst(StatementSyntax*& stmt) -{ - DEBUG_THIS_RULE(); +bool Parser::parseReturnStatement_AtFirst(StatementSyntax *&stmt) { + DEBUG_THIS_RULE(); - auto retStmt = makeNode(); - stmt = retStmt; - retStmt->returnKwTkIdx_ = consume(); + auto retStmt = makeNode(); + stmt = retStmt; + retStmt->returnKwTkIdx_ = consume(); - if (peek().kind() == SemicolonToken) { - retStmt->semicolonTkIdx_ = consume(); - return true; - } + if (peek().kind() == SemicolonToken) { + retStmt->semicolonTkIdx_ = consume(); + return true; + } - return checkStatementParse( - parseExpression(retStmt->expr_) - && match(SemicolonToken, &retStmt->semicolonTkIdx_)); + return checkStatementParse(parseExpression(retStmt->expr_) && + match(SemicolonToken, &retStmt->semicolonTkIdx_)); } /** @@ -738,216 +696,198 @@ bool Parser::parseReturnStatement_AtFirst(StatementSyntax*& stmt) * * \remark J.5.10. * - * \see https://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html#Using-Assembly-Language-with-C + * \see + * https://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html#Using-Assembly-Language-with-C */ -bool Parser::parseExtGNU_AsmStatement(StatementSyntax*& stmt) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___asm__, - return false, - "assert failure: `asm'"); - - if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_Asm()) - diagReporter_.ExpectedFeature("GNU asm"); - - auto asmStmt = makeNode(); - stmt = asmStmt; - asmStmt->asmKwTkIdx_ = consume(); - - parseExtGNU_AsmQualifiers(asmStmt->asmQuals_); - - if (!(match(OpenParenToken, &asmStmt->openParenTkIdx_) - && parseStringLiteral(asmStmt->strLit_))) { - return ignoreStatement(); +bool Parser::parseExtGNU_AsmStatement(StatementSyntax *&stmt) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == Keyword_ExtGNU___asm__, return false, + "assert failure: `asm'"); + + if (!tree_->parseOptions().extensions().isEnabled_ExtGNU_Asm()) + diagReporter_.ExpectedFeature("GNU asm"); + + auto asmStmt = makeNode(); + stmt = asmStmt; + asmStmt->asmKwTkIdx_ = consume(); + + parseExtGNU_AsmQualifiers(asmStmt->asmQuals_); + + if (!(match(OpenParenToken, &asmStmt->openParenTkIdx_) && + parseStringLiteral(asmStmt->strLit_))) { + return ignoreStatement(); + } + + if (peek().kind() == ColonToken) { + asmStmt->colon1TkIdx_ = consume(); + if ((peek().kind() == StringLiteralToken || + peek().kind() == OpenBracketToken) && + !parseCommaSeparatedItems( + asmStmt->outOprds_, + &Parser::parseExtGNU_AsmOutputOperand_AtFirst)) { + return ignoreStatement(); } - - if (peek().kind() == ColonToken) { - asmStmt->colon1TkIdx_ = consume(); - if ((peek().kind() == StringLiteralToken - || peek().kind() == OpenBracketToken) - && !parseCommaSeparatedItems( - asmStmt->outOprds_, - &Parser::parseExtGNU_AsmOutputOperand_AtFirst)) { - return ignoreStatement(); - } + } + + if (peek().kind() == ColonToken) { + asmStmt->colon2TkIdx_ = consume(); + if ((peek().kind() == StringLiteralToken || + peek().kind() == OpenBracketToken) && + !parseCommaSeparatedItems( + asmStmt->inOprds_, &Parser::parseExtGNU_AsmInputOperand_AtFirst)) { + return ignoreStatement(); } + } + + if (peek().kind() == ColonToken) { + asmStmt->colon3TkIdx_ = consume(); + if (!parseExtGNU_AsmClobbers(asmStmt->clobs_)) + return ignoreStatement(); + } + + if (peek().kind() == ColonToken) { + asmStmt->colon4TkIdx_ = consume(); + if (!parseExtGNU_AsmGotoLabels(asmStmt->labels_)) + return ignoreStatement(); + } + + return checkStatementParse( + match(CloseParenToken, &asmStmt->closeParenTkIdx_) && + match(SemicolonToken, &asmStmt->semicolonTkIdx_)); +} - if (peek().kind() == ColonToken) { - asmStmt->colon2TkIdx_ = consume(); - if ((peek().kind() == StringLiteralToken - || peek().kind() == OpenBracketToken) - && !parseCommaSeparatedItems( - asmStmt->inOprds_, - &Parser::parseExtGNU_AsmInputOperand_AtFirst)) { - return ignoreStatement(); - } - } +void Parser::parseExtGNU_AsmQualifiers(SpecifierListSyntax *&specList) { + DEBUG_THIS_RULE(); - if (peek().kind() == ColonToken) { - asmStmt->colon3TkIdx_ = consume(); - if (!parseExtGNU_AsmClobbers(asmStmt->clobs_)) - return ignoreStatement(); - } + SpecifierListSyntax **qualsList_cur = &specList; - if (peek().kind() == ColonToken) { - asmStmt->colon4TkIdx_ = consume(); - if (!parseExtGNU_AsmGotoLabels(asmStmt->labels_)) - return ignoreStatement(); + while (true) { + SpecifierSyntax *qual = nullptr; + switch (peek().kind()) { + case Keyword_volatile: + parseTrivialSpecifier_AtFirst( + qual, ExtGNU_AsmVolatileQualifier); + break; + + case Keyword_inline: + parseTrivialSpecifier_AtFirst( + qual, ExtGNU_AsmInlineQualifier); + break; + + case Keyword_goto: + parseTrivialSpecifier_AtFirst( + qual, ExtGNU_AsmGotoQualifier); + break; + + default: + return; } - return checkStatementParse( - match(CloseParenToken, &asmStmt->closeParenTkIdx_) - && match(SemicolonToken, &asmStmt->semicolonTkIdx_)); -} - -void Parser::parseExtGNU_AsmQualifiers(SpecifierListSyntax*& specList) -{ - DEBUG_THIS_RULE(); - - SpecifierListSyntax** qualsList_cur = &specList; - - while (true) { - SpecifierSyntax* qual = nullptr; - switch (peek().kind()) { - case Keyword_volatile: - parseTrivialSpecifier_AtFirst( - qual, - ExtGNU_AsmVolatileQualifier); - break; - - case Keyword_inline: - parseTrivialSpecifier_AtFirst( - qual, - ExtGNU_AsmInlineQualifier); - break; - - case Keyword_goto: - parseTrivialSpecifier_AtFirst( - qual, - ExtGNU_AsmGotoQualifier); - break; - - default: - return; - } - - *qualsList_cur = makeNode(qual); - qualsList_cur = &(*qualsList_cur)->next; - } + *qualsList_cur = makeNode(qual); + qualsList_cur = &(*qualsList_cur)->next; + } } -bool Parser::parseExtGNU_AsmOutputOperand_AtFirst(ExtGNU_AsmOperandSyntax*& asmOprd, - ExtGNU_AsmOperandListSyntax*&) -{ - return parseExtGNU_AsmOperand_AtFirst(asmOprd, ExtGNU_AsmOutputOperand); +bool Parser::parseExtGNU_AsmOutputOperand_AtFirst( + ExtGNU_AsmOperandSyntax *&asmOprd, ExtGNU_AsmOperandListSyntax *&) { + return parseExtGNU_AsmOperand_AtFirst(asmOprd, ExtGNU_AsmOutputOperand); } -bool Parser::parseExtGNU_AsmInputOperand_AtFirst(ExtGNU_AsmOperandSyntax*& asmOprd, - ExtGNU_AsmOperandListSyntax*&) -{ - return parseExtGNU_AsmOperand_AtFirst(asmOprd, ExtGNU_AsmInputOperand); +bool Parser::parseExtGNU_AsmInputOperand_AtFirst( + ExtGNU_AsmOperandSyntax *&asmOprd, ExtGNU_AsmOperandListSyntax *&) { + return parseExtGNU_AsmOperand_AtFirst(asmOprd, ExtGNU_AsmInputOperand); } -bool Parser::parseExtGNU_AsmOperand_AtFirst(ExtGNU_AsmOperandSyntax*& asmOprd, - SyntaxKind oprdK) -{ - DEBUG_THIS_RULE(); - PSY_ASSERT_W_MSG(peek().kind() == StringLiteralToken - || peek().kind() == OpenBracketToken, - return false, - "assert failure: `[' or `'"); - - auto oprd = makeNode(oprdK); - asmOprd = oprd; - - if (peek().kind() == OpenBracketToken) { - oprd->openBracketTkIdx_ = consume(); - if (!(parseIdentifierName(oprd->identExpr_) - && match(CloseBracketToken, &oprd->closeBracketTkIdx_))) - return false; - } - - return parseStringLiteral(oprd->strLit_) - && match(OpenParenToken, &oprd->openParenTkIdx_) - && parseExpression(oprd->expr_) - && match(CloseParenToken, &oprd->closeParenTkIdx_); +bool Parser::parseExtGNU_AsmOperand_AtFirst(ExtGNU_AsmOperandSyntax *&asmOprd, + SyntaxKind oprdK) { + DEBUG_THIS_RULE(); + PSY_ASSERT_W_MSG(peek().kind() == StringLiteralToken || + peek().kind() == OpenBracketToken, + return false, "assert failure: `[' or `'"); + + auto oprd = makeNode(oprdK); + asmOprd = oprd; + + if (peek().kind() == OpenBracketToken) { + oprd->openBracketTkIdx_ = consume(); + if (!(parseIdentifierName(oprd->identExpr_) && + match(CloseBracketToken, &oprd->closeBracketTkIdx_))) + return false; + } + + return parseStringLiteral(oprd->strLit_) && + match(OpenParenToken, &oprd->openParenTkIdx_) && + parseExpression(oprd->expr_) && + match(CloseParenToken, &oprd->closeParenTkIdx_); } -bool Parser::parseExtGNU_AsmClobbers(ExpressionListSyntax*& clobList) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExtGNU_AsmClobbers(ExpressionListSyntax *&clobList) { + DEBUG_THIS_RULE(); - if (peek().kind() != StringLiteralToken) - return true; + if (peek().kind() != StringLiteralToken) + return true; - return parseCommaSeparatedItems( - clobList, - &Parser::parseExtGNU_AsmClobber_AtFirst); + return parseCommaSeparatedItems( + clobList, &Parser::parseExtGNU_AsmClobber_AtFirst); } -bool Parser::parseExtGNU_AsmClobber_AtFirst(ExpressionSyntax*& clob, ExpressionListSyntax*&) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExtGNU_AsmClobber_AtFirst(ExpressionSyntax *&clob, + ExpressionListSyntax *&) { + DEBUG_THIS_RULE(); - return parseStringLiteral(clob); + return parseStringLiteral(clob); } -bool Parser::parseExtGNU_AsmGotoLabels(ExpressionListSyntax*& labelList) -{ - DEBUG_THIS_RULE(); - - if (peek().kind() != IdentifierToken) - return true; +bool Parser::parseExtGNU_AsmGotoLabels(ExpressionListSyntax *&labelList) { + DEBUG_THIS_RULE(); - return parseCommaSeparatedItems( - labelList, - &Parser::parseExtGNU_AsmGotoLabel_AtFirst); + if (peek().kind() != IdentifierToken) + return true; + return parseCommaSeparatedItems( + labelList, &Parser::parseExtGNU_AsmGotoLabel_AtFirst); } -bool Parser::parseExtGNU_AsmGotoLabel_AtFirst(ExpressionSyntax*& label, - ExpressionListSyntax*&) -{ - DEBUG_THIS_RULE(); +bool Parser::parseExtGNU_AsmGotoLabel_AtFirst(ExpressionSyntax *&label, + ExpressionListSyntax *&) { + DEBUG_THIS_RULE(); - parseIdentifierName_AtFirst(label); - return true; + parseIdentifierName_AtFirst(label); + return true; } -bool Parser::checkStatementParse(bool stmtParsed) -{ - if (!stmtParsed) - return ignoreStatement(); - return true; +bool Parser::checkStatementParse(bool stmtParsed) { + if (!stmtParsed) + return ignoreStatement(); + return true; } namespace psy { namespace C { Parser::StatementContext operator+(Parser::StatementContext a, - Parser::StatementContext b) -{ - switch (a) { - case Parser::StatementContext::None: - return b; - - case Parser::StatementContext::Switch: - if (b == Parser::StatementContext::Loop) - return Parser::StatementContext::SwitchAndLoop; - return a; - - case Parser::StatementContext::Loop: - if (b == Parser::StatementContext::Switch) - return Parser::StatementContext::SwitchAndLoop; - return a; - - case Parser::StatementContext::SwitchAndLoop: - return a; - - default: - PSY_ASSERT_W_MSG(false, return Parser::StatementContext::None, ""); - } + Parser::StatementContext b) { + switch (a) { + case Parser::StatementContext::None: + return b; + + case Parser::StatementContext::Switch: + if (b == Parser::StatementContext::Loop) + return Parser::StatementContext::SwitchAndLoop; + return a; + + case Parser::StatementContext::Loop: + if (b == Parser::StatementContext::Switch) + return Parser::StatementContext::SwitchAndLoop; + return a; + + case Parser::StatementContext::SwitchAndLoop: + return a; + + default: + PSY_ASSERT_W_MSG(false, return Parser::StatementContext::None, ""); + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/parser/TextCompleteness.h b/C/parser/TextCompleteness.h index d9dd8982e..03c3ce74e 100644 --- a/C/parser/TextCompleteness.h +++ b/C/parser/TextCompleteness.h @@ -31,15 +31,13 @@ namespace C { /** * \brief The alternatives for the TextCompleteness of the parsed text. */ -enum class PSY_C_API TextCompleteness : std::uint8_t -{ - Unknown, - Full, - Fragment +enum class PSY_C_API TextCompleteness : std::uint8_t { + Unknown, + Full, + Fragment }; -} // C -} // psy +} // namespace C +} // namespace psy #endif - diff --git a/C/parser/TextPreprocessingState.h b/C/parser/TextPreprocessingState.h index 2ac4f0bb7..b208dc3d7 100644 --- a/C/parser/TextPreprocessingState.h +++ b/C/parser/TextPreprocessingState.h @@ -31,15 +31,13 @@ namespace C { /** * \brief The alternatives for the TextPreprocessingState of the parsed text. */ -enum class PSY_C_API TextPreprocessingState : std::uint8_t -{ - Unknown, - Preprocessed, - Unpreprocessed +enum class PSY_C_API TextPreprocessingState : std::uint8_t { + Unknown, + Preprocessed, + Unpreprocessed }; -} // C -} // psy +} // namespace C +} // namespace psy #endif - diff --git a/C/parser/Unparser.cpp b/C/parser/Unparser.cpp index 5b4bbf0da..60d3e2411 100644 --- a/C/parser/Unparser.cpp +++ b/C/parser/Unparser.cpp @@ -30,23 +30,20 @@ using namespace psy; using namespace C; -void Unparser::unparse(const SyntaxNode* node, std::ostream& os) -{ - os_ = &os; - visit(node); +void Unparser::unparse(const SyntaxNode *node, std::ostream &os) { + os_ = &os; + visit(node); } -void Unparser::terminal(const SyntaxToken& tk, const SyntaxNode*) -{ - if (tk.kind() == EndOfFile) - return; +void Unparser::terminal(const SyntaxToken &tk, const SyntaxNode *) { + if (tk.kind() == EndOfFile) + return; - *os_ << tk.valueText_c_str(); + *os_ << tk.valueText_c_str(); - if (tk.kind() == CloseBraceToken - || tk.kind() == OpenBraceToken - || tk.kind() == SemicolonToken) - *os_ << "\n"; - else - *os_ << " "; + if (tk.kind() == CloseBraceToken || tk.kind() == OpenBraceToken || + tk.kind() == SemicolonToken) + *os_ << "\n"; + else + *os_ << " "; } diff --git a/C/parser/Unparser.h b/C/parser/Unparser.h index 15d3b9f55..fb7fb6405 100644 --- a/C/parser/Unparser.h +++ b/C/parser/Unparser.h @@ -30,20 +30,19 @@ namespace psy { namespace C { -class PSY_C_NON_API Unparser : public SyntaxDumper -{ +class PSY_C_NON_API Unparser : public SyntaxDumper { public: - using SyntaxDumper::SyntaxDumper; + using SyntaxDumper::SyntaxDumper; - void unparse(const SyntaxNode* node, std::ostream& os); + void unparse(const SyntaxNode *node, std::ostream &os); protected: - void terminal(const SyntaxToken& tk, const SyntaxNode* node) override; + void terminal(const SyntaxToken &tk, const SyntaxNode *node) override; - std::ostream* os_; + std::ostream *os_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/plugin-api/DeclarationInterceptor.h b/C/plugin-api/DeclarationInterceptor.h index 28ec704ed..c66926cf4 100644 --- a/C/plugin-api/DeclarationInterceptor.h +++ b/C/plugin-api/DeclarationInterceptor.h @@ -21,22 +21,21 @@ #ifndef PSYCHE_C_DECLARATION_INTERCEPTOR_H__ #define PSYCHE_C_DECLARATION_INTERCEPTOR_H__ -#include "PluginConfig.h" #include "Fwds.h" +#include "PluginConfig.h" namespace psy { namespace C { -class PLUGIN_API DeclarationInterceptor -{ +class PLUGIN_API DeclarationInterceptor { public: - virtual ~DeclarationInterceptor() = default; + virtual ~DeclarationInterceptor() = default; - virtual bool intercept(DeclaratorDeclarationSyntax*) { return false; } - virtual bool intercept(FunctionDefinitionSyntax*) { return false; } + virtual bool intercept(DeclaratorDeclarationSyntax *) { return false; } + virtual bool intercept(FunctionDefinitionSyntax *) { return false; } }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/plugin-api/PluginConfig.h b/C/plugin-api/PluginConfig.h index 6b9e358d3..08ce238bc 100644 --- a/C/plugin-api/PluginConfig.h +++ b/C/plugin-api/PluginConfig.h @@ -23,28 +23,28 @@ // From https://gcc.gnu.org/wiki/Visibility #if defined _WIN32 || defined __CYGWIN__ - #ifdef EXPORT_PLUGIN_API - #ifdef __GNUC__ - #define PLUGIN_API __attribute__ ((dllexport)) - #else - #define PLUGIN_API __declspec(dllexport) - #endif - #else - #ifdef __GNUC__ - #define PLUGIN_API __attribute__ ((dllimport)) - #else - #define PLUGIN_API __declspec(dllimport) - #endif - #endif - #define PLUGIN_API_LOCAL +#ifdef EXPORT_PLUGIN_API +#ifdef __GNUC__ +#define PLUGIN_API __attribute__((dllexport)) #else - #if __GNUC__ >= 4 - #define PLUGIN_API __attribute__ ((visibility ("default"))) - #define PLUGIN_API_LOCAL __attribute__ ((visibility ("hidden"))) - #else - #define PLUGIN_API - #define PLUGIN_API_LOCAL - #endif +#define PLUGIN_API __declspec(dllexport) +#endif +#else +#ifdef __GNUC__ +#define PLUGIN_API __attribute__((dllimport)) +#else +#define PLUGIN_API __declspec(dllimport) +#endif +#endif +#define PLUGIN_API_LOCAL +#else +#if __GNUC__ >= 4 +#define PLUGIN_API __attribute__((visibility("default"))) +#define PLUGIN_API_LOCAL __attribute__((visibility("hidden"))) +#else +#define PLUGIN_API +#define PLUGIN_API_LOCAL +#endif #endif #endif diff --git a/C/plugin-api/SourceInspector.h b/C/plugin-api/SourceInspector.h index af752e74d..080625ba1 100644 --- a/C/plugin-api/SourceInspector.h +++ b/C/plugin-api/SourceInspector.h @@ -21,8 +21,8 @@ #ifndef PSYCHE_C_SOURCE_INSPECTOR_H__ #define PSYCHE_C_SOURCE_INSPECTOR_H__ -#include "PluginConfig.h" #include "Fwds.h" +#include "PluginConfig.h" #include #include @@ -30,15 +30,15 @@ namespace psy { namespace C { -class PLUGIN_API SourceInspector -{ +class PLUGIN_API SourceInspector { public: - virtual ~SourceInspector() = default; + virtual ~SourceInspector() = default; - virtual std::vector detectRequiredHeaders(const std::string&) = 0; + virtual std::vector + detectRequiredHeaders(const std::string &) = 0; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/reparser/Disambiguator.cpp b/C/reparser/Disambiguator.cpp index 5cafa7974..ba6b3a12e 100644 --- a/C/reparser/Disambiguator.cpp +++ b/C/reparser/Disambiguator.cpp @@ -28,430 +28,424 @@ using namespace psy; using namespace C; -Disambiguator::~Disambiguator() -{} +Disambiguator::~Disambiguator() {} -Disambiguator::Disambiguator(SyntaxTree* tree) - : SyntaxVisitor(tree) - , pendingAmbigs_(0) -{} +Disambiguator::Disambiguator(SyntaxTree *tree) + : SyntaxVisitor(tree), pendingAmbigs_(0) {} -unsigned int Disambiguator::disambiguate() -{ - visit(tree_->root()); +unsigned int Disambiguator::disambiguate() { + visit(tree_->root()); - return pendingAmbigs_; + return pendingAmbigs_; } template -SyntaxVisitor::Action Disambiguator::visitMaybeAmbiguousExpression(ExprT* const& node) -{ - ExprT*& node_P = const_cast(node); - switch (node->kind()) { - case AmbiguousCastOrBinaryExpression: { - auto ambigNode = node->asAmbiguousCastOrBinaryExpression(); - auto disambig = disambiguateExpression(ambigNode); - switch (disambig) { - case Disambiguation::KeepCastExpression: - node_P = ambigNode->castExpr_; - visit(node_P); - break; - - case Disambiguation::KeepExpressionStatement: - node_P = ambigNode->binExpr_; - visit(node_P); - break; - - case Disambiguation::Inconclusive: - ++pendingAmbigs_; - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Skip); - } - break; - } - - default: - visit(node); - break; +SyntaxVisitor::Action +Disambiguator::visitMaybeAmbiguousExpression(ExprT *const &node) { + ExprT *&node_P = const_cast(node); + switch (node->kind()) { + case AmbiguousCastOrBinaryExpression: { + auto ambigNode = node->asAmbiguousCastOrBinaryExpression(); + auto disambig = disambiguateExpression(ambigNode); + switch (disambig) { + case Disambiguation::KeepCastExpression: + node_P = ambigNode->castExpr_; + visit(node_P); + break; + + case Disambiguation::KeepExpressionStatement: + node_P = ambigNode->binExpr_; + visit(node_P); + break; + + case Disambiguation::Inconclusive: + ++pendingAmbigs_; + break; + + default: + PSY_ESCAPE_VIA_RETURN(Action::Skip); } + break; + } - return Action::Skip; + default: + visit(node); + break; + } + + return Action::Skip; } template -SyntaxVisitor::Action Disambiguator::visitMaybeAmbiguousStatement(StmtT* const& node) -{ - StmtT*& node_P = const_cast(node); - switch (node->kind()) { - case AmbiguousMultiplicationOrPointerDeclaration: - case AmbiguousCallOrVariableDeclaration: { - auto ambigNode = node->asAmbiguousExpressionOrDeclarationStatement(); - auto disambig = disambiguateStatement(ambigNode); - switch (disambig) { - case Disambiguation::KeepDeclarationStatement: - node_P = ambigNode->declStmt_; - visit(node_P); - break; - - case Disambiguation::KeepExpressionStatement: - node_P = ambigNode->exprStmt_; - visit(node_P); - break; - - case Disambiguation::Inconclusive: - ++pendingAmbigs_; - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Skip); - } - break; - } - - default: - visit(node); - break; +SyntaxVisitor::Action +Disambiguator::visitMaybeAmbiguousStatement(StmtT *const &node) { + StmtT *&node_P = const_cast(node); + switch (node->kind()) { + case AmbiguousMultiplicationOrPointerDeclaration: + case AmbiguousCallOrVariableDeclaration: { + auto ambigNode = node->asAmbiguousExpressionOrDeclarationStatement(); + auto disambig = disambiguateStatement(ambigNode); + switch (disambig) { + case Disambiguation::KeepDeclarationStatement: + node_P = ambigNode->declStmt_; + visit(node_P); + break; + + case Disambiguation::KeepExpressionStatement: + node_P = ambigNode->exprStmt_; + visit(node_P); + break; + + case Disambiguation::Inconclusive: + ++pendingAmbigs_; + break; + + default: + PSY_ESCAPE_VIA_RETURN(Action::Skip); } + break; + } + + default: + visit(node); + break; + } - return Action::Skip; + return Action::Skip; } template -SyntaxVisitor::Action Disambiguator::visitMaybeAmbiguousTypeReference(TypeRefT* const& node) -{ - TypeRefT*& node_P = const_cast(node); - switch (node->kind()) { - case AmbiguousTypeNameOrExpressionAsTypeReference: { - auto ambigNode = node->asAmbiguousTypeNameOrExpressionAsTypeReference(); - auto disambig = disambiguateTypeReference(ambigNode); - switch (disambig) { - case Disambiguation::KeepTypeName: - node_P = ambigNode->tyNameAsTyRef_; - visit(node_P); - break; - - case Disambiguation::KeepExpressionStatement: - node_P = ambigNode->exprAsTyRef_; - visit(node_P); - break; - - case Disambiguation::Inconclusive: - ++pendingAmbigs_; - break; - - default: - PSY_ESCAPE_VIA_RETURN(Action::Skip); - } - break; - } - - default: - visit(node); - break; +SyntaxVisitor::Action +Disambiguator::visitMaybeAmbiguousTypeReference(TypeRefT *const &node) { + TypeRefT *&node_P = const_cast(node); + switch (node->kind()) { + case AmbiguousTypeNameOrExpressionAsTypeReference: { + auto ambigNode = node->asAmbiguousTypeNameOrExpressionAsTypeReference(); + auto disambig = disambiguateTypeReference(ambigNode); + switch (disambig) { + case Disambiguation::KeepTypeName: + node_P = ambigNode->tyNameAsTyRef_; + visit(node_P); + break; + + case Disambiguation::KeepExpressionStatement: + node_P = ambigNode->exprAsTyRef_; + visit(node_P); + break; + + case Disambiguation::Inconclusive: + ++pendingAmbigs_; + break; + + default: + PSY_ESCAPE_VIA_RETURN(Action::Skip); } + break; + } + + default: + visit(node); + break; + } - return Action::Skip; + return Action::Skip; } //--------------// // Declarations // //--------------// -SyntaxVisitor::Action Disambiguator::visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitStaticAssertDeclaration( + const StaticAssertDeclarationSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitAlignmentSpecifier(const AlignmentSpecifierSyntax* node) -{ - visitMaybeAmbiguousTypeReference(node->tyRef_); +SyntaxVisitor::Action +Disambiguator::visitAlignmentSpecifier(const AlignmentSpecifierSyntax *node) { + visitMaybeAmbiguousTypeReference(node->tyRef_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitExtGNU_Typeof(const ExtGNU_TypeofSyntax* node) -{ - visitMaybeAmbiguousTypeReference(node->tyRef_); +SyntaxVisitor::Action +Disambiguator::visitExtGNU_Typeof(const ExtGNU_TypeofSyntax *node) { + visitMaybeAmbiguousTypeReference(node->tyRef_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitSubscriptSuffix(const SubscriptSuffixSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action +Disambiguator::visitSubscriptSuffix(const SubscriptSuffixSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitExpressionInitializer(const ExpressionInitializerSyntax* node) -{ - return visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitExpressionInitializer( + const ExpressionInitializerSyntax *node) { + return visitMaybeAmbiguousExpression(node->expr_); } -SyntaxVisitor::Action Disambiguator::visitArrayDesignator(const ArrayDesignatorSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action +Disambiguator::visitArrayDesignator(const ArrayDesignatorSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } //-------------// // Expressions // //-------------// -SyntaxVisitor::Action Disambiguator::visitParenthesizedExpression(const ParenthesizedExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitParenthesizedExpression( + const ParenthesizedExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitGenericSelectionExpression(const GenericSelectionExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); - for (auto it = node->associations(); it; it = it->next) - visit(it->value); +SyntaxVisitor::Action Disambiguator::visitGenericSelectionExpression( + const GenericSelectionExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); + for (auto it = node->associations(); it; it = it->next) + visit(it->value); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitGenericAssociation(const GenericAssociationSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action +Disambiguator::visitGenericAssociation(const GenericAssociationSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitExtGNU_EnclosedCompoundStatementExpression( - const ExtGNU_EnclosedCompoundStatementExpressionSyntax* node) -{ - visit(node->stmt_); +SyntaxVisitor::Action +Disambiguator::visitExtGNU_EnclosedCompoundStatementExpression( + const ExtGNU_EnclosedCompoundStatementExpressionSyntax *node) { + visit(node->stmt_); - return Action::Skip; + return Action::Skip; } SyntaxVisitor::Action Disambiguator::visitExtGNU_ComplexValuedExpression( - const ExtGNU_ComplexValuedExpressionSyntax* node) -{ - return Action::Skip; + const ExtGNU_ComplexValuedExpressionSyntax *node) { + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitPrefixUnaryExpression(const PrefixUnaryExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitPrefixUnaryExpression( + const PrefixUnaryExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitPostfixUnaryExpression(const PostfixUnaryExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitPostfixUnaryExpression( + const PostfixUnaryExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitMemberAccessExpression(const MemberAccessExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitMemberAccessExpression( + const MemberAccessExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitArraySubscriptExpression(const ArraySubscriptExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitArraySubscriptExpression( + const ArraySubscriptExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitTypeTraitExpression(const TypeTraitExpressionSyntax* node) -{ - return visitMaybeAmbiguousTypeReference(node->tyRef_); +SyntaxVisitor::Action +Disambiguator::visitTypeTraitExpression(const TypeTraitExpressionSyntax *node) { + return visitMaybeAmbiguousTypeReference(node->tyRef_); } -SyntaxVisitor::Action Disambiguator::visitCastExpression(const CastExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action +Disambiguator::visitCastExpression(const CastExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitCallExpression(const CallExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action +Disambiguator::visitCallExpression(const CallExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitVAArgumentExpression(const VAArgumentExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitVAArgumentExpression( + const VAArgumentExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitBinaryExpression(const BinaryExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->leftExpr_); - visitMaybeAmbiguousExpression(node->rightExpr_); +SyntaxVisitor::Action +Disambiguator::visitBinaryExpression(const BinaryExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->leftExpr_); + visitMaybeAmbiguousExpression(node->rightExpr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitConditionalExpression(const ConditionalExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->condExpr_); - visitMaybeAmbiguousExpression(node->whenTrueExpr_); - visitMaybeAmbiguousExpression(node->whenFalseExpr_); +SyntaxVisitor::Action Disambiguator::visitConditionalExpression( + const ConditionalExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->condExpr_); + visitMaybeAmbiguousExpression(node->whenTrueExpr_); + visitMaybeAmbiguousExpression(node->whenFalseExpr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitAssignmentExpression(const AssignmentExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->leftExpr_); - visitMaybeAmbiguousExpression(node->rightExpr_); +SyntaxVisitor::Action Disambiguator::visitAssignmentExpression( + const AssignmentExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->leftExpr_); + visitMaybeAmbiguousExpression(node->rightExpr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitSequencingExpression(const SequencingExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->leftExpr_); - visitMaybeAmbiguousExpression(node->rightExpr_); +SyntaxVisitor::Action Disambiguator::visitSequencingExpression( + const SequencingExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->leftExpr_); + visitMaybeAmbiguousExpression(node->rightExpr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitExtGNU_ChooseExpression(const ExtGNU_ChooseExpressionSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr1_); - visitMaybeAmbiguousExpression(node->expr2_); +SyntaxVisitor::Action Disambiguator::visitExtGNU_ChooseExpression( + const ExtGNU_ChooseExpressionSyntax *node) { + visitMaybeAmbiguousExpression(node->expr1_); + visitMaybeAmbiguousExpression(node->expr2_); - return Action::Skip; + return Action::Skip; } //------------// // Statements // //------------// -SyntaxVisitor::Action Disambiguator::visitCompoundStatement(const CompoundStatementSyntax* node) -{ - for (auto iter = node->stmts_; iter; iter = iter->next) - visitMaybeAmbiguousStatement(iter->value); +SyntaxVisitor::Action +Disambiguator::visitCompoundStatement(const CompoundStatementSyntax *node) { + for (auto iter = node->stmts_; iter; iter = iter->next) + visitMaybeAmbiguousStatement(iter->value); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitDeclarationStatement(const DeclarationStatementSyntax* node) -{ - return Action::Skip; +SyntaxVisitor::Action Disambiguator::visitDeclarationStatement( + const DeclarationStatementSyntax *node) { + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitExpressionStatement(const ExpressionStatementSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action +Disambiguator::visitExpressionStatement(const ExpressionStatementSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitLabeledStatement(const LabeledStatementSyntax* node) -{ - visitMaybeAmbiguousStatement(node->stmt_); +SyntaxVisitor::Action +Disambiguator::visitLabeledStatement(const LabeledStatementSyntax *node) { + visitMaybeAmbiguousStatement(node->stmt_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitIfStatement(const IfStatementSyntax* node) -{ - visitMaybeAmbiguousExpression(node->cond_); - visitMaybeAmbiguousStatement(node->stmt_); - visitMaybeAmbiguousStatement(node->elseStmt_); +SyntaxVisitor::Action +Disambiguator::visitIfStatement(const IfStatementSyntax *node) { + visitMaybeAmbiguousExpression(node->cond_); + visitMaybeAmbiguousStatement(node->stmt_); + visitMaybeAmbiguousStatement(node->elseStmt_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitSwitchStatement(const SwitchStatementSyntax* node) -{ - visitMaybeAmbiguousExpression(node->cond_); - visitMaybeAmbiguousStatement(node->stmt_); +SyntaxVisitor::Action +Disambiguator::visitSwitchStatement(const SwitchStatementSyntax *node) { + visitMaybeAmbiguousExpression(node->cond_); + visitMaybeAmbiguousStatement(node->stmt_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitWhileStatement(const WhileStatementSyntax* node) -{ - visitMaybeAmbiguousExpression(node->cond_); - visitMaybeAmbiguousStatement(node->stmt_); +SyntaxVisitor::Action +Disambiguator::visitWhileStatement(const WhileStatementSyntax *node) { + visitMaybeAmbiguousExpression(node->cond_); + visitMaybeAmbiguousStatement(node->stmt_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitDoStatement(const DoStatementSyntax* node) -{ - visitMaybeAmbiguousExpression(node->cond_); - visitMaybeAmbiguousStatement(node->stmt_); +SyntaxVisitor::Action +Disambiguator::visitDoStatement(const DoStatementSyntax *node) { + visitMaybeAmbiguousExpression(node->cond_); + visitMaybeAmbiguousStatement(node->stmt_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitForStatement(const ForStatementSyntax* node) -{ - visit(node->initStmt_); - visitMaybeAmbiguousExpression(node->cond_); - visitMaybeAmbiguousExpression(node->expr_); - visitMaybeAmbiguousStatement(node->stmt_); +SyntaxVisitor::Action +Disambiguator::visitForStatement(const ForStatementSyntax *node) { + visit(node->initStmt_); + visitMaybeAmbiguousExpression(node->cond_); + visitMaybeAmbiguousExpression(node->expr_); + visitMaybeAmbiguousStatement(node->stmt_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitReturnStatement(const ReturnStatementSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action +Disambiguator::visitReturnStatement(const ReturnStatementSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action Disambiguator::visitExtGNU_AsmOperand(const ExtGNU_AsmOperandSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action +Disambiguator::visitExtGNU_AsmOperand(const ExtGNU_AsmOperandSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } //--------// // Common // //--------// -SyntaxVisitor::Action Disambiguator::visitExpressionAsTypeReference(const ExpressionAsTypeReferenceSyntax* node) -{ - visitMaybeAmbiguousExpression(node->expr_); +SyntaxVisitor::Action Disambiguator::visitExpressionAsTypeReference( + const ExpressionAsTypeReferenceSyntax *node) { + visitMaybeAmbiguousExpression(node->expr_); - return Action::Skip; + return Action::Skip; } //-------------// // Ambiguities // //-------------// -SyntaxVisitor::Action Disambiguator::visitAmbiguousTypeNameOrExpressionAsTypeReference( - const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax*) -{ - PSY_ESCAPE_VIA_RETURN(Action::Quit); +SyntaxVisitor::Action +Disambiguator::visitAmbiguousTypeNameOrExpressionAsTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *) { + PSY_ESCAPE_VIA_RETURN(Action::Quit); } SyntaxVisitor::Action Disambiguator::visitAmbiguousCastOrBinaryExpression( - const AmbiguousCastOrBinaryExpressionSyntax*) -{ - PSY_ESCAPE_VIA_RETURN(Action::Quit); + const AmbiguousCastOrBinaryExpressionSyntax *) { + PSY_ESCAPE_VIA_RETURN(Action::Quit); } -SyntaxVisitor::Action Disambiguator::visitAmbiguousExpressionOrDeclarationStatement( - const AmbiguousExpressionOrDeclarationStatementSyntax*) -{ - PSY_ESCAPE_VIA_RETURN(Action::Quit); +SyntaxVisitor::Action +Disambiguator::visitAmbiguousExpressionOrDeclarationStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *) { + PSY_ESCAPE_VIA_RETURN(Action::Quit); } diff --git a/C/reparser/Disambiguator.h b/C/reparser/Disambiguator.h index 04ba4bd85..126fb90e1 100644 --- a/C/reparser/Disambiguator.h +++ b/C/reparser/Disambiguator.h @@ -33,111 +33,127 @@ namespace psy { namespace C { -class PSY_C_NON_API Disambiguator : public SyntaxVisitor -{ +class PSY_C_NON_API Disambiguator : public SyntaxVisitor { public: - virtual ~Disambiguator(); + virtual ~Disambiguator(); -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Reparser); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Reparser); - unsigned int disambiguate(); + unsigned int disambiguate(); -PSY_INTERNAL_AND_EXTENSIBLE: - Disambiguator(SyntaxTree* tree); + PSY_INTERNAL_AND_EXTENSIBLE : Disambiguator(SyntaxTree *tree); - enum class Disambiguation : std::int8_t - { - Inconclusive, - KeepCastExpression, - KeepBinaryExpression, - KeepExpressionStatement, - KeepDeclarationStatement, - KeepTypeName, - KeepExpression, - }; + enum class Disambiguation : std::int8_t { + Inconclusive, + KeepCastExpression, + KeepBinaryExpression, + KeepExpressionStatement, + KeepDeclarationStatement, + KeepTypeName, + KeepExpression, + }; - virtual Disambiguation disambiguateExpression(const AmbiguousCastOrBinaryExpressionSyntax*) const = 0; - virtual Disambiguation disambiguateStatement(const AmbiguousExpressionOrDeclarationStatementSyntax*) const = 0; - virtual Disambiguation disambiguateTypeReference(const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax*) const = 0; + virtual Disambiguation disambiguateExpression( + const AmbiguousCastOrBinaryExpressionSyntax *) const = 0; + virtual Disambiguation disambiguateStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *) const = 0; + virtual Disambiguation disambiguateTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *) const = 0; private: - template Action visitMaybeAmbiguousExpression(ExprT* const&); - template Action visitMaybeAmbiguousStatement(StmtT* const&); - template Action visitMaybeAmbiguousTypeReference(TypeRefT* const&); + template Action visitMaybeAmbiguousExpression(ExprT *const &); + template Action visitMaybeAmbiguousStatement(StmtT *const &); + template + Action visitMaybeAmbiguousTypeReference(TypeRefT *const &); - unsigned int pendingAmbigs_; + unsigned int pendingAmbigs_; protected: - //--------------// - // Declarations // - //--------------// - Action visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax*) override; - - /* Specifiers */ - Action visitAlignmentSpecifier(const AlignmentSpecifierSyntax*) override; - Action visitExtGNU_Typeof(const ExtGNU_TypeofSyntax*) override; - - /* Declarators */ - Action visitSubscriptSuffix(const SubscriptSuffixSyntax*) override; - - /* Initializers */ - Action visitExpressionInitializer(const ExpressionInitializerSyntax*) override; - Action visitArrayDesignator(const ArrayDesignatorSyntax*) override; - - //-------------// - // Expressions // - //-------------// - Action visitParenthesizedExpression(const ParenthesizedExpressionSyntax*) override; - Action visitGenericSelectionExpression(const GenericSelectionExpressionSyntax*) override; - Action visitGenericAssociation(const GenericAssociationSyntax*) override; - Action visitExtGNU_EnclosedCompoundStatementExpression(const ExtGNU_EnclosedCompoundStatementExpressionSyntax*) override; - Action visitExtGNU_ComplexValuedExpression(const ExtGNU_ComplexValuedExpressionSyntax*) override; - - /* Operations */ - Action visitPrefixUnaryExpression(const PrefixUnaryExpressionSyntax*) override; - Action visitPostfixUnaryExpression(const PostfixUnaryExpressionSyntax*) override; - Action visitMemberAccessExpression(const MemberAccessExpressionSyntax*) override; - Action visitArraySubscriptExpression(const ArraySubscriptExpressionSyntax*) override; - Action visitTypeTraitExpression(const TypeTraitExpressionSyntax*) override; - Action visitCastExpression(const CastExpressionSyntax*) override; - Action visitCallExpression(const CallExpressionSyntax*) override; - Action visitVAArgumentExpression(const VAArgumentExpressionSyntax*) override; - Action visitBinaryExpression(const BinaryExpressionSyntax*) override; - Action visitConditionalExpression(const ConditionalExpressionSyntax*) override; - Action visitAssignmentExpression(const AssignmentExpressionSyntax*) override; - Action visitSequencingExpression(const SequencingExpressionSyntax*) override; - Action visitExtGNU_ChooseExpression(const ExtGNU_ChooseExpressionSyntax*) override; - - //------------// - // Statements // - //------------// - Action visitCompoundStatement(const CompoundStatementSyntax*) override; - Action visitDeclarationStatement(const DeclarationStatementSyntax*) override; - Action visitExpressionStatement(const ExpressionStatementSyntax*) override; - Action visitLabeledStatement(const LabeledStatementSyntax*) override; - Action visitIfStatement(const IfStatementSyntax*) override; - Action visitSwitchStatement(const SwitchStatementSyntax*) override; - Action visitWhileStatement(const WhileStatementSyntax*) override; - Action visitDoStatement(const DoStatementSyntax*) override; - Action visitForStatement(const ForStatementSyntax*) override; - Action visitReturnStatement(const ReturnStatementSyntax*) override; - Action visitExtGNU_AsmOperand(const ExtGNU_AsmOperandSyntax*) override; - - //--------// - // Common // - //--------// - Action visitExpressionAsTypeReference(const ExpressionAsTypeReferenceSyntax*) override; - - //-------------// - // Ambiguities // - //-------------// - Action visitAmbiguousTypeNameOrExpressionAsTypeReference(const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax*) override; - Action visitAmbiguousCastOrBinaryExpression(const AmbiguousCastOrBinaryExpressionSyntax*) override; - Action visitAmbiguousExpressionOrDeclarationStatement(const AmbiguousExpressionOrDeclarationStatementSyntax*) override; + //--------------// + // Declarations // + //--------------// + Action + visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax *) override; + + /* Specifiers */ + Action visitAlignmentSpecifier(const AlignmentSpecifierSyntax *) override; + Action visitExtGNU_Typeof(const ExtGNU_TypeofSyntax *) override; + + /* Declarators */ + Action visitSubscriptSuffix(const SubscriptSuffixSyntax *) override; + + /* Initializers */ + Action + visitExpressionInitializer(const ExpressionInitializerSyntax *) override; + Action visitArrayDesignator(const ArrayDesignatorSyntax *) override; + + //-------------// + // Expressions // + //-------------// + Action + visitParenthesizedExpression(const ParenthesizedExpressionSyntax *) override; + Action visitGenericSelectionExpression( + const GenericSelectionExpressionSyntax *) override; + Action visitGenericAssociation(const GenericAssociationSyntax *) override; + Action visitExtGNU_EnclosedCompoundStatementExpression( + const ExtGNU_EnclosedCompoundStatementExpressionSyntax *) override; + Action visitExtGNU_ComplexValuedExpression( + const ExtGNU_ComplexValuedExpressionSyntax *) override; + + /* Operations */ + Action + visitPrefixUnaryExpression(const PrefixUnaryExpressionSyntax *) override; + Action + visitPostfixUnaryExpression(const PostfixUnaryExpressionSyntax *) override; + Action + visitMemberAccessExpression(const MemberAccessExpressionSyntax *) override; + Action visitArraySubscriptExpression( + const ArraySubscriptExpressionSyntax *) override; + Action visitTypeTraitExpression(const TypeTraitExpressionSyntax *) override; + Action visitCastExpression(const CastExpressionSyntax *) override; + Action visitCallExpression(const CallExpressionSyntax *) override; + Action visitVAArgumentExpression(const VAArgumentExpressionSyntax *) override; + Action visitBinaryExpression(const BinaryExpressionSyntax *) override; + Action + visitConditionalExpression(const ConditionalExpressionSyntax *) override; + Action visitAssignmentExpression(const AssignmentExpressionSyntax *) override; + Action visitSequencingExpression(const SequencingExpressionSyntax *) override; + Action + visitExtGNU_ChooseExpression(const ExtGNU_ChooseExpressionSyntax *) override; + + //------------// + // Statements // + //------------// + Action visitCompoundStatement(const CompoundStatementSyntax *) override; + Action visitDeclarationStatement(const DeclarationStatementSyntax *) override; + Action visitExpressionStatement(const ExpressionStatementSyntax *) override; + Action visitLabeledStatement(const LabeledStatementSyntax *) override; + Action visitIfStatement(const IfStatementSyntax *) override; + Action visitSwitchStatement(const SwitchStatementSyntax *) override; + Action visitWhileStatement(const WhileStatementSyntax *) override; + Action visitDoStatement(const DoStatementSyntax *) override; + Action visitForStatement(const ForStatementSyntax *) override; + Action visitReturnStatement(const ReturnStatementSyntax *) override; + Action visitExtGNU_AsmOperand(const ExtGNU_AsmOperandSyntax *) override; + + //--------// + // Common // + //--------// + Action visitExpressionAsTypeReference( + const ExpressionAsTypeReferenceSyntax *) override; + + //-------------// + // Ambiguities // + //-------------// + Action visitAmbiguousTypeNameOrExpressionAsTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *) override; + Action visitAmbiguousCastOrBinaryExpression( + const AmbiguousCastOrBinaryExpressionSyntax *) override; + Action visitAmbiguousExpressionOrDeclarationStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *) override; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/reparser/Disambiguator_GuidelineImposition.h b/C/reparser/Disambiguator_GuidelineImposition.h index 4d8e839e2..c404f7d17 100644 --- a/C/reparser/Disambiguator_GuidelineImposition.h +++ b/C/reparser/Disambiguator_GuidelineImposition.h @@ -28,13 +28,12 @@ namespace psy { namespace C { -class PSY_C_NON_API GuidelineImpositionReparser : public SyntaxVisitor -{ +class PSY_C_NON_API GuidelineImpositionReparser : public SyntaxVisitor { public: - GuidelineImpositionReparser(SyntaxTree* tree); + GuidelineImpositionReparser(SyntaxTree *tree); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/reparser/Disambiguator_SyntaxCorrelation.cpp b/C/reparser/Disambiguator_SyntaxCorrelation.cpp index e16be3953..70ad27d3f 100644 --- a/C/reparser/Disambiguator_SyntaxCorrelation.cpp +++ b/C/reparser/Disambiguator_SyntaxCorrelation.cpp @@ -30,93 +30,84 @@ using namespace psy; using namespace C; -SyntaxCorrelationDisambiguator::SyntaxCorrelationDisambiguator(SyntaxTree* tree) - : Disambiguator(tree) -{} +SyntaxCorrelationDisambiguator::SyntaxCorrelationDisambiguator(SyntaxTree *tree) + : Disambiguator(tree) {} -void SyntaxCorrelationDisambiguator::acquireCatalog(std::unique_ptr catalog) -{ - catalog_ = std::move(catalog); +void SyntaxCorrelationDisambiguator::acquireCatalog( + std::unique_ptr catalog) { + catalog_ = std::move(catalog); } -SyntaxVisitor::Action SyntaxCorrelationDisambiguator::visitTranslationUnit(const TranslationUnitSyntax* node) -{ - catalog_->enterLevel(node); +SyntaxVisitor::Action SyntaxCorrelationDisambiguator::visitTranslationUnit( + const TranslationUnitSyntax *node) { + catalog_->enterLevel(node); - for (auto iter = node->declarations(); iter; iter = iter->next) - visit(iter->value); + for (auto iter = node->declarations(); iter; iter = iter->next) + visit(iter->value); - catalog_->exitLevel(); + catalog_->exitLevel(); - return Action::Skip; + return Action::Skip; } -Disambiguator::Disambiguation SyntaxCorrelationDisambiguator::disambiguateExpression( - const AmbiguousCastOrBinaryExpressionSyntax* node) const -{ - auto typeName = node->castExpression()->typeName(); - PSY_ASSERT(typeName->specifiers() - && typeName->specifiers()->value - && typeName->specifiers()->value->kind() == TypedefName, - return Disambiguation::Inconclusive); - - auto typedefName = typeName->specifiers()->value->asTypedefName(); - auto name = typedefName->identifierToken().valueText(); - - return recognizesTypeName(name) - ? Disambiguation::KeepCastExpression - : recognizesName(name) - ? Disambiguation::KeepBinaryExpression - : Disambiguation::Inconclusive; +Disambiguator::Disambiguation +SyntaxCorrelationDisambiguator::disambiguateExpression( + const AmbiguousCastOrBinaryExpressionSyntax *node) const { + auto typeName = node->castExpression()->typeName(); + PSY_ASSERT(typeName->specifiers() && typeName->specifiers()->value && + typeName->specifiers()->value->kind() == TypedefName, + return Disambiguation::Inconclusive); + + auto typedefName = typeName->specifiers()->value->asTypedefName(); + auto name = typedefName->identifierToken().valueText(); + + return recognizesTypeName(name) ? Disambiguation::KeepCastExpression + : recognizesName(name) ? Disambiguation::KeepBinaryExpression + : Disambiguation::Inconclusive; } -Disambiguator::Disambiguation SyntaxCorrelationDisambiguator::disambiguateStatement( - const AmbiguousExpressionOrDeclarationStatementSyntax* node) const -{ - auto decl = node->declarationStatement()->declaration(); - PSY_ASSERT(decl->kind() == VariableAndOrFunctionDeclaration, return Disambiguation::Inconclusive); - - auto varDecl = decl->asVariableAndOrFunctionDeclaration(); - PSY_ASSERT(varDecl->specifiers() - && varDecl->specifiers()->value - && varDecl->specifiers()->value->kind() == TypedefName, - return Disambiguation::Inconclusive); - - auto typedefName = varDecl->specifiers()->value->asTypedefName(); - auto name = typedefName->identifierToken().valueText(); - - return recognizesTypeName(name) - ? Disambiguation::KeepDeclarationStatement - : recognizesName(name) - ? Disambiguation::KeepExpressionStatement - : Disambiguation::Inconclusive; +Disambiguator::Disambiguation +SyntaxCorrelationDisambiguator::disambiguateStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *node) const { + auto decl = node->declarationStatement()->declaration(); + PSY_ASSERT(decl->kind() == VariableAndOrFunctionDeclaration, + return Disambiguation::Inconclusive); + + auto varDecl = decl->asVariableAndOrFunctionDeclaration(); + PSY_ASSERT(varDecl->specifiers() && varDecl->specifiers()->value && + varDecl->specifiers()->value->kind() == TypedefName, + return Disambiguation::Inconclusive); + + auto typedefName = varDecl->specifiers()->value->asTypedefName(); + auto name = typedefName->identifierToken().valueText(); + + return recognizesTypeName(name) ? Disambiguation::KeepDeclarationStatement + : recognizesName(name) ? Disambiguation::KeepExpressionStatement + : Disambiguation::Inconclusive; } -Disambiguator::Disambiguation SyntaxCorrelationDisambiguator::disambiguateTypeReference( - const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax* node) const -{ - auto typeName = node->typeNameAsTypeReference()->typeName(); - PSY_ASSERT(typeName->specifiers() - && typeName->specifiers()->value - && typeName->specifiers()->value->kind() == TypedefName, - return Disambiguation::Inconclusive); - - auto typedefName = typeName->specifiers()->value->asTypedefName(); - auto name = typedefName->identifierToken().valueText(); - - return recognizesTypeName(name) - ? Disambiguation::KeepTypeName - : recognizesName(name) - ? Disambiguation::KeepExpression - : Disambiguation::Inconclusive; +Disambiguator::Disambiguation +SyntaxCorrelationDisambiguator::disambiguateTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *node) const { + auto typeName = node->typeNameAsTypeReference()->typeName(); + PSY_ASSERT(typeName->specifiers() && typeName->specifiers()->value && + typeName->specifiers()->value->kind() == TypedefName, + return Disambiguation::Inconclusive); + + auto typedefName = typeName->specifiers()->value->asTypedefName(); + auto name = typedefName->identifierToken().valueText(); + + return recognizesTypeName(name) ? Disambiguation::KeepTypeName + : recognizesName(name) ? Disambiguation::KeepExpression + : Disambiguation::Inconclusive; } -bool SyntaxCorrelationDisambiguator::recognizesTypeName(const std::string& name) const -{ - return catalog_->containsTypeName(name); +bool SyntaxCorrelationDisambiguator::recognizesTypeName( + const std::string &name) const { + return catalog_->containsTypeName(name); } -bool SyntaxCorrelationDisambiguator::recognizesName(const std::string& name) const -{ - return catalog_->containsName(name); +bool SyntaxCorrelationDisambiguator::recognizesName( + const std::string &name) const { + return catalog_->containsName(name); } diff --git a/C/reparser/Disambiguator_SyntaxCorrelation.h b/C/reparser/Disambiguator_SyntaxCorrelation.h index fedd643b5..f40fd4398 100644 --- a/C/reparser/Disambiguator_SyntaxCorrelation.h +++ b/C/reparser/Disambiguator_SyntaxCorrelation.h @@ -33,32 +33,35 @@ namespace psy { namespace C { -class PSY_C_NON_API SyntaxCorrelationDisambiguator final : public Disambiguator -{ -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Reparser); +class PSY_C_NON_API SyntaxCorrelationDisambiguator final + : public Disambiguator { + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Reparser); - SyntaxCorrelationDisambiguator(SyntaxTree* tree); + SyntaxCorrelationDisambiguator(SyntaxTree *tree); - void acquireCatalog(std::unique_ptr catalog); + void acquireCatalog(std::unique_ptr catalog); private: - std::unique_ptr catalog_; + std::unique_ptr catalog_; - virtual Disambiguation disambiguateExpression(const AmbiguousCastOrBinaryExpressionSyntax*) const override; - virtual Disambiguation disambiguateStatement(const AmbiguousExpressionOrDeclarationStatementSyntax*) const override; - virtual Disambiguation disambiguateTypeReference(const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax*) const override; + virtual Disambiguation disambiguateExpression( + const AmbiguousCastOrBinaryExpressionSyntax *) const override; + virtual Disambiguation disambiguateStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *) const override; + virtual Disambiguation disambiguateTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *) + const override; - bool recognizesTypeName(const std::string& name) const; - bool recognizesName(const std::string& name) const; + bool recognizesTypeName(const std::string &name) const; + bool recognizesName(const std::string &name) const; - //--------------// - // Declarations // - //--------------// - Action visitTranslationUnit(const TranslationUnitSyntax*) override; + //--------------// + // Declarations // + //--------------// + Action visitTranslationUnit(const TranslationUnitSyntax *) override; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/reparser/Disambiguator_TypeSynonymsVerification.h b/C/reparser/Disambiguator_TypeSynonymsVerification.h index ee66ac02e..37f7e3529 100644 --- a/C/reparser/Disambiguator_TypeSynonymsVerification.h +++ b/C/reparser/Disambiguator_TypeSynonymsVerification.h @@ -28,13 +28,12 @@ namespace psy { namespace C { -class PSY_C_NON_API TypeSynonymsVerificationReparser : public SyntaxVisitor -{ +class PSY_C_NON_API TypeSynonymsVerificationReparser : public SyntaxVisitor { public: - TypeSynonymsVerificationReparser(SyntaxTree* tree); + TypeSynonymsVerificationReparser(SyntaxTree *tree); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/reparser/NameCatalog.cpp b/C/reparser/NameCatalog.cpp index 984ffdc8b..87f081a23 100644 --- a/C/reparser/NameCatalog.cpp +++ b/C/reparser/NameCatalog.cpp @@ -30,97 +30,84 @@ using namespace C; #include -NameCatalog::~NameCatalog() -{} +NameCatalog::~NameCatalog() {} -void NameCatalog::createLevelAndEnter(const SyntaxNode* node) -{ - PSY_ASSERT(node, return); - PSY_ASSERT(!levelExists(node), return); +void NameCatalog::createLevelAndEnter(const SyntaxNode *node) { + PSY_ASSERT(node, return); + PSY_ASSERT(!levelExists(node), return); - TypeNames types; - Names nonTypes; - if (!levelKeys_.empty()) { - auto levelIt = levels_.find(levelKeys_.top()); - PSY_ASSERT(levelIt != levels_.end(), return); + TypeNames types; + Names nonTypes; + if (!levelKeys_.empty()) { + auto levelIt = levels_.find(levelKeys_.top()); + PSY_ASSERT(levelIt != levels_.end(), return); - types = levelIt->second.first; - nonTypes = levelIt->second.second; - } + types = levelIt->second.first; + nonTypes = levelIt->second.second; + } - levels_.insert(std::make_pair(node, std::make_pair(types, nonTypes))); + levels_.insert(std::make_pair(node, std::make_pair(types, nonTypes))); - enterLevel(node); + enterLevel(node); } -void NameCatalog::enterLevel(const SyntaxNode* node) -{ - PSY_ASSERT(node, return); - PSY_ASSERT(levelExists(node), return); +void NameCatalog::enterLevel(const SyntaxNode *node) { + PSY_ASSERT(node, return); + PSY_ASSERT(levelExists(node), return); - levelKeys_.push(node); + levelKeys_.push(node); } -void NameCatalog::exitLevel() -{ - levelKeys_.pop(); -} +void NameCatalog::exitLevel() { levelKeys_.pop(); } -void NameCatalog::catalogTypeName(std::string s) -{ - auto level = currentLevel(); - level->first.insert(std::move(s)); +void NameCatalog::catalogTypeName(std::string s) { + auto level = currentLevel(); + level->first.insert(std::move(s)); } -void NameCatalog::catalogName(std::string s) -{ - auto level = currentLevel(); - level->second.insert(std::move(s)); +void NameCatalog::catalogName(std::string s) { + auto level = currentLevel(); + level->second.insert(std::move(s)); } -bool NameCatalog::containsTypeName(const std::string& s) const -{ - auto level = currentLevel(); - return level->first.find(s) != level->first.end(); +bool NameCatalog::containsTypeName(const std::string &s) const { + auto level = currentLevel(); + return level->first.find(s) != level->first.end(); } -bool NameCatalog::containsName(const std::string &s) const -{ - auto level = currentLevel(); - return level->second.find(s) != level->first.end(); +bool NameCatalog::containsName(const std::string &s) const { + auto level = currentLevel(); + return level->second.find(s) != level->first.end(); } -bool NameCatalog::levelExists(const SyntaxNode* node) const -{ - return levels_.count(node) != 0; +bool NameCatalog::levelExists(const SyntaxNode *node) const { + return levels_.count(node) != 0; } -NameCatalog::NameIndex* NameCatalog::currentLevel() const -{ - PSY_ASSERT(!levelKeys_.empty(), return nullptr); - PSY_ASSERT(levelExists(levelKeys_.top()), return nullptr); +NameCatalog::NameIndex *NameCatalog::currentLevel() const { + PSY_ASSERT(!levelKeys_.empty(), return nullptr); + PSY_ASSERT(levelExists(levelKeys_.top()), return nullptr); - return &levels_[levelKeys_.top()]; + return &levels_[levelKeys_.top()]; } namespace psy { namespace C { -std::ostream& operator<<(std::ostream& os, const NameCatalog& disambigCatalog) -{ - for (const auto& p : disambigCatalog.levels_) { - os << to_string(p.first->kind()) << std::endl; - os << "\tTypes: "; - for (const auto& t : p.second.first) - os << t << " "; - std::cout << std::endl; - os << "\tAny: "; - for (const auto& v : p.second.second) - os << v << " "; - os << std::endl; - } - return os; +std::ostream &operator<<(std::ostream &os, const NameCatalog &disambigCatalog) { + for (const auto &p : disambigCatalog.levels_) { + os << to_string(p.first->kind()) << std::endl; + os << "\tTypes: "; + for (const auto &t : p.second.first) + os << t << " "; + std::cout << std::endl; + os << "\tAny: "; + for (const auto &v : p.second.second) + os << v << " "; + os << std::endl; + } + return os; } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/reparser/NameCatalog.h b/C/reparser/NameCatalog.h index 2f0d8a46d..70a4e0f45 100644 --- a/C/reparser/NameCatalog.h +++ b/C/reparser/NameCatalog.h @@ -36,45 +36,43 @@ namespace psy { namespace C { -class PSY_C_NON_API NameCatalog -{ - friend std::ostream& operator<<(std::ostream& os, const NameCatalog& disambigCatalog); +class PSY_C_NON_API NameCatalog { + friend std::ostream &operator<<(std::ostream &os, + const NameCatalog &disambigCatalog); public: - ~NameCatalog(); + ~NameCatalog(); -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(NameCataloger); - PSY_GRANT_ACCESS(SyntaxCorrelationDisambiguator); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(NameCataloger); + PSY_GRANT_ACCESS(SyntaxCorrelationDisambiguator); - void createLevelAndEnter(const SyntaxNode*); - void enterLevel(const SyntaxNode*); - void exitLevel(); + void createLevelAndEnter(const SyntaxNode *); + void enterLevel(const SyntaxNode *); + void exitLevel(); - void catalogTypeName(std::string s); - void catalogName(std::string s); + void catalogTypeName(std::string s); + void catalogName(std::string s); - bool containsTypeName(const std::string& s) const; - bool containsName(const std::string& s) const; + bool containsTypeName(const std::string &s) const; + bool containsName(const std::string &s) const; private: - using TypeNames = std::unordered_set; - using Names = std::unordered_set; - using NameIndex = std::pair; + using TypeNames = std::unordered_set; + using Names = std::unordered_set; + using NameIndex = std::pair; - using Levels = std::unordered_map; + using Levels = std::unordered_map; - mutable Levels levels_; - std::stack levelKeys_; + mutable Levels levels_; + std::stack levelKeys_; - bool levelExists(const SyntaxNode*) const; - NameIndex* currentLevel() const; + bool levelExists(const SyntaxNode *) const; + NameIndex *currentLevel() const; }; -std::ostream& operator<<(std::ostream& os, const NameCatalog& disambigCatalog); +std::ostream &operator<<(std::ostream &os, const NameCatalog &disambigCatalog); -} // C -} // psy +} // namespace C +} // namespace psy #endif - diff --git a/C/reparser/NameCataloger.cpp b/C/reparser/NameCataloger.cpp index 9596ecd78..e7cbf9d21 100644 --- a/C/reparser/NameCataloger.cpp +++ b/C/reparser/NameCataloger.cpp @@ -28,89 +28,84 @@ using namespace psy; using namespace C; -NameCataloger::NameCataloger(SyntaxTree* tree) - : SyntaxVisitor(tree) - , catalog_(new NameCatalog) -{} - -std::unique_ptr NameCataloger::catalogFor(const SyntaxNode* node) -{ - visit(node); - return std::move(catalog_); +NameCataloger::NameCataloger(SyntaxTree *tree) + : SyntaxVisitor(tree), catalog_(new NameCatalog) {} + +std::unique_ptr NameCataloger::catalogFor(const SyntaxNode *node) { + visit(node); + return std::move(catalog_); } -SyntaxVisitor::Action NameCataloger::visitTranslationUnit(const TranslationUnitSyntax* node) -{ - catalog_->createLevelAndEnter(node); +SyntaxVisitor::Action +NameCataloger::visitTranslationUnit(const TranslationUnitSyntax *node) { + catalog_->createLevelAndEnter(node); - for (auto iter = node->declarations(); iter; iter = iter->next) - visit(iter->value); + for (auto iter = node->declarations(); iter; iter = iter->next) + visit(iter->value); - catalog_->exitLevel(); + catalog_->exitLevel(); - std::cout << "CATALOG\n" << *catalog_ << std::endl; + std::cout << "CATALOG\n" << *catalog_ << std::endl; - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action NameCataloger::visitTypedefName(const TypedefNameSyntax* node) -{ - catalog_->catalogTypeName(node->identifierToken().valueText()); +SyntaxVisitor::Action +NameCataloger::visitTypedefName(const TypedefNameSyntax *node) { + catalog_->catalogTypeName(node->identifierToken().valueText()); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action NameCataloger::visitIdentifierDeclarator(const IdentifierDeclaratorSyntax* node) -{ - catalog_->catalogName(node->identifierToken().valueText()); +SyntaxVisitor::Action NameCataloger::visitIdentifierDeclarator( + const IdentifierDeclaratorSyntax *node) { + catalog_->catalogName(node->identifierToken().valueText()); - visit(node->initializer()); + visit(node->initializer()); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action NameCataloger::visitIdentifierName(const IdentifierNameSyntax* node) -{ - catalog_->catalogName(node->identifierToken().valueText()); +SyntaxVisitor::Action +NameCataloger::visitIdentifierName(const IdentifierNameSyntax *node) { + catalog_->catalogName(node->identifierToken().valueText()); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action NameCataloger::visitAmbiguousTypeNameOrExpressionAsTypeReference( - const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax* node) -{ - return Action::Skip; +SyntaxVisitor::Action +NameCataloger::visitAmbiguousTypeNameOrExpressionAsTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *node) { + return Action::Skip; } SyntaxVisitor::Action NameCataloger::visitAmbiguousCastOrBinaryExpression( - const AmbiguousCastOrBinaryExpressionSyntax* node) -{ - visit(node->binaryExpression()->right()); + const AmbiguousCastOrBinaryExpressionSyntax *node) { + visit(node->binaryExpression()->right()); - return Action::Skip; + return Action::Skip; } -SyntaxVisitor::Action NameCataloger::visitAmbiguousExpressionOrDeclarationStatement( - const AmbiguousExpressionOrDeclarationStatementSyntax* node) -{ - auto expr = node->expressionStatement()->expression(); - switch (expr->kind()) { - case MultiplyExpression: { - auto binExpr = expr->asBinaryExpression(); - visit(binExpr->right()); - break; - } - - case CallExpression: { - auto callExpr = expr->asCallExpression(); - visit(callExpr->arguments()->value); - break; - } - - default: - PSY_ESCAPE_VIA_RETURN(Action::Skip); - } - - return Action::Skip; +SyntaxVisitor::Action +NameCataloger::visitAmbiguousExpressionOrDeclarationStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *node) { + auto expr = node->expressionStatement()->expression(); + switch (expr->kind()) { + case MultiplyExpression: { + auto binExpr = expr->asBinaryExpression(); + visit(binExpr->right()); + break; + } + + case CallExpression: { + auto callExpr = expr->asCallExpression(); + visit(callExpr->arguments()->value); + break; + } + + default: + PSY_ESCAPE_VIA_RETURN(Action::Skip); + } + + return Action::Skip; } - diff --git a/C/reparser/NameCataloger.h b/C/reparser/NameCataloger.h index 8f56e16ac..a55161699 100644 --- a/C/reparser/NameCataloger.h +++ b/C/reparser/NameCataloger.h @@ -33,44 +33,46 @@ namespace psy { namespace C { -class PSY_C_NON_API NameCataloger : public SyntaxVisitor -{ +class PSY_C_NON_API NameCataloger : public SyntaxVisitor { public: - NameCataloger(SyntaxTree* tree); + NameCataloger(SyntaxTree *tree); - std::unique_ptr catalogFor(const SyntaxNode*); + std::unique_ptr catalogFor(const SyntaxNode *); private: - std::unique_ptr catalog_; - - using SyntaxVisitor::visit; - using Base = SyntaxVisitor; - - //--------------// - // Declarations // - //--------------// - Action visitTranslationUnit(const TranslationUnitSyntax*) override; - - /* Specifiers */ - Action visitTypedefName(const TypedefNameSyntax*) override; - - /* Declarators */ - Action visitIdentifierDeclarator(const IdentifierDeclaratorSyntax*) override; - - //-------------// - // Expressions // - //-------------// - Action visitIdentifierName(const IdentifierNameSyntax*) override; - - //-------------// - // Ambiguities // - //-------------// - Action visitAmbiguousTypeNameOrExpressionAsTypeReference(const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax*) override; - Action visitAmbiguousCastOrBinaryExpression(const AmbiguousCastOrBinaryExpressionSyntax*) override; - Action visitAmbiguousExpressionOrDeclarationStatement(const AmbiguousExpressionOrDeclarationStatementSyntax*) override; + std::unique_ptr catalog_; + + using SyntaxVisitor::visit; + using Base = SyntaxVisitor; + + //--------------// + // Declarations // + //--------------// + Action visitTranslationUnit(const TranslationUnitSyntax *) override; + + /* Specifiers */ + Action visitTypedefName(const TypedefNameSyntax *) override; + + /* Declarators */ + Action visitIdentifierDeclarator(const IdentifierDeclaratorSyntax *) override; + + //-------------// + // Expressions // + //-------------// + Action visitIdentifierName(const IdentifierNameSyntax *) override; + + //-------------// + // Ambiguities // + //-------------// + Action visitAmbiguousTypeNameOrExpressionAsTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *) override; + Action visitAmbiguousCastOrBinaryExpression( + const AmbiguousCastOrBinaryExpressionSyntax *) override; + Action visitAmbiguousExpressionOrDeclarationStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *) override; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/reparser/Reparser.cpp b/C/reparser/Reparser.cpp index f7e73898c..db777e47f 100644 --- a/C/reparser/Reparser.cpp +++ b/C/reparser/Reparser.cpp @@ -22,10 +22,10 @@ #include "SyntaxTree.h" -#include "reparser/NameCataloger.h" #include "reparser/Disambiguator_GuidelineImposition.h" #include "reparser/Disambiguator_SyntaxCorrelation.h" #include "reparser/Disambiguator_TypeSynonymsVerification.h" +#include "reparser/NameCataloger.h" #include "syntax/SyntaxNode.h" #include "../common/infra/Escape.h" @@ -34,42 +34,39 @@ using namespace psy; using namespace C; Reparser::Reparser() - : disambigStrategy_(DisambiguationStrategy::SyntaxCorrelation) - , permitHeuristic_(false) -{} + : disambigStrategy_(DisambiguationStrategy::SyntaxCorrelation), + permitHeuristic_(false) {} -void Reparser::setDisambiguationStrategy(DisambiguationStrategy strategy) -{ - disambigStrategy_ = strategy; +void Reparser::setDisambiguationStrategy(DisambiguationStrategy strategy) { + disambigStrategy_ = strategy; } -void Reparser::setPermitHeuristic(bool heuristic) -{ - permitHeuristic_ = heuristic; +void Reparser::setPermitHeuristic(bool heuristic) { + permitHeuristic_ = heuristic; } -void Reparser::reparse(SyntaxTree* tree) -{ - if (disambigStrategy_ == Reparser::DisambiguationStrategy::GuidelineImposition) { - // TODO - return; - } +void Reparser::reparse(SyntaxTree *tree) { + if (disambigStrategy_ == + Reparser::DisambiguationStrategy::GuidelineImposition) { + // TODO + return; + } - NameCataloger cataloger(tree); - auto catalog = cataloger.catalogFor(tree->root()); + NameCataloger cataloger(tree); + auto catalog = cataloger.catalogFor(tree->root()); - switch (disambigStrategy_) { - case Reparser::DisambiguationStrategy::SyntaxCorrelation: { - SyntaxCorrelationDisambiguator disambiguator(tree); - disambiguator.acquireCatalog(std::move(catalog)); - disambiguator.disambiguate(); - break; - } + switch (disambigStrategy_) { + case Reparser::DisambiguationStrategy::SyntaxCorrelation: { + SyntaxCorrelationDisambiguator disambiguator(tree); + disambiguator.acquireCatalog(std::move(catalog)); + disambiguator.disambiguate(); + break; + } - case Reparser::DisambiguationStrategy::TypeSynonymsVerification: - break; + case Reparser::DisambiguationStrategy::TypeSynonymsVerification: + break; - default: - PSY_ESCAPE(); - } + default: + PSY_ESCAPE(); + } } diff --git a/C/reparser/Reparser.h b/C/reparser/Reparser.h index 668a085bd..419bffe2a 100644 --- a/C/reparser/Reparser.h +++ b/C/reparser/Reparser.h @@ -33,35 +33,32 @@ namespace psy { namespace C { -class PSY_C_NON_API Reparser -{ -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SyntaxTree); - PSY_GRANT_ACCESS(InternalsTestSuite); +class PSY_C_NON_API Reparser { + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SyntaxTree); + PSY_GRANT_ACCESS(InternalsTestSuite); - Reparser(); + Reparser(); - enum class DisambiguationStrategy : std::uint8_t - { - UNSPECIFIED = 0, + enum class DisambiguationStrategy : std::uint8_t { + UNSPECIFIED = 0, - TypeSynonymsVerification, - SyntaxCorrelation, - GuidelineImposition - }; + TypeSynonymsVerification, + SyntaxCorrelation, + GuidelineImposition + }; - void setDisambiguationStrategy(DisambiguationStrategy strategy); + void setDisambiguationStrategy(DisambiguationStrategy strategy); - void setPermitHeuristic(bool heuristic); + void setPermitHeuristic(bool heuristic); - void reparse(SyntaxTree* tree); + void reparse(SyntaxTree *tree); private: - DisambiguationStrategy disambigStrategy_; - bool permitHeuristic_; + DisambiguationStrategy disambigStrategy_; + bool permitHeuristic_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/stdlib-support/CnippetPlugin.cpp b/C/stdlib-support/CnippetPlugin.cpp index f95d8f7d2..245c275da 100644 --- a/C/stdlib-support/CnippetPlugin.cpp +++ b/C/stdlib-support/CnippetPlugin.cpp @@ -18,18 +18,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include "StdLibInterceptor.h" #include "StdLibInspector.h" +#include "StdLibInterceptor.h" using namespace psy; using namespace C; extern "C" { -PLUGIN_API StdLibInterceptor* newInterceptor() { return new StdLibInterceptor; } -PLUGIN_API void deleteInterceptor(StdLibInterceptor* p) { delete p; } - -PLUGIN_API StdLibInspector* newInspector() { return new StdLibInspector; } -PLUGIN_API void deleteInspector(StdLibInspector* p) { delete p; } +PLUGIN_API StdLibInterceptor *newInterceptor() { return new StdLibInterceptor; } +PLUGIN_API void deleteInterceptor(StdLibInterceptor *p) { delete p; } +PLUGIN_API StdLibInspector *newInspector() { return new StdLibInspector; } +PLUGIN_API void deleteInspector(StdLibInspector *p) { delete p; } } diff --git a/C/stdlib-support/StdLibIndex.cpp b/C/stdlib-support/StdLibIndex.cpp index 07730b08a..c7bf2ba5c 100644 --- a/C/stdlib-support/StdLibIndex.cpp +++ b/C/stdlib-support/StdLibIndex.cpp @@ -32,303 +32,195 @@ using namespace psy; using namespace C; // C89/90 -const StdLibIndex::Index StdLibIndex::c89idx_ - { - { "assert.h", - { - { "assert", SymbolKind::Value } - } - }, - { "errno.h", - { - { "errno", SymbolKind::Value } - } - }, - { "ctype.h", - { - { "isalnum", SymbolKind::Value }, - { "isalpha", SymbolKind::Value }, - { "islower", SymbolKind::Value }, - { "isupper", SymbolKind::Value }, - { "isdigit", SymbolKind::Value }, - { "isxdigit", SymbolKind::Value }, - { "iscntrl", SymbolKind::Value }, - { "isgraph", SymbolKind::Value }, - { "isspace", SymbolKind::Value }, - { "isprint", SymbolKind::Value }, - { "ispunch", SymbolKind::Value }, - { "tolower", SymbolKind::Value }, - { "toupper", SymbolKind::Value } - } - }, - { "setjmp.h", - { - { "setjmp", SymbolKind::Value }, - { "longjmp", SymbolKind::Value }, - { "jmp_buf", SymbolKind::Type } - } - }, - { "signal.h", - { - { "signal", SymbolKind::Value }, - { "raise", SymbolKind::Value }, - { "sig_atomic_t", SymbolKind::Type }, - { "SIG_DFL", SymbolKind::Value }, - { "SIG_IGN", SymbolKind::Value }, - { "SIG_ERR", SymbolKind::Value }, - { "SIGTERM", SymbolKind::Value }, - { "SIGSEGV", SymbolKind::Value }, - { "SIGINT", SymbolKind::Value }, - { "SIGILL", SymbolKind::Value }, - { "SIGABRT", SymbolKind::Value }, - { "SIGFPE", SymbolKind::Value }, - } - }, - { "stdlib.h", - { - { "abort", SymbolKind::Value }, - { "exit", SymbolKind::Value }, - { "atexit", SymbolKind::Value }, - { "EXIT_SUCCESS", SymbolKind::Value }, - { "EXIT_FAILURE", SymbolKind::Value }, - { "system", SymbolKind::Value }, - { "getenv", SymbolKind::Value }, - { "malloc", SymbolKind::Value }, - { "calloc", SymbolKind::Value }, - { "realloc", SymbolKind::Value }, - { "free", SymbolKind::Value }, - { "atof", SymbolKind::Value }, - { "atoi", SymbolKind::Value }, - { "atol", SymbolKind::Value }, - { "strtol", SymbolKind::Value }, - { "strtoul", SymbolKind::Value }, - { "strtod", SymbolKind::Value }, - { "strtold", SymbolKind::Value }, - { "mblen", SymbolKind::Value }, - { "mbtowc", SymbolKind::Value }, - { "wctomb", SymbolKind::Value }, - { "mbstowcs", SymbolKind::Value }, - { "wcstombs", SymbolKind::Value }, - } - }, - { "string.h", - { - { "strcpy", SymbolKind::Value }, - { "strncpy", SymbolKind::Value }, - { "strcat", SymbolKind::Value }, - { "strncat", SymbolKind::Value }, - { "strxfrm", SymbolKind::Value }, - { "strlen", SymbolKind::Value }, - { "strcmp", SymbolKind::Value }, - { "strncmp", SymbolKind::Value }, - { "strcoll", SymbolKind::Value }, - { "strchr", SymbolKind::Value }, - { "strspn", SymbolKind::Value }, - { "strcspn", SymbolKind::Value } - } - }, - { "stdio.h", - { - { "fopen", SymbolKind::Value }, - { "freopen", SymbolKind::Value }, - { "fclose", SymbolKind::Value }, - { "fflush", SymbolKind::Value }, - { "setbuf", SymbolKind::Value }, - { "setvbuf", SymbolKind::Value }, - { "fwide", SymbolKind::Value }, - { "fread", SymbolKind::Value }, - { "fwrite", SymbolKind::Value }, - { "fgetc", SymbolKind::Value }, - { "getc", SymbolKind::Value }, - { "fgets", SymbolKind::Value }, - { "fputc", SymbolKind::Value }, - { "putc", SymbolKind::Value }, - { "fputs", SymbolKind::Value }, - { "getchar", SymbolKind::Value }, - { "gets", SymbolKind::Value }, - { "putchar", SymbolKind::Value }, - { "puts", SymbolKind::Value }, - { "ungetc", SymbolKind::Value }, - { "fgetwc", SymbolKind::Value }, - { "getwc", SymbolKind::Value }, - { "fgetws", SymbolKind::Value }, - { "fputwc", SymbolKind::Value }, - { "putwc", SymbolKind::Value }, - { "fputws", SymbolKind::Value }, - { "getwchar", SymbolKind::Value }, - { "putwchar", SymbolKind::Value }, - { "ungetwc", SymbolKind::Value }, - { "scanf", SymbolKind::Value }, - { "fscanf", SymbolKind::Value }, - { "sscanf", SymbolKind::Value }, - { "printf", SymbolKind::Value }, - { "fprintf", SymbolKind::Value }, - { "sprintf", SymbolKind::Value }, - { "vprintf", SymbolKind::Value }, - { "vfprintf", SymbolKind::Value }, - { "vsprintf", SymbolKind::Value }, - { "wscanf", SymbolKind::Value }, - { "swscanf", SymbolKind::Value }, - { "ftell", SymbolKind::Value }, - { "fgetpos", SymbolKind::Value }, - { "fseek", SymbolKind::Value }, - { "fsetpos", SymbolKind::Value }, - { "rewind", SymbolKind::Value }, - { "clearerr", SymbolKind::Value }, - { "feof", SymbolKind::Value }, - { "ferror", SymbolKind::Value }, - { "perror", SymbolKind::Value }, - { "remove", SymbolKind::Value }, - { "rename", SymbolKind::Value }, - { "tmpfile", SymbolKind::Value }, - { "tmpnam", SymbolKind::Value }, - { "FILE", SymbolKind::Type }, - { "fpos_t", SymbolKind::Type }, - { "stdin", SymbolKind::Value }, - { "stdout", SymbolKind::Value }, - { "stderr", SymbolKind::Value }, - { "EOF", SymbolKind::Value }, - { "FOPEN_MAX", SymbolKind::Value }, - { "FILENAME_MAX", SymbolKind::Value }, - { "BUFSIZ", SymbolKind::Value }, - { "_IOFBF", SymbolKind::Value }, - { "_IOLBF", SymbolKind::Value }, - { "_IONBF", SymbolKind::Value }, - { "SEEK_SET", SymbolKind::Value }, - { "SEEK_CUR", SymbolKind::Value }, - { "SEEK_END", SymbolKind::Value }, - { "TMP_MAX", SymbolKind::Value }, - { "L_tmpnam", SymbolKind::Value } - } - }, - { "wchar.h", - { - { "wchar_t", SymbolKind::Value }, - { "mbstate_t", SymbolKind::Value }, - } - }, - { "wctype.h", - { - { "iswalnum", SymbolKind::Value }, - { "iswalpha", SymbolKind::Value }, - { "iswlower", SymbolKind::Value }, - { "iswupper", SymbolKind::Value }, - { "iswdigit", SymbolKind::Value }, - { "iswxdigit", SymbolKind::Value }, - { "iswcntrl", SymbolKind::Value }, - { "iswgraph", SymbolKind::Value }, - { "iswspace", SymbolKind::Value }, - { "iswblank", SymbolKind::Value }, - { "iswprint", SymbolKind::Value }, - { "iswpunct", SymbolKind::Value }, - { "iswctype", SymbolKind::Value }, - { "wctype_t", SymbolKind::Type }, - { "wctrans_t", SymbolKind::Type }, - { "wint_t", SymbolKind::Type }, - { "towlower", SymbolKind::Value }, - { "towupper", SymbolKind::Value }, - { "towctrans", SymbolKind::Value }, - { "wctrans", SymbolKind::Value } - } - } - }; +const StdLibIndex::Index StdLibIndex::c89idx_{ + {"assert.h", {{"assert", SymbolKind::Value}}}, + {"errno.h", {{"errno", SymbolKind::Value}}}, + {"ctype.h", + {{"isalnum", SymbolKind::Value}, + {"isalpha", SymbolKind::Value}, + {"islower", SymbolKind::Value}, + {"isupper", SymbolKind::Value}, + {"isdigit", SymbolKind::Value}, + {"isxdigit", SymbolKind::Value}, + {"iscntrl", SymbolKind::Value}, + {"isgraph", SymbolKind::Value}, + {"isspace", SymbolKind::Value}, + {"isprint", SymbolKind::Value}, + {"ispunch", SymbolKind::Value}, + {"tolower", SymbolKind::Value}, + {"toupper", SymbolKind::Value}}}, + {"setjmp.h", + {{"setjmp", SymbolKind::Value}, + {"longjmp", SymbolKind::Value}, + {"jmp_buf", SymbolKind::Type}}}, + {"signal.h", + { + {"signal", SymbolKind::Value}, + {"raise", SymbolKind::Value}, + {"sig_atomic_t", SymbolKind::Type}, + {"SIG_DFL", SymbolKind::Value}, + {"SIG_IGN", SymbolKind::Value}, + {"SIG_ERR", SymbolKind::Value}, + {"SIGTERM", SymbolKind::Value}, + {"SIGSEGV", SymbolKind::Value}, + {"SIGINT", SymbolKind::Value}, + {"SIGILL", SymbolKind::Value}, + {"SIGABRT", SymbolKind::Value}, + {"SIGFPE", SymbolKind::Value}, + }}, + {"stdlib.h", + { + {"abort", SymbolKind::Value}, + {"exit", SymbolKind::Value}, + {"atexit", SymbolKind::Value}, + {"EXIT_SUCCESS", SymbolKind::Value}, + {"EXIT_FAILURE", SymbolKind::Value}, + {"system", SymbolKind::Value}, + {"getenv", SymbolKind::Value}, + {"malloc", SymbolKind::Value}, + {"calloc", SymbolKind::Value}, + {"realloc", SymbolKind::Value}, + {"free", SymbolKind::Value}, + {"atof", SymbolKind::Value}, + {"atoi", SymbolKind::Value}, + {"atol", SymbolKind::Value}, + {"strtol", SymbolKind::Value}, + {"strtoul", SymbolKind::Value}, + {"strtod", SymbolKind::Value}, + {"strtold", SymbolKind::Value}, + {"mblen", SymbolKind::Value}, + {"mbtowc", SymbolKind::Value}, + {"wctomb", SymbolKind::Value}, + {"mbstowcs", SymbolKind::Value}, + {"wcstombs", SymbolKind::Value}, + }}, + {"string.h", + {{"strcpy", SymbolKind::Value}, + {"strncpy", SymbolKind::Value}, + {"strcat", SymbolKind::Value}, + {"strncat", SymbolKind::Value}, + {"strxfrm", SymbolKind::Value}, + {"strlen", SymbolKind::Value}, + {"strcmp", SymbolKind::Value}, + {"strncmp", SymbolKind::Value}, + {"strcoll", SymbolKind::Value}, + {"strchr", SymbolKind::Value}, + {"strspn", SymbolKind::Value}, + {"strcspn", SymbolKind::Value}}}, + {"stdio.h", + {{"fopen", SymbolKind::Value}, {"freopen", SymbolKind::Value}, + {"fclose", SymbolKind::Value}, {"fflush", SymbolKind::Value}, + {"setbuf", SymbolKind::Value}, {"setvbuf", SymbolKind::Value}, + {"fwide", SymbolKind::Value}, {"fread", SymbolKind::Value}, + {"fwrite", SymbolKind::Value}, {"fgetc", SymbolKind::Value}, + {"getc", SymbolKind::Value}, {"fgets", SymbolKind::Value}, + {"fputc", SymbolKind::Value}, {"putc", SymbolKind::Value}, + {"fputs", SymbolKind::Value}, {"getchar", SymbolKind::Value}, + {"gets", SymbolKind::Value}, {"putchar", SymbolKind::Value}, + {"puts", SymbolKind::Value}, {"ungetc", SymbolKind::Value}, + {"fgetwc", SymbolKind::Value}, {"getwc", SymbolKind::Value}, + {"fgetws", SymbolKind::Value}, {"fputwc", SymbolKind::Value}, + {"putwc", SymbolKind::Value}, {"fputws", SymbolKind::Value}, + {"getwchar", SymbolKind::Value}, {"putwchar", SymbolKind::Value}, + {"ungetwc", SymbolKind::Value}, {"scanf", SymbolKind::Value}, + {"fscanf", SymbolKind::Value}, {"sscanf", SymbolKind::Value}, + {"printf", SymbolKind::Value}, {"fprintf", SymbolKind::Value}, + {"sprintf", SymbolKind::Value}, {"vprintf", SymbolKind::Value}, + {"vfprintf", SymbolKind::Value}, {"vsprintf", SymbolKind::Value}, + {"wscanf", SymbolKind::Value}, {"swscanf", SymbolKind::Value}, + {"ftell", SymbolKind::Value}, {"fgetpos", SymbolKind::Value}, + {"fseek", SymbolKind::Value}, {"fsetpos", SymbolKind::Value}, + {"rewind", SymbolKind::Value}, {"clearerr", SymbolKind::Value}, + {"feof", SymbolKind::Value}, {"ferror", SymbolKind::Value}, + {"perror", SymbolKind::Value}, {"remove", SymbolKind::Value}, + {"rename", SymbolKind::Value}, {"tmpfile", SymbolKind::Value}, + {"tmpnam", SymbolKind::Value}, {"FILE", SymbolKind::Type}, + {"fpos_t", SymbolKind::Type}, {"stdin", SymbolKind::Value}, + {"stdout", SymbolKind::Value}, {"stderr", SymbolKind::Value}, + {"EOF", SymbolKind::Value}, {"FOPEN_MAX", SymbolKind::Value}, + {"FILENAME_MAX", SymbolKind::Value}, {"BUFSIZ", SymbolKind::Value}, + {"_IOFBF", SymbolKind::Value}, {"_IOLBF", SymbolKind::Value}, + {"_IONBF", SymbolKind::Value}, {"SEEK_SET", SymbolKind::Value}, + {"SEEK_CUR", SymbolKind::Value}, {"SEEK_END", SymbolKind::Value}, + {"TMP_MAX", SymbolKind::Value}, {"L_tmpnam", SymbolKind::Value}}}, + {"wchar.h", + { + {"wchar_t", SymbolKind::Value}, + {"mbstate_t", SymbolKind::Value}, + }}, + {"wctype.h", + {{"iswalnum", SymbolKind::Value}, {"iswalpha", SymbolKind::Value}, + {"iswlower", SymbolKind::Value}, {"iswupper", SymbolKind::Value}, + {"iswdigit", SymbolKind::Value}, {"iswxdigit", SymbolKind::Value}, + {"iswcntrl", SymbolKind::Value}, {"iswgraph", SymbolKind::Value}, + {"iswspace", SymbolKind::Value}, {"iswblank", SymbolKind::Value}, + {"iswprint", SymbolKind::Value}, {"iswpunct", SymbolKind::Value}, + {"iswctype", SymbolKind::Value}, {"wctype_t", SymbolKind::Type}, + {"wctrans_t", SymbolKind::Type}, {"wint_t", SymbolKind::Type}, + {"towlower", SymbolKind::Value}, {"towupper", SymbolKind::Value}, + {"towctrans", SymbolKind::Value}, {"wctrans", SymbolKind::Value}}}}; // C99 -const StdLibIndex::Index StdLibIndex::c99idx_ - { - { "ctype.h", - { - { "isblank", SymbolKind::Value } - } - }, - { "stdlib.h", - { - { "_Exit", SymbolKind::Value }, - { "atoll", SymbolKind::Value }, - { "strtoll", SymbolKind::Value }, - { "strtoull", SymbolKind::Value }, - { "strtof", SymbolKind::Value }, - { "strtold", SymbolKind::Value }, - { "strtoimax", SymbolKind::Value }, - { "strtoumax", SymbolKind::Value } - } - }, - { "inttypes.h", - { - { "strtoimax", SymbolKind::Value }, - { "strtoumax", SymbolKind::Value } - } - } - }; +const StdLibIndex::Index StdLibIndex::c99idx_{ + {"ctype.h", {{"isblank", SymbolKind::Value}}}, + {"stdlib.h", + {{"_Exit", SymbolKind::Value}, + {"atoll", SymbolKind::Value}, + {"strtoll", SymbolKind::Value}, + {"strtoull", SymbolKind::Value}, + {"strtof", SymbolKind::Value}, + {"strtold", SymbolKind::Value}, + {"strtoimax", SymbolKind::Value}, + {"strtoumax", SymbolKind::Value}}}, + {"inttypes.h", + {{"strtoimax", SymbolKind::Value}, {"strtoumax", SymbolKind::Value}}}}; // C11 -const StdLibIndex::Index StdLibIndex::c11idx_ - { - { "assert.h", - { - { "static_assert", SymbolKind::Value } - } - }, - { "errno.h", - { - { "errno_t", SymbolKind::Type } - } - }, - { "string.h", - { - { "strcpy_s", SymbolKind::Value }, - { "strncpy_s", SymbolKind::Value }, - { "strcat_s", SymbolKind::Value }, - { "strncat_s", SymbolKind::Value }, - { "strnlen_s", SymbolKind::Value } - } - }, - { "stdlib.h", - { - { "quick_exit", SymbolKind::Value }, - { "at_quick_exit", SymbolKind::Value }, - { "getenv_s", SymbolKind::Value }, - { "aligned_alloc", SymbolKind::Value }, - { "wctomb_s", SymbolKind::Value }, - { "mbstowcs_s", SymbolKind::Value }, - { "wcstombs_s", SymbolKind::Value }, - } - } - }; +const StdLibIndex::Index StdLibIndex::c11idx_{ + {"assert.h", {{"static_assert", SymbolKind::Value}}}, + {"errno.h", {{"errno_t", SymbolKind::Type}}}, + {"string.h", + {{"strcpy_s", SymbolKind::Value}, + {"strncpy_s", SymbolKind::Value}, + {"strcat_s", SymbolKind::Value}, + {"strncat_s", SymbolKind::Value}, + {"strnlen_s", SymbolKind::Value}}}, + {"stdlib.h", + { + {"quick_exit", SymbolKind::Value}, + {"at_quick_exit", SymbolKind::Value}, + {"getenv_s", SymbolKind::Value}, + {"aligned_alloc", SymbolKind::Value}, + {"wctomb_s", SymbolKind::Value}, + {"mbstowcs_s", SymbolKind::Value}, + {"wcstombs_s", SymbolKind::Value}, + }}}; +StdLibIndex::StdLibIndex(Version std) : std_(std) {} -StdLibIndex::StdLibIndex(Version std) - : std_(std) -{} +std::vector StdLibIndex::inspect(const Compilation &c) const { + std::vector v; -std::vector StdLibIndex::inspect(const Compilation& c) const -{ - std::vector v; + //... - //... - - return v; + return v; } -bool StdLibIndex::recognizes(const char* ident) const -{ - // TODO: Index by string length. +bool StdLibIndex::recognizes(const char *ident) const { + // TODO: Index by string length. - auto f = [ident] (const Index& idx) { - for (const auto& v : idx) { - for (const auto& api : v.second) { - if (!strcmp(api.first, ident)) - return true; - } - } - return false; - }; + auto f = [ident](const Index &idx) { + for (const auto &v : idx) { + for (const auto &api : v.second) { + if (!strcmp(api.first, ident)) + return true; + } + } + return false; + }; - return f(c89idx_) - ? true - : std_ == Version::C99 && f(c99idx_) - ? true - : std_ == Version::C11 - ? f(c11idx_) - : false; + return f(c89idx_) ? true + : std_ == Version::C99 && f(c99idx_) ? true + : std_ == Version::C11 ? f(c11idx_) + : false; } diff --git a/C/stdlib-support/StdLibIndex.h b/C/stdlib-support/StdLibIndex.h index e08c1f141..dc8c202da 100644 --- a/C/stdlib-support/StdLibIndex.h +++ b/C/stdlib-support/StdLibIndex.h @@ -30,38 +30,28 @@ namespace psy { namespace C { -class StdLibIndex final -{ +class StdLibIndex final { public: - enum class Version - { - C89, - C99, - C11 - }; + enum class Version { C89, C99, C11 }; - StdLibIndex(Version std); + StdLibIndex(Version std); - std::vector inspect(const Compilation&) const; + std::vector inspect(const Compilation &) const; - bool recognizes(const char* ident) const; + bool recognizes(const char *ident) const; private: - enum class SymbolKind : char - { - Type, - Value - }; - using StdSymbol = std::pair; - using Index = std::unordered_map>; - - Version std_; - static const Index c89idx_; - static const Index c99idx_; - static const Index c11idx_; + enum class SymbolKind : char { Type, Value }; + using StdSymbol = std::pair; + using Index = std::unordered_map>; + + Version std_; + static const Index c89idx_; + static const Index c99idx_; + static const Index c11idx_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/stdlib-support/StdLibInspector.cpp b/C/stdlib-support/StdLibInspector.cpp index 951e41ce8..a9e4d0971 100644 --- a/C/stdlib-support/StdLibInspector.cpp +++ b/C/stdlib-support/StdLibInspector.cpp @@ -23,7 +23,7 @@ using namespace psy; using namespace C; -std::vector StdLibInspector::detectRequiredHeaders(const std::string& source) -{ - return { }; +std::vector +StdLibInspector::detectRequiredHeaders(const std::string &source) { + return {}; } diff --git a/C/stdlib-support/StdLibInspector.h b/C/stdlib-support/StdLibInspector.h index 41b220bc9..16129e6a0 100644 --- a/C/stdlib-support/StdLibInspector.h +++ b/C/stdlib-support/StdLibInspector.h @@ -26,13 +26,12 @@ namespace psy { namespace C { -class StdLibInspector final : SourceInspector -{ +class StdLibInspector final : SourceInspector { public: - std::vector detectRequiredHeaders(const std::string&) override; + std::vector detectRequiredHeaders(const std::string &) override; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/stdlib-support/StdLibInterceptor.cpp b/C/stdlib-support/StdLibInterceptor.cpp index 879be139f..fd3c33a48 100644 --- a/C/stdlib-support/StdLibInterceptor.cpp +++ b/C/stdlib-support/StdLibInterceptor.cpp @@ -23,18 +23,14 @@ #include "syntax/SyntaxLexeme_ALL.h" #include "syntax/SyntaxNodes.h" -#include #include +#include using namespace psy; using namespace C; -bool StdLibInterceptor::intercept(DeclaratorDeclarationSyntax*) -{ - return false; +bool StdLibInterceptor::intercept(DeclaratorDeclarationSyntax *) { + return false; } -bool StdLibInterceptor::intercept(FunctionDefinitionSyntax*) -{ - return false; -} +bool StdLibInterceptor::intercept(FunctionDefinitionSyntax *) { return false; } diff --git a/C/stdlib-support/StdLibInterceptor.h b/C/stdlib-support/StdLibInterceptor.h index 377bd1b41..81314efd9 100644 --- a/C/stdlib-support/StdLibInterceptor.h +++ b/C/stdlib-support/StdLibInterceptor.h @@ -27,18 +27,16 @@ namespace psy { namespace C { -class StdLibInterceptor final : public DeclarationInterceptor -{ +class StdLibInterceptor final : public DeclarationInterceptor { public: - bool intercept(DeclaratorDeclarationSyntax*) override; - bool intercept(FunctionDefinitionSyntax*) override; + bool intercept(DeclaratorDeclarationSyntax *) override; + bool intercept(FunctionDefinitionSyntax *) override; private: - - StdLibIndex index_ { StdLibIndex::Version::C99 }; // TODO: Config appropriately. + StdLibIndex index_{StdLibIndex::Version::C99}; // TODO: Config appropriately. }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/Accessibility.h b/C/symbols/Accessibility.h index 001309d43..ae287b363 100644 --- a/C/symbols/Accessibility.h +++ b/C/symbols/Accessibility.h @@ -36,15 +36,14 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.Accessibility * from Roslyn, the .NET Compiler Platform. */ -enum class PSY_C_API Accessibility : std::uint8_t -{ - Unknown, - Private, - Protected, - Public +enum class PSY_C_API Accessibility : std::uint8_t { + Unknown, + Private, + Protected, + Public }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/BuiltinTypeFacts.cpp b/C/symbols/BuiltinTypeFacts.cpp index e4f80dcff..1a59c30dd 100644 --- a/C/symbols/BuiltinTypeFacts.cpp +++ b/C/symbols/BuiltinTypeFacts.cpp @@ -23,29 +23,29 @@ using namespace psy; using namespace C; -bool BuiltinTypeFacts::areEquivalent(BuiltinTypeKind builtTyKind_a, BuiltinTypeKind builtTyKind_b) -{ - if (builtTyKind_a == builtTyKind_b) - return true; +bool BuiltinTypeFacts::areEquivalent(BuiltinTypeKind builtTyKind_a, + BuiltinTypeKind builtTyKind_b) { + if (builtTyKind_a == builtTyKind_b) + return true; - switch (builtTyKind_a) { - case BuiltinTypeKind::Short: - return builtTyKind_b == BuiltinTypeKind::Short_S; - case BuiltinTypeKind::Short_S: - return builtTyKind_b == BuiltinTypeKind::Short; - case BuiltinTypeKind::Int: - return builtTyKind_b == BuiltinTypeKind::Int_S; - case BuiltinTypeKind::Int_S: - return builtTyKind_b == BuiltinTypeKind::Int; - case BuiltinTypeKind::Long: - return builtTyKind_b == BuiltinTypeKind::Long_S; - case BuiltinTypeKind::Long_S: - return builtTyKind_b == BuiltinTypeKind::Long; - case BuiltinTypeKind::LongLong: - return builtTyKind_b == BuiltinTypeKind::LongLong_S; - case BuiltinTypeKind::LongLong_S: - return builtTyKind_b == BuiltinTypeKind::LongLong; - default: - return false; - } + switch (builtTyKind_a) { + case BuiltinTypeKind::Short: + return builtTyKind_b == BuiltinTypeKind::Short_S; + case BuiltinTypeKind::Short_S: + return builtTyKind_b == BuiltinTypeKind::Short; + case BuiltinTypeKind::Int: + return builtTyKind_b == BuiltinTypeKind::Int_S; + case BuiltinTypeKind::Int_S: + return builtTyKind_b == BuiltinTypeKind::Int; + case BuiltinTypeKind::Long: + return builtTyKind_b == BuiltinTypeKind::Long_S; + case BuiltinTypeKind::Long_S: + return builtTyKind_b == BuiltinTypeKind::Long; + case BuiltinTypeKind::LongLong: + return builtTyKind_b == BuiltinTypeKind::LongLong_S; + case BuiltinTypeKind::LongLong_S: + return builtTyKind_b == BuiltinTypeKind::LongLong; + default: + return false; + } } diff --git a/C/symbols/BuiltinTypeFacts.h b/C/symbols/BuiltinTypeFacts.h index 898bb3bb1..46cc1c8a3 100644 --- a/C/symbols/BuiltinTypeFacts.h +++ b/C/symbols/BuiltinTypeFacts.h @@ -31,13 +31,13 @@ namespace C { /** * \brief The BuiltinTypeFacts class. */ -class PSY_C_API BuiltinTypeFacts -{ +class PSY_C_API BuiltinTypeFacts { public: - static bool areEquivalent(BuiltinTypeKind builtTyKind_a, BuiltinTypeKind builtTyKind_b); + static bool areEquivalent(BuiltinTypeKind builtTyKind_a, + BuiltinTypeKind builtTyKind_b); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/Symbol.cpp b/C/symbols/Symbol.cpp index 5e4a68ec7..ede4b9f3d 100644 --- a/C/symbols/Symbol.cpp +++ b/C/symbols/Symbol.cpp @@ -31,85 +31,63 @@ #include #include -Symbol::Symbol(SymbolImpl* p) - : P(p) -{} - -Symbol::~Symbol() -{} - -const Assembly* Symbol::owningAssembly() const -{ - for (auto compilation : P->tree_->linkedCompilations()) { - const auto&& syms = compilation->assembly()->symbols(); - auto it = std::find(syms.begin(), syms.end(), this); - if (it != syms.end()) - return compilation->assembly(); - } - - PSY_ESCAPE_VIA_RETURN(nullptr); -} +Symbol::Symbol(SymbolImpl *p) : P(p) {} -const Scope *Symbol::scope() const -{ - return P->scope_; -} +Symbol::~Symbol() {} -Accessibility Symbol::declaredAccessibility() const -{ - return P->access_; -} +const Assembly *Symbol::owningAssembly() const { + for (auto compilation : P->tree_->linkedCompilations()) { + const auto &&syms = compilation->assembly()->symbols(); + auto it = std::find(syms.begin(), syms.end(), this); + if (it != syms.end()) + return compilation->assembly(); + } -std::vector Symbol::declaringSyntaxReferences() const -{ - return {}; + PSY_ESCAPE_VIA_RETURN(nullptr); } -SymbolKind Symbol::kind() const -{ - return P->kind_; -} +const Scope *Symbol::scope() const { return P->scope_; } -const NameSpace* Symbol::nameSpace() const -{ - return P->ns_; +Accessibility Symbol::declaredAccessibility() const { return P->access_; } + +std::vector Symbol::declaringSyntaxReferences() const { + return {}; } -Location Symbol::location() const -{ - const auto& synRefs = declaringSyntaxReferences(); +SymbolKind Symbol::kind() const { return P->kind_; } + +const NameSpace *Symbol::nameSpace() const { return P->ns_; } + +Location Symbol::location() const { + const auto &synRefs = declaringSyntaxReferences(); - std::vector locs; - std::transform(synRefs.begin(), - synRefs.end(), - std::back_inserter(locs), - [] (auto& synRef) { - return synRef.syntax()->firstToken().location(); - }); + std::vector locs; + std::transform( + synRefs.begin(), synRefs.end(), std::back_inserter(locs), + [](auto &synRef) { return synRef.syntax()->firstToken().location(); }); - // TODO - return locs.front(); + // TODO + return locs.front(); } namespace psy { namespace C { -std::string to_string(const Symbol& sym) -{ - switch (sym.kind()) { - case SymbolKind::Library: - return to_string(*sym.asLibrary()); - case SymbolKind::Function: - return to_string(*sym.asFunction()); - case SymbolKind::Value: - return to_string(*sym.asValue()); - case SymbolKind::Type: - return to_string(*sym.asType()); - default: - PSY_ESCAPE_VIA_RETURN(""); - return ""; - } +std::string to_string(const Symbol &sym) { + switch (sym.kind()) { + case SymbolKind::Library: + return to_string(*sym.asLibrary()); + case SymbolKind::Function: + return to_string(*sym.asFunction()); + case SymbolKind::Value: + return to_string(*sym.asValue()); + case SymbolKind::Type: + return to_string(*sym.asType()); + default: + PSY_ESCAPE_VIA_RETURN(""); + return ""; + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/Symbol.h b/C/symbols/Symbol.h index 46f56674f..c64544195 100644 --- a/C/symbols/Symbol.h +++ b/C/symbols/Symbol.h @@ -31,8 +31,8 @@ #include "binder/NameSpace.h" #include "syntax/SyntaxReference.h" -#include "../common/location/Location.h" #include "../common/infra/Pimpl.h" +#include "../common/location/Location.h" #include #include @@ -47,75 +47,74 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.ISymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API Symbol -{ +class PSY_C_API Symbol { public: - virtual ~Symbol(); - - /** - * The SymbolKind of \c this Symbol. - */ - SymbolKind kind() const; - - virtual LibrarySymbol* asLibrary() { return nullptr; } - virtual const LibrarySymbol* asLibrary() const { return nullptr; } - virtual FunctionSymbol* asFunction() { return nullptr; } - virtual const FunctionSymbol* asFunction() const { return nullptr; } - virtual ValueSymbol* asValue() { return nullptr; } - virtual const ValueSymbol* asValue() const { return nullptr; } - virtual TypeSymbol* asType() { return nullptr; } - virtual const TypeSymbol* asType() const { return nullptr; } - - /** - * The Assembly that owns \c this Symbol. - */ - const Assembly* owningAssembly() const; - - /** - * The Symbol that contains \c this Symbol. - */ - const Symbol* containingSymbol() const; - - /** - * The Scope of \c this Symbol. - * - * \remark 6.2.1-4 - */ - const Scope* scope() const; - - /** - * The NameSpace of \c this Symbol. - */ - const NameSpace* nameSpace() const; - - /** - * The Location of \c this Symbol. - */ - Location location() const; - - /** - * The Accessibility \c this Symbol declares. - */ - Accessibility declaredAccessibility() const; - - /** - * References to the SyntaxNodes that \a declare \c this Symbol. - */ - std::vector declaringSyntaxReferences() const; + virtual ~Symbol(); + + /** + * The SymbolKind of \c this Symbol. + */ + SymbolKind kind() const; + + virtual LibrarySymbol *asLibrary() { return nullptr; } + virtual const LibrarySymbol *asLibrary() const { return nullptr; } + virtual FunctionSymbol *asFunction() { return nullptr; } + virtual const FunctionSymbol *asFunction() const { return nullptr; } + virtual ValueSymbol *asValue() { return nullptr; } + virtual const ValueSymbol *asValue() const { return nullptr; } + virtual TypeSymbol *asType() { return nullptr; } + virtual const TypeSymbol *asType() const { return nullptr; } + + /** + * The Assembly that owns \c this Symbol. + */ + const Assembly *owningAssembly() const; + + /** + * The Symbol that contains \c this Symbol. + */ + const Symbol *containingSymbol() const; + + /** + * The Scope of \c this Symbol. + * + * \remark 6.2.1-4 + */ + const Scope *scope() const; + + /** + * The NameSpace of \c this Symbol. + */ + const NameSpace *nameSpace() const; + + /** + * The Location of \c this Symbol. + */ + Location location() const; + + /** + * The Accessibility \c this Symbol declares. + */ + Accessibility declaredAccessibility() const; + + /** + * References to the SyntaxNodes that \a declare \c this Symbol. + */ + std::vector declaringSyntaxReferences() const; protected: - DECL_PIMPL(Symbol); + DECL_PIMPL(Symbol); - Symbol(SymbolImpl* p); + Symbol(SymbolImpl *p); - // Unavailable - Symbol(const Symbol&) = delete; - Symbol& operator=(const Symbol&) = delete; + // Unavailable + Symbol(const Symbol &) = delete; + Symbol &operator=(const Symbol &) = delete; }; -std::string PSY_C_API to_string(const Symbol& sym); +std::string PSY_C_API to_string(const Symbol &sym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/SymbolKind.h b/C/symbols/SymbolKind.h index 48c3faf8b..4610066c9 100644 --- a/C/symbols/SymbolKind.h +++ b/C/symbols/SymbolKind.h @@ -39,33 +39,31 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.SymbolKind * from Roslyn, the .NET Compiler Platform. */ -enum class PSY_C_API SymbolKind : std::uint8_t -{ - UNSPECIFIED = 0, +enum class PSY_C_API SymbolKind : std::uint8_t { + UNSPECIFIED = 0, - Library, - Function, - Value, - Type, + Library, + Function, + Value, + Type, }; -inline std::string PSY_C_API to_string(SymbolKind kind) -{ - switch (kind) { - case SymbolKind::Library: - return "Library"; - case SymbolKind::Function: - return "Function"; - case SymbolKind::Value: - return "Value"; - case SymbolKind::Type: - return "Type"; - default: - PSY_ESCAPE_VIA_RETURN(""); - } +inline std::string PSY_C_API to_string(SymbolKind kind) { + switch (kind) { + case SymbolKind::Library: + return "Library"; + case SymbolKind::Function: + return "Function"; + case SymbolKind::Value: + return "Value"; + case SymbolKind::Type: + return "Type"; + default: + PSY_ESCAPE_VIA_RETURN(""); + } } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/SymbolName.cpp b/C/symbols/SymbolName.cpp index bd3fd3c1f..41b090da9 100644 --- a/C/symbols/SymbolName.cpp +++ b/C/symbols/SymbolName.cpp @@ -27,41 +27,37 @@ using namespace psy; using namespace C; -SymbolName::SymbolName() -{} +SymbolName::SymbolName() {} -SymbolName::~SymbolName() -{} +SymbolName::~SymbolName() {} -SymbolNameKind SymbolName::kind() const -{ - if (asPlainSymbolName()) - return SymbolNameKind::Plain; - if (asTagSymbolName()) - return SymbolNameKind::Tag; - if (asEmptySymbolName()) - return SymbolNameKind::Empty; +SymbolNameKind SymbolName::kind() const { + if (asPlainSymbolName()) + return SymbolNameKind::Plain; + if (asTagSymbolName()) + return SymbolNameKind::Tag; + if (asEmptySymbolName()) + return SymbolNameKind::Empty; - PSY_ASSERT_W_MSG(false, return SymbolNameKind::Plain, ""); + PSY_ASSERT_W_MSG(false, return SymbolNameKind::Plain, ""); } namespace psy { namespace C { -std::string to_string(const SymbolName& name) -{ - switch (name.kind()) { - case SymbolNameKind::Plain: - return to_string(static_cast(name)); - case SymbolNameKind::Tag: - return to_string(static_cast(name)); - case SymbolNameKind::Empty: - return to_string(static_cast(name)); - default: - PSY_ESCAPE_VIA_RETURN(""); - return ""; - } +std::string to_string(const SymbolName &name) { + switch (name.kind()) { + case SymbolNameKind::Plain: + return to_string(static_cast(name)); + case SymbolNameKind::Tag: + return to_string(static_cast(name)); + case SymbolNameKind::Empty: + return to_string(static_cast(name)); + default: + PSY_ESCAPE_VIA_RETURN(""); + return ""; + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/SymbolName.h b/C/symbols/SymbolName.h index 8aa2c8629..46d60bbd1 100644 --- a/C/symbols/SymbolName.h +++ b/C/symbols/SymbolName.h @@ -37,39 +37,38 @@ namespace C { /** * \brief The SymbolName class. */ -class PSY_C_API SymbolName -{ +class PSY_C_API SymbolName { public: - virtual ~SymbolName(); + virtual ~SymbolName(); - //!@{ - /** - * Cast \c this SymbolName. - */ - virtual PlainSymbolName* asPlainSymbolName() { return nullptr; } - virtual const PlainSymbolName* asPlainSymbolName() const { return nullptr; } - virtual TagSymbolName* asTagSymbolName() { return nullptr; } - virtual const TagSymbolName* asTagSymbolName() const { return nullptr; } - virtual EmptySymbolName* asEmptySymbolName() { return nullptr; } - virtual const EmptySymbolName* asEmptySymbolName() const { return nullptr; } + //!@{ + /** + * Cast \c this SymbolName. + */ + virtual PlainSymbolName *asPlainSymbolName() { return nullptr; } + virtual const PlainSymbolName *asPlainSymbolName() const { return nullptr; } + virtual TagSymbolName *asTagSymbolName() { return nullptr; } + virtual const TagSymbolName *asTagSymbolName() const { return nullptr; } + virtual EmptySymbolName *asEmptySymbolName() { return nullptr; } + virtual const EmptySymbolName *asEmptySymbolName() const { return nullptr; } - /** - * The SymbolName of \c this SymbolName. - */ - SymbolNameKind kind() const; + /** + * The SymbolName of \c this SymbolName. + */ + SymbolNameKind kind() const; - /** - * The text of \c this SymbolName. - */ - virtual std::string text() const = 0; + /** + * The text of \c this SymbolName. + */ + virtual std::string text() const = 0; protected: - SymbolName(); + SymbolName(); }; -std::string to_string(const SymbolName& name); +std::string to_string(const SymbolName &name); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/SymbolNameKind.h b/C/symbols/SymbolNameKind.h index 2221f3848..b895eb044 100644 --- a/C/symbols/SymbolNameKind.h +++ b/C/symbols/SymbolNameKind.h @@ -34,30 +34,23 @@ namespace C { /** * \brief The SymbolNameKind enum. */ -enum class SymbolNameKind : std::uint8_t -{ - UNSPECIFIED = 0, - Empty, - Plain, - Tag -}; - -inline std::string PSY_C_API to_string(SymbolNameKind symNameK) -{ - switch (symNameK) { - case SymbolNameKind::Empty: - return "Empty"; - case SymbolNameKind::Plain: - return "Plain"; - case SymbolNameKind::Tag: - return "Tag"; - default: - PSY_ESCAPE_VIA_RETURN(""); - return ""; - } +enum class SymbolNameKind : std::uint8_t { UNSPECIFIED = 0, Empty, Plain, Tag }; + +inline std::string PSY_C_API to_string(SymbolNameKind symNameK) { + switch (symNameK) { + case SymbolNameKind::Empty: + return "Empty"; + case SymbolNameKind::Plain: + return "Plain"; + case SymbolNameKind::Tag: + return "Tag"; + default: + PSY_ESCAPE_VIA_RETURN(""); + return ""; + } } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/SymbolName_Empty.cpp b/C/symbols/SymbolName_Empty.cpp index 44cb73e80..c94d978a6 100644 --- a/C/symbols/SymbolName_Empty.cpp +++ b/C/symbols/SymbolName_Empty.cpp @@ -23,25 +23,17 @@ namespace psy { namespace C { -std::string to_string(const EmptySymbolName&) -{ - return ""; -} +std::string to_string(const EmptySymbolName &) { return ""; } -bool operator==(const EmptySymbolName&, const EmptySymbolName&) -{ - return false; +bool operator==(const EmptySymbolName &, const EmptySymbolName &) { + return false; } -bool operator!=(const EmptySymbolName& a, const EmptySymbolName& b) -{ - return !(a == b); +bool operator!=(const EmptySymbolName &a, const EmptySymbolName &b) { + return !(a == b); } -std::string EmptySymbolName::text() const -{ - return ""; -} +std::string EmptySymbolName::text() const { return ""; } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/SymbolName_Empty.h b/C/symbols/SymbolName_Empty.h index e7b959485..360b1ac91 100644 --- a/C/symbols/SymbolName_Empty.h +++ b/C/symbols/SymbolName_Empty.h @@ -29,28 +29,29 @@ namespace C { /** * \brief The EmptySymbolName class. */ -class PSY_C_API EmptySymbolName final : public SymbolName -{ +class PSY_C_API EmptySymbolName final : public SymbolName { public: - //!@{ - /** - * Cast \c this SymbolName as an EmptySymbolName. - */ - virtual EmptySymbolName* asEmptySymbolName() override { return this; } - virtual const EmptySymbolName* asEmptySymbolName() const override { return this; } - - /** - * The text of \c this SymbolName. - */ - virtual std::string text() const override; + //!@{ + /** + * Cast \c this SymbolName as an EmptySymbolName. + */ + virtual EmptySymbolName *asEmptySymbolName() override { return this; } + virtual const EmptySymbolName *asEmptySymbolName() const override { + return this; + } + + /** + * The text of \c this SymbolName. + */ + virtual std::string text() const override; }; -std::string to_string(const EmptySymbolName& name); +std::string to_string(const EmptySymbolName &name); -bool operator==(const EmptySymbolName& a, const EmptySymbolName& b); -bool operator!=(const EmptySymbolName& a, const EmptySymbolName& b); +bool operator==(const EmptySymbolName &a, const EmptySymbolName &b); +bool operator!=(const EmptySymbolName &a, const EmptySymbolName &b); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/SymbolName_Plain.cpp b/C/symbols/SymbolName_Plain.cpp index 66e1c5326..afde90e99 100644 --- a/C/symbols/SymbolName_Plain.cpp +++ b/C/symbols/SymbolName_Plain.cpp @@ -23,32 +23,22 @@ using namespace psy; using namespace C; -std::string PlainSymbolName::text() const -{ - return s_; -} +std::string PlainSymbolName::text() const { return s_; } -PlainSymbolName::PlainSymbolName(std::string s) - : s_(std::move(s)) -{} +PlainSymbolName::PlainSymbolName(std::string s) : s_(std::move(s)) {} namespace psy { namespace C { -std::string to_string(const PlainSymbolName& name) -{ - return name.s_; -} +std::string to_string(const PlainSymbolName &name) { return name.s_; } -bool operator==(const PlainSymbolName& a, const PlainSymbolName& b) -{ - return a.s_ == b.s_; +bool operator==(const PlainSymbolName &a, const PlainSymbolName &b) { + return a.s_ == b.s_; } -bool operator!=(const PlainSymbolName& a, const PlainSymbolName& b) -{ - return !(a == b); +bool operator!=(const PlainSymbolName &a, const PlainSymbolName &b) { + return !(a == b); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/SymbolName_Plain.h b/C/symbols/SymbolName_Plain.h index 2019169cb..9c0a0ca6b 100644 --- a/C/symbols/SymbolName_Plain.h +++ b/C/symbols/SymbolName_Plain.h @@ -31,38 +31,38 @@ namespace C { /** * \brief The PlainSymbolName class. */ -class PSY_C_API PlainSymbolName final : public SymbolName -{ - friend std::string to_string(const PlainSymbolName& name); - friend bool operator==(const PlainSymbolName& a, const PlainSymbolName& b); +class PSY_C_API PlainSymbolName final : public SymbolName { + friend std::string to_string(const PlainSymbolName &name); + friend bool operator==(const PlainSymbolName &a, const PlainSymbolName &b); public: - //!@{ - /** - * Cast \c this SymbolName as a PlainSymbolName. - */ - virtual PlainSymbolName* asPlainSymbolName() override { return this; } - virtual const PlainSymbolName* asPlainSymbolName() const override { return this; } - //!@} + //!@{ + /** + * Cast \c this SymbolName as a PlainSymbolName. + */ + virtual PlainSymbolName *asPlainSymbolName() override { return this; } + virtual const PlainSymbolName *asPlainSymbolName() const override { + return this; + } + //!@} - /** - * The text of \c this SymbolName. - */ - virtual std::string text() const override; + /** + * The text of \c this SymbolName. + */ + virtual std::string text() const override; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); - PSY_GRANT_ACCESS(NamedTypeSymbol); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); + PSY_GRANT_ACCESS(NamedTypeSymbol); - PlainSymbolName(std::string s); + PlainSymbolName(std::string s); private: - std::string s_; + std::string s_; }; -bool operator!=(const PlainSymbolName& a, const PlainSymbolName& b); +bool operator!=(const PlainSymbolName &a, const PlainSymbolName &b); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/SymbolName_Tag.cpp b/C/symbols/SymbolName_Tag.cpp index 67d480c2c..3f24fc008 100644 --- a/C/symbols/SymbolName_Tag.cpp +++ b/C/symbols/SymbolName_Tag.cpp @@ -26,52 +26,41 @@ using namespace psy; using namespace C; TagSymbolName::TagSymbolName(TagChoice tagChoice, std::string tag) - : tagChoice_(tagChoice) - , tag_(std::move(tag)) -{} + : tagChoice_(tagChoice), tag_(std::move(tag)) {} -TagSymbolName::TagChoice TagSymbolName::tagChoice() const -{ - return tagChoice_; -} +TagSymbolName::TagChoice TagSymbolName::tagChoice() const { return tagChoice_; } -std::string TagSymbolName::text() const -{ - std::string prefix; - switch (tagChoice_) { - case TagChoice::Struct: - prefix = "struct "; - break; - case TagChoice::Union: - prefix = "union "; - break; - case TagChoice::Enum: - prefix = "enum "; - break; - default: - PSY_ESCAPE_VIA_RETURN(""); - return ""; - } - return prefix + tag_; +std::string TagSymbolName::text() const { + std::string prefix; + switch (tagChoice_) { + case TagChoice::Struct: + prefix = "struct "; + break; + case TagChoice::Union: + prefix = "union "; + break; + case TagChoice::Enum: + prefix = "enum "; + break; + default: + PSY_ESCAPE_VIA_RETURN(""); + return ""; + } + return prefix + tag_; } namespace psy { namespace C { -std::string to_string(const TagSymbolName& name) -{ - return name.text(); -} +std::string to_string(const TagSymbolName &name) { return name.text(); } -bool operator==(const TagSymbolName& a, const TagSymbolName& b) -{ - return a.kind() == b.kind() && a.tag_ == b.tag_; +bool operator==(const TagSymbolName &a, const TagSymbolName &b) { + return a.kind() == b.kind() && a.tag_ == b.tag_; } -bool operator!=(const TagSymbolName& a, const TagSymbolName& b) -{ - return !(a == b); +bool operator!=(const TagSymbolName &a, const TagSymbolName &b) { + return !(a == b); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/SymbolName_Tag.h b/C/symbols/SymbolName_Tag.h index b0fc26d66..72fa7a85e 100644 --- a/C/symbols/SymbolName_Tag.h +++ b/C/symbols/SymbolName_Tag.h @@ -34,57 +34,54 @@ namespace C { /** * \brief The TagSymbolName class. */ -class PSY_C_API TagSymbolName final : public SymbolName -{ - friend std::string to_string(const TagSymbolName& name); - friend bool operator==(const TagSymbolName& a, const TagSymbolName& b); +class PSY_C_API TagSymbolName final : public SymbolName { + friend std::string to_string(const TagSymbolName &name); + friend bool operator==(const TagSymbolName &a, const TagSymbolName &b); public: - //!@{ - /** - * Cast \c this SymbolNanem as a TagSymbolName. - */ - virtual TagSymbolName* asTagSymbolName() override { return this; } - virtual const TagSymbolName* asTagSymbolName() const override { return this; } - //!@} - - /** - * The choice of a tag. - * - * \remark \remark 6.7.2.3-2 - */ - enum class TagChoice : std::uint8_t - { - UNSPECIFIED = 0, - - Struct, - Union, - Enum - }; - - /** - * The TagChoice of \c this TagSymbolName. - */ - TagChoice tagChoice() const; - - /** - * The text of \c this TagSymbolName. - */ - virtual std::string text() const override; - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(NamedTypeSymbol); - - TagSymbolName(TagChoice tagK, std::string tag); + //!@{ + /** + * Cast \c this SymbolNanem as a TagSymbolName. + */ + virtual TagSymbolName *asTagSymbolName() override { return this; } + virtual const TagSymbolName *asTagSymbolName() const override { return this; } + //!@} + + /** + * The choice of a tag. + * + * \remark \remark 6.7.2.3-2 + */ + enum class TagChoice : std::uint8_t { + UNSPECIFIED = 0, + + Struct, + Union, + Enum + }; + + /** + * The TagChoice of \c this TagSymbolName. + */ + TagChoice tagChoice() const; + + /** + * The text of \c this TagSymbolName. + */ + virtual std::string text() const override; + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(NamedTypeSymbol); + + TagSymbolName(TagChoice tagK, std::string tag); private: - TagChoice tagChoice_; - std::string tag_; + TagChoice tagChoice_; + std::string tag_; }; -bool operator!=(const TagSymbolName& a, const TagSymbolName& b); +bool operator!=(const TagSymbolName &a, const TagSymbolName &b); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/Symbol_Function.cpp b/C/symbols/Symbol_Function.cpp index be62455e0..90af38f10 100644 --- a/C/symbols/Symbol_Function.cpp +++ b/C/symbols/Symbol_Function.cpp @@ -30,62 +30,45 @@ using namespace psy; using namespace C; -struct FunctionSymbol::FunctionSymbolImpl : SymbolImpl -{ - FunctionSymbolImpl(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym) - : SymbolImpl(tree, scope, containingSym, SymbolKind::Function) - , name_(nullptr) - , tySym_(nullptr) - {} - - std::unique_ptr name_; - const TypeSymbol* tySym_; +struct FunctionSymbol::FunctionSymbolImpl : SymbolImpl { + FunctionSymbolImpl(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym) + : SymbolImpl(tree, scope, containingSym, SymbolKind::Function), + name_(nullptr), tySym_(nullptr) {} + + std::unique_ptr name_; + const TypeSymbol *tySym_; }; -FunctionSymbol::FunctionSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym) - : Symbol(new FunctionSymbolImpl(tree, - scope, - containingSym)) -{} - -const SymbolName* FunctionSymbol::name() const -{ - return P_CAST->name_.get(); -} +FunctionSymbol::FunctionSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym) + : Symbol(new FunctionSymbolImpl(tree, scope, containingSym)) {} -void FunctionSymbol::setName(std::unique_ptr symName) -{ - P_CAST->name_ = std::move(symName); -} +const SymbolName *FunctionSymbol::name() const { return P_CAST->name_.get(); } -const TypeSymbol* FunctionSymbol::type() const -{ - return P_CAST->tySym_; +void FunctionSymbol::setName(std::unique_ptr symName) { + P_CAST->name_ = std::move(symName); } -void FunctionSymbol::setType(const TypeSymbol* tySym) -{ - P_CAST->tySym_ = tySym; +const TypeSymbol *FunctionSymbol::type() const { return P_CAST->tySym_; } + +void FunctionSymbol::setType(const TypeSymbol *tySym) { + P_CAST->tySym_ = tySym; } namespace psy { namespace C { -std::string to_string(const FunctionSymbol& sym) -{ - std::ostringstream oss; - oss << "[@function |"; - oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); - oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); - oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); - oss << " @]"; +std::string to_string(const FunctionSymbol &sym) { + std::ostringstream oss; + oss << "[@function |"; + oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); + oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); + oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); + oss << " @]"; - return oss.str(); + return oss.str(); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/Symbol_Function.h b/C/symbols/Symbol_Function.h index 30ad9b539..9b870010d 100644 --- a/C/symbols/Symbol_Function.h +++ b/C/symbols/Symbol_Function.h @@ -37,55 +37,52 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.IMethodSymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API FunctionSymbol final : public Symbol - , public TypeClass_NameableSymbol - , public TypeClass_TypeableSymbol -{ +class PSY_C_API FunctionSymbol final : public Symbol, + public TypeClass_NameableSymbol, + public TypeClass_TypeableSymbol { public: - //!@{ - /** - * Cast \c this Symbol as a FunctionSymbol. - */ - virtual FunctionSymbol* asFunction() override { return this; } - virtual const FunctionSymbol* asFunction() const override { return this; } - //!@} + //!@{ + /** + * Cast \c this Symbol as a FunctionSymbol. + */ + virtual FunctionSymbol *asFunction() override { return this; } + virtual const FunctionSymbol *asFunction() const override { return this; } + //!@} - /** - * The SymbolName of \c this Symbol. - */ - const SymbolName* name() const; + /** + * The SymbolName of \c this Symbol. + */ + const SymbolName *name() const; - /** - * The type of \c this FunctionSymbol. - * - * \sa FunctionSymbol::returnType - */ - const TypeSymbol* type() const; + /** + * The type of \c this FunctionSymbol. + * + * \sa FunctionSymbol::returnType + */ + const TypeSymbol *type() const; - /** - * The return type of \c this FunctionSymbol. - * - * \sa FunctionSymbol::type - */ - const TypeSymbol* returnType() const; + /** + * The return type of \c this FunctionSymbol. + * + * \sa FunctionSymbol::type + */ + const TypeSymbol *returnType() const; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); - FunctionSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym); + FunctionSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym); - virtual void setName(std::unique_ptr symName) override; - virtual void setType(const TypeSymbol* tySym) override; + virtual void setName(std::unique_ptr symName) override; + virtual void setType(const TypeSymbol *tySym) override; protected: - DECL_PIMPL_SUB(FunctionSymbol); + DECL_PIMPL_SUB(FunctionSymbol); }; -std::string PSY_C_API to_string(const FunctionSymbol& sym); +std::string PSY_C_API to_string(const FunctionSymbol &sym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/Symbol_Library.cpp b/C/symbols/Symbol_Library.cpp index e3219e160..6d49b6528 100644 --- a/C/symbols/Symbol_Library.cpp +++ b/C/symbols/Symbol_Library.cpp @@ -26,26 +26,19 @@ using namespace psy; using namespace C; -LibrarySymbol::LibrarySymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym) - : Symbol(new SymbolImpl(tree, - scope, - containingSym, - SymbolKind::Library)) -{} +LibrarySymbol::LibrarySymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym) + : Symbol(new SymbolImpl(tree, scope, containingSym, SymbolKind::Library)) {} namespace psy { namespace C { -std::string to_string(const LibrarySymbol& sym) -{ - std::ostringstream oss; - oss << "{!library !}"; +std::string to_string(const LibrarySymbol &sym) { + std::ostringstream oss; + oss << "{!library !}"; - return oss.str(); + return oss.str(); } -} // C -} // psy - +} // namespace C +} // namespace psy diff --git a/C/symbols/Symbol_Library.h b/C/symbols/Symbol_Library.h index 4628725ac..c93e5e8f2 100644 --- a/C/symbols/Symbol_Library.h +++ b/C/symbols/Symbol_Library.h @@ -42,28 +42,25 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.IModuleSymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API LibrarySymbol final : public Symbol -{ +class PSY_C_API LibrarySymbol final : public Symbol { public: - //!@{ - /** - * Cast \c this Symbol as a LibrarySymbol. - */ - virtual LibrarySymbol* asLibrary() override { return this; } - virtual const LibrarySymbol* asLibrary() const override { return this; } - //!@} + //!@{ + /** + * Cast \c this Symbol as a LibrarySymbol. + */ + virtual LibrarySymbol *asLibrary() override { return this; } + virtual const LibrarySymbol *asLibrary() const override { return this; } + //!@} -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); - LibrarySymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym); + LibrarySymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym); }; -std::string PSY_C_API to_string(const LibrarySymbol& sym); +std::string PSY_C_API to_string(const LibrarySymbol &sym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/Symbol_Type.cpp b/C/symbols/Symbol_Type.cpp index 101f26442..8a8e5d123 100644 --- a/C/symbols/Symbol_Type.cpp +++ b/C/symbols/Symbol_Type.cpp @@ -27,67 +27,42 @@ using namespace psy; using namespace C; -TypeSymbol::TypeSymbol(TypeSymbolImpl* p) - : Symbol(p) -{} +TypeSymbol::TypeSymbol(TypeSymbolImpl *p) : Symbol(p) {} -TypeSymbol::~TypeSymbol() -{} +TypeSymbol::~TypeSymbol() {} -TypeKind TypeSymbol::typeKind() const -{ - return P_CAST->tyKind_; -} +TypeKind TypeSymbol::typeKind() const { return P_CAST->tyKind_; } -bool TypeSymbol::isConstQualified() const -{ - return P->BF_.const_; -} +bool TypeSymbol::isConstQualified() const { return P->BF_.const_; } -bool TypeSymbol::isVolatileQualified() const -{ - return P->BF_.volatile_; -} +bool TypeSymbol::isVolatileQualified() const { return P->BF_.volatile_; } -bool TypeSymbol::isRestrictQualified() const -{ - return P->BF_.restrict_; -} +bool TypeSymbol::isRestrictQualified() const { return P->BF_.restrict_; } -void TypeSymbol::qualifyWithConst() -{ - P->BF_.const_ = 1; -} +void TypeSymbol::qualifyWithConst() { P->BF_.const_ = 1; } -void TypeSymbol::qualifyWithVolatile() -{ - P->BF_.volatile_ = 1; -} +void TypeSymbol::qualifyWithVolatile() { P->BF_.volatile_ = 1; } -void TypeSymbol::qualifyWithRestrict() -{ - P->BF_.restrict_ = 1; -} +void TypeSymbol::qualifyWithRestrict() { P->BF_.restrict_ = 1; } namespace psy { namespace C { -std::string PSY_C_API to_string(const TypeSymbol& tySym) -{ - switch (tySym.typeKind()) { - case TypeKind::Array: - return to_string(*tySym.asArrayType()); - case TypeKind::Function: - return to_string(*tySym.asFunctionType()); - case TypeKind::Named: - return to_string(*tySym.asNamedType()); - case TypeKind::Pointer: - return to_string(*tySym.asPointerType()); - default: - PSY_ESCAPE_VIA_RETURN(""); - return ""; - } +std::string PSY_C_API to_string(const TypeSymbol &tySym) { + switch (tySym.typeKind()) { + case TypeKind::Array: + return to_string(*tySym.asArrayType()); + case TypeKind::Function: + return to_string(*tySym.asFunctionType()); + case TypeKind::Named: + return to_string(*tySym.asNamedType()); + case TypeKind::Pointer: + return to_string(*tySym.asPointerType()); + default: + PSY_ESCAPE_VIA_RETURN(""); + return ""; + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/Symbol_Type.h b/C/symbols/Symbol_Type.h index 956049905..5159e3330 100644 --- a/C/symbols/Symbol_Type.h +++ b/C/symbols/Symbol_Type.h @@ -24,8 +24,8 @@ #include "API.h" #include "Fwds.h" -#include "TypeKind.h" #include "Symbol.h" +#include "TypeKind.h" #include "../common/infra/InternalAccess.h" @@ -45,69 +45,67 @@ namespace C { * Influence by the API of Clang/LLVM is present as well; specifically: * \c clang::Type and \c clang::QualType. */ -class PSY_C_API TypeSymbol : public Symbol -{ +class PSY_C_API TypeSymbol : public Symbol { public: - virtual ~TypeSymbol(); - - //!@{ - /** - * Cast \c this Symbol as a TypeSymbol. - */ - virtual TypeSymbol* asType() override { return this; } - virtual const TypeSymbol* asType() const override { return this; } - //!@} - - //!@{ - /** - * Cast \c this TypeSymbol. - */ - virtual ArrayTypeSymbol* asArrayType() { return nullptr; } - virtual const ArrayTypeSymbol* asArrayType() const { return nullptr; } - virtual FunctionTypeSymbol* asFunctionType() { return nullptr; } - virtual const FunctionTypeSymbol* asFunctionType() const { return nullptr; } - virtual NamedTypeSymbol* asNamedType() { return nullptr; } - virtual const NamedTypeSymbol* asNamedType() const { return nullptr; } - virtual PointerTypeSymbol* asPointerType() { return nullptr; } - virtual const PointerTypeSymbol* asPointerType() const { return nullptr; } - //!@} - - /** - * The TypeKind of \c this type. - */ - TypeKind typeKind() const; - - /** - * Whether the type is \c const qualified. - */ - bool isConstQualified() const; - - /** - * Whether the type is \c volatile qualified. - */ - bool isVolatileQualified() const; - - /** - * Whether the type is \c restrict qualified. - */ - bool isRestrictQualified() const; - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SemanticsOfTypeQualifiers); - - void qualifyWithConst(); - void qualifyWithVolatile(); - void qualifyWithRestrict(); + virtual ~TypeSymbol(); + + //!@{ + /** + * Cast \c this Symbol as a TypeSymbol. + */ + virtual TypeSymbol *asType() override { return this; } + virtual const TypeSymbol *asType() const override { return this; } + //!@} + + //!@{ + /** + * Cast \c this TypeSymbol. + */ + virtual ArrayTypeSymbol *asArrayType() { return nullptr; } + virtual const ArrayTypeSymbol *asArrayType() const { return nullptr; } + virtual FunctionTypeSymbol *asFunctionType() { return nullptr; } + virtual const FunctionTypeSymbol *asFunctionType() const { return nullptr; } + virtual NamedTypeSymbol *asNamedType() { return nullptr; } + virtual const NamedTypeSymbol *asNamedType() const { return nullptr; } + virtual PointerTypeSymbol *asPointerType() { return nullptr; } + virtual const PointerTypeSymbol *asPointerType() const { return nullptr; } + //!@} + + /** + * The TypeKind of \c this type. + */ + TypeKind typeKind() const; + + /** + * Whether the type is \c const qualified. + */ + bool isConstQualified() const; + + /** + * Whether the type is \c volatile qualified. + */ + bool isVolatileQualified() const; + + /** + * Whether the type is \c restrict qualified. + */ + bool isRestrictQualified() const; + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SemanticsOfTypeQualifiers); + + void qualifyWithConst(); + void qualifyWithVolatile(); + void qualifyWithRestrict(); protected: - DECL_PIMPL_SUB(TypeSymbol); + DECL_PIMPL_SUB(TypeSymbol); - TypeSymbol(TypeSymbolImpl* p); + TypeSymbol(TypeSymbolImpl *p); }; -std::string PSY_C_API to_string(const TypeSymbol& tySym); +std::string PSY_C_API to_string(const TypeSymbol &tySym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/Symbol_Value.cpp b/C/symbols/Symbol_Value.cpp index a0005e7c1..108290978 100644 --- a/C/symbols/Symbol_Value.cpp +++ b/C/symbols/Symbol_Value.cpp @@ -28,80 +28,53 @@ using namespace psy; using namespace C; -struct ValueSymbol::ValueSymbolImpl : SymbolImpl -{ - ValueSymbolImpl(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - ValueKind valKind) - : SymbolImpl(tree, scope, containingSym, SymbolKind::Value) - , valKind_(valKind) - , name_(nullptr) - , tySym_(nullptr) - {} - - ValueKind valKind_; - std::unique_ptr name_; - const TypeSymbol* tySym_; +struct ValueSymbol::ValueSymbolImpl : SymbolImpl { + ValueSymbolImpl(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, ValueKind valKind) + : SymbolImpl(tree, scope, containingSym, SymbolKind::Value), + valKind_(valKind), name_(nullptr), tySym_(nullptr) {} + + ValueKind valKind_; + std::unique_ptr name_; + const TypeSymbol *tySym_; }; -ValueSymbol::ValueSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - ValueKind valKind) - : Symbol(new ValueSymbolImpl(tree, - scope, - containingSym, - valKind)) -{} - -ValueSymbol::~ValueSymbol() -{} - -ValueKind ValueSymbol::valueKind() const -{ - return P_CAST->valKind_; -} +ValueSymbol::ValueSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, ValueKind valKind) + : Symbol(new ValueSymbolImpl(tree, scope, containingSym, valKind)) {} -const SymbolName* ValueSymbol::name() const -{ - return P_CAST->name_.get(); -} +ValueSymbol::~ValueSymbol() {} -const TypeSymbol* ValueSymbol::type() const -{ - return P_CAST->tySym_; -} +ValueKind ValueSymbol::valueKind() const { return P_CAST->valKind_; } -void ValueSymbol::setType(const TypeSymbol* tySym) -{ - P_CAST->tySym_ = tySym; -} +const SymbolName *ValueSymbol::name() const { return P_CAST->name_.get(); } + +const TypeSymbol *ValueSymbol::type() const { return P_CAST->tySym_; } + +void ValueSymbol::setType(const TypeSymbol *tySym) { P_CAST->tySym_ = tySym; } -void ValueSymbol::setName(std::unique_ptr symName) -{ - P_CAST->name_ = std::move(symName); +void ValueSymbol::setName(std::unique_ptr symName) { + P_CAST->name_ = std::move(symName); } namespace psy { namespace C { -std::string to_string(const ValueSymbol& sym) -{ - switch (sym.valueKind()) { - case ValueKind::Enumerator: - return to_string(*sym.asEnumerator()); - case ValueKind::Field: - return to_string(*sym.asField()); - case ValueKind::Parameter: - return to_string(*sym.asParameter()); - case ValueKind::Variable: - return to_string(*sym.asVariable()); - default: - PSY_ESCAPE_VIA_RETURN(""); - return ""; - } +std::string to_string(const ValueSymbol &sym) { + switch (sym.valueKind()) { + case ValueKind::Enumerator: + return to_string(*sym.asEnumerator()); + case ValueKind::Field: + return to_string(*sym.asField()); + case ValueKind::Parameter: + return to_string(*sym.asParameter()); + case ValueKind::Variable: + return to_string(*sym.asVariable()); + default: + PSY_ESCAPE_VIA_RETURN(""); + return ""; + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/Symbol_Value.h b/C/symbols/Symbol_Value.h index b715d34d7..5f328ee5a 100644 --- a/C/symbols/Symbol_Value.h +++ b/C/symbols/Symbol_Value.h @@ -39,67 +39,63 @@ namespace C { /** * \brief The ValueSymbol class. */ -class PSY_C_API ValueSymbol : public Symbol - , public TypeClass_NameableSymbol - , public TypeClass_TypeableSymbol -{ +class PSY_C_API ValueSymbol : public Symbol, + public TypeClass_NameableSymbol, + public TypeClass_TypeableSymbol { public: - virtual ~ValueSymbol(); - - //!@{ - /** - * Cast \c this Symbol as a ValueSymbol. - */ - virtual ValueSymbol* asValue() override { return this; } - virtual const ValueSymbol* asValue() const override { return this; } - - //!@{ - /** - * Cast \c this ValueSymbol. - */ - virtual EnumeratorSymbol* asEnumerator() { return nullptr; } - virtual const EnumeratorSymbol* asEnumerator() const { return nullptr; } - virtual FieldSymbol* asField() { return nullptr; } - virtual const FieldSymbol* asField() const { return nullptr; } - virtual VariableSymbol* asVariable() { return nullptr; } - virtual const VariableSymbol* asVariable() const { return nullptr; } - virtual ParameterSymbol* asParameter() { return nullptr; } - virtual const ParameterSymbol* asParameter() const { return nullptr; } - //!@} - - /** - * The (value) kind of \c this value. - */ - ValueKind valueKind() const; - - /** - * The SymbolName of \c this Symbol. - */ - const SymbolName* name() const; - - /** - * The type of \c this value. - */ - const TypeSymbol* type() const; - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); - - virtual void setName(std::unique_ptr symName) override; - virtual void setType(const TypeSymbol* tySym) override; + virtual ~ValueSymbol(); + + //!@{ + /** + * Cast \c this Symbol as a ValueSymbol. + */ + virtual ValueSymbol *asValue() override { return this; } + virtual const ValueSymbol *asValue() const override { return this; } + + //!@{ + /** + * Cast \c this ValueSymbol. + */ + virtual EnumeratorSymbol *asEnumerator() { return nullptr; } + virtual const EnumeratorSymbol *asEnumerator() const { return nullptr; } + virtual FieldSymbol *asField() { return nullptr; } + virtual const FieldSymbol *asField() const { return nullptr; } + virtual VariableSymbol *asVariable() { return nullptr; } + virtual const VariableSymbol *asVariable() const { return nullptr; } + virtual ParameterSymbol *asParameter() { return nullptr; } + virtual const ParameterSymbol *asParameter() const { return nullptr; } + //!@} + + /** + * The (value) kind of \c this value. + */ + ValueKind valueKind() const; + + /** + * The SymbolName of \c this Symbol. + */ + const SymbolName *name() const; + + /** + * The type of \c this value. + */ + const TypeSymbol *type() const; + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); + + virtual void setName(std::unique_ptr symName) override; + virtual void setType(const TypeSymbol *tySym) override; protected: - DECL_PIMPL_SUB(ValueSymbol); + DECL_PIMPL_SUB(ValueSymbol); - ValueSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - ValueKind valKind); + ValueSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, ValueKind valKind); }; -std::string PSY_C_API to_string(const ValueSymbol& sym); +std::string PSY_C_API to_string(const ValueSymbol &sym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeClass_NameableSymbol.cpp b/C/symbols/TypeClass_NameableSymbol.cpp index bb803cd6c..3a699d83f 100644 --- a/C/symbols/TypeClass_NameableSymbol.cpp +++ b/C/symbols/TypeClass_NameableSymbol.cpp @@ -25,7 +25,6 @@ using namespace psy; using namespace C; -TypeClass_NameableSymbol* TypeClass_NameableSymbol::asInstance(Symbol* sym) -{ - return dynamic_cast(sym); +TypeClass_NameableSymbol *TypeClass_NameableSymbol::asInstance(Symbol *sym) { + return dynamic_cast(sym); } diff --git a/C/symbols/TypeClass_NameableSymbol.h b/C/symbols/TypeClass_NameableSymbol.h index 805970a53..17b80371a 100644 --- a/C/symbols/TypeClass_NameableSymbol.h +++ b/C/symbols/TypeClass_NameableSymbol.h @@ -29,17 +29,16 @@ namespace psy { namespace C { -class PSY_C_NON_API TypeClass_NameableSymbol -{ +class PSY_C_NON_API TypeClass_NameableSymbol { public: - virtual ~TypeClass_NameableSymbol() {} + virtual ~TypeClass_NameableSymbol() {} - static TypeClass_NameableSymbol* asInstance(Symbol*); + static TypeClass_NameableSymbol *asInstance(Symbol *); - virtual void setName(std::unique_ptr symName) = 0; + virtual void setName(std::unique_ptr symName) = 0; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeClass_TypeableSymbol.cpp b/C/symbols/TypeClass_TypeableSymbol.cpp index 29035d845..7aab1e407 100644 --- a/C/symbols/TypeClass_TypeableSymbol.cpp +++ b/C/symbols/TypeClass_TypeableSymbol.cpp @@ -25,7 +25,6 @@ using namespace psy; using namespace C; -TypeClass_TypeableSymbol* TypeClass_TypeableSymbol::asInstance(Symbol* sym) -{ - return dynamic_cast(sym); +TypeClass_TypeableSymbol *TypeClass_TypeableSymbol::asInstance(Symbol *sym) { + return dynamic_cast(sym); } diff --git a/C/symbols/TypeClass_TypeableSymbol.h b/C/symbols/TypeClass_TypeableSymbol.h index 08dc9c297..5e6cbc0dc 100644 --- a/C/symbols/TypeClass_TypeableSymbol.h +++ b/C/symbols/TypeClass_TypeableSymbol.h @@ -29,17 +29,16 @@ namespace psy { namespace C { -class PSY_C_NON_API TypeClass_TypeableSymbol -{ +class PSY_C_NON_API TypeClass_TypeableSymbol { public: - virtual ~TypeClass_TypeableSymbol() {} + virtual ~TypeClass_TypeableSymbol() {} - static TypeClass_TypeableSymbol* asInstance(Symbol*); + static TypeClass_TypeableSymbol *asInstance(Symbol *); - virtual void setType(const TypeSymbol* tySym) = 0; + virtual void setType(const TypeSymbol *tySym) = 0; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeKind.h b/C/symbols/TypeKind.h index e34536e68..20d712251 100644 --- a/C/symbols/TypeKind.h +++ b/C/symbols/TypeKind.h @@ -39,33 +39,31 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.TypeKind * from Roslyn, the .NET Compiler Platform. */ -enum class PSY_C_API TypeKind : std::uint8_t -{ - UNSPECIFIED = 0, +enum class PSY_C_API TypeKind : std::uint8_t { + UNSPECIFIED = 0, - Array, - Function, - Named, - Pointer, + Array, + Function, + Named, + Pointer, }; -inline std::string PSY_C_API to_string(TypeKind tyKind) -{ - switch (tyKind) { - case TypeKind::Array: - return "Array"; - case TypeKind::Function: - return "Function"; - case TypeKind::Named: - return "Named"; - case TypeKind::Pointer: - return "Pointer"; - default: - PSY_ESCAPE_VIA_RETURN(""); - } +inline std::string PSY_C_API to_string(TypeKind tyKind) { + switch (tyKind) { + case TypeKind::Array: + return "Array"; + case TypeKind::Function: + return "Function"; + case TypeKind::Named: + return "Named"; + case TypeKind::Pointer: + return "Pointer"; + default: + PSY_ESCAPE_VIA_RETURN(""); + } } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeKind_Builtin.h b/C/symbols/TypeKind_Builtin.h index 448942559..79ab38d29 100644 --- a/C/symbols/TypeKind_Builtin.h +++ b/C/symbols/TypeKind_Builtin.h @@ -37,9 +37,9 @@ namespace C { * * The unsigned integer types are suffixed with \c _U; * the signed integer types are suffixed with \c _S. - * The signed integer types are equivalent to their "plain" versions, except for \c char: - * \c char is a separate type from signed char and unsigned char; - * its enumerator is \c Char only (without any suffix). + * The signed integer types are equivalent to their "plain" versions, except for + * \c char: \c char is a separate type from signed char and + * unsigned char; its enumerator is \c Char only (without any suffix). * * \remark 6.2.5-3 * \remark 6.2.5-17 @@ -50,101 +50,103 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.SpecialType * from Roslyn, the .NET Compiler Platform. */ -enum class PSY_C_API BuiltinTypeKind : std::uint8_t -{ - UNSPECIFIED = 0, +enum class PSY_C_API BuiltinTypeKind : std::uint8_t { + UNSPECIFIED = 0, - Void, + Void, - Char, // char - Char_S, // signed char - Char_U, // unsigned char + Char, // char + Char_S, // signed char + Char_U, // unsigned char - Short, Short_S, // short, signed short, short int, or signed short int - Short_U, // unsigned short, or unsigned short int + Short, + Short_S, // short, signed short, short int, or signed short int + Short_U, // unsigned short, or unsigned short int - Int, Int_S, // int, signed, or signed int - Int_U, // unsigned, or unsigned int + Int, + Int_S, // int, signed, or signed int + Int_U, // unsigned, or unsigned int - Long, Long_S, // long, signed long, long int, or signed long int - Long_U, // unsigned long, or unsigned long int + Long, + Long_S, // long, signed long, long int, or signed long int + Long_U, // unsigned long, or unsigned long int - LongLong, LongLong_S, // long long, signed long long, long long int, or signed long long int - LongLong_U, // unsigned long long, or unsigned long long int + LongLong, + LongLong_S, // long long, signed long long, long long int, or signed long long + // int + LongLong_U, // unsigned long long, or unsigned long long int - Float, + Float, - Double, + Double, - LongDouble, + LongDouble, - Bool, + Bool, - FloatComplex, - DoubleComplex, - LongDoubleComplex + FloatComplex, + DoubleComplex, + LongDoubleComplex }; -inline std::string PSY_C_API canonicalText(BuiltinTypeKind builtTyKind) -{ - switch (builtTyKind) { - case BuiltinTypeKind::Void: - return "void"; - case BuiltinTypeKind::Char: - return "char"; - case BuiltinTypeKind::Char_S: - return "signed char"; - case BuiltinTypeKind::Char_U: - return "unsigned char"; - case BuiltinTypeKind::Short: - return "short"; - case BuiltinTypeKind::Short_S: - return "signed short"; - case BuiltinTypeKind::Short_U: - return "unsigned short"; - case BuiltinTypeKind::Int: - return "int"; - case BuiltinTypeKind::Int_S: - return "signed int"; - case BuiltinTypeKind::Int_U: - return "unsigned int"; - case BuiltinTypeKind::Long: - return "long"; - case BuiltinTypeKind::Long_S: - return "signed long"; - case BuiltinTypeKind::Long_U: - return "unsigned long"; - case BuiltinTypeKind::LongLong: - return "long long"; - case BuiltinTypeKind::LongLong_S: - return "signed long long"; - case BuiltinTypeKind::LongLong_U: - return "unsigned long long"; - case BuiltinTypeKind::Float: - return "float"; - case BuiltinTypeKind::Double: - return "double"; - case BuiltinTypeKind::LongDouble: - return "long double"; - case BuiltinTypeKind::Bool: - return "_Bool"; - case BuiltinTypeKind::FloatComplex: - return "float _Complex"; - case BuiltinTypeKind::DoubleComplex: - return "double _Complex"; - case BuiltinTypeKind::LongDoubleComplex: - return "long double _Complex"; - default: - PSY_ESCAPE_VIA_RETURN(""); - } +inline std::string PSY_C_API canonicalText(BuiltinTypeKind builtTyKind) { + switch (builtTyKind) { + case BuiltinTypeKind::Void: + return "void"; + case BuiltinTypeKind::Char: + return "char"; + case BuiltinTypeKind::Char_S: + return "signed char"; + case BuiltinTypeKind::Char_U: + return "unsigned char"; + case BuiltinTypeKind::Short: + return "short"; + case BuiltinTypeKind::Short_S: + return "signed short"; + case BuiltinTypeKind::Short_U: + return "unsigned short"; + case BuiltinTypeKind::Int: + return "int"; + case BuiltinTypeKind::Int_S: + return "signed int"; + case BuiltinTypeKind::Int_U: + return "unsigned int"; + case BuiltinTypeKind::Long: + return "long"; + case BuiltinTypeKind::Long_S: + return "signed long"; + case BuiltinTypeKind::Long_U: + return "unsigned long"; + case BuiltinTypeKind::LongLong: + return "long long"; + case BuiltinTypeKind::LongLong_S: + return "signed long long"; + case BuiltinTypeKind::LongLong_U: + return "unsigned long long"; + case BuiltinTypeKind::Float: + return "float"; + case BuiltinTypeKind::Double: + return "double"; + case BuiltinTypeKind::LongDouble: + return "long double"; + case BuiltinTypeKind::Bool: + return "_Bool"; + case BuiltinTypeKind::FloatComplex: + return "float _Complex"; + case BuiltinTypeKind::DoubleComplex: + return "double _Complex"; + case BuiltinTypeKind::LongDoubleComplex: + return "long double _Complex"; + default: + PSY_ESCAPE_VIA_RETURN(""); + } } -inline std::string PSY_C_API to_string(BuiltinTypeKind builtTyKind) -{ - return canonicalText(builtTyKind); +inline std::string PSY_C_API to_string(BuiltinTypeKind builtTyKind) { + return canonicalText(builtTyKind); } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeKind_Named.h b/C/symbols/TypeKind_Named.h index 646b1ecb3..b770a061e 100644 --- a/C/symbols/TypeKind_Named.h +++ b/C/symbols/TypeKind_Named.h @@ -36,36 +36,34 @@ namespace C { /** * \brief The NamedTypeKind class. */ -enum class PSY_C_API NamedTypeKind : std::uint8_t -{ - UNSPECIFIED = 0, +enum class PSY_C_API NamedTypeKind : std::uint8_t { + UNSPECIFIED = 0, - Builtin, - Structure, - Union, - Enumeration, - Synonym + Builtin, + Structure, + Union, + Enumeration, + Synonym }; -inline std::string PSY_C_API to_string(NamedTypeKind namedTyK) -{ - switch (namedTyK) { - case NamedTypeKind::Builtin: - return "Builtin"; - case NamedTypeKind::Structure: - return "Structure"; - case NamedTypeKind::Union: - return "Union"; - case NamedTypeKind::Enumeration: - return "Enumeration"; - case NamedTypeKind::Synonym: - return "Synonym"; - default: - PSY_ESCAPE_VIA_RETURN(""); - } +inline std::string PSY_C_API to_string(NamedTypeKind namedTyK) { + switch (namedTyK) { + case NamedTypeKind::Builtin: + return "Builtin"; + case NamedTypeKind::Structure: + return "Structure"; + case NamedTypeKind::Union: + return "Union"; + case NamedTypeKind::Enumeration: + return "Enumeration"; + case NamedTypeKind::Synonym: + return "Synonym"; + default: + PSY_ESCAPE_VIA_RETURN(""); + } } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeSymbol_Array.cpp b/C/symbols/TypeSymbol_Array.cpp index 5c17ae027..21ea7c038 100644 --- a/C/symbols/TypeSymbol_Array.cpp +++ b/C/symbols/TypeSymbol_Array.cpp @@ -26,49 +26,36 @@ using namespace psy; using namespace C; -struct ArrayTypeSymbol::ArrayTypeSymbolImpl : TypeSymbolImpl -{ - ArrayTypeSymbolImpl(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* elemTySym) - : TypeSymbolImpl(tree, - scope, - containingSym, - TypeKind::Array) - , elemTySym_(elemTySym) - {} +struct ArrayTypeSymbol::ArrayTypeSymbolImpl : TypeSymbolImpl { + ArrayTypeSymbolImpl(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, const TypeSymbol *elemTySym) + : TypeSymbolImpl(tree, scope, containingSym, TypeKind::Array), + elemTySym_(elemTySym) {} - const TypeSymbol* elemTySym_; + const TypeSymbol *elemTySym_; }; -ArrayTypeSymbol::ArrayTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* elemTySym) - : TypeSymbol(new ArrayTypeSymbolImpl(tree, - scope, - containingSym, - elemTySym)) -{} +ArrayTypeSymbol::ArrayTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, + const TypeSymbol *elemTySym) + : TypeSymbol( + new ArrayTypeSymbolImpl(tree, scope, containingSym, elemTySym)) {} -const TypeSymbol* ArrayTypeSymbol::elementType() const -{ - return P_CAST->elemTySym_; +const TypeSymbol *ArrayTypeSymbol::elementType() const { + return P_CAST->elemTySym_; } namespace psy { namespace C { -std::string to_string(const ArrayTypeSymbol& tySym) -{ - std::ostringstream oss; - oss << "<#array type |"; - oss << " " << to_string(*tySym.elementType()); - oss << " #>"; +std::string to_string(const ArrayTypeSymbol &tySym) { + std::ostringstream oss; + oss << "<#array type |"; + oss << " " << to_string(*tySym.elementType()); + oss << " #>"; - return oss.str(); + return oss.str(); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/TypeSymbol_Array.h b/C/symbols/TypeSymbol_Array.h index eb28fffe4..2e3da2240 100644 --- a/C/symbols/TypeSymbol_Array.h +++ b/C/symbols/TypeSymbol_Array.h @@ -35,39 +35,35 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.IArrayTypeSymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API ArrayTypeSymbol final : public TypeSymbol -{ +class PSY_C_API ArrayTypeSymbol final : public TypeSymbol { public: - //!@{ - /** - * Cast \c this TypeSymbol as a ArrayTypeSymbol. - */ - virtual ArrayTypeSymbol* asArrayType() override { return this; } - virtual const ArrayTypeSymbol* asArrayType() const override { return this; } - //!@} + //!@{ + /** + * Cast \c this TypeSymbol as a ArrayTypeSymbol. + */ + virtual ArrayTypeSymbol *asArrayType() override { return this; } + virtual const ArrayTypeSymbol *asArrayType() const override { return this; } + //!@} - /** - * The element type of \c this ArrayTypeSymbol. - * - * \remark 6.2.5-20 - */ - const TypeSymbol* elementType() const; + /** + * The element type of \c this ArrayTypeSymbol. + * + * \remark 6.2.5-20 + */ + const TypeSymbol *elementType() const; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); - ArrayTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* elemTySym); + ArrayTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, const TypeSymbol *elemTySym); private: - DECL_PIMPL_SUB(ArrayTypeSymbol) + DECL_PIMPL_SUB(ArrayTypeSymbol) }; -std::string PSY_C_API to_string(const ArrayTypeSymbol& tySym); +std::string PSY_C_API to_string(const ArrayTypeSymbol &tySym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeSymbol_Function.cpp b/C/symbols/TypeSymbol_Function.cpp index 682417180..f74f228de 100644 --- a/C/symbols/TypeSymbol_Function.cpp +++ b/C/symbols/TypeSymbol_Function.cpp @@ -26,60 +26,47 @@ using namespace psy; using namespace C; -struct FunctionTypeSymbol::FunctionTypeSymbolImpl : TypeSymbolImpl -{ - FunctionTypeSymbolImpl(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* retTySym) - : TypeSymbolImpl(tree, - scope, - containingSym, - TypeKind::Function) - , retTySym_(retTySym) - {} +struct FunctionTypeSymbol::FunctionTypeSymbolImpl : TypeSymbolImpl { + FunctionTypeSymbolImpl(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, + const TypeSymbol *retTySym) + : TypeSymbolImpl(tree, scope, containingSym, TypeKind::Function), + retTySym_(retTySym) {} - const TypeSymbol* retTySym_; - std::vector parmTySyms_; + const TypeSymbol *retTySym_; + std::vector parmTySyms_; }; -FunctionTypeSymbol::FunctionTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* retTySym) - : TypeSymbol(new FunctionTypeSymbolImpl(tree, - scope, - containingSym, - retTySym)) -{} +FunctionTypeSymbol::FunctionTypeSymbol(const SyntaxTree *tree, + const Scope *scope, + const Symbol *containingSym, + const TypeSymbol *retTySym) + : TypeSymbol( + new FunctionTypeSymbolImpl(tree, scope, containingSym, retTySym)) {} -const TypeSymbol* FunctionTypeSymbol::returnType() const -{ - return P_CAST->retTySym_; +const TypeSymbol *FunctionTypeSymbol::returnType() const { + return P_CAST->retTySym_; } -std::vector FunctionTypeSymbol::parameterTypes() const -{ - return P_CAST->parmTySyms_; +std::vector FunctionTypeSymbol::parameterTypes() const { + return P_CAST->parmTySyms_; } -void FunctionTypeSymbol::addParameter(const TypeSymbol* parmTySym) -{ - P_CAST->parmTySyms_.push_back(parmTySym); +void FunctionTypeSymbol::addParameter(const TypeSymbol *parmTySym) { + P_CAST->parmTySyms_.push_back(parmTySym); } namespace psy { namespace C { -std::string to_string(const FunctionTypeSymbol& tySym) -{ - std::ostringstream oss; - oss << "<@function type |"; - oss << " return:" << to_string(*tySym.returnType()); - oss << " @>"; +std::string to_string(const FunctionTypeSymbol &tySym) { + std::ostringstream oss; + oss << "<@function type |"; + oss << " return:" << to_string(*tySym.returnType()); + oss << " @>"; - return oss.str(); + return oss.str(); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/TypeSymbol_Function.h b/C/symbols/TypeSymbol_Function.h index fe0ad5219..a7e62da3a 100644 --- a/C/symbols/TypeSymbol_Function.h +++ b/C/symbols/TypeSymbol_Function.h @@ -33,44 +33,40 @@ namespace C { * * \remark 6.2.5-20 */ -class PSY_C_API FunctionTypeSymbol final : public TypeSymbol -{ +class PSY_C_API FunctionTypeSymbol final : public TypeSymbol { public: - //!@{ - /** - * Cast \c this TypeSymbol as a FunctionTypeSymbol. - */ - virtual FunctionTypeSymbol* asFunctionType() { return this; } - virtual const FunctionTypeSymbol* asFunctionType() const { return this; } - //!@} + //!@{ + /** + * Cast \c this TypeSymbol as a FunctionTypeSymbol. + */ + virtual FunctionTypeSymbol *asFunctionType() { return this; } + virtual const FunctionTypeSymbol *asFunctionType() const { return this; } + //!@} - /** - * The return type of \c this FunctionTypeSymbol. - */ - const TypeSymbol* returnType() const; + /** + * The return type of \c this FunctionTypeSymbol. + */ + const TypeSymbol *returnType() const; - /** - * The parameter types of \c this FunctionTypeSymbol. - */ - std::vector parameterTypes() const; + /** + * The parameter types of \c this FunctionTypeSymbol. + */ + std::vector parameterTypes() const; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); - FunctionTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* retTySym); + FunctionTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, const TypeSymbol *retTySym); - void addParameter(const TypeSymbol* parmTySym); + void addParameter(const TypeSymbol *parmTySym); private: - DECL_PIMPL_SUB(FunctionTypeSymbol) + DECL_PIMPL_SUB(FunctionTypeSymbol) }; -std::string PSY_C_API to_string(const FunctionTypeSymbol& tySym); +std::string PSY_C_API to_string(const FunctionTypeSymbol &tySym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeSymbol_Named.cpp b/C/symbols/TypeSymbol_Named.cpp index fb88573cb..2203bf439 100644 --- a/C/symbols/TypeSymbol_Named.cpp +++ b/C/symbols/TypeSymbol_Named.cpp @@ -27,103 +27,75 @@ using namespace psy; using namespace C; -struct NamedTypeSymbol::NamedTypeSymbolImpl : TypeSymbolImpl -{ - NamedTypeSymbolImpl(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - NamedTypeKind namedTypeKind) - : TypeSymbolImpl(tree, - scope, - containingSym, - TypeKind::Named) - , name_(nullptr) - , namedTypeKind_(namedTypeKind) - {} - - std::unique_ptr name_; - NamedTypeKind namedTypeKind_; - BuiltinTypeKind builtTyKind_; +struct NamedTypeSymbol::NamedTypeSymbolImpl : TypeSymbolImpl { + NamedTypeSymbolImpl(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, NamedTypeKind namedTypeKind) + : TypeSymbolImpl(tree, scope, containingSym, TypeKind::Named), + name_(nullptr), namedTypeKind_(namedTypeKind) {} + + std::unique_ptr name_; + NamedTypeKind namedTypeKind_; + BuiltinTypeKind builtTyKind_; }; -NamedTypeSymbol::NamedTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, +NamedTypeSymbol::NamedTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, BuiltinTypeKind builtTyKind) - : TypeSymbol(new NamedTypeSymbolImpl(tree, - scope, - containingSym, - NamedTypeKind::Builtin)) -{ - patchBuiltinTypeKind(builtTyKind); + : TypeSymbol(new NamedTypeSymbolImpl(tree, scope, containingSym, + NamedTypeKind::Builtin)) { + patchBuiltinTypeKind(builtTyKind); } -NamedTypeSymbol::NamedTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const std::string& name) - : TypeSymbol(new NamedTypeSymbolImpl(tree, - scope, - containingSym, - NamedTypeKind::Synonym)) -{ - P_CAST->name_.reset(new PlainSymbolName(name)); +NamedTypeSymbol::NamedTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, + const std::string &name) + : TypeSymbol(new NamedTypeSymbolImpl(tree, scope, containingSym, + NamedTypeKind::Synonym)) { + P_CAST->name_.reset(new PlainSymbolName(name)); } -NamedTypeSymbol::NamedTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, +NamedTypeSymbol::NamedTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, TagSymbolName::TagChoice tagChoice, - const std::string& tag) + const std::string &tag) : TypeSymbol(new NamedTypeSymbolImpl( - tree, - scope, - containingSym, - tagChoice == TagSymbolName::TagChoice::Struct - ? NamedTypeKind::Structure - : tagChoice == TagSymbolName::TagChoice::Union - ? NamedTypeKind::Union - : tagChoice == TagSymbolName::TagChoice::Enum - ? NamedTypeKind::Enumeration - : NamedTypeKind::UNSPECIFIED)) -{ - P_CAST->name_.reset(new TagSymbolName(tagChoice, tag)); + tree, scope, containingSym, + tagChoice == TagSymbolName::TagChoice::Struct + ? NamedTypeKind::Structure + : tagChoice == TagSymbolName::TagChoice::Union ? NamedTypeKind::Union + : tagChoice == TagSymbolName::TagChoice::Enum + ? NamedTypeKind::Enumeration + : NamedTypeKind::UNSPECIFIED)) { + P_CAST->name_.reset(new TagSymbolName(tagChoice, tag)); } -const SymbolName* NamedTypeSymbol::name() const -{ - return P_CAST->name_.get(); -} +const SymbolName *NamedTypeSymbol::name() const { return P_CAST->name_.get(); } -NamedTypeKind NamedTypeSymbol::namedTypeKind() const -{ - return P_CAST->namedTypeKind_; +NamedTypeKind NamedTypeSymbol::namedTypeKind() const { + return P_CAST->namedTypeKind_; } -BuiltinTypeKind NamedTypeSymbol::builtinTypeKind() const -{ - return P_CAST->builtTyKind_; +BuiltinTypeKind NamedTypeSymbol::builtinTypeKind() const { + return P_CAST->builtTyKind_; } -void NamedTypeSymbol::patchBuiltinTypeKind(BuiltinTypeKind builtTyKind) -{ - P_CAST->name_.reset(new PlainSymbolName(canonicalText(builtTyKind))); - P_CAST->builtTyKind_ = builtTyKind; +void NamedTypeSymbol::patchBuiltinTypeKind(BuiltinTypeKind builtTyKind) { + P_CAST->name_.reset(new PlainSymbolName(canonicalText(builtTyKind))); + P_CAST->builtTyKind_ = builtTyKind; } namespace psy { namespace C { -std::string to_string(const NamedTypeSymbol& tySym) -{ - std::ostringstream oss; - oss << "<$named-type |"; - if (tySym.name()) - oss << " " << to_string(*tySym.name()); - oss << " $>"; +std::string to_string(const NamedTypeSymbol &tySym) { + std::ostringstream oss; + oss << "<$named-type |"; + if (tySym.name()) + oss << " " << to_string(*tySym.name()); + oss << " $>"; - return oss.str(); + return oss.str(); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/TypeSymbol_Named.h b/C/symbols/TypeSymbol_Named.h index 6cd2d503c..2680d7324 100644 --- a/C/symbols/TypeSymbol_Named.h +++ b/C/symbols/TypeSymbol_Named.h @@ -21,8 +21,8 @@ #ifndef PSYCHE_C_SYMBOL_NAMED_TYPE_H__ #define PSYCHE_C_SYMBOL_NAMED_TYPE_H__ -#include "Symbol_Type.h" #include "SymbolName_Tag.h" +#include "Symbol_Type.h" #include "TypeKind_Builtin.h" #include "TypeKind_Named.h" @@ -39,61 +39,53 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.INamedTypeSymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API NamedTypeSymbol final : public TypeSymbol -{ +class PSY_C_API NamedTypeSymbol final : public TypeSymbol { public: - //!@{ - /** - * Cast \c this TypeSymbol as a NamedTypeSymbol. - */ - virtual NamedTypeSymbol* asNamedType() override { return this; } - virtual const NamedTypeSymbol* asNamedType() const override { return this; } - //!@} - - /** - * The type name kind of \c this NamedTypeSymbol. - */ - NamedTypeKind namedTypeKind() const; - - /** - * The BuiltinTypeKind of \c this type. - */ - BuiltinTypeKind builtinTypeKind() const; - - /** - * The SymbolName of \c this Symbol. - */ - const SymbolName* name() const; - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); - PSY_GRANT_ACCESS(ConstraintsInTypeSpecifiers); - - NamedTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - BuiltinTypeKind builtTyK); - - NamedTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const std::string& name); - - NamedTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - TagSymbolName::TagChoice tagChoice, - const std::string& tag); - - void patchBuiltinTypeKind(BuiltinTypeKind); + //!@{ + /** + * Cast \c this TypeSymbol as a NamedTypeSymbol. + */ + virtual NamedTypeSymbol *asNamedType() override { return this; } + virtual const NamedTypeSymbol *asNamedType() const override { return this; } + //!@} + + /** + * The type name kind of \c this NamedTypeSymbol. + */ + NamedTypeKind namedTypeKind() const; + + /** + * The BuiltinTypeKind of \c this type. + */ + BuiltinTypeKind builtinTypeKind() const; + + /** + * The SymbolName of \c this Symbol. + */ + const SymbolName *name() const; + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); + PSY_GRANT_ACCESS(ConstraintsInTypeSpecifiers); + + NamedTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, BuiltinTypeKind builtTyK); + + NamedTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, const std::string &name); + + NamedTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, + TagSymbolName::TagChoice tagChoice, const std::string &tag); + + void patchBuiltinTypeKind(BuiltinTypeKind); private: - DECL_PIMPL_SUB(NamedTypeSymbol) + DECL_PIMPL_SUB(NamedTypeSymbol) }; -std::string PSY_C_API to_string(const NamedTypeSymbol& tySym); +std::string PSY_C_API to_string(const NamedTypeSymbol &tySym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/TypeSymbol_Pointer.cpp b/C/symbols/TypeSymbol_Pointer.cpp index 86b7a0554..b16ac3484 100644 --- a/C/symbols/TypeSymbol_Pointer.cpp +++ b/C/symbols/TypeSymbol_Pointer.cpp @@ -26,73 +26,55 @@ using namespace psy; using namespace C; -struct PointerTypeSymbol::PointerTypeSymbolImpl : TypeSymbolImpl -{ - PointerTypeSymbolImpl(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* refedTySym) - : TypeSymbolImpl(tree, - scope, - containingSym, - TypeKind::Pointer) - , refedTySym_(refedTySym) - , arrayDecay_(false) - , functionDecay_(false) - {} +struct PointerTypeSymbol::PointerTypeSymbolImpl : TypeSymbolImpl { + PointerTypeSymbolImpl(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, + const TypeSymbol *refedTySym) + : TypeSymbolImpl(tree, scope, containingSym, TypeKind::Pointer), + refedTySym_(refedTySym), arrayDecay_(false), functionDecay_(false) {} - const TypeSymbol* refedTySym_; - bool arrayDecay_; - bool functionDecay_; + const TypeSymbol *refedTySym_; + bool arrayDecay_; + bool functionDecay_; }; -PointerTypeSymbol::PointerTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* refedTySym) - : TypeSymbol(new PointerTypeSymbolImpl(tree, - scope, - containingSym, - refedTySym)) -{} +PointerTypeSymbol::PointerTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, + const TypeSymbol *refedTySym) + : TypeSymbol( + new PointerTypeSymbolImpl(tree, scope, containingSym, refedTySym)) {} -const TypeSymbol* PointerTypeSymbol::referencedType() const -{ - return P_CAST->refedTySym_; +const TypeSymbol *PointerTypeSymbol::referencedType() const { + return P_CAST->refedTySym_; } -bool PointerTypeSymbol::arisesFromArrayDecay() const -{ - return P_CAST->arrayDecay_; +bool PointerTypeSymbol::arisesFromArrayDecay() const { + return P_CAST->arrayDecay_; } -bool PointerTypeSymbol::arisesFromFunctionDecay() const -{ - return P_CAST->functionDecay_; +bool PointerTypeSymbol::arisesFromFunctionDecay() const { + return P_CAST->functionDecay_; } -void PointerTypeSymbol::markAsArisingFromArrayDecay() -{ - P_CAST->arrayDecay_ = true; +void PointerTypeSymbol::markAsArisingFromArrayDecay() { + P_CAST->arrayDecay_ = true; } -void PointerTypeSymbol::markAsArisingFromFunctionDecay() -{ - P_CAST->functionDecay_ = true; +void PointerTypeSymbol::markAsArisingFromFunctionDecay() { + P_CAST->functionDecay_ = true; } namespace psy { namespace C { -std::string to_string(const PointerTypeSymbol& tySym) -{ - std::ostringstream oss; - oss << "<*pointer type |"; - oss << " " << to_string(*tySym.referencedType()); - oss << " *>"; +std::string to_string(const PointerTypeSymbol &tySym) { + std::ostringstream oss; + oss << "<*pointer type |"; + oss << " " << to_string(*tySym.referencedType()); + oss << " *>"; - return oss.str(); + return oss.str(); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/TypeSymbol_Pointer.h b/C/symbols/TypeSymbol_Pointer.h index e49502358..3183102a3 100644 --- a/C/symbols/TypeSymbol_Pointer.h +++ b/C/symbols/TypeSymbol_Pointer.h @@ -35,56 +35,56 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.IPointerTypeSymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API PointerTypeSymbol final : public TypeSymbol -{ +class PSY_C_API PointerTypeSymbol final : public TypeSymbol { public: - //!@{ - /** - * Cast \c this TypeSymbol as a PointerTypeSymbol. - */ - virtual PointerTypeSymbol* asPointerType() override { return this; } - virtual const PointerTypeSymbol* asPointerType() const override { return this; } - //!@} + //!@{ + /** + * Cast \c this TypeSymbol as a PointerTypeSymbol. + */ + virtual PointerTypeSymbol *asPointerType() override { return this; } + virtual const PointerTypeSymbol *asPointerType() const override { + return this; + } + //!@} - /** - * The referenced type of \c this PointerTypeSymbol. - * - * \remark 6.2.5-20 - */ - const TypeSymbol* referencedType() const; + /** + * The referenced type of \c this PointerTypeSymbol. + * + * \remark 6.2.5-20 + */ + const TypeSymbol *referencedType() const; - /** - * Whether \c this PointerTypeSymbol arises from an array of type to pointer to type decay. - * - * \remark 6.7.6.3-7 - */ - bool arisesFromArrayDecay() const; + /** + * Whether \c this PointerTypeSymbol arises from an array of type to pointer + * to type decay. + * + * \remark 6.7.6.3-7 + */ + bool arisesFromArrayDecay() const; - /** - * Whether \c this PointerTypeSymbol arises from a function type to pointer to function type decay. - * - * \remark 6.7.6.3-8 - */ - bool arisesFromFunctionDecay() const; + /** + * Whether \c this PointerTypeSymbol arises from a function type to pointer to + * function type decay. + * + * \remark 6.7.6.3-8 + */ + bool arisesFromFunctionDecay() const; -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); - PointerTypeSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym, - const TypeSymbol* refedTySym); + PointerTypeSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym, const TypeSymbol *refedTySym); - void markAsArisingFromArrayDecay(); - void markAsArisingFromFunctionDecay(); + void markAsArisingFromArrayDecay(); + void markAsArisingFromFunctionDecay(); private: - DECL_PIMPL_SUB(PointerTypeSymbol) + DECL_PIMPL_SUB(PointerTypeSymbol) }; -std::string PSY_C_API to_string(const PointerTypeSymbol& tySym); +std::string PSY_C_API to_string(const PointerTypeSymbol &tySym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/ValueKind.h b/C/symbols/ValueKind.h index f63608352..dd4bdc500 100644 --- a/C/symbols/ValueKind.h +++ b/C/symbols/ValueKind.h @@ -36,33 +36,31 @@ namespace C { /** * \brief The ValueKind enum. */ -enum class PSY_C_API ValueKind : std::uint8_t -{ - UNSPECIFIED = 0, +enum class PSY_C_API ValueKind : std::uint8_t { + UNSPECIFIED = 0, - Enumerator, - Field, - Parameter, - Variable + Enumerator, + Field, + Parameter, + Variable }; -inline std::string PSY_C_API to_string(ValueKind valK) -{ - switch (valK) { - case ValueKind::Enumerator: - return "Enumerator"; - case ValueKind::Field: - return "Field"; - case ValueKind::Parameter: - return "Parameter"; - case ValueKind::Variable: - return "Variable"; - default: - PSY_ESCAPE_VIA_RETURN(""); - } +inline std::string PSY_C_API to_string(ValueKind valK) { + switch (valK) { + case ValueKind::Enumerator: + return "Enumerator"; + case ValueKind::Field: + return "Field"; + case ValueKind::Parameter: + return "Parameter"; + case ValueKind::Variable: + return "Variable"; + default: + PSY_ESCAPE_VIA_RETURN(""); + } } -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/ValueSymbol_Enumerator.cpp b/C/symbols/ValueSymbol_Enumerator.cpp index 0cd08f1c8..777d0ea40 100644 --- a/C/symbols/ValueSymbol_Enumerator.cpp +++ b/C/symbols/ValueSymbol_Enumerator.cpp @@ -20,37 +20,31 @@ #include "ValueSymbol_Enumerator.h" -#include "symbols/Symbol_ALL.h" #include "binder/Scope.h" +#include "symbols/Symbol_ALL.h" #include using namespace psy; using namespace C; -EnumeratorSymbol::EnumeratorSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym) - : ValueSymbol(tree, - scope, - containingSym, - ValueKind::Enumerator) -{} +EnumeratorSymbol::EnumeratorSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym) + : ValueSymbol(tree, scope, containingSym, ValueKind::Enumerator) {} namespace psy { namespace C { -std::string to_string(const EnumeratorSymbol& sym) -{ - std::ostringstream oss; - oss << "{^enumerator |"; - oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); - oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); - oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); - oss << " ^}"; +std::string to_string(const EnumeratorSymbol &sym) { + std::ostringstream oss; + oss << "{^enumerator |"; + oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); + oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); + oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); + oss << " ^}"; - return oss.str(); + return oss.str(); } -} // C -} // psi +} // namespace C +} // namespace psy diff --git a/C/symbols/ValueSymbol_Enumerator.h b/C/symbols/ValueSymbol_Enumerator.h index bfd21d957..9a6c8075c 100644 --- a/C/symbols/ValueSymbol_Enumerator.h +++ b/C/symbols/ValueSymbol_Enumerator.h @@ -29,28 +29,25 @@ namespace C { /** * \brief The EnumeratorSymbol class. */ -class PSY_C_API EnumeratorSymbol final : public ValueSymbol -{ +class PSY_C_API EnumeratorSymbol final : public ValueSymbol { public: - //!@{ - /** - * Cast \c this ValueSymbol as a EnumeratorSymbol. - */ - virtual EnumeratorSymbol* asEnumerator() { return this; } - virtual const EnumeratorSymbol* asEnumerator() const { return this; } - //!@} - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); - - EnumeratorSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym); + //!@{ + /** + * Cast \c this ValueSymbol as a EnumeratorSymbol. + */ + virtual EnumeratorSymbol *asEnumerator() { return this; } + virtual const EnumeratorSymbol *asEnumerator() const { return this; } + //!@} + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); + + EnumeratorSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym); }; -std::string PSY_C_API to_string(const EnumeratorSymbol& sym); +std::string PSY_C_API to_string(const EnumeratorSymbol &sym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/ValueSymbol_Field.cpp b/C/symbols/ValueSymbol_Field.cpp index 11acbb981..0c037bb14 100644 --- a/C/symbols/ValueSymbol_Field.cpp +++ b/C/symbols/ValueSymbol_Field.cpp @@ -20,37 +20,31 @@ #include "ValueSymbol_Field.h" -#include "symbols/Symbol_ALL.h" #include "binder/Scope.h" +#include "symbols/Symbol_ALL.h" #include using namespace psy; using namespace C; -FieldSymbol::FieldSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym) - : ValueSymbol(tree, - scope, - containingSym, - ValueKind::Field) -{} +FieldSymbol::FieldSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym) + : ValueSymbol(tree, scope, containingSym, ValueKind::Field) {} namespace psy { namespace C { -std::string to_string(const FieldSymbol& sym) -{ - std::ostringstream oss; - oss << "{%field |"; - oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); - oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); - oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); - oss << " %}"; +std::string to_string(const FieldSymbol &sym) { + std::ostringstream oss; + oss << "{%field |"; + oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); + oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); + oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); + oss << " %}"; - return oss.str(); + return oss.str(); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/ValueSymbol_Field.h b/C/symbols/ValueSymbol_Field.h index d38a28083..c2b085815 100644 --- a/C/symbols/ValueSymbol_Field.h +++ b/C/symbols/ValueSymbol_Field.h @@ -33,28 +33,25 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.IFieldSymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API FieldSymbol final : public ValueSymbol -{ +class PSY_C_API FieldSymbol final : public ValueSymbol { public: - //!@{ - /** - * Cast \c this ValueSymbol as a FieldSymbol. - */ - virtual FieldSymbol* asField() override { return this; } - virtual const FieldSymbol* asField() const override { return this; } - //!@} - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); - - FieldSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym); + //!@{ + /** + * Cast \c this ValueSymbol as a FieldSymbol. + */ + virtual FieldSymbol *asField() override { return this; } + virtual const FieldSymbol *asField() const override { return this; } + //!@} + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); + + FieldSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym); }; -std::string PSY_C_API to_string(const FieldSymbol& sym); +std::string PSY_C_API to_string(const FieldSymbol &sym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/ValueSymbol_Parameter.cpp b/C/symbols/ValueSymbol_Parameter.cpp index f1dc44627..a5c401e83 100644 --- a/C/symbols/ValueSymbol_Parameter.cpp +++ b/C/symbols/ValueSymbol_Parameter.cpp @@ -20,37 +20,31 @@ #include "ValueSymbol_Parameter.h" -#include "symbols/Symbol_ALL.h" #include "binder/Scope.h" +#include "symbols/Symbol_ALL.h" #include using namespace psy; using namespace C; -ParameterSymbol::ParameterSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym) - : ValueSymbol(tree, - scope, - containingSym, - ValueKind::Parameter) -{} +ParameterSymbol::ParameterSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym) + : ValueSymbol(tree, scope, containingSym, ValueKind::Parameter) {} namespace psy { namespace C { -std::string to_string(const ParameterSymbol& sym) -{ - std::ostringstream oss; - oss << "{~parameter |"; - oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); - oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); - oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); - oss << " ~}"; +std::string to_string(const ParameterSymbol &sym) { + std::ostringstream oss; + oss << "{~parameter |"; + oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); + oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); + oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); + oss << " ~}"; - return oss.str(); + return oss.str(); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/ValueSymbol_Parameter.h b/C/symbols/ValueSymbol_Parameter.h index 4bcaac718..0351524ed 100644 --- a/C/symbols/ValueSymbol_Parameter.h +++ b/C/symbols/ValueSymbol_Parameter.h @@ -33,28 +33,25 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.IParameterSymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API ParameterSymbol final : public ValueSymbol -{ +class PSY_C_API ParameterSymbol final : public ValueSymbol { public: - //!@{ - /** - * Cast \c this Symbol as a ParameterSymbol. - */ - virtual ParameterSymbol* asParameter() override { return this; } - virtual const ParameterSymbol* asParameter() const override { return this; } - //!@} - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); - - ParameterSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym); + //!@{ + /** + * Cast \c this Symbol as a ParameterSymbol. + */ + virtual ParameterSymbol *asParameter() override { return this; } + virtual const ParameterSymbol *asParameter() const override { return this; } + //!@} + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); + + ParameterSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym); }; -std::string PSY_C_API to_string(const ParameterSymbol& sym); +std::string PSY_C_API to_string(const ParameterSymbol &sym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/symbols/ValueSymbol_Variable.cpp b/C/symbols/ValueSymbol_Variable.cpp index 64561b618..5d62303d0 100644 --- a/C/symbols/ValueSymbol_Variable.cpp +++ b/C/symbols/ValueSymbol_Variable.cpp @@ -28,29 +28,23 @@ using namespace psy; using namespace C; -VariableSymbol::VariableSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym) - : ValueSymbol(tree, - scope, - containingSym, - ValueKind::Variable) -{} +VariableSymbol::VariableSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym) + : ValueSymbol(tree, scope, containingSym, ValueKind::Variable) {} namespace psy { namespace C { -std::string to_string(const VariableSymbol& sym) -{ - std::ostringstream oss; - oss << "{`variable |"; - oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); - oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); - oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); - oss << " `}"; +std::string to_string(const VariableSymbol &sym) { + std::ostringstream oss; + oss << "{`variable |"; + oss << " " << (sym.name() ? to_string(*sym.name()) : "name:NULL"); + oss << " " << (sym.type() ? to_string(*sym.type()) : "type:NULL"); + oss << " " << (sym.scope() ? to_string(sym.scope()->kind()) : "scope:NULL"); + oss << " `}"; - return oss.str(); + return oss.str(); } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/symbols/ValueSymbol_Variable.h b/C/symbols/ValueSymbol_Variable.h index 839d27f77..775029154 100644 --- a/C/symbols/ValueSymbol_Variable.h +++ b/C/symbols/ValueSymbol_Variable.h @@ -33,28 +33,25 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.ILocalSymbol * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API VariableSymbol final : public ValueSymbol -{ +class PSY_C_API VariableSymbol final : public ValueSymbol { public: - //!@{ - /** - * Cast \c this Symbol as a VariableSymbol. - */ - virtual VariableSymbol* asVariable() override { return this; } - virtual const VariableSymbol* asVariable() const override { return this; } - //!@} - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(Binder); - - VariableSymbol(const SyntaxTree* tree, - const Scope* scope, - const Symbol* containingSym); + //!@{ + /** + * Cast \c this Symbol as a VariableSymbol. + */ + virtual VariableSymbol *asVariable() override { return this; } + virtual const VariableSymbol *asVariable() const override { return this; } + //!@} + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(Binder); + + VariableSymbol(const SyntaxTree *tree, const Scope *scope, + const Symbol *containingSym); }; -std::string PSY_C_API to_string(const VariableSymbol& sym); +std::string PSY_C_API to_string(const VariableSymbol &sym); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxDumper.h b/C/syntax/SyntaxDumper.h index 1ecc1f81e..c4a6eb260 100644 --- a/C/syntax/SyntaxDumper.h +++ b/C/syntax/SyntaxDumper.h @@ -25,7 +25,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, The Qt Company gives you certain additional +** In addition, as a special exception, The Qt Company gives you certain +*additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** @@ -52,839 +53,824 @@ namespace psy { namespace C { -class PSY_C_NON_API SyntaxDumper : protected SyntaxVisitor -{ +class PSY_C_NON_API SyntaxDumper : protected SyntaxVisitor { public: - SyntaxDumper(SyntaxTree* tree) - : SyntaxVisitor(tree) - {} + SyntaxDumper(SyntaxTree *tree) : SyntaxVisitor(tree) {} protected: - virtual void terminal(const SyntaxToken&, const SyntaxNode*) {} - virtual void nonterminal(const SyntaxNode* node) { visit(node); } - - //--------------// - // Declarations // - //--------------// - virtual Action visitTranslationUnit(const TranslationUnitSyntax* node) override - { - for (auto iter = node->declarations(); iter; iter = iter->next) - nonterminal(iter->value); - return Action::Skip; - } - - void traverseDeclaration(const DeclarationSyntax* node) - { - terminal(node->extensionKeyword(), node); - } - - virtual Action visitIncompleteDeclaration(const IncompleteDeclarationSyntax* node) override - { - traverseDeclaration(node); - for (auto it = node->specifiers(); it; it = it->next) - nonterminal(it->value); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - void traverseTypeDeclaration(const TypeDeclarationSyntax* node) - { - traverseDeclaration(node); - nonterminal(node->typeSpecifier()); - terminal(node->semicolonToken(), node); - } - - virtual Action visitStructOrUnionDeclaration(const StructOrUnionDeclarationSyntax* node) override - { - traverseTypeDeclaration(node); - return Action::Skip; - } - - virtual Action visitEnumDeclaration(const EnumDeclarationSyntax* node) override - { - traverseTypeDeclaration(node); - return Action::Skip; - } - - virtual Action visitEnumeratorDeclaration(const EnumeratorDeclarationSyntax* node) override - { - traverseDeclaration(node); - terminal(node->identifierToken(), node); - for (auto iter = node->attributes(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->equalsToken(), node); - nonterminal(node->expression()); - terminal(node->commaToken(), node); - return Action::Skip; - } - - virtual Action visitVariableAndOrFunctionDeclaration(const VariableAndOrFunctionDeclarationSyntax* node) override - { - traverseDeclaration(node); - for (auto iter = node->specifiers(); iter; iter = iter->next) - nonterminal(iter->value); - for (auto iter = node->declarators(); iter; iter = iter->next) { - nonterminal(iter->value); - terminal(iter->delimiterToken(), node); - } - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitFieldDeclaration(const FieldDeclarationSyntax* node) override - { - traverseDeclaration(node); - for (auto iter = node->specifiers(); iter; iter = iter->next) - nonterminal(iter->value); - for (auto iter = node->declarators(); iter; iter = iter->next) { - nonterminal(iter->value); - terminal(iter->delimiterToken(), node); - } - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitParameterDeclaration(const ParameterDeclarationSyntax* node) override - { - for (auto iter = node->specifiers(); iter; iter = iter->next) - nonterminal(iter->value); - nonterminal(node->declarator()); - return Action::Skip; - } - - virtual Action visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax* node) override - { - terminal(node->staticAssertKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->expression()); - terminal(node->commaToken(), node); - nonterminal(node->stringLiteral()); - terminal(node->closeParenthesisToken(), node); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitFunctionDefinition(const FunctionDefinitionSyntax* node) override - { - traverseDeclaration(node); - for (auto iter = node->specifiers(); iter; iter = iter->next) - nonterminal(iter->value); - nonterminal(node->declarator()); - for (auto iter = node->extKR_params(); iter; iter = iter->next) - nonterminal(iter->value); - nonterminal(node->body()); - return Action::Skip; - } - - virtual Action visitExtGNU_AsmStatementDeclaration(const ExtGNU_AsmStatementDeclarationSyntax* node) override - { - traverseDeclaration(node); - terminal(node->asmKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->stringLiteral()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitExtKR_ParameterDeclaration(const ExtKR_ParameterDeclarationSyntax* node) override - { - for (auto iter = node->specifiers(); iter; iter = iter->next) - nonterminal(iter->value); - for (auto iter = node->declarators(); iter; iter = iter->next) { - nonterminal(iter->value); - terminal(iter->delimiterToken(), node); - } - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - /* Specifiers */ - virtual Action visitTrivialSpecifier_Common(const TrivialSpecifierSyntax* node) - { - terminal(node->specifierToken(), node); - return Action::Skip; - } - - virtual Action visitStorageClass(const StorageClassSyntax* node) override - { - return visitTrivialSpecifier_Common(node); - } - - virtual Action visitBuiltinTypeSpecifier(const BuiltinTypeSpecifierSyntax* node) override - { - return visitTrivialSpecifier_Common(node); - } - - virtual Action visitTagTypeSpecifier(const TagTypeSpecifierSyntax* node) override - { - terminal(node->keyword(), node); - for (auto iter = node->attributes(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->tagToken(), node); - terminal(node->openBraceToken(), node); - for (auto iter = node->declarations(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->closeBraceToken(), node); - for (auto iter = node->attributes_PostCloseBrace(); iter; iter = iter->next) - nonterminal(iter->value); - return Action::Skip; - } - - virtual Action visitAtomicTypeSpecifier(const AtomicTypeSpecifierSyntax* node) override - { - terminal(node->atomicKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->typeName()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitTypedefName(const TypedefNameSyntax* node) override - { - terminal(node->identifierToken(), node); - return Action::Skip; - } - - virtual Action visitTypeQualifier(const TypeQualifierSyntax* node) override - { - return visitTrivialSpecifier_Common(node); - } - - virtual Action visitFunctionSpecifier(const FunctionSpecifierSyntax* node) override - { - return visitTrivialSpecifier_Common(node); - } - - virtual Action visitAlignmentSpecifier(const AlignmentSpecifierSyntax* node) override - { - terminal(node->alignasKeyword(), node); - nonterminal(node->tyReference()); - return Action::Skip; - } - - virtual Action visitExtGNU_Typeof(const ExtGNU_TypeofSyntax* node) override - { - terminal(node->typeofKeyword(), node); - nonterminal(node->tyReference()); - return Action::Skip; - } - - virtual Action visitExtGNU_AttributeSpecifier(const ExtGNU_AttributeSpecifierSyntax* node) override - { - terminal(node->attributeKeyword(), node); - terminal(node->openOuterParenthesisToken(), node); - terminal(node->openInnerParenthesisToken(), node); - for (auto iter = node->attributes(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->closeInnerParenthesisToken(), node); - terminal(node->closeOuterParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitExtGNU_Attribute(const ExtGNU_AttributeSyntax* node) override - { - terminal(node->keywordOrIdentifierToken(), node); - terminal(node->openParenthesisToken(), node); - for (auto iter = node->expressions(); iter; iter = iter->next) { - nonterminal(iter->value); - terminal(iter->delimiterToken(), node); - } - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitExtGNU_AsmLabel(const ExtGNU_AsmLabelSyntax* node) override - { - terminal(node->asmKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->stringLiteral()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - /* Declarators */ - virtual Action visitArrayOrFunctionDeclarator(const ArrayOrFunctionDeclaratorSyntax* node) override - { - for (auto iter = node->attributes(); iter; iter = iter->next) - nonterminal(iter->value); - nonterminal(node->innerDeclarator()); - nonterminal(node->suffix()); - for (auto iter = node->attributes_PostDeclarator(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->equalsToken(), node); - nonterminal(node->initializer()); - return Action::Skip; - } - - virtual Action visitPointerDeclarator(const PointerDeclaratorSyntax* node) override - { - for (auto iter = node->attributes(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->asteriskToken(), node); - for (auto iter = node->qualifiersAndAttributes(); iter; iter = iter->next) - nonterminal(iter->value); - nonterminal(node->innerDeclarator()); - terminal(node->equalsToken(), node); - nonterminal(node->initializer()); - return Action::Skip; - } - - virtual Action visitParenthesizedDeclarator(const ParenthesizedDeclaratorSyntax* node) override - { - terminal(node->openParenthesisToken(), node); - nonterminal(node->innerDeclarator()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitIdentifierDeclarator(const IdentifierDeclaratorSyntax* node) override - { - terminal(node->identifierToken(), node); - for (auto iter = node->attributes_PostIdentifier(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->equalsToken(), node); - nonterminal(node->initializer()); - return Action::Skip; - } - - virtual Action visitSubscriptSuffix(const SubscriptSuffixSyntax* node) override - { - terminal(node->openBracketToken(), node); - for (auto iter = node->qualifiersAndAttributes(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->staticKeyword(), node); - for (auto iter = node->qualifiersAndAttributes_PostStatic(); iter; iter = iter->next) - nonterminal(iter->value); - nonterminal(node->expression()); - terminal(node->asteriskToken(), node); - terminal(node->closeBracketToken(), node); - return Action::Skip; - } - - virtual Action visitParameterSuffix(const ParameterSuffixSyntax* node) override - { - terminal(node->openParenthesisToken(), node); - for (auto iter = node->parameters(); iter; iter = iter->next) { - nonterminal(iter->value); - terminal(iter->delimiterToken(), node); - } - terminal(node->ellipsisToken(), node); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitBitfieldDeclarator(const BitfieldDeclaratorSyntax* node) override - { - nonterminal(node->innerDeclarator()); - terminal(node->colonToken(), node); - nonterminal(node->expression()); - for (auto iter = node->attributes(); iter; iter = iter->next) - nonterminal(iter->value); - return Action::Skip; - } - - /* Initializers */ - virtual Action visitExpressionInitializer(const ExpressionInitializerSyntax* node) override - { - nonterminal(node->expression()); - return Action::Skip; - } - - virtual Action visitBraceEnclosedInitializer(const BraceEnclosedInitializerSyntax* node) override - { - terminal(node->openBraceToken(), node); - for (auto iter = node->initializerList(); iter; iter = iter->next) { - nonterminal(iter->value); - terminal(iter->delimiterToken(), node); - } - terminal(node->closeBraceToken(), node); - return Action::Skip; - } - - virtual Action visitDesignatedInitializer(const DesignatedInitializerSyntax* node) override - { - for (auto iter = node->designators(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->equalsToken(), node); - nonterminal(node->initializer()); - return Action::Skip; - } - - virtual Action visitFieldDesignator(const FieldDesignatorSyntax* node) override - { - terminal(node->dotToken(), node); - terminal(node->identifierToken(), node); - return Action::Skip; - } - - virtual Action visitArrayDesignator(const ArrayDesignatorSyntax* node) override - { - terminal(node->openBracketToken(), node); - nonterminal(node->expression()); - terminal(node->closeBracketToken(), node); - return Action::Skip; - } - - virtual Action visitOffsetOfDesignator(const OffsetOfDesignatorSyntax* node) override - { - terminal(node->identifierToken(), node); - for (auto iter = node->designators(); iter; iter = iter->next) - nonterminal(iter->value); - return Action::Skip; - } - - //-------------// - // Expressions // - //-------------// - void traverseExpression(const ExpressionSyntax* node) - { - terminal(node->extensionKeyword(), node); - } - - virtual Action visitIdentifierName(const IdentifierNameSyntax* node) override - { - traverseExpression(node); - terminal(node->identifierToken(), node); - return Action::Skip; - } - - virtual Action visitPredefinedName(const PredefinedNameSyntax* node) override - { - traverseExpression(node); - terminal(node->predefinedToken(), node); - return Action::Skip; - } - - virtual Action visitConstantExpression(const ConstantExpressionSyntax* node) override - { - traverseExpression(node); - terminal(node->constantToken(), node); - return Action::Skip; - } - - virtual Action visitStringLiteralExpression(const StringLiteralExpressionSyntax* node) override - { - traverseExpression(node); - terminal(node->literalToken(), node); - nonterminal(node->adjacent()); - return Action::Skip; - } - - virtual Action visitParenthesizedExpression(const ParenthesizedExpressionSyntax* node) override - { - traverseExpression(node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->expression()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitGenericSelectionExpression(const GenericSelectionExpressionSyntax* node) override - { - traverseExpression(node); - terminal(node->genericKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->expression()); - terminal(node->commaToken(), node); - for (auto it = node->associations(); it; it = it->next) { - nonterminal(it->value); - terminal(it->delimiterToken(), node); - } - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitGenericAssociation(const GenericAssociationSyntax* node) override - { - nonterminal(node->typeName_or_default()); - terminal(node->colonToken(), node); - nonterminal(node->expression()); - return Action::Skip; - } - - virtual Action visitExtGNU_EnclosedCompoundStatementExpression(const ExtGNU_EnclosedCompoundStatementExpressionSyntax* node) override - { - terminal(node->openParenthesisToken(), node); - nonterminal(node->statement()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitExtGNU_ComplexValuedExpression(const ExtGNU_ComplexValuedExpressionSyntax* node) override - { - terminal(node->operatorToken(), node); - nonterminal(node->expression()); - return Action::Skip; - } - - /* Operations */ - virtual Action visitPrefixUnaryExpression(const PrefixUnaryExpressionSyntax* node) override - { - traverseExpression(node); - terminal(node->operatorToken(), node); - nonterminal(node->expression()); - return Action::Skip; - } - - virtual Action visitPostfixUnaryExpression(const PostfixUnaryExpressionSyntax* node) override - { - traverseExpression(node); - nonterminal(node->expression()); - terminal(node->operatorToken(), node); - return Action::Skip; - } - - virtual Action visitMemberAccessExpression(const MemberAccessExpressionSyntax* node) override - { - traverseExpression(node); - nonterminal(node->expression()); - terminal(node->operatorToken(), node); - nonterminal(node->identifier()); - return Action::Skip; - } - - virtual Action visitArraySubscriptExpression(const ArraySubscriptExpressionSyntax* node) override - { - traverseExpression(node); - nonterminal(node->expression()); - terminal(node->openBracketToken(), node); - nonterminal(node->argument()); - terminal(node->closeBracketToken(), node); - return Action::Skip; - } - - - virtual Action visitTypeTraitExpression(const TypeTraitExpressionSyntax* node) override - { - traverseExpression(node); - terminal(node->operatorToken(), node); - nonterminal(node->tyReference()); - return Action::Skip; - } - - virtual Action visitCastExpression(const CastExpressionSyntax* node) override - { - traverseExpression(node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->typeName()); - terminal(node->closeParenthesisToken(), node); - nonterminal(node->expression()); - return Action::Skip; - } - - virtual Action visitCallExpression(const CallExpressionSyntax* node) override - { - nonterminal(node->expression()); - terminal(node->openParenthesisToken(), node); - for (auto iter = node->arguments(); iter; iter = iter->next) { - nonterminal(iter->value); - terminal(iter->delimiterToken(), node); - } - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitVAArgumentExpression(const VAArgumentExpressionSyntax* node) override - { - terminal(node->keyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->expression()); - terminal(node->commaToken(), node); - nonterminal(node->typeName()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitOffsetOfExpression(const OffsetOfExpressionSyntax* node) override - { - terminal(node->keyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->typeName()); - terminal(node->commaToken(), node); - nonterminal(node->offsetOfDesignator()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - virtual Action visitCompoundLiteralExpression(const CompoundLiteralExpressionSyntax* node) override - { - terminal(node->openParenthesisToken(), node); - nonterminal(node->typeName()); - terminal(node->closeParenthesisToken(), node); - nonterminal(node->initializer()); - return Action::Skip; - } - - virtual Action visitBinaryExpression(const BinaryExpressionSyntax* node) override - { - nonterminal(node->left()); - terminal(node->operatorToken(), node); - nonterminal(node->right()); - return Action::Skip; - } - - virtual Action visitConditionalExpression(const ConditionalExpressionSyntax* node) override - { - nonterminal(node->condition()); - terminal(node->questionToken(), node); - nonterminal(node->whenTrue()); - terminal(node->colonToken(), node); - nonterminal(node->whenFalse()); - return Action::Skip; - } - - virtual Action visitAssignmentExpression(const AssignmentExpressionSyntax* node) override - { - nonterminal(node->left()); - terminal(node->operatorToken(), node); - nonterminal(node->right()); - return Action::Skip; - } - - virtual Action visitSequencingExpression(const SequencingExpressionSyntax* node) override - { - nonterminal(node->left()); - terminal(node->operatorToken(), node); - nonterminal(node->right()); - return Action::Skip; - } - - virtual Action visitExtGNU_ChooseExpression(const ExtGNU_ChooseExpressionSyntax* node) override - { - terminal(node->keyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->constantExpression()); - terminal(node->commaToken1(), node); - nonterminal(node->expression1()); - terminal(node->commaToken2(), node); - nonterminal(node->expression2()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - //------------// - // Statements // - //------------// - virtual Action visitCompoundStatement(const CompoundStatementSyntax* node) override - { - terminal(node->openBraceToken(), node); - for (auto iter = node->statements(); iter; iter = iter->next) - nonterminal(iter->value); - terminal(node->closeBraceToken(), node); - return Action::Skip; - } - - virtual Action visitDeclarationStatement(const DeclarationStatementSyntax* node) override - { - nonterminal(node->declaration()); - return Action::Skip; - } - - virtual Action visitExpressionStatement(const ExpressionStatementSyntax* node) override - { - nonterminal(node->expression()); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitLabeledStatement(const LabeledStatementSyntax* node) override - { - terminal(node->labelToken(), node); - nonterminal(node->expression()); - terminal(node->colonToken(), node); - nonterminal(node->statement()); - return Action::Skip; - } - - virtual Action visitIfStatement(const IfStatementSyntax* node) override - { - terminal(node->ifKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->condition()); - terminal(node->closeParenthesisToken(), node); - nonterminal(node->statement()); - terminal(node->elseKeyword(), node); - nonterminal(node->elseStatement()); - return Action::Skip; - } - - virtual Action visitSwitchStatement(const SwitchStatementSyntax* node) override - { - terminal(node->switchKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->condition()); - terminal(node->closeParenthesisToken(), node); - nonterminal(node->statement()); - return Action::Skip; - } - - virtual Action visitWhileStatement(const WhileStatementSyntax* node) override - { - terminal(node->whileKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->condition()); - terminal(node->closeParenthesisToken(), node); - nonterminal(node->statement()); - return Action::Skip; - } - - virtual Action visitDoStatement(const DoStatementSyntax* node) override - { - terminal(node->doKeyword(), node); - nonterminal(node->statement()); - terminal(node->whileKeyword(), node); - terminal(node->openParenthesisToken(), node); - nonterminal(node->condition()); - terminal(node->closeParenthesisToken(), node); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitForStatement(const ForStatementSyntax* node) override - { - terminal(node->forKeyword(), node); - terminal(node->openParenthesisToken(), node); - terminal(node->extensionKeyword(), node); - nonterminal(node->initializer()); - nonterminal(node->condition()); - terminal(node->semicolonToken(), node); - nonterminal(node->expression()); - terminal(node->closeParenthesisToken(), node); - nonterminal(node->statement()); - return Action::Skip; - } - - virtual Action visitGotoStatement(const GotoStatementSyntax* node) override - { - terminal(node->gotoKeyword(), node); - terminal(node->identifierToken(), node); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitContinueStatement(const ContinueStatementSyntax* node) override - { - terminal(node->continueKeyword(), node); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitBreakStatement(const BreakStatementSyntax* node) override - { - terminal(node->breakKeyword(), node); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitReturnStatement(const ReturnStatementSyntax* node) override - { - terminal(node->returnKeyword(), node); - nonterminal(node->expression()); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitExtGNU_AsmStatement(const ExtGNU_AsmStatementSyntax* node) override - { - terminal(node->asmKeyword(), node); - for (auto it = node->asmQualifiers(); it; it = it->next) - nonterminal(it->value); - terminal(node->openParenthesisToken(), node); - nonterminal(node->stringLiteral()); - terminal(node->colon1Token(), node); - for (auto it = node->outputOperands(); it; it = it->next) { - nonterminal(it->value); - terminal(it->delimiterToken(), node); - } - terminal(node->colon2Token(), node); - for (auto it = node->inputOperands(); it; it = it->next) { - nonterminal(it->value); - terminal(it->delimiterToken(), node); - } - terminal(node->colon3Token(), node); - for (auto it = node->clobbers(); it; it = it->next) { - nonterminal(it->value); - terminal(it->delimiterToken(), node); - } - terminal(node->colon4Token(), node); - for (auto it = node->gotoLabels(); it; it = it->next) { - nonterminal(it->value); - terminal(it->delimiterToken(), node); - } - terminal(node->closeParenthesisToken(), node); - terminal(node->semicolonToken(), node); - return Action::Skip; - } - - virtual Action visitExtGNU_AsmQualifier(const ExtGNU_AsmQualifierSyntax* node) override - { - terminal(node->asmQualifier(), node); - return Action::Skip; - } - - virtual Action visitExtGNU_AsmOperand(const ExtGNU_AsmOperandSyntax* node) override - { - terminal(node->openBracketToken(), node); - nonterminal(node->identifier()); - terminal(node->closeBracketToken(), node); - nonterminal(node->stringLiteral()); - terminal(node->openParenthesisToken(), node); - nonterminal(node->expression()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - //--------// - // Common // - //--------// - virtual Action visitTypeName(const TypeNameSyntax* node) override - { - for (auto it = node->specifiers(); it; it = it->next) - nonterminal(it->value); - nonterminal(node->declarator()); - return Action::Skip; - } - - virtual Action visitExpressionAsTypeReference(const ExpressionAsTypeReferenceSyntax* node) override - { - nonterminal(node->expression()); - return Action::Skip; - } - - virtual Action visitTypeNameAsTypeReference(const TypeNameAsTypeReferenceSyntax* node) override - { - terminal(node->openParenthesisToken(), node); - nonterminal(node->typeName()); - terminal(node->closeParenthesisToken(), node); - return Action::Skip; - } - - //-------------// - // Ambiguities // - //-------------// - virtual Action visitAmbiguousTypeNameOrExpressionAsTypeReference(const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax* node) override - { - nonterminal(node->expressionAsTypeReference()); - nonterminal(node->typeNameAsTypeReference()); - return Action::Skip; - } - - virtual Action visitAmbiguousCastOrBinaryExpression(const AmbiguousCastOrBinaryExpressionSyntax* node) override - { - nonterminal(node->castExpression()); - nonterminal(node->binaryExpression()); - return Action::Skip; - } - - virtual Action visitAmbiguousExpressionOrDeclarationStatement(const AmbiguousExpressionOrDeclarationStatementSyntax* node) override - { - nonterminal(node->declarationStatement()); - nonterminal(node->expressionStatement()); - return Action::Skip; - } + virtual void terminal(const SyntaxToken &, const SyntaxNode *) {} + virtual void nonterminal(const SyntaxNode *node) { visit(node); } + + //--------------// + // Declarations // + //--------------// + virtual Action + visitTranslationUnit(const TranslationUnitSyntax *node) override { + for (auto iter = node->declarations(); iter; iter = iter->next) + nonterminal(iter->value); + return Action::Skip; + } + + void traverseDeclaration(const DeclarationSyntax *node) { + terminal(node->extensionKeyword(), node); + } + + virtual Action + visitIncompleteDeclaration(const IncompleteDeclarationSyntax *node) override { + traverseDeclaration(node); + for (auto it = node->specifiers(); it; it = it->next) + nonterminal(it->value); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + void traverseTypeDeclaration(const TypeDeclarationSyntax *node) { + traverseDeclaration(node); + nonterminal(node->typeSpecifier()); + terminal(node->semicolonToken(), node); + } + + virtual Action visitStructOrUnionDeclaration( + const StructOrUnionDeclarationSyntax *node) override { + traverseTypeDeclaration(node); + return Action::Skip; + } + + virtual Action + visitEnumDeclaration(const EnumDeclarationSyntax *node) override { + traverseTypeDeclaration(node); + return Action::Skip; + } + + virtual Action + visitEnumeratorDeclaration(const EnumeratorDeclarationSyntax *node) override { + traverseDeclaration(node); + terminal(node->identifierToken(), node); + for (auto iter = node->attributes(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->equalsToken(), node); + nonterminal(node->expression()); + terminal(node->commaToken(), node); + return Action::Skip; + } + + virtual Action visitVariableAndOrFunctionDeclaration( + const VariableAndOrFunctionDeclarationSyntax *node) override { + traverseDeclaration(node); + for (auto iter = node->specifiers(); iter; iter = iter->next) + nonterminal(iter->value); + for (auto iter = node->declarators(); iter; iter = iter->next) { + nonterminal(iter->value); + terminal(iter->delimiterToken(), node); + } + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitFieldDeclaration(const FieldDeclarationSyntax *node) override { + traverseDeclaration(node); + for (auto iter = node->specifiers(); iter; iter = iter->next) + nonterminal(iter->value); + for (auto iter = node->declarators(); iter; iter = iter->next) { + nonterminal(iter->value); + terminal(iter->delimiterToken(), node); + } + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitParameterDeclaration(const ParameterDeclarationSyntax *node) override { + for (auto iter = node->specifiers(); iter; iter = iter->next) + nonterminal(iter->value); + nonterminal(node->declarator()); + return Action::Skip; + } + + virtual Action visitStaticAssertDeclaration( + const StaticAssertDeclarationSyntax *node) override { + terminal(node->staticAssertKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->expression()); + terminal(node->commaToken(), node); + nonterminal(node->stringLiteral()); + terminal(node->closeParenthesisToken(), node); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitFunctionDefinition(const FunctionDefinitionSyntax *node) override { + traverseDeclaration(node); + for (auto iter = node->specifiers(); iter; iter = iter->next) + nonterminal(iter->value); + nonterminal(node->declarator()); + for (auto iter = node->extKR_params(); iter; iter = iter->next) + nonterminal(iter->value); + nonterminal(node->body()); + return Action::Skip; + } + + virtual Action visitExtGNU_AsmStatementDeclaration( + const ExtGNU_AsmStatementDeclarationSyntax *node) override { + traverseDeclaration(node); + terminal(node->asmKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->stringLiteral()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action visitExtKR_ParameterDeclaration( + const ExtKR_ParameterDeclarationSyntax *node) override { + for (auto iter = node->specifiers(); iter; iter = iter->next) + nonterminal(iter->value); + for (auto iter = node->declarators(); iter; iter = iter->next) { + nonterminal(iter->value); + terminal(iter->delimiterToken(), node); + } + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + /* Specifiers */ + virtual Action + visitTrivialSpecifier_Common(const TrivialSpecifierSyntax *node) { + terminal(node->specifierToken(), node); + return Action::Skip; + } + + virtual Action visitStorageClass(const StorageClassSyntax *node) override { + return visitTrivialSpecifier_Common(node); + } + + virtual Action + visitBuiltinTypeSpecifier(const BuiltinTypeSpecifierSyntax *node) override { + return visitTrivialSpecifier_Common(node); + } + + virtual Action + visitTagTypeSpecifier(const TagTypeSpecifierSyntax *node) override { + terminal(node->keyword(), node); + for (auto iter = node->attributes(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->tagToken(), node); + terminal(node->openBraceToken(), node); + for (auto iter = node->declarations(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->closeBraceToken(), node); + for (auto iter = node->attributes_PostCloseBrace(); iter; iter = iter->next) + nonterminal(iter->value); + return Action::Skip; + } + + virtual Action + visitAtomicTypeSpecifier(const AtomicTypeSpecifierSyntax *node) override { + terminal(node->atomicKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->typeName()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action visitTypedefName(const TypedefNameSyntax *node) override { + terminal(node->identifierToken(), node); + return Action::Skip; + } + + virtual Action visitTypeQualifier(const TypeQualifierSyntax *node) override { + return visitTrivialSpecifier_Common(node); + } + + virtual Action + visitFunctionSpecifier(const FunctionSpecifierSyntax *node) override { + return visitTrivialSpecifier_Common(node); + } + + virtual Action + visitAlignmentSpecifier(const AlignmentSpecifierSyntax *node) override { + terminal(node->alignasKeyword(), node); + nonterminal(node->tyReference()); + return Action::Skip; + } + + virtual Action visitExtGNU_Typeof(const ExtGNU_TypeofSyntax *node) override { + terminal(node->typeofKeyword(), node); + nonterminal(node->tyReference()); + return Action::Skip; + } + + virtual Action visitExtGNU_AttributeSpecifier( + const ExtGNU_AttributeSpecifierSyntax *node) override { + terminal(node->attributeKeyword(), node); + terminal(node->openOuterParenthesisToken(), node); + terminal(node->openInnerParenthesisToken(), node); + for (auto iter = node->attributes(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->closeInnerParenthesisToken(), node); + terminal(node->closeOuterParenthesisToken(), node); + return Action::Skip; + } + + virtual Action + visitExtGNU_Attribute(const ExtGNU_AttributeSyntax *node) override { + terminal(node->keywordOrIdentifierToken(), node); + terminal(node->openParenthesisToken(), node); + for (auto iter = node->expressions(); iter; iter = iter->next) { + nonterminal(iter->value); + terminal(iter->delimiterToken(), node); + } + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action + visitExtGNU_AsmLabel(const ExtGNU_AsmLabelSyntax *node) override { + terminal(node->asmKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->stringLiteral()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + /* Declarators */ + virtual Action visitArrayOrFunctionDeclarator( + const ArrayOrFunctionDeclaratorSyntax *node) override { + for (auto iter = node->attributes(); iter; iter = iter->next) + nonterminal(iter->value); + nonterminal(node->innerDeclarator()); + nonterminal(node->suffix()); + for (auto iter = node->attributes_PostDeclarator(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->equalsToken(), node); + nonterminal(node->initializer()); + return Action::Skip; + } + + virtual Action + visitPointerDeclarator(const PointerDeclaratorSyntax *node) override { + for (auto iter = node->attributes(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->asteriskToken(), node); + for (auto iter = node->qualifiersAndAttributes(); iter; iter = iter->next) + nonterminal(iter->value); + nonterminal(node->innerDeclarator()); + terminal(node->equalsToken(), node); + nonterminal(node->initializer()); + return Action::Skip; + } + + virtual Action visitParenthesizedDeclarator( + const ParenthesizedDeclaratorSyntax *node) override { + terminal(node->openParenthesisToken(), node); + nonterminal(node->innerDeclarator()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action + visitIdentifierDeclarator(const IdentifierDeclaratorSyntax *node) override { + terminal(node->identifierToken(), node); + for (auto iter = node->attributes_PostIdentifier(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->equalsToken(), node); + nonterminal(node->initializer()); + return Action::Skip; + } + + virtual Action + visitSubscriptSuffix(const SubscriptSuffixSyntax *node) override { + terminal(node->openBracketToken(), node); + for (auto iter = node->qualifiersAndAttributes(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->staticKeyword(), node); + for (auto iter = node->qualifiersAndAttributes_PostStatic(); iter; + iter = iter->next) + nonterminal(iter->value); + nonterminal(node->expression()); + terminal(node->asteriskToken(), node); + terminal(node->closeBracketToken(), node); + return Action::Skip; + } + + virtual Action + visitParameterSuffix(const ParameterSuffixSyntax *node) override { + terminal(node->openParenthesisToken(), node); + for (auto iter = node->parameters(); iter; iter = iter->next) { + nonterminal(iter->value); + terminal(iter->delimiterToken(), node); + } + terminal(node->ellipsisToken(), node); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action + visitBitfieldDeclarator(const BitfieldDeclaratorSyntax *node) override { + nonterminal(node->innerDeclarator()); + terminal(node->colonToken(), node); + nonterminal(node->expression()); + for (auto iter = node->attributes(); iter; iter = iter->next) + nonterminal(iter->value); + return Action::Skip; + } + + /* Initializers */ + virtual Action + visitExpressionInitializer(const ExpressionInitializerSyntax *node) override { + nonterminal(node->expression()); + return Action::Skip; + } + + virtual Action visitBraceEnclosedInitializer( + const BraceEnclosedInitializerSyntax *node) override { + terminal(node->openBraceToken(), node); + for (auto iter = node->initializerList(); iter; iter = iter->next) { + nonterminal(iter->value); + terminal(iter->delimiterToken(), node); + } + terminal(node->closeBraceToken(), node); + return Action::Skip; + } + + virtual Action + visitDesignatedInitializer(const DesignatedInitializerSyntax *node) override { + for (auto iter = node->designators(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->equalsToken(), node); + nonterminal(node->initializer()); + return Action::Skip; + } + + virtual Action + visitFieldDesignator(const FieldDesignatorSyntax *node) override { + terminal(node->dotToken(), node); + terminal(node->identifierToken(), node); + return Action::Skip; + } + + virtual Action + visitArrayDesignator(const ArrayDesignatorSyntax *node) override { + terminal(node->openBracketToken(), node); + nonterminal(node->expression()); + terminal(node->closeBracketToken(), node); + return Action::Skip; + } + + virtual Action + visitOffsetOfDesignator(const OffsetOfDesignatorSyntax *node) override { + terminal(node->identifierToken(), node); + for (auto iter = node->designators(); iter; iter = iter->next) + nonterminal(iter->value); + return Action::Skip; + } + + //-------------// + // Expressions // + //-------------// + void traverseExpression(const ExpressionSyntax *node) { + terminal(node->extensionKeyword(), node); + } + + virtual Action + visitIdentifierName(const IdentifierNameSyntax *node) override { + traverseExpression(node); + terminal(node->identifierToken(), node); + return Action::Skip; + } + + virtual Action + visitPredefinedName(const PredefinedNameSyntax *node) override { + traverseExpression(node); + terminal(node->predefinedToken(), node); + return Action::Skip; + } + + virtual Action + visitConstantExpression(const ConstantExpressionSyntax *node) override { + traverseExpression(node); + terminal(node->constantToken(), node); + return Action::Skip; + } + + virtual Action visitStringLiteralExpression( + const StringLiteralExpressionSyntax *node) override { + traverseExpression(node); + terminal(node->literalToken(), node); + nonterminal(node->adjacent()); + return Action::Skip; + } + + virtual Action visitParenthesizedExpression( + const ParenthesizedExpressionSyntax *node) override { + traverseExpression(node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->expression()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action visitGenericSelectionExpression( + const GenericSelectionExpressionSyntax *node) override { + traverseExpression(node); + terminal(node->genericKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->expression()); + terminal(node->commaToken(), node); + for (auto it = node->associations(); it; it = it->next) { + nonterminal(it->value); + terminal(it->delimiterToken(), node); + } + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action + visitGenericAssociation(const GenericAssociationSyntax *node) override { + nonterminal(node->typeName_or_default()); + terminal(node->colonToken(), node); + nonterminal(node->expression()); + return Action::Skip; + } + + virtual Action visitExtGNU_EnclosedCompoundStatementExpression( + const ExtGNU_EnclosedCompoundStatementExpressionSyntax *node) override { + terminal(node->openParenthesisToken(), node); + nonterminal(node->statement()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action visitExtGNU_ComplexValuedExpression( + const ExtGNU_ComplexValuedExpressionSyntax *node) override { + terminal(node->operatorToken(), node); + nonterminal(node->expression()); + return Action::Skip; + } + + /* Operations */ + virtual Action + visitPrefixUnaryExpression(const PrefixUnaryExpressionSyntax *node) override { + traverseExpression(node); + terminal(node->operatorToken(), node); + nonterminal(node->expression()); + return Action::Skip; + } + + virtual Action visitPostfixUnaryExpression( + const PostfixUnaryExpressionSyntax *node) override { + traverseExpression(node); + nonterminal(node->expression()); + terminal(node->operatorToken(), node); + return Action::Skip; + } + + virtual Action visitMemberAccessExpression( + const MemberAccessExpressionSyntax *node) override { + traverseExpression(node); + nonterminal(node->expression()); + terminal(node->operatorToken(), node); + nonterminal(node->identifier()); + return Action::Skip; + } + + virtual Action visitArraySubscriptExpression( + const ArraySubscriptExpressionSyntax *node) override { + traverseExpression(node); + nonterminal(node->expression()); + terminal(node->openBracketToken(), node); + nonterminal(node->argument()); + terminal(node->closeBracketToken(), node); + return Action::Skip; + } + + virtual Action + visitTypeTraitExpression(const TypeTraitExpressionSyntax *node) override { + traverseExpression(node); + terminal(node->operatorToken(), node); + nonterminal(node->tyReference()); + return Action::Skip; + } + + virtual Action + visitCastExpression(const CastExpressionSyntax *node) override { + traverseExpression(node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->typeName()); + terminal(node->closeParenthesisToken(), node); + nonterminal(node->expression()); + return Action::Skip; + } + + virtual Action + visitCallExpression(const CallExpressionSyntax *node) override { + nonterminal(node->expression()); + terminal(node->openParenthesisToken(), node); + for (auto iter = node->arguments(); iter; iter = iter->next) { + nonterminal(iter->value); + terminal(iter->delimiterToken(), node); + } + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action + visitVAArgumentExpression(const VAArgumentExpressionSyntax *node) override { + terminal(node->keyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->expression()); + terminal(node->commaToken(), node); + nonterminal(node->typeName()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action + visitOffsetOfExpression(const OffsetOfExpressionSyntax *node) override { + terminal(node->keyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->typeName()); + terminal(node->commaToken(), node); + nonterminal(node->offsetOfDesignator()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + virtual Action visitCompoundLiteralExpression( + const CompoundLiteralExpressionSyntax *node) override { + terminal(node->openParenthesisToken(), node); + nonterminal(node->typeName()); + terminal(node->closeParenthesisToken(), node); + nonterminal(node->initializer()); + return Action::Skip; + } + + virtual Action + visitBinaryExpression(const BinaryExpressionSyntax *node) override { + nonterminal(node->left()); + terminal(node->operatorToken(), node); + nonterminal(node->right()); + return Action::Skip; + } + + virtual Action + visitConditionalExpression(const ConditionalExpressionSyntax *node) override { + nonterminal(node->condition()); + terminal(node->questionToken(), node); + nonterminal(node->whenTrue()); + terminal(node->colonToken(), node); + nonterminal(node->whenFalse()); + return Action::Skip; + } + + virtual Action + visitAssignmentExpression(const AssignmentExpressionSyntax *node) override { + nonterminal(node->left()); + terminal(node->operatorToken(), node); + nonterminal(node->right()); + return Action::Skip; + } + + virtual Action + visitSequencingExpression(const SequencingExpressionSyntax *node) override { + nonterminal(node->left()); + terminal(node->operatorToken(), node); + nonterminal(node->right()); + return Action::Skip; + } + + virtual Action visitExtGNU_ChooseExpression( + const ExtGNU_ChooseExpressionSyntax *node) override { + terminal(node->keyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->constantExpression()); + terminal(node->commaToken1(), node); + nonterminal(node->expression1()); + terminal(node->commaToken2(), node); + nonterminal(node->expression2()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + //------------// + // Statements // + //------------// + virtual Action + visitCompoundStatement(const CompoundStatementSyntax *node) override { + terminal(node->openBraceToken(), node); + for (auto iter = node->statements(); iter; iter = iter->next) + nonterminal(iter->value); + terminal(node->closeBraceToken(), node); + return Action::Skip; + } + + virtual Action + visitDeclarationStatement(const DeclarationStatementSyntax *node) override { + nonterminal(node->declaration()); + return Action::Skip; + } + + virtual Action + visitExpressionStatement(const ExpressionStatementSyntax *node) override { + nonterminal(node->expression()); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitLabeledStatement(const LabeledStatementSyntax *node) override { + terminal(node->labelToken(), node); + nonterminal(node->expression()); + terminal(node->colonToken(), node); + nonterminal(node->statement()); + return Action::Skip; + } + + virtual Action visitIfStatement(const IfStatementSyntax *node) override { + terminal(node->ifKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->condition()); + terminal(node->closeParenthesisToken(), node); + nonterminal(node->statement()); + terminal(node->elseKeyword(), node); + nonterminal(node->elseStatement()); + return Action::Skip; + } + + virtual Action + visitSwitchStatement(const SwitchStatementSyntax *node) override { + terminal(node->switchKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->condition()); + terminal(node->closeParenthesisToken(), node); + nonterminal(node->statement()); + return Action::Skip; + } + + virtual Action + visitWhileStatement(const WhileStatementSyntax *node) override { + terminal(node->whileKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->condition()); + terminal(node->closeParenthesisToken(), node); + nonterminal(node->statement()); + return Action::Skip; + } + + virtual Action visitDoStatement(const DoStatementSyntax *node) override { + terminal(node->doKeyword(), node); + nonterminal(node->statement()); + terminal(node->whileKeyword(), node); + terminal(node->openParenthesisToken(), node); + nonterminal(node->condition()); + terminal(node->closeParenthesisToken(), node); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action visitForStatement(const ForStatementSyntax *node) override { + terminal(node->forKeyword(), node); + terminal(node->openParenthesisToken(), node); + terminal(node->extensionKeyword(), node); + nonterminal(node->initializer()); + nonterminal(node->condition()); + terminal(node->semicolonToken(), node); + nonterminal(node->expression()); + terminal(node->closeParenthesisToken(), node); + nonterminal(node->statement()); + return Action::Skip; + } + + virtual Action visitGotoStatement(const GotoStatementSyntax *node) override { + terminal(node->gotoKeyword(), node); + terminal(node->identifierToken(), node); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitContinueStatement(const ContinueStatementSyntax *node) override { + terminal(node->continueKeyword(), node); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitBreakStatement(const BreakStatementSyntax *node) override { + terminal(node->breakKeyword(), node); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitReturnStatement(const ReturnStatementSyntax *node) override { + terminal(node->returnKeyword(), node); + nonterminal(node->expression()); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitExtGNU_AsmStatement(const ExtGNU_AsmStatementSyntax *node) override { + terminal(node->asmKeyword(), node); + for (auto it = node->asmQualifiers(); it; it = it->next) + nonterminal(it->value); + terminal(node->openParenthesisToken(), node); + nonterminal(node->stringLiteral()); + terminal(node->colon1Token(), node); + for (auto it = node->outputOperands(); it; it = it->next) { + nonterminal(it->value); + terminal(it->delimiterToken(), node); + } + terminal(node->colon2Token(), node); + for (auto it = node->inputOperands(); it; it = it->next) { + nonterminal(it->value); + terminal(it->delimiterToken(), node); + } + terminal(node->colon3Token(), node); + for (auto it = node->clobbers(); it; it = it->next) { + nonterminal(it->value); + terminal(it->delimiterToken(), node); + } + terminal(node->colon4Token(), node); + for (auto it = node->gotoLabels(); it; it = it->next) { + nonterminal(it->value); + terminal(it->delimiterToken(), node); + } + terminal(node->closeParenthesisToken(), node); + terminal(node->semicolonToken(), node); + return Action::Skip; + } + + virtual Action + visitExtGNU_AsmQualifier(const ExtGNU_AsmQualifierSyntax *node) override { + terminal(node->asmQualifier(), node); + return Action::Skip; + } + + virtual Action + visitExtGNU_AsmOperand(const ExtGNU_AsmOperandSyntax *node) override { + terminal(node->openBracketToken(), node); + nonterminal(node->identifier()); + terminal(node->closeBracketToken(), node); + nonterminal(node->stringLiteral()); + terminal(node->openParenthesisToken(), node); + nonterminal(node->expression()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + //--------// + // Common // + //--------// + virtual Action visitTypeName(const TypeNameSyntax *node) override { + for (auto it = node->specifiers(); it; it = it->next) + nonterminal(it->value); + nonterminal(node->declarator()); + return Action::Skip; + } + + virtual Action visitExpressionAsTypeReference( + const ExpressionAsTypeReferenceSyntax *node) override { + nonterminal(node->expression()); + return Action::Skip; + } + + virtual Action visitTypeNameAsTypeReference( + const TypeNameAsTypeReferenceSyntax *node) override { + terminal(node->openParenthesisToken(), node); + nonterminal(node->typeName()); + terminal(node->closeParenthesisToken(), node); + return Action::Skip; + } + + //-------------// + // Ambiguities // + //-------------// + virtual Action visitAmbiguousTypeNameOrExpressionAsTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *node) override { + nonterminal(node->expressionAsTypeReference()); + nonterminal(node->typeNameAsTypeReference()); + return Action::Skip; + } + + virtual Action visitAmbiguousCastOrBinaryExpression( + const AmbiguousCastOrBinaryExpressionSyntax *node) override { + nonterminal(node->castExpression()); + nonterminal(node->binaryExpression()); + return Action::Skip; + } + + virtual Action visitAmbiguousExpressionOrDeclarationStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *node) override { + nonterminal(node->declarationStatement()); + nonterminal(node->expressionStatement()); + return Action::Skip; + } }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxFacts.h b/C/syntax/SyntaxFacts.h index 96392996b..770107aa5 100644 --- a/C/syntax/SyntaxFacts.h +++ b/C/syntax/SyntaxFacts.h @@ -34,377 +34,361 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.CSharp.SyntaxFacts * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API SyntaxFacts -{ +class PSY_C_API SyntaxFacts { public: - - //--------------// - // Declarations // - //--------------// - - static bool isStorageClassToken(SyntaxKind tkK) - { - switch (tkK) { - case Keyword_typedef: - case Keyword_extern: - case Keyword_static: - case Keyword__Thread_local: - case Keyword_ExtGNU___thread: - case Keyword_auto: - case Keyword_register: - return true; - default: - return false; - } + //--------------// + // Declarations // + //--------------// + + static bool isStorageClassToken(SyntaxKind tkK) { + switch (tkK) { + case Keyword_typedef: + case Keyword_extern: + case Keyword_static: + case Keyword__Thread_local: + case Keyword_ExtGNU___thread: + case Keyword_auto: + case Keyword_register: + return true; + default: + return false; } - - static bool isBuiltinTypeSpecifierToken(SyntaxKind tkK) - { - switch (tkK) { - case Keyword_void: - case Keyword_char: - case Keyword_short: - case Keyword_int: - case Keyword_long: - case Keyword_float: - case Keyword_double: - case Keyword__Bool: - case Keyword__Complex: - case Keyword_signed: - case Keyword_unsigned: - case Keyword_Ext_char16_t: - case Keyword_Ext_char32_t: - case Keyword_Ext_wchar_t: - case Keyword_ExtGNU___complex__: - return true; - default: - return false; - } + } + + static bool isBuiltinTypeSpecifierToken(SyntaxKind tkK) { + switch (tkK) { + case Keyword_void: + case Keyword_char: + case Keyword_short: + case Keyword_int: + case Keyword_long: + case Keyword_float: + case Keyword_double: + case Keyword__Bool: + case Keyword__Complex: + case Keyword_signed: + case Keyword_unsigned: + case Keyword_Ext_char16_t: + case Keyword_Ext_char32_t: + case Keyword_Ext_wchar_t: + case Keyword_ExtGNU___complex__: + return true; + default: + return false; } - - static bool isTypeQualifierToken(SyntaxKind tkK) - { - switch (tkK) { - case Keyword_const: - case Keyword_volatile: - case Keyword_restrict: - case Keyword__Atomic: - return true; - default: - return false; - } + } + + static bool isTypeQualifierToken(SyntaxKind tkK) { + switch (tkK) { + case Keyword_const: + case Keyword_volatile: + case Keyword_restrict: + case Keyword__Atomic: + return true; + default: + return false; } - - static bool isFunctionSpecifierToken(SyntaxKind tkK) - { - switch (tkK) { - case Keyword_inline: - case Keyword__Noreturn: - return true; - default: - return false; - } + } + + static bool isFunctionSpecifierToken(SyntaxKind tkK) { + switch (tkK) { + case Keyword_inline: + case Keyword__Noreturn: + return true; + default: + return false; } - - //-------------// - // Expressions // - //-------------// - - static bool isConstantToken(SyntaxKind tkK) - { - switch (tkK) { - case IntegerConstantToken: - case FloatingConstantToken: - case CharacterConstantToken: - case CharacterConstant_L_Token: - case CharacterConstant_u_Token: - case CharacterConstant_U_Token: - case ImaginaryIntegerConstantToken: - case ImaginaryFloatingConstantToken: - case Keyword_Ext_true: - case Keyword_Ext_false: - case Keyword_Ext_NULL: - case Keyword_Ext_nullptr: - return true; - default: - return false; - } + } + + //-------------// + // Expressions // + //-------------// + + static bool isConstantToken(SyntaxKind tkK) { + switch (tkK) { + case IntegerConstantToken: + case FloatingConstantToken: + case CharacterConstantToken: + case CharacterConstant_L_Token: + case CharacterConstant_u_Token: + case CharacterConstant_U_Token: + case ImaginaryIntegerConstantToken: + case ImaginaryFloatingConstantToken: + case Keyword_Ext_true: + case Keyword_Ext_false: + case Keyword_Ext_NULL: + case Keyword_Ext_nullptr: + return true; + default: + return false; } - - static bool isStringLiteralToken(SyntaxKind tkK) - { - switch (tkK) { - case StringLiteralToken: - case StringLiteral_L_Token: - case StringLiteral_u8_Token: - case StringLiteral_u_Token: - case StringLiteral_U_Token: - case StringLiteral_R_Token: - case StringLiteral_LR_Token: - case StringLiteral_u8R_Token: - case StringLiteral_uR_Token: - case StringLiteral_UR_Token: - return true; - default: - return false; - } + } + + static bool isStringLiteralToken(SyntaxKind tkK) { + switch (tkK) { + case StringLiteralToken: + case StringLiteral_L_Token: + case StringLiteral_u8_Token: + case StringLiteral_u_Token: + case StringLiteral_U_Token: + case StringLiteral_R_Token: + case StringLiteral_LR_Token: + case StringLiteral_u8R_Token: + case StringLiteral_uR_Token: + case StringLiteral_UR_Token: + return true; + default: + return false; } - - static bool isNAryOperatorToken(SyntaxKind tkK) - { - switch (tkK) { - /* Binary */ - case BarBarToken: - case AmpersandAmpersandToken: - case BarToken: - case CaretToken: - case AmpersandToken: - case EqualsEqualsToken: - case ExclamationEqualsToken: - case GreaterThanToken: - case LessThanToken: - case GreaterThanEqualsToken: - case LessThanEqualsToken: - case LessThanLessThanToken: - case GreaterThanGreaterThanToken: - case PlusToken: - case MinusToken: - case AsteriskToken: - case SlashToken: - case PercentToken: - - /* Conditional */ - case QuestionToken: - - /* Assignment */ - case EqualsToken: - case AsteriskEqualsToken: - case SlashEqualsToken: - case PercentEqualsToken: - case PlusEqualsToken: - case MinusEqualsToken: - case LessThanLessThanEqualsToken: - case GreaterThanGreaterThanEqualsToken: - case AmpersandEqualsToken: - case CaretEqualsToken: - case BarEqualsToken: - - /* Sequencing */ - case CommaToken: - return true; - - default: - return false; - } + } + + static bool isNAryOperatorToken(SyntaxKind tkK) { + switch (tkK) { + /* Binary */ + case BarBarToken: + case AmpersandAmpersandToken: + case BarToken: + case CaretToken: + case AmpersandToken: + case EqualsEqualsToken: + case ExclamationEqualsToken: + case GreaterThanToken: + case LessThanToken: + case GreaterThanEqualsToken: + case LessThanEqualsToken: + case LessThanLessThanToken: + case GreaterThanGreaterThanToken: + case PlusToken: + case MinusToken: + case AsteriskToken: + case SlashToken: + case PercentToken: + + /* Conditional */ + case QuestionToken: + + /* Assignment */ + case EqualsToken: + case AsteriskEqualsToken: + case SlashEqualsToken: + case PercentEqualsToken: + case PlusEqualsToken: + case MinusEqualsToken: + case LessThanLessThanEqualsToken: + case GreaterThanGreaterThanEqualsToken: + case AmpersandEqualsToken: + case CaretEqualsToken: + case BarEqualsToken: + + /* Sequencing */ + case CommaToken: + return true; + + default: + return false; } - - static SyntaxKind NAryExpressionKind(SyntaxKind NAryTkK) - { - switch (NAryTkK) { - /* Binary */ - case BarBarToken: - return LogicalORExpression; - case AmpersandAmpersandToken: - return LogicalANDExpression; - case BarToken: - return BitwiseORExpression; - case CaretToken: - return BitwiseXORExpression; - case AmpersandToken: - return BitwiseANDExpression; - case EqualsEqualsToken: - return EqualsExpression; - case ExclamationEqualsToken: - return NotEqualsExpression; - case GreaterThanToken: - return GreaterThanExpression; - case LessThanToken: - return LessThanExpression; - case GreaterThanEqualsToken: - return GreaterThanOrEqualExpression; - case LessThanEqualsToken: - return LessThanOrEqualExpression; - case LessThanLessThanToken: - return LeftShiftExpression; - case GreaterThanGreaterThanToken: - return RightShiftExpression; - case PlusToken: - return AddExpression; - case MinusToken: - return SubstractExpression; - case AsteriskToken: - return MultiplyExpression; - case SlashToken: - return DivideExpression; - case PercentToken: - return ModuleExpression; - - /* Conditional */ - case QuestionToken: - return ConditionalExpression; - - /* Assignment */ - case EqualsToken: - return BasicAssignmentExpression; - case AsteriskEqualsToken: - return MultiplyAssignmentExpression; - case SlashEqualsToken: - return DivideAssignmentExpression; - case PercentEqualsToken: - return ModuloAssignmentExpression; - case PlusEqualsToken: - return AddAssignmentExpression; - case MinusEqualsToken: - return SubtractAssignmentExpression; - case LessThanLessThanEqualsToken: - return LeftShiftAssignmentExpression; - case GreaterThanGreaterThanEqualsToken: - return RightShiftAssignmentExpression; - case AmpersandEqualsToken: - return AndAssignmentExpression; - case CaretEqualsToken: - return ExclusiveOrAssignmentExpression; - case BarEqualsToken: - return OrAssignmentExpression; - - /* Sequencing */ - case CommaToken: - return SequencingExpression; - - default: - return Error; - } + } + + static SyntaxKind NAryExpressionKind(SyntaxKind NAryTkK) { + switch (NAryTkK) { + /* Binary */ + case BarBarToken: + return LogicalORExpression; + case AmpersandAmpersandToken: + return LogicalANDExpression; + case BarToken: + return BitwiseORExpression; + case CaretToken: + return BitwiseXORExpression; + case AmpersandToken: + return BitwiseANDExpression; + case EqualsEqualsToken: + return EqualsExpression; + case ExclamationEqualsToken: + return NotEqualsExpression; + case GreaterThanToken: + return GreaterThanExpression; + case LessThanToken: + return LessThanExpression; + case GreaterThanEqualsToken: + return GreaterThanOrEqualExpression; + case LessThanEqualsToken: + return LessThanOrEqualExpression; + case LessThanLessThanToken: + return LeftShiftExpression; + case GreaterThanGreaterThanToken: + return RightShiftExpression; + case PlusToken: + return AddExpression; + case MinusToken: + return SubstractExpression; + case AsteriskToken: + return MultiplyExpression; + case SlashToken: + return DivideExpression; + case PercentToken: + return ModuleExpression; + + /* Conditional */ + case QuestionToken: + return ConditionalExpression; + + /* Assignment */ + case EqualsToken: + return BasicAssignmentExpression; + case AsteriskEqualsToken: + return MultiplyAssignmentExpression; + case SlashEqualsToken: + return DivideAssignmentExpression; + case PercentEqualsToken: + return ModuloAssignmentExpression; + case PlusEqualsToken: + return AddAssignmentExpression; + case MinusEqualsToken: + return SubtractAssignmentExpression; + case LessThanLessThanEqualsToken: + return LeftShiftAssignmentExpression; + case GreaterThanGreaterThanEqualsToken: + return RightShiftAssignmentExpression; + case AmpersandEqualsToken: + return AndAssignmentExpression; + case CaretEqualsToken: + return ExclusiveOrAssignmentExpression; + case BarEqualsToken: + return OrAssignmentExpression; + + /* Sequencing */ + case CommaToken: + return SequencingExpression; + + default: + return Error; } - - static bool isAssignmentExpression(SyntaxKind exprK) - { - switch (exprK) { - case BasicAssignmentExpression: - case MultiplyAssignmentExpression: - case DivideAssignmentExpression: - case ModuloAssignmentExpression: - case AddAssignmentExpression: - case SubtractAssignmentExpression: - case LeftShiftAssignmentExpression: - case RightShiftAssignmentExpression: - case AndAssignmentExpression: - case ExclusiveOrAssignmentExpression: - case OrAssignmentExpression: - return true; - - default: - return false; - } + } + + static bool isAssignmentExpression(SyntaxKind exprK) { + switch (exprK) { + case BasicAssignmentExpression: + case MultiplyAssignmentExpression: + case DivideAssignmentExpression: + case ModuloAssignmentExpression: + case AddAssignmentExpression: + case SubtractAssignmentExpression: + case LeftShiftAssignmentExpression: + case RightShiftAssignmentExpression: + case AndAssignmentExpression: + case ExclusiveOrAssignmentExpression: + case OrAssignmentExpression: + return true; + + default: + return false; } - - static bool isAssignmentExpressionOperatorToken(SyntaxKind tkK) - { - switch (tkK) { - case EqualsToken: - case PlusEqualsToken: - case MinusEqualsToken: - case AsteriskEqualsToken: - case SlashEqualsToken: - case PercentEqualsToken: - case LessThanLessThanEqualsToken: - case GreaterThanGreaterThanEqualsToken: - case AmpersandEqualsToken: - case CaretEqualsToken: - case BarEqualsToken: - return true; - - default: - return false; - } + } + + static bool isAssignmentExpressionOperatorToken(SyntaxKind tkK) { + switch (tkK) { + case EqualsToken: + case PlusEqualsToken: + case MinusEqualsToken: + case AsteriskEqualsToken: + case SlashEqualsToken: + case PercentEqualsToken: + case LessThanLessThanEqualsToken: + case GreaterThanGreaterThanEqualsToken: + case AmpersandEqualsToken: + case CaretEqualsToken: + case BarEqualsToken: + return true; + + default: + return false; } - - static bool isBinaryExpression(SyntaxKind exprK) - { - switch (exprK) { - case MultiplyExpression: - case DivideExpression: - case ModuleExpression: - case AddExpression: - case SubstractExpression: - case LeftShiftExpression: - case RightShiftExpression: - case LessThanExpression: - case LessThanOrEqualExpression: - case GreaterThanExpression: - case GreaterThanOrEqualExpression: - case EqualsExpression: - case NotEqualsExpression: - case BitwiseANDExpression: - case BitwiseXORExpression: - case BitwiseORExpression: - case LogicalANDExpression: - case LogicalORExpression: - return true; - - default: - return false; - } + } + + static bool isBinaryExpression(SyntaxKind exprK) { + switch (exprK) { + case MultiplyExpression: + case DivideExpression: + case ModuleExpression: + case AddExpression: + case SubstractExpression: + case LeftShiftExpression: + case RightShiftExpression: + case LessThanExpression: + case LessThanOrEqualExpression: + case GreaterThanExpression: + case GreaterThanOrEqualExpression: + case EqualsExpression: + case NotEqualsExpression: + case BitwiseANDExpression: + case BitwiseXORExpression: + case BitwiseORExpression: + case LogicalANDExpression: + case LogicalORExpression: + return true; + + default: + return false; } - - static bool isBinaryExpressionOperatorToken(SyntaxKind tkK) - { - switch (tkK) { - case AsteriskToken: - case SlashToken: - case PercentToken: - case PlusToken: - case MinusToken: - case LessThanLessThanToken: - case GreaterThanGreaterThanToken: - case LessThanToken: - case LessThanEqualsToken: - case GreaterThanToken: - case GreaterThanEqualsToken: - case EqualsEqualsToken: - case ExclamationEqualsToken: - case AmpersandToken: - case CaretToken: - case BarToken: - case AmpersandAmpersandToken: - case BarBarToken: - return true; - - default: - return false; - } + } + + static bool isBinaryExpressionOperatorToken(SyntaxKind tkK) { + switch (tkK) { + case AsteriskToken: + case SlashToken: + case PercentToken: + case PlusToken: + case MinusToken: + case LessThanLessThanToken: + case GreaterThanGreaterThanToken: + case LessThanToken: + case LessThanEqualsToken: + case GreaterThanToken: + case GreaterThanEqualsToken: + case EqualsEqualsToken: + case ExclamationEqualsToken: + case AmpersandToken: + case CaretToken: + case BarToken: + case AmpersandAmpersandToken: + case BarBarToken: + return true; + + default: + return false; } + } - static bool isPredefinedToken(SyntaxKind tkK) - { - switch(tkK) { - case Keyword___func__: - case Keyword_ExtGNU___FUNCTION__: - case Keyword_ExtGNU___PRETTY_FUNCTION__: - return true; - - default: - return false; - } - } + static bool isPredefinedToken(SyntaxKind tkK) { + switch (tkK) { + case Keyword___func__: + case Keyword_ExtGNU___FUNCTION__: + case Keyword_ExtGNU___PRETTY_FUNCTION__: + return true; - //------------// - // Statements // - //------------// - - static bool isExtGNU_AsmQualifierToken(SyntaxKind tkK) - { - switch (tkK) { - case Keyword_volatile: - case Keyword_inline: - case Keyword_goto: - return true; - default: - return false; - } + default: + return false; + } + } + + //------------// + // Statements // + //------------// + + static bool isExtGNU_AsmQualifierToken(SyntaxKind tkK) { + switch (tkK) { + case Keyword_volatile: + case Keyword_inline: + case Keyword_goto: + return true; + default: + return false; } + } }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxHolder.cpp b/C/syntax/SyntaxHolder.cpp index 1ef3da55d..1820ca1ab 100644 --- a/C/syntax/SyntaxHolder.cpp +++ b/C/syntax/SyntaxHolder.cpp @@ -24,46 +24,28 @@ using namespace psy; using namespace C; SyntaxHolder::SyntaxHolder(LexedTokens::IndexType tkIdx) - : syntax_(tkIdx) - , variant_(Variant::Token) -{} + : syntax_(tkIdx), variant_(Variant::Token) {} -SyntaxHolder::SyntaxHolder(const SyntaxNode* node) - : syntax_(node) - , variant_(Variant::Node) -{} +SyntaxHolder::SyntaxHolder(const SyntaxNode *node) + : syntax_(node), variant_(Variant::Node) {} -SyntaxHolder::SyntaxHolder(const SyntaxNodeList* nodeList) - : syntax_(nodeList) - , variant_(Variant::NodeList) -{} +SyntaxHolder::SyntaxHolder(const SyntaxNodeList *nodeList) + : syntax_(nodeList), variant_(Variant::NodeList) {} -LexedTokens::IndexType SyntaxHolder::tokenIndex() const -{ - return std::get(syntax_); +LexedTokens::IndexType SyntaxHolder::tokenIndex() const { + return std::get(syntax_); } -const SyntaxNode* SyntaxHolder::node() const -{ - return std::get(syntax_); +const SyntaxNode *SyntaxHolder::node() const { + return std::get(syntax_); } -const SyntaxNodeList* SyntaxHolder::nodeList() const -{ - return std::get(syntax_); +const SyntaxNodeList *SyntaxHolder::nodeList() const { + return std::get(syntax_); } -bool SyntaxHolder::isToken() const -{ - return variant_ == Variant::Token; -} +bool SyntaxHolder::isToken() const { return variant_ == Variant::Token; } -bool SyntaxHolder::isNode() const -{ - return variant_ == Variant::Node; -} +bool SyntaxHolder::isNode() const { return variant_ == Variant::Node; } -bool SyntaxHolder::isNodeList() const -{ - return variant_ == Variant::NodeList; -} +bool SyntaxHolder::isNodeList() const { return variant_ == Variant::NodeList; } diff --git a/C/syntax/SyntaxHolder.h b/C/syntax/SyntaxHolder.h index 49ee790fc..59f3815ca 100644 --- a/C/syntax/SyntaxHolder.h +++ b/C/syntax/SyntaxHolder.h @@ -36,38 +36,36 @@ namespace C { * * A wrapper for any syntax form (or a handle to it). */ -class PSY_C_NON_API SyntaxHolder -{ +class PSY_C_NON_API SyntaxHolder { public: - enum class Variant : char - { - Token, - Node, - NodeList, - }; + enum class Variant : char { + Token, + Node, + NodeList, + }; - Variant variant() const { return variant_; } + Variant variant() const { return variant_; } - bool isToken() const; - bool isNode() const; - bool isNodeList() const; + bool isToken() const; + bool isNode() const; + bool isNodeList() const; - SyntaxHolder(LexedTokens::IndexType tkIdx); - SyntaxHolder(const SyntaxNode* node); - SyntaxHolder(const SyntaxNodeList* nodeList); + SyntaxHolder(LexedTokens::IndexType tkIdx); + SyntaxHolder(const SyntaxNode *node); + SyntaxHolder(const SyntaxNodeList *nodeList); - LexedTokens::IndexType tokenIndex() const; - const SyntaxNode* node() const; - const SyntaxNodeList* nodeList() const; + LexedTokens::IndexType tokenIndex() const; + const SyntaxNode *node() const; + const SyntaxNodeList *nodeList() const; private: - std::variant syntax_; - Variant variant_; + std::variant + syntax_; + Variant variant_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxKind.h b/C/syntax/SyntaxKind.h index d32e20a86..ab19184b0 100644 --- a/C/syntax/SyntaxKind.h +++ b/C/syntax/SyntaxKind.h @@ -32,492 +32,492 @@ namespace C { /** * \brief The SyntaxKind enumeration. */ -enum PSY_C_API SyntaxKind : std::uint16_t -{ - EndOfFile = 0, - Error, - -//=================================================================== Valued Tokens - - STARTof_ValuedToken, - - MultiLineCommentTrivia = STARTof_ValuedToken, - MultiLineDocumentationCommentTrivia, - SingleLineCommentTrivia, - SingleLineDocumentationCommentTrivia, - - IdentifierToken, - - IntegerConstantToken, - FloatingConstantToken, - ImaginaryIntegerConstantToken, - ImaginaryFloatingConstantToken, - - CharacterConstantToken, - CharacterConstant_L_Token, - CharacterConstant_u_Token, - CharacterConstant_U_Token, - - StringLiteralToken, - StringLiteral_L_Token, - StringLiteral_u8_Token, - StringLiteral_u_Token, - StringLiteral_U_Token, - - ENDof_ValuedToken = StringLiteral_U_Token, - -//=================================================================== Tokens - - STARTof_KeywordOrPunctuatorToken, - - EllipsisToken = STARTof_KeywordOrPunctuatorToken, - - OpenBraceToken, - CloseBraceToken, - - OpenBracketToken, - CloseBracketToken, - - OpenParenToken, - CloseParenToken, - - HashToken, - HashHashToken, - - SemicolonToken, - - // --------------- // - // --- C89/C90 --- // - // --------------- // - - /* Keywords: 6.4.1. */ - Keyword_auto, - Keyword_break, - Keyword_case, - Keyword_char, - Keyword_const, - Keyword_continue, - Keyword_default, - Keyword_do, - Keyword_double, - Keyword_else, - Keyword_enum, - Keyword_extern, - Keyword_float, - Keyword_for, - Keyword_goto, - Keyword_if, - Keyword_inline, - Keyword_int, - Keyword_long, - Keyword_register, - Keyword_restrict, - Keyword_return, - Keyword_short, - Keyword_signed, - Keyword_static, - Keyword_struct, - Keyword_switch, - Keyword_typedef, - Keyword_union, - Keyword_unsigned, - Keyword_void, - Keyword_volatile, - Keyword_while, - - /* Member access: 6.5.2.3. */ - ArrowToken, - DotToken, - - /* Increment/decrement: 6.5.2.4 (postfix) and 6.5.3.3 (prefix). */ - PlusPlusToken, - MinusMinusToken, - - /* Address, access, and indirection: 6.5.3.2.*/ - AsteriskToken, - AmpersandToken, - - /* Arithmetic: 6.5.3.3 (unary), 6.5.5 (multiplicative), 6.5.6 (additive), - * 6.5.7 (shift), 6.5.11 (bit or), and 6.5.12 (bit xor) -- 6.5.10 (bit AND) - * and the star appeared earlier. */ - PlusToken, - MinusToken, - TildeToken, - SlashToken, - PercentToken, - LessThanLessThanToken, - GreaterThanGreaterThanToken, - BarToken, - CaretToken, - - /* Logical: 6.5.3.3 (unary), 6.5.13 (AND), and 6.5.14 (OR). */ - ExclamationToken, - AmpersandAmpersandToken, - BarBarToken, - - /* Comparisson: 6.5.8 (relational) and 6.5.9 (equality). */ - LessThanToken, - LessThanEqualsToken, - GreaterThanToken, - GreaterThanEqualsToken, - EqualsEqualsToken, - ExclamationEqualsToken, - - /* Conditional: 6.5.15. */ - ColonToken, - QuestionToken, - - /* Assignment: 6.5.16. */ - EqualsToken, - AsteriskEqualsToken, - SlashEqualsToken, - PercentEqualsToken, - PlusEqualsToken, - MinusEqualsToken, - LessThanLessThanEqualsToken, - GreaterThanGreaterThanEqualsToken, - AmpersandEqualsToken, - CaretEqualsToken, - BarEqualsToken, - - /* Comma: 6.5.17. */ - CommaToken, - - /* sizeof: 6.5.3.4. */ - Keyword_sizeof, - - // ----------- // - // --- C95 --- // - // ----------- // - Keyword_Ext_wchar_t, /* Enabled/disabled by parse/language options. */ - - // ----------- // - // --- C99 --- // - // ----------- // - Keyword__Bool, - Keyword__Complex, - Keyword___func__, - - // ----------- // - // --- C11 --- // - // ----------- // - Keyword__Alignas, - Keyword__Alignof, - Keyword__Atomic, - Keyword__Generic, - Keyword__Noreturn, - Keyword__Static_assert, - Keyword__Thread_local, - - /* The types char16_t and char32_t are from . - Enabled/disabled by parse/language options. */ - Keyword_Ext_char16_t, - Keyword_Ext_char32_t, - - /* Enabled/disabled by parse/language options. */ - Keyword_Ext_false, - Keyword_Ext_true, - - /* Enabled/disabled by parse/language options. */ - Keyword_Ext_NULL, - Keyword_Ext_nullptr, - - /* Enabled/disabled by parse/language options. */ - StringLiteral_R_Token, - StringLiteral_LR_Token, - StringLiteral_u8R_Token, - StringLiteral_uR_Token, - StringLiteral_UR_Token, - - // -----------------------// - // --- Extension: GNU --- // - // -----------------------// - Keyword_ExtGNU___attribute__, - Keyword_ExtGNU___thread, - Keyword_ExtGNU___typeof__, - Keyword_ExtGNU___extension__, - Keyword_ExtGNU___asm__, // Portability: J.5.10. - Keyword_ExtGNU___builtin_va_arg, - Keyword_ExtGNU___builtin_offsetof, - Keyword_ExtGNU___builtin_tgmath, - Keyword_ExtGNU___builtin_choose_expr, - Keyword_ExtGNU___FUNCTION__, - Keyword_ExtGNU___PRETTY_FUNCTION__, - Keyword_ExtGNU___complex__, - Keyword_ExtGNU___real__, - Keyword_ExtGNU___imag__, - - // --------------------------// - // --- Translated macros --- // - // --------------------------// - Keyword_MacroStd_va_arg, - Keyword_MacroStd_offsetof, - - // --------------------------// - // --- Extension: Psyche --- // - // --------------------------// - Keyword_ExtPSY__Template, - Keyword_ExtPSY__Forall, - Keyword_ExtPSY__Exists, - Keyword_ExtPSY_omission, - - /* Operator names from (7.9). - Enable/disable this in parse/language options. */ - OperatorName_ORToken = BarBarToken, - OperatorName_ANDToken = AmpersandAmpersandToken, - OperatorName_NOTToken = ExclamationToken, - OperatorName_XORToken = CaretToken, - OperatorName_BITORToken = BarToken, - OperatorName_COMPLToken = TildeToken, - OperatorName_OREQToken = BarEqualsToken, - OperatorName_ANDEQToken = AmpersandEqualsToken, - OperatorName_BITANDToken = AmpersandToken, - OperatorName_NOTEQToken = ExclamationEqualsToken, - OperatorName_XOREQToken = CaretEqualsToken, - - /* Aliases - TODO: Do NOT add more... - We want to preserve original tokens to allow exact AST rewrite. - */ - KeywordAlias_Bool = Keyword__Bool, - KeywordAlias_asm = Keyword_ExtGNU___asm__, - KeywordAlias_typeof = Keyword_ExtGNU___typeof__, - - KeywordAlias___alignas = Keyword__Alignas, - KeywordAlias___alignof = Keyword__Alignof, - KeywordAlias___asm = Keyword_ExtGNU___asm__, - KeywordAlias___attribute = Keyword_ExtGNU___attribute__, - KeywordAlias___const = Keyword_const, - KeywordAlias___inline = Keyword_inline, - KeywordAlias___restrict = Keyword_restrict, - KeywordAlias___signed = Keyword_signed, - KeywordAlias___typeof = Keyword_ExtGNU___typeof__, - KeywordAlias___volatile = Keyword_volatile, - - KeywordAlias___alignas__ = Keyword__Alignas, - KeywordAlias___alignof__ = Keyword__Alignof, - KeywordAlias___const__ = Keyword_const, - KeywordAlias___inline__ = Keyword_inline, - KeywordAlias___restrict__ = Keyword_restrict, - KeywordAlias___signed__ = Keyword_signed, - KeywordAlias___volatile__ = Keyword_volatile, - - ENDof_KeywordOrPunctuatorToken = KeywordAlias___volatile__, - -//=================================================================== Nodes - - STARTof_Node = 1000, - - //--------------// - // Declarations // - //--------------// - TranslationUnit = STARTof_Node, - IncompleteDeclaration, - StructDeclaration, - UnionDeclaration, - EnumDeclaration, - EnumeratorDeclaration, - VariableAndOrFunctionDeclaration, - FieldDeclaration, - ParameterDeclaration, - StaticAssertDeclaration, - FunctionDefinition, - ExtGNU_AsmStatementDeclaration, - ExtPSY_TemplateDeclaration, - ExtKR_ParameterDeclaration, - - /* Specifiers */ - TypedefStorageClass, - ExternStorageClass, - StaticStorageClass, - AutoStorageClass, - RegisterStorageClass, - ThreadLocalStorageClass, - ConstQualifier, - RestrictQualifier, - VolatileQualifier, - AtomicQualifier, - BuiltinTypeSpecifier, - StructTypeSpecifier, - UnionTypeSpecifier, - EnumTypeSpecifier, - AtomicTypeSpecifier, - TypedefName, - TypeDeclarationAsSpecifier, - ExtGNU_Typeof, - ExtPSY_QuantifiedTypeSpecifier, - InlineSpecifier, - NoReturnSpecifier, - AlignmentSpecifier, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - ExtGNU_AsmLabel, - - /* Declarators */ - PointerDeclarator, - IdentifierDeclarator, - AbstractDeclarator, - ParenthesizedDeclarator, - ArrayDeclarator, - FunctionDeclarator, - BitfieldDeclarator, - SubscriptSuffix, - ParameterSuffix, - BitfieldDeclaratorSuffix, - ExtKR_IdentifierDeclarator, - - /* Initializers */ - ExpressionInitializer, - BraceEnclosedInitializer, - DesignatedInitializer, - FieldDesignator, - ArrayDesignator, - - OffsetOfDesignator, - - //-------------// - // Expressions // - //-------------// - IntegerConstantExpression, - FloatingConstantExpression, - ImaginaryIntegerConstantExpression, - ImaginaryFloatingConstantExpression, - CharacterConstantExpression, - BooleanConstantExpression, - NULL_ConstantExpression, - StringLiteralExpression, - ParenthesizedExpression, - GenericSelectionExpression, - TypedGenericAssociation, - DefaultGenericAssociation, - ExtGNU_EnclosedCompoundStatementExpression, - ExtGNU_ComplexValuedExpression, - ExtGNU_RealExpression, - ExtGNU_ImagExpression, - - /* Names */ - IdentifierName, - PredefinedName, - - /* Unary */ - PostIncrementExpression, - PostDecrementExpression, - PreIncrementExpression, - PreDecrementExpression, - UnaryPlusExpression, - UnaryMinusExpression, - BitwiseNotExpression, - LogicalNotExpression, - - /* Type trait */ - SizeofExpression, - AlignofExpression, - - /* Pointers */ - AddressOfExpression, - PointerIndirectionExpression, - - /* Access */ - DirectMemberAccessExpression, - IndirectMemberAccessExpression, - ElementAccessExpression, - - /* Invocation-like */ - CallExpression, - CompoundLiteralExpression, - CastExpression, - VAArgumentExpression, - OffsetOfExpression, - ExtGNU_ChooseExpression, - - /* Binary */ - MultiplyExpression, - DivideExpression, - ModuleExpression, - AddExpression, - SubstractExpression, - LeftShiftExpression, - RightShiftExpression, - LessThanExpression, - LessThanOrEqualExpression, - GreaterThanExpression, - GreaterThanOrEqualExpression, - EqualsExpression, - NotEqualsExpression, - BitwiseANDExpression, - BitwiseXORExpression, - BitwiseORExpression, - LogicalANDExpression, - LogicalORExpression, - - /* Conditional */ - ConditionalExpression, - - /* Assignment */ - BasicAssignmentExpression, - MultiplyAssignmentExpression, - DivideAssignmentExpression, - ModuloAssignmentExpression, - AddAssignmentExpression, - SubtractAssignmentExpression, - LeftShiftAssignmentExpression, - RightShiftAssignmentExpression, - AndAssignmentExpression, - ExclusiveOrAssignmentExpression, - OrAssignmentExpression, - - /* Sequencing */ - SequencingExpression, - - //------------// - // Statements // - //------------// - CompoundStatement, - DeclarationStatement, - ExpressionStatement, - IdentifierLabelStatement, - DefaultLabelStatement, - CaseLabelStatement, - DefaultStatement, - IfStatement, - SwitchStatement, - WhileStatement, - DoStatement, - ForStatement, - GotoStatement, - ContinueStatement, - BreakStatement, - ReturnStatement, - ExtGNU_AsmStatement, - ExtGNU_AsmVolatileQualifier, - ExtGNU_AsmInlineQualifier, - ExtGNU_AsmGotoQualifier, - ExtGNU_AsmInputOperand, - ExtGNU_AsmOutputOperand, - - //--------// - // Common // - //--------// - TypeName, - ExpressionAsTypeReference, - TypeNameAsTypeReference, - - //-------------// - // Ambiguities // - //-------------// - AmbiguousCastOrBinaryExpression, - AmbiguousTypeNameOrExpressionAsTypeReference, - AmbiguousCallOrVariableDeclaration, - AmbiguousMultiplicationOrPointerDeclaration, - - ENDof_Node = AmbiguousMultiplicationOrPointerDeclaration, - -//=================================================================== Misc - - UnknownSyntax +enum PSY_C_API SyntaxKind : std::uint16_t { + EndOfFile = 0, + Error, + + //=================================================================== Valued + // Tokens + + STARTof_ValuedToken, + + MultiLineCommentTrivia = STARTof_ValuedToken, + MultiLineDocumentationCommentTrivia, + SingleLineCommentTrivia, + SingleLineDocumentationCommentTrivia, + + IdentifierToken, + + IntegerConstantToken, + FloatingConstantToken, + ImaginaryIntegerConstantToken, + ImaginaryFloatingConstantToken, + + CharacterConstantToken, + CharacterConstant_L_Token, + CharacterConstant_u_Token, + CharacterConstant_U_Token, + + StringLiteralToken, + StringLiteral_L_Token, + StringLiteral_u8_Token, + StringLiteral_u_Token, + StringLiteral_U_Token, + + ENDof_ValuedToken = StringLiteral_U_Token, + + //=================================================================== Tokens + + STARTof_KeywordOrPunctuatorToken, + + EllipsisToken = STARTof_KeywordOrPunctuatorToken, + + OpenBraceToken, + CloseBraceToken, + + OpenBracketToken, + CloseBracketToken, + + OpenParenToken, + CloseParenToken, + + HashToken, + HashHashToken, + + SemicolonToken, + + // --------------- // + // --- C89/C90 --- // + // --------------- // + + /* Keywords: 6.4.1. */ + Keyword_auto, + Keyword_break, + Keyword_case, + Keyword_char, + Keyword_const, + Keyword_continue, + Keyword_default, + Keyword_do, + Keyword_double, + Keyword_else, + Keyword_enum, + Keyword_extern, + Keyword_float, + Keyword_for, + Keyword_goto, + Keyword_if, + Keyword_inline, + Keyword_int, + Keyword_long, + Keyword_register, + Keyword_restrict, + Keyword_return, + Keyword_short, + Keyword_signed, + Keyword_static, + Keyword_struct, + Keyword_switch, + Keyword_typedef, + Keyword_union, + Keyword_unsigned, + Keyword_void, + Keyword_volatile, + Keyword_while, + + /* Member access: 6.5.2.3. */ + ArrowToken, + DotToken, + + /* Increment/decrement: 6.5.2.4 (postfix) and 6.5.3.3 (prefix). */ + PlusPlusToken, + MinusMinusToken, + + /* Address, access, and indirection: 6.5.3.2.*/ + AsteriskToken, + AmpersandToken, + + /* Arithmetic: 6.5.3.3 (unary), 6.5.5 (multiplicative), 6.5.6 (additive), + * 6.5.7 (shift), 6.5.11 (bit or), and 6.5.12 (bit xor) -- 6.5.10 (bit AND) + * and the star appeared earlier. */ + PlusToken, + MinusToken, + TildeToken, + SlashToken, + PercentToken, + LessThanLessThanToken, + GreaterThanGreaterThanToken, + BarToken, + CaretToken, + + /* Logical: 6.5.3.3 (unary), 6.5.13 (AND), and 6.5.14 (OR). */ + ExclamationToken, + AmpersandAmpersandToken, + BarBarToken, + + /* Comparisson: 6.5.8 (relational) and 6.5.9 (equality). */ + LessThanToken, + LessThanEqualsToken, + GreaterThanToken, + GreaterThanEqualsToken, + EqualsEqualsToken, + ExclamationEqualsToken, + + /* Conditional: 6.5.15. */ + ColonToken, + QuestionToken, + + /* Assignment: 6.5.16. */ + EqualsToken, + AsteriskEqualsToken, + SlashEqualsToken, + PercentEqualsToken, + PlusEqualsToken, + MinusEqualsToken, + LessThanLessThanEqualsToken, + GreaterThanGreaterThanEqualsToken, + AmpersandEqualsToken, + CaretEqualsToken, + BarEqualsToken, + + /* Comma: 6.5.17. */ + CommaToken, + + /* sizeof: 6.5.3.4. */ + Keyword_sizeof, + + // ----------- // + // --- C95 --- // + // ----------- // + Keyword_Ext_wchar_t, /* Enabled/disabled by parse/language options. */ + + // ----------- // + // --- C99 --- // + // ----------- // + Keyword__Bool, + Keyword__Complex, + Keyword___func__, + + // ----------- // + // --- C11 --- // + // ----------- // + Keyword__Alignas, + Keyword__Alignof, + Keyword__Atomic, + Keyword__Generic, + Keyword__Noreturn, + Keyword__Static_assert, + Keyword__Thread_local, + + /* The types char16_t and char32_t are from . + Enabled/disabled by parse/language options. */ + Keyword_Ext_char16_t, + Keyword_Ext_char32_t, + + /* Enabled/disabled by parse/language options. */ + Keyword_Ext_false, + Keyword_Ext_true, + + /* Enabled/disabled by parse/language options. */ + Keyword_Ext_NULL, + Keyword_Ext_nullptr, + + /* Enabled/disabled by parse/language options. */ + StringLiteral_R_Token, + StringLiteral_LR_Token, + StringLiteral_u8R_Token, + StringLiteral_uR_Token, + StringLiteral_UR_Token, + + // -----------------------// + // --- Extension: GNU --- // + // -----------------------// + Keyword_ExtGNU___attribute__, + Keyword_ExtGNU___thread, + Keyword_ExtGNU___typeof__, + Keyword_ExtGNU___extension__, + Keyword_ExtGNU___asm__, // Portability: J.5.10. + Keyword_ExtGNU___builtin_va_arg, + Keyword_ExtGNU___builtin_offsetof, + Keyword_ExtGNU___builtin_tgmath, + Keyword_ExtGNU___builtin_choose_expr, + Keyword_ExtGNU___FUNCTION__, + Keyword_ExtGNU___PRETTY_FUNCTION__, + Keyword_ExtGNU___complex__, + Keyword_ExtGNU___real__, + Keyword_ExtGNU___imag__, + + // --------------------------// + // --- Translated macros --- // + // --------------------------// + Keyword_MacroStd_va_arg, + Keyword_MacroStd_offsetof, + + // --------------------------// + // --- Extension: Psyche --- // + // --------------------------// + Keyword_ExtPSY__Template, + Keyword_ExtPSY__Forall, + Keyword_ExtPSY__Exists, + Keyword_ExtPSY_omission, + + /* Operator names from (7.9). + Enable/disable this in parse/language options. */ + OperatorName_ORToken = BarBarToken, + OperatorName_ANDToken = AmpersandAmpersandToken, + OperatorName_NOTToken = ExclamationToken, + OperatorName_XORToken = CaretToken, + OperatorName_BITORToken = BarToken, + OperatorName_COMPLToken = TildeToken, + OperatorName_OREQToken = BarEqualsToken, + OperatorName_ANDEQToken = AmpersandEqualsToken, + OperatorName_BITANDToken = AmpersandToken, + OperatorName_NOTEQToken = ExclamationEqualsToken, + OperatorName_XOREQToken = CaretEqualsToken, + + /* Aliases + TODO: Do NOT add more... + We want to preserve original tokens to allow exact AST rewrite. + */ + KeywordAlias_Bool = Keyword__Bool, + KeywordAlias_asm = Keyword_ExtGNU___asm__, + KeywordAlias_typeof = Keyword_ExtGNU___typeof__, + + KeywordAlias___alignas = Keyword__Alignas, + KeywordAlias___alignof = Keyword__Alignof, + KeywordAlias___asm = Keyword_ExtGNU___asm__, + KeywordAlias___attribute = Keyword_ExtGNU___attribute__, + KeywordAlias___const = Keyword_const, + KeywordAlias___inline = Keyword_inline, + KeywordAlias___restrict = Keyword_restrict, + KeywordAlias___signed = Keyword_signed, + KeywordAlias___typeof = Keyword_ExtGNU___typeof__, + KeywordAlias___volatile = Keyword_volatile, + + KeywordAlias___alignas__ = Keyword__Alignas, + KeywordAlias___alignof__ = Keyword__Alignof, + KeywordAlias___const__ = Keyword_const, + KeywordAlias___inline__ = Keyword_inline, + KeywordAlias___restrict__ = Keyword_restrict, + KeywordAlias___signed__ = Keyword_signed, + KeywordAlias___volatile__ = Keyword_volatile, + + ENDof_KeywordOrPunctuatorToken = KeywordAlias___volatile__, + + //=================================================================== Nodes + + STARTof_Node = 1000, + + //--------------// + // Declarations // + //--------------// + TranslationUnit = STARTof_Node, + IncompleteDeclaration, + StructDeclaration, + UnionDeclaration, + EnumDeclaration, + EnumeratorDeclaration, + VariableAndOrFunctionDeclaration, + FieldDeclaration, + ParameterDeclaration, + StaticAssertDeclaration, + FunctionDefinition, + ExtGNU_AsmStatementDeclaration, + ExtPSY_TemplateDeclaration, + ExtKR_ParameterDeclaration, + + /* Specifiers */ + TypedefStorageClass, + ExternStorageClass, + StaticStorageClass, + AutoStorageClass, + RegisterStorageClass, + ThreadLocalStorageClass, + ConstQualifier, + RestrictQualifier, + VolatileQualifier, + AtomicQualifier, + BuiltinTypeSpecifier, + StructTypeSpecifier, + UnionTypeSpecifier, + EnumTypeSpecifier, + AtomicTypeSpecifier, + TypedefName, + TypeDeclarationAsSpecifier, + ExtGNU_Typeof, + ExtPSY_QuantifiedTypeSpecifier, + InlineSpecifier, + NoReturnSpecifier, + AlignmentSpecifier, + ExtGNU_AttributeSpecifier, + ExtGNU_Attribute, + ExtGNU_AsmLabel, + + /* Declarators */ + PointerDeclarator, + IdentifierDeclarator, + AbstractDeclarator, + ParenthesizedDeclarator, + ArrayDeclarator, + FunctionDeclarator, + BitfieldDeclarator, + SubscriptSuffix, + ParameterSuffix, + BitfieldDeclaratorSuffix, + ExtKR_IdentifierDeclarator, + + /* Initializers */ + ExpressionInitializer, + BraceEnclosedInitializer, + DesignatedInitializer, + FieldDesignator, + ArrayDesignator, + + OffsetOfDesignator, + + //-------------// + // Expressions // + //-------------// + IntegerConstantExpression, + FloatingConstantExpression, + ImaginaryIntegerConstantExpression, + ImaginaryFloatingConstantExpression, + CharacterConstantExpression, + BooleanConstantExpression, + NULL_ConstantExpression, + StringLiteralExpression, + ParenthesizedExpression, + GenericSelectionExpression, + TypedGenericAssociation, + DefaultGenericAssociation, + ExtGNU_EnclosedCompoundStatementExpression, + ExtGNU_ComplexValuedExpression, + ExtGNU_RealExpression, + ExtGNU_ImagExpression, + + /* Names */ + IdentifierName, + PredefinedName, + + /* Unary */ + PostIncrementExpression, + PostDecrementExpression, + PreIncrementExpression, + PreDecrementExpression, + UnaryPlusExpression, + UnaryMinusExpression, + BitwiseNotExpression, + LogicalNotExpression, + + /* Type trait */ + SizeofExpression, + AlignofExpression, + + /* Pointers */ + AddressOfExpression, + PointerIndirectionExpression, + + /* Access */ + DirectMemberAccessExpression, + IndirectMemberAccessExpression, + ElementAccessExpression, + + /* Invocation-like */ + CallExpression, + CompoundLiteralExpression, + CastExpression, + VAArgumentExpression, + OffsetOfExpression, + ExtGNU_ChooseExpression, + + /* Binary */ + MultiplyExpression, + DivideExpression, + ModuleExpression, + AddExpression, + SubstractExpression, + LeftShiftExpression, + RightShiftExpression, + LessThanExpression, + LessThanOrEqualExpression, + GreaterThanExpression, + GreaterThanOrEqualExpression, + EqualsExpression, + NotEqualsExpression, + BitwiseANDExpression, + BitwiseXORExpression, + BitwiseORExpression, + LogicalANDExpression, + LogicalORExpression, + + /* Conditional */ + ConditionalExpression, + + /* Assignment */ + BasicAssignmentExpression, + MultiplyAssignmentExpression, + DivideAssignmentExpression, + ModuloAssignmentExpression, + AddAssignmentExpression, + SubtractAssignmentExpression, + LeftShiftAssignmentExpression, + RightShiftAssignmentExpression, + AndAssignmentExpression, + ExclusiveOrAssignmentExpression, + OrAssignmentExpression, + + /* Sequencing */ + SequencingExpression, + + //------------// + // Statements // + //------------// + CompoundStatement, + DeclarationStatement, + ExpressionStatement, + IdentifierLabelStatement, + DefaultLabelStatement, + CaseLabelStatement, + DefaultStatement, + IfStatement, + SwitchStatement, + WhileStatement, + DoStatement, + ForStatement, + GotoStatement, + ContinueStatement, + BreakStatement, + ReturnStatement, + ExtGNU_AsmStatement, + ExtGNU_AsmVolatileQualifier, + ExtGNU_AsmInlineQualifier, + ExtGNU_AsmGotoQualifier, + ExtGNU_AsmInputOperand, + ExtGNU_AsmOutputOperand, + + //--------// + // Common // + //--------// + TypeName, + ExpressionAsTypeReference, + TypeNameAsTypeReference, + + //-------------// + // Ambiguities // + //-------------// + AmbiguousCastOrBinaryExpression, + AmbiguousTypeNameOrExpressionAsTypeReference, + AmbiguousCallOrVariableDeclaration, + AmbiguousMultiplicationOrPointerDeclaration, + + ENDof_Node = AmbiguousMultiplicationOrPointerDeclaration, + + //=================================================================== Misc + + UnknownSyntax }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxLexeme.cpp b/C/syntax/SyntaxLexeme.cpp index a3597b276..94b44f2c6 100644 --- a/C/syntax/SyntaxLexeme.cpp +++ b/C/syntax/SyntaxLexeme.cpp @@ -24,159 +24,117 @@ using namespace psy; using namespace C; -SyntaxLexeme::SyntaxLexeme(const char* chars, unsigned int size, Kind kind) - : TextElement(chars, size) - , BF_all_(0) -{ - BF_.kind_ = static_cast(kind); -} - -SyntaxLexeme::~SyntaxLexeme() -{} - -SyntaxLexeme::Kind SyntaxLexeme::kind() const -{ - return Kind(BF_.kind_); -} - -void SyntaxLexeme::checkHexPrefix() -{ - const char* chars = begin(); - if (size() > 1 - && chars[0] == '0' - && (chars[1] == 'x' || chars[1] == 'X')) { - BF_.hex_ = 1; +SyntaxLexeme::SyntaxLexeme(const char *chars, unsigned int size, Kind kind) + : TextElement(chars, size), BF_all_(0) { + BF_.kind_ = static_cast(kind); +} + +SyntaxLexeme::~SyntaxLexeme() {} + +SyntaxLexeme::Kind SyntaxLexeme::kind() const { return Kind(BF_.kind_); } + +void SyntaxLexeme::checkHexPrefix() { + const char *chars = begin(); + if (size() > 1 && chars[0] == '0' && (chars[1] == 'x' || chars[1] == 'X')) { + BF_.hex_ = 1; + } +} + +void SyntaxLexeme::checkVariousPrefixesAndSuffixes() { + const char *kEnd = end(); + for (const char *cur = begin(); cur != kEnd; ++cur) { + switch (*cur) { + case 'l': + if (cur + 1 != kEnd && *(cur + 1) == 'l') { + BF_.llOrLL_ = 1; + ++cur; + } else + BF_.l_ = 1; + break; + + case 'L': + if (cur + 1 != kEnd && *(cur + 1) == 'L') { + BF_.llOrLL_ = 1; + ++cur; + } else + BF_.L_ = 1; + break; + + case 'u': + if (cur + 1 != kEnd && *(cur + 1) == '8') { + BF_.u8_ = 1; + ++cur; + } else + BF_.u_ = 1; + break; + + case 'U': + BF_.U_ = 1; + break; + + case 'f': + case 'F': + BF_.fOrF_ = 1; + break; } + } } -void SyntaxLexeme::checkVariousPrefixesAndSuffixes() -{ - const char* kEnd = end(); - for (const char* cur = begin(); cur != kEnd; ++cur) { - switch (*cur) { - case 'l': - if (cur + 1 != kEnd && *(cur + 1 ) == 'l') { - BF_.llOrLL_ = 1; - ++cur; - } - else - BF_.l_ = 1; - break; - - case 'L': - if (cur + 1 != kEnd && *(cur + 1) == 'L') { - BF_.llOrLL_ = 1; - ++cur; - } - else - BF_.L_ = 1; - break; - - case 'u': - if (cur + 1 != kEnd && *(cur + 1 ) == '8') { - BF_.u8_ = 1; - ++cur; - } - else - BF_.u_ = 1; - break; - - case 'U': - BF_.U_ = 1; - break; - - case 'f': - case 'F': - BF_.fOrF_ = 1; - break; - } - } -} - -std::string SyntaxLexeme::valueText() const -{ - return c_str(); -} +std::string SyntaxLexeme::valueText() const { return c_str(); } -template <> -int SyntaxLexeme::value() const -{ - return std::stoi(valueText()); +template <> int SyntaxLexeme::value() const { + return std::stoi(valueText()); } -template <> -long SyntaxLexeme::value() const -{ - return std::stol(valueText()); +template <> long SyntaxLexeme::value() const { + return std::stol(valueText()); } -template <> -long long SyntaxLexeme::value() const -{ - return std::stoll(valueText()); +template <> long long SyntaxLexeme::value() const { + return std::stoll(valueText()); } -template <> -unsigned long SyntaxLexeme::value() const -{ - return std::stoul(valueText()); +template <> unsigned long SyntaxLexeme::value() const { + return std::stoul(valueText()); } -template <> -unsigned long long SyntaxLexeme::value() const -{ - return std::stoull(valueText()); +template <> unsigned long long SyntaxLexeme::value() const { + return std::stoull(valueText()); } -template <> -float SyntaxLexeme::value() const -{ - return std::stof(valueText()); +template <> float SyntaxLexeme::value() const { + return std::stof(valueText()); } -template <> -double SyntaxLexeme::value() const -{ - return std::stod(valueText()); +template <> double SyntaxLexeme::value() const { + return std::stod(valueText()); } -template <> -long double SyntaxLexeme::value() const -{ - return std::stold(valueText()); +template <> long double SyntaxLexeme::value() const { + return std::stold(valueText()); } -template <> -unsigned char SyntaxLexeme::value() const -{ - // Lexeme is: 'c' - return c_str()[1]; +template <> unsigned char SyntaxLexeme::value() const { + // Lexeme is: 'c' + return c_str()[1]; } -template <> -wchar_t SyntaxLexeme::value() const -{ - // Lexeme is: L'c' - return c_str()[2]; +template <> wchar_t SyntaxLexeme::value() const { + // Lexeme is: L'c' + return c_str()[2]; } -template <> -char16_t SyntaxLexeme::value() const -{ - // Lexeme is: u'c' - return c_str()[2]; +template <> char16_t SyntaxLexeme::value() const { + // Lexeme is: u'c' + return c_str()[2]; } -template <> -char32_t SyntaxLexeme::value() const -{ - // Lexeme is: U'c' - return c_str()[2]; +template <> char32_t SyntaxLexeme::value() const { + // Lexeme is: U'c' + return c_str()[2]; } -template <> -std::string SyntaxLexeme::value() const -{ - auto p = valueText(); - return std::string(p.c_str() + 1, p.size() - 2); +template <> std::string SyntaxLexeme::value() const { + auto p = valueText(); + return std::string(p.c_str() + 1, p.size() - 2); } diff --git a/C/syntax/SyntaxLexeme.h b/C/syntax/SyntaxLexeme.h index e93293ad9..698ac0bb6 100644 --- a/C/syntax/SyntaxLexeme.h +++ b/C/syntax/SyntaxLexeme.h @@ -35,113 +35,112 @@ namespace C { /** * \brief The SyntaxLexeme class. */ -class PSY_C_API SyntaxLexeme : public TextElement -{ +class PSY_C_API SyntaxLexeme : public TextElement { public: - virtual ~SyntaxLexeme(); - - //!@{ - /** - * Cast \c this SyntaxLexeme. - */ - virtual Identifier* asIdentifier() { return nullptr; } - virtual IntegerConstant* asIntegerConstant() { return nullptr; } - virtual FloatingConstant* asFloatingConstant() { return nullptr; } - virtual CharacterConstant* asCharacterConstant() { return nullptr; } - virtual ImaginaryIntegerConstant* asImaginaryIntegerConstant() { return nullptr; } - virtual ImaginaryFloatingConstant* asImaginaryFloatingConstant() { return nullptr; } - virtual StringLiteral* asStringLiteralExpression() { return nullptr; } - //!@} - - /** - * \brief The SyntaxLexeme::Kind enumeraiton. - */ - enum class Kind : std::uint16_t - { - UNSPECIFIED = 0, - - Identifier, - IntegerConstant, - FloatingConstant, - CharacterConstant, - ImaginaryIntegerConstant, - ImaginaryFloatingConstant, - StringLiteral - }; - - /** - * The Kind of \c this SyntaxLexeme. - */ - Kind kind() const; - - /** - * The value of \c this SyntaxLexeme represented as text, by an \c std::string. - * - * \note - * The return of this method is the same as that of SyntaxToken::valueText, - * for the SyntaxToken from which \c this SyntaxLexeme was obtained. - * - * \sa SyntaxToken::valueText - */ - std::string valueText() const; - - /** - * The value of \c this SyntaxLexeme. Template parameter \c ValueT - * must be substituted, as an argument, by the C type corresponding - * to the lexeme in question. Therefore, prior to calling - * SyntaxLexeme::value, one must check the speficic kind of a lexeme, - * and any variant it might have. Consider the snippet below, which - * stores in \c i the C value of \c 42UL of a given SyntaxLexeme, - * named \c lexeme. - * - * \code - * if (lexeme->asIntegerConstant()) { - * auto intLexeme = lexeme->asIntegerConstant(); - * if (intLexeme->signedness() == IntegerConstant::Signedness::Unsigned - * && intLexeme->variant() == IntegerConstant::Variant::Long) { - * auto i = intLexeme->value(); - * // ... - * } - * } - * \endcode - * - * \remark 6.2.5 - * \remark 6.4 - */ - template ValueT value() const; + virtual ~SyntaxLexeme(); + + //!@{ + /** + * Cast \c this SyntaxLexeme. + */ + virtual Identifier *asIdentifier() { return nullptr; } + virtual IntegerConstant *asIntegerConstant() { return nullptr; } + virtual FloatingConstant *asFloatingConstant() { return nullptr; } + virtual CharacterConstant *asCharacterConstant() { return nullptr; } + virtual ImaginaryIntegerConstant *asImaginaryIntegerConstant() { + return nullptr; + } + virtual ImaginaryFloatingConstant *asImaginaryFloatingConstant() { + return nullptr; + } + virtual StringLiteral *asStringLiteralExpression() { return nullptr; } + //!@} + + /** + * \brief The SyntaxLexeme::Kind enumeraiton. + */ + enum class Kind : std::uint16_t { + UNSPECIFIED = 0, + + Identifier, + IntegerConstant, + FloatingConstant, + CharacterConstant, + ImaginaryIntegerConstant, + ImaginaryFloatingConstant, + StringLiteral + }; + + /** + * The Kind of \c this SyntaxLexeme. + */ + Kind kind() const; + + /** + * The value of \c this SyntaxLexeme represented as text, by an \c + * std::string. + * + * \note + * The return of this method is the same as that of SyntaxToken::valueText, + * for the SyntaxToken from which \c this SyntaxLexeme was obtained. + * + * \sa SyntaxToken::valueText + */ + std::string valueText() const; + + /** + * The value of \c this SyntaxLexeme. Template parameter \c ValueT + * must be substituted, as an argument, by the C type corresponding + * to the lexeme in question. Therefore, prior to calling + * SyntaxLexeme::value, one must check the speficic kind of a lexeme, + * and any variant it might have. Consider the snippet below, which + * stores in \c i the C value of \c 42UL of a given SyntaxLexeme, + * named \c lexeme. + * + * \code + * if (lexeme->asIntegerConstant()) { + * auto intLexeme = lexeme->asIntegerConstant(); + * if (intLexeme->signedness() == IntegerConstant::Signedness::Unsigned + * && intLexeme->variant() == IntegerConstant::Variant::Long) { + * auto i = intLexeme->value(); + * // ... + * } + * } + * \endcode + * + * \remark 6.2.5 + * \remark 6.4 + */ + template ValueT value() const; protected: - SyntaxLexeme(const char* chars, - unsigned int size, - Kind kind); - - // Unavailable - SyntaxLexeme(const SyntaxLexeme&) = delete; - SyntaxLexeme& operator=(const SyntaxLexeme&) = delete; - - void checkHexPrefix(); - void checkVariousPrefixesAndSuffixes(); - - struct BitFields - { - std::uint16_t kind_ : 3; - std::uint16_t hex_ : 1; - std::uint16_t l_ : 1; - std::uint16_t L_ : 1; - std::uint16_t u_ : 1; - std::uint16_t u8_ : 1; - std::uint16_t U_ : 1; - std::uint16_t llOrLL_ : 1; - std::uint16_t fOrF_ : 1; - }; - union - { - std::uint16_t BF_all_; - BitFields BF_; - }; + SyntaxLexeme(const char *chars, unsigned int size, Kind kind); + + // Unavailable + SyntaxLexeme(const SyntaxLexeme &) = delete; + SyntaxLexeme &operator=(const SyntaxLexeme &) = delete; + + void checkHexPrefix(); + void checkVariousPrefixesAndSuffixes(); + + struct BitFields { + std::uint16_t kind_ : 3; + std::uint16_t hex_ : 1; + std::uint16_t l_ : 1; + std::uint16_t L_ : 1; + std::uint16_t u_ : 1; + std::uint16_t u8_ : 1; + std::uint16_t U_ : 1; + std::uint16_t llOrLL_ : 1; + std::uint16_t fOrF_ : 1; + }; + union { + std::uint16_t BF_all_; + BitFields BF_; + }; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxLexeme_ALL.h b/C/syntax/SyntaxLexeme_ALL.h index 5b0b91098..e849ba58e 100644 --- a/C/syntax/SyntaxLexeme_ALL.h +++ b/C/syntax/SyntaxLexeme_ALL.h @@ -22,8 +22,8 @@ #ifndef PSYCHE_C_SYNTAX_LEXEMES_H__ #define PSYCHE_C_SYNTAX_LEXEMES_H__ -#include "SyntaxLexeme_Identifier.h" #include "SyntaxLexeme_Constant.h" +#include "SyntaxLexeme_Identifier.h" #include "SyntaxLexeme_StringLiteral.h" #endif diff --git a/C/syntax/SyntaxLexeme_Constant.cpp b/C/syntax/SyntaxLexeme_Constant.cpp index 65cfdef76..758d9a587 100644 --- a/C/syntax/SyntaxLexeme_Constant.cpp +++ b/C/syntax/SyntaxLexeme_Constant.cpp @@ -24,108 +24,87 @@ using namespace psy; using namespace C; - -Constant::Constant(const char* chars, unsigned int size, Kind kind) - : SyntaxLexeme(chars, size, kind) -{ - checkHexPrefix(); - checkVariousPrefixesAndSuffixes(); +Constant::Constant(const char *chars, unsigned int size, Kind kind) + : SyntaxLexeme(chars, size, kind) { + checkHexPrefix(); + checkVariousPrefixesAndSuffixes(); } -IntegerConstant::IntegerConstant(const char* chars, unsigned int size) - : Constant(chars, - size, - Kind::IntegerConstant) -{} +IntegerConstant::IntegerConstant(const char *chars, unsigned int size) + : Constant(chars, size, Kind::IntegerConstant) {} -IntegerConstant::Signedness IntegerConstant::signedness() const -{ - return (BF_.u_ || BF_.U_) ? Signedness::Unsigned : Signedness::Signed; +IntegerConstant::Signedness IntegerConstant::signedness() const { + return (BF_.u_ || BF_.U_) ? Signedness::Unsigned : Signedness::Signed; } -IntegerConstant::Variant IntegerConstant::variant() const -{ - if (BF_.llOrLL_) - return Variant::LongLong; +IntegerConstant::Variant IntegerConstant::variant() const { + if (BF_.llOrLL_) + return Variant::LongLong; - if (BF_.l_ or BF_.L_) - return Variant::Long; + if (BF_.l_ or BF_.L_) + return Variant::Long; - return Variant::Int; + return Variant::Int; } -FloatingConstant::FloatingConstant(const char* chars, unsigned int size) - : Constant(chars, - size, - Kind::FloatingConstant) -{} +FloatingConstant::FloatingConstant(const char *chars, unsigned int size) + : Constant(chars, size, Kind::FloatingConstant) {} -FloatingConstant::Variant FloatingConstant::variant() const -{ - if (BF_.fOrF_) - return Variant::Float; +FloatingConstant::Variant FloatingConstant::variant() const { + if (BF_.fOrF_) + return Variant::Float; - if (BF_.l_ or BF_.L_) - return Variant::LongDouble; + if (BF_.l_ or BF_.L_) + return Variant::LongDouble; - return Variant::Double; + return Variant::Double; } -CharacterConstant::CharacterConstant(const char* chars, unsigned int size) - : Constant(chars, - size, - Kind::CharacterConstant) -{} +CharacterConstant::CharacterConstant(const char *chars, unsigned int size) + : Constant(chars, size, Kind::CharacterConstant) {} -CharacterConstant::Variant CharacterConstant::variant() const -{ - if (BF_.L_) - return Variant::L_wchar_t; +CharacterConstant::Variant CharacterConstant::variant() const { + if (BF_.L_) + return Variant::L_wchar_t; - if (BF_.u_) - return Variant::u_char16_t; + if (BF_.u_) + return Variant::u_char16_t; - if (BF_.U_) - return Variant::U_char32_t; + if (BF_.U_) + return Variant::U_char32_t; - return Variant::Plain_u_char; + return Variant::Plain_u_char; } -ImaginaryIntegerConstant::ImaginaryIntegerConstant(const char* chars, unsigned int size) - : Constant::Constant(chars, - size, - Kind::ImaginaryIntegerConstant) -{} +ImaginaryIntegerConstant::ImaginaryIntegerConstant(const char *chars, + unsigned int size) + : Constant::Constant(chars, size, Kind::ImaginaryIntegerConstant) {} -ImaginaryIntegerConstant::Signedness ImaginaryIntegerConstant::signedness() const -{ - return (BF_.u_ || BF_.U_) ? Signedness::Unsigned : Signedness::Signed; +ImaginaryIntegerConstant::Signedness +ImaginaryIntegerConstant::signedness() const { + return (BF_.u_ || BF_.U_) ? Signedness::Unsigned : Signedness::Signed; } -ImaginaryIntegerConstant::Variant ImaginaryIntegerConstant::variant() const -{ - if (BF_.llOrLL_) - return Variant::LongLong; +ImaginaryIntegerConstant::Variant ImaginaryIntegerConstant::variant() const { + if (BF_.llOrLL_) + return Variant::LongLong; - if (BF_.l_ or BF_.L_) - return Variant::Long; + if (BF_.l_ or BF_.L_) + return Variant::Long; - return Variant::Int; + return Variant::Int; } -ImaginaryFloatingConstant::ImaginaryFloatingConstant(const char* chars, unsigned int size) - : Constant::Constant(chars, - size, - Kind::ImaginaryFloatingConstant) -{} +ImaginaryFloatingConstant::ImaginaryFloatingConstant(const char *chars, + unsigned int size) + : Constant::Constant(chars, size, Kind::ImaginaryFloatingConstant) {} -ImaginaryFloatingConstant::Variant ImaginaryFloatingConstant::variant() const -{ - if (BF_.fOrF_) - return Variant::Float; +ImaginaryFloatingConstant::Variant ImaginaryFloatingConstant::variant() const { + if (BF_.fOrF_) + return Variant::Float; - if (BF_.l_ or BF_.L_) - return Variant::LongDouble; + if (BF_.l_ or BF_.L_) + return Variant::LongDouble; - return Variant::Double; + return Variant::Double; } diff --git a/C/syntax/SyntaxLexeme_Constant.h b/C/syntax/SyntaxLexeme_Constant.h index b8e10a987..c6022e2b5 100644 --- a/C/syntax/SyntaxLexeme_Constant.h +++ b/C/syntax/SyntaxLexeme_Constant.h @@ -37,204 +37,177 @@ namespace C { * * The base class of every constant. */ -class PSY_C_API Constant : public SyntaxLexeme -{ +class PSY_C_API Constant : public SyntaxLexeme { protected: - Constant(const char* chars, - unsigned int size, - Kind kind); + Constant(const char *chars, unsigned int size, Kind kind); }; /** * \brief The IntegerConstant class. */ -class PSY_C_API IntegerConstant final : public Constant -{ +class PSY_C_API IntegerConstant final : public Constant { public: - //!@{ - /** - * Cast \c this SyntaxLexeme as an IntegerConstant. - */ - virtual IntegerConstant* asIntegerConstant() override { return this; } - //!@} - - /** - * \brief The IntegerConstant::Signedness enumeration. - */ - enum class Signedness : std::uint8_t - { - Signed, - Unsigned, - }; - - /** - * The Signedness of \c this IntegerConstant. - */ - Signedness signedness() const; - - /** - * \brief The IntegerConstant::Variant enumeration. - */ - enum class Variant : std::uint8_t - { - Int, - Long, - LongLong - }; - - /** - * The Variant of \c this IntegerConstant. - */ - Variant variant() const; - - // TODO: Make internal. - IntegerConstant(const char* chars, unsigned int size); + //!@{ + /** + * Cast \c this SyntaxLexeme as an IntegerConstant. + */ + virtual IntegerConstant *asIntegerConstant() override { return this; } + //!@} + + /** + * \brief The IntegerConstant::Signedness enumeration. + */ + enum class Signedness : std::uint8_t { + Signed, + Unsigned, + }; + + /** + * The Signedness of \c this IntegerConstant. + */ + Signedness signedness() const; + + /** + * \brief The IntegerConstant::Variant enumeration. + */ + enum class Variant : std::uint8_t { Int, Long, LongLong }; + + /** + * The Variant of \c this IntegerConstant. + */ + Variant variant() const; + + // TODO: Make internal. + IntegerConstant(const char *chars, unsigned int size); }; /** * \brief The FloatingConstant class. */ -class PSY_C_API FloatingConstant final : public Constant -{ +class PSY_C_API FloatingConstant final : public Constant { public: - //!@{ - /** - * Cast \c this SyntaxLexeme as a FloatingConstant. - */ - virtual FloatingConstant* asFloatingConstant() override { return this; } - //!@} - - /** - * \brief The FloatingConstant::Variant enumeration. - */ - enum class Variant : std::uint8_t - { - Float, - Double, - LongDouble - }; - - /** - * The Variant of \c this FloatingConstant. - */ - Variant variant() const; - - // TODO: Make internal. - FloatingConstant(const char* chars, unsigned int size); + //!@{ + /** + * Cast \c this SyntaxLexeme as a FloatingConstant. + */ + virtual FloatingConstant *asFloatingConstant() override { return this; } + //!@} + + /** + * \brief The FloatingConstant::Variant enumeration. + */ + enum class Variant : std::uint8_t { Float, Double, LongDouble }; + + /** + * The Variant of \c this FloatingConstant. + */ + Variant variant() const; + + // TODO: Make internal. + FloatingConstant(const char *chars, unsigned int size); }; /** * \brief The CharacterConstant class. */ -class PSY_C_API CharacterConstant final : public Constant -{ +class PSY_C_API CharacterConstant final : public Constant { public: - //!@{ - /** - * Cast \c this SyntaxLexeme as a CharacterConstant. - */ - virtual CharacterConstant* asCharacterConstant() override { return this; } - //!@} - - /** - * \brief The CharacterConstant::Variant enumeration. - */ - enum class Variant : std::uint8_t - { - Plain_u_char, - L_wchar_t, - u_char16_t, - U_char32_t - }; - - /** - * The Variant of \c this CharacterConstant. - */ - Variant variant() const; - - // TODO: Make internal. - CharacterConstant(const char* chars, unsigned int size); + //!@{ + /** + * Cast \c this SyntaxLexeme as a CharacterConstant. + */ + virtual CharacterConstant *asCharacterConstant() override { return this; } + //!@} + + /** + * \brief The CharacterConstant::Variant enumeration. + */ + enum class Variant : std::uint8_t { + Plain_u_char, + L_wchar_t, + u_char16_t, + U_char32_t + }; + + /** + * The Variant of \c this CharacterConstant. + */ + Variant variant() const; + + // TODO: Make internal. + CharacterConstant(const char *chars, unsigned int size); }; /** * \brief The ImaginaryIntegerConstant class. */ -class PSY_C_API ImaginaryIntegerConstant final : public Constant -{ +class PSY_C_API ImaginaryIntegerConstant final : public Constant { public: - //!@{ - /** - * Cast \c this SyntaxLexeme as an ImaginaryIntegerConstant. - */ - virtual ImaginaryIntegerConstant* asImaginaryIntegerConstant() override { return this; } - //!@} - - /** - * \brief The ImaginaryIntegerConstant::Signedness enumeration. - */ - enum class Signedness : std::uint8_t - { - Signed, - Unsigned, - }; - - /** - * The Signedness of \c this ImaginaryIntegerConstant. - */ - Signedness signedness() const; - - /** - * \brief The ImaginaryIntegerConstant::Variant enumeration. - */ - enum class Variant : std::uint8_t - { - Int, - Long, - LongLong - }; - - /** - * The Variant of \c this ImaginaryIntegerConstant. - */ - Variant variant() const; - - // TODO: Make internal. - ImaginaryIntegerConstant(const char* chars, unsigned int size); + //!@{ + /** + * Cast \c this SyntaxLexeme as an ImaginaryIntegerConstant. + */ + virtual ImaginaryIntegerConstant *asImaginaryIntegerConstant() override { + return this; + } + //!@} + + /** + * \brief The ImaginaryIntegerConstant::Signedness enumeration. + */ + enum class Signedness : std::uint8_t { + Signed, + Unsigned, + }; + + /** + * The Signedness of \c this ImaginaryIntegerConstant. + */ + Signedness signedness() const; + + /** + * \brief The ImaginaryIntegerConstant::Variant enumeration. + */ + enum class Variant : std::uint8_t { Int, Long, LongLong }; + + /** + * The Variant of \c this ImaginaryIntegerConstant. + */ + Variant variant() const; + + // TODO: Make internal. + ImaginaryIntegerConstant(const char *chars, unsigned int size); }; /** * \brief The ImaginaryFloatingConstant class. */ -class PSY_C_API ImaginaryFloatingConstant final : public Constant -{ +class PSY_C_API ImaginaryFloatingConstant final : public Constant { public: - //!@{ - /** - * Cast \c this SyntaxLexemeas an ImaginaryFloatingConstant. - */ - virtual ImaginaryFloatingConstant* asImaginaryFloatingConstant() override { return this; } - //!@} - - /** - * \brief The ImaginaryFloatingConstant::Variant enumeration. - */ - enum class Variant : std::uint8_t - { - Float, - Double, - LongDouble - }; - - /** - * The Variant of \c this ImaginaryFloatingConstant. - */ - Variant variant() const; - - // TODO: Make internal. - ImaginaryFloatingConstant(const char* chars, unsigned int size); + //!@{ + /** + * Cast \c this SyntaxLexemeas an ImaginaryFloatingConstant. + */ + virtual ImaginaryFloatingConstant *asImaginaryFloatingConstant() override { + return this; + } + //!@} + + /** + * \brief The ImaginaryFloatingConstant::Variant enumeration. + */ + enum class Variant : std::uint8_t { Float, Double, LongDouble }; + + /** + * The Variant of \c this ImaginaryFloatingConstant. + */ + Variant variant() const; + + // TODO: Make internal. + ImaginaryFloatingConstant(const char *chars, unsigned int size); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxLexeme_Identifier.cpp b/C/syntax/SyntaxLexeme_Identifier.cpp index 4c7216c97..1f7a78ebc 100644 --- a/C/syntax/SyntaxLexeme_Identifier.cpp +++ b/C/syntax/SyntaxLexeme_Identifier.cpp @@ -24,8 +24,5 @@ using namespace psy; using namespace C; -Identifier::Identifier(const char* chars, unsigned int size) - : SyntaxLexeme(chars, - size, - Kind::Identifier) -{} +Identifier::Identifier(const char *chars, unsigned int size) + : SyntaxLexeme(chars, size, Kind::Identifier) {} diff --git a/C/syntax/SyntaxLexeme_Identifier.h b/C/syntax/SyntaxLexeme_Identifier.h index 341670b0a..1742d2831 100644 --- a/C/syntax/SyntaxLexeme_Identifier.h +++ b/C/syntax/SyntaxLexeme_Identifier.h @@ -33,21 +33,20 @@ namespace C { /** * \brief The Identifier class. */ -class PSY_C_API Identifier final : public SyntaxLexeme -{ +class PSY_C_API Identifier final : public SyntaxLexeme { public: - //!@{ - /** - * Cast \c this SyntaxLexeme as an Identifier. - */ - virtual Identifier* asIdentifier() override { return this; } - //!@} - - // TODO: Make internal. - Identifier(const char* chars, unsigned int size); + //!@{ + /** + * Cast \c this SyntaxLexeme as an Identifier. + */ + virtual Identifier *asIdentifier() override { return this; } + //!@} + + // TODO: Make internal. + Identifier(const char *chars, unsigned int size); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxLexeme_StringLiteral.cpp b/C/syntax/SyntaxLexeme_StringLiteral.cpp index 30ee19b1c..15813c611 100644 --- a/C/syntax/SyntaxLexeme_StringLiteral.cpp +++ b/C/syntax/SyntaxLexeme_StringLiteral.cpp @@ -25,26 +25,22 @@ using namespace psy; using namespace C; StringLiteral::StringLiteral(const char *chars, unsigned int size) - : SyntaxLexeme(chars, - size, - Kind::StringLiteral) -{ - checkVariousPrefixesAndSuffixes(); + : SyntaxLexeme(chars, size, Kind::StringLiteral) { + checkVariousPrefixesAndSuffixes(); } -StringLiteral::Variant StringLiteral::variant() const -{ - if (BF_.L_) - return Variant::L_wchar_t; +StringLiteral::Variant StringLiteral::variant() const { + if (BF_.L_) + return Variant::L_wchar_t; - if (BF_.u8_) - return Variant::u8_char; + if (BF_.u8_) + return Variant::u8_char; - if (BF_.u_) - return Variant::u_char16_t; + if (BF_.u_) + return Variant::u_char16_t; - if (BF_.U_) - return Variant::U_char32_t; + if (BF_.U_) + return Variant::U_char32_t; - return Variant::Plain_char; + return Variant::Plain_char; } diff --git a/C/syntax/SyntaxLexeme_StringLiteral.h b/C/syntax/SyntaxLexeme_StringLiteral.h index b355eb46b..dadf0ce87 100644 --- a/C/syntax/SyntaxLexeme_StringLiteral.h +++ b/C/syntax/SyntaxLexeme_StringLiteral.h @@ -33,37 +33,35 @@ namespace C { /** * \brief The StringLiteral class. */ -class PSY_C_API StringLiteral final : public SyntaxLexeme -{ +class PSY_C_API StringLiteral final : public SyntaxLexeme { public: - //!@{ - /** - * Cast \c this SyntaxLexeme as an StringLiteral. - */ - virtual StringLiteral* asStringLiteralExpression() { return nullptr; } + //!@{ + /** + * Cast \c this SyntaxLexeme as an StringLiteral. + */ + virtual StringLiteral *asStringLiteralExpression() { return nullptr; } - /** - * \brief The StringLiteral::Variant enumeration. - */ - enum class Variant : std::uint8_t - { - Plain_char, - L_wchar_t, - u8_char, - u_char16_t, - U_char32_t - }; + /** + * \brief The StringLiteral::Variant enumeration. + */ + enum class Variant : std::uint8_t { + Plain_char, + L_wchar_t, + u8_char, + u_char16_t, + U_char32_t + }; - /** - * The Variant of \c this StringLiteral. - */ - Variant variant() const; + /** + * The Variant of \c this StringLiteral. + */ + Variant variant() const; - // TODO: Make internal. - StringLiteral(const char* chars, unsigned int size); + // TODO: Make internal. + StringLiteral(const char *chars, unsigned int size); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxNamePrinter.cpp b/C/syntax/SyntaxNamePrinter.cpp index f40433029..817c9d5ca 100644 --- a/C/syntax/SyntaxNamePrinter.cpp +++ b/C/syntax/SyntaxNamePrinter.cpp @@ -33,113 +33,108 @@ namespace { int CUR_LEVEL; -std::string formatSnippet(std::string& snippet) -{ - std::replace_if(snippet.begin(), snippet.end(), - [] (char c) { return c == '\n' || c == '\t'; }, - ' '); - - while (true) { - auto pos = snippet.find(" "); - if (pos == std::string::npos) - break; - snippet = snippet.replace(pos, 2, " "); - } - - static const auto MAX_LEN = 30; - if (snippet.length() > MAX_LEN) { - snippet = snippet.substr(0, MAX_LEN); - snippet += "..."; - } - - return snippet; +std::string formatSnippet(std::string &snippet) { + std::replace_if( + snippet.begin(), snippet.end(), + [](char c) { return c == '\n' || c == '\t'; }, ' '); + + while (true) { + auto pos = snippet.find(" "); + if (pos == std::string::npos) + break; + snippet = snippet.replace(pos, 2, " "); + } + + static const auto MAX_LEN = 30; + if (snippet.length() > MAX_LEN) { + snippet = snippet.substr(0, MAX_LEN); + snippet += "..."; + } + + return snippet; } -} // anonymous +} // namespace -void SyntaxNamePrinter::print(const SyntaxNode* node, Style style) -{ - print(node, style, std::cout); +void SyntaxNamePrinter::print(const SyntaxNode *node, Style style) { + print(node, style, std::cout); } -void SyntaxNamePrinter::print(const SyntaxNode* node, Style style, std::ostream& os) -{ - CUR_LEVEL = 0; +void SyntaxNamePrinter::print(const SyntaxNode *node, Style style, + std::ostream &os) { + CUR_LEVEL = 0; - nonterminal(node); + nonterminal(node); - auto source = node->syntaxTree()->text().rawText(); + auto source = node->syntaxTree()->text().rawText(); - os << std::endl; - for (auto i = 0U; i < dump_.size(); ++i) { - auto node = std::get<0>(dump_[i]); - auto nodeLevel = std::get<1>(dump_[i]); - - if (style == Style::Plain) { - os << std::string(nodeLevel * 4, ' '); - os << to_string(node->kind()) << std::endl; - continue; - } - - auto levelCnt = 0; - while (nodeLevel > levelCnt) { - if (nodeLevel == levelCnt + 1) { - os << '|'; - os << std::string(2, '-'); - } - else { - int nextLevelBelow; - for (auto j = i + 1; j < dump_.size(); ++j) { - nextLevelBelow = std::get<1>(dump_[j]); - if (nextLevelBelow <= levelCnt + 1) - break; - } - if (nextLevelBelow == levelCnt + 1) - os << '|'; - else - os << ' '; - os << std::string(2, ' '); - } - ++levelCnt; - } + os << std::endl; + for (auto i = 0U; i < dump_.size(); ++i) { + auto node = std::get<0>(dump_[i]); + auto nodeLevel = std::get<1>(dump_[i]); - os << to_string(node->kind()) << " "; + if (style == Style::Plain) { + os << std::string(nodeLevel * 4, ' '); + os << to_string(node->kind()) << std::endl; + continue; + } - if (node->kind() == TranslationUnit) { - os << std::endl; - continue; + auto levelCnt = 0; + while (nodeLevel > levelCnt) { + if (nodeLevel == levelCnt + 1) { + os << '|'; + os << std::string(2, '-'); + } else { + int nextLevelBelow; + for (auto j = i + 1; j < dump_.size(); ++j) { + nextLevelBelow = std::get<1>(dump_[j]); + if (nextLevelBelow <= levelCnt + 1) + break; } + if (nextLevelBelow == levelCnt + 1) + os << '|'; + else + os << ' '; + os << std::string(2, ' '); + } + ++levelCnt; + } - os << " <"; - auto firstTk = node->firstToken(); - auto lastTk = node->lastToken(); - if (firstTk.isValid()) - os << firstTk.location().lineSpan().span().start(); - os << ".."; - if (lastTk.isValid()) - os << lastTk.location().lineSpan().span().end(); - os << "> "; - - if (firstTk.isValid() && lastTk.isValid()) { - auto firstTkStart = source.c_str() + firstTk.span().start(); - auto lastTkEnd = source.c_str() + lastTk.span().end(); - std::string snippet(firstTkStart, lastTkEnd - firstTkStart); - os << " `" << formatSnippet(snippet) << "`"; - } + os << to_string(node->kind()) << " "; - os << std::endl; + if (node->kind() == TranslationUnit) { + os << std::endl; + continue; } + + os << " <"; + auto firstTk = node->firstToken(); + auto lastTk = node->lastToken(); + if (firstTk.isValid()) + os << firstTk.location().lineSpan().span().start(); + os << ".."; + if (lastTk.isValid()) + os << lastTk.location().lineSpan().span().end(); + os << "> "; + + if (firstTk.isValid() && lastTk.isValid()) { + auto firstTkStart = source.c_str() + firstTk.span().start(); + auto lastTkEnd = source.c_str() + lastTk.span().end(); + std::string snippet(firstTkStart, lastTkEnd - firstTkStart); + os << " `" << formatSnippet(snippet) << "`"; + } + + os << std::endl; + } } -void SyntaxNamePrinter::nonterminal(const SyntaxNode* node) -{ - if (!node) - return; +void SyntaxNamePrinter::nonterminal(const SyntaxNode *node) { + if (!node) + return; - dump_.push_back(std::make_tuple(node, CUR_LEVEL)); + dump_.push_back(std::make_tuple(node, CUR_LEVEL)); - ++CUR_LEVEL; - visit(node); - --CUR_LEVEL; + ++CUR_LEVEL; + visit(node); + --CUR_LEVEL; } - diff --git a/C/syntax/SyntaxNamePrinter.h b/C/syntax/SyntaxNamePrinter.h index ef2a480fd..d51548619 100644 --- a/C/syntax/SyntaxNamePrinter.h +++ b/C/syntax/SyntaxNamePrinter.h @@ -32,27 +32,22 @@ namespace psy { namespace C { -class PSY_C_API SyntaxNamePrinter final : public SyntaxDumper -{ +class PSY_C_API SyntaxNamePrinter final : public SyntaxDumper { public: - using SyntaxDumper::SyntaxDumper; + using SyntaxDumper::SyntaxDumper; - enum class Style : char - { - Plain, - Decorated - }; + enum class Style : char { Plain, Decorated }; - void print(const SyntaxNode* node, Style style); - void print(const SyntaxNode* node, Style style, std::ostream& os); + void print(const SyntaxNode *node, Style style); + void print(const SyntaxNode *node, Style style, std::ostream &os); private: - virtual void nonterminal(const SyntaxNode* node) override; + virtual void nonterminal(const SyntaxNode *node) override; - std::vector> dump_; + std::vector> dump_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxNode.cpp b/C/syntax/SyntaxNode.cpp index df3023a8d..f1086fab3 100644 --- a/C/syntax/SyntaxNode.cpp +++ b/C/syntax/SyntaxNode.cpp @@ -29,478 +29,463 @@ using namespace psy; using namespace C; -SyntaxNode::SyntaxNode(SyntaxTree* tree, SyntaxKind kind) - : tree_(tree) - , kind_(kind) -{} +SyntaxNode::SyntaxNode(SyntaxTree *tree, SyntaxKind kind) + : tree_(tree), kind_(kind) {} -SyntaxNode::~SyntaxNode() -{} +SyntaxNode::~SyntaxNode() {} -const SyntaxTree* SyntaxNode::syntaxTree() const -{ - return tree_; -} +const SyntaxTree *SyntaxNode::syntaxTree() const { return tree_; } -SyntaxKind SyntaxNode::kind() const -{ - return kind_; -} +SyntaxKind SyntaxNode::kind() const { return kind_; } -SyntaxToken SyntaxNode::firstToken() const -{ - return findValidToken(childNodesAndTokens()); +SyntaxToken SyntaxNode::firstToken() const { + return findValidToken(childNodesAndTokens()); } -SyntaxToken SyntaxNode::lastToken() const -{ - auto reversed = childNodesAndTokens(); - std::reverse(reversed.begin(), reversed.end()); - return findValidToken(reversed); +SyntaxToken SyntaxNode::lastToken() const { + auto reversed = childNodesAndTokens(); + std::reverse(reversed.begin(), reversed.end()); + return findValidToken(reversed); } -SyntaxToken SyntaxNode::findValidToken(const std::vector& syntaxHolders) const -{ - for (const auto& synH : syntaxHolders) { - switch (synH.variant()) { - case SyntaxHolder::Variant::Token: - if (synH.tokenIndex() != LexedTokens::invalidIndex()) - return tokenAtIndex(synH.tokenIndex()); - break; - - case SyntaxHolder::Variant::Node: - if (synH.node()) { - auto tk = synH.node()->firstToken(); - if (tk != SyntaxToken::invalid()) - return tk; - } - break; - - case SyntaxHolder::Variant::NodeList: - if (synH.nodeList()) { - auto tk = synH.nodeList()->firstToken(); - if (tk != SyntaxToken::invalid()) - return tk; - } - break; - } +SyntaxToken SyntaxNode::findValidToken( + const std::vector &syntaxHolders) const { + for (const auto &synH : syntaxHolders) { + switch (synH.variant()) { + case SyntaxHolder::Variant::Token: + if (synH.tokenIndex() != LexedTokens::invalidIndex()) + return tokenAtIndex(synH.tokenIndex()); + break; + + case SyntaxHolder::Variant::Node: + if (synH.node()) { + auto tk = synH.node()->firstToken(); + if (tk != SyntaxToken::invalid()) + return tk; + } + break; + + case SyntaxHolder::Variant::NodeList: + if (synH.nodeList()) { + auto tk = synH.nodeList()->firstToken(); + if (tk != SyntaxToken::invalid()) + return tk; + } + break; } - return 0; + } + return 0; } -SyntaxToken SyntaxNode::tokenAtIndex(LexedTokens::IndexType tkIdx) const -{ - if (tkIdx == 0) - return SyntaxToken::invalid(); - return tree_->tokenAt(tkIdx); +SyntaxToken SyntaxNode::tokenAtIndex(LexedTokens::IndexType tkIdx) const { + if (tkIdx == 0) + return SyntaxToken::invalid(); + return tree_->tokenAt(tkIdx); } -void SyntaxNode::visitChildren(SyntaxVisitor* visitor) const -{ - for (auto synH : childNodesAndTokens()) { - switch (synH.variant()) { - case SyntaxHolder::Variant::Node: { - if (!synH.node()) - continue; - - auto node = const_cast(synH.node()); - node->acceptVisitor(visitor); - break; - } - - case SyntaxHolder::Variant::NodeList: { - if (!synH.nodeList()) - continue; - - auto nodeL = const_cast(synH.nodeList()); - nodeL->acceptVisitor(visitor); - break; - } - - default: - break; - } +void SyntaxNode::visitChildren(SyntaxVisitor *visitor) const { + for (auto synH : childNodesAndTokens()) { + switch (synH.variant()) { + case SyntaxHolder::Variant::Node: { + if (!synH.node()) + continue; + + auto node = const_cast(synH.node()); + node->acceptVisitor(visitor); + break; } -} -void SyntaxNode::acceptVisitor(SyntaxVisitor* visitor) const -{ - if (visitor->preVisit(this)) { - auto action = dispatchVisit(visitor); - if (action == SyntaxVisitor::Action::Visit) - visitChildren(visitor); + case SyntaxHolder::Variant::NodeList: { + if (!synH.nodeList()) + continue; + + auto nodeL = const_cast(synH.nodeList()); + nodeL->acceptVisitor(visitor); + break; } - visitor->postVisit(this); + + default: + break; + } + } +} + +void SyntaxNode::acceptVisitor(SyntaxVisitor *visitor) const { + if (visitor->preVisit(this)) { + auto action = dispatchVisit(visitor); + if (action == SyntaxVisitor::Action::Visit) + visitChildren(visitor); + } + visitor->postVisit(this); } namespace psy { namespace C { -extern const char* tokenNames[]; - -std::string PSY_C_API to_string(SyntaxKind kind) -{ - switch (kind) { - - //--------------// - // Declarations // - //--------------// - case TranslationUnit: - return "TranslationUnit"; - case IncompleteDeclaration: - return "IncompleteDeclaration"; - case StructDeclaration: - return "StructDeclaration"; - case UnionDeclaration: - return "UnionDeclaration"; - case EnumDeclaration: - return "EnumDeclaration"; - case EnumeratorDeclaration: - return "EnumeratorDeclaration"; - case VariableAndOrFunctionDeclaration: - return "VariableAndOrFunctionDeclaration"; - case ParameterDeclaration: - return "ParameterDeclaration"; - case FieldDeclaration: - return "FieldDeclaration"; - case StaticAssertDeclaration: - return "StaticAssertDeclaration"; - case FunctionDefinition: - return "FunctionDefinition"; - case ExtGNU_AsmStatementDeclaration: - return "ExtGNU_AsmStatementDeclaration"; - case ExtPSY_TemplateDeclaration: - return "ExtPSY_TemplateDeclaration"; - case ExtKR_ParameterDeclaration: - return "ExtKR_ParameterDeclaration"; - - /* Specifiers */ - case TypedefStorageClass: - return "TypedefStorageClass"; - case ExternStorageClass: - return "ExternStorageClass"; - case StaticStorageClass: - return "StaticStorageClass"; - case AutoStorageClass: - return "AutoStorageClass"; - case RegisterStorageClass: - return "RegisterStorageClass"; - case ThreadLocalStorageClass: - return "ThreadLocalStorageClass"; - case ConstQualifier: - return "ConstQualifier"; - case RestrictQualifier: - return "RestrictQualifier"; - case VolatileQualifier: - return "VolatileQualifier"; - case AtomicQualifier: - return "AtomicQualifier"; - case BuiltinTypeSpecifier: - return "BuiltinTypeSpecifier"; - case StructTypeSpecifier: - return "StructTypeSpecifier"; - case UnionTypeSpecifier: - return "UnionTypeSpecifier"; - case EnumTypeSpecifier: - return "EnumTypeSpecifier"; - case AtomicTypeSpecifier: - return "AtomicTypeSpecifier"; - case TypeDeclarationAsSpecifier: - return "TypeDeclarationAsSpecifier"; - case InlineSpecifier: - return "InlineSpecifier"; - case NoReturnSpecifier: - return "NoReturnSpecifier"; - case AlignmentSpecifier: - return "AlignmentSpecifier"; - case TypedefName: - return "TypedefName"; - case ExtGNU_AttributeSpecifier: - return "ExtGNU_AttributeSpecifier"; - case ExtGNU_Attribute: - return "ExtGNU_Attribute"; - case ExtGNU_AsmLabel: - return "ExtGNU_AsmLabel"; - case ExtGNU_Typeof: - return "ExtGNU_Typeof"; - - /* Declarators */ - case PointerDeclarator: - return "PointerDeclarator"; - case IdentifierDeclarator: - return "IdentifierDeclarator"; - case AbstractDeclarator: - return "AbstractDeclarator"; - case ParenthesizedDeclarator: - return "ParenthesizedDeclarator"; - case ArrayDeclarator: - return "ArrayDeclarator"; - case FunctionDeclarator: - return "FunctionDeclarator"; - case BitfieldDeclarator: - return "BitfieldDeclarator"; - case SubscriptSuffix: - return "SubscriptSuffix"; - case ParameterSuffix: - return "ParameterSuffix"; - case BitfieldDeclaratorSuffix: - return "BitfieldDeclaratorSuffix"; - - /* Initializers */ - case ExpressionInitializer: - return "ExpressionInitializer"; - case BraceEnclosedInitializer: - return "BraceEnclosedInitializer"; - case DesignatedInitializer: - return "DesignatedInitializer"; - case FieldDesignator: - return "FieldDesignator"; - case ArrayDesignator: - return "ArrayDesignator"; - - case OffsetOfDesignator: - return "OffsetOfDesignator"; - - //-------------// - // Expressions // - //-------------// - case IntegerConstantExpression: - return "IntegerConstantExpression"; - case FloatingConstantExpression: - return "FloatingConstantExpression"; - case CharacterConstantExpression: - return "CharacterConstantExpression"; - case ImaginaryIntegerConstantExpression: - return "ImaginaryIntegerConstantExpression"; - case ImaginaryFloatingConstantExpression: - return "ImaginaryFloatingConstantExpression"; - case BooleanConstantExpression: - return "BooleanLiteralExpression"; - case NULL_ConstantExpression: - return "NULL_ConstantExpression"; - case StringLiteralExpression: - return "StringLiteralExpression"; - case ParenthesizedExpression: - return "ParenthesizedExpression"; - case GenericSelectionExpression: - return "GenericSelectionExpression"; - case TypedGenericAssociation: - return "GenericTypenameAssociation"; - case DefaultGenericAssociation: - return "GenericDefaultAssociation"; - case ExtGNU_EnclosedCompoundStatementExpression: - return "ExtGNU_EnclosedCompoundStatementExpression"; - case ExtGNU_ComplexValuedExpression: - return "ExtGNU_ComplexValuedExpression"; - case ExtGNU_RealExpression: - return "ExtGNU_RealExpression"; - case ExtGNU_ImagExpression: - return "ExtGNU_ImagExpression"; - - /* Names */ - case IdentifierName: - return "IdentifierName"; - case PredefinedName: - return "PredefinedName"; - - /* Unary */ - case PreIncrementExpression: - return "PreIncrementExpression"; - case PreDecrementExpression: - return "PreDecrementExpression"; - case PostIncrementExpression: - return "PostIncrementExpression"; - case PostDecrementExpression: - return "PostDecrementExpression"; - case UnaryPlusExpression: - return "UnaryPlusExpression"; - case UnaryMinusExpression: - return "UnaryMinusExpression"; - case BitwiseNotExpression: - return "BitwiseNotExpression"; - case LogicalNotExpression: - return "LogicalNotExpression"; - - /* Type trait */ - case SizeofExpression: - return "SizeofExpression"; - case AlignofExpression: - return "AlignofExpression"; - - /* Pointers */ - case AddressOfExpression: - return "AddressOfExpression"; - case PointerIndirectionExpression: - return "PointerIndirectionExpression"; - - /* Access */ - case DirectMemberAccessExpression: - return "DirectMemberAccessExpression"; - case IndirectMemberAccessExpression: - return "IndirectMemberAccessExpression"; - case ElementAccessExpression: - return "ElementAccessExpression"; - - /* Invocation-like */ - case CallExpression: - return "CallExpression"; - case CompoundLiteralExpression: - return "CompoundLiteralExpression"; - case CastExpression: - return "CastExpression"; - case VAArgumentExpression: - return "VAArgumentExpression"; - case OffsetOfExpression: - return "OffsetOfExpression"; - case ExtGNU_ChooseExpression: - return "ExtGNU_ChooseExpression"; - - /* Binary */ - case MultiplyExpression: - return "MultipliyExpression"; - case DivideExpression: - return "DivideExpression"; - case ModuleExpression: - return "ModuleExpression"; - case AddExpression: - return "AddExpression"; - case SubstractExpression: - return "SubstractExpression"; - case LeftShiftExpression: - return "LeftShiftExpression"; - case RightShiftExpression: - return "RightShiftExpression"; - case LessThanExpression: - return "LessThanExpression"; - case LessThanOrEqualExpression: - return "LessThanOrEqualExpression"; - case GreaterThanExpression: - return "GreaterThanExpression"; - case GreaterThanOrEqualExpression: - return "GreaterThanOrEqualExpression"; - case EqualsExpression: - return "EqualsExpression"; - case NotEqualsExpression: - return "NotEqualsExpression"; - case BitwiseANDExpression: - return "BitwiseExpression"; - case BitwiseXORExpression: - return "ExclusiveOrExpression"; - case BitwiseORExpression: - return "BitwiseOrExpression"; - case LogicalANDExpression: - return "LogicalAndExpression"; - case LogicalORExpression: - return "LogicalOrExpression"; - case ConditionalExpression: - return "ConditionalExpression"; - - /* Assignment */ - case BasicAssignmentExpression: - return "BasicAssignmentExpression"; - case MultiplyAssignmentExpression: - return "MultiplyAssignmentExpression"; - case DivideAssignmentExpression: - return "DivideAssignmentExpression"; - case ModuloAssignmentExpression: - return "ModuloAssignmentExpression"; - case AddAssignmentExpression: - return "AddAssignmentExpression"; - case SubtractAssignmentExpression: - return "SubtractAssignmentExpression"; - case LeftShiftAssignmentExpression: - return "LeftShiftAssignmentExpression"; - case RightShiftAssignmentExpression: - return "RightShiftAssignmentExpression"; - case AndAssignmentExpression: - return "AndAssignmentExpression"; - case ExclusiveOrAssignmentExpression: - return "ExclusiveOrAssignmentExpression"; - case OrAssignmentExpression: - return "OrAssignmentExpression"; - - /* Sequencing */ - case SequencingExpression: - return "SequencingExpression"; - - //------------// - // Statements // - //------------// - case CompoundStatement: - return "CompoundStatement"; - case DeclarationStatement: - return "DeclarationStatement"; - case ExpressionStatement: - return "ExpressionStatement"; - case IdentifierLabelStatement: - return "IdentifierLabelStatement"; - case DefaultLabelStatement: - return "DefaultLabelStatement"; - case CaseLabelStatement: - return "CaseLabelStatement"; - case DefaultStatement: - return "DefaultStatement"; - case IfStatement: - return "IfStatement"; - case SwitchStatement: - return "SwitchStatement"; - case WhileStatement: - return "WhileStatement"; - case DoStatement: - return "DoStatement"; - case ForStatement: - return "ForStatement"; - case GotoStatement: - return "GotoStatement"; - case ContinueStatement: - return "ContinueStatement"; - case BreakStatement: - return "BreakStatement"; - case ReturnStatement: - return "ReturnStatement"; - case ExtGNU_AsmStatement: - return "ExtGNU_AsmStatement"; - case ExtGNU_AsmVolatileQualifier: - return "ExtGNU_AsmVolatileQualifier"; - case ExtGNU_AsmInlineQualifier: - return "ExtGNU_AsmInlineQualifier"; - case ExtGNU_AsmGotoQualifier: - return "ExtGNU_AsmGotoQualifier"; - case ExtGNU_AsmInputOperand: - return "ExtGNU_AsmInputOperand"; - case ExtGNU_AsmOutputOperand: - return "ExtGNU_AsmOutputOperand"; - - //--------// - // Common // - //--------// - case TypeName: - return "TypeName"; - case ExpressionAsTypeReference: - return "ExpressionAsTypeReference"; - case TypeNameAsTypeReference: - return "TypeNameAsTypeReference"; - - //-------------// - // Ambiguities // - //-------------// - case AmbiguousTypeNameOrExpressionAsTypeReference: - return "AmbiguousTypeNameOrExpressionAsTypeReference"; - case AmbiguousCastOrBinaryExpression: - return "AmbiguousCastOrBinaryExpression"; - case AmbiguousCallOrVariableDeclaration: - return "AmbiguousCallOrVariableDeclaration"; - case AmbiguousMultiplicationOrPointerDeclaration: - return "AmbiguousCallOrVariableDeclaration"; - -//=================================================================== Misc - - case UnknownSyntax: - return ""; - default: - return tokenNames[kind]; - } +extern const char *tokenNames[]; + +std::string PSY_C_API to_string(SyntaxKind kind) { + switch (kind) { + + //--------------// + // Declarations // + //--------------// + case TranslationUnit: + return "TranslationUnit"; + case IncompleteDeclaration: + return "IncompleteDeclaration"; + case StructDeclaration: + return "StructDeclaration"; + case UnionDeclaration: + return "UnionDeclaration"; + case EnumDeclaration: + return "EnumDeclaration"; + case EnumeratorDeclaration: + return "EnumeratorDeclaration"; + case VariableAndOrFunctionDeclaration: + return "VariableAndOrFunctionDeclaration"; + case ParameterDeclaration: + return "ParameterDeclaration"; + case FieldDeclaration: + return "FieldDeclaration"; + case StaticAssertDeclaration: + return "StaticAssertDeclaration"; + case FunctionDefinition: + return "FunctionDefinition"; + case ExtGNU_AsmStatementDeclaration: + return "ExtGNU_AsmStatementDeclaration"; + case ExtPSY_TemplateDeclaration: + return "ExtPSY_TemplateDeclaration"; + case ExtKR_ParameterDeclaration: + return "ExtKR_ParameterDeclaration"; + + /* Specifiers */ + case TypedefStorageClass: + return "TypedefStorageClass"; + case ExternStorageClass: + return "ExternStorageClass"; + case StaticStorageClass: + return "StaticStorageClass"; + case AutoStorageClass: + return "AutoStorageClass"; + case RegisterStorageClass: + return "RegisterStorageClass"; + case ThreadLocalStorageClass: + return "ThreadLocalStorageClass"; + case ConstQualifier: + return "ConstQualifier"; + case RestrictQualifier: + return "RestrictQualifier"; + case VolatileQualifier: + return "VolatileQualifier"; + case AtomicQualifier: + return "AtomicQualifier"; + case BuiltinTypeSpecifier: + return "BuiltinTypeSpecifier"; + case StructTypeSpecifier: + return "StructTypeSpecifier"; + case UnionTypeSpecifier: + return "UnionTypeSpecifier"; + case EnumTypeSpecifier: + return "EnumTypeSpecifier"; + case AtomicTypeSpecifier: + return "AtomicTypeSpecifier"; + case TypeDeclarationAsSpecifier: + return "TypeDeclarationAsSpecifier"; + case InlineSpecifier: + return "InlineSpecifier"; + case NoReturnSpecifier: + return "NoReturnSpecifier"; + case AlignmentSpecifier: + return "AlignmentSpecifier"; + case TypedefName: + return "TypedefName"; + case ExtGNU_AttributeSpecifier: + return "ExtGNU_AttributeSpecifier"; + case ExtGNU_Attribute: + return "ExtGNU_Attribute"; + case ExtGNU_AsmLabel: + return "ExtGNU_AsmLabel"; + case ExtGNU_Typeof: + return "ExtGNU_Typeof"; + + /* Declarators */ + case PointerDeclarator: + return "PointerDeclarator"; + case IdentifierDeclarator: + return "IdentifierDeclarator"; + case AbstractDeclarator: + return "AbstractDeclarator"; + case ParenthesizedDeclarator: + return "ParenthesizedDeclarator"; + case ArrayDeclarator: + return "ArrayDeclarator"; + case FunctionDeclarator: + return "FunctionDeclarator"; + case BitfieldDeclarator: + return "BitfieldDeclarator"; + case SubscriptSuffix: + return "SubscriptSuffix"; + case ParameterSuffix: + return "ParameterSuffix"; + case BitfieldDeclaratorSuffix: + return "BitfieldDeclaratorSuffix"; + + /* Initializers */ + case ExpressionInitializer: + return "ExpressionInitializer"; + case BraceEnclosedInitializer: + return "BraceEnclosedInitializer"; + case DesignatedInitializer: + return "DesignatedInitializer"; + case FieldDesignator: + return "FieldDesignator"; + case ArrayDesignator: + return "ArrayDesignator"; + + case OffsetOfDesignator: + return "OffsetOfDesignator"; + + //-------------// + // Expressions // + //-------------// + case IntegerConstantExpression: + return "IntegerConstantExpression"; + case FloatingConstantExpression: + return "FloatingConstantExpression"; + case CharacterConstantExpression: + return "CharacterConstantExpression"; + case ImaginaryIntegerConstantExpression: + return "ImaginaryIntegerConstantExpression"; + case ImaginaryFloatingConstantExpression: + return "ImaginaryFloatingConstantExpression"; + case BooleanConstantExpression: + return "BooleanLiteralExpression"; + case NULL_ConstantExpression: + return "NULL_ConstantExpression"; + case StringLiteralExpression: + return "StringLiteralExpression"; + case ParenthesizedExpression: + return "ParenthesizedExpression"; + case GenericSelectionExpression: + return "GenericSelectionExpression"; + case TypedGenericAssociation: + return "GenericTypenameAssociation"; + case DefaultGenericAssociation: + return "GenericDefaultAssociation"; + case ExtGNU_EnclosedCompoundStatementExpression: + return "ExtGNU_EnclosedCompoundStatementExpression"; + case ExtGNU_ComplexValuedExpression: + return "ExtGNU_ComplexValuedExpression"; + case ExtGNU_RealExpression: + return "ExtGNU_RealExpression"; + case ExtGNU_ImagExpression: + return "ExtGNU_ImagExpression"; + + /* Names */ + case IdentifierName: + return "IdentifierName"; + case PredefinedName: + return "PredefinedName"; + + /* Unary */ + case PreIncrementExpression: + return "PreIncrementExpression"; + case PreDecrementExpression: + return "PreDecrementExpression"; + case PostIncrementExpression: + return "PostIncrementExpression"; + case PostDecrementExpression: + return "PostDecrementExpression"; + case UnaryPlusExpression: + return "UnaryPlusExpression"; + case UnaryMinusExpression: + return "UnaryMinusExpression"; + case BitwiseNotExpression: + return "BitwiseNotExpression"; + case LogicalNotExpression: + return "LogicalNotExpression"; + + /* Type trait */ + case SizeofExpression: + return "SizeofExpression"; + case AlignofExpression: + return "AlignofExpression"; + + /* Pointers */ + case AddressOfExpression: + return "AddressOfExpression"; + case PointerIndirectionExpression: + return "PointerIndirectionExpression"; + + /* Access */ + case DirectMemberAccessExpression: + return "DirectMemberAccessExpression"; + case IndirectMemberAccessExpression: + return "IndirectMemberAccessExpression"; + case ElementAccessExpression: + return "ElementAccessExpression"; + + /* Invocation-like */ + case CallExpression: + return "CallExpression"; + case CompoundLiteralExpression: + return "CompoundLiteralExpression"; + case CastExpression: + return "CastExpression"; + case VAArgumentExpression: + return "VAArgumentExpression"; + case OffsetOfExpression: + return "OffsetOfExpression"; + case ExtGNU_ChooseExpression: + return "ExtGNU_ChooseExpression"; + + /* Binary */ + case MultiplyExpression: + return "MultipliyExpression"; + case DivideExpression: + return "DivideExpression"; + case ModuleExpression: + return "ModuleExpression"; + case AddExpression: + return "AddExpression"; + case SubstractExpression: + return "SubstractExpression"; + case LeftShiftExpression: + return "LeftShiftExpression"; + case RightShiftExpression: + return "RightShiftExpression"; + case LessThanExpression: + return "LessThanExpression"; + case LessThanOrEqualExpression: + return "LessThanOrEqualExpression"; + case GreaterThanExpression: + return "GreaterThanExpression"; + case GreaterThanOrEqualExpression: + return "GreaterThanOrEqualExpression"; + case EqualsExpression: + return "EqualsExpression"; + case NotEqualsExpression: + return "NotEqualsExpression"; + case BitwiseANDExpression: + return "BitwiseExpression"; + case BitwiseXORExpression: + return "ExclusiveOrExpression"; + case BitwiseORExpression: + return "BitwiseOrExpression"; + case LogicalANDExpression: + return "LogicalAndExpression"; + case LogicalORExpression: + return "LogicalOrExpression"; + case ConditionalExpression: + return "ConditionalExpression"; + + /* Assignment */ + case BasicAssignmentExpression: + return "BasicAssignmentExpression"; + case MultiplyAssignmentExpression: + return "MultiplyAssignmentExpression"; + case DivideAssignmentExpression: + return "DivideAssignmentExpression"; + case ModuloAssignmentExpression: + return "ModuloAssignmentExpression"; + case AddAssignmentExpression: + return "AddAssignmentExpression"; + case SubtractAssignmentExpression: + return "SubtractAssignmentExpression"; + case LeftShiftAssignmentExpression: + return "LeftShiftAssignmentExpression"; + case RightShiftAssignmentExpression: + return "RightShiftAssignmentExpression"; + case AndAssignmentExpression: + return "AndAssignmentExpression"; + case ExclusiveOrAssignmentExpression: + return "ExclusiveOrAssignmentExpression"; + case OrAssignmentExpression: + return "OrAssignmentExpression"; + + /* Sequencing */ + case SequencingExpression: + return "SequencingExpression"; + + //------------// + // Statements // + //------------// + case CompoundStatement: + return "CompoundStatement"; + case DeclarationStatement: + return "DeclarationStatement"; + case ExpressionStatement: + return "ExpressionStatement"; + case IdentifierLabelStatement: + return "IdentifierLabelStatement"; + case DefaultLabelStatement: + return "DefaultLabelStatement"; + case CaseLabelStatement: + return "CaseLabelStatement"; + case DefaultStatement: + return "DefaultStatement"; + case IfStatement: + return "IfStatement"; + case SwitchStatement: + return "SwitchStatement"; + case WhileStatement: + return "WhileStatement"; + case DoStatement: + return "DoStatement"; + case ForStatement: + return "ForStatement"; + case GotoStatement: + return "GotoStatement"; + case ContinueStatement: + return "ContinueStatement"; + case BreakStatement: + return "BreakStatement"; + case ReturnStatement: + return "ReturnStatement"; + case ExtGNU_AsmStatement: + return "ExtGNU_AsmStatement"; + case ExtGNU_AsmVolatileQualifier: + return "ExtGNU_AsmVolatileQualifier"; + case ExtGNU_AsmInlineQualifier: + return "ExtGNU_AsmInlineQualifier"; + case ExtGNU_AsmGotoQualifier: + return "ExtGNU_AsmGotoQualifier"; + case ExtGNU_AsmInputOperand: + return "ExtGNU_AsmInputOperand"; + case ExtGNU_AsmOutputOperand: + return "ExtGNU_AsmOutputOperand"; + + //--------// + // Common // + //--------// + case TypeName: + return "TypeName"; + case ExpressionAsTypeReference: + return "ExpressionAsTypeReference"; + case TypeNameAsTypeReference: + return "TypeNameAsTypeReference"; + + //-------------// + // Ambiguities // + //-------------// + case AmbiguousTypeNameOrExpressionAsTypeReference: + return "AmbiguousTypeNameOrExpressionAsTypeReference"; + case AmbiguousCastOrBinaryExpression: + return "AmbiguousCastOrBinaryExpression"; + case AmbiguousCallOrVariableDeclaration: + return "AmbiguousCallOrVariableDeclaration"; + case AmbiguousMultiplicationOrPointerDeclaration: + return "AmbiguousCallOrVariableDeclaration"; + + //=================================================================== Misc + + case UnknownSyntax: + return ""; + default: + return tokenNames[kind]; + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/syntax/SyntaxNode.h b/C/syntax/SyntaxNode.h index dc4739d4a..b588c06f5 100644 --- a/C/syntax/SyntaxNode.h +++ b/C/syntax/SyntaxNode.h @@ -25,11 +25,11 @@ #include "API.h" #include "Fwds.h" +#include "SyntaxHolder.h" #include "SyntaxKind.h" #include "SyntaxNodeList.h" #include "SyntaxToken.h" #include "SyntaxVisitor.h" -#include "SyntaxHolder.h" #include "infra/Managed.h" #include "parser/LexedTokens.h" @@ -51,317 +51,603 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.SyntaxNode * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API SyntaxNode : public Managed -{ +class PSY_C_API SyntaxNode : public Managed { public: - virtual ~SyntaxNode(); - - /** - * The SyntaxTree to which \c this SyntaxNode belongs to. - */ - const SyntaxTree* syntaxTree() const; - - /** - * The SyntaxKind of \c this SyntaxNode. - */ - SyntaxKind kind() const; - - /** - * Whether \c this SyntaxNode is of SyntaxKind \p k. - */ - bool isKind(SyntaxKind k) { return kind() == k; } - - /** - * The first token of \c this SyntaxNode. - */ - SyntaxToken firstToken() const; - - /** - * The last token of \c this SyntaxNode. - */ - SyntaxToken lastToken() const; - - //!@{ - /** - * Accept \c this SyntaxNode for traversal by the given \p visitor. - */ - void acceptVisitor(SyntaxVisitor* visitor) const; - - /** - * Accept the SyntaxNode \p node for traversal by the given \p visitor. - */ - static void acceptVisitor(const SyntaxNode* node, SyntaxVisitor* visitor) - { - if (node) - node->acceptVisitor(visitor); - } - - /** - * Accept the syntax list \p it for traversal by the given \p visitor. - */ - template - static void acceptVisitor(List* it, SyntaxVisitor* visitor) - { - for (; it; it = it->next) - acceptVisitor(it->value, visitor); - } - //!@} - - //--------------// - // Declarations // - //--------------// - virtual TranslationUnitSyntax* asTranslationUnit() { return nullptr; } - virtual const TranslationUnitSyntax* asTranslationUnit() const { return nullptr; } - virtual DeclarationSyntax* asDeclaration() { return nullptr; } - virtual const DeclarationSyntax* asDeclaration() const { return nullptr; } - virtual IncompleteDeclarationSyntax* asIncompleteDeclaration() { return nullptr; } - virtual const IncompleteDeclarationSyntax* asIncompleteDeclaration() const { return nullptr; } - virtual NamedDeclarationSyntax* asNamedDeclaration() { return nullptr; } - virtual const NamedDeclarationSyntax* asNamedDeclaration() const { return nullptr; } - virtual TypeDeclarationSyntax* asTypeDeclaration() { return nullptr; } - virtual const TypeDeclarationSyntax* asTypeDeclaration() const { return nullptr; } - virtual TagDeclarationSyntax* asTagDeclaration() { return nullptr; } - virtual const TagDeclarationSyntax* asTagDeclaration() const { return nullptr; } - virtual StructOrUnionDeclarationSyntax* asStructOrUnionDeclaration() { return nullptr; } - virtual const StructOrUnionDeclarationSyntax* asStructOrUnionDeclaration() const { return nullptr; } - virtual EnumDeclarationSyntax* asEnumDeclaration() { return nullptr; } - virtual const EnumDeclarationSyntax* asEnumDeclaration() const { return nullptr; } - virtual EnumeratorDeclarationSyntax* asEnumeratorDeclaration() { return nullptr; } - virtual const EnumeratorDeclarationSyntax* asEnumeratorDeclaration() const { return nullptr; } - virtual ValueDeclarationSyntax* asValueDeclaration() { return nullptr; } - virtual const ValueDeclarationSyntax* asValueDeclaration() const { return nullptr; } - virtual DeclaratorDeclarationSyntax* asDeclaratorDeclaration() { return nullptr; } - virtual const DeclaratorDeclarationSyntax* asDeclaratorDeclaration() const { return nullptr; } - virtual VariableAndOrFunctionDeclarationSyntax* asVariableAndOrFunctionDeclaration() { return nullptr; } - virtual const VariableAndOrFunctionDeclarationSyntax* asVariableAndOrFunctionDeclaration() const { return nullptr; } - virtual ParameterDeclarationSyntax* asParameterDeclaration() { return nullptr; } - virtual const ParameterDeclarationSyntax* asParameterDeclaration() const { return nullptr; } - virtual FieldDeclarationSyntax* asFieldDeclaration() { return nullptr; } - virtual const FieldDeclarationSyntax* asFieldDeclaration() const { return nullptr; } - virtual StaticAssertDeclarationSyntax* asStaticAssertDeclaration() { return nullptr; } - virtual const StaticAssertDeclarationSyntax* asStaticAssertDeclaration() const { return nullptr; } - virtual FunctionDefinitionSyntax* asFunctionDefinition() { return nullptr; } - virtual const FunctionDefinitionSyntax* asFunctionDefinition() const { return nullptr; } - virtual ExtPSY_TemplateDeclarationSyntax* asExtPSY_TemplateDeclaration() { return nullptr; } - virtual const ExtPSY_TemplateDeclarationSyntax* asExtPSY_TemplateDeclaration() const { return nullptr; } - virtual ExtGNU_AsmStatementDeclarationSyntax* asExtGNU_AsmStatementDeclaration() { return nullptr; } - virtual const ExtGNU_AsmStatementDeclarationSyntax* asExtGNU_AsmStatementDeclaration() const { return nullptr; } - virtual ExtKR_ParameterDeclarationSyntax* asExtKR_ParameterDeclaration() { return nullptr; } - virtual const ExtKR_ParameterDeclarationSyntax* asExtKR_ParameterDeclaration() const { return nullptr; } - - /* Specifiers */ - virtual SpecifierSyntax* asSpecifier() { return nullptr; } - virtual const SpecifierSyntax* asSpecifier() const { return nullptr; } - virtual TrivialSpecifierSyntax* asTrivialSpecifier() { return nullptr; } - virtual const TrivialSpecifierSyntax* asTrivialSpecifier() const { return nullptr; } - virtual StorageClassSyntax* asStorageClass() { return nullptr; } - virtual const StorageClassSyntax* asStorageClass() const { return nullptr; } - virtual BuiltinTypeSpecifierSyntax* asBuiltinTypeSpecifier() { return nullptr; } - virtual const BuiltinTypeSpecifierSyntax* asBuiltinTypeSpecifier() const { return nullptr; } - virtual TagTypeSpecifierSyntax* asTagTypeSpecifier() { return nullptr; } - virtual const TagTypeSpecifierSyntax* asTagTypeSpecifier() const { return nullptr; } - virtual TypeDeclarationAsSpecifierSyntax* asTypeDeclarationAsSpecifier() { return nullptr; } - virtual AtomicTypeSpecifierSyntax* asAtomicTypeSpecifier() { return nullptr; } - virtual const AtomicTypeSpecifierSyntax* asAtomicTypeSpecifier() const { return nullptr; } - virtual const TypeDeclarationAsSpecifierSyntax* asTypeDeclarationAsSpecifier() const { return nullptr; } - virtual TypeQualifierSyntax* asTypeQualifier() { return nullptr; } - virtual const TypeQualifierSyntax* asTypeQualifier() const { return nullptr; } - virtual FunctionSpecifierSyntax* asFunctionSpecifier() { return nullptr; } - virtual const FunctionSpecifierSyntax* asFunctionSpecifier() const { return nullptr; } - virtual AlignmentSpecifierSyntax* asAlignmentSpecifier() { return nullptr; } - virtual const AlignmentSpecifierSyntax* asAlignmentSpecifier() const { return nullptr; } - virtual TypedefNameSyntax* asTypedefName() { return nullptr; } - virtual const TypedefNameSyntax* asTypedefName() const { return nullptr; } - virtual ExtGNU_AttributeSpecifierSyntax* asExtGNU_AttributeSpecifier() { return nullptr; } - virtual const ExtGNU_AttributeSpecifierSyntax* asExtGNU_AttributeSpecifier() const { return nullptr; } - virtual ExtGNU_AttributeSyntax* asExtGNU_Attribute() { return nullptr; } - virtual const ExtGNU_AttributeSyntax* asExtGNU_Attribute() const { return nullptr; } - virtual ExtGNU_AsmLabelSyntax* asExtGNU_AsmLabel() { return nullptr; } - virtual const ExtGNU_AsmLabelSyntax* asExtGNU_AsmLabel() const { return nullptr; } - virtual ExtGNU_TypeofSyntax* asExtGNU_Typeof() { return nullptr; } - virtual const ExtGNU_TypeofSyntax* asExtGNU_Typeof() const { return nullptr; } - virtual ExtPSY_QuantifiedTypeSpecifierSyntax* asExtPSY_QuantifiedTypeSpecifier() { return nullptr; } - virtual const ExtPSY_QuantifiedTypeSpecifierSyntax* asExtPSY_QuantifiedTypeSpecifier() const { return nullptr; } - - /* Declarators */ - virtual DeclaratorSyntax* asDeclarator() { return nullptr; } - virtual const DeclaratorSyntax* asDeclarator() const { return nullptr; } - virtual PointerDeclaratorSyntax* asPointerDeclarator() { return nullptr; } - virtual const PointerDeclaratorSyntax* asPointerDeclarator() const { return nullptr; } - virtual IdentifierDeclaratorSyntax* asIdentifierDeclarator() { return nullptr; } - virtual const IdentifierDeclaratorSyntax* asIdentifierDeclarator() const { return nullptr; } - virtual AbstractDeclaratorSyntax* asAbstractDeclarator() { return nullptr; } - virtual const AbstractDeclaratorSyntax* asAbstractDeclarator() const { return nullptr; } - virtual ParenthesizedDeclaratorSyntax* asParenthesizedDeclarator() { return nullptr; } - virtual const ParenthesizedDeclaratorSyntax* asParenthesizedDeclarator() const { return nullptr; } - virtual ArrayOrFunctionDeclaratorSyntax* asArrayOrFunctionDeclarator() { return nullptr; } - virtual const ArrayOrFunctionDeclaratorSyntax* asArrayOrFunctionDeclarator() const { return nullptr; } - virtual DeclaratorSuffixSyntax* asDeclaratorSuffix() { return nullptr; } - virtual const DeclaratorSuffixSyntax* asDeclaratorSuffix() const { return nullptr; } - virtual SubscriptSuffixSyntax* asSubscriptSuffix() { return nullptr; } - virtual const SubscriptSuffixSyntax* asSubscriptSuffix() const { return nullptr; } - virtual ParameterSuffixSyntax* asParameterSuffix() { return nullptr; } - virtual const ParameterSuffixSyntax* asParameterSuffix() const { return nullptr; } - virtual BitfieldDeclaratorSyntax* asBitfieldDeclarator() { return nullptr; } - virtual const BitfieldDeclaratorSyntax* asBitfieldDeclarator() const { return nullptr; } - - /* Initializers */ - virtual InitializerSyntax* asInitializer() { return nullptr; } - virtual const InitializerSyntax* asInitializer() const { return nullptr; } - virtual ExpressionInitializerSyntax* asExpressionInitializer() { return nullptr; } - virtual const ExpressionInitializerSyntax* asExpressionInitializer() const { return nullptr; } - virtual BraceEnclosedInitializerSyntax* asBraceEnclosedInitializer() { return nullptr; } - virtual const BraceEnclosedInitializerSyntax* asBraceEnclosedInitializer() const { return nullptr; } - virtual DesignatedInitializerSyntax* asDesignatedInitializer() { return nullptr; } - virtual const DesignatedInitializerSyntax* asDesignatedInitializer() const { return nullptr; } - virtual DesignatorSyntax* asDesignator() { return nullptr; } - virtual const DesignatorSyntax* asDesignator() const { return nullptr; } - virtual ArrayDesignatorSyntax* asArrayDesignator() { return nullptr; } - virtual const ArrayDesignatorSyntax* asArrayDesignator() const { return nullptr; } - virtual FieldDesignatorSyntax* asFieldDesignator() { return nullptr; } - virtual const FieldDesignatorSyntax* asFieldDesignator() const { return nullptr; } - - virtual OffsetOfDesignatorSyntax* asOffsetOfDesignator() { return nullptr; } - virtual const OffsetOfDesignatorSyntax* asOffsetOfDesignator() const { return nullptr; } - - //-------------// - // Expressions // - //-------------// - virtual ExpressionSyntax* asExpression() { return nullptr; } - virtual const ExpressionSyntax* asExpression() const { return nullptr; } - virtual ConstantExpressionSyntax* asConstantExpression() { return nullptr; } - virtual const ConstantExpressionSyntax* asConstantExpression() const { return nullptr; } - virtual StringLiteralExpressionSyntax* asStringLiteralExpression() { return nullptr; } - virtual const StringLiteralExpressionSyntax* asStringLiteralExpression() const { return nullptr; } - virtual ParenthesizedExpressionSyntax* asParenthesizedExpression() { return nullptr; } - virtual const ParenthesizedExpressionSyntax* asParenthesizedExpression() const { return nullptr; } - virtual GenericSelectionExpressionSyntax* asGenericSelectionExpression() { return nullptr; } - virtual const GenericSelectionExpressionSyntax* asGenericSelectionExpression() const { return nullptr; } - virtual GenericAssociationSyntax* asGenericAssociation() { return nullptr; } - virtual const GenericAssociationSyntax* asGenericAssociation() const { return nullptr; } - virtual ExtGNU_EnclosedCompoundStatementExpressionSyntax* asExtGNU_EnclosedCompoundStatementExpression() { return nullptr; } - virtual const ExtGNU_EnclosedCompoundStatementExpressionSyntax* asExtGNU_EnclosedCompoundStatementExpression() const { return nullptr; } - virtual ExtGNU_ComplexValuedExpressionSyntax* asExtGNU_ComplexValuedExpression() { return nullptr; } - virtual const ExtGNU_ComplexValuedExpressionSyntax* asExtGNU_ComplexValuedExpression() const { return nullptr; } - - /* Names */ - virtual NameSyntax* asName() { return nullptr; } - virtual const NameSyntax* asName() const { return nullptr; } - virtual IdentifierNameSyntax* asIdentifierName() { return nullptr; } - virtual const IdentifierNameSyntax* asIdentifierName() const { return nullptr; } - virtual PredefinedNameSyntax* asPredefinedName() { return nullptr; } - virtual const PredefinedNameSyntax* asPredefinedName() const { return nullptr; } - - /* Operations */ - virtual UnaryExpressionSyntax* asUnaryExpression() { return nullptr; } - virtual const UnaryExpressionSyntax* asUnaryExpression() const { return nullptr; } - virtual PostfixUnaryExpressionSyntax* asPostfixUnaryExpression() { return nullptr; } - virtual const PostfixUnaryExpressionSyntax* asPostfixUnaryExpression() const { return nullptr; } - virtual PrefixUnaryExpressionSyntax* asPrefixUnaryExpression() { return nullptr; } - virtual const PrefixUnaryExpressionSyntax* asPrefixUnaryExpression() const { return nullptr; } - virtual MemberAccessExpressionSyntax* asMemberAccessExpression() { return nullptr; } - virtual const MemberAccessExpressionSyntax* asMemberAccessExpression() const { return nullptr; } - virtual ArraySubscriptExpressionSyntax* asArraySubscriptExpression() { return nullptr; } - virtual const ArraySubscriptExpressionSyntax* asArraySubscriptExpression() const { return nullptr; } - virtual TypeTraitExpressionSyntax* asTypeTraitExpression() { return nullptr; } - virtual const TypeTraitExpressionSyntax* asTypeTraitExpression() const { return nullptr; } - virtual CallExpressionSyntax* asCallExpression() { return nullptr; } - virtual const CallExpressionSyntax* asCallExpression() const { return nullptr; } - virtual CompoundLiteralExpressionSyntax* asCompoundLiteralExpression() { return nullptr; } - virtual const CompoundLiteralExpressionSyntax* asCompoundLiteralExpression() const { return nullptr; } - virtual CastExpressionSyntax* asCastExpression() { return nullptr; } - virtual const CastExpressionSyntax* asCastExpression() const { return nullptr; } - virtual VAArgumentExpressionSyntax* asVAArgumentExpression() { return nullptr; } - virtual const VAArgumentExpressionSyntax* asVAArgumentExpression() const { return nullptr; } - virtual OffsetOfExpressionSyntax* asOffsetOfExpression() { return nullptr; } - virtual const OffsetOfExpressionSyntax* asOffsetOfExpression() const { return nullptr; } - virtual BinaryExpressionSyntax* asBinaryExpression() { return nullptr; } - virtual const BinaryExpressionSyntax* asBinaryExpression() const { return nullptr; } - virtual ConditionalExpressionSyntax* asConditionalExpression() { return nullptr; } - virtual const ConditionalExpressionSyntax* asConditionalExpression() const { return nullptr; } - virtual AssignmentExpressionSyntax* asAssignmentExpression() { return nullptr; } - virtual const AssignmentExpressionSyntax* asAssignmentExpression() const { return nullptr; } - virtual SequencingExpressionSyntax* asSequencingExpression() { return nullptr; } - virtual const SequencingExpressionSyntax* asSequencingExpression() const { return nullptr; } - virtual ExtGNU_ChooseExpressionSyntax* asExtGNU_ChooseExpression() { return nullptr; } - virtual const ExtGNU_ChooseExpressionSyntax* asExtGNU_ChooseExpression() const { return nullptr; } - - //------------// - // Statements // - //------------// - virtual StatementSyntax* asStatement() { return nullptr; } - virtual const StatementSyntax* asStatement() const { return nullptr; } - virtual CompoundStatementSyntax* asCompoundStatement() { return nullptr; } - virtual const CompoundStatementSyntax* asCompoundStatement() const { return nullptr; } - virtual DeclarationStatementSyntax* asDeclarationStatement() { return nullptr; } - virtual const DeclarationStatementSyntax* asDeclarationStatement() const { return nullptr; } - virtual ExpressionStatementSyntax* asExpressionStatement() { return nullptr; } - virtual const ExpressionStatementSyntax* asExpressionStatement() const { return nullptr; } - virtual LabeledStatementSyntax* asLabeledStatement() { return nullptr; } - virtual const LabeledStatementSyntax* asLabeledStatement() const { return nullptr; } - virtual IfStatementSyntax* asIfStatement() { return nullptr; } - virtual const IfStatementSyntax* asIfStatement() const { return nullptr; } - virtual SwitchStatementSyntax* asSwitchStatement() { return nullptr; } - virtual const SwitchStatementSyntax* asSwitchStatement() const { return nullptr; } - virtual WhileStatementSyntax* asWhileStatement() { return nullptr; } - virtual const WhileStatementSyntax* asWhileStatement() const { return nullptr; } - virtual DoStatementSyntax* asDoStatement() { return nullptr; } - virtual const DoStatementSyntax* asDoStatement() const { return nullptr; } - virtual ForStatementSyntax* asForStatement() { return nullptr; } - virtual const ForStatementSyntax* asForStatement() const { return nullptr; } - virtual GotoStatementSyntax* asGotoStatement() { return nullptr; } - virtual const GotoStatementSyntax* asGotoStatement() const { return nullptr; } - virtual ContinueStatementSyntax* asContinueStatement() { return nullptr; } - virtual const ContinueStatementSyntax* asContinueStatement() const { return nullptr; } - virtual BreakStatementSyntax* asBreakStatement() { return nullptr; } - virtual const BreakStatementSyntax* asBreakStatement() const { return nullptr; } - virtual ReturnStatementSyntax* asReturnStatement() { return nullptr; } - virtual const ReturnStatementSyntax* asReturnStatement() const { return nullptr; } - virtual ExtGNU_AsmStatementSyntax* asExtGNU_AsmStatement() { return nullptr; } - virtual const ExtGNU_AsmStatementSyntax* asExtGNU_AsmStatement() const { return nullptr; } - virtual ExtGNU_AsmQualifierSyntax* asExtGNU_AsmQualifier() { return nullptr; } - virtual const ExtGNU_AsmQualifierSyntax* asExtGNU_AsmQualifier() const { return nullptr; } - virtual ExtGNU_AsmOperandSyntax* asExtGNU_AsmOperand() { return nullptr; } - virtual const ExtGNU_AsmOperandSyntax* asExtGNU_AsmOperand() const { return nullptr; } - - //--------// - // Common // - //--------// - virtual TypeNameSyntax* asTypeName() { return nullptr; } - virtual const TypeNameSyntax* asTypeName() const { return nullptr; } - virtual TypeReferenceSyntax* asTypeReference() { return nullptr; } - virtual const TypeReferenceSyntax* asTypeReference() const { return nullptr; } - virtual ExpressionAsTypeReferenceSyntax* asExpressionAsTypeReference() { return nullptr; } - virtual const ExpressionAsTypeReferenceSyntax* asExpressionAsTypeReference() const { return nullptr; } - virtual TypeNameAsTypeReferenceSyntax* asTypeNameAsTypeReference() { return nullptr; } - virtual const TypeNameAsTypeReferenceSyntax* asTypeNameAsTypeReference() const { return nullptr; } - - //-------------// - // Ambiguities // - //-------------// - virtual AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax* asAmbiguousTypeNameOrExpressionAsTypeReference() { return nullptr; } - virtual const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax* asAmbiguousTypeNameOrExpressionAsTypeReference() const { return nullptr; } - virtual AmbiguousCastOrBinaryExpressionSyntax* asAmbiguousCastOrBinaryExpression() { return nullptr; } - virtual const AmbiguousCastOrBinaryExpressionSyntax* asAmbiguousCastOrBinaryExpression() const { return nullptr; } - virtual AmbiguousExpressionOrDeclarationStatementSyntax* asAmbiguousExpressionOrDeclarationStatement() { return nullptr; } - virtual const AmbiguousExpressionOrDeclarationStatementSyntax* asAmbiguousExpressionOrDeclarationStatement() const { return nullptr; } + virtual ~SyntaxNode(); + + /** + * The SyntaxTree to which \c this SyntaxNode belongs to. + */ + const SyntaxTree *syntaxTree() const; + + /** + * The SyntaxKind of \c this SyntaxNode. + */ + SyntaxKind kind() const; + + /** + * Whether \c this SyntaxNode is of SyntaxKind \p k. + */ + bool isKind(SyntaxKind k) { return kind() == k; } + + /** + * The first token of \c this SyntaxNode. + */ + SyntaxToken firstToken() const; + + /** + * The last token of \c this SyntaxNode. + */ + SyntaxToken lastToken() const; + + //!@{ + /** + * Accept \c this SyntaxNode for traversal by the given \p visitor. + */ + void acceptVisitor(SyntaxVisitor *visitor) const; + + /** + * Accept the SyntaxNode \p node for traversal by the given \p visitor. + */ + static void acceptVisitor(const SyntaxNode *node, SyntaxVisitor *visitor) { + if (node) + node->acceptVisitor(visitor); + } + + /** + * Accept the syntax list \p it for traversal by the given \p visitor. + */ + template + static void acceptVisitor(List *it, + SyntaxVisitor *visitor) { + for (; it; it = it->next) + acceptVisitor(it->value, visitor); + } + //!@} + + //--------------// + // Declarations // + //--------------// + virtual TranslationUnitSyntax *asTranslationUnit() { return nullptr; } + virtual const TranslationUnitSyntax *asTranslationUnit() const { + return nullptr; + } + virtual DeclarationSyntax *asDeclaration() { return nullptr; } + virtual const DeclarationSyntax *asDeclaration() const { return nullptr; } + virtual IncompleteDeclarationSyntax *asIncompleteDeclaration() { + return nullptr; + } + virtual const IncompleteDeclarationSyntax *asIncompleteDeclaration() const { + return nullptr; + } + virtual NamedDeclarationSyntax *asNamedDeclaration() { return nullptr; } + virtual const NamedDeclarationSyntax *asNamedDeclaration() const { + return nullptr; + } + virtual TypeDeclarationSyntax *asTypeDeclaration() { return nullptr; } + virtual const TypeDeclarationSyntax *asTypeDeclaration() const { + return nullptr; + } + virtual TagDeclarationSyntax *asTagDeclaration() { return nullptr; } + virtual const TagDeclarationSyntax *asTagDeclaration() const { + return nullptr; + } + virtual StructOrUnionDeclarationSyntax *asStructOrUnionDeclaration() { + return nullptr; + } + virtual const StructOrUnionDeclarationSyntax * + asStructOrUnionDeclaration() const { + return nullptr; + } + virtual EnumDeclarationSyntax *asEnumDeclaration() { return nullptr; } + virtual const EnumDeclarationSyntax *asEnumDeclaration() const { + return nullptr; + } + virtual EnumeratorDeclarationSyntax *asEnumeratorDeclaration() { + return nullptr; + } + virtual const EnumeratorDeclarationSyntax *asEnumeratorDeclaration() const { + return nullptr; + } + virtual ValueDeclarationSyntax *asValueDeclaration() { return nullptr; } + virtual const ValueDeclarationSyntax *asValueDeclaration() const { + return nullptr; + } + virtual DeclaratorDeclarationSyntax *asDeclaratorDeclaration() { + return nullptr; + } + virtual const DeclaratorDeclarationSyntax *asDeclaratorDeclaration() const { + return nullptr; + } + virtual VariableAndOrFunctionDeclarationSyntax * + asVariableAndOrFunctionDeclaration() { + return nullptr; + } + virtual const VariableAndOrFunctionDeclarationSyntax * + asVariableAndOrFunctionDeclaration() const { + return nullptr; + } + virtual ParameterDeclarationSyntax *asParameterDeclaration() { + return nullptr; + } + virtual const ParameterDeclarationSyntax *asParameterDeclaration() const { + return nullptr; + } + virtual FieldDeclarationSyntax *asFieldDeclaration() { return nullptr; } + virtual const FieldDeclarationSyntax *asFieldDeclaration() const { + return nullptr; + } + virtual StaticAssertDeclarationSyntax *asStaticAssertDeclaration() { + return nullptr; + } + virtual const StaticAssertDeclarationSyntax * + asStaticAssertDeclaration() const { + return nullptr; + } + virtual FunctionDefinitionSyntax *asFunctionDefinition() { return nullptr; } + virtual const FunctionDefinitionSyntax *asFunctionDefinition() const { + return nullptr; + } + virtual ExtPSY_TemplateDeclarationSyntax *asExtPSY_TemplateDeclaration() { + return nullptr; + } + virtual const ExtPSY_TemplateDeclarationSyntax * + asExtPSY_TemplateDeclaration() const { + return nullptr; + } + virtual ExtGNU_AsmStatementDeclarationSyntax * + asExtGNU_AsmStatementDeclaration() { + return nullptr; + } + virtual const ExtGNU_AsmStatementDeclarationSyntax * + asExtGNU_AsmStatementDeclaration() const { + return nullptr; + } + virtual ExtKR_ParameterDeclarationSyntax *asExtKR_ParameterDeclaration() { + return nullptr; + } + virtual const ExtKR_ParameterDeclarationSyntax * + asExtKR_ParameterDeclaration() const { + return nullptr; + } + + /* Specifiers */ + virtual SpecifierSyntax *asSpecifier() { return nullptr; } + virtual const SpecifierSyntax *asSpecifier() const { return nullptr; } + virtual TrivialSpecifierSyntax *asTrivialSpecifier() { return nullptr; } + virtual const TrivialSpecifierSyntax *asTrivialSpecifier() const { + return nullptr; + } + virtual StorageClassSyntax *asStorageClass() { return nullptr; } + virtual const StorageClassSyntax *asStorageClass() const { return nullptr; } + virtual BuiltinTypeSpecifierSyntax *asBuiltinTypeSpecifier() { + return nullptr; + } + virtual const BuiltinTypeSpecifierSyntax *asBuiltinTypeSpecifier() const { + return nullptr; + } + virtual TagTypeSpecifierSyntax *asTagTypeSpecifier() { return nullptr; } + virtual const TagTypeSpecifierSyntax *asTagTypeSpecifier() const { + return nullptr; + } + virtual TypeDeclarationAsSpecifierSyntax *asTypeDeclarationAsSpecifier() { + return nullptr; + } + virtual AtomicTypeSpecifierSyntax *asAtomicTypeSpecifier() { return nullptr; } + virtual const AtomicTypeSpecifierSyntax *asAtomicTypeSpecifier() const { + return nullptr; + } + virtual const TypeDeclarationAsSpecifierSyntax * + asTypeDeclarationAsSpecifier() const { + return nullptr; + } + virtual TypeQualifierSyntax *asTypeQualifier() { return nullptr; } + virtual const TypeQualifierSyntax *asTypeQualifier() const { return nullptr; } + virtual FunctionSpecifierSyntax *asFunctionSpecifier() { return nullptr; } + virtual const FunctionSpecifierSyntax *asFunctionSpecifier() const { + return nullptr; + } + virtual AlignmentSpecifierSyntax *asAlignmentSpecifier() { return nullptr; } + virtual const AlignmentSpecifierSyntax *asAlignmentSpecifier() const { + return nullptr; + } + virtual TypedefNameSyntax *asTypedefName() { return nullptr; } + virtual const TypedefNameSyntax *asTypedefName() const { return nullptr; } + virtual ExtGNU_AttributeSpecifierSyntax *asExtGNU_AttributeSpecifier() { + return nullptr; + } + virtual const ExtGNU_AttributeSpecifierSyntax * + asExtGNU_AttributeSpecifier() const { + return nullptr; + } + virtual ExtGNU_AttributeSyntax *asExtGNU_Attribute() { return nullptr; } + virtual const ExtGNU_AttributeSyntax *asExtGNU_Attribute() const { + return nullptr; + } + virtual ExtGNU_AsmLabelSyntax *asExtGNU_AsmLabel() { return nullptr; } + virtual const ExtGNU_AsmLabelSyntax *asExtGNU_AsmLabel() const { + return nullptr; + } + virtual ExtGNU_TypeofSyntax *asExtGNU_Typeof() { return nullptr; } + virtual const ExtGNU_TypeofSyntax *asExtGNU_Typeof() const { return nullptr; } + virtual ExtPSY_QuantifiedTypeSpecifierSyntax * + asExtPSY_QuantifiedTypeSpecifier() { + return nullptr; + } + virtual const ExtPSY_QuantifiedTypeSpecifierSyntax * + asExtPSY_QuantifiedTypeSpecifier() const { + return nullptr; + } + + /* Declarators */ + virtual DeclaratorSyntax *asDeclarator() { return nullptr; } + virtual const DeclaratorSyntax *asDeclarator() const { return nullptr; } + virtual PointerDeclaratorSyntax *asPointerDeclarator() { return nullptr; } + virtual const PointerDeclaratorSyntax *asPointerDeclarator() const { + return nullptr; + } + virtual IdentifierDeclaratorSyntax *asIdentifierDeclarator() { + return nullptr; + } + virtual const IdentifierDeclaratorSyntax *asIdentifierDeclarator() const { + return nullptr; + } + virtual AbstractDeclaratorSyntax *asAbstractDeclarator() { return nullptr; } + virtual const AbstractDeclaratorSyntax *asAbstractDeclarator() const { + return nullptr; + } + virtual ParenthesizedDeclaratorSyntax *asParenthesizedDeclarator() { + return nullptr; + } + virtual const ParenthesizedDeclaratorSyntax * + asParenthesizedDeclarator() const { + return nullptr; + } + virtual ArrayOrFunctionDeclaratorSyntax *asArrayOrFunctionDeclarator() { + return nullptr; + } + virtual const ArrayOrFunctionDeclaratorSyntax * + asArrayOrFunctionDeclarator() const { + return nullptr; + } + virtual DeclaratorSuffixSyntax *asDeclaratorSuffix() { return nullptr; } + virtual const DeclaratorSuffixSyntax *asDeclaratorSuffix() const { + return nullptr; + } + virtual SubscriptSuffixSyntax *asSubscriptSuffix() { return nullptr; } + virtual const SubscriptSuffixSyntax *asSubscriptSuffix() const { + return nullptr; + } + virtual ParameterSuffixSyntax *asParameterSuffix() { return nullptr; } + virtual const ParameterSuffixSyntax *asParameterSuffix() const { + return nullptr; + } + virtual BitfieldDeclaratorSyntax *asBitfieldDeclarator() { return nullptr; } + virtual const BitfieldDeclaratorSyntax *asBitfieldDeclarator() const { + return nullptr; + } + + /* Initializers */ + virtual InitializerSyntax *asInitializer() { return nullptr; } + virtual const InitializerSyntax *asInitializer() const { return nullptr; } + virtual ExpressionInitializerSyntax *asExpressionInitializer() { + return nullptr; + } + virtual const ExpressionInitializerSyntax *asExpressionInitializer() const { + return nullptr; + } + virtual BraceEnclosedInitializerSyntax *asBraceEnclosedInitializer() { + return nullptr; + } + virtual const BraceEnclosedInitializerSyntax * + asBraceEnclosedInitializer() const { + return nullptr; + } + virtual DesignatedInitializerSyntax *asDesignatedInitializer() { + return nullptr; + } + virtual const DesignatedInitializerSyntax *asDesignatedInitializer() const { + return nullptr; + } + virtual DesignatorSyntax *asDesignator() { return nullptr; } + virtual const DesignatorSyntax *asDesignator() const { return nullptr; } + virtual ArrayDesignatorSyntax *asArrayDesignator() { return nullptr; } + virtual const ArrayDesignatorSyntax *asArrayDesignator() const { + return nullptr; + } + virtual FieldDesignatorSyntax *asFieldDesignator() { return nullptr; } + virtual const FieldDesignatorSyntax *asFieldDesignator() const { + return nullptr; + } + + virtual OffsetOfDesignatorSyntax *asOffsetOfDesignator() { return nullptr; } + virtual const OffsetOfDesignatorSyntax *asOffsetOfDesignator() const { + return nullptr; + } + + //-------------// + // Expressions // + //-------------// + virtual ExpressionSyntax *asExpression() { return nullptr; } + virtual const ExpressionSyntax *asExpression() const { return nullptr; } + virtual ConstantExpressionSyntax *asConstantExpression() { return nullptr; } + virtual const ConstantExpressionSyntax *asConstantExpression() const { + return nullptr; + } + virtual StringLiteralExpressionSyntax *asStringLiteralExpression() { + return nullptr; + } + virtual const StringLiteralExpressionSyntax * + asStringLiteralExpression() const { + return nullptr; + } + virtual ParenthesizedExpressionSyntax *asParenthesizedExpression() { + return nullptr; + } + virtual const ParenthesizedExpressionSyntax * + asParenthesizedExpression() const { + return nullptr; + } + virtual GenericSelectionExpressionSyntax *asGenericSelectionExpression() { + return nullptr; + } + virtual const GenericSelectionExpressionSyntax * + asGenericSelectionExpression() const { + return nullptr; + } + virtual GenericAssociationSyntax *asGenericAssociation() { return nullptr; } + virtual const GenericAssociationSyntax *asGenericAssociation() const { + return nullptr; + } + virtual ExtGNU_EnclosedCompoundStatementExpressionSyntax * + asExtGNU_EnclosedCompoundStatementExpression() { + return nullptr; + } + virtual const ExtGNU_EnclosedCompoundStatementExpressionSyntax * + asExtGNU_EnclosedCompoundStatementExpression() const { + return nullptr; + } + virtual ExtGNU_ComplexValuedExpressionSyntax * + asExtGNU_ComplexValuedExpression() { + return nullptr; + } + virtual const ExtGNU_ComplexValuedExpressionSyntax * + asExtGNU_ComplexValuedExpression() const { + return nullptr; + } + + /* Names */ + virtual NameSyntax *asName() { return nullptr; } + virtual const NameSyntax *asName() const { return nullptr; } + virtual IdentifierNameSyntax *asIdentifierName() { return nullptr; } + virtual const IdentifierNameSyntax *asIdentifierName() const { + return nullptr; + } + virtual PredefinedNameSyntax *asPredefinedName() { return nullptr; } + virtual const PredefinedNameSyntax *asPredefinedName() const { + return nullptr; + } + + /* Operations */ + virtual UnaryExpressionSyntax *asUnaryExpression() { return nullptr; } + virtual const UnaryExpressionSyntax *asUnaryExpression() const { + return nullptr; + } + virtual PostfixUnaryExpressionSyntax *asPostfixUnaryExpression() { + return nullptr; + } + virtual const PostfixUnaryExpressionSyntax *asPostfixUnaryExpression() const { + return nullptr; + } + virtual PrefixUnaryExpressionSyntax *asPrefixUnaryExpression() { + return nullptr; + } + virtual const PrefixUnaryExpressionSyntax *asPrefixUnaryExpression() const { + return nullptr; + } + virtual MemberAccessExpressionSyntax *asMemberAccessExpression() { + return nullptr; + } + virtual const MemberAccessExpressionSyntax *asMemberAccessExpression() const { + return nullptr; + } + virtual ArraySubscriptExpressionSyntax *asArraySubscriptExpression() { + return nullptr; + } + virtual const ArraySubscriptExpressionSyntax * + asArraySubscriptExpression() const { + return nullptr; + } + virtual TypeTraitExpressionSyntax *asTypeTraitExpression() { return nullptr; } + virtual const TypeTraitExpressionSyntax *asTypeTraitExpression() const { + return nullptr; + } + virtual CallExpressionSyntax *asCallExpression() { return nullptr; } + virtual const CallExpressionSyntax *asCallExpression() const { + return nullptr; + } + virtual CompoundLiteralExpressionSyntax *asCompoundLiteralExpression() { + return nullptr; + } + virtual const CompoundLiteralExpressionSyntax * + asCompoundLiteralExpression() const { + return nullptr; + } + virtual CastExpressionSyntax *asCastExpression() { return nullptr; } + virtual const CastExpressionSyntax *asCastExpression() const { + return nullptr; + } + virtual VAArgumentExpressionSyntax *asVAArgumentExpression() { + return nullptr; + } + virtual const VAArgumentExpressionSyntax *asVAArgumentExpression() const { + return nullptr; + } + virtual OffsetOfExpressionSyntax *asOffsetOfExpression() { return nullptr; } + virtual const OffsetOfExpressionSyntax *asOffsetOfExpression() const { + return nullptr; + } + virtual BinaryExpressionSyntax *asBinaryExpression() { return nullptr; } + virtual const BinaryExpressionSyntax *asBinaryExpression() const { + return nullptr; + } + virtual ConditionalExpressionSyntax *asConditionalExpression() { + return nullptr; + } + virtual const ConditionalExpressionSyntax *asConditionalExpression() const { + return nullptr; + } + virtual AssignmentExpressionSyntax *asAssignmentExpression() { + return nullptr; + } + virtual const AssignmentExpressionSyntax *asAssignmentExpression() const { + return nullptr; + } + virtual SequencingExpressionSyntax *asSequencingExpression() { + return nullptr; + } + virtual const SequencingExpressionSyntax *asSequencingExpression() const { + return nullptr; + } + virtual ExtGNU_ChooseExpressionSyntax *asExtGNU_ChooseExpression() { + return nullptr; + } + virtual const ExtGNU_ChooseExpressionSyntax * + asExtGNU_ChooseExpression() const { + return nullptr; + } + + //------------// + // Statements // + //------------// + virtual StatementSyntax *asStatement() { return nullptr; } + virtual const StatementSyntax *asStatement() const { return nullptr; } + virtual CompoundStatementSyntax *asCompoundStatement() { return nullptr; } + virtual const CompoundStatementSyntax *asCompoundStatement() const { + return nullptr; + } + virtual DeclarationStatementSyntax *asDeclarationStatement() { + return nullptr; + } + virtual const DeclarationStatementSyntax *asDeclarationStatement() const { + return nullptr; + } + virtual ExpressionStatementSyntax *asExpressionStatement() { return nullptr; } + virtual const ExpressionStatementSyntax *asExpressionStatement() const { + return nullptr; + } + virtual LabeledStatementSyntax *asLabeledStatement() { return nullptr; } + virtual const LabeledStatementSyntax *asLabeledStatement() const { + return nullptr; + } + virtual IfStatementSyntax *asIfStatement() { return nullptr; } + virtual const IfStatementSyntax *asIfStatement() const { return nullptr; } + virtual SwitchStatementSyntax *asSwitchStatement() { return nullptr; } + virtual const SwitchStatementSyntax *asSwitchStatement() const { + return nullptr; + } + virtual WhileStatementSyntax *asWhileStatement() { return nullptr; } + virtual const WhileStatementSyntax *asWhileStatement() const { + return nullptr; + } + virtual DoStatementSyntax *asDoStatement() { return nullptr; } + virtual const DoStatementSyntax *asDoStatement() const { return nullptr; } + virtual ForStatementSyntax *asForStatement() { return nullptr; } + virtual const ForStatementSyntax *asForStatement() const { return nullptr; } + virtual GotoStatementSyntax *asGotoStatement() { return nullptr; } + virtual const GotoStatementSyntax *asGotoStatement() const { return nullptr; } + virtual ContinueStatementSyntax *asContinueStatement() { return nullptr; } + virtual const ContinueStatementSyntax *asContinueStatement() const { + return nullptr; + } + virtual BreakStatementSyntax *asBreakStatement() { return nullptr; } + virtual const BreakStatementSyntax *asBreakStatement() const { + return nullptr; + } + virtual ReturnStatementSyntax *asReturnStatement() { return nullptr; } + virtual const ReturnStatementSyntax *asReturnStatement() const { + return nullptr; + } + virtual ExtGNU_AsmStatementSyntax *asExtGNU_AsmStatement() { return nullptr; } + virtual const ExtGNU_AsmStatementSyntax *asExtGNU_AsmStatement() const { + return nullptr; + } + virtual ExtGNU_AsmQualifierSyntax *asExtGNU_AsmQualifier() { return nullptr; } + virtual const ExtGNU_AsmQualifierSyntax *asExtGNU_AsmQualifier() const { + return nullptr; + } + virtual ExtGNU_AsmOperandSyntax *asExtGNU_AsmOperand() { return nullptr; } + virtual const ExtGNU_AsmOperandSyntax *asExtGNU_AsmOperand() const { + return nullptr; + } + + //--------// + // Common // + //--------// + virtual TypeNameSyntax *asTypeName() { return nullptr; } + virtual const TypeNameSyntax *asTypeName() const { return nullptr; } + virtual TypeReferenceSyntax *asTypeReference() { return nullptr; } + virtual const TypeReferenceSyntax *asTypeReference() const { return nullptr; } + virtual ExpressionAsTypeReferenceSyntax *asExpressionAsTypeReference() { + return nullptr; + } + virtual const ExpressionAsTypeReferenceSyntax * + asExpressionAsTypeReference() const { + return nullptr; + } + virtual TypeNameAsTypeReferenceSyntax *asTypeNameAsTypeReference() { + return nullptr; + } + virtual const TypeNameAsTypeReferenceSyntax * + asTypeNameAsTypeReference() const { + return nullptr; + } + + //-------------// + // Ambiguities // + //-------------// + virtual AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax * + asAmbiguousTypeNameOrExpressionAsTypeReference() { + return nullptr; + } + virtual const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax * + asAmbiguousTypeNameOrExpressionAsTypeReference() const { + return nullptr; + } + virtual AmbiguousCastOrBinaryExpressionSyntax * + asAmbiguousCastOrBinaryExpression() { + return nullptr; + } + virtual const AmbiguousCastOrBinaryExpressionSyntax * + asAmbiguousCastOrBinaryExpression() const { + return nullptr; + } + virtual AmbiguousExpressionOrDeclarationStatementSyntax * + asAmbiguousExpressionOrDeclarationStatement() { + return nullptr; + } + virtual const AmbiguousExpressionOrDeclarationStatementSyntax * + asAmbiguousExpressionOrDeclarationStatement() const { + return nullptr; + } protected: - SyntaxNode(SyntaxTree* tree, SyntaxKind kind = Error); + SyntaxNode(SyntaxTree *tree, SyntaxKind kind = Error); - // Unavailable - SyntaxNode(const SyntaxNode& other) = delete; - SyntaxNode& operator=(const SyntaxNode& other) = delete; + // Unavailable + SyntaxNode(const SyntaxNode &other) = delete; + SyntaxNode &operator=(const SyntaxNode &other) = delete; - SyntaxToken tokenAtIndex(LexedTokens::IndexType tkIdx) const; - SyntaxToken findValidToken(const std::vector& syntaxHolders) const; - void visitChildren(SyntaxVisitor* visitor) const; + SyntaxToken tokenAtIndex(LexedTokens::IndexType tkIdx) const; + SyntaxToken + findValidToken(const std::vector &syntaxHolders) const; + void visitChildren(SyntaxVisitor *visitor) const; - virtual std::vector childNodesAndTokens() const { return {}; } - virtual SyntaxVisitor::Action dispatchVisit(SyntaxVisitor* visitor) const = 0; + virtual std::vector childNodesAndTokens() const { return {}; } + virtual SyntaxVisitor::Action dispatchVisit(SyntaxVisitor *visitor) const = 0; - SyntaxTree* tree_; - SyntaxKind kind_; + SyntaxTree *tree_; + SyntaxKind kind_; }; /** @@ -369,7 +655,7 @@ class PSY_C_API SyntaxNode : public Managed */ std::string PSY_C_API to_string(SyntaxKind kind); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxNodeList.cpp b/C/syntax/SyntaxNodeList.cpp index 1c34325fc..26ea5f8da 100644 --- a/C/syntax/SyntaxNodeList.cpp +++ b/C/syntax/SyntaxNodeList.cpp @@ -28,29 +28,27 @@ using namespace psy; using namespace C; -SyntaxToken SyntaxNodeList::token(LexedTokens::IndexType tkIdx, SyntaxTree* tree) -{ - return tree->tokenAt(tkIdx); +SyntaxToken SyntaxNodeList::token(LexedTokens::IndexType tkIdx, + SyntaxTree *tree) { + return tree->tokenAt(tkIdx); } template -SyntaxToken -SyntaxNodeSeparatedList::delimiterToken() const -{ - return SyntaxNodeList::token(delimTkIdx_, Base::tree_); +SyntaxToken SyntaxNodeSeparatedList::delimiterToken() const { + return SyntaxNodeList::token(delimTkIdx_, Base::tree_); } namespace psy { namespace C { -template class SyntaxNodeSeparatedList; -template class SyntaxNodeSeparatedList; -template class SyntaxNodeSeparatedList; -template class SyntaxNodeSeparatedList; -template class SyntaxNodeSeparatedList; -template class SyntaxNodeSeparatedList; -template class SyntaxNodeSeparatedList; -template class SyntaxNodeSeparatedList; - -} // C -} // psy +template class SyntaxNodeSeparatedList; +template class SyntaxNodeSeparatedList; +template class SyntaxNodeSeparatedList; +template class SyntaxNodeSeparatedList; +template class SyntaxNodeSeparatedList; +template class SyntaxNodeSeparatedList; +template class SyntaxNodeSeparatedList; +template class SyntaxNodeSeparatedList; + +} // namespace C +} // namespace psy diff --git a/C/syntax/SyntaxNodeList.h b/C/syntax/SyntaxNodeList.h index 385b8aff0..003a6b711 100644 --- a/C/syntax/SyntaxNodeList.h +++ b/C/syntax/SyntaxNodeList.h @@ -36,113 +36,97 @@ namespace C { class SyntaxTree; -class PSY_C_API SyntaxNodeList -{ +class PSY_C_API SyntaxNodeList { public: + /** + * The first token of \c this SyntaxNodeList. + */ + virtual SyntaxToken firstToken() const = 0; - /** - * The first token of \c this SyntaxNodeList. - */ - virtual SyntaxToken firstToken() const = 0; + /** + * The last token of \c this SyntaxNode. + */ + virtual SyntaxToken lastToken() const = 0; - /** - * The last token of \c this SyntaxNode. - */ - virtual SyntaxToken lastToken() const = 0; + static SyntaxToken token(LexedTokens::IndexType tkIdx, SyntaxTree *tree); - static SyntaxToken token(LexedTokens::IndexType tkIdx, SyntaxTree* tree); - - virtual void acceptVisitor(SyntaxVisitor* visitor) = 0; + virtual void acceptVisitor(SyntaxVisitor *visitor) = 0; }; - /** * \brief The CoreSyntaxNodeList class \b template. * * The base class of every syntax list. */ -template -class PSY_C_API CoreSyntaxNodeList - : public List - , public SyntaxNodeList -{ +template +class PSY_C_API CoreSyntaxNodeList : public List, + public SyntaxNodeList { public: - CoreSyntaxNodeList(SyntaxTree* tree) - : List() - , tree_(tree) - {} - - CoreSyntaxNodeList(SyntaxTree* tree, const SyntaxNodeT& node) - : List(node) - , tree_(tree) - {} - - CoreSyntaxNodeList(const CoreSyntaxNodeList&) = delete; - CoreSyntaxNodeList& operator=(const CoreSyntaxNodeList&) = delete; - - virtual SyntaxToken firstToken() const override - { - if (this->value) - return this->value->firstToken(); - return SyntaxToken::invalid(); - } - - virtual SyntaxToken lastToken() const override - { - SyntaxNodeT node = this->lastValue(); - if (node) - return node->lastToken(); - return SyntaxToken::invalid(); + CoreSyntaxNodeList(SyntaxTree *tree) + : List(), tree_(tree) {} + + CoreSyntaxNodeList(SyntaxTree *tree, const SyntaxNodeT &node) + : List(node), tree_(tree) {} + + CoreSyntaxNodeList(const CoreSyntaxNodeList &) = delete; + CoreSyntaxNodeList &operator=(const CoreSyntaxNodeList &) = delete; + + virtual SyntaxToken firstToken() const override { + if (this->value) + return this->value->firstToken(); + return SyntaxToken::invalid(); + } + + virtual SyntaxToken lastToken() const override { + SyntaxNodeT node = this->lastValue(); + if (node) + return node->lastToken(); + return SyntaxToken::invalid(); + } + + virtual void acceptVisitor(SyntaxVisitor *visitor) override { + for (auto it = this; it; it = it->next) { + SyntaxNodeT node = static_cast(it->value); + if (node) + node->acceptVisitor(visitor); } + } - virtual void acceptVisitor(SyntaxVisitor* visitor) override - { - for (auto it = this; it; it = it->next) { - SyntaxNodeT node = static_cast(it->value); - if (node) - node->acceptVisitor(visitor); - } - } - - SyntaxTree* tree_; + SyntaxTree *tree_; }; - /** * \brief The SyntaxNodePlainList class (template). */ template class PSY_C_API SyntaxNodePlainList final - : public CoreSyntaxNodeList> -{ + : public CoreSyntaxNodeList> { public: - using CoreSyntaxNodeList>::CoreSyntaxNodeList; - using NodeType = SyntaxNodeT; + using CoreSyntaxNodeList< + SyntaxNodeT, SyntaxNodePlainList>::CoreSyntaxNodeList; + using NodeType = SyntaxNodeT; }; - /** * \brief The SyntaxNodeSeparatedList class (template). */ template class PSY_C_API SyntaxNodeSeparatedList final - : public CoreSyntaxNodeList> -{ + : public CoreSyntaxNodeList> { public: - SyntaxToken delimiterToken() const; + SyntaxToken delimiterToken() const; - using Base = CoreSyntaxNodeList>; - using NodeType = SyntaxNodeT; - using CoreSyntaxNodeList>::CoreSyntaxNodeList; + using Base = + CoreSyntaxNodeList>; + using NodeType = SyntaxNodeT; + using CoreSyntaxNodeList< + SyntaxNodeT, SyntaxNodeSeparatedList>::CoreSyntaxNodeList; - unsigned delimTkIdx_ = 0; + unsigned delimTkIdx_ = 0; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxNodes.h b/C/syntax/SyntaxNodes.h index b031fb943..b9f2c4f5d 100644 --- a/C/syntax/SyntaxNodes.h +++ b/C/syntax/SyntaxNodes.h @@ -27,13 +27,14 @@ #include "SyntaxToken.h" #include "SyntaxTree.h" -#define AST__COMMON__(NODE, BASE_NODE) \ - friend class Parser; \ - friend class Disambiguator; \ - friend class Binder; \ - public: \ - virtual NODE##Syntax* as##NODE() override { return this; } \ - virtual const NODE##Syntax* as##NODE() const override { return this; } +#define AST__COMMON__(NODE, BASE_NODE) \ + friend class Parser; \ + friend class Disambiguator; \ + friend class Binder; \ + \ +public: \ + virtual NODE##Syntax *as##NODE() override { return this; } \ + virtual const NODE##Syntax *as##NODE() const override { return this; } /* * There are 2 coarse variations of AST nodes: @@ -45,13 +46,13 @@ * Macros prefixed with `AST_G_NODE' apply on 1, while macros prefixed * with `AST_NODE' apply on 2. */ -#define AST_G_NODE__COMMON__(NODE) \ - AST__COMMON__(NODE,) \ - using BaseSyntax = SyntaxNode; +#define AST_G_NODE__COMMON__(NODE) \ + AST__COMMON__(NODE, ) \ + using BaseSyntax = SyntaxNode; -#define AST_NODE__COMMON__(NODE, BASE_NODE) \ - AST__COMMON__(NODE, BASE_NODE) \ - using BaseSyntax = BASE_NODE##Syntax; +#define AST_NODE__COMMON__(NODE, BASE_NODE) \ + AST__COMMON__(NODE, BASE_NODE) \ + using BaseSyntax = BASE_NODE##Syntax; /* * The class of an AST node further varies in respect to whether: @@ -63,112 +64,110 @@ * In the last case, the construct for the AST node in question requires * an specific `SyntaxKind' argument. */ -#define AST_G_NODE(NODE) \ - AST_G_NODE__COMMON__(NODE) \ - using SyntaxNode::SyntaxNode; -#define AST_G_NODE_1K(NODE) \ - AST_G_NODE__COMMON__(NODE) \ - NODE##Syntax(SyntaxTree* tree) : SyntaxNode(tree, NODE) {} \ - DISPATCH_VISIT(NODE) -#define AST_G_NODE_NK(NODE) \ - AST_G_NODE__COMMON__(NODE) \ - NODE##Syntax(SyntaxTree* tree, SyntaxKind kind) : SyntaxNode(tree, kind) {} \ - DISPATCH_VISIT(NODE) - -#define AST_NODE(NODE, BASE_NODE) \ - AST_NODE__COMMON__(NODE, BASE_NODE) \ - using BASE_NODE##Syntax::BASE_NODE##Syntax; -#define AST_NODE_1K(NODE, BASE_NODE) \ - AST_NODE__COMMON__(NODE, BASE_NODE) \ - NODE##Syntax(SyntaxTree* tree) : BASE_NODE##Syntax(tree, NODE) {} \ - DISPATCH_VISIT(NODE) -#define AST_NODE_NK(NODE, BASE_NODE) \ - AST_NODE__COMMON__(NODE, BASE_NODE) \ - NODE##Syntax(SyntaxTree* tree, SyntaxKind kind) : BASE_NODE##Syntax(tree, kind) {} \ - DISPATCH_VISIT(NODE) +#define AST_G_NODE(NODE) \ + AST_G_NODE__COMMON__(NODE) \ + using SyntaxNode::SyntaxNode; +#define AST_G_NODE_1K(NODE) \ + AST_G_NODE__COMMON__(NODE) \ + NODE##Syntax(SyntaxTree *tree) : SyntaxNode(tree, NODE) {} \ + DISPATCH_VISIT(NODE) +#define AST_G_NODE_NK(NODE) \ + AST_G_NODE__COMMON__(NODE) \ + NODE##Syntax(SyntaxTree *tree, SyntaxKind kind) : SyntaxNode(tree, kind) {} \ + DISPATCH_VISIT(NODE) + +#define AST_NODE(NODE, BASE_NODE) \ + AST_NODE__COMMON__(NODE, BASE_NODE) \ + using BASE_NODE##Syntax::BASE_NODE##Syntax; +#define AST_NODE_1K(NODE, BASE_NODE) \ + AST_NODE__COMMON__(NODE, BASE_NODE) \ + NODE##Syntax(SyntaxTree *tree) : BASE_NODE##Syntax(tree, NODE) {} \ + DISPATCH_VISIT(NODE) +#define AST_NODE_NK(NODE, BASE_NODE) \ + AST_NODE__COMMON__(NODE, BASE_NODE) \ + NODE##Syntax(SyntaxTree *tree, SyntaxKind kind) \ + : BASE_NODE##Syntax(tree, kind) {} \ + DISPATCH_VISIT(NODE) /* * The children, either nodes or tokens, of an AST node. */ -#define AST_CHILD_LST1(NAME1) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_1(NAME1)) -#define AST_CHILD_LST2(NAME1, NAME2) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_2(NAME1, NAME2)) -#define AST_CHILD_LST3(NAME1, NAME2, NAME3) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_3(NAME1, NAME2, NAME3)) -#define AST_CHILD_LST4(NAME1, NAME2, NAME3, NAME4) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_4(NAME1, NAME2, NAME3, NAME4)) -#define AST_CHILD_LST5(NAME1, NAME2, NAME3, NAME4, NAME5) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_5(NAME1, NAME2, NAME3, NAME4, NAME5)) -#define AST_CHILD_LST6(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_6(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6)) -#define AST_CHILD_LST7(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_7(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7)) +#define AST_CHILD_LST1(NAME1) CHILD_NODES_AND_TOKENS(CHILD_NAME_1(NAME1)) +#define AST_CHILD_LST2(NAME1, NAME2) \ + CHILD_NODES_AND_TOKENS(CHILD_NAME_2(NAME1, NAME2)) +#define AST_CHILD_LST3(NAME1, NAME2, NAME3) \ + CHILD_NODES_AND_TOKENS(CHILD_NAME_3(NAME1, NAME2, NAME3)) +#define AST_CHILD_LST4(NAME1, NAME2, NAME3, NAME4) \ + CHILD_NODES_AND_TOKENS(CHILD_NAME_4(NAME1, NAME2, NAME3, NAME4)) +#define AST_CHILD_LST5(NAME1, NAME2, NAME3, NAME4, NAME5) \ + CHILD_NODES_AND_TOKENS(CHILD_NAME_5(NAME1, NAME2, NAME3, NAME4, NAME5)) +#define AST_CHILD_LST6(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6) \ + CHILD_NODES_AND_TOKENS(CHILD_NAME_6(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6)) +#define AST_CHILD_LST7(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7) \ + CHILD_NODES_AND_TOKENS( \ + CHILD_NAME_7(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7)) #define AST_CHILD_LST8(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_8(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8)) -#define AST_CHILD_LST9(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8, NAME9) \ - CHILD_NODES_AND_TOKENS(CHILD_NAME_9(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8, NAME9)) - -#define CHILD_NAME_1(NAME1) \ - SyntaxHolder(NAME1) -#define CHILD_NAME_2(NAME1, NAME2) \ - CHILD_NAME_1(NAME1), \ - SyntaxHolder(NAME2) -#define CHILD_NAME_3(NAME1, NAME2, NAME3) \ - CHILD_NAME_2(NAME1, NAME2), \ - SyntaxHolder(NAME3) -#define CHILD_NAME_4(NAME1, NAME2, NAME3, NAME4) \ - CHILD_NAME_3(NAME1, NAME2, NAME3), \ - SyntaxHolder(NAME4) -#define CHILD_NAME_5(NAME1, NAME2, NAME3, NAME4, NAME5) \ - CHILD_NAME_4(NAME1, NAME2, NAME3, NAME4), \ - SyntaxHolder(NAME5) -#define CHILD_NAME_6(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6) \ - CHILD_NAME_5(NAME1, NAME2, NAME3, NAME4, NAME5), \ - SyntaxHolder(NAME6) -#define CHILD_NAME_7(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7) \ - CHILD_NAME_6(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6), \ - SyntaxHolder(NAME7) -#define CHILD_NAME_8(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8) \ - CHILD_NAME_7(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7), \ - SyntaxHolder(NAME8) -#define CHILD_NAME_9(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8, NAME9) \ - CHILD_NAME_8(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8), \ - SyntaxHolder(NAME9) + CHILD_NODES_AND_TOKENS( \ + CHILD_NAME_8(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8)) +#define AST_CHILD_LST9(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8, \ + NAME9) \ + CHILD_NODES_AND_TOKENS(CHILD_NAME_9(NAME1, NAME2, NAME3, NAME4, NAME5, \ + NAME6, NAME7, NAME8, NAME9)) + +#define CHILD_NAME_1(NAME1) SyntaxHolder(NAME1) +#define CHILD_NAME_2(NAME1, NAME2) CHILD_NAME_1(NAME1), SyntaxHolder(NAME2) +#define CHILD_NAME_3(NAME1, NAME2, NAME3) \ + CHILD_NAME_2(NAME1, NAME2), SyntaxHolder(NAME3) +#define CHILD_NAME_4(NAME1, NAME2, NAME3, NAME4) \ + CHILD_NAME_3(NAME1, NAME2, NAME3), SyntaxHolder(NAME4) +#define CHILD_NAME_5(NAME1, NAME2, NAME3, NAME4, NAME5) \ + CHILD_NAME_4(NAME1, NAME2, NAME3, NAME4), SyntaxHolder(NAME5) +#define CHILD_NAME_6(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6) \ + CHILD_NAME_5(NAME1, NAME2, NAME3, NAME4, NAME5), SyntaxHolder(NAME6) +#define CHILD_NAME_7(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7) \ + CHILD_NAME_6(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6), SyntaxHolder(NAME7) +#define CHILD_NAME_8(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8) \ + CHILD_NAME_7(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7), \ + SyntaxHolder(NAME8) +#define CHILD_NAME_9(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8, \ + NAME9) \ + CHILD_NAME_8(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7, NAME8), \ + SyntaxHolder(NAME9) /* * The default implementation of the visitor dispatching function for * vising the `this' node. */ -#define DISPATCH_VISIT(NODE) \ - protected: \ - virtual SyntaxVisitor::Action dispatchVisit(SyntaxVisitor* visitor) const override \ - { return visitor->visit##NODE(this); } +#define DISPATCH_VISIT(NODE) \ +protected: \ + virtual SyntaxVisitor::Action dispatchVisit(SyntaxVisitor *visitor) \ + const override { \ + return visitor->visit##NODE(this); \ + } /* * The default implementation of the function that gather the child * nodes and tokens of the `this' node. */ -#define CHILD_NODES_AND_TOKENS(CHILDREN_SYNTAX) \ - public: \ - virtual std::vector childNodesAndTokens() const override \ - { auto self = { CHILDREN_SYNTAX }; \ - return merge(BaseSyntax::childNodesAndTokens(), self); } +#define CHILD_NODES_AND_TOKENS(CHILDREN_SYNTAX) \ +public: \ + virtual std::vector childNodesAndTokens() const override { \ + auto self = {CHILDREN_SYNTAX}; \ + return merge(BaseSyntax::childNodesAndTokens(), self); \ + } using namespace psy; using namespace C; -inline std::vector merge(std::vector&& a, - std::vector&& b) -{ - a.insert(a.end(), b.begin(), b.end()); - return std::move(a); +inline std::vector merge(std::vector &&a, + std::vector &&b) { + a.insert(a.end(), b.begin(), b.end()); + return std::move(a); } namespace psy { namespace C { - /** * \brief The DeclarationSyntax class. * @@ -179,18 +178,20 @@ namespace C { * \note Similar to: * - \c clang::Decl of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax and - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax of + * Roslyn. */ -class PSY_C_API DeclarationSyntax : public SyntaxNode - , public MIXIN_GNUExtensionFlag -{ - AST_G_NODE(Declaration) +class PSY_C_API DeclarationSyntax : public SyntaxNode, + public MIXIN_GNUExtensionFlag { + AST_G_NODE(Declaration) public: - SyntaxToken extensionKeyword() const override { return tokenAtIndex(extKwTkIdx_); } + SyntaxToken extensionKeyword() const override { + return tokenAtIndex(extKwTkIdx_); + } private: - AST_CHILD_LST1(extKwTkIdx_); + AST_CHILD_LST1(extKwTkIdx_); }; /** @@ -200,9 +201,8 @@ class PSY_C_API DeclarationSyntax : public SyntaxNode * * \remark 6.7.1, 6.7.2, 6.7.3, 6.7.4, and 6.7.5. */ -class PSY_C_API SpecifierSyntax : public SyntaxNode -{ - AST_G_NODE(Specifier) +class PSY_C_API SpecifierSyntax : public SyntaxNode { + AST_G_NODE(Specifier) }; /** @@ -216,9 +216,8 @@ class PSY_C_API SpecifierSyntax : public SyntaxNode * - \c clang::Declarator of LLVM/Clang. * - \c clang::syntax::Declarator of Clang's Libtooling. */ -class PSY_C_API DeclaratorSyntax : public SyntaxNode -{ - AST_G_NODE(Declarator) +class PSY_C_API DeclaratorSyntax : public SyntaxNode { + AST_G_NODE(Declarator) }; /** @@ -228,9 +227,8 @@ class PSY_C_API DeclaratorSyntax : public SyntaxNode * * \remark 6.7.6 */ -class PSY_C_API DeclaratorSuffixSyntax : public SyntaxNode -{ - AST_G_NODE(DeclaratorSuffix) +class PSY_C_API DeclaratorSuffixSyntax : public SyntaxNode { + AST_G_NODE(DeclaratorSuffix) }; /** @@ -239,11 +237,11 @@ class PSY_C_API DeclaratorSuffixSyntax : public SyntaxNode * \remark 6.7.9 * * \note Similar to: - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax of + * Roslyn. */ -class PSY_C_API InitializerSyntax : public SyntaxNode -{ - AST_G_NODE(Initializer) +class PSY_C_API InitializerSyntax : public SyntaxNode { + AST_G_NODE(Initializer) }; /** @@ -268,36 +266,35 @@ class PSY_C_API InitializerSyntax : public SyntaxNode * - \c clang::syntax::Expression of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax of Roslyn. */ -class PSY_C_API ExpressionSyntax : public SyntaxNode - , public MIXIN_GNUExtensionFlag -{ - AST_G_NODE(Expression) +class PSY_C_API ExpressionSyntax : public SyntaxNode, + public MIXIN_GNUExtensionFlag { + AST_G_NODE(Expression) public: - SyntaxToken extensionKeyword() const override { return tokenAtIndex(extKwTkIdx_); } + SyntaxToken extensionKeyword() const override { + return tokenAtIndex(extKwTkIdx_); + } private: - AST_CHILD_LST1(extKwTkIdx_); + AST_CHILD_LST1(extKwTkIdx_); }; /** * \brief The StatementSyntax class: The base class for all statements. */ -class PSY_C_API StatementSyntax : public SyntaxNode -{ - AST_G_NODE(Statement) +class PSY_C_API StatementSyntax : public SyntaxNode { + AST_G_NODE(Statement) }; /** * \brief The TypeReferenceSyntax class. */ -class PSY_C_API TypeReferenceSyntax : public SyntaxNode -{ - AST_G_NODE(TypeReference) +class PSY_C_API TypeReferenceSyntax : public SyntaxNode { + AST_G_NODE(TypeReference) }; -} // C -} // psy +} // namespace C +} // namespace psy #include "SyntaxNodes_Common.h" #include "SyntaxNodes_Declarations.h" diff --git a/C/syntax/SyntaxNodes_Common.h b/C/syntax/SyntaxNodes_Common.h index 271544d2f..f1292afec 100644 --- a/C/syntax/SyntaxNodes_Common.h +++ b/C/syntax/SyntaxNodes_Common.h @@ -41,54 +41,55 @@ namespace C { * * \remark 6.7.7 */ -class PSY_C_API TypeNameSyntax final : public SyntaxNode -{ - AST_G_NODE_1K(TypeName) +class PSY_C_API TypeNameSyntax final : public SyntaxNode { + AST_G_NODE_1K(TypeName) public: - const SpecifierListSyntax* specifiers() const { return specs_; } - const DeclaratorSyntax* declarator() const { return decltor_; } + const SpecifierListSyntax *specifiers() const { return specs_; } + const DeclaratorSyntax *declarator() const { return decltor_; } private: - SpecifierListSyntax* specs_ = nullptr; - DeclaratorSyntax* decltor_ = nullptr; - AST_CHILD_LST2(specs_, decltor_); + SpecifierListSyntax *specs_ = nullptr; + DeclaratorSyntax *decltor_ = nullptr; + AST_CHILD_LST2(specs_, decltor_); }; /** * \brief The ExpressionAsTypeReferenceSyntax class. */ -class PSY_C_API ExpressionAsTypeReferenceSyntax final : public TypeReferenceSyntax -{ - AST_NODE_1K(ExpressionAsTypeReference, TypeReference) +class PSY_C_API ExpressionAsTypeReferenceSyntax final + : public TypeReferenceSyntax { + AST_NODE_1K(ExpressionAsTypeReference, TypeReference) public: - const ExpressionSyntax* expression() const { return expr_; } + const ExpressionSyntax *expression() const { return expr_; } private: - ExpressionSyntax* expr_ = nullptr; - AST_CHILD_LST1(expr_) + ExpressionSyntax *expr_ = nullptr; + AST_CHILD_LST1(expr_) }; /** * \brief The TypeNameAsTypeReferenceSyntax class. */ -class PSY_C_API TypeNameAsTypeReferenceSyntax final : public TypeReferenceSyntax -{ - AST_NODE_1K(TypeNameAsTypeReference, TypeReference) +class PSY_C_API TypeNameAsTypeReferenceSyntax final + : public TypeReferenceSyntax { + AST_NODE_1K(TypeNameAsTypeReference, TypeReference) public: - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const TypeNameSyntax* typeName() const { return typeName_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const TypeNameSyntax *typeName() const { return typeName_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - TypeNameSyntax* typeName_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(openParenTkIdx_, - typeName_, - closeParenTkIdx_) + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + TypeNameSyntax *typeName_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(openParenTkIdx_, typeName_, closeParenTkIdx_) }; /** @@ -106,21 +107,25 @@ class PSY_C_API TypeNameAsTypeReferenceSyntax final : public TypeReferenceSyntax * sizeof (x) * \endcode */ -class PSY_C_API AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax final : public TypeReferenceSyntax -{ - AST_NODE_1K(AmbiguousTypeNameOrExpressionAsTypeReference, TypeReference) +class PSY_C_API AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax final + : public TypeReferenceSyntax { + AST_NODE_1K(AmbiguousTypeNameOrExpressionAsTypeReference, TypeReference) public: - const ExpressionAsTypeReferenceSyntax* expressionAsTypeReference() const { return exprAsTyRef_; } - const TypeNameAsTypeReferenceSyntax* typeNameAsTypeReference() const { return tyNameAsTyRef_; } + const ExpressionAsTypeReferenceSyntax *expressionAsTypeReference() const { + return exprAsTyRef_; + } + const TypeNameAsTypeReferenceSyntax *typeNameAsTypeReference() const { + return tyNameAsTyRef_; + } private: - ExpressionAsTypeReferenceSyntax* exprAsTyRef_ = nullptr; - TypeNameAsTypeReferenceSyntax* tyNameAsTyRef_ = nullptr; - AST_CHILD_LST2(exprAsTyRef_, tyNameAsTyRef_); + ExpressionAsTypeReferenceSyntax *exprAsTyRef_ = nullptr; + TypeNameAsTypeReferenceSyntax *tyNameAsTyRef_ = nullptr; + AST_CHILD_LST2(exprAsTyRef_, tyNameAsTyRef_); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxNodes_Declarations.h b/C/syntax/SyntaxNodes_Declarations.h index 13e2af5b0..b483cea81 100644 --- a/C/syntax/SyntaxNodes_Declarations.h +++ b/C/syntax/SyntaxNodes_Declarations.h @@ -42,16 +42,15 @@ namespace C { * - a \a type-qualifier, or * - a \a function-specifier. */ -class PSY_C_API TrivialSpecifierSyntax : public SpecifierSyntax -{ - AST_NODE(TrivialSpecifier, Specifier) +class PSY_C_API TrivialSpecifierSyntax : public SpecifierSyntax { + AST_NODE(TrivialSpecifier, Specifier) public: - SyntaxToken specifierToken() const { return tokenAtIndex(specTkIdx_); } + SyntaxToken specifierToken() const { return tokenAtIndex(specTkIdx_); } protected: - LexedTokens::IndexType specTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST1(specTkIdx_); + LexedTokens::IndexType specTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST1(specTkIdx_); }; /** @@ -59,12 +58,11 @@ class PSY_C_API TrivialSpecifierSyntax : public SpecifierSyntax * * \remark 6.7.1 */ -class PSY_C_API StorageClassSyntax final : public TrivialSpecifierSyntax -{ - AST_NODE_NK(StorageClass, TrivialSpecifier) +class PSY_C_API StorageClassSyntax final : public TrivialSpecifierSyntax { + AST_NODE_NK(StorageClass, TrivialSpecifier) public: - SyntaxToken storageClassKeyword() const { return tokenAtIndex(specTkIdx_); } + SyntaxToken storageClassKeyword() const { return tokenAtIndex(specTkIdx_); } }; /** @@ -72,12 +70,12 @@ class PSY_C_API StorageClassSyntax final : public TrivialSpecifierSyntax * * \remark 6.7.2 */ -class PSY_C_API BuiltinTypeSpecifierSyntax final : public TrivialSpecifierSyntax -{ - AST_NODE_NK(BuiltinTypeSpecifier, TrivialSpecifier) +class PSY_C_API BuiltinTypeSpecifierSyntax final + : public TrivialSpecifierSyntax { + AST_NODE_NK(BuiltinTypeSpecifier, TrivialSpecifier) public: - SyntaxToken builtinTypeKeyword() const { return tokenAtIndex(specTkIdx_); } + SyntaxToken builtinTypeKeyword() const { return tokenAtIndex(specTkIdx_); } }; /** @@ -85,36 +83,33 @@ class PSY_C_API BuiltinTypeSpecifierSyntax final : public TrivialSpecifierSyntax * * \remark 6.7.2.1, 6.7.2.2, and 6.7.2.3 */ -class PSY_C_API TagTypeSpecifierSyntax final : public SpecifierSyntax -{ - AST_NODE_NK(TagTypeSpecifier, Specifier) +class PSY_C_API TagTypeSpecifierSyntax final : public SpecifierSyntax { + AST_NODE_NK(TagTypeSpecifier, Specifier) public: - SyntaxToken keyword() const { return tokenAtIndex(kwTkIdx_); } - const SpecifierListSyntax* attributes() const { return attrs1_; } - SyntaxToken tagToken() const { return tokenAtIndex(tagTkIdx_); } - SyntaxToken openBraceToken() const { return tokenAtIndex(openBraceTkIdx_); } - const DeclarationListSyntax* declarations() const { return decls_; } - SyntaxToken closeBraceToken() const { return tokenAtIndex(closeBraceTkIdx_); } - const SpecifierListSyntax* attributes_PostCloseBrace() const { return attrs2_; } + SyntaxToken keyword() const { return tokenAtIndex(kwTkIdx_); } + const SpecifierListSyntax *attributes() const { return attrs1_; } + SyntaxToken tagToken() const { return tokenAtIndex(tagTkIdx_); } + SyntaxToken openBraceToken() const { return tokenAtIndex(openBraceTkIdx_); } + const DeclarationListSyntax *declarations() const { return decls_; } + SyntaxToken closeBraceToken() const { return tokenAtIndex(closeBraceTkIdx_); } + const SpecifierListSyntax *attributes_PostCloseBrace() const { + return attrs2_; + } private: - LexedTokens::IndexType kwTkIdx_ = LexedTokens::invalidIndex(); - SpecifierListSyntax* attrs1_ = nullptr; - LexedTokens::IndexType tagTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openBraceTkIdx_ = LexedTokens::invalidIndex(); - DeclarationListSyntax* decls_ = nullptr; - LexedTokens::IndexType closeBraceTkIdx_ = LexedTokens::invalidIndex();; - SpecifierListSyntax* attrs2_ = nullptr; - AST_CHILD_LST7(kwTkIdx_, - attrs1_, - tagTkIdx_, - openBraceTkIdx_, - decls_, - closeBraceTkIdx_, - attrs2_); - - mutable Symbol* sym_ = nullptr; + LexedTokens::IndexType kwTkIdx_ = LexedTokens::invalidIndex(); + SpecifierListSyntax *attrs1_ = nullptr; + LexedTokens::IndexType tagTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openBraceTkIdx_ = LexedTokens::invalidIndex(); + DeclarationListSyntax *decls_ = nullptr; + LexedTokens::IndexType closeBraceTkIdx_ = LexedTokens::invalidIndex(); + ; + SpecifierListSyntax *attrs2_ = nullptr; + AST_CHILD_LST7(kwTkIdx_, attrs1_, tagTkIdx_, openBraceTkIdx_, decls_, + closeBraceTkIdx_, attrs2_); + + mutable Symbol *sym_ = nullptr; }; /** @@ -122,25 +117,25 @@ class PSY_C_API TagTypeSpecifierSyntax final : public SpecifierSyntax * * \remark 6.7.2.4 */ -class PSY_C_API AtomicTypeSpecifierSyntax final : public SpecifierSyntax -{ - AST_NODE_1K(AtomicTypeSpecifier, Specifier) +class PSY_C_API AtomicTypeSpecifierSyntax final : public SpecifierSyntax { + AST_NODE_1K(AtomicTypeSpecifier, Specifier) public: - SyntaxToken atomicKeyword() const { return tokenAtIndex(atomicKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const TypeNameSyntax* typeName() const { return typeName_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken atomicKeyword() const { return tokenAtIndex(atomicKwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const TypeNameSyntax *typeName() const { return typeName_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType atomicKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - TypeNameSyntax* typeName_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST4(atomicKwTkIdx_, - openParenTkIdx_, - typeName_, - closeParenTkIdx_); + LexedTokens::IndexType atomicKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + TypeNameSyntax *typeName_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST4(atomicKwTkIdx_, openParenTkIdx_, typeName_, closeParenTkIdx_); }; /** @@ -148,12 +143,11 @@ class PSY_C_API AtomicTypeSpecifierSyntax final : public SpecifierSyntax * * \remark 6.7.3 */ -class PSY_C_API TypeQualifierSyntax final : public TrivialSpecifierSyntax -{ - AST_NODE_NK(TypeQualifier, TrivialSpecifier) +class PSY_C_API TypeQualifierSyntax final : public TrivialSpecifierSyntax { + AST_NODE_NK(TypeQualifier, TrivialSpecifier) public: - SyntaxToken qualifierKeyword() const { return tokenAtIndex(specTkIdx_); } + SyntaxToken qualifierKeyword() const { return tokenAtIndex(specTkIdx_); } }; /** @@ -161,12 +155,11 @@ class PSY_C_API TypeQualifierSyntax final : public TrivialSpecifierSyntax * * \remark 6.7.4 */ -class PSY_C_API FunctionSpecifierSyntax final : public TrivialSpecifierSyntax -{ - AST_NODE_NK(FunctionSpecifier, TrivialSpecifier) +class PSY_C_API FunctionSpecifierSyntax final : public TrivialSpecifierSyntax { + AST_NODE_NK(FunctionSpecifier, TrivialSpecifier) public: - SyntaxToken specifierKeyword() const { return tokenAtIndex(specTkIdx_); } + SyntaxToken specifierKeyword() const { return tokenAtIndex(specTkIdx_); } }; /** @@ -182,18 +175,17 @@ class PSY_C_API FunctionSpecifierSyntax final : public TrivialSpecifierSyntax * * \remark 6.7.5 */ -class PSY_C_API AlignmentSpecifierSyntax final : public SpecifierSyntax -{ - AST_NODE_1K(AlignmentSpecifier, Specifier) +class PSY_C_API AlignmentSpecifierSyntax final : public SpecifierSyntax { + AST_NODE_1K(AlignmentSpecifier, Specifier) public: - SyntaxToken alignasKeyword() const { return tokenAtIndex(alignasKwTkIdx_); } - const TypeReferenceSyntax* tyReference() const { return tyRef_; } + SyntaxToken alignasKeyword() const { return tokenAtIndex(alignasKwTkIdx_); } + const TypeReferenceSyntax *tyReference() const { return tyRef_; } private: - LexedTokens::IndexType alignasKwTkIdx_ = LexedTokens::invalidIndex(); - TypeReferenceSyntax* tyRef_ = nullptr; - AST_CHILD_LST2(alignasKwTkIdx_, tyRef_); + LexedTokens::IndexType alignasKwTkIdx_ = LexedTokens::invalidIndex(); + TypeReferenceSyntax *tyRef_ = nullptr; + AST_CHILD_LST2(alignasKwTkIdx_, tyRef_); }; /** @@ -210,18 +202,17 @@ class PSY_C_API AlignmentSpecifierSyntax final : public SpecifierSyntax * \attention Thisis a GNU extension: * https://gcc.gnu.org/onlinedocs/gcc/Typeof.html#Typeof */ -class PSY_C_API ExtGNU_TypeofSyntax final : public SpecifierSyntax -{ - AST_NODE_1K(ExtGNU_Typeof, Specifier); +class PSY_C_API ExtGNU_TypeofSyntax final : public SpecifierSyntax { + AST_NODE_1K(ExtGNU_Typeof, Specifier); public: - SyntaxToken typeofKeyword() const { return tokenAtIndex(typeofKwTkIdx_); } - const TypeReferenceSyntax* tyReference() const { return tyRef_; } + SyntaxToken typeofKeyword() const { return tokenAtIndex(typeofKwTkIdx_); } + const TypeReferenceSyntax *tyReference() const { return tyRef_; } private: - LexedTokens::IndexType typeofKwTkIdx_ = LexedTokens::invalidIndex(); - TypeReferenceSyntax* tyRef_ = nullptr; - AST_CHILD_LST2(typeofKwTkIdx_, tyRef_); + LexedTokens::IndexType typeofKwTkIdx_ = LexedTokens::invalidIndex(); + TypeReferenceSyntax *tyRef_ = nullptr; + AST_CHILD_LST2(typeofKwTkIdx_, tyRef_); }; /** @@ -230,31 +221,34 @@ class PSY_C_API ExtGNU_TypeofSyntax final : public SpecifierSyntax * \attention This is a GNU extension: * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html */ -class PSY_C_API ExtGNU_AttributeSpecifierSyntax final : public SpecifierSyntax -{ - AST_NODE_1K(ExtGNU_AttributeSpecifier, Specifier) +class PSY_C_API ExtGNU_AttributeSpecifierSyntax final : public SpecifierSyntax { + AST_NODE_1K(ExtGNU_AttributeSpecifier, Specifier) public: - SyntaxToken attributeKeyword() const { return tokenAtIndex(attrKwTkIdx_); } - SyntaxToken openOuterParenthesisToken() const { return tokenAtIndex(openOuterParenTkIdx_); } - SyntaxToken openInnerParenthesisToken() const { return tokenAtIndex(openInnerParenTkIdx_); } - const ExtGNU_AttributeListSyntax* attributes() const { return attrs_; } - SyntaxToken closeInnerParenthesisToken() const { return tokenAtIndex(closeInnerParenTkIdx_); } - SyntaxToken closeOuterParenthesisToken() const { return tokenAtIndex(closeOuterParenTkIdx_); } + SyntaxToken attributeKeyword() const { return tokenAtIndex(attrKwTkIdx_); } + SyntaxToken openOuterParenthesisToken() const { + return tokenAtIndex(openOuterParenTkIdx_); + } + SyntaxToken openInnerParenthesisToken() const { + return tokenAtIndex(openInnerParenTkIdx_); + } + const ExtGNU_AttributeListSyntax *attributes() const { return attrs_; } + SyntaxToken closeInnerParenthesisToken() const { + return tokenAtIndex(closeInnerParenTkIdx_); + } + SyntaxToken closeOuterParenthesisToken() const { + return tokenAtIndex(closeOuterParenTkIdx_); + } private: - LexedTokens::IndexType attrKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openOuterParenTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openInnerParenTkIdx_ = LexedTokens::invalidIndex(); - ExtGNU_AttributeListSyntax* attrs_ = nullptr; - LexedTokens::IndexType closeInnerParenTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType closeOuterParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST6(attrKwTkIdx_, - openOuterParenTkIdx_, - openInnerParenTkIdx_, - attrs_, - closeInnerParenTkIdx_, - closeOuterParenTkIdx_); + LexedTokens::IndexType attrKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openOuterParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openInnerParenTkIdx_ = LexedTokens::invalidIndex(); + ExtGNU_AttributeListSyntax *attrs_ = nullptr; + LexedTokens::IndexType closeInnerParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType closeOuterParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST6(attrKwTkIdx_, openOuterParenTkIdx_, openInnerParenTkIdx_, + attrs_, closeInnerParenTkIdx_, closeOuterParenTkIdx_); }; /** @@ -263,22 +257,27 @@ class PSY_C_API ExtGNU_AttributeSpecifierSyntax final : public SpecifierSyntax * \attention This is a GNU extension: * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html */ -class PSY_C_API ExtGNU_AttributeSyntax final : public SyntaxNode -{ - AST_G_NODE_1K(ExtGNU_Attribute) +class PSY_C_API ExtGNU_AttributeSyntax final : public SyntaxNode { + AST_G_NODE_1K(ExtGNU_Attribute) public: - SyntaxToken keywordOrIdentifierToken() const { return tokenAtIndex(kwOrIdentTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionListSyntax* expressions() const { return exprs_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken keywordOrIdentifierToken() const { + return tokenAtIndex(kwOrIdentTkIdx_); + } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionListSyntax *expressions() const { return exprs_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType kwOrIdentTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionListSyntax* exprs_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST4(kwOrIdentTkIdx_, openParenTkIdx_, exprs_, closeParenTkIdx_); + LexedTokens::IndexType kwOrIdentTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionListSyntax *exprs_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST4(kwOrIdentTkIdx_, openParenTkIdx_, exprs_, closeParenTkIdx_); }; /** @@ -290,25 +289,25 @@ class PSY_C_API ExtGNU_AttributeSyntax final : public SyntaxNode * \note Similar to: * - \c clang::AsmLabelAttrExpr of LLMV/Clang. */ -class PSY_C_API ExtGNU_AsmLabelSyntax final : public SpecifierSyntax -{ - AST_NODE_1K(ExtGNU_AsmLabel, Specifier) +class PSY_C_API ExtGNU_AsmLabelSyntax final : public SpecifierSyntax { + AST_NODE_1K(ExtGNU_AsmLabel, Specifier) public: - SyntaxToken asmKeyword() const { return tokenAtIndex(asmKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* stringLiteral() const { return strLit_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken asmKeyword() const { return tokenAtIndex(asmKwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *stringLiteral() const { return strLit_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType asmKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* strLit_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST4(asmKwTkIdx_, - openParenTkIdx_, - strLit_, - closeParenTkIdx_); + LexedTokens::IndexType asmKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *strLit_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST4(asmKwTkIdx_, openParenTkIdx_, strLit_, closeParenTkIdx_); }; /** @@ -316,19 +315,16 @@ class PSY_C_API ExtGNU_AsmLabelSyntax final : public SpecifierSyntax * * \attention This is a Psyche-C extension. */ -class PSY_C_API ExtPSY_QuantifiedTypeSpecifierSyntax : public SpecifierSyntax -{ - AST_NODE_1K(ExtPSY_QuantifiedTypeSpecifier, Specifier) +class PSY_C_API ExtPSY_QuantifiedTypeSpecifierSyntax : public SpecifierSyntax { + AST_NODE_1K(ExtPSY_QuantifiedTypeSpecifier, Specifier) private: - LexedTokens::IndexType quantifierTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST4(quantifierTkIdx_, - openParenTkIdx_, - identTkIdx_, - closeParenTkIdx_); + LexedTokens::IndexType quantifierTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST4(quantifierTkIdx_, openParenTkIdx_, identTkIdx_, + closeParenTkIdx_); }; /** @@ -336,16 +332,15 @@ class PSY_C_API ExtPSY_QuantifiedTypeSpecifierSyntax : public SpecifierSyntax * * \remark 6.7.8 */ -class PSY_C_API TypedefNameSyntax final : public SpecifierSyntax -{ - AST_NODE_1K(TypedefName, Specifier) +class PSY_C_API TypedefNameSyntax final : public SpecifierSyntax { + AST_NODE_1K(TypedefName, Specifier) public: - SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } + SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } private: - LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST1(identTkIdx_); + LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST1(identTkIdx_); }; /* Declarators */ @@ -354,28 +349,25 @@ class PSY_C_API TypedefNameSyntax final : public SpecifierSyntax * * \remark 6.7.6-4 */ -class PSY_C_API IdentifierDeclaratorSyntax final : public DeclaratorSyntax -{ - AST_NODE_1K(IdentifierDeclarator, Declarator) +class PSY_C_API IdentifierDeclaratorSyntax final : public DeclaratorSyntax { + AST_NODE_1K(IdentifierDeclarator, Declarator) public: - const SpecifierListSyntax* attributes() const { return attrs1_; } - SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } - const SpecifierListSyntax* attributes_PostIdentifier() const { return attrs2_; } - SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } - const InitializerSyntax* initializer() const { return init_; } + const SpecifierListSyntax *attributes() const { return attrs1_; } + SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } + const SpecifierListSyntax *attributes_PostIdentifier() const { + return attrs2_; + } + SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } + const InitializerSyntax *initializer() const { return init_; } private: - SpecifierListSyntax* attrs1_ = nullptr; - LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); - SpecifierListSyntax* attrs2_ = nullptr; - LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); - InitializerSyntax* init_ = nullptr; - AST_CHILD_LST5(attrs1_, - identTkIdx_, - attrs2_, - equalsTkIdx_, - init_) + SpecifierListSyntax *attrs1_ = nullptr; + LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); + SpecifierListSyntax *attrs2_ = nullptr; + LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); + InitializerSyntax *init_ = nullptr; + AST_CHILD_LST5(attrs1_, identTkIdx_, attrs2_, equalsTkIdx_, init_) }; /** @@ -383,20 +375,23 @@ class PSY_C_API IdentifierDeclaratorSyntax final : public DeclaratorSyntax * * \remark 6.7.6-6 */ -class PSY_C_API ParenthesizedDeclaratorSyntax final : public DeclaratorSyntax -{ - AST_NODE_1K(ParenthesizedDeclarator, Declarator); +class PSY_C_API ParenthesizedDeclaratorSyntax final : public DeclaratorSyntax { + AST_NODE_1K(ParenthesizedDeclarator, Declarator); public: - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const DeclaratorSyntax* innerDeclarator() const { return innerDecltor_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const DeclaratorSyntax *innerDeclarator() const { return innerDecltor_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - DeclaratorSyntax* innerDecltor_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(openParenTkIdx_, innerDecltor_, closeParenTkIdx_) + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + DeclaratorSyntax *innerDecltor_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(openParenTkIdx_, innerDecltor_, closeParenTkIdx_) }; /** @@ -407,16 +402,15 @@ class PSY_C_API ParenthesizedDeclaratorSyntax final : public DeclaratorSyntax * * \remark 6.7.7-2 */ -class PSY_C_API AbstractDeclaratorSyntax final : public DeclaratorSyntax -{ - AST_NODE_1K(AbstractDeclarator, Declarator) +class PSY_C_API AbstractDeclaratorSyntax final : public DeclaratorSyntax { + AST_NODE_1K(AbstractDeclarator, Declarator) public: - const SpecifierListSyntax* attributes() const { return attrs_; } + const SpecifierListSyntax *attributes() const { return attrs_; } private: - SpecifierListSyntax* attrs_ = nullptr; - AST_CHILD_LST1(attrs_); + SpecifierListSyntax *attrs_ = nullptr; + AST_CHILD_LST1(attrs_); }; /** @@ -424,31 +418,28 @@ class PSY_C_API AbstractDeclaratorSyntax final : public DeclaratorSyntax * * \remark 6.7.6.1 */ -class PSY_C_API PointerDeclaratorSyntax final : public DeclaratorSyntax -{ - AST_NODE_1K(PointerDeclarator, Declarator) +class PSY_C_API PointerDeclaratorSyntax final : public DeclaratorSyntax { + AST_NODE_1K(PointerDeclarator, Declarator) public: - const SpecifierListSyntax* attributes() const { return attrs_; } - SyntaxToken asteriskToken() const { return tokenAtIndex(asteriskTkIdx_); } - const SpecifierListSyntax* qualifiersAndAttributes() const { return qualsAndAttrs_; } - const DeclaratorSyntax* innerDeclarator() const { return innerDecltor_; } - SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } - const InitializerSyntax* initializer() const { return init_; } + const SpecifierListSyntax *attributes() const { return attrs_; } + SyntaxToken asteriskToken() const { return tokenAtIndex(asteriskTkIdx_); } + const SpecifierListSyntax *qualifiersAndAttributes() const { + return qualsAndAttrs_; + } + const DeclaratorSyntax *innerDeclarator() const { return innerDecltor_; } + SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } + const InitializerSyntax *initializer() const { return init_; } private: - SpecifierListSyntax* attrs_ = nullptr; - LexedTokens::IndexType asteriskTkIdx_ = LexedTokens::invalidIndex(); - SpecifierListSyntax* qualsAndAttrs_ = nullptr; - DeclaratorSyntax* innerDecltor_ = nullptr; - LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); - InitializerSyntax* init_ = nullptr; - AST_CHILD_LST6(attrs_, - asteriskTkIdx_, - qualsAndAttrs_, - innerDecltor_, - equalsTkIdx_, - init_) + SpecifierListSyntax *attrs_ = nullptr; + LexedTokens::IndexType asteriskTkIdx_ = LexedTokens::invalidIndex(); + SpecifierListSyntax *qualsAndAttrs_ = nullptr; + DeclaratorSyntax *innerDecltor_ = nullptr; + LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); + InitializerSyntax *init_ = nullptr; + AST_CHILD_LST6(attrs_, asteriskTkIdx_, qualsAndAttrs_, innerDecltor_, + equalsTkIdx_, init_) }; /** @@ -458,33 +449,30 @@ class PSY_C_API PointerDeclaratorSyntax final : public DeclaratorSyntax * * \remark 6.7.6.2 and 6.7.6.3 */ -class PSY_C_API ArrayOrFunctionDeclaratorSyntax final : public DeclaratorSyntax -{ - AST_NODE_NK(ArrayOrFunctionDeclarator, Declarator) +class PSY_C_API ArrayOrFunctionDeclaratorSyntax final + : public DeclaratorSyntax { + AST_NODE_NK(ArrayOrFunctionDeclarator, Declarator) public: - const SpecifierListSyntax* attributes() const { return attrs1_; } - const DeclaratorSyntax* innerDeclarator() const { return innerDecltor_; } - const DeclaratorSuffixSyntax* suffix() const { return suffix_; } - const SpecifierListSyntax* attributes_PostDeclarator() const { return attrs2_; } - SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } - const InitializerSyntax* initializer() const { return init_; } + const SpecifierListSyntax *attributes() const { return attrs1_; } + const DeclaratorSyntax *innerDeclarator() const { return innerDecltor_; } + const DeclaratorSuffixSyntax *suffix() const { return suffix_; } + const SpecifierListSyntax *attributes_PostDeclarator() const { + return attrs2_; + } + SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } + const InitializerSyntax *initializer() const { return init_; } public: - SpecifierListSyntax* attrs1_ = nullptr; - DeclaratorSyntax* innerDecltor_ = nullptr; - DeclaratorSuffixSyntax* suffix_ = nullptr; - SpecifierListSyntax* attrs2_ = nullptr; - LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); - InitializerSyntax* init_ = nullptr; - AST_CHILD_LST6(attrs1_, - innerDecltor_, - suffix_, - attrs2_, - equalsTkIdx_, - init_) - - mutable Symbol* sym_; + SpecifierListSyntax *attrs1_ = nullptr; + DeclaratorSyntax *innerDecltor_ = nullptr; + DeclaratorSuffixSyntax *suffix_ = nullptr; + SpecifierListSyntax *attrs2_ = nullptr; + LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); + InitializerSyntax *init_ = nullptr; + AST_CHILD_LST6(attrs1_, innerDecltor_, suffix_, attrs2_, equalsTkIdx_, init_) + + mutable Symbol *sym_; }; /** @@ -494,34 +482,36 @@ class PSY_C_API ArrayOrFunctionDeclaratorSyntax final : public DeclaratorSyntax * * \remark 6.7.6.2 */ -class PSY_C_API SubscriptSuffixSyntax final : public DeclaratorSuffixSyntax -{ - AST_NODE_1K(SubscriptSuffix, DeclaratorSuffix) +class PSY_C_API SubscriptSuffixSyntax final : public DeclaratorSuffixSyntax { + AST_NODE_1K(SubscriptSuffix, DeclaratorSuffix) public: - SyntaxToken openBracketToken() const { return tokenAtIndex(openBracketTkIdx_); } - const SpecifierListSyntax* qualifiersAndAttributes() const { return qualsAndAttrs1_; } - SyntaxToken staticKeyword() const { return tokenAtIndex(staticKwTkIdx_); } - SpecifierListSyntax* qualifiersAndAttributes_PostStatic() const { return qualsAndAttrs2_; } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken asteriskToken() const { return tokenAtIndex(asteriskTkIdx_); } - SyntaxToken closeBracketToken() const { return tokenAtIndex(closeBracketTkIdx_); } + SyntaxToken openBracketToken() const { + return tokenAtIndex(openBracketTkIdx_); + } + const SpecifierListSyntax *qualifiersAndAttributes() const { + return qualsAndAttrs1_; + } + SyntaxToken staticKeyword() const { return tokenAtIndex(staticKwTkIdx_); } + SpecifierListSyntax *qualifiersAndAttributes_PostStatic() const { + return qualsAndAttrs2_; + } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken asteriskToken() const { return tokenAtIndex(asteriskTkIdx_); } + SyntaxToken closeBracketToken() const { + return tokenAtIndex(closeBracketTkIdx_); + } private: - LexedTokens::IndexType openBracketTkIdx_ = LexedTokens::invalidIndex(); - SpecifierListSyntax* qualsAndAttrs1_ = nullptr; - LexedTokens::IndexType staticKwTkIdx_ = LexedTokens::invalidIndex(); - SpecifierListSyntax* qualsAndAttrs2_ = nullptr; - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType asteriskTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType closeBracketTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST7(openBracketTkIdx_, - qualsAndAttrs1_, - staticKwTkIdx_, - qualsAndAttrs2_, - expr_, - asteriskTkIdx_, - closeBracketTkIdx_) + LexedTokens::IndexType openBracketTkIdx_ = LexedTokens::invalidIndex(); + SpecifierListSyntax *qualsAndAttrs1_ = nullptr; + LexedTokens::IndexType staticKwTkIdx_ = LexedTokens::invalidIndex(); + SpecifierListSyntax *qualsAndAttrs2_ = nullptr; + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType asteriskTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType closeBracketTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST7(openBracketTkIdx_, qualsAndAttrs1_, staticKwTkIdx_, + qualsAndAttrs2_, expr_, asteriskTkIdx_, closeBracketTkIdx_) }; /** @@ -531,26 +521,26 @@ class PSY_C_API SubscriptSuffixSyntax final : public DeclaratorSuffixSyntax * * \remark 6.7.6.3 */ -class PSY_C_API ParameterSuffixSyntax final : public DeclaratorSuffixSyntax -{ - AST_NODE_1K(ParameterSuffix, DeclaratorSuffix) +class PSY_C_API ParameterSuffixSyntax final : public DeclaratorSuffixSyntax { + AST_NODE_1K(ParameterSuffix, DeclaratorSuffix) public: - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ParameterDeclarationListSyntax* parameters() const { return decls_; } - SyntaxToken ellipsisToken() const { return tokenAtIndex(ellipsisTkIdx_); } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ParameterDeclarationListSyntax *parameters() const { return decls_; } + SyntaxToken ellipsisToken() const { return tokenAtIndex(ellipsisTkIdx_); } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ParameterDeclarationListSyntax* decls_ = nullptr; - LexedTokens::IndexType ellipsisTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType psyOmitTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST4(openParenTkIdx_, - decls_, - ellipsisTkIdx_, - closeParenTkIdx_) + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ParameterDeclarationListSyntax *decls_ = nullptr; + LexedTokens::IndexType ellipsisTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType psyOmitTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST4(openParenTkIdx_, decls_, ellipsisTkIdx_, closeParenTkIdx_) }; /** @@ -558,25 +548,21 @@ class PSY_C_API ParameterSuffixSyntax final : public DeclaratorSuffixSyntax * * \remark 6.7.2.1-9 */ -class PSY_C_API BitfieldDeclaratorSyntax final : public DeclaratorSyntax -{ - AST_NODE_1K(BitfieldDeclarator, Declarator) +class PSY_C_API BitfieldDeclaratorSyntax final : public DeclaratorSyntax { + AST_NODE_1K(BitfieldDeclarator, Declarator) public: - const DeclaratorSyntax* innerDeclarator() const { return innerDecltor_; } - SyntaxToken colonToken() const { return tokenAtIndex(colonTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - const SpecifierListSyntax* attributes() const { return attrs_; } + const DeclaratorSyntax *innerDeclarator() const { return innerDecltor_; } + SyntaxToken colonToken() const { return tokenAtIndex(colonTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + const SpecifierListSyntax *attributes() const { return attrs_; } private: - DeclaratorSyntax* innerDecltor_ = nullptr; - LexedTokens::IndexType colonTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - SpecifierListSyntax* attrs_ = nullptr; - AST_CHILD_LST4(innerDecltor_, - colonTkIdx_, - expr_, - expr_); + DeclaratorSyntax *innerDecltor_ = nullptr; + LexedTokens::IndexType colonTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + SpecifierListSyntax *attrs_ = nullptr; + AST_CHILD_LST4(innerDecltor_, colonTkIdx_, expr_, expr_); }; //--------------// @@ -595,33 +581,31 @@ class PSY_C_API BitfieldDeclaratorSyntax final : public DeclaratorSyntax * - \c clang::syntax::TranslationUnit of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.CompilationUnitSyntax of Roslyn. */ -class PSY_C_API TranslationUnitSyntax final : public SyntaxNode -{ - AST_G_NODE_1K(TranslationUnit) +class PSY_C_API TranslationUnitSyntax final : public SyntaxNode { + AST_G_NODE_1K(TranslationUnit) public: - const DeclarationListSyntax* declarations() const { return decls_; } + const DeclarationListSyntax *declarations() const { return decls_; } private: - DeclarationListSyntax* decls_ = nullptr; - AST_CHILD_LST1(decls_) + DeclarationListSyntax *decls_ = nullptr; + AST_CHILD_LST1(decls_) }; /** * \brief The IncompleteDeclarationSyntax class. */ -class PSY_C_API IncompleteDeclarationSyntax final : public DeclarationSyntax -{ - AST_NODE_1K(IncompleteDeclaration, Declaration) +class PSY_C_API IncompleteDeclarationSyntax final : public DeclarationSyntax { + AST_NODE_1K(IncompleteDeclaration, Declaration) public: - const SpecifierListSyntax* specifiers() const { return specs_; } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + const SpecifierListSyntax *specifiers() const { return specs_; } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - const SpecifierListSyntax* specs_ = nullptr; - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST2(specs_, semicolonTkIdx_) + const SpecifierListSyntax *specs_ = nullptr; + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST2(specs_, semicolonTkIdx_) }; /** @@ -633,9 +617,8 @@ class PSY_C_API IncompleteDeclarationSyntax final : public DeclarationSyntax * - \c clang::NamedDecl of LLVM/Clang. * - \c clang::syntax::SimpleDeclaration of Clang's Libtooling. */ -class PSY_C_API NamedDeclarationSyntax : public DeclarationSyntax -{ - AST_NODE(NamedDeclaration, Declaration) +class PSY_C_API NamedDeclarationSyntax : public DeclarationSyntax { + AST_NODE(NamedDeclaration, Declaration) }; /** @@ -649,17 +632,16 @@ class PSY_C_API NamedDeclarationSyntax : public DeclarationSyntax * - \c clang::TypeDecl of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax of Roslyn. */ -class PSY_C_API TypeDeclarationSyntax : public NamedDeclarationSyntax -{ - AST_NODE(TypeDeclaration, NamedDeclaration) +class PSY_C_API TypeDeclarationSyntax : public NamedDeclarationSyntax { + AST_NODE(TypeDeclaration, NamedDeclaration) - const TagTypeSpecifierSyntax* typeSpecifier() const { return typeSpec_; } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + const TagTypeSpecifierSyntax *typeSpecifier() const { return typeSpec_; } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - TagTypeSpecifierSyntax* typeSpec_ = nullptr; - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST2(typeSpec_, semicolonTkIdx_) + TagTypeSpecifierSyntax *typeSpec_ = nullptr; + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST2(typeSpec_, semicolonTkIdx_) }; /** @@ -673,9 +655,8 @@ class PSY_C_API TypeDeclarationSyntax : public NamedDeclarationSyntax * \note Similar to: * - \c clang::TagDecl of LLVM/Clang. */ -class PSY_C_API TagDeclarationSyntax : public TypeDeclarationSyntax -{ - AST_NODE(TagDeclaration, TypeDeclaration) +class PSY_C_API TagDeclarationSyntax : public TypeDeclarationSyntax { + AST_NODE(TagDeclaration, TypeDeclaration) }; /** @@ -690,9 +671,9 @@ class PSY_C_API TagDeclarationSyntax : public TypeDeclarationSyntax * - \c Microsoft.CodeAnalysis.CSharp.StructDeclarationSyntax and * - \c Microsoft.CodeAnalysis.CSharp.ClassDeclarationSyntax of Roslyn. */ -class PSY_C_API StructOrUnionDeclarationSyntax final : public TagDeclarationSyntax -{ - AST_NODE_NK(StructOrUnionDeclaration, TagDeclaration) +class PSY_C_API StructOrUnionDeclarationSyntax final + : public TagDeclarationSyntax { + AST_NODE_NK(StructOrUnionDeclaration, TagDeclaration) }; /** @@ -704,9 +685,8 @@ class PSY_C_API StructOrUnionDeclarationSyntax final : public TagDeclarationSynt * - \c clang::EnumDecl of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.EnumDeclarationSyntax of Roslyn. */ -class PSY_C_API EnumDeclarationSyntax final : public TagDeclarationSyntax -{ - AST_NODE_NK(EnumDeclaration, TagDeclaration) +class PSY_C_API EnumDeclarationSyntax final : public TagDeclarationSyntax { + AST_NODE_NK(EnumDeclaration, TagDeclaration) }; /** @@ -727,19 +707,18 @@ class PSY_C_API EnumDeclarationSyntax final : public TagDeclarationSyntax * * \remark 6.7.2.1-8 */ -class PSY_C_API TypeDeclarationAsSpecifierSyntax final : public SpecifierSyntax -{ - AST_NODE_1K(TypeDeclarationAsSpecifier, Specifier) +class PSY_C_API TypeDeclarationAsSpecifierSyntax final + : public SpecifierSyntax { + AST_NODE_1K(TypeDeclarationAsSpecifier, Specifier) public: - const TypeDeclarationSyntax* typeDeclaration() const { return typeDecl_; } + const TypeDeclarationSyntax *typeDeclaration() const { return typeDecl_; } private: - TypeDeclarationSyntax* typeDecl_ = nullptr; - AST_CHILD_LST1(typeDecl_); + TypeDeclarationSyntax *typeDecl_ = nullptr; + AST_CHILD_LST1(typeDecl_); }; - /** * \brief The ValueDeclarationSyntax class. * @@ -748,9 +727,8 @@ class PSY_C_API TypeDeclarationAsSpecifierSyntax final : public SpecifierSyntax * \note Similar to: * - \c clang::ValueDecl of LLVM/Clang. */ -class PSY_C_API ValueDeclarationSyntax : public DeclarationSyntax -{ - AST_NODE(ValueDeclaration, Declaration) +class PSY_C_API ValueDeclarationSyntax : public DeclarationSyntax { + AST_NODE(ValueDeclaration, Declaration) }; /** @@ -760,30 +738,27 @@ class PSY_C_API ValueDeclarationSyntax : public DeclarationSyntax * * \note Similar to: * - \c clang::EnumConstantDecl of LLVM/Clang. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.EnumeratorDeclarationSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.EnumeratorDeclarationSyntax of + * Roslyn. */ -class PSY_C_API EnumeratorDeclarationSyntax final : public ValueDeclarationSyntax -{ - AST_NODE_1K(EnumeratorDeclaration, ValueDeclaration) +class PSY_C_API EnumeratorDeclarationSyntax final + : public ValueDeclarationSyntax { + AST_NODE_1K(EnumeratorDeclaration, ValueDeclaration) public: - SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } - const SpecifierListSyntax* attributes() const { return attrs_; } - SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } + SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } + const SpecifierListSyntax *attributes() const { return attrs_; } + SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } private: - LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); - SpecifierListSyntax* attrs_ = nullptr; - LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST5(identTkIdx_, - attrs_, - equalsTkIdx_, - expr_, - commaTkIdx_) + LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); + SpecifierListSyntax *attrs_ = nullptr; + LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST5(identTkIdx_, attrs_, equalsTkIdx_, expr_, commaTkIdx_) }; /** @@ -797,9 +772,8 @@ class PSY_C_API EnumeratorDeclarationSyntax final : public ValueDeclarationSynta * - \c clang::DeclaratorDecl of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclaratorSyntax of Roslyn. */ -class PSY_C_API DeclaratorDeclarationSyntax : public ValueDeclarationSyntax -{ - AST_NODE(DeclaratorDeclaration, ValueDeclaration) +class PSY_C_API DeclaratorDeclarationSyntax : public ValueDeclarationSyntax { + AST_NODE(DeclaratorDeclaration, ValueDeclaration) }; /** @@ -810,10 +784,11 @@ class PSY_C_API DeclaratorDeclarationSyntax : public ValueDeclarationSyntax * - a \b function. * * It isn't distinguished, by means of a further inherited type, the exact - * variety of the \a declaration, i.e., there are no \c "VariableDeclarationSyntax" - * or \c "FunctionDeclarationSyntax" class. Yet, the \a declarator within - * this \a declaration is refined enough: identifying either an object or - * a function. The reason for this design is explained through the snippet below: + * variety of the \a declaration, i.e., there are no \c + * "VariableDeclarationSyntax" or \c "FunctionDeclarationSyntax" class. Yet, the + * \a declarator within this \a declaration is refined enough: identifying + * either an object or a function. The reason for this design is explained + * through the snippet below: * * \code * double x, y(); @@ -824,32 +799,33 @@ class PSY_C_API DeclaratorDeclarationSyntax : public ValueDeclarationSyntax * This \a declaration declares a variable named \c x, and a function named * \c y. Specifically, the type specifier \c double is shared both declarators * (in the latter case, it states the return type of \c y). Therefore, by - * providing only a "variable and/or function" syntax, we keep the AST consistent - * and rewritable, without introducing artificial artifacts. + * providing only a "variable and/or function" syntax, we keep the AST + * consistent and rewritable, without introducing artificial artifacts. * * \remark 6.7.6-2 * * \note Similar to: * - \c clang::VarDecl and \c clang::FunctionDecl of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax and - * \c Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax of Roslyn. + * \c Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax of + * Roslyn. */ -class PSY_C_API VariableAndOrFunctionDeclarationSyntax : public DeclaratorDeclarationSyntax -{ - AST_NODE_1K(VariableAndOrFunctionDeclaration, DeclaratorDeclaration) +class PSY_C_API VariableAndOrFunctionDeclarationSyntax + : public DeclaratorDeclarationSyntax { + AST_NODE_1K(VariableAndOrFunctionDeclaration, DeclaratorDeclaration) public: - const SpecifierListSyntax* specifiers() const { return specs_; } - const DeclaratorListSyntax* declarators() const { return decltors_; } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + const SpecifierListSyntax *specifiers() const { return specs_; } + const DeclaratorListSyntax *declarators() const { return decltors_; } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - SpecifierListSyntax* specs_ = nullptr; - DeclaratorListSyntax* decltors_ = nullptr; - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(specs_, decltors_, semicolonTkIdx_) + SpecifierListSyntax *specs_ = nullptr; + DeclaratorListSyntax *decltors_ = nullptr; + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(specs_, decltors_, semicolonTkIdx_) - mutable SymbolList* syms_ = nullptr; + mutable SymbolList *syms_ = nullptr; }; /** @@ -863,24 +839,22 @@ class PSY_C_API VariableAndOrFunctionDeclarationSyntax : public DeclaratorDeclar * \note Similar to: * - \c clang::FieldDecl of LLVM/Clang. */ -class PSY_C_API FieldDeclarationSyntax final : public DeclaratorDeclarationSyntax -{ - AST_NODE_1K(FieldDeclaration, DeclaratorDeclaration) +class PSY_C_API FieldDeclarationSyntax final + : public DeclaratorDeclarationSyntax { + AST_NODE_1K(FieldDeclaration, DeclaratorDeclaration) public: - const SpecifierListSyntax* specifiers() const { return specs_; } - const DeclaratorListSyntax* declarators() const { return decltors_; } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + const SpecifierListSyntax *specifiers() const { return specs_; } + const DeclaratorListSyntax *declarators() const { return decltors_; } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - SpecifierListSyntax* specs_ = nullptr; - DeclaratorListSyntax* decltors_ = nullptr; - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(specs_, - decltors_, - semicolonTkIdx_) - - mutable SymbolList* syms_ = nullptr; + SpecifierListSyntax *specs_ = nullptr; + DeclaratorListSyntax *decltors_ = nullptr; + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(specs_, decltors_, semicolonTkIdx_) + + mutable SymbolList *syms_ = nullptr; }; /** @@ -892,20 +866,20 @@ class PSY_C_API FieldDeclarationSyntax final : public DeclaratorDeclarationSynta * - \c clang::ParmVarDecl of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax of Roslyn. */ -class PSY_C_API ParameterDeclarationSyntax final : public DeclaratorDeclarationSyntax -{ - AST_NODE_1K(ParameterDeclaration, DeclaratorDeclaration) +class PSY_C_API ParameterDeclarationSyntax final + : public DeclaratorDeclarationSyntax { + AST_NODE_1K(ParameterDeclaration, DeclaratorDeclaration) public: - const SpecifierListSyntax* specifiers() const { return specs_; } - const DeclaratorSyntax* declarator() const { return decltor_; } + const SpecifierListSyntax *specifiers() const { return specs_; } + const DeclaratorSyntax *declarator() const { return decltor_; } private: - SpecifierListSyntax* specs_ = nullptr; - DeclaratorSyntax* decltor_ = nullptr; - AST_CHILD_LST2(specs_, decltor_) + SpecifierListSyntax *specs_ = nullptr; + DeclaratorSyntax *decltor_ = nullptr; + AST_CHILD_LST2(specs_, decltor_) - mutable ParameterSymbol* sym_ = nullptr; + mutable ParameterSymbol *sym_ = nullptr; }; /** @@ -913,34 +887,34 @@ class PSY_C_API ParameterDeclarationSyntax final : public DeclaratorDeclarationS * * \remark 6.7.10 */ -class PSY_C_API StaticAssertDeclarationSyntax final : public DeclarationSyntax -{ - AST_NODE_1K(StaticAssertDeclaration, Declaration) +class PSY_C_API StaticAssertDeclarationSyntax final : public DeclarationSyntax { + AST_NODE_1K(StaticAssertDeclaration, Declaration) public: - SyntaxToken staticAssertKeyword() const { return tokenAtIndex(staticAssertKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } - const ExpressionSyntax* stringLiteral() const { return strLit_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + SyntaxToken staticAssertKeyword() const { + return tokenAtIndex(staticAssertKwTkIdx_); + } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } + const ExpressionSyntax *stringLiteral() const { return strLit_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - LexedTokens::IndexType staticAssertKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* strLit_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST7(staticAssertKwTkIdx_, - openParenTkIdx_, - expr_, - commaTkIdx_, - strLit_, - closeParenTkIdx_, - semicolonTkIdx_); + LexedTokens::IndexType staticAssertKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *strLit_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST7(staticAssertKwTkIdx_, openParenTkIdx_, expr_, commaTkIdx_, + strLit_, closeParenTkIdx_, semicolonTkIdx_); }; /** @@ -950,24 +924,25 @@ class PSY_C_API StaticAssertDeclarationSyntax final : public DeclarationSyntax * * \remark 6.9.1 */ -class PSY_C_API FunctionDefinitionSyntax final : public DeclarationSyntax -{ - AST_NODE_1K(FunctionDefinition, Declaration) +class PSY_C_API FunctionDefinitionSyntax final : public DeclarationSyntax { + AST_NODE_1K(FunctionDefinition, Declaration) public: - const SpecifierListSyntax* specifiers() const { return specs_; } - const DeclaratorSyntax* declarator() const { return decltor_; } - const ExtKR_ParameterDeclarationListSyntax* extKR_params() const { return extKR_params_; } - const StatementSyntax* body() const { return body_; } + const SpecifierListSyntax *specifiers() const { return specs_; } + const DeclaratorSyntax *declarator() const { return decltor_; } + const ExtKR_ParameterDeclarationListSyntax *extKR_params() const { + return extKR_params_; + } + const StatementSyntax *body() const { return body_; } private: - SpecifierListSyntax* specs_ = nullptr; - DeclaratorSyntax* decltor_ = nullptr; - ExtKR_ParameterDeclarationListSyntax* extKR_params_ = nullptr; - StatementSyntax* body_ = nullptr; - AST_CHILD_LST4(specs_, decltor_, extKR_params_, body_); + SpecifierListSyntax *specs_ = nullptr; + DeclaratorSyntax *decltor_ = nullptr; + ExtKR_ParameterDeclarationListSyntax *extKR_params_ = nullptr; + StatementSyntax *body_ = nullptr; + AST_CHILD_LST4(specs_, decltor_, extKR_params_, body_); - mutable FunctionSymbol* sym_; + mutable FunctionSymbol *sym_; }; /** @@ -983,22 +958,26 @@ class PSY_C_API FunctionDefinitionSyntax final : public DeclarationSyntax * \note Similar to: * - \c clang::FileScopeAsmDecl of LLVM/Clang. */ -class PSY_C_API ExtGNU_AsmStatementDeclarationSyntax final : public DeclarationSyntax -{ - AST_NODE_1K(ExtGNU_AsmStatementDeclaration, Declaration) +class PSY_C_API ExtGNU_AsmStatementDeclarationSyntax final + : public DeclarationSyntax { + AST_NODE_1K(ExtGNU_AsmStatementDeclaration, Declaration) public: - SyntaxToken asmKeyword() const { return tokenAtIndex(asmTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const SyntaxNode* stringLiteral() const { return strLit_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken asmKeyword() const { return tokenAtIndex(asmTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const SyntaxNode *stringLiteral() const { return strLit_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType asmTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* strLit_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST4(asmTkIdx_, openParenTkIdx_, strLit_, closeParenTkIdx_); + LexedTokens::IndexType asmTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *strLit_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST4(asmTkIdx_, openParenTkIdx_, strLit_, closeParenTkIdx_); }; /** @@ -1006,18 +985,18 @@ class PSY_C_API ExtGNU_AsmStatementDeclarationSyntax final : public DeclarationS * * A Psyche-C \c _Template extension \a declaration. */ -class PSY_C_API ExtPSY_TemplateDeclarationSyntax final : public DeclarationSyntax -{ - AST_NODE_1K(ExtPSY_TemplateDeclaration, Declaration) +class PSY_C_API ExtPSY_TemplateDeclarationSyntax final + : public DeclarationSyntax { + AST_NODE_1K(ExtPSY_TemplateDeclaration, Declaration) public: - SyntaxToken templateToken() const { return tokenAtIndex(templateTkIdx_); } - const DeclarationSyntax* declaration() const { return decl_; } + SyntaxToken templateToken() const { return tokenAtIndex(templateTkIdx_); } + const DeclarationSyntax *declaration() const { return decl_; } private: - LexedTokens::IndexType templateTkIdx_ = LexedTokens::invalidIndex(); - DeclarationSyntax* decl_ = nullptr; - AST_CHILD_LST2(templateTkIdx_, decl_) + LexedTokens::IndexType templateTkIdx_ = LexedTokens::invalidIndex(); + DeclarationSyntax *decl_ = nullptr; + AST_CHILD_LST2(templateTkIdx_, decl_) }; /** @@ -1035,33 +1014,32 @@ class PSY_C_API ExtPSY_TemplateDeclarationSyntax final : public DeclarationSynta * } * \endcode */ -class PSY_C_API ExtKR_ParameterDeclarationSyntax final : public DeclaratorDeclarationSyntax -{ - AST_NODE_1K(ExtKR_ParameterDeclaration, DeclaratorDeclaration) +class PSY_C_API ExtKR_ParameterDeclarationSyntax final + : public DeclaratorDeclarationSyntax { + AST_NODE_1K(ExtKR_ParameterDeclaration, DeclaratorDeclaration) public: - const SpecifierListSyntax* specifiers() const { return specs_; } - const DeclaratorListSyntax* declarators() const { return decltors_; } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + const SpecifierListSyntax *specifiers() const { return specs_; } + const DeclaratorListSyntax *declarators() const { return decltors_; } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - SpecifierListSyntax* specs_ = nullptr; - DeclaratorListSyntax* decltors_ = nullptr; - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(specs_, decltors_, semicolonTkIdx_) + SpecifierListSyntax *specs_ = nullptr; + DeclaratorListSyntax *decltors_ = nullptr; + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(specs_, decltors_, semicolonTkIdx_) }; /* Initializers */ -class PSY_C_API ExpressionInitializerSyntax final : public InitializerSyntax -{ - AST_NODE_1K(ExpressionInitializer, Initializer) +class PSY_C_API ExpressionInitializerSyntax final : public InitializerSyntax { + AST_NODE_1K(ExpressionInitializer, Initializer) public: - const ExpressionSyntax* expression() const { return expr_; } + const ExpressionSyntax *expression() const { return expr_; } private: - ExpressionSyntax* expr_ = nullptr; - AST_CHILD_LST1(expr_); + ExpressionSyntax *expr_ = nullptr; + AST_CHILD_LST1(expr_); }; /** @@ -1076,20 +1054,19 @@ class PSY_C_API ExpressionInitializerSyntax final : public InitializerSyntax * \note Similar to: * - \c clang::InitListExpr of LLMV/Clang. */ -class BraceEnclosedInitializerSyntax final : public InitializerSyntax -{ - AST_NODE_1K(BraceEnclosedInitializer, Initializer) +class BraceEnclosedInitializerSyntax final : public InitializerSyntax { + AST_NODE_1K(BraceEnclosedInitializer, Initializer) public: - SyntaxToken openBraceToken() const { return tokenAtIndex(openBraceTkIdx_); } - const InitializerListSyntax* initializerList() const { return initList_; } - SyntaxToken closeBraceToken() const { return tokenAtIndex(closeBraceTkIdx_); } + SyntaxToken openBraceToken() const { return tokenAtIndex(openBraceTkIdx_); } + const InitializerListSyntax *initializerList() const { return initList_; } + SyntaxToken closeBraceToken() const { return tokenAtIndex(closeBraceTkIdx_); } private: - LexedTokens::IndexType openBraceTkIdx_ = LexedTokens::invalidIndex(); - InitializerListSyntax* initList_ = nullptr; - LexedTokens::IndexType closeBraceTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(openBraceTkIdx_, initList_, closeBraceTkIdx_) + LexedTokens::IndexType openBraceTkIdx_ = LexedTokens::invalidIndex(); + InitializerListSyntax *initList_ = nullptr; + LexedTokens::IndexType closeBraceTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(openBraceTkIdx_, initList_, closeBraceTkIdx_) }; /** @@ -1104,24 +1081,22 @@ class BraceEnclosedInitializerSyntax final : public InitializerSyntax * * \note Similar to: * - \c clang::DesignatedInitExpr of LLMV/Clang. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax of + * Roslyn. */ -class DesignatedInitializerSyntax final : public InitializerSyntax -{ - AST_NODE_1K(DesignatedInitializer, Initializer) +class DesignatedInitializerSyntax final : public InitializerSyntax { + AST_NODE_1K(DesignatedInitializer, Initializer) public: - const DesignatorListSyntax* designators() const { return desigs_; } - SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } - const InitializerSyntax* initializer() const { return init_; } + const DesignatorListSyntax *designators() const { return desigs_; } + SyntaxToken equalsToken() const { return tokenAtIndex(equalsTkIdx_); } + const InitializerSyntax *initializer() const { return init_; } private: - DesignatorListSyntax* desigs_ = nullptr; - LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); - InitializerSyntax* init_ = nullptr; - AST_CHILD_LST3(desigs_, - equalsTkIdx_, - init_); + DesignatorListSyntax *desigs_ = nullptr; + LexedTokens::IndexType equalsTkIdx_ = LexedTokens::invalidIndex(); + InitializerSyntax *init_ = nullptr; + AST_CHILD_LST3(desigs_, equalsTkIdx_, init_); }; /** @@ -1132,9 +1107,8 @@ class DesignatedInitializerSyntax final : public InitializerSyntax * \note Similar to: * - \c clang::DesignatedInitExpr::Designator of LLMV/Clang. */ -class DesignatorSyntax : public SyntaxNode -{ - AST_G_NODE(Designator) +class DesignatorSyntax : public SyntaxNode { + AST_G_NODE(Designator) }; /** @@ -1148,19 +1122,17 @@ class DesignatorSyntax : public SyntaxNode * \note Similar to: * - \c clang::DesignatedInitExpr::FieldDesignator of LLMV/Clang. */ -class FieldDesignatorSyntax final : public DesignatorSyntax -{ - AST_NODE_1K(FieldDesignator, Designator) +class FieldDesignatorSyntax final : public DesignatorSyntax { + AST_NODE_1K(FieldDesignator, Designator) public: - SyntaxToken dotToken() const { return tokenAtIndex(dotTkIdx_); } - SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } + SyntaxToken dotToken() const { return tokenAtIndex(dotTkIdx_); } + SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } private: - LexedTokens::IndexType dotTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST2(dotTkIdx_, - identTkIdx_); + LexedTokens::IndexType dotTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST2(dotTkIdx_, identTkIdx_); }; /** @@ -1175,45 +1147,44 @@ class FieldDesignatorSyntax final : public DesignatorSyntax * \note Similar to: * - \c clang::DesignatedInitExpr::ArrayOrRangeDesignator of LLMV/Clang. */ -class ArrayDesignatorSyntax final : public DesignatorSyntax -{ - AST_NODE_1K(ArrayDesignator, Designator) +class ArrayDesignatorSyntax final : public DesignatorSyntax { + AST_NODE_1K(ArrayDesignator, Designator) public: - SyntaxToken openBracketToken() const { return tokenAtIndex(openBracketTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken closeBracketToken() const { return tokenAtIndex(closeBracketTkIdx_); } + SyntaxToken openBracketToken() const { + return tokenAtIndex(openBracketTkIdx_); + } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken closeBracketToken() const { + return tokenAtIndex(closeBracketTkIdx_); + } public: - LexedTokens::IndexType openBracketTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType closeBracketTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(openBracketTkIdx_, - expr_, - closeBracketTkIdx_); + LexedTokens::IndexType openBracketTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType closeBracketTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(openBracketTkIdx_, expr_, closeBracketTkIdx_); }; /** * \brief The OffsetOfDesignatorSyntax class. * */ -class OffsetOfDesignatorSyntax final : public DesignatorSyntax -{ - AST_NODE_1K(OffsetOfDesignator, Designator) +class OffsetOfDesignatorSyntax final : public DesignatorSyntax { + AST_NODE_1K(OffsetOfDesignator, Designator) public: - SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } - const DesignatorListSyntax* designators() const { return desigs_; } + SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } + const DesignatorListSyntax *designators() const { return desigs_; } private: - LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); - DesignatorListSyntax* desigs_ = nullptr; + LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); + DesignatorListSyntax *desigs_ = nullptr; - AST_CHILD_LST2(identTkIdx_, desigs_) + AST_CHILD_LST2(identTkIdx_, desigs_) }; - -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxNodes_Expressions.h b/C/syntax/SyntaxNodes_Expressions.h index 15d1033e3..ba6b757b5 100644 --- a/C/syntax/SyntaxNodes_Expressions.h +++ b/C/syntax/SyntaxNodes_Expressions.h @@ -23,8 +23,8 @@ #define PSYCHE_C_SYNTAX_NODES_EXPRESSIONS_H__ #include "SyntaxNode.h" -#include "SyntaxNodes_Statements.h" #include "SyntaxNodes_MIXIN.h" +#include "SyntaxNodes_Statements.h" #include "SyntaxToken.h" #include "SyntaxTree.h" @@ -67,23 +67,23 @@ namespace C { * \see LanguageExtensions::enable_NativeBooleans * * \note Similar to: - * - \c clang::IntegerLiteral, \c clang::FloatingLiteral, \c clang::CharacterLiteral, and - * \c clang::CXXBoolLiteralExpr of LLVM/Clang. - * - \c clang::syntax::IntegerLiteralExpression, \c clang::syntax::FloatingLiteralExpression, - * \c clang::syntax::CharacterLiteralExpression, and \c clang::syntax::BoolLiteralExpression - * of Clang's Libtooling. + * - \c clang::IntegerLiteral, \c clang::FloatingLiteral, \c + * clang::CharacterLiteral, and \c clang::CXXBoolLiteralExpr of LLVM/Clang. + * - \c clang::syntax::IntegerLiteralExpression, \c + * clang::syntax::FloatingLiteralExpression, \c + * clang::syntax::CharacterLiteralExpression, and \c + * clang::syntax::BoolLiteralExpression of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.LiteralExpressionSyntax of Roslyn. */ -class PSY_C_API ConstantExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_NK(ConstantExpression, Expression) +class PSY_C_API ConstantExpressionSyntax final : public ExpressionSyntax { + AST_NODE_NK(ConstantExpression, Expression) public: - SyntaxToken constantToken() const { return tokenAtIndex(constantTkIdx_); } + SyntaxToken constantToken() const { return tokenAtIndex(constantTkIdx_); } private: - LexedTokens::IndexType constantTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST1(constantTkIdx_) + LexedTokens::IndexType constantTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST1(constantTkIdx_) }; /** @@ -103,19 +103,18 @@ class PSY_C_API ConstantExpressionSyntax final : public ExpressionSyntax * - \c clang::syntax::StringLiteralExpression of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.LiteralExpressionSyntax of Roslyn. */ -class PSY_C_API StringLiteralExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(StringLiteralExpression, Expression) +class PSY_C_API StringLiteralExpressionSyntax final : public ExpressionSyntax { + AST_NODE_1K(StringLiteralExpression, Expression) public: - SyntaxToken literalToken() const { return tokenAtIndex(litTkIdx_); } - StringLiteralExpressionSyntax* adjacent() const { return adjacent_; } + SyntaxToken literalToken() const { return tokenAtIndex(litTkIdx_); } + StringLiteralExpressionSyntax *adjacent() const { return adjacent_; } private: - LexedTokens::IndexType litTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST1(litTkIdx_) + LexedTokens::IndexType litTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST1(litTkIdx_) - StringLiteralExpressionSyntax* adjacent_ = nullptr; + StringLiteralExpressionSyntax *adjacent_ = nullptr; }; /** @@ -126,9 +125,8 @@ class PSY_C_API StringLiteralExpressionSyntax final : public ExpressionSyntax * \note Similar to: * - \c Microsoft.CodeAnalysis.CSharp.Syntax.NameSyntax of Roslyn. */ -class PSY_C_API NameSyntax : public ExpressionSyntax -{ - AST_NODE(Name, Expression) +class PSY_C_API NameSyntax : public ExpressionSyntax { + AST_NODE(Name, Expression) }; /** @@ -145,16 +143,15 @@ class PSY_C_API NameSyntax : public ExpressionSyntax * - \c clang::syntax::IdExpression of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax of Roslyn. */ -class PSY_C_API IdentifierNameSyntax final : public NameSyntax -{ - AST_NODE_1K(IdentifierName, Name) +class PSY_C_API IdentifierNameSyntax final : public NameSyntax { + AST_NODE_1K(IdentifierName, Name) public: - SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } + SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } private: - LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST1(identTkIdx_) + LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST1(identTkIdx_) }; /** @@ -166,16 +163,15 @@ class PSY_C_API IdentifierNameSyntax final : public NameSyntax * __PRETTY_FUNCTION__ * \endcode */ -class PSY_C_API PredefinedNameSyntax final : public NameSyntax -{ - AST_NODE_1K(PredefinedName, Name) +class PSY_C_API PredefinedNameSyntax final : public NameSyntax { + AST_NODE_1K(PredefinedName, Name) public: - SyntaxToken predefinedToken() const { return tokenAtIndex(predefTkIdx_); } + SyntaxToken predefinedToken() const { return tokenAtIndex(predefTkIdx_); } private: - LexedTokens::IndexType predefTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST1(predefTkIdx_) + LexedTokens::IndexType predefTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST1(predefTkIdx_) }; /** @@ -192,24 +188,26 @@ class PSY_C_API PredefinedNameSyntax final : public NameSyntax * \note Similar to: * - \c clang::ParenExpr of LLVM/Clang. * - \c clang::syntax::ParenExpression of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedExpressionSyntax of + * Roslyn. */ -class PSY_C_API ParenthesizedExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(ParenthesizedExpression, Expression) +class PSY_C_API ParenthesizedExpressionSyntax final : public ExpressionSyntax { + AST_NODE_1K(ParenthesizedExpression, Expression) public: - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(openParenTkIdx_, - expr_, - closeParenTkIdx_) + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(openParenTkIdx_, expr_, closeParenTkIdx_) }; /** @@ -220,31 +218,31 @@ class PSY_C_API ParenthesizedExpressionSyntax final : public ExpressionSyntax * \note Similar to: * - \c clang:GenericSelectionExpr of LLVM/Clang. */ -class PSY_C_API GenericSelectionExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(GenericSelectionExpression, Expression) +class PSY_C_API GenericSelectionExpressionSyntax final + : public ExpressionSyntax { + AST_NODE_1K(GenericSelectionExpression, Expression) public: - SyntaxToken genericKeyword() const { return tokenAtIndex(genericKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } - const GenericAssociationListSyntax* associations() const { return assocs_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken genericKeyword() const { return tokenAtIndex(genericKwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } + const GenericAssociationListSyntax *associations() const { return assocs_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType genericKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); - GenericAssociationListSyntax* assocs_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST6(genericKwTkIdx_, - openParenTkIdx_, - expr_, - commaTkIdx_, - assocs_, - closeParenTkIdx_) + LexedTokens::IndexType genericKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); + GenericAssociationListSyntax *assocs_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST6(genericKwTkIdx_, openParenTkIdx_, expr_, commaTkIdx_, assocs_, + closeParenTkIdx_) }; /** @@ -252,20 +250,19 @@ class PSY_C_API GenericSelectionExpressionSyntax final : public ExpressionSyntax * * \remark 6.5.1.1 */ -class PSY_C_API GenericAssociationSyntax final : public SyntaxNode -{ - AST_G_NODE_NK(GenericAssociation) +class PSY_C_API GenericAssociationSyntax final : public SyntaxNode { + AST_G_NODE_NK(GenericAssociation) public: - const SyntaxNode* typeName_or_default() const { return typeName_or_default_; } - SyntaxToken colonToken() const { return tokenAtIndex(colonTkIdx_); } - const ExpressionSyntax * expression() const { return expr_; } + const SyntaxNode *typeName_or_default() const { return typeName_or_default_; } + SyntaxToken colonToken() const { return tokenAtIndex(colonTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } private: - SyntaxNode* typeName_or_default_ = nullptr; - LexedTokens::IndexType colonTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - AST_CHILD_LST3(typeName_or_default_, colonTkIdx_, expr_) + SyntaxNode *typeName_or_default_ = nullptr; + LexedTokens::IndexType colonTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + AST_CHILD_LST3(typeName_or_default_, colonTkIdx_, expr_) }; /** @@ -274,20 +271,24 @@ class PSY_C_API GenericAssociationSyntax final : public SyntaxNode * \attention This is a GNU extension: * https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs */ -class PSY_C_API ExtGNU_EnclosedCompoundStatementExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(ExtGNU_EnclosedCompoundStatementExpression, Expression) +class PSY_C_API ExtGNU_EnclosedCompoundStatementExpressionSyntax final + : public ExpressionSyntax { + AST_NODE_1K(ExtGNU_EnclosedCompoundStatementExpression, Expression) public: - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const CompoundStatementSyntax* statement() const { return stmt_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const CompoundStatementSyntax *statement() const { return stmt_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - CompoundStatementSyntax* stmt_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(openParenTkIdx_, stmt_, closeParenTkIdx_) + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + CompoundStatementSyntax *stmt_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(openParenTkIdx_, stmt_, closeParenTkIdx_) }; /* Operations */ @@ -308,9 +309,8 @@ class PSY_C_API ExtGNU_EnclosedCompoundStatementExpressionSyntax final : public * - \c clang::UnaryOperator of LLVM/Clang. * - \c clang::syntax::UnaryOperatorExpression of Clang's Libtooling. */ -class PSY_C_API UnaryExpressionSyntax : public ExpressionSyntax -{ - AST_NODE(UnaryExpression, Expression) +class PSY_C_API UnaryExpressionSyntax : public ExpressionSyntax { + AST_NODE(UnaryExpression, Expression) }; /** @@ -325,22 +325,23 @@ class PSY_C_API UnaryExpressionSyntax : public ExpressionSyntax * \note Similar to: * - \c clang::UnaryOperator of LLVM/Clang. * - \c clang::syntax::PostfixUnaryOperatorExpression of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.PostfixUnaryExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.PostfixUnaryExpressionSyntax of + * Roslyn. * * \remark 6.5.2.4 */ -class PSY_C_API PostfixUnaryExpressionSyntax final : public UnaryExpressionSyntax -{ - AST_NODE_NK(PostfixUnaryExpression, UnaryExpression) +class PSY_C_API PostfixUnaryExpressionSyntax final + : public UnaryExpressionSyntax { + AST_NODE_NK(PostfixUnaryExpression, UnaryExpression) public: - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } private: - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST2(expr_, oprtrTkIdx_) + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST2(expr_, oprtrTkIdx_) }; /** @@ -359,20 +360,21 @@ class PSY_C_API PostfixUnaryExpressionSyntax final : public UnaryExpressionSynta * \note Similar to: * - \c clang::UnaryOperator of LLVM/Clang. * - \c clang::syntax::PrefixUnaryOperatorExpression of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.PrefixUnaryExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.PrefixUnaryExpressionSyntax of + * Roslyn. */ -class PSY_C_API PrefixUnaryExpressionSyntax final : public UnaryExpressionSyntax -{ - AST_NODE_NK(PrefixUnaryExpression, UnaryExpression) +class PSY_C_API PrefixUnaryExpressionSyntax final + : public UnaryExpressionSyntax { + AST_NODE_NK(PrefixUnaryExpression, UnaryExpression) public: - SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } + SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } private: - LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - AST_CHILD_LST2(oprtrTkIdx_, expr_) + LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + AST_CHILD_LST2(oprtrTkIdx_, expr_) }; /** @@ -387,24 +389,28 @@ class PSY_C_API PrefixUnaryExpressionSyntax final : public UnaryExpressionSyntax * \note Similar to: * - \c clang::ArraySubscriptExpr of LLVM/Clang. * - \c clang::syntax::ArraySubscript of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ElementAccessExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ElementAccessExpressionSyntax of + * Roslyn. */ -class PSY_C_API ArraySubscriptExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_NK(ArraySubscriptExpression, Expression) +class PSY_C_API ArraySubscriptExpressionSyntax final : public ExpressionSyntax { + AST_NODE_NK(ArraySubscriptExpression, Expression) public: - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken openBracketToken() const { return tokenAtIndex(openBracketTkIdx_); } - const ExpressionSyntax* argument() const { return arg_; } - SyntaxToken closeBracketToken() const { return tokenAtIndex(closeBracketTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken openBracketToken() const { + return tokenAtIndex(openBracketTkIdx_); + } + const ExpressionSyntax *argument() const { return arg_; } + SyntaxToken closeBracketToken() const { + return tokenAtIndex(closeBracketTkIdx_); + } private: - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType openBracketTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* arg_ = nullptr; - LexedTokens::IndexType closeBracketTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST4(expr_, openBracketTkIdx_, arg_, closeBracketTkIdx_) + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType openBracketTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *arg_ = nullptr; + LexedTokens::IndexType closeBracketTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST4(expr_, openBracketTkIdx_, arg_, closeBracketTkIdx_) }; /** @@ -420,24 +426,28 @@ class PSY_C_API ArraySubscriptExpressionSyntax final : public ExpressionSyntax * \note Similar to: * - \c clang::CallExpr in LLVM/Clang. * - \c clang::syntax::CallExpression in Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax of + * Roslyn. */ -class PSY_C_API CallExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_NK(CallExpression, Expression) +class PSY_C_API CallExpressionSyntax final : public ExpressionSyntax { + AST_NODE_NK(CallExpression, Expression) public: - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionListSyntax* arguments() const { return args_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionListSyntax *arguments() const { return args_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionListSyntax* args_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST4(expr_, openParenTkIdx_, args_, closeParenTkIdx_) + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionListSyntax *args_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST4(expr_, openParenTkIdx_, args_, closeParenTkIdx_) }; /** @@ -453,22 +463,22 @@ class PSY_C_API CallExpressionSyntax final : public ExpressionSyntax * \note Similar to: * - \c clang::MemberExpr of LLVM/Clang. * - \c clang::syntax::MemberExpression of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax of + * Roslyn. */ -class PSY_C_API MemberAccessExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_NK(MemberAccessExpression, Expression) +class PSY_C_API MemberAccessExpressionSyntax final : public ExpressionSyntax { + AST_NODE_NK(MemberAccessExpression, Expression) public: - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } - const IdentifierNameSyntax* identifier() const { return identExpr_; } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } + const IdentifierNameSyntax *identifier() const { return identExpr_; } private: - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); - IdentifierNameSyntax* identExpr_ = nullptr; - AST_CHILD_LST3(expr_, oprtrTkIdx_, identExpr_) + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); + IdentifierNameSyntax *identExpr_ = nullptr; + AST_CHILD_LST3(expr_, oprtrTkIdx_, identExpr_) }; /** @@ -479,22 +489,26 @@ class PSY_C_API MemberAccessExpressionSyntax final : public ExpressionSyntax * \note Similar to: * - \c clang::CompoundLiteralExpr of LLVM/Clang. */ -class PSY_C_API CompoundLiteralExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(CompoundLiteralExpression, Expression) +class PSY_C_API CompoundLiteralExpressionSyntax final + : public ExpressionSyntax { + AST_NODE_1K(CompoundLiteralExpression, Expression) public: - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const TypeNameSyntax* typeName() const { return typeName_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - const InitializerSyntax* initializer() const { return init_; } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const TypeNameSyntax *typeName() const { return typeName_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + const InitializerSyntax *initializer() const { return init_; } private: - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - TypeNameSyntax* typeName_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - InitializerSyntax* init_ = nullptr; - AST_CHILD_LST4(openParenTkIdx_, typeName_, closeParenTkIdx_, init_) + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + TypeNameSyntax *typeName_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + InitializerSyntax *init_ = nullptr; + AST_CHILD_LST4(openParenTkIdx_, typeName_, closeParenTkIdx_, init_) }; /** @@ -518,18 +532,17 @@ class PSY_C_API CompoundLiteralExpressionSyntax final : public ExpressionSyntax * - \c clang::syntax::PrefixUnaryOperatorExpression of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.SizeOfExpressionSyntax of Roslyn. */ -class PSY_C_API TypeTraitExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_NK(TypeTraitExpression, Expression) +class PSY_C_API TypeTraitExpressionSyntax final : public ExpressionSyntax { + AST_NODE_NK(TypeTraitExpression, Expression) public: - SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } - const TypeReferenceSyntax* tyReference() const { return tyRef_; } + SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } + const TypeReferenceSyntax *tyReference() const { return tyRef_; } private: - LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); - TypeReferenceSyntax* tyRef_ = nullptr; - AST_CHILD_LST2(oprtrTkIdx_, tyRef_); + LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); + TypeReferenceSyntax *tyRef_ = nullptr; + AST_CHILD_LST2(oprtrTkIdx_, tyRef_); }; /** @@ -546,21 +559,25 @@ class PSY_C_API TypeTraitExpressionSyntax final : public ExpressionSyntax * - \c clang::CStyleCastExpr of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.CastExpressionSyntax of Roslyn. */ -class PSY_C_API CastExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(CastExpression, Expression) +class PSY_C_API CastExpressionSyntax final : public ExpressionSyntax { + AST_NODE_1K(CastExpression, Expression) public: - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const TypeNameSyntax* typeName() const { return typeName_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const TypeNameSyntax *typeName() const { return typeName_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + const ExpressionSyntax *expression() const { return expr_; } private: - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - TypeNameSyntax* typeName_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex();; - ExpressionSyntax* expr_ = nullptr; + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + TypeNameSyntax *typeName_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + ; + ExpressionSyntax *expr_ = nullptr; }; /** @@ -581,18 +598,19 @@ class PSY_C_API CastExpressionSyntax final : public ExpressionSyntax * - \c Microsoft.CodeAnalysis.CSharp.Syntax.BinaryExpressionSyntax of Roslyn. */ class PSY_C_API BinaryExpressionSyntax - : public ExpressionSyntax - , public MIXIN_LeftExpressionInfixOperatorRightExpression -{ - AST_NODE_NK(BinaryExpression, Expression) + : public ExpressionSyntax, + public MIXIN_LeftExpressionInfixOperatorRightExpression { + AST_NODE_NK(BinaryExpression, Expression) public: - const ExpressionSyntax* left() const override { return leftExpr_; } - SyntaxToken operatorToken() const override { return tokenAtIndex(oprtrTkIdx_); } - const ExpressionSyntax* right() const override { return rightExpr_; } + const ExpressionSyntax *left() const override { return leftExpr_; } + SyntaxToken operatorToken() const override { + return tokenAtIndex(oprtrTkIdx_); + } + const ExpressionSyntax *right() const override { return rightExpr_; } private: - AST_CHILD_LST3(leftExpr_, oprtrTkIdx_, rightExpr_) + AST_CHILD_LST3(leftExpr_, oprtrTkIdx_, rightExpr_) }; /** @@ -606,25 +624,25 @@ class PSY_C_API BinaryExpressionSyntax * * \note Similar to: * - \c clang::ConditionalOperator of LLVM/Clang. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ConditionalExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ConditionalExpressionSyntax of + * Roslyn. */ -class PSY_C_API ConditionalExpressionSyntax : public ExpressionSyntax -{ - AST_NODE_1K(ConditionalExpression, Expression) +class PSY_C_API ConditionalExpressionSyntax : public ExpressionSyntax { + AST_NODE_1K(ConditionalExpression, Expression) public: - const ExpressionSyntax* condition() const { return condExpr_; } - SyntaxToken questionToken() const { return tokenAtIndex(questionTkIdx_); } - const ExpressionSyntax* whenTrue() const { return whenTrueExpr_; } - SyntaxToken colonToken() const { return tokenAtIndex(colonTkIdx_); } - const ExpressionSyntax* whenFalse() const { return whenFalseExpr_; } + const ExpressionSyntax *condition() const { return condExpr_; } + SyntaxToken questionToken() const { return tokenAtIndex(questionTkIdx_); } + const ExpressionSyntax *whenTrue() const { return whenTrueExpr_; } + SyntaxToken colonToken() const { return tokenAtIndex(colonTkIdx_); } + const ExpressionSyntax *whenFalse() const { return whenFalseExpr_; } private: - ExpressionSyntax* condExpr_ = nullptr; - LexedTokens::IndexType questionTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* whenTrueExpr_ = nullptr; - LexedTokens::IndexType colonTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* whenFalseExpr_ = nullptr; + ExpressionSyntax *condExpr_ = nullptr; + LexedTokens::IndexType questionTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *whenTrueExpr_ = nullptr; + LexedTokens::IndexType colonTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *whenFalseExpr_ = nullptr; }; /** @@ -641,21 +659,23 @@ class PSY_C_API ConditionalExpressionSyntax : public ExpressionSyntax * \note Similar to: * - \c clang::BinaryOperator of LLVM/Clang. * - \c clang::syntax::BinaryOperatorExpression of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.AssignmentExpressionSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.AssignmentExpressionSyntax of + * Roslyn. */ class PSY_C_API AssignmentExpressionSyntax final - : public ExpressionSyntax - , public MIXIN_LeftExpressionInfixOperatorRightExpression -{ - AST_NODE_NK(AssignmentExpression, Expression) + : public ExpressionSyntax, + public MIXIN_LeftExpressionInfixOperatorRightExpression { + AST_NODE_NK(AssignmentExpression, Expression) public: - const ExpressionSyntax* left() const override { return leftExpr_; } - SyntaxToken operatorToken() const override { return tokenAtIndex(oprtrTkIdx_); } - const ExpressionSyntax* right() const override { return rightExpr_; } + const ExpressionSyntax *left() const override { return leftExpr_; } + SyntaxToken operatorToken() const override { + return tokenAtIndex(oprtrTkIdx_); + } + const ExpressionSyntax *right() const override { return rightExpr_; } private: - AST_CHILD_LST3(leftExpr_, oprtrTkIdx_, rightExpr_) + AST_CHILD_LST3(leftExpr_, oprtrTkIdx_, rightExpr_) }; /** @@ -673,41 +693,43 @@ class PSY_C_API AssignmentExpressionSyntax final * - \c clang::syntax::BinaryOperatorExpression of Clang's Libtooling. */ class PSY_C_API SequencingExpressionSyntax - : public ExpressionSyntax - , public MIXIN_LeftExpressionInfixOperatorRightExpression -{ - AST_NODE_1K(SequencingExpression, Expression) + : public ExpressionSyntax, + public MIXIN_LeftExpressionInfixOperatorRightExpression { + AST_NODE_1K(SequencingExpression, Expression) public: - const ExpressionSyntax* left() const override { return leftExpr_; } - SyntaxToken operatorToken() const override { return tokenAtIndex(oprtrTkIdx_); } - const ExpressionSyntax* right() const override { return rightExpr_; } + const ExpressionSyntax *left() const override { return leftExpr_; } + SyntaxToken operatorToken() const override { + return tokenAtIndex(oprtrTkIdx_); + } + const ExpressionSyntax *right() const override { return rightExpr_; } private: - AST_CHILD_LST3(leftExpr_, oprtrTkIdx_, rightExpr_) + AST_CHILD_LST3(leftExpr_, oprtrTkIdx_, rightExpr_) }; /** * \brief The AmbiguousCastOrBinaryExpressionSyntax class. * - * Represents the ambiguous syntaxes \a cast-expression and \a binary-expression. + * Represents the ambiguous syntaxes \a cast-expression and \a + * binary-expression. * * \code * (x) + y * (x) * y * \endcode */ -class PSY_C_API AmbiguousCastOrBinaryExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_NK(AmbiguousCastOrBinaryExpression, Expression) +class PSY_C_API AmbiguousCastOrBinaryExpressionSyntax final + : public ExpressionSyntax { + AST_NODE_NK(AmbiguousCastOrBinaryExpression, Expression) public: - const CastExpressionSyntax* castExpression() const { return castExpr_; } - const BinaryExpressionSyntax* binaryExpression() const { return binExpr_; } + const CastExpressionSyntax *castExpression() const { return castExpr_; } + const BinaryExpressionSyntax *binaryExpression() const { return binExpr_; } private: - CastExpressionSyntax* castExpr_ = nullptr; - BinaryExpressionSyntax* binExpr_ = nullptr; + CastExpressionSyntax *castExpr_ = nullptr; + BinaryExpressionSyntax *binExpr_ = nullptr; }; /** @@ -718,27 +740,30 @@ class PSY_C_API AmbiguousCastOrBinaryExpressionSyntax final : public ExpressionS * \note Similar to: * - \c clang:VAArgExpr of LLVM/Clang. */ -class PSY_C_API VAArgumentExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(VAArgumentExpression, Expression) +class PSY_C_API VAArgumentExpressionSyntax final : public ExpressionSyntax { + AST_NODE_1K(VAArgumentExpression, Expression) public: - SyntaxToken keyword() const { return tokenAtIndex(kwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } - const TypeNameSyntax* typeName() const { return typeName_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken keyword() const { return tokenAtIndex(kwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } + const TypeNameSyntax *typeName() const { return typeName_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType kwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); - TypeNameSyntax* typeName_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - - AST_CHILD_LST2(expr_, typeName_) + LexedTokens::IndexType kwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); + TypeNameSyntax *typeName_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + + AST_CHILD_LST2(expr_, typeName_) }; /** @@ -754,32 +779,33 @@ class PSY_C_API VAArgumentExpressionSyntax final : public ExpressionSyntax * \note Similar to: * - \c clang::OffsetOfExpr of LLVM/Clang. */ -class PSY_C_API OffsetOfExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(OffsetOfExpression, Expression) +class PSY_C_API OffsetOfExpressionSyntax final : public ExpressionSyntax { + AST_NODE_1K(OffsetOfExpression, Expression) public: - SyntaxToken keyword() const { return tokenAtIndex(kwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const TypeNameSyntax* typeName() const { return typeName_; } - SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } - const DesignatorSyntax* offsetOfDesignator() const { return offsetOfDesignator_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken keyword() const { return tokenAtIndex(kwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const TypeNameSyntax *typeName() const { return typeName_; } + SyntaxToken commaToken() const { return tokenAtIndex(commaTkIdx_); } + const DesignatorSyntax *offsetOfDesignator() const { + return offsetOfDesignator_; + } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType kwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - TypeNameSyntax* typeName_ = nullptr; - LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); - DesignatorSyntax* offsetOfDesignator_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - - AST_CHILD_LST6(kwTkIdx_, - openParenTkIdx_, - typeName_, - commaTkIdx_, - offsetOfDesignator_, - closeParenTkIdx_) + LexedTokens::IndexType kwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + TypeNameSyntax *typeName_ = nullptr; + LexedTokens::IndexType commaTkIdx_ = LexedTokens::invalidIndex(); + DesignatorSyntax *offsetOfDesignator_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + + AST_CHILD_LST6(kwTkIdx_, openParenTkIdx_, typeName_, commaTkIdx_, + offsetOfDesignator_, closeParenTkIdx_) }; /** @@ -794,38 +820,35 @@ class PSY_C_API OffsetOfExpressionSyntax final : public ExpressionSyntax * \note Similar to: * - \c clang::ChooseExpr of LLVM/Clang. */ -class PSY_C_API ExtGNU_ChooseExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_1K(ExtGNU_ChooseExpression, Expression) +class PSY_C_API ExtGNU_ChooseExpressionSyntax final : public ExpressionSyntax { + AST_NODE_1K(ExtGNU_ChooseExpression, Expression) public: - SyntaxToken keyword() const { return tokenAtIndex(kwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* constantExpression() const { return constExpr_; } - SyntaxToken commaToken1() const { return tokenAtIndex(commaTkIdx1_); } - const ExpressionSyntax* expression1() const { return expr1_; } - SyntaxToken commaToken2() const { return tokenAtIndex(commaTkIdx2_); } - const ExpressionSyntax* expression2() const { return expr2_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken keyword() const { return tokenAtIndex(kwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *constantExpression() const { return constExpr_; } + SyntaxToken commaToken1() const { return tokenAtIndex(commaTkIdx1_); } + const ExpressionSyntax *expression1() const { return expr1_; } + SyntaxToken commaToken2() const { return tokenAtIndex(commaTkIdx2_); } + const ExpressionSyntax *expression2() const { return expr2_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType kwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* constExpr_ = nullptr; - LexedTokens::IndexType commaTkIdx1_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr1_ = nullptr; - LexedTokens::IndexType commaTkIdx2_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr2_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - - AST_CHILD_LST8(kwTkIdx_, - openParenTkIdx_, - constExpr_, - commaTkIdx1_, - expr1_, - commaTkIdx2_, - expr2_, - closeParenTkIdx_) + LexedTokens::IndexType kwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *constExpr_ = nullptr; + LexedTokens::IndexType commaTkIdx1_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr1_ = nullptr; + LexedTokens::IndexType commaTkIdx2_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr2_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + + AST_CHILD_LST8(kwTkIdx_, openParenTkIdx_, constExpr_, commaTkIdx1_, expr1_, + commaTkIdx2_, expr2_, closeParenTkIdx_) }; /** @@ -836,22 +859,22 @@ class PSY_C_API ExtGNU_ChooseExpressionSyntax final : public ExpressionSyntax * __imag__ expr * \endcode */ -class PSY_C_API ExtGNU_ComplexValuedExpressionSyntax final : public ExpressionSyntax -{ - AST_NODE_NK(ExtGNU_ComplexValuedExpression, Expression) +class PSY_C_API ExtGNU_ComplexValuedExpressionSyntax final + : public ExpressionSyntax { + AST_NODE_NK(ExtGNU_ComplexValuedExpression, Expression) public: - SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } + SyntaxToken operatorToken() const { return tokenAtIndex(oprtrTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } private: - LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; + LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; - AST_CHILD_LST2(oprtrTkIdx_, expr_) + AST_CHILD_LST2(oprtrTkIdx_, expr_) }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxNodes_MIXIN.h b/C/syntax/SyntaxNodes_MIXIN.h index f755cb6cf..ccc37dfcc 100644 --- a/C/syntax/SyntaxNodes_MIXIN.h +++ b/C/syntax/SyntaxNodes_MIXIN.h @@ -28,33 +28,31 @@ namespace psy { namespace C { -class MIXIN_LeftExpressionInfixOperatorRightExpression -{ +class MIXIN_LeftExpressionInfixOperatorRightExpression { protected: - friend class Parser; - friend class Disambiguator; + friend class Parser; + friend class Disambiguator; - virtual const ExpressionSyntax* left() const = 0; - virtual SyntaxToken operatorToken() const = 0; - virtual const ExpressionSyntax* right() const = 0; + virtual const ExpressionSyntax *left() const = 0; + virtual SyntaxToken operatorToken() const = 0; + virtual const ExpressionSyntax *right() const = 0; - ExpressionSyntax* leftExpr_ = nullptr; - LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* rightExpr_ = nullptr; + ExpressionSyntax *leftExpr_ = nullptr; + LexedTokens::IndexType oprtrTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *rightExpr_ = nullptr; }; -class MIXIN_GNUExtensionFlag -{ +class MIXIN_GNUExtensionFlag { protected: - friend class Parser; - friend class Disambiguator; + friend class Parser; + friend class Disambiguator; - virtual SyntaxToken extensionKeyword() const = 0; + virtual SyntaxToken extensionKeyword() const = 0; - LexedTokens::IndexType extKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType extKwTkIdx_ = LexedTokens::invalidIndex(); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxNodes_Statements.h b/C/syntax/SyntaxNodes_Statements.h index 8d36d9bc5..ac036ddc7 100644 --- a/C/syntax/SyntaxNodes_Statements.h +++ b/C/syntax/SyntaxNodes_Statements.h @@ -44,25 +44,21 @@ namespace C { * - \c clang::syntax::LabelStmt of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.LabeledStatementSyntax of Roslyn. */ -class PSY_C_API LabeledStatementSyntax final : public StatementSyntax -{ - AST_NODE_NK(LabeledStatement, Statement) +class PSY_C_API LabeledStatementSyntax final : public StatementSyntax { + AST_NODE_NK(LabeledStatement, Statement) public: - SyntaxToken labelToken() const { return tokenAtIndex(labelTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken colonToken() const { return tokenAtIndex(colonTkIdx_); } - const StatementSyntax* statement() const { return stmt_; } + SyntaxToken labelToken() const { return tokenAtIndex(labelTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken colonToken() const { return tokenAtIndex(colonTkIdx_); } + const StatementSyntax *statement() const { return stmt_; } private: - LexedTokens::IndexType labelTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType colonTkIdx_ = LexedTokens::invalidIndex(); - StatementSyntax* stmt_ = nullptr; - AST_CHILD_LST4(labelTkIdx_, - expr_, - colonTkIdx_, - stmt_) + LexedTokens::IndexType labelTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType colonTkIdx_ = LexedTokens::invalidIndex(); + StatementSyntax *stmt_ = nullptr; + AST_CHILD_LST4(labelTkIdx_, expr_, colonTkIdx_, stmt_) }; /** @@ -74,22 +70,19 @@ class PSY_C_API LabeledStatementSyntax final : public StatementSyntax * - \c clang::CompoundStmt of LLVM/Clang. * - \c clang::syntax::CompoundStatement of Clang's Libtooling. */ -class PSY_C_API CompoundStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(CompoundStatement, Statement) +class PSY_C_API CompoundStatementSyntax final : public StatementSyntax { + AST_NODE_1K(CompoundStatement, Statement) public: - SyntaxToken openBraceToken() const { return tokenAtIndex(openBraceTkIdx_); } - const StatementListSyntax* statements() const { return stmts_; } - SyntaxToken closeBraceToken() const { return tokenAtIndex(closeBraceTkIdx_); } + SyntaxToken openBraceToken() const { return tokenAtIndex(openBraceTkIdx_); } + const StatementListSyntax *statements() const { return stmts_; } + SyntaxToken closeBraceToken() const { return tokenAtIndex(closeBraceTkIdx_); } private: - LexedTokens::IndexType openBraceTkIdx_ = LexedTokens::invalidIndex(); - StatementListSyntax* stmts_ = nullptr; - LexedTokens::IndexType closeBraceTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(openBraceTkIdx_, - stmts_, - closeBraceTkIdx_) + LexedTokens::IndexType openBraceTkIdx_ = LexedTokens::invalidIndex(); + StatementListSyntax *stmts_ = nullptr; + LexedTokens::IndexType closeBraceTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(openBraceTkIdx_, stmts_, closeBraceTkIdx_) }; /** @@ -103,18 +96,18 @@ class PSY_C_API CompoundStatementSyntax final : public StatementSyntax * \note Similar to: * - \c clang::DeclStmt of LLVM/Clang. * - \c clang::syntax::DeclarationStatement of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax of + * Roslyn. */ -class PSY_C_API DeclarationStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(DeclarationStatement, Statement) +class PSY_C_API DeclarationStatementSyntax final : public StatementSyntax { + AST_NODE_1K(DeclarationStatement, Statement) public: - const DeclarationSyntax* declaration() const { return decl_; } + const DeclarationSyntax *declaration() const { return decl_; } private: - DeclarationSyntax* decl_ = nullptr; - AST_CHILD_LST1(decl_) + DeclarationSyntax *decl_ = nullptr; + AST_CHILD_LST1(decl_) }; /** @@ -124,20 +117,20 @@ class PSY_C_API DeclarationStatementSyntax final : public StatementSyntax * * \note Similar to: * - \c clang::syntax::ExpressionStatement of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax of + * Roslyn. */ -class PSY_C_API ExpressionStatementSyntax : public StatementSyntax -{ - AST_NODE_1K(ExpressionStatement, Statement) +class PSY_C_API ExpressionStatementSyntax : public StatementSyntax { + AST_NODE_1K(ExpressionStatement, Statement) public: - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST2(expr_, semicolonTkIdx_) + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST2(expr_, semicolonTkIdx_) }; /** @@ -156,18 +149,22 @@ class PSY_C_API ExpressionStatementSyntax : public StatementSyntax * x * y ; * \endcode */ -class PSY_C_API AmbiguousExpressionOrDeclarationStatementSyntax final : public StatementSyntax -{ - AST_NODE_NK(AmbiguousExpressionOrDeclarationStatement, Statement) +class PSY_C_API AmbiguousExpressionOrDeclarationStatementSyntax final + : public StatementSyntax { + AST_NODE_NK(AmbiguousExpressionOrDeclarationStatement, Statement) public: - const DeclarationStatementSyntax* declarationStatement() const { return declStmt_; } - const ExpressionStatementSyntax* expressionStatement() const { return exprStmt_; } + const DeclarationStatementSyntax *declarationStatement() const { + return declStmt_; + } + const ExpressionStatementSyntax *expressionStatement() const { + return exprStmt_; + } private: - DeclarationStatementSyntax* declStmt_ = nullptr; - ExpressionStatementSyntax* exprStmt_ = nullptr; - AST_CHILD_LST2(declStmt_, exprStmt_) + DeclarationStatementSyntax *declStmt_ = nullptr; + ExpressionStatementSyntax *exprStmt_ = nullptr; + AST_CHILD_LST2(declStmt_, exprStmt_) }; /** @@ -178,36 +175,35 @@ class PSY_C_API AmbiguousExpressionOrDeclarationStatementSyntax final : public S * \note Similar to: * - \c clang::IfStmt of LLVM/Clang. * - \c clang::syntax::IfStatement of Clang's Libtooling. - * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax of Roslyn. + * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax of + * Roslyn. */ -class PSY_C_API IfStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(IfStatement, Statement) +class PSY_C_API IfStatementSyntax final : public StatementSyntax { + AST_NODE_1K(IfStatement, Statement) public: - SyntaxToken ifKeyword() const { return tokenAtIndex(ifKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - ExpressionSyntax* condition() const { return cond_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - StatementSyntax* statement() const { return stmt_; } - SyntaxToken elseKeyword() const { return tokenAtIndex(elseKwTkIdx_); } - StatementSyntax* elseStatement() const { return elseStmt_; } + SyntaxToken ifKeyword() const { return tokenAtIndex(ifKwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + ExpressionSyntax *condition() const { return cond_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + StatementSyntax *statement() const { return stmt_; } + SyntaxToken elseKeyword() const { return tokenAtIndex(elseKwTkIdx_); } + StatementSyntax *elseStatement() const { return elseStmt_; } public: - LexedTokens::IndexType ifKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* cond_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - StatementSyntax* stmt_ = nullptr; - LexedTokens::IndexType elseKwTkIdx_ = LexedTokens::invalidIndex(); - StatementSyntax* elseStmt_ = nullptr; - AST_CHILD_LST7(ifKwTkIdx_, - openParenTkIdx_, - cond_, - closeParenTkIdx_, - stmt_, - elseKwTkIdx_, - elseStmt_) + LexedTokens::IndexType ifKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *cond_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + StatementSyntax *stmt_ = nullptr; + LexedTokens::IndexType elseKwTkIdx_ = LexedTokens::invalidIndex(); + StatementSyntax *elseStmt_ = nullptr; + AST_CHILD_LST7(ifKwTkIdx_, openParenTkIdx_, cond_, closeParenTkIdx_, stmt_, + elseKwTkIdx_, elseStmt_) }; /** @@ -220,28 +216,28 @@ class PSY_C_API IfStatementSyntax final : public StatementSyntax * - \c clang::syntax::SwitchStatement of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.SwitchStatementSyntax of Roslyn. */ -class PSY_C_API SwitchStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(SwitchStatement, Statement) +class PSY_C_API SwitchStatementSyntax final : public StatementSyntax { + AST_NODE_1K(SwitchStatement, Statement) public: - SyntaxToken switchKeyword() const { return tokenAtIndex(switchKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* condition() const { return cond_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - const StatementSyntax* statement() const { return stmt_; } + SyntaxToken switchKeyword() const { return tokenAtIndex(switchKwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *condition() const { return cond_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + const StatementSyntax *statement() const { return stmt_; } public: - LexedTokens::IndexType switchKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* cond_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - StatementSyntax* stmt_ = nullptr; - AST_CHILD_LST5(switchKwTkIdx_, - openParenTkIdx_, - cond_, - closeParenTkIdx_, - stmt_) + LexedTokens::IndexType switchKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *cond_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + StatementSyntax *stmt_ = nullptr; + AST_CHILD_LST5(switchKwTkIdx_, openParenTkIdx_, cond_, closeParenTkIdx_, + stmt_) }; /** @@ -254,28 +250,27 @@ class PSY_C_API SwitchStatementSyntax final : public StatementSyntax * - \c clang::syntax::WhileStatement of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.WhileStatementSyntax of Roslyn. */ -class PSY_C_API WhileStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(WhileStatement, Statement) +class PSY_C_API WhileStatementSyntax final : public StatementSyntax { + AST_NODE_1K(WhileStatement, Statement) public: - SyntaxToken whileKeyword() const { return tokenAtIndex(whileKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* condition() const { return cond_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - const StatementSyntax* statement() const { return stmt_; } + SyntaxToken whileKeyword() const { return tokenAtIndex(whileKwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *condition() const { return cond_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + const StatementSyntax *statement() const { return stmt_; } private: - LexedTokens::IndexType whileKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* cond_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - StatementSyntax* stmt_ = nullptr; - AST_CHILD_LST5(whileKwTkIdx_, - openParenTkIdx_, - cond_, - closeParenTkIdx_, - stmt_) + LexedTokens::IndexType whileKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *cond_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + StatementSyntax *stmt_ = nullptr; + AST_CHILD_LST5(whileKwTkIdx_, openParenTkIdx_, cond_, closeParenTkIdx_, stmt_) }; /** @@ -287,34 +282,32 @@ class PSY_C_API WhileStatementSyntax final : public StatementSyntax * - \c clang::DoStmt of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.DoStatementSyntax of Roslyn. */ -class PSY_C_API DoStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(DoStatement, Statement) +class PSY_C_API DoStatementSyntax final : public StatementSyntax { + AST_NODE_1K(DoStatement, Statement) public: - SyntaxToken doKeyword() const { return tokenAtIndex(doKwTkIdx_); } - const StatementSyntax* statement() const { return stmt_; } - SyntaxToken whileKeyword() const { return tokenAtIndex(whileKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* condition() const { return cond_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + SyntaxToken doKeyword() const { return tokenAtIndex(doKwTkIdx_); } + const StatementSyntax *statement() const { return stmt_; } + SyntaxToken whileKeyword() const { return tokenAtIndex(whileKwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *condition() const { return cond_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - LexedTokens::IndexType doKwTkIdx_ = LexedTokens::invalidIndex(); - StatementSyntax* stmt_ = nullptr; - LexedTokens::IndexType whileKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* cond_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST7(doKwTkIdx_, - stmt_, - whileKwTkIdx_, - openParenTkIdx_, - cond_, - closeParenTkIdx_, - semicolonTkIdx_) + LexedTokens::IndexType doKwTkIdx_ = LexedTokens::invalidIndex(); + StatementSyntax *stmt_ = nullptr; + LexedTokens::IndexType whileKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *cond_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST7(doKwTkIdx_, stmt_, whileKwTkIdx_, openParenTkIdx_, cond_, + closeParenTkIdx_, semicolonTkIdx_) }; /** @@ -327,40 +320,36 @@ class PSY_C_API DoStatementSyntax final : public StatementSyntax * - \c clang::syntax::ForStatement of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ForStatementSyntax of Roslyn. */ -class PSY_C_API ForStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(ForStatement, Statement) +class PSY_C_API ForStatementSyntax final : public StatementSyntax { + AST_NODE_1K(ForStatement, Statement) public: - SyntaxToken forKeyword() const { return tokenAtIndex(forKwTkIdx_); } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - SyntaxToken extensionKeyword() const { return tokenAtIndex(extKwTkIdx_); } - const StatementSyntax* initializer() const { return initStmt_; } - const ExpressionSyntax* condition() const { return cond_; } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - const StatementSyntax* statement() const { return stmt_; } + SyntaxToken forKeyword() const { return tokenAtIndex(forKwTkIdx_); } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + SyntaxToken extensionKeyword() const { return tokenAtIndex(extKwTkIdx_); } + const StatementSyntax *initializer() const { return initStmt_; } + const ExpressionSyntax *condition() const { return cond_; } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + const StatementSyntax *statement() const { return stmt_; } private: - LexedTokens::IndexType forKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType extKwTkIdx_ = LexedTokens::invalidIndex(); - StatementSyntax* initStmt_ = nullptr; - ExpressionSyntax* cond_ = nullptr; - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - StatementSyntax* stmt_ = nullptr; - AST_CHILD_LST9(forKwTkIdx_, - openParenTkIdx_, - extKwTkIdx_, - initStmt_, - cond_, - semicolonTkIdx_, - expr_, - closeParenTkIdx_, - stmt_) + LexedTokens::IndexType forKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType extKwTkIdx_ = LexedTokens::invalidIndex(); + StatementSyntax *initStmt_ = nullptr; + ExpressionSyntax *cond_ = nullptr; + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + StatementSyntax *stmt_ = nullptr; + AST_CHILD_LST9(forKwTkIdx_, openParenTkIdx_, extKwTkIdx_, initStmt_, cond_, + semicolonTkIdx_, expr_, closeParenTkIdx_, stmt_) }; /** @@ -372,19 +361,18 @@ class PSY_C_API ForStatementSyntax final : public StatementSyntax * - \c clang::GotoStmt of LLVM/Clang. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.GotoStatementSyntax of Roslyn. */ -class PSY_C_API GotoStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(GotoStatement, Statement) +class PSY_C_API GotoStatementSyntax final : public StatementSyntax { + AST_NODE_1K(GotoStatement, Statement) public: - SyntaxToken gotoKeyword() const { return tokenAtIndex(gotoKwTkIdx_); } - SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + SyntaxToken gotoKeyword() const { return tokenAtIndex(gotoKwTkIdx_); } + SyntaxToken identifierToken() const { return tokenAtIndex(identTkIdx_); } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - LexedTokens::IndexType gotoKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType gotoKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType identTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); }; /** @@ -397,19 +385,17 @@ class PSY_C_API GotoStatementSyntax final : public StatementSyntax * - \c clang::syntax::ContinueStatement of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ContinueStatementSyntax of Roslyn. */ -class PSY_C_API ContinueStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(ContinueStatement, Statement) +class PSY_C_API ContinueStatementSyntax final : public StatementSyntax { + AST_NODE_1K(ContinueStatement, Statement) public: - SyntaxToken continueKeyword() const { return tokenAtIndex(continueKwTkIdx_); } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + SyntaxToken continueKeyword() const { return tokenAtIndex(continueKwTkIdx_); } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } public: - LexedTokens::IndexType continueKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST2(continueKwTkIdx_, - semicolonTkIdx_) + LexedTokens::IndexType continueKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST2(continueKwTkIdx_, semicolonTkIdx_) }; /** @@ -422,19 +408,17 @@ class PSY_C_API ContinueStatementSyntax final : public StatementSyntax * - \c clang::syntax::BreakStatement of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.BreakStatementSyntax of Roslyn. */ -class PSY_C_API BreakStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(BreakStatement, Statement) +class PSY_C_API BreakStatementSyntax final : public StatementSyntax { + AST_NODE_1K(BreakStatement, Statement) public: - SyntaxToken breakKeyword() const { return tokenAtIndex(breakKwTkIdx_); } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + SyntaxToken breakKeyword() const { return tokenAtIndex(breakKwTkIdx_); } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - LexedTokens::IndexType breakKwTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST2(breakKwTkIdx_, - semicolonTkIdx_) + LexedTokens::IndexType breakKwTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST2(breakKwTkIdx_, semicolonTkIdx_) }; /** @@ -447,48 +431,52 @@ class PSY_C_API BreakStatementSyntax final : public StatementSyntax * - \c clang::syntax::ReturnStatement of Clang's Libtooling. * - \c Microsoft.CodeAnalysis.CSharp.Syntax.ReturnStatementSyntax of Roslyn. */ -class PSY_C_API ReturnStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(ReturnStatement, Statement) +class PSY_C_API ReturnStatementSyntax final : public StatementSyntax { + AST_NODE_1K(ReturnStatement, Statement) public: - SyntaxToken returnKeyword() const { return tokenAtIndex(returnKwTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + SyntaxToken returnKeyword() const { return tokenAtIndex(returnKwTkIdx_); } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } public: - LexedTokens::IndexType returnKwTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - AST_CHILD_LST3(returnKwTkIdx_, - expr_, - semicolonTkIdx_) + LexedTokens::IndexType returnKwTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); + AST_CHILD_LST3(returnKwTkIdx_, expr_, semicolonTkIdx_) }; /** * \brief The ExtGNU_AsmOperandSyntax class. */ -class PSY_C_API ExtGNU_AsmOperandSyntax final : public SyntaxNode -{ - AST_G_NODE_NK(ExtGNU_AsmOperand) +class PSY_C_API ExtGNU_AsmOperandSyntax final : public SyntaxNode { + AST_G_NODE_NK(ExtGNU_AsmOperand) public: - SyntaxToken openBracketToken() const { return tokenAtIndex(openBracketTkIdx_); } - const ExpressionSyntax* identifier() const { return identExpr_; } - SyntaxToken closeBracketToken() const { return tokenAtIndex(closeBracketTkIdx_); } - const ExpressionSyntax* stringLiteral() const { return strLit_; } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* expression() const { return expr_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } + SyntaxToken openBracketToken() const { + return tokenAtIndex(openBracketTkIdx_); + } + const ExpressionSyntax *identifier() const { return identExpr_; } + SyntaxToken closeBracketToken() const { + return tokenAtIndex(closeBracketTkIdx_); + } + const ExpressionSyntax *stringLiteral() const { return strLit_; } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *expression() const { return expr_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } private: - LexedTokens::IndexType openBracketTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* identExpr_ = nullptr; - LexedTokens::IndexType closeBracketTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* strLit_ = nullptr; - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* expr_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType openBracketTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *identExpr_ = nullptr; + LexedTokens::IndexType closeBracketTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *strLit_ = nullptr; + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *expr_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); }; /** @@ -501,53 +489,57 @@ class PSY_C_API ExtGNU_AsmOperandSyntax final : public SyntaxNode * * \see ExtGNU_AsmStatementDeclarationSyntax */ -class PSY_C_API ExtGNU_AsmStatementSyntax final : public StatementSyntax -{ - AST_NODE_1K(ExtGNU_AsmStatement, Statement) +class PSY_C_API ExtGNU_AsmStatementSyntax final : public StatementSyntax { + AST_NODE_1K(ExtGNU_AsmStatement, Statement) public: - SyntaxToken asmKeyword() const { return tokenAtIndex(asmKwTkIdx_); } - const SpecifierListSyntax* asmQualifiers() const { return asmQuals_; } - SyntaxToken openParenthesisToken() const { return tokenAtIndex(openParenTkIdx_); } - const ExpressionSyntax* stringLiteral() const { return strLit_; } - SyntaxToken colon1Token() const { return tokenAtIndex(colon1TkIdx_); } - const ExtGNU_AsmOperandListSyntax* outputOperands() const { return outOprds_; } - SyntaxToken colon2Token() const { return tokenAtIndex(colon2TkIdx_); } - const ExtGNU_AsmOperandListSyntax* inputOperands() const { return inOprds_; } - SyntaxToken colon3Token() const { return tokenAtIndex(colon3TkIdx_); } - const ExpressionListSyntax* clobbers() const { return clobs_; } - SyntaxToken colon4Token() const { return tokenAtIndex(colon4TkIdx_); } - const ExpressionListSyntax* gotoLabels() const { return labels_; } - SyntaxToken closeParenthesisToken() const { return tokenAtIndex(closeParenTkIdx_); } - SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } + SyntaxToken asmKeyword() const { return tokenAtIndex(asmKwTkIdx_); } + const SpecifierListSyntax *asmQualifiers() const { return asmQuals_; } + SyntaxToken openParenthesisToken() const { + return tokenAtIndex(openParenTkIdx_); + } + const ExpressionSyntax *stringLiteral() const { return strLit_; } + SyntaxToken colon1Token() const { return tokenAtIndex(colon1TkIdx_); } + const ExtGNU_AsmOperandListSyntax *outputOperands() const { + return outOprds_; + } + SyntaxToken colon2Token() const { return tokenAtIndex(colon2TkIdx_); } + const ExtGNU_AsmOperandListSyntax *inputOperands() const { return inOprds_; } + SyntaxToken colon3Token() const { return tokenAtIndex(colon3TkIdx_); } + const ExpressionListSyntax *clobbers() const { return clobs_; } + SyntaxToken colon4Token() const { return tokenAtIndex(colon4TkIdx_); } + const ExpressionListSyntax *gotoLabels() const { return labels_; } + SyntaxToken closeParenthesisToken() const { + return tokenAtIndex(closeParenTkIdx_); + } + SyntaxToken semicolonToken() const { return tokenAtIndex(semicolonTkIdx_); } private: - LexedTokens::IndexType asmKwTkIdx_ = LexedTokens::invalidIndex(); - SpecifierListSyntax* asmQuals_ = nullptr; - LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); - ExpressionSyntax* strLit_ = nullptr; - LexedTokens::IndexType colon1TkIdx_ = LexedTokens::invalidIndex(); - ExtGNU_AsmOperandListSyntax* outOprds_ = nullptr; - LexedTokens::IndexType colon2TkIdx_ = LexedTokens::invalidIndex(); - ExtGNU_AsmOperandListSyntax* inOprds_ = nullptr; - LexedTokens::IndexType colon3TkIdx_ = LexedTokens::invalidIndex(); - ExpressionListSyntax* clobs_ = nullptr; - LexedTokens::IndexType colon4TkIdx_ = LexedTokens::invalidIndex(); - ExpressionListSyntax* labels_ = nullptr; - LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); - LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); - + LexedTokens::IndexType asmKwTkIdx_ = LexedTokens::invalidIndex(); + SpecifierListSyntax *asmQuals_ = nullptr; + LexedTokens::IndexType openParenTkIdx_ = LexedTokens::invalidIndex(); + ExpressionSyntax *strLit_ = nullptr; + LexedTokens::IndexType colon1TkIdx_ = LexedTokens::invalidIndex(); + ExtGNU_AsmOperandListSyntax *outOprds_ = nullptr; + LexedTokens::IndexType colon2TkIdx_ = LexedTokens::invalidIndex(); + ExtGNU_AsmOperandListSyntax *inOprds_ = nullptr; + LexedTokens::IndexType colon3TkIdx_ = LexedTokens::invalidIndex(); + ExpressionListSyntax *clobs_ = nullptr; + LexedTokens::IndexType colon4TkIdx_ = LexedTokens::invalidIndex(); + ExpressionListSyntax *labels_ = nullptr; + LexedTokens::IndexType closeParenTkIdx_ = LexedTokens::invalidIndex(); + LexedTokens::IndexType semicolonTkIdx_ = LexedTokens::invalidIndex(); }; -class PSY_C_API ExtGNU_AsmQualifierSyntax final : public TrivialSpecifierSyntax -{ - AST_NODE_NK(ExtGNU_AsmQualifier, TrivialSpecifier) +class PSY_C_API ExtGNU_AsmQualifierSyntax final + : public TrivialSpecifierSyntax { + AST_NODE_NK(ExtGNU_AsmQualifier, TrivialSpecifier) public: - SyntaxToken asmQualifier() const { return tokenAtIndex(specTkIdx_); } + SyntaxToken asmQualifier() const { return tokenAtIndex(specTkIdx_); } }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxReference.cpp b/C/syntax/SyntaxReference.cpp index d71b0ad08..15c6e50fe 100644 --- a/C/syntax/SyntaxReference.cpp +++ b/C/syntax/SyntaxReference.cpp @@ -23,12 +23,6 @@ using namespace psy; using namespace C; -const SyntaxTree* SyntaxReference::syntaxTree() const -{ - return nullptr; -} +const SyntaxTree *SyntaxReference::syntaxTree() const { return nullptr; } -const SyntaxNode* SyntaxReference::syntax() const -{ - return nullptr; -} +const SyntaxNode *SyntaxReference::syntax() const { return nullptr; } diff --git a/C/syntax/SyntaxReference.h b/C/syntax/SyntaxReference.h index 6be182ff3..b2a954e4a 100644 --- a/C/syntax/SyntaxReference.h +++ b/C/syntax/SyntaxReference.h @@ -34,21 +34,20 @@ namespace C { * This API is inspired by that of \c Microsoft.CodeAnalysis.SyntaxReference * from Roslyn, the .NET Compiler Platform. */ -class PSY_C_API SyntaxReference -{ +class PSY_C_API SyntaxReference { public: - /** - * The SyntaxTree referenced by \c this SyntaxReference. - */ - const SyntaxTree* syntaxTree() const; + /** + * The SyntaxTree referenced by \c this SyntaxReference. + */ + const SyntaxTree *syntaxTree() const; - /** - * The SyntaxNode referenced by \c this SyntaxReference. - */ - const SyntaxNode* syntax() const; + /** + * The SyntaxNode referenced by \c this SyntaxReference. + */ + const SyntaxNode *syntax() const; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxToken.cpp b/C/syntax/SyntaxToken.cpp index 1223167d1..1dbb1a8e8 100644 --- a/C/syntax/SyntaxToken.cpp +++ b/C/syntax/SyntaxToken.cpp @@ -29,8 +29,7 @@ namespace psy { namespace C { -const char* tokenNames[] = -{ +const char *tokenNames[] = { // ----------------------------------------------------------------- // // These must be ordered as according to the SyntaxKind enumerators. // // ----------------------------------------------------------------- // @@ -75,7 +74,7 @@ const char* tokenNames[] = "#", "##", - ";", + ";", "auto", "break", @@ -210,258 +209,222 @@ const char* tokenNames[] = "_Template", "_Forall", "_Exists", - "" -}; + ""}; -} // C -} // psy +} // namespace C +} // namespace psy using namespace psy; using namespace C; -SyntaxToken::SyntaxToken(SyntaxTree* tree) - : tree_(tree) - , rawSyntaxK_(0) - , byteSize_(0) - , charSize_(0) - , byteOffset_(0) - , charOffset_(0) - , matchingBracket_(0) - , BF_all_(0) - , lineno_(0) - , column_(0) - , lexeme_(nullptr) -{ - if (!tree_) - BF_.missing_ = true; +SyntaxToken::SyntaxToken(SyntaxTree *tree) + : tree_(tree), rawSyntaxK_(0), byteSize_(0), charSize_(0), byteOffset_(0), + charOffset_(0), matchingBracket_(0), BF_all_(0), lineno_(0), column_(0), + lexeme_(nullptr) { + if (!tree_) + BF_.missing_ = true; } -SyntaxToken::~SyntaxToken() -{} - -void SyntaxToken::setup() -{ - rawSyntaxK_ = 0; - byteSize_ = 0; - charSize_ = 0; - byteOffset_ = 0; - charOffset_ = 0; - matchingBracket_ = 0; - BF_all_ = 0; - lexeme_ = nullptr; +SyntaxToken::~SyntaxToken() {} + +void SyntaxToken::setup() { + rawSyntaxK_ = 0; + byteSize_ = 0; + charSize_ = 0; + byteOffset_ = 0; + charOffset_ = 0; + matchingBracket_ = 0; + BF_all_ = 0; + lexeme_ = nullptr; } -bool SyntaxToken::isComment() const -{ - return rawSyntaxK_ == MultiLineCommentTrivia - || rawSyntaxK_ == MultiLineDocumentationCommentTrivia - || rawSyntaxK_ == SingleLineCommentTrivia - || rawSyntaxK_ == SingleLineDocumentationCommentTrivia - || rawSyntaxK_ == Keyword_ExtPSY_omission; +bool SyntaxToken::isComment() const { + return rawSyntaxK_ == MultiLineCommentTrivia || + rawSyntaxK_ == MultiLineDocumentationCommentTrivia || + rawSyntaxK_ == SingleLineCommentTrivia || + rawSyntaxK_ == SingleLineDocumentationCommentTrivia || + rawSyntaxK_ == Keyword_ExtPSY_omission; } -Location SyntaxToken::location() const -{ - LinePosition lineStart(lineno_, column_); - LinePosition lineEnd(lineno_, column_ + byteSize_ - 1); // TODO: Account for joined tokens. - FileLinePositionSpan fileLineSpan(tree_->filePath(), lineStart, lineEnd); +Location SyntaxToken::location() const { + LinePosition lineStart(lineno_, column_); + LinePosition lineEnd(lineno_, column_ + byteSize_ - + 1); // TODO: Account for joined tokens. + FileLinePositionSpan fileLineSpan(tree_->filePath(), lineStart, lineEnd); - return Location::create(fileLineSpan); + return Location::create(fileLineSpan); } -SyntaxToken::Category SyntaxToken::category() const -{ - return category(SyntaxKind(rawSyntaxK_)); +SyntaxToken::Category SyntaxToken::category() const { + return category(SyntaxKind(rawSyntaxK_)); } -SyntaxToken::Category SyntaxToken::category(SyntaxKind k) -{ - switch (k) { - case IdentifierToken: - return Category::Identifiers; - - case IntegerConstantToken: - case FloatingConstantToken: - case CharacterConstantToken: - case CharacterConstant_L_Token: - case CharacterConstant_u_Token: - case CharacterConstant_U_Token: - case ImaginaryIntegerConstantToken: - case ImaginaryFloatingConstantToken: - return Category::Constants; - - case StringLiteralToken: - case StringLiteral_L_Token: - case StringLiteral_u8_Token: - case StringLiteral_u_Token: - case StringLiteral_U_Token: - case StringLiteral_R_Token: - case StringLiteral_LR_Token: - case StringLiteral_u8R_Token: - case StringLiteral_uR_Token: - case StringLiteral_UR_Token: - return Category::StringLiterals; - - case EllipsisToken: - case OpenBraceToken: - case CloseBraceToken: - case OpenBracketToken: - case CloseBracketToken: - case OpenParenToken: - case CloseParenToken: - - case HashToken: - case HashHashToken: - - case SemicolonToken: - - case ArrowToken: - case DotToken: - - case PlusPlusToken: - case MinusMinusToken: - - case AsteriskToken: - case AmpersandToken: - - case PlusToken: - case MinusToken: - case TildeToken: - case SlashToken: - case PercentToken: - case LessThanLessThanToken: - case GreaterThanGreaterThanToken: - case BarToken: - case CaretToken: - - case ExclamationToken: - case AmpersandAmpersandToken: - case BarBarToken: - - case LessThanToken: - case LessThanEqualsToken: - case GreaterThanToken: - case GreaterThanEqualsToken: - case EqualsEqualsToken: - case ExclamationEqualsToken: - - case ColonToken: - case QuestionToken: - - case EqualsToken: - case AsteriskEqualsToken: - case SlashEqualsToken: - case PercentEqualsToken: - case PlusEqualsToken: - case MinusEqualsToken: - case LessThanLessThanEqualsToken: - case GreaterThanGreaterThanEqualsToken: - case AmpersandEqualsToken: - case CaretEqualsToken: - case BarEqualsToken: - case CommaToken: - return Category::Punctuators; - - default: - if (k > STARTof_KeywordOrPunctuatorToken - && k <= ENDof_KeywordOrPunctuatorToken) - return Category::Keywords; - return Category::Unrecognized; - } +SyntaxToken::Category SyntaxToken::category(SyntaxKind k) { + switch (k) { + case IdentifierToken: + return Category::Identifiers; + + case IntegerConstantToken: + case FloatingConstantToken: + case CharacterConstantToken: + case CharacterConstant_L_Token: + case CharacterConstant_u_Token: + case CharacterConstant_U_Token: + case ImaginaryIntegerConstantToken: + case ImaginaryFloatingConstantToken: + return Category::Constants; + + case StringLiteralToken: + case StringLiteral_L_Token: + case StringLiteral_u8_Token: + case StringLiteral_u_Token: + case StringLiteral_U_Token: + case StringLiteral_R_Token: + case StringLiteral_LR_Token: + case StringLiteral_u8R_Token: + case StringLiteral_uR_Token: + case StringLiteral_UR_Token: + return Category::StringLiterals; + + case EllipsisToken: + case OpenBraceToken: + case CloseBraceToken: + case OpenBracketToken: + case CloseBracketToken: + case OpenParenToken: + case CloseParenToken: + + case HashToken: + case HashHashToken: + + case SemicolonToken: + + case ArrowToken: + case DotToken: + + case PlusPlusToken: + case MinusMinusToken: + + case AsteriskToken: + case AmpersandToken: + + case PlusToken: + case MinusToken: + case TildeToken: + case SlashToken: + case PercentToken: + case LessThanLessThanToken: + case GreaterThanGreaterThanToken: + case BarToken: + case CaretToken: + + case ExclamationToken: + case AmpersandAmpersandToken: + case BarBarToken: + + case LessThanToken: + case LessThanEqualsToken: + case GreaterThanToken: + case GreaterThanEqualsToken: + case EqualsEqualsToken: + case ExclamationEqualsToken: + + case ColonToken: + case QuestionToken: + + case EqualsToken: + case AsteriskEqualsToken: + case SlashEqualsToken: + case PercentEqualsToken: + case PlusEqualsToken: + case MinusEqualsToken: + case LessThanLessThanEqualsToken: + case GreaterThanGreaterThanEqualsToken: + case AmpersandEqualsToken: + case CaretEqualsToken: + case BarEqualsToken: + case CommaToken: + return Category::Punctuators; + + default: + if (k > STARTof_KeywordOrPunctuatorToken && + k <= ENDof_KeywordOrPunctuatorToken) + return Category::Keywords; + return Category::Unrecognized; + } } -SyntaxLexeme* SyntaxToken::valueLexeme() const -{ - return lexeme_; +SyntaxLexeme *SyntaxToken::valueLexeme() const { return lexeme_; } + +std::string SyntaxToken::valueText() const { return valueText_c_str(); } + +const char *SyntaxToken::valueText_c_str() const { + switch (rawSyntaxK_) { + case IdentifierToken: + case IntegerConstantToken: + case FloatingConstantToken: + case CharacterConstantToken: + case CharacterConstant_L_Token: + case CharacterConstant_u_Token: + case CharacterConstant_U_Token: + case ImaginaryIntegerConstantToken: + case ImaginaryFloatingConstantToken: + case StringLiteralToken: + case StringLiteral_L_Token: + case StringLiteral_u8_Token: + case StringLiteral_u_Token: + case StringLiteral_U_Token: + case StringLiteral_R_Token: + case StringLiteral_LR_Token: + case StringLiteral_u8R_Token: + case StringLiteral_uR_Token: + case StringLiteral_UR_Token: + return lexeme_->c_str(); + + default: + return tokenNames[rawSyntaxK_]; + } } -std::string SyntaxToken::valueText() const -{ - return valueText_c_str(); -} - -const char* SyntaxToken::valueText_c_str() const -{ - switch (rawSyntaxK_) { - case IdentifierToken: - case IntegerConstantToken: - case FloatingConstantToken: - case CharacterConstantToken: - case CharacterConstant_L_Token: - case CharacterConstant_u_Token: - case CharacterConstant_U_Token: - case ImaginaryIntegerConstantToken: - case ImaginaryFloatingConstantToken: - case StringLiteralToken: - case StringLiteral_L_Token: - case StringLiteral_u8_Token: - case StringLiteral_u_Token: - case StringLiteral_U_Token: - case StringLiteral_R_Token: - case StringLiteral_LR_Token: - case StringLiteral_u8R_Token: - case StringLiteral_uR_Token: - case StringLiteral_UR_Token: - return lexeme_->c_str(); - - default: - return tokenNames[rawSyntaxK_]; - } -} +bool SyntaxToken::isValid() const { return tree_ != nullptr; } -bool SyntaxToken::isValid() const -{ - return tree_ != nullptr; -} +TextSpan SyntaxToken::span() const { return TextSpan(charStart(), charEnd()); } -TextSpan SyntaxToken::span() const -{ - return TextSpan(charStart(), charEnd()); -} - -SyntaxToken SyntaxToken::invalid() -{ - return SyntaxToken(nullptr); -} +SyntaxToken SyntaxToken::invalid() { return SyntaxToken(nullptr); } namespace psy { namespace C { -bool operator==(const SyntaxToken& a, const SyntaxToken& b) -{ - return a.tree_ == b.tree_ - && a.rawSyntaxK_ == b.rawSyntaxK_ - && a.byteOffset_ == b.byteOffset_ - && a.byteSize_ == b.byteSize_; +bool operator==(const SyntaxToken &a, const SyntaxToken &b) { + return a.tree_ == b.tree_ && a.rawSyntaxK_ == b.rawSyntaxK_ && + a.byteOffset_ == b.byteOffset_ && a.byteSize_ == b.byteSize_; } -bool operator!=(const SyntaxToken& a, const SyntaxToken& b) -{ - return !(a == b); +bool operator!=(const SyntaxToken &a, const SyntaxToken &b) { + return !(a == b); } -std::string to_string(SyntaxToken::Category category) -{ - switch (category) { - case SyntaxToken::Category::Keywords: - return "[keywords]"; +std::string to_string(SyntaxToken::Category category) { + switch (category) { + case SyntaxToken::Category::Keywords: + return "[keywords]"; - case SyntaxToken::Category::Identifiers: - return "[identifiers]"; + case SyntaxToken::Category::Identifiers: + return "[identifiers]"; - case SyntaxToken::Category::Constants: - return "[constants]"; + case SyntaxToken::Category::Constants: + return "[constants]"; - case SyntaxToken::Category::StringLiterals: - return "[string literals]"; + case SyntaxToken::Category::StringLiterals: + return "[string literals]"; - case SyntaxToken::Category::Punctuators: - return "[punctuators]"; + case SyntaxToken::Category::Punctuators: + return "[punctuators]"; - default: - return "[unrecognized]"; - } + default: + return "[unrecognized]"; + } } -} // C -} // psy +} // namespace C +} // namespace psy diff --git a/C/syntax/SyntaxToken.h b/C/syntax/SyntaxToken.h index 95ee7ea9c..e521a1b96 100644 --- a/C/syntax/SyntaxToken.h +++ b/C/syntax/SyntaxToken.h @@ -50,231 +50,226 @@ namespace C { * Influence by the API of Clang/LLVM is present as well; specifically: * \c clang::Token and \c clang::Preprocessor. */ -class PSY_C_API SyntaxToken -{ - friend bool operator==(const SyntaxToken& a, const SyntaxToken& b); +class PSY_C_API SyntaxToken { + friend bool operator==(const SyntaxToken &a, const SyntaxToken &b); public: - ~SyntaxToken(); - - /** - * The SyntaxKind of \c this SyntaxToken. - */ - SyntaxKind kind() const { return SyntaxKind(rawSyntaxK_); } - - /** - * Whether \c this SyntaxToken is of SyntaxKind \p k. - */ - bool isKind(SyntaxKind k) { return kind() == k; } - - /** - * The raw kind of \c this SyntaxToken. - */ - unsigned int rawKind() const { return rawSyntaxK_; } - - /** - * Whether \c this SyntaxToken is of the given \p rawKind. - */ - bool isRawKind(unsigned int rawKind) const { return rawSyntaxK_ == rawKind; } - - /** - * \brief The existing SyntaxToken categories. - * - * \remark 6.4-3 - */ - enum class Category - { - Keywords, - Identifiers, - Constants, - StringLiterals, - Punctuators, - Unrecognized - }; - - /** - * The Category of \c this SyntaxToken. - */ - Category category() const; - - /** - * The Category of the SyntaxToken of kind \p k. - */ - static Category category(SyntaxKind k); - - /** - * The value of \c this SyntaxToken represented by a lexeme, from which - * the actual value (e.g., an integer such as \c 42) may be obtained. - * - * \see SyntaxLexeme::value - */ - SyntaxLexeme* valueLexeme() const; - - /** - * The value of \c this SyntaxToken represented as text, by an \c std::string. - * - * \sa valueText_c_str - */ - std::string valueText() const; - - /** - * The value of \c this SyntaxToken represented as text, by C-style string. - * - * \sa valueText - */ - const char* valueText_c_str() const; - - /** - * Whether \c this SyntaxToken is at the start of a line. - */ - bool isAtStartOfLine() const { return BF_.atStartOfLine_; } - - /** - * Whether \c this SyntaxToken has any leading trivia (e.g., a whitespace). - */ - bool hasLeadingTrivia() const { return BF_.hasLeadingWS_; } - - /** - * Whether \c this SyntaxToken is joined with the previous one. - */ - bool isJoined() const { return BF_.joined_; } - - /** - * Whether \c this SyntaxToken is the result of a preprocessor expansion. - * - * \see SyntaxToken::isPPGenerated - */ - bool isPPExpanded() const { return BF_.expanded_; } - - /** - * Whether \c this SyntaxToken is the result of a preprocessor expansion - * and generated. Consider: - * - * \code{.c} - * #define FOO(a, b) a + b; - * FOO(1, 2) - * \endcode - * - * After preprocessing, we have: - * - * \code - * 1 + 2; - * \endcode - * - * Tokens \c 1, \c +, \c 2, and \c ; are all preprocessor-expanded; but - * only \c + and \c ; are both expanded and generated. - * - * \see SyntaxToken::isPPExpanded - */ - bool isPPGenerated() const { return BF_.generated_; } - - /** - * Whether \c this SyntaxToken is a comment. - */ - bool isComment() const; - - /** - * Whether \c this SyntaxToken is missing from the source. - */ - bool isMissing() const { return BF_.missing_; } - - /** - * Whether \c this SyntaxToken is valid. - * - * \see SyntaxToken::invalid - */ - bool isValid() const; - - /** - * The Location of \c this SyntaxToken. - */ - Location location() const; - - /** - * The text span of \c this SyntaxToken. - */ - TextSpan span() const; - - /** - * An invalid SyntaxToken. - */ - static SyntaxToken invalid(); - -PSY_INTERNAL_AND_RESTRICTED: - PSY_GRANT_ACCESS(SyntaxTree); - PSY_GRANT_ACCESS(SyntaxTree); - PSY_GRANT_ACCESS(SyntaxNode); - PSY_GRANT_ACCESS(Lexer); - PSY_GRANT_ACCESS(Parser); - - SyntaxToken(SyntaxTree* tree); - - void setup(); - - unsigned int byteStart() const { return byteOffset_; } - unsigned int byteEnd() const { return byteOffset_ + byteSize_; } - - unsigned int charStart() const { return charOffset_; } - unsigned int charEnd() const { return charOffset_ + charSize_; } - - SyntaxTree* tree_; - - /* - * Watch for data layout (size) before changing members or their order. - */ - - std::uint16_t rawSyntaxK_; // Keep the same underlying type of SyntaxKind. - std::uint16_t byteSize_; - std::uint16_t charSize_; - std::uint32_t byteOffset_; - std::uint32_t charOffset_; // UTF-16 - std::size_t matchingBracket_; - - struct BitFields - { - std::uint16_t atStartOfLine_ : 1; - std::uint16_t hasLeadingWS_ : 1; - std::uint16_t joined_ : 1; - std::uint16_t expanded_ : 1; - std::uint16_t generated_ : 1; - std::uint16_t missing_ : 1; - }; - union - { - std::uint16_t BF_all_; - BitFields BF_; - }; - - unsigned int lineno_; - unsigned int column_; - - union - { - SyntaxLexeme* lexeme_; - const Identifier* identifier_; - const IntegerConstant* integer_; - const FloatingConstant* floating_; - const CharacterConstant* character_; - const ImaginaryIntegerConstant* imaginaryInteger_; - const ImaginaryFloatingConstant* imaginaryFloating_; - const StringLiteral* string_; - }; + ~SyntaxToken(); + + /** + * The SyntaxKind of \c this SyntaxToken. + */ + SyntaxKind kind() const { return SyntaxKind(rawSyntaxK_); } + + /** + * Whether \c this SyntaxToken is of SyntaxKind \p k. + */ + bool isKind(SyntaxKind k) { return kind() == k; } + + /** + * The raw kind of \c this SyntaxToken. + */ + unsigned int rawKind() const { return rawSyntaxK_; } + + /** + * Whether \c this SyntaxToken is of the given \p rawKind. + */ + bool isRawKind(unsigned int rawKind) const { return rawSyntaxK_ == rawKind; } + + /** + * \brief The existing SyntaxToken categories. + * + * \remark 6.4-3 + */ + enum class Category { + Keywords, + Identifiers, + Constants, + StringLiterals, + Punctuators, + Unrecognized + }; + + /** + * The Category of \c this SyntaxToken. + */ + Category category() const; + + /** + * The Category of the SyntaxToken of kind \p k. + */ + static Category category(SyntaxKind k); + + /** + * The value of \c this SyntaxToken represented by a lexeme, from which + * the actual value (e.g., an integer such as \c 42) may be obtained. + * + * \see SyntaxLexeme::value + */ + SyntaxLexeme *valueLexeme() const; + + /** + * The value of \c this SyntaxToken represented as text, by an \c std::string. + * + * \sa valueText_c_str + */ + std::string valueText() const; + + /** + * The value of \c this SyntaxToken represented as text, by C-style string. + * + * \sa valueText + */ + const char *valueText_c_str() const; + + /** + * Whether \c this SyntaxToken is at the start of a line. + */ + bool isAtStartOfLine() const { return BF_.atStartOfLine_; } + + /** + * Whether \c this SyntaxToken has any leading trivia (e.g., a whitespace). + */ + bool hasLeadingTrivia() const { return BF_.hasLeadingWS_; } + + /** + * Whether \c this SyntaxToken is joined with the previous one. + */ + bool isJoined() const { return BF_.joined_; } + + /** + * Whether \c this SyntaxToken is the result of a preprocessor expansion. + * + * \see SyntaxToken::isPPGenerated + */ + bool isPPExpanded() const { return BF_.expanded_; } + + /** + * Whether \c this SyntaxToken is the result of a preprocessor expansion + * and generated. Consider: + * + * \code{.c} + * #define FOO(a, b) a + b; + * FOO(1, 2) + * \endcode + * + * After preprocessing, we have: + * + * \code + * 1 + 2; + * \endcode + * + * Tokens \c 1, \c +, \c 2, and \c ; are all preprocessor-expanded; but + * only \c + and \c ; are both expanded and generated. + * + * \see SyntaxToken::isPPExpanded + */ + bool isPPGenerated() const { return BF_.generated_; } + + /** + * Whether \c this SyntaxToken is a comment. + */ + bool isComment() const; + + /** + * Whether \c this SyntaxToken is missing from the source. + */ + bool isMissing() const { return BF_.missing_; } + + /** + * Whether \c this SyntaxToken is valid. + * + * \see SyntaxToken::invalid + */ + bool isValid() const; + + /** + * The Location of \c this SyntaxToken. + */ + Location location() const; + + /** + * The text span of \c this SyntaxToken. + */ + TextSpan span() const; + + /** + * An invalid SyntaxToken. + */ + static SyntaxToken invalid(); + + PSY_INTERNAL_AND_RESTRICTED : PSY_GRANT_ACCESS(SyntaxTree); + PSY_GRANT_ACCESS(SyntaxTree); + PSY_GRANT_ACCESS(SyntaxNode); + PSY_GRANT_ACCESS(Lexer); + PSY_GRANT_ACCESS(Parser); + + SyntaxToken(SyntaxTree *tree); + + void setup(); + + unsigned int byteStart() const { return byteOffset_; } + unsigned int byteEnd() const { return byteOffset_ + byteSize_; } + + unsigned int charStart() const { return charOffset_; } + unsigned int charEnd() const { return charOffset_ + charSize_; } + + SyntaxTree *tree_; + + /* + * Watch for data layout (size) before changing members or their order. + */ + + std::uint16_t rawSyntaxK_; // Keep the same underlying type of SyntaxKind. + std::uint16_t byteSize_; + std::uint16_t charSize_; + std::uint32_t byteOffset_; + std::uint32_t charOffset_; // UTF-16 + std::size_t matchingBracket_; + + struct BitFields { + std::uint16_t atStartOfLine_ : 1; + std::uint16_t hasLeadingWS_ : 1; + std::uint16_t joined_ : 1; + std::uint16_t expanded_ : 1; + std::uint16_t generated_ : 1; + std::uint16_t missing_ : 1; + }; + union { + std::uint16_t BF_all_; + BitFields BF_; + }; + + unsigned int lineno_; + unsigned int column_; + + union { + SyntaxLexeme *lexeme_; + const Identifier *identifier_; + const IntegerConstant *integer_; + const FloatingConstant *floating_; + const CharacterConstant *character_; + const ImaginaryIntegerConstant *imaginaryInteger_; + const ImaginaryFloatingConstant *imaginaryFloating_; + const StringLiteral *string_; + }; }; /** * The SyntaxKind \p kind as a \c std::string. */ -std::string PSY_C_API to_string(SyntaxKind kind); // Definition in SyntaxNode.cpp +std::string PSY_C_API +to_string(SyntaxKind kind); // Definition in SyntaxNode.cpp /** * The SyntaxToken::Category \p category as a \c std::string. */ std::string PSY_C_API to_string(SyntaxToken::Category category); -bool operator==(const SyntaxToken& a, const SyntaxToken& b); -bool operator!=(const SyntaxToken& a, const SyntaxToken& b); +bool operator==(const SyntaxToken &a, const SyntaxToken &b); +bool operator!=(const SyntaxToken &a, const SyntaxToken &b); -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxUtilities.cpp b/C/syntax/SyntaxUtilities.cpp index 3f6bf4808..7d127511e 100644 --- a/C/syntax/SyntaxUtilities.cpp +++ b/C/syntax/SyntaxUtilities.cpp @@ -26,38 +26,38 @@ using namespace psy; using namespace C; -const DeclaratorSyntax* SyntaxUtilities::innermostDeclaratorOrSelf(const DeclaratorSyntax* decltor) -{ - while (decltor) { - const DeclaratorSyntax* innerDecltor = innerDeclaratorOrSelf(decltor); - if (innerDecltor == decltor) - break; - decltor = innerDecltor; - } - return decltor; +const DeclaratorSyntax * +SyntaxUtilities::innermostDeclaratorOrSelf(const DeclaratorSyntax *decltor) { + while (decltor) { + const DeclaratorSyntax *innerDecltor = innerDeclaratorOrSelf(decltor); + if (innerDecltor == decltor) + break; + decltor = innerDecltor; + } + return decltor; } -const DeclaratorSyntax* SyntaxUtilities::innerDeclaratorOrSelf(const DeclaratorSyntax* decltor) -{ - switch (decltor->kind()) { - case PointerDeclarator: - return decltor->asPointerDeclarator()->innerDeclarator(); +const DeclaratorSyntax * +SyntaxUtilities::innerDeclaratorOrSelf(const DeclaratorSyntax *decltor) { + switch (decltor->kind()) { + case PointerDeclarator: + return decltor->asPointerDeclarator()->innerDeclarator(); - case ArrayDeclarator: - case FunctionDeclarator: - return decltor->asArrayOrFunctionDeclarator()->innerDeclarator(); + case ArrayDeclarator: + case FunctionDeclarator: + return decltor->asArrayOrFunctionDeclarator()->innerDeclarator(); - case BitfieldDeclarator: - return decltor->asBitfieldDeclarator()->innerDeclarator(); + case BitfieldDeclarator: + return decltor->asBitfieldDeclarator()->innerDeclarator(); - default: - return decltor; - } + default: + return decltor; + } } -const DeclaratorSyntax* SyntaxUtilities::strippedDeclaratorOrSelf(const DeclaratorSyntax* decltor) -{ - while (decltor && decltor->asParenthesizedDeclarator()) - decltor = decltor->asParenthesizedDeclarator()->innerDeclarator(); - return decltor; +const DeclaratorSyntax * +SyntaxUtilities::strippedDeclaratorOrSelf(const DeclaratorSyntax *decltor) { + while (decltor && decltor->asParenthesizedDeclarator()) + decltor = decltor->asParenthesizedDeclarator()->innerDeclarator(); + return decltor; } diff --git a/C/syntax/SyntaxUtilities.h b/C/syntax/SyntaxUtilities.h index 97dd44e76..b17017fc7 100644 --- a/C/syntax/SyntaxUtilities.h +++ b/C/syntax/SyntaxUtilities.h @@ -30,36 +30,40 @@ namespace C { /** * \brief The SyntaxUtilities class. */ -class PSY_C_API SyntaxUtilities -{ +class PSY_C_API SyntaxUtilities { public: - /** - * Return the \a innermost DeclaratorSyntax of the given \p decltor. - * - * \see innerDeclaratorOrSelf - */ - static const DeclaratorSyntax* innermostDeclaratorOrSelf(const DeclaratorSyntax* decltor); + /** + * Return the \a innermost DeclaratorSyntax of the given \p decltor. + * + * \see innerDeclaratorOrSelf + */ + static const DeclaratorSyntax * + innermostDeclaratorOrSelf(const DeclaratorSyntax *decltor); - /** - * Return the \a inner DeclaratorSyntax of the given \p decltor. - * - * A DeclaratorSyntax has an \a inner DeclaratorSyntax if it's one the following: - * - a PointerDeclaratorSyntax; - * - an ArrayDeclaratorSyntax; - * - a FunctionDeclaratorSyntax; - * - or a BitfieldDeclaratorSyntax. - */ - static const DeclaratorSyntax* innerDeclaratorOrSelf(const DeclaratorSyntax* decltor); + /** + * Return the \a inner DeclaratorSyntax of the given \p decltor. + * + * A DeclaratorSyntax has an \a inner DeclaratorSyntax if it's one the + * following: + * - a PointerDeclaratorSyntax; + * - an ArrayDeclaratorSyntax; + * - a FunctionDeclaratorSyntax; + * - or a BitfieldDeclaratorSyntax. + */ + static const DeclaratorSyntax * + innerDeclaratorOrSelf(const DeclaratorSyntax *decltor); - /** - * Return the \a stripped DeclaratorSyntax of the given \p decltor. - * - * A DeclaratorSyntax is \a stripped if it's not a ParenthesizedDeclaratorSyntax. - */ - static const DeclaratorSyntax* strippedDeclaratorOrSelf(const DeclaratorSyntax* decltor); + /** + * Return the \a stripped DeclaratorSyntax of the given \p decltor. + * + * A DeclaratorSyntax is \a stripped if it's not a + * ParenthesizedDeclaratorSyntax. + */ + static const DeclaratorSyntax * + strippedDeclaratorOrSelf(const DeclaratorSyntax *decltor); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxVisitor.cpp b/C/syntax/SyntaxVisitor.cpp index 01995960b..3e0ca546d 100644 --- a/C/syntax/SyntaxVisitor.cpp +++ b/C/syntax/SyntaxVisitor.cpp @@ -27,14 +27,10 @@ using namespace psy; using namespace C; -SyntaxVisitor::SyntaxVisitor(const SyntaxTree* tree) - : tree_(tree) -{} +SyntaxVisitor::SyntaxVisitor(const SyntaxTree *tree) : tree_(tree) {} -SyntaxVisitor::~SyntaxVisitor() -{} +SyntaxVisitor::~SyntaxVisitor() {} -void SyntaxVisitor::visit(const SyntaxNode* node) -{ - SyntaxNode::acceptVisitor(node, this); +void SyntaxVisitor::visit(const SyntaxNode *node) { + SyntaxNode::acceptVisitor(node, this); } diff --git a/C/syntax/SyntaxVisitor.h b/C/syntax/SyntaxVisitor.h index 4f0b0d5cf..7881af46a 100644 --- a/C/syntax/SyntaxVisitor.h +++ b/C/syntax/SyntaxVisitor.h @@ -33,164 +33,362 @@ namespace C { /** * \brief The SyntaxVisitor class. */ -class PSY_C_API SyntaxVisitor -{ +class PSY_C_API SyntaxVisitor { public: - SyntaxVisitor(const SyntaxTree* tree); - virtual ~SyntaxVisitor(); - - /** - * \brief The Action enumeration. - */ - enum class Action : std::uint8_t - { - Visit, - Skip, - Quit - }; - - virtual bool preVisit(const SyntaxNode*) { return true; } - virtual void postVisit(const SyntaxNode*) {} - - /** - * Visit the SyntaxNode \p node. - */ - void visit(const SyntaxNode* node); - - /** - * Visit the SyntaxNodePlainList \p it. - */ - template - void visit(CoreSyntaxNodeList* it) - { - for (; it; it = it->next) - visit(it->value); - } - - //--------------// - // Declarations // - //--------------// - virtual Action visitTranslationUnit(const TranslationUnitSyntax*) { return Action::Visit; } - virtual Action visitIncompleteDeclaration(const IncompleteDeclarationSyntax*) { return Action::Visit; } - virtual Action visitStructOrUnionDeclaration(const StructOrUnionDeclarationSyntax*) { return Action::Visit; } - virtual Action visitEnumDeclaration(const EnumDeclarationSyntax*) { return Action::Visit; } - virtual Action visitEnumeratorDeclaration(const EnumeratorDeclarationSyntax*) { return Action::Visit; } - virtual Action visitVariableAndOrFunctionDeclaration(const VariableAndOrFunctionDeclarationSyntax*) { return Action::Visit; } - virtual Action visitFieldDeclaration(const FieldDeclarationSyntax*) { return Action::Visit; } - virtual Action visitParameterDeclaration(const ParameterDeclarationSyntax*) { return Action::Visit; } - virtual Action visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax*) { return Action::Visit; } - virtual Action visitFunctionDefinition(const FunctionDefinitionSyntax*) { return Action::Visit; } - virtual Action visitExtPSY_TemplateDeclaration(const ExtPSY_TemplateDeclarationSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_AsmStatementDeclaration(const ExtGNU_AsmStatementDeclarationSyntax*) { return Action::Visit; } - virtual Action visitExtKR_ParameterDeclaration(const ExtKR_ParameterDeclarationSyntax*) { return Action::Visit; } - - /* Specifiers */ - virtual Action visitStorageClass(const StorageClassSyntax*) { return Action::Visit; } - virtual Action visitBuiltinTypeSpecifier(const BuiltinTypeSpecifierSyntax*) { return Action::Visit; } - virtual Action visitTagTypeSpecifier(const TagTypeSpecifierSyntax*) { return Action::Visit; } - virtual Action visitAtomicTypeSpecifier(const AtomicTypeSpecifierSyntax*) { return Action::Visit; } - virtual Action visitTypeDeclarationAsSpecifier(const TypeDeclarationAsSpecifierSyntax*) { return Action::Visit; } - virtual Action visitTypedefName(const TypedefNameSyntax*) { return Action::Visit; } - virtual Action visitTypeQualifier(const TypeQualifierSyntax*) { return Action::Visit; } - virtual Action visitFunctionSpecifier(const FunctionSpecifierSyntax*) { return Action::Visit; } - virtual Action visitAlignmentSpecifier(const AlignmentSpecifierSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_Typeof(const ExtGNU_TypeofSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_AttributeSpecifier(const ExtGNU_AttributeSpecifierSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_Attribute(const ExtGNU_AttributeSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_AsmLabel(const ExtGNU_AsmLabelSyntax*) { return Action::Visit; } - virtual Action visitExtPSY_QuantifiedTypeSpecifier(const ExtPSY_QuantifiedTypeSpecifierSyntax*) { return Action::Visit; } - - /* Declarators */ - virtual Action visitArrayOrFunctionDeclarator(const ArrayOrFunctionDeclaratorSyntax*) { return Action::Visit; } - virtual Action visitPointerDeclarator(const PointerDeclaratorSyntax*) { return Action::Visit; } - virtual Action visitParenthesizedDeclarator(const ParenthesizedDeclaratorSyntax*) { return Action::Visit; } - virtual Action visitIdentifierDeclarator(const IdentifierDeclaratorSyntax*) { return Action::Visit; } - virtual Action visitAbstractDeclarator(const AbstractDeclaratorSyntax*) { return Action::Visit; } - virtual Action visitSubscriptSuffix(const SubscriptSuffixSyntax*) { return Action::Visit; } - virtual Action visitParameterSuffix(const ParameterSuffixSyntax*) { return Action::Visit; } - virtual Action visitBitfieldDeclarator(const BitfieldDeclaratorSyntax*) { return Action::Visit; } - - /* Initializers */ - virtual Action visitExpressionInitializer(const ExpressionInitializerSyntax*) { return Action::Visit; } - virtual Action visitBraceEnclosedInitializer(const BraceEnclosedInitializerSyntax*) { return Action::Visit; } - virtual Action visitDesignatedInitializer(const DesignatedInitializerSyntax*) { return Action::Visit; } - virtual Action visitFieldDesignator(const FieldDesignatorSyntax*) { return Action::Visit; } - virtual Action visitArrayDesignator(const ArrayDesignatorSyntax*) { return Action::Visit; } - virtual Action visitOffsetOfDesignator(const OffsetOfDesignatorSyntax*) { return Action::Visit; } - - //-------------// - // Expressions // - //-------------// - virtual Action visitIdentifierName(const IdentifierNameSyntax*) { return Action::Visit; } - virtual Action visitPredefinedName(const PredefinedNameSyntax*) { return Action::Visit; } - virtual Action visitConstantExpression(const ConstantExpressionSyntax*) { return Action::Visit; } - virtual Action visitStringLiteralExpression(const StringLiteralExpressionSyntax*) { return Action::Visit; } - virtual Action visitParenthesizedExpression(const ParenthesizedExpressionSyntax*) { return Action::Visit; } - virtual Action visitGenericSelectionExpression(const GenericSelectionExpressionSyntax*) { return Action::Visit; } - virtual Action visitGenericAssociation(const GenericAssociationSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_EnclosedCompoundStatementExpression(const ExtGNU_EnclosedCompoundStatementExpressionSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_ComplexValuedExpression(const ExtGNU_ComplexValuedExpressionSyntax*) { return Action::Visit; } - - /* Operations */ - virtual Action visitPrefixUnaryExpression(const PrefixUnaryExpressionSyntax*) { return Action::Visit; } - virtual Action visitPostfixUnaryExpression(const PostfixUnaryExpressionSyntax*) { return Action::Visit; } - virtual Action visitMemberAccessExpression(const MemberAccessExpressionSyntax*) { return Action::Visit; } - virtual Action visitArraySubscriptExpression(const ArraySubscriptExpressionSyntax*) { return Action::Visit; } - virtual Action visitTypeTraitExpression(const TypeTraitExpressionSyntax*) { return Action::Visit; } - virtual Action visitCastExpression(const CastExpressionSyntax*) { return Action::Visit; } - virtual Action visitCallExpression(const CallExpressionSyntax*) { return Action::Visit; } - virtual Action visitVAArgumentExpression(const VAArgumentExpressionSyntax*) { return Action::Visit; } - virtual Action visitOffsetOfExpression(const OffsetOfExpressionSyntax*) { return Action::Visit; } - virtual Action visitCompoundLiteralExpression(const CompoundLiteralExpressionSyntax*) { return Action::Visit; } - virtual Action visitBinaryExpression(const BinaryExpressionSyntax*) { return Action::Visit; } - virtual Action visitConditionalExpression(const ConditionalExpressionSyntax*) { return Action::Visit; } - virtual Action visitAssignmentExpression(const AssignmentExpressionSyntax*) { return Action::Visit; } - virtual Action visitSequencingExpression(const SequencingExpressionSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_ChooseExpression(const ExtGNU_ChooseExpressionSyntax*) { return Action::Visit; } - - //------------// - // Statements // - //------------// - virtual Action visitCompoundStatement(const CompoundStatementSyntax*) { return Action::Visit; } - virtual Action visitDeclarationStatement(const DeclarationStatementSyntax*) { return Action::Visit; } - virtual Action visitExpressionStatement(const ExpressionStatementSyntax*) { return Action::Visit; } - virtual Action visitLabeledStatement(const LabeledStatementSyntax*) { return Action::Visit; } - virtual Action visitIfStatement(const IfStatementSyntax*) { return Action::Visit; } - virtual Action visitSwitchStatement(const SwitchStatementSyntax*) { return Action::Visit; } - virtual Action visitWhileStatement(const WhileStatementSyntax*) { return Action::Visit; } - virtual Action visitDoStatement(const DoStatementSyntax*) { return Action::Visit; } - virtual Action visitForStatement(const ForStatementSyntax*) { return Action::Visit; } - virtual Action visitGotoStatement(const GotoStatementSyntax*) { return Action::Visit; } - virtual Action visitContinueStatement(const ContinueStatementSyntax*) { return Action::Visit; } - virtual Action visitBreakStatement(const BreakStatementSyntax*) { return Action::Visit; } - virtual Action visitReturnStatement(const ReturnStatementSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_AsmStatement(const ExtGNU_AsmStatementSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_AsmQualifier(const ExtGNU_AsmQualifierSyntax*) { return Action::Visit; } - virtual Action visitExtGNU_AsmOperand(const ExtGNU_AsmOperandSyntax*) { return Action::Visit; } - - //--------// - // Common // - //--------// - virtual Action visitTypeName(const TypeNameSyntax*) { return Action::Visit; } - virtual Action visitExpressionAsTypeReference(const ExpressionAsTypeReferenceSyntax*) { return Action::Visit; } - virtual Action visitTypeNameAsTypeReference(const TypeNameAsTypeReferenceSyntax*) { return Action::Visit; } - - //-------------// - // Ambiguities // - //-------------// - virtual Action visitAmbiguousTypeNameOrExpressionAsTypeReference(const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax*) { return Action::Visit; } - virtual Action visitAmbiguousCastOrBinaryExpression(const AmbiguousCastOrBinaryExpressionSyntax*) { return Action::Visit; } - virtual Action visitAmbiguousExpressionOrDeclarationStatement(const AmbiguousExpressionOrDeclarationStatementSyntax*) { return Action::Visit; } + SyntaxVisitor(const SyntaxTree *tree); + virtual ~SyntaxVisitor(); + + /** + * \brief The Action enumeration. + */ + enum class Action : std::uint8_t { Visit, Skip, Quit }; + + virtual bool preVisit(const SyntaxNode *) { return true; } + virtual void postVisit(const SyntaxNode *) {} + + /** + * Visit the SyntaxNode \p node. + */ + void visit(const SyntaxNode *node); + + /** + * Visit the SyntaxNodePlainList \p it. + */ + template + void visit(CoreSyntaxNodeList *it) { + for (; it; it = it->next) + visit(it->value); + } + + //--------------// + // Declarations // + //--------------// + virtual Action visitTranslationUnit(const TranslationUnitSyntax *) { + return Action::Visit; + } + virtual Action + visitIncompleteDeclaration(const IncompleteDeclarationSyntax *) { + return Action::Visit; + } + virtual Action + visitStructOrUnionDeclaration(const StructOrUnionDeclarationSyntax *) { + return Action::Visit; + } + virtual Action visitEnumDeclaration(const EnumDeclarationSyntax *) { + return Action::Visit; + } + virtual Action + visitEnumeratorDeclaration(const EnumeratorDeclarationSyntax *) { + return Action::Visit; + } + virtual Action visitVariableAndOrFunctionDeclaration( + const VariableAndOrFunctionDeclarationSyntax *) { + return Action::Visit; + } + virtual Action visitFieldDeclaration(const FieldDeclarationSyntax *) { + return Action::Visit; + } + virtual Action visitParameterDeclaration(const ParameterDeclarationSyntax *) { + return Action::Visit; + } + virtual Action + visitStaticAssertDeclaration(const StaticAssertDeclarationSyntax *) { + return Action::Visit; + } + virtual Action visitFunctionDefinition(const FunctionDefinitionSyntax *) { + return Action::Visit; + } + virtual Action + visitExtPSY_TemplateDeclaration(const ExtPSY_TemplateDeclarationSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_AsmStatementDeclaration( + const ExtGNU_AsmStatementDeclarationSyntax *) { + return Action::Visit; + } + virtual Action + visitExtKR_ParameterDeclaration(const ExtKR_ParameterDeclarationSyntax *) { + return Action::Visit; + } + + /* Specifiers */ + virtual Action visitStorageClass(const StorageClassSyntax *) { + return Action::Visit; + } + virtual Action visitBuiltinTypeSpecifier(const BuiltinTypeSpecifierSyntax *) { + return Action::Visit; + } + virtual Action visitTagTypeSpecifier(const TagTypeSpecifierSyntax *) { + return Action::Visit; + } + virtual Action visitAtomicTypeSpecifier(const AtomicTypeSpecifierSyntax *) { + return Action::Visit; + } + virtual Action + visitTypeDeclarationAsSpecifier(const TypeDeclarationAsSpecifierSyntax *) { + return Action::Visit; + } + virtual Action visitTypedefName(const TypedefNameSyntax *) { + return Action::Visit; + } + virtual Action visitTypeQualifier(const TypeQualifierSyntax *) { + return Action::Visit; + } + virtual Action visitFunctionSpecifier(const FunctionSpecifierSyntax *) { + return Action::Visit; + } + virtual Action visitAlignmentSpecifier(const AlignmentSpecifierSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_Typeof(const ExtGNU_TypeofSyntax *) { + return Action::Visit; + } + virtual Action + visitExtGNU_AttributeSpecifier(const ExtGNU_AttributeSpecifierSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_Attribute(const ExtGNU_AttributeSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_AsmLabel(const ExtGNU_AsmLabelSyntax *) { + return Action::Visit; + } + virtual Action visitExtPSY_QuantifiedTypeSpecifier( + const ExtPSY_QuantifiedTypeSpecifierSyntax *) { + return Action::Visit; + } + + /* Declarators */ + virtual Action + visitArrayOrFunctionDeclarator(const ArrayOrFunctionDeclaratorSyntax *) { + return Action::Visit; + } + virtual Action visitPointerDeclarator(const PointerDeclaratorSyntax *) { + return Action::Visit; + } + virtual Action + visitParenthesizedDeclarator(const ParenthesizedDeclaratorSyntax *) { + return Action::Visit; + } + virtual Action visitIdentifierDeclarator(const IdentifierDeclaratorSyntax *) { + return Action::Visit; + } + virtual Action visitAbstractDeclarator(const AbstractDeclaratorSyntax *) { + return Action::Visit; + } + virtual Action visitSubscriptSuffix(const SubscriptSuffixSyntax *) { + return Action::Visit; + } + virtual Action visitParameterSuffix(const ParameterSuffixSyntax *) { + return Action::Visit; + } + virtual Action visitBitfieldDeclarator(const BitfieldDeclaratorSyntax *) { + return Action::Visit; + } + + /* Initializers */ + virtual Action + visitExpressionInitializer(const ExpressionInitializerSyntax *) { + return Action::Visit; + } + virtual Action + visitBraceEnclosedInitializer(const BraceEnclosedInitializerSyntax *) { + return Action::Visit; + } + virtual Action + visitDesignatedInitializer(const DesignatedInitializerSyntax *) { + return Action::Visit; + } + virtual Action visitFieldDesignator(const FieldDesignatorSyntax *) { + return Action::Visit; + } + virtual Action visitArrayDesignator(const ArrayDesignatorSyntax *) { + return Action::Visit; + } + virtual Action visitOffsetOfDesignator(const OffsetOfDesignatorSyntax *) { + return Action::Visit; + } + + //-------------// + // Expressions // + //-------------// + virtual Action visitIdentifierName(const IdentifierNameSyntax *) { + return Action::Visit; + } + virtual Action visitPredefinedName(const PredefinedNameSyntax *) { + return Action::Visit; + } + virtual Action visitConstantExpression(const ConstantExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitStringLiteralExpression(const StringLiteralExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitParenthesizedExpression(const ParenthesizedExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitGenericSelectionExpression(const GenericSelectionExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitGenericAssociation(const GenericAssociationSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_EnclosedCompoundStatementExpression( + const ExtGNU_EnclosedCompoundStatementExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_ComplexValuedExpression( + const ExtGNU_ComplexValuedExpressionSyntax *) { + return Action::Visit; + } + + /* Operations */ + virtual Action + visitPrefixUnaryExpression(const PrefixUnaryExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitPostfixUnaryExpression(const PostfixUnaryExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitMemberAccessExpression(const MemberAccessExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitArraySubscriptExpression(const ArraySubscriptExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitTypeTraitExpression(const TypeTraitExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitCastExpression(const CastExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitCallExpression(const CallExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitVAArgumentExpression(const VAArgumentExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitOffsetOfExpression(const OffsetOfExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitCompoundLiteralExpression(const CompoundLiteralExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitBinaryExpression(const BinaryExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitConditionalExpression(const ConditionalExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitAssignmentExpression(const AssignmentExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitSequencingExpression(const SequencingExpressionSyntax *) { + return Action::Visit; + } + virtual Action + visitExtGNU_ChooseExpression(const ExtGNU_ChooseExpressionSyntax *) { + return Action::Visit; + } + + //------------// + // Statements // + //------------// + virtual Action visitCompoundStatement(const CompoundStatementSyntax *) { + return Action::Visit; + } + virtual Action visitDeclarationStatement(const DeclarationStatementSyntax *) { + return Action::Visit; + } + virtual Action visitExpressionStatement(const ExpressionStatementSyntax *) { + return Action::Visit; + } + virtual Action visitLabeledStatement(const LabeledStatementSyntax *) { + return Action::Visit; + } + virtual Action visitIfStatement(const IfStatementSyntax *) { + return Action::Visit; + } + virtual Action visitSwitchStatement(const SwitchStatementSyntax *) { + return Action::Visit; + } + virtual Action visitWhileStatement(const WhileStatementSyntax *) { + return Action::Visit; + } + virtual Action visitDoStatement(const DoStatementSyntax *) { + return Action::Visit; + } + virtual Action visitForStatement(const ForStatementSyntax *) { + return Action::Visit; + } + virtual Action visitGotoStatement(const GotoStatementSyntax *) { + return Action::Visit; + } + virtual Action visitContinueStatement(const ContinueStatementSyntax *) { + return Action::Visit; + } + virtual Action visitBreakStatement(const BreakStatementSyntax *) { + return Action::Visit; + } + virtual Action visitReturnStatement(const ReturnStatementSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_AsmStatement(const ExtGNU_AsmStatementSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_AsmQualifier(const ExtGNU_AsmQualifierSyntax *) { + return Action::Visit; + } + virtual Action visitExtGNU_AsmOperand(const ExtGNU_AsmOperandSyntax *) { + return Action::Visit; + } + + //--------// + // Common // + //--------// + virtual Action visitTypeName(const TypeNameSyntax *) { return Action::Visit; } + virtual Action + visitExpressionAsTypeReference(const ExpressionAsTypeReferenceSyntax *) { + return Action::Visit; + } + virtual Action + visitTypeNameAsTypeReference(const TypeNameAsTypeReferenceSyntax *) { + return Action::Visit; + } + + //-------------// + // Ambiguities // + //-------------// + virtual Action visitAmbiguousTypeNameOrExpressionAsTypeReference( + const AmbiguousTypeNameOrExpressionAsTypeReferenceSyntax *) { + return Action::Visit; + } + virtual Action visitAmbiguousCastOrBinaryExpression( + const AmbiguousCastOrBinaryExpressionSyntax *) { + return Action::Visit; + } + virtual Action visitAmbiguousExpressionOrDeclarationStatement( + const AmbiguousExpressionOrDeclarationStatementSyntax *) { + return Action::Visit; + } protected: - // Unavailable. - SyntaxVisitor(const SyntaxVisitor&) = delete; - void operator=(const SyntaxVisitor&) = delete; + // Unavailable. + SyntaxVisitor(const SyntaxVisitor &) = delete; + void operator=(const SyntaxVisitor &) = delete; - const SyntaxTree* tree_; + const SyntaxTree *tree_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/syntax/SyntaxWriterDOTFormat.cpp b/C/syntax/SyntaxWriterDOTFormat.cpp index 539656a36..ecbe664f2 100644 --- a/C/syntax/SyntaxWriterDOTFormat.cpp +++ b/C/syntax/SyntaxWriterDOTFormat.cpp @@ -25,7 +25,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, The Qt Company gives you certain additional +** In addition, as a special exception, The Qt Company gives you certain +*additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** @@ -43,124 +44,113 @@ #include "SyntaxWriterDOTFormat.h" #include "SyntaxLexeme_ALL.h" -#include "SyntaxVisitor.h" #include "SyntaxTree.h" +#include "SyntaxVisitor.h" #ifdef __GNUC__ -# include +#include #endif using namespace psy; using namespace C; -void SyntaxWriterDOTFormat::write(const SyntaxNode* node, - const std::string& fileSuffix) -{ - std::string basename = tree_->filePath(); - basename.append(fileSuffix); - std::ofstream ofs(basename); - write(node, fileSuffix, ofs); - ofs.close(); +void SyntaxWriterDOTFormat::write(const SyntaxNode *node, + const std::string &fileSuffix) { + std::string basename = tree_->filePath(); + basename.append(fileSuffix); + std::ofstream ofs(basename); + write(node, fileSuffix, ofs); + ofs.close(); } -void SyntaxWriterDOTFormat::write(const SyntaxNode* node, - const std::string& fileSuffix, - std::ostream &os) -{ - os_ = &os; - count_ = 1; +void SyntaxWriterDOTFormat::write(const SyntaxNode *node, + const std::string &fileSuffix, + std::ostream &os) { + os_ = &os; + count_ = 1; - *os_ << "digraph Syntax { ordering=out;" << std::endl; - // std::cout << "rankdir = \"LR\";" << std::endl; + *os_ << "digraph Syntax { ordering=out;" << std::endl; + // std::cout << "rankdir = \"LR\";" << std::endl; - generateTokens(); - visit(node); + generateTokens(); + visit(node); - for (const auto& conn : connections_) - *os_ << conn.first << " -> " << conn.second << std::endl; + for (const auto &conn : connections_) + *os_ << conn.first << " -> " << conn.second << std::endl; - alignTerminals(); + alignTerminals(); - *os_ << "}" << std::endl; + *os_ << "}" << std::endl; } -void SyntaxWriterDOTFormat::alignTerminals() -{ - *os_ <<"{ rank=same;" << std::endl; - for (const auto& terminalShape : terminalShapes_) - *os_ << " " << terminalShape << ";" << std::endl; - *os_ <<"}"<tokenCount(); ++token) { - if (tree_->tokenAt(token).kind() == EndOfFile) - break; - - std::string t; - t.append(terminalId(token)); - t.append(" [shape=rect label = \""); - t.append(tree_->tokenAt(token).valueText()); - t.append("\"]"); - - if (token > 1) { - t.append("; "); - t.append(terminalId(token - 1)); - t.append(" -> "); - t.append(terminalId(token)); - t.append(" [arrowhead=\"vee\" color=\"transparent\"]"); - } - - terminalShapes_.push_back(t); + for (unsigned token = 1; token < tree_->tokenCount(); ++token) { + if (tree_->tokenAt(token).kind() == EndOfFile) + break; + + std::string t; + t.append(terminalId(token)); + t.append(" [shape=rect label = \""); + t.append(tree_->tokenAt(token).valueText()); + t.append("\"]"); + + if (token > 1) { + t.append("; "); + t.append(terminalId(token - 1)); + t.append(" -> "); + t.append(terminalId(token)); + t.append(" [arrowhead=\"vee\" color=\"transparent\"]"); } -} -void SyntaxWriterDOTFormat::nodeLabel(const SyntaxNode* node) -{ - *os_ << id_[node] << " [label=\"" << name(node) << "\"];" << std::endl; + terminalShapes_.push_back(t); + } } -bool SyntaxWriterDOTFormat::preVisit(const SyntaxNode* node) -{ - const std::string id = 'n' + std::to_string(count_++); - id_[node] = id; +void SyntaxWriterDOTFormat::nodeLabel(const SyntaxNode *node) { + *os_ << id_[node] << " [label=\"" << name(node) << "\"];" << std::endl; +} - if (!nodes_.empty()) - connections_.push_back(std::make_pair(id_[nodes_.top()], id)); +bool SyntaxWriterDOTFormat::preVisit(const SyntaxNode *node) { + const std::string id = 'n' + std::to_string(count_++); + id_[node] = id; - nodes_.push(node); + if (!nodes_.empty()) + connections_.push_back(std::make_pair(id_[nodes_.top()], id)); - nodeLabel(node); + nodes_.push(node); - return true; -} + nodeLabel(node); -void SyntaxWriterDOTFormat::postVisit(const SyntaxNode *) -{ - nodes_.pop(); + return true; } +void SyntaxWriterDOTFormat::postVisit(const SyntaxNode *) { nodes_.pop(); } diff --git a/C/syntax/SyntaxWriterDOTFormat.h b/C/syntax/SyntaxWriterDOTFormat.h index 0ed323367..a33ec6bf6 100644 --- a/C/syntax/SyntaxWriterDOTFormat.h +++ b/C/syntax/SyntaxWriterDOTFormat.h @@ -25,7 +25,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, The Qt Company gives you certain additional +** In addition, as a special exception, The Qt Company gives you certain +*additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** @@ -57,37 +58,37 @@ namespace psy { namespace C { -class PSY_C_API SyntaxWriterDOTFormat final : public SyntaxDumper -{ +class PSY_C_API SyntaxWriterDOTFormat final : public SyntaxDumper { public: - using SyntaxDumper::SyntaxDumper; + using SyntaxDumper::SyntaxDumper; - void write(const SyntaxNode* node, const std::string& fileSuffix); - void write(const SyntaxNode* node, const std::string& fileSuffix, std::ostream& os); + void write(const SyntaxNode *node, const std::string &fileSuffix); + void write(const SyntaxNode *node, const std::string &fileSuffix, + std::ostream &os); private: - static std::string name(const SyntaxNode* node); + static std::string name(const SyntaxNode *node); - void terminal(const SyntaxToken& tk, const SyntaxNode* node) override; - std::string terminalId(unsigned token); - std::string terminalId(const SyntaxToken& tk); + void terminal(const SyntaxToken &tk, const SyntaxNode *node) override; + std::string terminalId(unsigned token); + std::string terminalId(const SyntaxToken &tk); - void generateTokens(); - void alignTerminals(); - void nodeLabel(const SyntaxNode* node); + void generateTokens(); + void alignTerminals(); + void nodeLabel(const SyntaxNode *node); - bool preVisit(const SyntaxNode* node) override; - void postVisit(const SyntaxNode*) override; + bool preVisit(const SyntaxNode *node) override; + void postVisit(const SyntaxNode *) override; - std::unordered_map id_; - std::vector> connections_; - std::stack nodes_; - std::vector terminalShapes_; - std::ostream* os_; - int count_; + std::unordered_map id_; + std::vector> connections_; + std::stack nodes_; + std::vector terminalShapes_; + std::ostream *os_; + int count_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/tests/BinderTester.cpp b/C/tests/BinderTester.cpp index ef616b64f..06980b4f1 100644 --- a/C/tests/BinderTester.cpp +++ b/C/tests/BinderTester.cpp @@ -20,8 +20,8 @@ #include "BinderTester.h" -#include "symbols/Symbol.h" #include "parser/Unparser.h" +#include "symbols/Symbol.h" #include "symbols/Symbol_ALL.h" #include "syntax/SyntaxLexeme_ALL.h" #include "syntax/SyntaxNamePrinter.h" @@ -32,30 +32,26 @@ using namespace C; const std::string BinderTester::Name = "BINDER"; -void BinderTester::testBinder() -{ - // TEMPORARY - std::vector active; - for (auto testData : tests_) { - auto n = std::string(testData.second); - auto p = n.find("case09"); - if (p != std::string::npos) { - std::cout << "\t\tskip (TEMP) " << n << std::endl; - continue; - } - active.push_back(testData); +void BinderTester::testBinder() { + // TEMPORARY + std::vector active; + for (auto testData : tests_) { + auto n = std::string(testData.second); + auto p = n.find("case09"); + if (p != std::string::npos) { + std::cout << "\t\tskip (TEMP) " << n << std::endl; + continue; } + active.push_back(testData); + } - return run(active); + return run(active); } -void BinderTester::bind(std::string text, Expectation X) -{ - (static_cast(suite_)->bind(text, X)); +void BinderTester::bind(std::string text, Expectation X) { + (static_cast(suite_)->bind(text, X)); } -void BinderTester::setUp() -{} +void BinderTester::setUp() {} -void BinderTester::tearDown() -{} +void BinderTester::tearDown() {} diff --git a/C/tests/BinderTester.h b/C/tests/BinderTester.h index d7ffbf5ff..5397a54b1 100644 --- a/C/tests/BinderTester.h +++ b/C/tests/BinderTester.h @@ -25,4220 +25,2898 @@ #include "TestSuite_Internals.h" #include "tests/Tester.h" -#define TEST_BINDER(Function) TestFunction { &BinderTester::Function, #Function } +#define TEST_BINDER(Function) \ + TestFunction { &BinderTester::Function, #Function } namespace psy { namespace C { -class BinderTester final : public Tester -{ +class BinderTester final : public Tester { public: - BinderTester(TestSuite* suite) - : Tester(suite) - {} + BinderTester(TestSuite *suite) : Tester(suite) {} - static const std::string Name; - virtual std::string name() const override { return Name; } - void setUp() override; - void tearDown() override; + static const std::string Name; + virtual std::string name() const override { return Name; } + void setUp() override; + void tearDown() override; - void testBinder(); + void testBinder(); - void bind(std::string text, Expectation X = Expectation()); + void bind(std::string text, Expectation X = Expectation()); - using TestFunction = std::pair, const char*>; + using TestFunction = + std::pair, const char *>; - /* - Functions - + 0000-0049 -> prototypes w/o parameters - + 0050-0099 -> prototypes - + 0100-0149 -> definitions w/o parameters - + 0150-0199 -> definitions - + 0200-0299 -> "signatures" - + 0300-0334 -> pointer to function as parameter - + 0335-0349 -> (decayed) function as parameter - + 0350-0384 -> pointer to array as parameter - + 0385-0399 -> (decayed) array as parameter - + 0400-0424 -> function/pointer to function as return - + 0425-0449 -> array/pointer to array as return - + 0450-0499 -> + /* + Functions + + 0000-0049 -> prototypes w/o parameters + + 0050-0099 -> prototypes + + 0100-0149 -> definitions w/o parameters + + 0150-0199 -> definitions + + 0200-0299 -> "signatures" + + 0300-0334 -> pointer to function as parameter + + 0335-0349 -> (decayed) function as parameter + + 0350-0384 -> pointer to array as parameter + + 0385-0399 -> (decayed) array as parameter + + 0400-0424 -> function/pointer to function as return + + 0425-0449 -> array/pointer to array as return + + 0450-0499 -> - Variables (globals/locals) - + 1000-1049 -> objects - + 1050-1099 -> objects of qualified type - + 1100-1129 -> pointers - + 1130-1149 -> pointers to functions - + 1150-1199 -> pointers to objects of qualified type - + 1200-1249 -> qualified pointers to objects of qualified type - + 1250-1299 -> qualified pointers - + 1300-1349 -> arrays - + 1350-1399 -> arrays of objects of qualified type + Variables (globals/locals) + + 1000-1049 -> objects + + 1050-1099 -> objects of qualified type + + 1100-1129 -> pointers + + 1130-1149 -> pointers to functions + + 1150-1199 -> pointers to objects of qualified type + + 1200-1249 -> qualified pointers to objects of qualified type + + 1250-1299 -> qualified pointers + + 1300-1349 -> arrays + + 1350-1399 -> arrays of objects of qualified type - Fields - + 2000-2049 -> objects - + 2050-2099 -> objects of qualified type - + 2100-2129 -> pointers - + 2130-2149 -> pointers to functions - + 2150-2199 -> pointers to objects of qualified type - + 2200-2249 -> qualified pointers to objects of qualified type - + 2250-2299 -> qualified pointers - + 2300-2349 -> arrays - + 2350-2399 -> arrays of objects of qualified type + Fields + + 2000-2049 -> objects + + 2050-2099 -> objects of qualified type + + 2100-2129 -> pointers + + 2130-2149 -> pointers to functions + + 2150-2199 -> pointers to objects of qualified type + + 2200-2249 -> qualified pointers to objects of qualified type + + 2250-2299 -> qualified pointers + + 2300-2349 -> arrays + + 2350-2399 -> arrays of objects of qualified type - Types - + 3000-0049 -> structures and unions - + 3050-0099 -> enumerations (and enumerators) - */ + Types + + 3000-0049 -> structures and unions + + 3050-0099 -> enumerations (and enumerators) + */ - void case0001(); - void case0002(); - void case0003(); - void case0004(); - void case0005(); - void case0006(); - void case0007(); - void case0008(); - void case0009(); - void case0010(); - void case0011(); - void case0012(); - void case0013(); - void case0014(); - void case0015(); - void case0016(); - void case0017(); - void case0018(); - void case0019(); - void case0020(); - void case0021(); - void case0022(); - void case0023(); - void case0024(); - void case0025(); - void case0026(); - void case0027(); - void case0028(); - void case0029(); - void case0030(); - void case0031(); - void case0032(); - void case0033(); - void case0034(); - void case0035(); - void case0036(); - void case0037(); - void case0038(); - void case0039(); - void case0040(); - void case0041(); - void case0042(); - void case0043(); - void case0044(); - void case0045(); - void case0046(); - void case0047(); - void case0048(); - void case0049(); - void case0050(); - void case0051(); - void case0052(); - void case0053(); - void case0054(); - void case0055(); - void case0056(); - void case0057(); - void case0058(); - void case0059(); - void case0060(); - void case0061(); - void case0062(); - void case0063(); - void case0064(); - void case0065(); - void case0066(); - void case0067(); - void case0068(); - void case0069(); - void case0070(); - void case0071(); - void case0072(); - void case0073(); - void case0074(); - void case0075(); - void case0076(); - void case0077(); - void case0078(); - void case0079(); - void case0080(); - void case0081(); - void case0082(); - void case0083(); - void case0084(); - void case0085(); - void case0086(); - void case0087(); - void case0088(); - void case0089(); - void case0090(); - void case0091(); - void case0092(); - void case0093(); - void case0094(); - void case0095(); - void case0096(); - void case0097(); - void case0098(); - void case0099(); + void case0001(); + void case0002(); + void case0003(); + void case0004(); + void case0005(); + void case0006(); + void case0007(); + void case0008(); + void case0009(); + void case0010(); + void case0011(); + void case0012(); + void case0013(); + void case0014(); + void case0015(); + void case0016(); + void case0017(); + void case0018(); + void case0019(); + void case0020(); + void case0021(); + void case0022(); + void case0023(); + void case0024(); + void case0025(); + void case0026(); + void case0027(); + void case0028(); + void case0029(); + void case0030(); + void case0031(); + void case0032(); + void case0033(); + void case0034(); + void case0035(); + void case0036(); + void case0037(); + void case0038(); + void case0039(); + void case0040(); + void case0041(); + void case0042(); + void case0043(); + void case0044(); + void case0045(); + void case0046(); + void case0047(); + void case0048(); + void case0049(); + void case0050(); + void case0051(); + void case0052(); + void case0053(); + void case0054(); + void case0055(); + void case0056(); + void case0057(); + void case0058(); + void case0059(); + void case0060(); + void case0061(); + void case0062(); + void case0063(); + void case0064(); + void case0065(); + void case0066(); + void case0067(); + void case0068(); + void case0069(); + void case0070(); + void case0071(); + void case0072(); + void case0073(); + void case0074(); + void case0075(); + void case0076(); + void case0077(); + void case0078(); + void case0079(); + void case0080(); + void case0081(); + void case0082(); + void case0083(); + void case0084(); + void case0085(); + void case0086(); + void case0087(); + void case0088(); + void case0089(); + void case0090(); + void case0091(); + void case0092(); + void case0093(); + void case0094(); + void case0095(); + void case0096(); + void case0097(); + void case0098(); + void case0099(); - void case0100(); - void case0101(); - void case0102(); - void case0103(); - void case0104(); - void case0105(); - void case0106(); - void case0107(); - void case0108(); - void case0109(); - void case0110(); - void case0111(); - void case0112(); - void case0113(); - void case0114(); - void case0115(); - void case0116(); - void case0117(); - void case0118(); - void case0119(); - void case0120(); - void case0121(); - void case0122(); - void case0123(); - void case0124(); - void case0125(); - void case0126(); - void case0127(); - void case0128(); - void case0129(); - void case0130(); - void case0131(); - void case0132(); - void case0133(); - void case0134(); - void case0135(); - void case0136(); - void case0137(); - void case0138(); - void case0139(); - void case0140(); - void case0141(); - void case0142(); - void case0143(); - void case0144(); - void case0145(); - void case0146(); - void case0147(); - void case0148(); - void case0149(); - void case0150(); - void case0151(); - void case0152(); - void case0153(); - void case0154(); - void case0155(); - void case0156(); - void case0157(); - void case0158(); - void case0159(); - void case0160(); - void case0161(); - void case0162(); - void case0163(); - void case0164(); - void case0165(); - void case0166(); - void case0167(); - void case0168(); - void case0169(); - void case0170(); - void case0171(); - void case0172(); - void case0173(); - void case0174(); - void case0175(); - void case0176(); - void case0177(); - void case0178(); - void case0179(); - void case0180(); - void case0181(); - void case0182(); - void case0183(); - void case0184(); - void case0185(); - void case0186(); - void case0187(); - void case0188(); - void case0189(); - void case0190(); - void case0191(); - void case0192(); - void case0193(); - void case0194(); - void case0195(); - void case0196(); - void case0197(); - void case0198(); - void case0199(); + void case0100(); + void case0101(); + void case0102(); + void case0103(); + void case0104(); + void case0105(); + void case0106(); + void case0107(); + void case0108(); + void case0109(); + void case0110(); + void case0111(); + void case0112(); + void case0113(); + void case0114(); + void case0115(); + void case0116(); + void case0117(); + void case0118(); + void case0119(); + void case0120(); + void case0121(); + void case0122(); + void case0123(); + void case0124(); + void case0125(); + void case0126(); + void case0127(); + void case0128(); + void case0129(); + void case0130(); + void case0131(); + void case0132(); + void case0133(); + void case0134(); + void case0135(); + void case0136(); + void case0137(); + void case0138(); + void case0139(); + void case0140(); + void case0141(); + void case0142(); + void case0143(); + void case0144(); + void case0145(); + void case0146(); + void case0147(); + void case0148(); + void case0149(); + void case0150(); + void case0151(); + void case0152(); + void case0153(); + void case0154(); + void case0155(); + void case0156(); + void case0157(); + void case0158(); + void case0159(); + void case0160(); + void case0161(); + void case0162(); + void case0163(); + void case0164(); + void case0165(); + void case0166(); + void case0167(); + void case0168(); + void case0169(); + void case0170(); + void case0171(); + void case0172(); + void case0173(); + void case0174(); + void case0175(); + void case0176(); + void case0177(); + void case0178(); + void case0179(); + void case0180(); + void case0181(); + void case0182(); + void case0183(); + void case0184(); + void case0185(); + void case0186(); + void case0187(); + void case0188(); + void case0189(); + void case0190(); + void case0191(); + void case0192(); + void case0193(); + void case0194(); + void case0195(); + void case0196(); + void case0197(); + void case0198(); + void case0199(); - void case0200(); - void case0201(); - void case0202(); - void case0203(); - void case0204(); - void case0205(); - void case0206(); - void case0207(); - void case0208(); - void case0209(); - void case0210(); - void case0211(); - void case0212(); - void case0213(); - void case0214(); - void case0215(); - void case0216(); - void case0217(); - void case0218(); - void case0219(); - void case0220(); - void case0221(); - void case0222(); - void case0223(); - void case0224(); - void case0225(); - void case0226(); - void case0227(); - void case0228(); - void case0229(); - void case0230(); - void case0231(); - void case0232(); - void case0233(); - void case0234(); - void case0235(); - void case0236(); - void case0237(); - void case0238(); - void case0239(); - void case0240(); - void case0241(); - void case0242(); - void case0243(); - void case0244(); - void case0245(); - void case0246(); - void case0247(); - void case0248(); - void case0249(); - void case0250(); - void case0251(); - void case0252(); - void case0253(); - void case0254(); - void case0255(); - void case0256(); - void case0257(); - void case0258(); - void case0259(); - void case0260(); - void case0261(); - void case0262(); - void case0263(); - void case0264(); - void case0265(); - void case0266(); - void case0267(); - void case0268(); - void case0269(); - void case0270(); - void case0271(); - void case0272(); - void case0273(); - void case0274(); - void case0275(); - void case0276(); - void case0277(); - void case0278(); - void case0279(); - void case0280(); - void case0281(); - void case0282(); - void case0283(); - void case0284(); - void case0285(); - void case0286(); - void case0287(); - void case0288(); - void case0289(); - void case0290(); - void case0291(); - void case0292(); - void case0293(); - void case0294(); - void case0295(); - void case0296(); - void case0297(); - void case0298(); - void case0299(); + void case0200(); + void case0201(); + void case0202(); + void case0203(); + void case0204(); + void case0205(); + void case0206(); + void case0207(); + void case0208(); + void case0209(); + void case0210(); + void case0211(); + void case0212(); + void case0213(); + void case0214(); + void case0215(); + void case0216(); + void case0217(); + void case0218(); + void case0219(); + void case0220(); + void case0221(); + void case0222(); + void case0223(); + void case0224(); + void case0225(); + void case0226(); + void case0227(); + void case0228(); + void case0229(); + void case0230(); + void case0231(); + void case0232(); + void case0233(); + void case0234(); + void case0235(); + void case0236(); + void case0237(); + void case0238(); + void case0239(); + void case0240(); + void case0241(); + void case0242(); + void case0243(); + void case0244(); + void case0245(); + void case0246(); + void case0247(); + void case0248(); + void case0249(); + void case0250(); + void case0251(); + void case0252(); + void case0253(); + void case0254(); + void case0255(); + void case0256(); + void case0257(); + void case0258(); + void case0259(); + void case0260(); + void case0261(); + void case0262(); + void case0263(); + void case0264(); + void case0265(); + void case0266(); + void case0267(); + void case0268(); + void case0269(); + void case0270(); + void case0271(); + void case0272(); + void case0273(); + void case0274(); + void case0275(); + void case0276(); + void case0277(); + void case0278(); + void case0279(); + void case0280(); + void case0281(); + void case0282(); + void case0283(); + void case0284(); + void case0285(); + void case0286(); + void case0287(); + void case0288(); + void case0289(); + void case0290(); + void case0291(); + void case0292(); + void case0293(); + void case0294(); + void case0295(); + void case0296(); + void case0297(); + void case0298(); + void case0299(); - void case0300(); - void case0301(); - void case0302(); - void case0303(); - void case0304(); - void case0305(); - void case0306(); - void case0307(); - void case0308(); - void case0309(); - void case0310(); - void case0311(); - void case0312(); - void case0313(); - void case0314(); - void case0315(); - void case0316(); - void case0317(); - void case0318(); - void case0319(); - void case0320(); - void case0321(); - void case0322(); - void case0323(); - void case0324(); - void case0325(); - void case0326(); - void case0327(); - void case0328(); - void case0329(); - void case0330(); - void case0331(); - void case0332(); - void case0333(); - void case0334(); - void case0335(); - void case0336(); - void case0337(); - void case0338(); - void case0339(); - void case0340(); - void case0341(); - void case0342(); - void case0343(); - void case0344(); - void case0345(); - void case0346(); - void case0347(); - void case0348(); - void case0349(); - void case0350(); - void case0351(); - void case0352(); - void case0353(); - void case0354(); - void case0355(); - void case0356(); - void case0357(); - void case0358(); - void case0359(); - void case0360(); - void case0361(); - void case0362(); - void case0363(); - void case0364(); - void case0365(); - void case0366(); - void case0367(); - void case0368(); - void case0369(); - void case0370(); - void case0371(); - void case0372(); - void case0373(); - void case0374(); - void case0375(); - void case0376(); - void case0377(); - void case0378(); - void case0379(); - void case0380(); - void case0381(); - void case0382(); - void case0383(); - void case0384(); - void case0385(); - void case0386(); - void case0387(); - void case0388(); - void case0389(); - void case0390(); - void case0391(); - void case0392(); - void case0393(); - void case0394(); - void case0395(); - void case0396(); - void case0397(); - void case0398(); - void case0399(); + void case0300(); + void case0301(); + void case0302(); + void case0303(); + void case0304(); + void case0305(); + void case0306(); + void case0307(); + void case0308(); + void case0309(); + void case0310(); + void case0311(); + void case0312(); + void case0313(); + void case0314(); + void case0315(); + void case0316(); + void case0317(); + void case0318(); + void case0319(); + void case0320(); + void case0321(); + void case0322(); + void case0323(); + void case0324(); + void case0325(); + void case0326(); + void case0327(); + void case0328(); + void case0329(); + void case0330(); + void case0331(); + void case0332(); + void case0333(); + void case0334(); + void case0335(); + void case0336(); + void case0337(); + void case0338(); + void case0339(); + void case0340(); + void case0341(); + void case0342(); + void case0343(); + void case0344(); + void case0345(); + void case0346(); + void case0347(); + void case0348(); + void case0349(); + void case0350(); + void case0351(); + void case0352(); + void case0353(); + void case0354(); + void case0355(); + void case0356(); + void case0357(); + void case0358(); + void case0359(); + void case0360(); + void case0361(); + void case0362(); + void case0363(); + void case0364(); + void case0365(); + void case0366(); + void case0367(); + void case0368(); + void case0369(); + void case0370(); + void case0371(); + void case0372(); + void case0373(); + void case0374(); + void case0375(); + void case0376(); + void case0377(); + void case0378(); + void case0379(); + void case0380(); + void case0381(); + void case0382(); + void case0383(); + void case0384(); + void case0385(); + void case0386(); + void case0387(); + void case0388(); + void case0389(); + void case0390(); + void case0391(); + void case0392(); + void case0393(); + void case0394(); + void case0395(); + void case0396(); + void case0397(); + void case0398(); + void case0399(); - void case0400(); - void case0401(); - void case0402(); - void case0403(); - void case0404(); - void case0405(); - void case0406(); - void case0407(); - void case0408(); - void case0409(); - void case0410(); - void case0411(); - void case0412(); - void case0413(); - void case0414(); - void case0415(); - void case0416(); - void case0417(); - void case0418(); - void case0419(); - void case0420(); - void case0421(); - void case0422(); - void case0423(); - void case0424(); - void case0425(); - void case0426(); - void case0427(); - void case0428(); - void case0429(); - void case0430(); - void case0431(); - void case0432(); - void case0433(); - void case0434(); - void case0435(); - void case0436(); - void case0437(); - void case0438(); - void case0439(); - void case0440(); - void case0441(); - void case0442(); - void case0443(); - void case0444(); - void case0445(); - void case0446(); - void case0447(); - void case0448(); - void case0449(); - void case0450(); - void case0451(); - void case0452(); - void case0453(); - void case0454(); - void case0455(); - void case0456(); - void case0457(); - void case0458(); - void case0459(); - void case0460(); - void case0461(); - void case0462(); - void case0463(); - void case0464(); - void case0465(); - void case0466(); - void case0467(); - void case0468(); - void case0469(); - void case0470(); - void case0471(); - void case0472(); - void case0473(); - void case0474(); - void case0475(); - void case0476(); - void case0477(); - void case0478(); - void case0479(); - void case0480(); - void case0481(); - void case0482(); - void case0483(); - void case0484(); - void case0485(); - void case0486(); - void case0487(); - void case0488(); - void case0489(); - void case0490(); - void case0491(); - void case0492(); - void case0493(); - void case0494(); - void case0495(); - void case0496(); - void case0497(); - void case0498(); - void case0499(); + void case0400(); + void case0401(); + void case0402(); + void case0403(); + void case0404(); + void case0405(); + void case0406(); + void case0407(); + void case0408(); + void case0409(); + void case0410(); + void case0411(); + void case0412(); + void case0413(); + void case0414(); + void case0415(); + void case0416(); + void case0417(); + void case0418(); + void case0419(); + void case0420(); + void case0421(); + void case0422(); + void case0423(); + void case0424(); + void case0425(); + void case0426(); + void case0427(); + void case0428(); + void case0429(); + void case0430(); + void case0431(); + void case0432(); + void case0433(); + void case0434(); + void case0435(); + void case0436(); + void case0437(); + void case0438(); + void case0439(); + void case0440(); + void case0441(); + void case0442(); + void case0443(); + void case0444(); + void case0445(); + void case0446(); + void case0447(); + void case0448(); + void case0449(); + void case0450(); + void case0451(); + void case0452(); + void case0453(); + void case0454(); + void case0455(); + void case0456(); + void case0457(); + void case0458(); + void case0459(); + void case0460(); + void case0461(); + void case0462(); + void case0463(); + void case0464(); + void case0465(); + void case0466(); + void case0467(); + void case0468(); + void case0469(); + void case0470(); + void case0471(); + void case0472(); + void case0473(); + void case0474(); + void case0475(); + void case0476(); + void case0477(); + void case0478(); + void case0479(); + void case0480(); + void case0481(); + void case0482(); + void case0483(); + void case0484(); + void case0485(); + void case0486(); + void case0487(); + void case0488(); + void case0489(); + void case0490(); + void case0491(); + void case0492(); + void case0493(); + void case0494(); + void case0495(); + void case0496(); + void case0497(); + void case0498(); + void case0499(); - void case0500(); - void case0501(); - void case0502(); - void case0503(); - void case0504(); - void case0505(); - void case0506(); - void case0507(); - void case0508(); - void case0509(); - void case0510(); - void case0511(); - void case0512(); - void case0513(); - void case0514(); - void case0515(); - void case0516(); - void case0517(); - void case0518(); - void case0519(); - void case0520(); - void case0521(); - void case0522(); - void case0523(); - void case0524(); - void case0525(); - void case0526(); - void case0527(); - void case0528(); - void case0529(); - void case0530(); - void case0531(); - void case0532(); - void case0533(); - void case0534(); - void case0535(); - void case0536(); - void case0537(); - void case0538(); - void case0539(); - void case0540(); - void case0541(); - void case0542(); - void case0543(); - void case0544(); - void case0545(); - void case0546(); - void case0547(); - void case0548(); - void case0549(); - void case0550(); - void case0551(); - void case0552(); - void case0553(); - void case0554(); - void case0555(); - void case0556(); - void case0557(); - void case0558(); - void case0559(); - void case0560(); - void case0561(); - void case0562(); - void case0563(); - void case0564(); - void case0565(); - void case0566(); - void case0567(); - void case0568(); - void case0569(); - void case0570(); - void case0571(); - void case0572(); - void case0573(); - void case0574(); - void case0575(); - void case0576(); - void case0577(); - void case0578(); - void case0579(); - void case0580(); - void case0581(); - void case0582(); - void case0583(); - void case0584(); - void case0585(); - void case0586(); - void case0587(); - void case0588(); - void case0589(); - void case0590(); - void case0591(); - void case0592(); - void case0593(); - void case0594(); - void case0595(); - void case0596(); - void case0597(); - void case0598(); - void case0599(); + void case0500(); + void case0501(); + void case0502(); + void case0503(); + void case0504(); + void case0505(); + void case0506(); + void case0507(); + void case0508(); + void case0509(); + void case0510(); + void case0511(); + void case0512(); + void case0513(); + void case0514(); + void case0515(); + void case0516(); + void case0517(); + void case0518(); + void case0519(); + void case0520(); + void case0521(); + void case0522(); + void case0523(); + void case0524(); + void case0525(); + void case0526(); + void case0527(); + void case0528(); + void case0529(); + void case0530(); + void case0531(); + void case0532(); + void case0533(); + void case0534(); + void case0535(); + void case0536(); + void case0537(); + void case0538(); + void case0539(); + void case0540(); + void case0541(); + void case0542(); + void case0543(); + void case0544(); + void case0545(); + void case0546(); + void case0547(); + void case0548(); + void case0549(); + void case0550(); + void case0551(); + void case0552(); + void case0553(); + void case0554(); + void case0555(); + void case0556(); + void case0557(); + void case0558(); + void case0559(); + void case0560(); + void case0561(); + void case0562(); + void case0563(); + void case0564(); + void case0565(); + void case0566(); + void case0567(); + void case0568(); + void case0569(); + void case0570(); + void case0571(); + void case0572(); + void case0573(); + void case0574(); + void case0575(); + void case0576(); + void case0577(); + void case0578(); + void case0579(); + void case0580(); + void case0581(); + void case0582(); + void case0583(); + void case0584(); + void case0585(); + void case0586(); + void case0587(); + void case0588(); + void case0589(); + void case0590(); + void case0591(); + void case0592(); + void case0593(); + void case0594(); + void case0595(); + void case0596(); + void case0597(); + void case0598(); + void case0599(); - void case0900(); - void case0901(); - void case0902(); - void case0903(); - void case0904(); - void case0905(); - void case0906(); - void case0907(); - void case0908(); - void case0909(); - void case0910(); - void case0911(); - void case0912(); - void case0913(); - void case0914(); - void case0915(); - void case0916(); - void case0917(); - void case0918(); - void case0919(); - void case0920(); - void case0921(); - void case0922(); - void case0923(); - void case0924(); - void case0925(); - void case0926(); - void case0927(); - void case0928(); - void case0929(); - void case0930(); - void case0931(); - void case0932(); - void case0933(); - void case0934(); - void case0935(); - void case0936(); - void case0937(); - void case0938(); - void case0939(); - void case0940(); - void case0941(); - void case0942(); - void case0943(); - void case0944(); - void case0945(); - void case0946(); - void case0947(); - void case0948(); - void case0949(); - void case0950(); - void case0951(); - void case0952(); - void case0953(); - void case0954(); - void case0955(); - void case0956(); - void case0957(); - void case0958(); - void case0959(); - void case0960(); - void case0961(); - void case0962(); - void case0963(); - void case0964(); - void case0965(); - void case0966(); - void case0967(); - void case0968(); - void case0969(); - void case0970(); - void case0971(); - void case0972(); - void case0973(); - void case0974(); - void case0975(); - void case0976(); - void case0977(); - void case0978(); - void case0979(); - void case0980(); - void case0981(); - void case0982(); - void case0983(); - void case0984(); - void case0985(); - void case0986(); - void case0987(); - void case0988(); - void case0989(); - void case0990(); - void case0991(); - void case0992(); - void case0993(); - void case0994(); - void case0995(); - void case0996(); - void case0997(); - void case0998(); - void case0999(); + void case0900(); + void case0901(); + void case0902(); + void case0903(); + void case0904(); + void case0905(); + void case0906(); + void case0907(); + void case0908(); + void case0909(); + void case0910(); + void case0911(); + void case0912(); + void case0913(); + void case0914(); + void case0915(); + void case0916(); + void case0917(); + void case0918(); + void case0919(); + void case0920(); + void case0921(); + void case0922(); + void case0923(); + void case0924(); + void case0925(); + void case0926(); + void case0927(); + void case0928(); + void case0929(); + void case0930(); + void case0931(); + void case0932(); + void case0933(); + void case0934(); + void case0935(); + void case0936(); + void case0937(); + void case0938(); + void case0939(); + void case0940(); + void case0941(); + void case0942(); + void case0943(); + void case0944(); + void case0945(); + void case0946(); + void case0947(); + void case0948(); + void case0949(); + void case0950(); + void case0951(); + void case0952(); + void case0953(); + void case0954(); + void case0955(); + void case0956(); + void case0957(); + void case0958(); + void case0959(); + void case0960(); + void case0961(); + void case0962(); + void case0963(); + void case0964(); + void case0965(); + void case0966(); + void case0967(); + void case0968(); + void case0969(); + void case0970(); + void case0971(); + void case0972(); + void case0973(); + void case0974(); + void case0975(); + void case0976(); + void case0977(); + void case0978(); + void case0979(); + void case0980(); + void case0981(); + void case0982(); + void case0983(); + void case0984(); + void case0985(); + void case0986(); + void case0987(); + void case0988(); + void case0989(); + void case0990(); + void case0991(); + void case0992(); + void case0993(); + void case0994(); + void case0995(); + void case0996(); + void case0997(); + void case0998(); + void case0999(); - // 1000-1999 + // 1000-1999 - void case1000(); - void case1001(); - void case1002(); - void case1003(); - void case1004(); - void case1005(); - void case1006(); - void case1007(); - void case1008(); - void case1009(); - void case1010(); - void case1011(); - void case1012(); - void case1013(); - void case1014(); - void case1015(); - void case1016(); - void case1017(); - void case1018(); - void case1019(); - void case1020(); - void case1021(); - void case1022(); - void case1023(); - void case1024(); - void case1025(); - void case1026(); - void case1027(); - void case1028(); - void case1029(); - void case1030(); - void case1031(); - void case1032(); - void case1033(); - void case1034(); - void case1035(); - void case1036(); - void case1037(); - void case1038(); - void case1039(); - void case1040(); - void case1041(); - void case1042(); - void case1043(); - void case1044(); - void case1045(); - void case1046(); - void case1047(); - void case1048(); - void case1049(); - void case1050(); - void case1051(); - void case1052(); - void case1053(); - void case1054(); - void case1055(); - void case1056(); - void case1057(); - void case1058(); - void case1059(); - void case1060(); - void case1061(); - void case1062(); - void case1063(); - void case1064(); - void case1065(); - void case1066(); - void case1067(); - void case1068(); - void case1069(); - void case1070(); - void case1071(); - void case1072(); - void case1073(); - void case1074(); - void case1075(); - void case1076(); - void case1077(); - void case1078(); - void case1079(); - void case1080(); - void case1081(); - void case1082(); - void case1083(); - void case1084(); - void case1085(); - void case1086(); - void case1087(); - void case1088(); - void case1089(); - void case1090(); - void case1091(); - void case1092(); - void case1093(); - void case1094(); - void case1095(); - void case1096(); - void case1097(); - void case1098(); - void case1099(); + void case1000(); + void case1001(); + void case1002(); + void case1003(); + void case1004(); + void case1005(); + void case1006(); + void case1007(); + void case1008(); + void case1009(); + void case1010(); + void case1011(); + void case1012(); + void case1013(); + void case1014(); + void case1015(); + void case1016(); + void case1017(); + void case1018(); + void case1019(); + void case1020(); + void case1021(); + void case1022(); + void case1023(); + void case1024(); + void case1025(); + void case1026(); + void case1027(); + void case1028(); + void case1029(); + void case1030(); + void case1031(); + void case1032(); + void case1033(); + void case1034(); + void case1035(); + void case1036(); + void case1037(); + void case1038(); + void case1039(); + void case1040(); + void case1041(); + void case1042(); + void case1043(); + void case1044(); + void case1045(); + void case1046(); + void case1047(); + void case1048(); + void case1049(); + void case1050(); + void case1051(); + void case1052(); + void case1053(); + void case1054(); + void case1055(); + void case1056(); + void case1057(); + void case1058(); + void case1059(); + void case1060(); + void case1061(); + void case1062(); + void case1063(); + void case1064(); + void case1065(); + void case1066(); + void case1067(); + void case1068(); + void case1069(); + void case1070(); + void case1071(); + void case1072(); + void case1073(); + void case1074(); + void case1075(); + void case1076(); + void case1077(); + void case1078(); + void case1079(); + void case1080(); + void case1081(); + void case1082(); + void case1083(); + void case1084(); + void case1085(); + void case1086(); + void case1087(); + void case1088(); + void case1089(); + void case1090(); + void case1091(); + void case1092(); + void case1093(); + void case1094(); + void case1095(); + void case1096(); + void case1097(); + void case1098(); + void case1099(); - void case1100(); - void case1101(); - void case1102(); - void case1103(); - void case1104(); - void case1105(); - void case1106(); - void case1107(); - void case1108(); - void case1109(); - void case1110(); - void case1111(); - void case1112(); - void case1113(); - void case1114(); - void case1115(); - void case1116(); - void case1117(); - void case1118(); - void case1119(); - void case1120(); - void case1121(); - void case1122(); - void case1123(); - void case1124(); - void case1125(); - void case1126(); - void case1127(); - void case1128(); - void case1129(); - void case1130(); - void case1131(); - void case1132(); - void case1133(); - void case1134(); - void case1135(); - void case1136(); - void case1137(); - void case1138(); - void case1139(); - void case1140(); - void case1141(); - void case1142(); - void case1143(); - void case1144(); - void case1145(); - void case1146(); - void case1147(); - void case1148(); - void case1149(); - void case1150(); - void case1151(); - void case1152(); - void case1153(); - void case1154(); - void case1155(); - void case1156(); - void case1157(); - void case1158(); - void case1159(); - void case1160(); - void case1161(); - void case1162(); - void case1163(); - void case1164(); - void case1165(); - void case1166(); - void case1167(); - void case1168(); - void case1169(); - void case1170(); - void case1171(); - void case1172(); - void case1173(); - void case1174(); - void case1175(); - void case1176(); - void case1177(); - void case1178(); - void case1179(); - void case1180(); - void case1181(); - void case1182(); - void case1183(); - void case1184(); - void case1185(); - void case1186(); - void case1187(); - void case1188(); - void case1189(); - void case1190(); - void case1191(); - void case1192(); - void case1193(); - void case1194(); - void case1195(); - void case1196(); - void case1197(); - void case1198(); - void case1199(); + void case1100(); + void case1101(); + void case1102(); + void case1103(); + void case1104(); + void case1105(); + void case1106(); + void case1107(); + void case1108(); + void case1109(); + void case1110(); + void case1111(); + void case1112(); + void case1113(); + void case1114(); + void case1115(); + void case1116(); + void case1117(); + void case1118(); + void case1119(); + void case1120(); + void case1121(); + void case1122(); + void case1123(); + void case1124(); + void case1125(); + void case1126(); + void case1127(); + void case1128(); + void case1129(); + void case1130(); + void case1131(); + void case1132(); + void case1133(); + void case1134(); + void case1135(); + void case1136(); + void case1137(); + void case1138(); + void case1139(); + void case1140(); + void case1141(); + void case1142(); + void case1143(); + void case1144(); + void case1145(); + void case1146(); + void case1147(); + void case1148(); + void case1149(); + void case1150(); + void case1151(); + void case1152(); + void case1153(); + void case1154(); + void case1155(); + void case1156(); + void case1157(); + void case1158(); + void case1159(); + void case1160(); + void case1161(); + void case1162(); + void case1163(); + void case1164(); + void case1165(); + void case1166(); + void case1167(); + void case1168(); + void case1169(); + void case1170(); + void case1171(); + void case1172(); + void case1173(); + void case1174(); + void case1175(); + void case1176(); + void case1177(); + void case1178(); + void case1179(); + void case1180(); + void case1181(); + void case1182(); + void case1183(); + void case1184(); + void case1185(); + void case1186(); + void case1187(); + void case1188(); + void case1189(); + void case1190(); + void case1191(); + void case1192(); + void case1193(); + void case1194(); + void case1195(); + void case1196(); + void case1197(); + void case1198(); + void case1199(); - void case1200(); - void case1201(); - void case1202(); - void case1203(); - void case1204(); - void case1205(); - void case1206(); - void case1207(); - void case1208(); - void case1209(); - void case1210(); - void case1211(); - void case1212(); - void case1213(); - void case1214(); - void case1215(); - void case1216(); - void case1217(); - void case1218(); - void case1219(); - void case1220(); - void case1221(); - void case1222(); - void case1223(); - void case1224(); - void case1225(); - void case1226(); - void case1227(); - void case1228(); - void case1229(); - void case1230(); - void case1231(); - void case1232(); - void case1233(); - void case1234(); - void case1235(); - void case1236(); - void case1237(); - void case1238(); - void case1239(); - void case1240(); - void case1241(); - void case1242(); - void case1243(); - void case1244(); - void case1245(); - void case1246(); - void case1247(); - void case1248(); - void case1249(); - void case1250(); - void case1251(); - void case1252(); - void case1253(); - void case1254(); - void case1255(); - void case1256(); - void case1257(); - void case1258(); - void case1259(); - void case1260(); - void case1261(); - void case1262(); - void case1263(); - void case1264(); - void case1265(); - void case1266(); - void case1267(); - void case1268(); - void case1269(); - void case1270(); - void case1271(); - void case1272(); - void case1273(); - void case1274(); - void case1275(); - void case1276(); - void case1277(); - void case1278(); - void case1279(); - void case1280(); - void case1281(); - void case1282(); - void case1283(); - void case1284(); - void case1285(); - void case1286(); - void case1287(); - void case1288(); - void case1289(); - void case1290(); - void case1291(); - void case1292(); - void case1293(); - void case1294(); - void case1295(); - void case1296(); - void case1297(); - void case1298(); - void case1299(); + void case1200(); + void case1201(); + void case1202(); + void case1203(); + void case1204(); + void case1205(); + void case1206(); + void case1207(); + void case1208(); + void case1209(); + void case1210(); + void case1211(); + void case1212(); + void case1213(); + void case1214(); + void case1215(); + void case1216(); + void case1217(); + void case1218(); + void case1219(); + void case1220(); + void case1221(); + void case1222(); + void case1223(); + void case1224(); + void case1225(); + void case1226(); + void case1227(); + void case1228(); + void case1229(); + void case1230(); + void case1231(); + void case1232(); + void case1233(); + void case1234(); + void case1235(); + void case1236(); + void case1237(); + void case1238(); + void case1239(); + void case1240(); + void case1241(); + void case1242(); + void case1243(); + void case1244(); + void case1245(); + void case1246(); + void case1247(); + void case1248(); + void case1249(); + void case1250(); + void case1251(); + void case1252(); + void case1253(); + void case1254(); + void case1255(); + void case1256(); + void case1257(); + void case1258(); + void case1259(); + void case1260(); + void case1261(); + void case1262(); + void case1263(); + void case1264(); + void case1265(); + void case1266(); + void case1267(); + void case1268(); + void case1269(); + void case1270(); + void case1271(); + void case1272(); + void case1273(); + void case1274(); + void case1275(); + void case1276(); + void case1277(); + void case1278(); + void case1279(); + void case1280(); + void case1281(); + void case1282(); + void case1283(); + void case1284(); + void case1285(); + void case1286(); + void case1287(); + void case1288(); + void case1289(); + void case1290(); + void case1291(); + void case1292(); + void case1293(); + void case1294(); + void case1295(); + void case1296(); + void case1297(); + void case1298(); + void case1299(); - void case1300(); - void case1301(); - void case1302(); - void case1303(); - void case1304(); - void case1305(); - void case1306(); - void case1307(); - void case1308(); - void case1309(); - void case1310(); - void case1311(); - void case1312(); - void case1313(); - void case1314(); - void case1315(); - void case1316(); - void case1317(); - void case1318(); - void case1319(); - void case1320(); - void case1321(); - void case1322(); - void case1323(); - void case1324(); - void case1325(); - void case1326(); - void case1327(); - void case1328(); - void case1329(); - void case1330(); - void case1331(); - void case1332(); - void case1333(); - void case1334(); - void case1335(); - void case1336(); - void case1337(); - void case1338(); - void case1339(); - void case1340(); - void case1341(); - void case1342(); - void case1343(); - void case1344(); - void case1345(); - void case1346(); - void case1347(); - void case1348(); - void case1349(); - void case1350(); - void case1351(); - void case1352(); - void case1353(); - void case1354(); - void case1355(); - void case1356(); - void case1357(); - void case1358(); - void case1359(); - void case1360(); - void case1361(); - void case1362(); - void case1363(); - void case1364(); - void case1365(); - void case1366(); - void case1367(); - void case1368(); - void case1369(); - void case1370(); - void case1371(); - void case1372(); - void case1373(); - void case1374(); - void case1375(); - void case1376(); - void case1377(); - void case1378(); - void case1379(); - void case1380(); - void case1381(); - void case1382(); - void case1383(); - void case1384(); - void case1385(); - void case1386(); - void case1387(); - void case1388(); - void case1389(); - void case1390(); - void case1391(); - void case1392(); - void case1393(); - void case1394(); - void case1395(); - void case1396(); - void case1397(); - void case1398(); - void case1399(); + void case1300(); + void case1301(); + void case1302(); + void case1303(); + void case1304(); + void case1305(); + void case1306(); + void case1307(); + void case1308(); + void case1309(); + void case1310(); + void case1311(); + void case1312(); + void case1313(); + void case1314(); + void case1315(); + void case1316(); + void case1317(); + void case1318(); + void case1319(); + void case1320(); + void case1321(); + void case1322(); + void case1323(); + void case1324(); + void case1325(); + void case1326(); + void case1327(); + void case1328(); + void case1329(); + void case1330(); + void case1331(); + void case1332(); + void case1333(); + void case1334(); + void case1335(); + void case1336(); + void case1337(); + void case1338(); + void case1339(); + void case1340(); + void case1341(); + void case1342(); + void case1343(); + void case1344(); + void case1345(); + void case1346(); + void case1347(); + void case1348(); + void case1349(); + void case1350(); + void case1351(); + void case1352(); + void case1353(); + void case1354(); + void case1355(); + void case1356(); + void case1357(); + void case1358(); + void case1359(); + void case1360(); + void case1361(); + void case1362(); + void case1363(); + void case1364(); + void case1365(); + void case1366(); + void case1367(); + void case1368(); + void case1369(); + void case1370(); + void case1371(); + void case1372(); + void case1373(); + void case1374(); + void case1375(); + void case1376(); + void case1377(); + void case1378(); + void case1379(); + void case1380(); + void case1381(); + void case1382(); + void case1383(); + void case1384(); + void case1385(); + void case1386(); + void case1387(); + void case1388(); + void case1389(); + void case1390(); + void case1391(); + void case1392(); + void case1393(); + void case1394(); + void case1395(); + void case1396(); + void case1397(); + void case1398(); + void case1399(); - // 2000-2999 + // 2000-2999 - void case2000(); - void case2001(); - void case2002(); - void case2003(); - void case2004(); - void case2005(); - void case2006(); - void case2007(); - void case2008(); - void case2009(); - void case2010(); - void case2011(); - void case2012(); - void case2013(); - void case2014(); - void case2015(); - void case2016(); - void case2017(); - void case2018(); - void case2019(); - void case2020(); - void case2021(); - void case2022(); - void case2023(); - void case2024(); - void case2025(); - void case2026(); - void case2027(); - void case2028(); - void case2029(); - void case2030(); - void case2031(); - void case2032(); - void case2033(); - void case2034(); - void case2035(); - void case2036(); - void case2037(); - void case2038(); - void case2039(); - void case2040(); - void case2041(); - void case2042(); - void case2043(); - void case2044(); - void case2045(); - void case2046(); - void case2047(); - void case2048(); - void case2049(); - void case2050(); - void case2051(); - void case2052(); - void case2053(); - void case2054(); - void case2055(); - void case2056(); - void case2057(); - void case2058(); - void case2059(); - void case2060(); - void case2061(); - void case2062(); - void case2063(); - void case2064(); - void case2065(); - void case2066(); - void case2067(); - void case2068(); - void case2069(); - void case2070(); - void case2071(); - void case2072(); - void case2073(); - void case2074(); - void case2075(); - void case2076(); - void case2077(); - void case2078(); - void case2079(); - void case2080(); - void case2081(); - void case2082(); - void case2083(); - void case2084(); - void case2085(); - void case2086(); - void case2087(); - void case2088(); - void case2089(); - void case2090(); - void case2091(); - void case2092(); - void case2093(); - void case2094(); - void case2095(); - void case2096(); - void case2097(); - void case2098(); - void case2099(); + void case2000(); + void case2001(); + void case2002(); + void case2003(); + void case2004(); + void case2005(); + void case2006(); + void case2007(); + void case2008(); + void case2009(); + void case2010(); + void case2011(); + void case2012(); + void case2013(); + void case2014(); + void case2015(); + void case2016(); + void case2017(); + void case2018(); + void case2019(); + void case2020(); + void case2021(); + void case2022(); + void case2023(); + void case2024(); + void case2025(); + void case2026(); + void case2027(); + void case2028(); + void case2029(); + void case2030(); + void case2031(); + void case2032(); + void case2033(); + void case2034(); + void case2035(); + void case2036(); + void case2037(); + void case2038(); + void case2039(); + void case2040(); + void case2041(); + void case2042(); + void case2043(); + void case2044(); + void case2045(); + void case2046(); + void case2047(); + void case2048(); + void case2049(); + void case2050(); + void case2051(); + void case2052(); + void case2053(); + void case2054(); + void case2055(); + void case2056(); + void case2057(); + void case2058(); + void case2059(); + void case2060(); + void case2061(); + void case2062(); + void case2063(); + void case2064(); + void case2065(); + void case2066(); + void case2067(); + void case2068(); + void case2069(); + void case2070(); + void case2071(); + void case2072(); + void case2073(); + void case2074(); + void case2075(); + void case2076(); + void case2077(); + void case2078(); + void case2079(); + void case2080(); + void case2081(); + void case2082(); + void case2083(); + void case2084(); + void case2085(); + void case2086(); + void case2087(); + void case2088(); + void case2089(); + void case2090(); + void case2091(); + void case2092(); + void case2093(); + void case2094(); + void case2095(); + void case2096(); + void case2097(); + void case2098(); + void case2099(); - void case2100(); - void case2101(); - void case2102(); - void case2103(); - void case2104(); - void case2105(); - void case2106(); - void case2107(); - void case2108(); - void case2109(); - void case2110(); - void case2111(); - void case2112(); - void case2113(); - void case2114(); - void case2115(); - void case2116(); - void case2117(); - void case2118(); - void case2119(); - void case2120(); - void case2121(); - void case2122(); - void case2123(); - void case2124(); - void case2125(); - void case2126(); - void case2127(); - void case2128(); - void case2129(); - void case2130(); - void case2131(); - void case2132(); - void case2133(); - void case2134(); - void case2135(); - void case2136(); - void case2137(); - void case2138(); - void case2139(); - void case2140(); - void case2141(); - void case2142(); - void case2143(); - void case2144(); - void case2145(); - void case2146(); - void case2147(); - void case2148(); - void case2149(); - void case2150(); - void case2151(); - void case2152(); - void case2153(); - void case2154(); - void case2155(); - void case2156(); - void case2157(); - void case2158(); - void case2159(); - void case2160(); - void case2161(); - void case2162(); - void case2163(); - void case2164(); - void case2165(); - void case2166(); - void case2167(); - void case2168(); - void case2169(); - void case2170(); - void case2171(); - void case2172(); - void case2173(); - void case2174(); - void case2175(); - void case2176(); - void case2177(); - void case2178(); - void case2179(); - void case2180(); - void case2181(); - void case2182(); - void case2183(); - void case2184(); - void case2185(); - void case2186(); - void case2187(); - void case2188(); - void case2189(); - void case2190(); - void case2191(); - void case2192(); - void case2193(); - void case2194(); - void case2195(); - void case2196(); - void case2197(); - void case2198(); - void case2199(); + void case2100(); + void case2101(); + void case2102(); + void case2103(); + void case2104(); + void case2105(); + void case2106(); + void case2107(); + void case2108(); + void case2109(); + void case2110(); + void case2111(); + void case2112(); + void case2113(); + void case2114(); + void case2115(); + void case2116(); + void case2117(); + void case2118(); + void case2119(); + void case2120(); + void case2121(); + void case2122(); + void case2123(); + void case2124(); + void case2125(); + void case2126(); + void case2127(); + void case2128(); + void case2129(); + void case2130(); + void case2131(); + void case2132(); + void case2133(); + void case2134(); + void case2135(); + void case2136(); + void case2137(); + void case2138(); + void case2139(); + void case2140(); + void case2141(); + void case2142(); + void case2143(); + void case2144(); + void case2145(); + void case2146(); + void case2147(); + void case2148(); + void case2149(); + void case2150(); + void case2151(); + void case2152(); + void case2153(); + void case2154(); + void case2155(); + void case2156(); + void case2157(); + void case2158(); + void case2159(); + void case2160(); + void case2161(); + void case2162(); + void case2163(); + void case2164(); + void case2165(); + void case2166(); + void case2167(); + void case2168(); + void case2169(); + void case2170(); + void case2171(); + void case2172(); + void case2173(); + void case2174(); + void case2175(); + void case2176(); + void case2177(); + void case2178(); + void case2179(); + void case2180(); + void case2181(); + void case2182(); + void case2183(); + void case2184(); + void case2185(); + void case2186(); + void case2187(); + void case2188(); + void case2189(); + void case2190(); + void case2191(); + void case2192(); + void case2193(); + void case2194(); + void case2195(); + void case2196(); + void case2197(); + void case2198(); + void case2199(); - void case2200(); - void case2201(); - void case2202(); - void case2203(); - void case2204(); - void case2205(); - void case2206(); - void case2207(); - void case2208(); - void case2209(); - void case2210(); - void case2211(); - void case2212(); - void case2213(); - void case2214(); - void case2215(); - void case2216(); - void case2217(); - void case2218(); - void case2219(); - void case2220(); - void case2221(); - void case2222(); - void case2223(); - void case2224(); - void case2225(); - void case2226(); - void case2227(); - void case2228(); - void case2229(); - void case2230(); - void case2231(); - void case2232(); - void case2233(); - void case2234(); - void case2235(); - void case2236(); - void case2237(); - void case2238(); - void case2239(); - void case2240(); - void case2241(); - void case2242(); - void case2243(); - void case2244(); - void case2245(); - void case2246(); - void case2247(); - void case2248(); - void case2249(); - void case2250(); - void case2251(); - void case2252(); - void case2253(); - void case2254(); - void case2255(); - void case2256(); - void case2257(); - void case2258(); - void case2259(); - void case2260(); - void case2261(); - void case2262(); - void case2263(); - void case2264(); - void case2265(); - void case2266(); - void case2267(); - void case2268(); - void case2269(); - void case2270(); - void case2271(); - void case2272(); - void case2273(); - void case2274(); - void case2275(); - void case2276(); - void case2277(); - void case2278(); - void case2279(); - void case2280(); - void case2281(); - void case2282(); - void case2283(); - void case2284(); - void case2285(); - void case2286(); - void case2287(); - void case2288(); - void case2289(); - void case2290(); - void case2291(); - void case2292(); - void case2293(); - void case2294(); - void case2295(); - void case2296(); - void case2297(); - void case2298(); - void case2299(); + void case2200(); + void case2201(); + void case2202(); + void case2203(); + void case2204(); + void case2205(); + void case2206(); + void case2207(); + void case2208(); + void case2209(); + void case2210(); + void case2211(); + void case2212(); + void case2213(); + void case2214(); + void case2215(); + void case2216(); + void case2217(); + void case2218(); + void case2219(); + void case2220(); + void case2221(); + void case2222(); + void case2223(); + void case2224(); + void case2225(); + void case2226(); + void case2227(); + void case2228(); + void case2229(); + void case2230(); + void case2231(); + void case2232(); + void case2233(); + void case2234(); + void case2235(); + void case2236(); + void case2237(); + void case2238(); + void case2239(); + void case2240(); + void case2241(); + void case2242(); + void case2243(); + void case2244(); + void case2245(); + void case2246(); + void case2247(); + void case2248(); + void case2249(); + void case2250(); + void case2251(); + void case2252(); + void case2253(); + void case2254(); + void case2255(); + void case2256(); + void case2257(); + void case2258(); + void case2259(); + void case2260(); + void case2261(); + void case2262(); + void case2263(); + void case2264(); + void case2265(); + void case2266(); + void case2267(); + void case2268(); + void case2269(); + void case2270(); + void case2271(); + void case2272(); + void case2273(); + void case2274(); + void case2275(); + void case2276(); + void case2277(); + void case2278(); + void case2279(); + void case2280(); + void case2281(); + void case2282(); + void case2283(); + void case2284(); + void case2285(); + void case2286(); + void case2287(); + void case2288(); + void case2289(); + void case2290(); + void case2291(); + void case2292(); + void case2293(); + void case2294(); + void case2295(); + void case2296(); + void case2297(); + void case2298(); + void case2299(); - void case2300(); - void case2301(); - void case2302(); - void case2303(); - void case2304(); - void case2305(); - void case2306(); - void case2307(); - void case2308(); - void case2309(); - void case2310(); - void case2311(); - void case2312(); - void case2313(); - void case2314(); - void case2315(); - void case2316(); - void case2317(); - void case2318(); - void case2319(); - void case2320(); - void case2321(); - void case2322(); - void case2323(); - void case2324(); - void case2325(); - void case2326(); - void case2327(); - void case2328(); - void case2329(); - void case2330(); - void case2331(); - void case2332(); - void case2333(); - void case2334(); - void case2335(); - void case2336(); - void case2337(); - void case2338(); - void case2339(); - void case2340(); - void case2341(); - void case2342(); - void case2343(); - void case2344(); - void case2345(); - void case2346(); - void case2347(); - void case2348(); - void case2349(); - void case2350(); - void case2351(); - void case2352(); - void case2353(); - void case2354(); - void case2355(); - void case2356(); - void case2357(); - void case2358(); - void case2359(); - void case2360(); - void case2361(); - void case2362(); - void case2363(); - void case2364(); - void case2365(); - void case2366(); - void case2367(); - void case2368(); - void case2369(); - void case2370(); - void case2371(); - void case2372(); - void case2373(); - void case2374(); - void case2375(); - void case2376(); - void case2377(); - void case2378(); - void case2379(); - void case2380(); - void case2381(); - void case2382(); - void case2383(); - void case2384(); - void case2385(); - void case2386(); - void case2387(); - void case2388(); - void case2389(); - void case2390(); - void case2391(); - void case2392(); - void case2393(); - void case2394(); - void case2395(); - void case2396(); - void case2397(); - void case2398(); - void case2399(); + void case2300(); + void case2301(); + void case2302(); + void case2303(); + void case2304(); + void case2305(); + void case2306(); + void case2307(); + void case2308(); + void case2309(); + void case2310(); + void case2311(); + void case2312(); + void case2313(); + void case2314(); + void case2315(); + void case2316(); + void case2317(); + void case2318(); + void case2319(); + void case2320(); + void case2321(); + void case2322(); + void case2323(); + void case2324(); + void case2325(); + void case2326(); + void case2327(); + void case2328(); + void case2329(); + void case2330(); + void case2331(); + void case2332(); + void case2333(); + void case2334(); + void case2335(); + void case2336(); + void case2337(); + void case2338(); + void case2339(); + void case2340(); + void case2341(); + void case2342(); + void case2343(); + void case2344(); + void case2345(); + void case2346(); + void case2347(); + void case2348(); + void case2349(); + void case2350(); + void case2351(); + void case2352(); + void case2353(); + void case2354(); + void case2355(); + void case2356(); + void case2357(); + void case2358(); + void case2359(); + void case2360(); + void case2361(); + void case2362(); + void case2363(); + void case2364(); + void case2365(); + void case2366(); + void case2367(); + void case2368(); + void case2369(); + void case2370(); + void case2371(); + void case2372(); + void case2373(); + void case2374(); + void case2375(); + void case2376(); + void case2377(); + void case2378(); + void case2379(); + void case2380(); + void case2381(); + void case2382(); + void case2383(); + void case2384(); + void case2385(); + void case2386(); + void case2387(); + void case2388(); + void case2389(); + void case2390(); + void case2391(); + void case2392(); + void case2393(); + void case2394(); + void case2395(); + void case2396(); + void case2397(); + void case2398(); + void case2399(); - // 3000-3999 + // 3000-3999 - void case3001(); - void case3002(); - void case3003(); - void case3004(); - void case3005(); - void case3006(); - void case3007(); - void case3008(); - void case3009(); - void case3010(); - void case3011(); - void case3012(); - void case3013(); - void case3014(); - void case3015(); - void case3016(); - void case3017(); - void case3018(); - void case3019(); - void case3020(); - void case3021(); - void case3022(); - void case3023(); - void case3024(); - void case3025(); - void case3026(); - void case3027(); - void case3028(); - void case3029(); - void case3030(); - void case3031(); - void case3032(); - void case3033(); - void case3034(); - void case3035(); - void case3036(); - void case3037(); - void case3038(); - void case3039(); - void case3040(); - void case3041(); - void case3042(); - void case3043(); - void case3044(); - void case3045(); - void case3046(); - void case3047(); - void case3048(); - void case3049(); - void case3050(); - void case3051(); - void case3052(); - void case3053(); - void case3054(); - void case3055(); - void case3056(); - void case3057(); - void case3058(); - void case3059(); - void case3060(); - void case3061(); - void case3062(); - void case3063(); - void case3064(); - void case3065(); - void case3066(); - void case3067(); - void case3068(); - void case3069(); - void case3070(); - void case3071(); - void case3072(); - void case3073(); - void case3074(); - void case3075(); - void case3076(); - void case3077(); - void case3078(); - void case3079(); - void case3080(); - void case3081(); - void case3082(); - void case3083(); - void case3084(); - void case3085(); - void case3086(); - void case3087(); - void case3088(); - void case3089(); - void case3090(); - void case3091(); - void case3092(); - void case3093(); - void case3094(); - void case3095(); - void case3096(); - void case3097(); - void case3098(); - void case3099(); + void case3001(); + void case3002(); + void case3003(); + void case3004(); + void case3005(); + void case3006(); + void case3007(); + void case3008(); + void case3009(); + void case3010(); + void case3011(); + void case3012(); + void case3013(); + void case3014(); + void case3015(); + void case3016(); + void case3017(); + void case3018(); + void case3019(); + void case3020(); + void case3021(); + void case3022(); + void case3023(); + void case3024(); + void case3025(); + void case3026(); + void case3027(); + void case3028(); + void case3029(); + void case3030(); + void case3031(); + void case3032(); + void case3033(); + void case3034(); + void case3035(); + void case3036(); + void case3037(); + void case3038(); + void case3039(); + void case3040(); + void case3041(); + void case3042(); + void case3043(); + void case3044(); + void case3045(); + void case3046(); + void case3047(); + void case3048(); + void case3049(); + void case3050(); + void case3051(); + void case3052(); + void case3053(); + void case3054(); + void case3055(); + void case3056(); + void case3057(); + void case3058(); + void case3059(); + void case3060(); + void case3061(); + void case3062(); + void case3063(); + void case3064(); + void case3065(); + void case3066(); + void case3067(); + void case3068(); + void case3069(); + void case3070(); + void case3071(); + void case3072(); + void case3073(); + void case3074(); + void case3075(); + void case3076(); + void case3077(); + void case3078(); + void case3079(); + void case3080(); + void case3081(); + void case3082(); + void case3083(); + void case3084(); + void case3085(); + void case3086(); + void case3087(); + void case3088(); + void case3089(); + void case3090(); + void case3091(); + void case3092(); + void case3093(); + void case3094(); + void case3095(); + void case3096(); + void case3097(); + void case3098(); + void case3099(); - void case3100(); - void case3101(); - void case3102(); - void case3103(); - void case3104(); - void case3105(); - void case3106(); - void case3107(); - void case3108(); - void case3109(); - void case3110(); - void case3111(); - void case3112(); - void case3113(); - void case3114(); - void case3115(); - void case3116(); - void case3117(); - void case3118(); - void case3119(); - void case3120(); - void case3121(); - void case3122(); - void case3123(); - void case3124(); - void case3125(); - void case3126(); - void case3127(); - void case3128(); - void case3129(); - void case3130(); - void case3131(); - void case3132(); - void case3133(); - void case3134(); - void case3135(); - void case3136(); - void case3137(); - void case3138(); - void case3139(); - void case3140(); - void case3141(); - void case3142(); - void case3143(); - void case3144(); - void case3145(); - void case3146(); - void case3147(); - void case3148(); - void case3149(); - void case3150(); - void case3151(); - void case3152(); - void case3153(); - void case3154(); - void case3155(); - void case3156(); - void case3157(); - void case3158(); - void case3159(); - void case3160(); - void case3161(); - void case3162(); - void case3163(); - void case3164(); - void case3165(); - void case3166(); - void case3167(); - void case3168(); - void case3169(); - void case3170(); - void case3171(); - void case3172(); - void case3173(); - void case3174(); - void case3175(); - void case3176(); - void case3177(); - void case3178(); - void case3179(); - void case3180(); - void case3181(); - void case3182(); - void case3183(); - void case3184(); - void case3185(); - void case3186(); - void case3187(); - void case3188(); - void case3189(); - void case3190(); - void case3191(); - void case3192(); - void case3193(); - void case3194(); - void case3195(); - void case3196(); - void case3197(); - void case3198(); - void case3199(); + void case3100(); + void case3101(); + void case3102(); + void case3103(); + void case3104(); + void case3105(); + void case3106(); + void case3107(); + void case3108(); + void case3109(); + void case3110(); + void case3111(); + void case3112(); + void case3113(); + void case3114(); + void case3115(); + void case3116(); + void case3117(); + void case3118(); + void case3119(); + void case3120(); + void case3121(); + void case3122(); + void case3123(); + void case3124(); + void case3125(); + void case3126(); + void case3127(); + void case3128(); + void case3129(); + void case3130(); + void case3131(); + void case3132(); + void case3133(); + void case3134(); + void case3135(); + void case3136(); + void case3137(); + void case3138(); + void case3139(); + void case3140(); + void case3141(); + void case3142(); + void case3143(); + void case3144(); + void case3145(); + void case3146(); + void case3147(); + void case3148(); + void case3149(); + void case3150(); + void case3151(); + void case3152(); + void case3153(); + void case3154(); + void case3155(); + void case3156(); + void case3157(); + void case3158(); + void case3159(); + void case3160(); + void case3161(); + void case3162(); + void case3163(); + void case3164(); + void case3165(); + void case3166(); + void case3167(); + void case3168(); + void case3169(); + void case3170(); + void case3171(); + void case3172(); + void case3173(); + void case3174(); + void case3175(); + void case3176(); + void case3177(); + void case3178(); + void case3179(); + void case3180(); + void case3181(); + void case3182(); + void case3183(); + void case3184(); + void case3185(); + void case3186(); + void case3187(); + void case3188(); + void case3189(); + void case3190(); + void case3191(); + void case3192(); + void case3193(); + void case3194(); + void case3195(); + void case3196(); + void case3197(); + void case3198(); + void case3199(); - void case3200(); - void case3201(); - void case3202(); - void case3203(); - void case3204(); - void case3205(); - void case3206(); - void case3207(); - void case3208(); - void case3209(); - void case3210(); - void case3211(); - void case3212(); - void case3213(); - void case3214(); - void case3215(); - void case3216(); - void case3217(); - void case3218(); - void case3219(); - void case3220(); - void case3221(); - void case3222(); - void case3223(); - void case3224(); - void case3225(); - void case3226(); - void case3227(); - void case3228(); - void case3229(); - void case3230(); - void case3231(); - void case3232(); - void case3233(); - void case3234(); - void case3235(); - void case3236(); - void case3237(); - void case3238(); - void case3239(); - void case3240(); - void case3241(); - void case3242(); - void case3243(); - void case3244(); - void case3245(); - void case3246(); - void case3247(); - void case3248(); - void case3249(); - void case3250(); - void case3251(); - void case3252(); - void case3253(); - void case3254(); - void case3255(); - void case3256(); - void case3257(); - void case3258(); - void case3259(); - void case3260(); - void case3261(); - void case3262(); - void case3263(); - void case3264(); - void case3265(); - void case3266(); - void case3267(); - void case3268(); - void case3269(); - void case3270(); - void case3271(); - void case3272(); - void case3273(); - void case3274(); - void case3275(); - void case3276(); - void case3277(); - void case3278(); - void case3279(); - void case3280(); - void case3281(); - void case3282(); - void case3283(); - void case3284(); - void case3285(); - void case3286(); - void case3287(); - void case3288(); - void case3289(); - void case3290(); - void case3291(); - void case3292(); - void case3293(); - void case3294(); - void case3295(); - void case3296(); - void case3297(); - void case3298(); - void case3299(); + void case3200(); + void case3201(); + void case3202(); + void case3203(); + void case3204(); + void case3205(); + void case3206(); + void case3207(); + void case3208(); + void case3209(); + void case3210(); + void case3211(); + void case3212(); + void case3213(); + void case3214(); + void case3215(); + void case3216(); + void case3217(); + void case3218(); + void case3219(); + void case3220(); + void case3221(); + void case3222(); + void case3223(); + void case3224(); + void case3225(); + void case3226(); + void case3227(); + void case3228(); + void case3229(); + void case3230(); + void case3231(); + void case3232(); + void case3233(); + void case3234(); + void case3235(); + void case3236(); + void case3237(); + void case3238(); + void case3239(); + void case3240(); + void case3241(); + void case3242(); + void case3243(); + void case3244(); + void case3245(); + void case3246(); + void case3247(); + void case3248(); + void case3249(); + void case3250(); + void case3251(); + void case3252(); + void case3253(); + void case3254(); + void case3255(); + void case3256(); + void case3257(); + void case3258(); + void case3259(); + void case3260(); + void case3261(); + void case3262(); + void case3263(); + void case3264(); + void case3265(); + void case3266(); + void case3267(); + void case3268(); + void case3269(); + void case3270(); + void case3271(); + void case3272(); + void case3273(); + void case3274(); + void case3275(); + void case3276(); + void case3277(); + void case3278(); + void case3279(); + void case3280(); + void case3281(); + void case3282(); + void case3283(); + void case3284(); + void case3285(); + void case3286(); + void case3287(); + void case3288(); + void case3289(); + void case3290(); + void case3291(); + void case3292(); + void case3293(); + void case3294(); + void case3295(); + void case3296(); + void case3297(); + void case3298(); + void case3299(); - void case3300(); - void case3301(); - void case3302(); - void case3303(); - void case3304(); - void case3305(); - void case3306(); - void case3307(); - void case3308(); - void case3309(); - void case3310(); - void case3311(); - void case3312(); - void case3313(); - void case3314(); - void case3315(); - void case3316(); - void case3317(); - void case3318(); - void case3319(); - void case3320(); - void case3321(); - void case3322(); - void case3323(); - void case3324(); - void case3325(); - void case3326(); - void case3327(); - void case3328(); - void case3329(); - void case3330(); - void case3331(); - void case3332(); - void case3333(); - void case3334(); - void case3335(); - void case3336(); - void case3337(); - void case3338(); - void case3339(); - void case3340(); - void case3341(); - void case3342(); - void case3343(); - void case3344(); - void case3345(); - void case3346(); - void case3347(); - void case3348(); - void case3349(); - void case3350(); - void case3351(); - void case3352(); - void case3353(); - void case3354(); - void case3355(); - void case3356(); - void case3357(); - void case3358(); - void case3359(); - void case3360(); - void case3361(); - void case3362(); - void case3363(); - void case3364(); - void case3365(); - void case3366(); - void case3367(); - void case3368(); - void case3369(); - void case3370(); - void case3371(); - void case3372(); - void case3373(); - void case3374(); - void case3375(); - void case3376(); - void case3377(); - void case3378(); - void case3379(); - void case3380(); - void case3381(); - void case3382(); - void case3383(); - void case3384(); - void case3385(); - void case3386(); - void case3387(); - void case3388(); - void case3389(); - void case3390(); - void case3391(); - void case3392(); - void case3393(); - void case3394(); - void case3395(); - void case3396(); - void case3397(); - void case3398(); - void case3399(); + void case3300(); + void case3301(); + void case3302(); + void case3303(); + void case3304(); + void case3305(); + void case3306(); + void case3307(); + void case3308(); + void case3309(); + void case3310(); + void case3311(); + void case3312(); + void case3313(); + void case3314(); + void case3315(); + void case3316(); + void case3317(); + void case3318(); + void case3319(); + void case3320(); + void case3321(); + void case3322(); + void case3323(); + void case3324(); + void case3325(); + void case3326(); + void case3327(); + void case3328(); + void case3329(); + void case3330(); + void case3331(); + void case3332(); + void case3333(); + void case3334(); + void case3335(); + void case3336(); + void case3337(); + void case3338(); + void case3339(); + void case3340(); + void case3341(); + void case3342(); + void case3343(); + void case3344(); + void case3345(); + void case3346(); + void case3347(); + void case3348(); + void case3349(); + void case3350(); + void case3351(); + void case3352(); + void case3353(); + void case3354(); + void case3355(); + void case3356(); + void case3357(); + void case3358(); + void case3359(); + void case3360(); + void case3361(); + void case3362(); + void case3363(); + void case3364(); + void case3365(); + void case3366(); + void case3367(); + void case3368(); + void case3369(); + void case3370(); + void case3371(); + void case3372(); + void case3373(); + void case3374(); + void case3375(); + void case3376(); + void case3377(); + void case3378(); + void case3379(); + void case3380(); + void case3381(); + void case3382(); + void case3383(); + void case3384(); + void case3385(); + void case3386(); + void case3387(); + void case3388(); + void case3389(); + void case3390(); + void case3391(); + void case3392(); + void case3393(); + void case3394(); + void case3395(); + void case3396(); + void case3397(); + void case3398(); + void case3399(); - void case3400(); - void case3401(); - void case3402(); - void case3403(); - void case3404(); - void case3405(); - void case3406(); - void case3407(); - void case3408(); - void case3409(); - void case3410(); - void case3411(); - void case3412(); - void case3413(); - void case3414(); - void case3415(); - void case3416(); - void case3417(); - void case3418(); - void case3419(); - void case3420(); - void case3421(); - void case3422(); - void case3423(); - void case3424(); - void case3425(); - void case3426(); - void case3427(); - void case3428(); - void case3429(); - void case3430(); - void case3431(); - void case3432(); - void case3433(); - void case3434(); - void case3435(); - void case3436(); - void case3437(); - void case3438(); - void case3439(); - void case3440(); - void case3441(); - void case3442(); - void case3443(); - void case3444(); - void case3445(); - void case3446(); - void case3447(); - void case3448(); - void case3449(); - void case3450(); - void case3451(); - void case3452(); - void case3453(); - void case3454(); - void case3455(); - void case3456(); - void case3457(); - void case3458(); - void case3459(); - void case3460(); - void case3461(); - void case3462(); - void case3463(); - void case3464(); - void case3465(); - void case3466(); - void case3467(); - void case3468(); - void case3469(); - void case3470(); - void case3471(); - void case3472(); - void case3473(); - void case3474(); - void case3475(); - void case3476(); - void case3477(); - void case3478(); - void case3479(); - void case3480(); - void case3481(); - void case3482(); - void case3483(); - void case3484(); - void case3485(); - void case3486(); - void case3487(); - void case3488(); - void case3489(); - void case3490(); - void case3491(); - void case3492(); - void case3493(); - void case3494(); - void case3495(); - void case3496(); - void case3497(); - void case3498(); - void case3499(); + void case3400(); + void case3401(); + void case3402(); + void case3403(); + void case3404(); + void case3405(); + void case3406(); + void case3407(); + void case3408(); + void case3409(); + void case3410(); + void case3411(); + void case3412(); + void case3413(); + void case3414(); + void case3415(); + void case3416(); + void case3417(); + void case3418(); + void case3419(); + void case3420(); + void case3421(); + void case3422(); + void case3423(); + void case3424(); + void case3425(); + void case3426(); + void case3427(); + void case3428(); + void case3429(); + void case3430(); + void case3431(); + void case3432(); + void case3433(); + void case3434(); + void case3435(); + void case3436(); + void case3437(); + void case3438(); + void case3439(); + void case3440(); + void case3441(); + void case3442(); + void case3443(); + void case3444(); + void case3445(); + void case3446(); + void case3447(); + void case3448(); + void case3449(); + void case3450(); + void case3451(); + void case3452(); + void case3453(); + void case3454(); + void case3455(); + void case3456(); + void case3457(); + void case3458(); + void case3459(); + void case3460(); + void case3461(); + void case3462(); + void case3463(); + void case3464(); + void case3465(); + void case3466(); + void case3467(); + void case3468(); + void case3469(); + void case3470(); + void case3471(); + void case3472(); + void case3473(); + void case3474(); + void case3475(); + void case3476(); + void case3477(); + void case3478(); + void case3479(); + void case3480(); + void case3481(); + void case3482(); + void case3483(); + void case3484(); + void case3485(); + void case3486(); + void case3487(); + void case3488(); + void case3489(); + void case3490(); + void case3491(); + void case3492(); + void case3493(); + void case3494(); + void case3495(); + void case3496(); + void case3497(); + void case3498(); + void case3499(); - void case3500(); - void case3501(); - void case3502(); - void case3503(); - void case3504(); - void case3505(); - void case3506(); - void case3507(); - void case3508(); - void case3509(); - void case3510(); - void case3511(); - void case3512(); - void case3513(); - void case3514(); - void case3515(); - void case3516(); - void case3517(); - void case3518(); - void case3519(); - void case3520(); - void case3521(); - void case3522(); - void case3523(); - void case3524(); - void case3525(); - void case3526(); - void case3527(); - void case3528(); - void case3529(); - void case3530(); - void case3531(); - void case3532(); - void case3533(); - void case3534(); - void case3535(); - void case3536(); - void case3537(); - void case3538(); - void case3539(); - void case3540(); - void case3541(); - void case3542(); - void case3543(); - void case3544(); - void case3545(); - void case3546(); - void case3547(); - void case3548(); - void case3549(); - void case3550(); - void case3551(); - void case3552(); - void case3553(); - void case3554(); - void case3555(); - void case3556(); - void case3557(); - void case3558(); - void case3559(); - void case3560(); - void case3561(); - void case3562(); - void case3563(); - void case3564(); - void case3565(); - void case3566(); - void case3567(); - void case3568(); - void case3569(); - void case3570(); - void case3571(); - void case3572(); - void case3573(); - void case3574(); - void case3575(); - void case3576(); - void case3577(); - void case3578(); - void case3579(); - void case3580(); - void case3581(); - void case3582(); - void case3583(); - void case3584(); - void case3585(); - void case3586(); - void case3587(); - void case3588(); - void case3589(); - void case3590(); - void case3591(); - void case3592(); - void case3593(); - void case3594(); - void case3595(); - void case3596(); - void case3597(); - void case3598(); - void case3599(); + void case3500(); + void case3501(); + void case3502(); + void case3503(); + void case3504(); + void case3505(); + void case3506(); + void case3507(); + void case3508(); + void case3509(); + void case3510(); + void case3511(); + void case3512(); + void case3513(); + void case3514(); + void case3515(); + void case3516(); + void case3517(); + void case3518(); + void case3519(); + void case3520(); + void case3521(); + void case3522(); + void case3523(); + void case3524(); + void case3525(); + void case3526(); + void case3527(); + void case3528(); + void case3529(); + void case3530(); + void case3531(); + void case3532(); + void case3533(); + void case3534(); + void case3535(); + void case3536(); + void case3537(); + void case3538(); + void case3539(); + void case3540(); + void case3541(); + void case3542(); + void case3543(); + void case3544(); + void case3545(); + void case3546(); + void case3547(); + void case3548(); + void case3549(); + void case3550(); + void case3551(); + void case3552(); + void case3553(); + void case3554(); + void case3555(); + void case3556(); + void case3557(); + void case3558(); + void case3559(); + void case3560(); + void case3561(); + void case3562(); + void case3563(); + void case3564(); + void case3565(); + void case3566(); + void case3567(); + void case3568(); + void case3569(); + void case3570(); + void case3571(); + void case3572(); + void case3573(); + void case3574(); + void case3575(); + void case3576(); + void case3577(); + void case3578(); + void case3579(); + void case3580(); + void case3581(); + void case3582(); + void case3583(); + void case3584(); + void case3585(); + void case3586(); + void case3587(); + void case3588(); + void case3589(); + void case3590(); + void case3591(); + void case3592(); + void case3593(); + void case3594(); + void case3595(); + void case3596(); + void case3597(); + void case3598(); + void case3599(); - std::vector tests_ - { - TEST_BINDER(case0001), - TEST_BINDER(case0002), - TEST_BINDER(case0003), - TEST_BINDER(case0004), - TEST_BINDER(case0005), - TEST_BINDER(case0006), - TEST_BINDER(case0007), - TEST_BINDER(case0008), - TEST_BINDER(case0009), - TEST_BINDER(case0010), - TEST_BINDER(case0011), - TEST_BINDER(case0012), - TEST_BINDER(case0013), - TEST_BINDER(case0014), - TEST_BINDER(case0015), - TEST_BINDER(case0016), - TEST_BINDER(case0017), - TEST_BINDER(case0018), - TEST_BINDER(case0019), - TEST_BINDER(case0020), - TEST_BINDER(case0021), - TEST_BINDER(case0022), - TEST_BINDER(case0023), - TEST_BINDER(case0024), - TEST_BINDER(case0025), - TEST_BINDER(case0026), - TEST_BINDER(case0027), - TEST_BINDER(case0028), - TEST_BINDER(case0029), - TEST_BINDER(case0030), - TEST_BINDER(case0031), - TEST_BINDER(case0032), - TEST_BINDER(case0033), - TEST_BINDER(case0034), - TEST_BINDER(case0035), - TEST_BINDER(case0036), - TEST_BINDER(case0037), - TEST_BINDER(case0038), - TEST_BINDER(case0039), - TEST_BINDER(case0040), - TEST_BINDER(case0041), - TEST_BINDER(case0042), - TEST_BINDER(case0043), - TEST_BINDER(case0044), - TEST_BINDER(case0045), - TEST_BINDER(case0046), - TEST_BINDER(case0047), - TEST_BINDER(case0048), - TEST_BINDER(case0049), - TEST_BINDER(case0050), - TEST_BINDER(case0051), - TEST_BINDER(case0052), - TEST_BINDER(case0053), - TEST_BINDER(case0054), - TEST_BINDER(case0055), - TEST_BINDER(case0056), - TEST_BINDER(case0057), - TEST_BINDER(case0058), - TEST_BINDER(case0059), - TEST_BINDER(case0060), - TEST_BINDER(case0061), - TEST_BINDER(case0062), - TEST_BINDER(case0063), - TEST_BINDER(case0064), - TEST_BINDER(case0065), - TEST_BINDER(case0066), - TEST_BINDER(case0067), - TEST_BINDER(case0068), - TEST_BINDER(case0069), - TEST_BINDER(case0070), - TEST_BINDER(case0071), - TEST_BINDER(case0072), - TEST_BINDER(case0073), - TEST_BINDER(case0074), - TEST_BINDER(case0075), - TEST_BINDER(case0076), - TEST_BINDER(case0077), - TEST_BINDER(case0078), - TEST_BINDER(case0079), - TEST_BINDER(case0080), - TEST_BINDER(case0081), - TEST_BINDER(case0082), - TEST_BINDER(case0083), - TEST_BINDER(case0084), - TEST_BINDER(case0085), - TEST_BINDER(case0086), - TEST_BINDER(case0087), - TEST_BINDER(case0088), - TEST_BINDER(case0089), - TEST_BINDER(case0090), - TEST_BINDER(case0091), - TEST_BINDER(case0092), - TEST_BINDER(case0093), - TEST_BINDER(case0094), - TEST_BINDER(case0095), - TEST_BINDER(case0096), - TEST_BINDER(case0097), - TEST_BINDER(case0098), - TEST_BINDER(case0099), + std::vector tests_{ + TEST_BINDER(case0001), TEST_BINDER(case0002), TEST_BINDER(case0003), + TEST_BINDER(case0004), TEST_BINDER(case0005), TEST_BINDER(case0006), + TEST_BINDER(case0007), TEST_BINDER(case0008), TEST_BINDER(case0009), + TEST_BINDER(case0010), TEST_BINDER(case0011), TEST_BINDER(case0012), + TEST_BINDER(case0013), TEST_BINDER(case0014), TEST_BINDER(case0015), + TEST_BINDER(case0016), TEST_BINDER(case0017), TEST_BINDER(case0018), + TEST_BINDER(case0019), TEST_BINDER(case0020), TEST_BINDER(case0021), + TEST_BINDER(case0022), TEST_BINDER(case0023), TEST_BINDER(case0024), + TEST_BINDER(case0025), TEST_BINDER(case0026), TEST_BINDER(case0027), + TEST_BINDER(case0028), TEST_BINDER(case0029), TEST_BINDER(case0030), + TEST_BINDER(case0031), TEST_BINDER(case0032), TEST_BINDER(case0033), + TEST_BINDER(case0034), TEST_BINDER(case0035), TEST_BINDER(case0036), + TEST_BINDER(case0037), TEST_BINDER(case0038), TEST_BINDER(case0039), + TEST_BINDER(case0040), TEST_BINDER(case0041), TEST_BINDER(case0042), + TEST_BINDER(case0043), TEST_BINDER(case0044), TEST_BINDER(case0045), + TEST_BINDER(case0046), TEST_BINDER(case0047), TEST_BINDER(case0048), + TEST_BINDER(case0049), TEST_BINDER(case0050), TEST_BINDER(case0051), + TEST_BINDER(case0052), TEST_BINDER(case0053), TEST_BINDER(case0054), + TEST_BINDER(case0055), TEST_BINDER(case0056), TEST_BINDER(case0057), + TEST_BINDER(case0058), TEST_BINDER(case0059), TEST_BINDER(case0060), + TEST_BINDER(case0061), TEST_BINDER(case0062), TEST_BINDER(case0063), + TEST_BINDER(case0064), TEST_BINDER(case0065), TEST_BINDER(case0066), + TEST_BINDER(case0067), TEST_BINDER(case0068), TEST_BINDER(case0069), + TEST_BINDER(case0070), TEST_BINDER(case0071), TEST_BINDER(case0072), + TEST_BINDER(case0073), TEST_BINDER(case0074), TEST_BINDER(case0075), + TEST_BINDER(case0076), TEST_BINDER(case0077), TEST_BINDER(case0078), + TEST_BINDER(case0079), TEST_BINDER(case0080), TEST_BINDER(case0081), + TEST_BINDER(case0082), TEST_BINDER(case0083), TEST_BINDER(case0084), + TEST_BINDER(case0085), TEST_BINDER(case0086), TEST_BINDER(case0087), + TEST_BINDER(case0088), TEST_BINDER(case0089), TEST_BINDER(case0090), + TEST_BINDER(case0091), TEST_BINDER(case0092), TEST_BINDER(case0093), + TEST_BINDER(case0094), TEST_BINDER(case0095), TEST_BINDER(case0096), + TEST_BINDER(case0097), TEST_BINDER(case0098), TEST_BINDER(case0099), - TEST_BINDER(case0100), - TEST_BINDER(case0101), - TEST_BINDER(case0102), - TEST_BINDER(case0103), - TEST_BINDER(case0104), - TEST_BINDER(case0105), - TEST_BINDER(case0106), - TEST_BINDER(case0107), - TEST_BINDER(case0108), - TEST_BINDER(case0109), - TEST_BINDER(case0110), - TEST_BINDER(case0111), - TEST_BINDER(case0112), - TEST_BINDER(case0113), - TEST_BINDER(case0114), - TEST_BINDER(case0115), - TEST_BINDER(case0116), - TEST_BINDER(case0117), - TEST_BINDER(case0118), - TEST_BINDER(case0119), - TEST_BINDER(case0120), - TEST_BINDER(case0121), - TEST_BINDER(case0122), - TEST_BINDER(case0123), - TEST_BINDER(case0124), - TEST_BINDER(case0125), - TEST_BINDER(case0126), - TEST_BINDER(case0127), - TEST_BINDER(case0128), - TEST_BINDER(case0129), - TEST_BINDER(case0130), - TEST_BINDER(case0131), - TEST_BINDER(case0132), - TEST_BINDER(case0133), - TEST_BINDER(case0134), - TEST_BINDER(case0135), - TEST_BINDER(case0136), - TEST_BINDER(case0137), - TEST_BINDER(case0138), - TEST_BINDER(case0139), - TEST_BINDER(case0140), - TEST_BINDER(case0141), - TEST_BINDER(case0142), - TEST_BINDER(case0143), - TEST_BINDER(case0144), - TEST_BINDER(case0145), - TEST_BINDER(case0146), - TEST_BINDER(case0147), - TEST_BINDER(case0148), - TEST_BINDER(case0149), - TEST_BINDER(case0150), - TEST_BINDER(case0151), - TEST_BINDER(case0152), - TEST_BINDER(case0153), - TEST_BINDER(case0154), - TEST_BINDER(case0155), - TEST_BINDER(case0156), - TEST_BINDER(case0157), - TEST_BINDER(case0158), - TEST_BINDER(case0159), - TEST_BINDER(case0160), - TEST_BINDER(case0161), - TEST_BINDER(case0162), - TEST_BINDER(case0163), - TEST_BINDER(case0164), - TEST_BINDER(case0165), - TEST_BINDER(case0166), - TEST_BINDER(case0167), - TEST_BINDER(case0168), - TEST_BINDER(case0169), - TEST_BINDER(case0170), - TEST_BINDER(case0171), - TEST_BINDER(case0172), - TEST_BINDER(case0173), - TEST_BINDER(case0174), - TEST_BINDER(case0175), - TEST_BINDER(case0176), - TEST_BINDER(case0177), - TEST_BINDER(case0178), - TEST_BINDER(case0179), - TEST_BINDER(case0180), - TEST_BINDER(case0181), - TEST_BINDER(case0182), - TEST_BINDER(case0183), - TEST_BINDER(case0184), - TEST_BINDER(case0185), - TEST_BINDER(case0186), - TEST_BINDER(case0187), - TEST_BINDER(case0188), - TEST_BINDER(case0189), - TEST_BINDER(case0190), - TEST_BINDER(case0191), - TEST_BINDER(case0192), - TEST_BINDER(case0193), - TEST_BINDER(case0194), - TEST_BINDER(case0195), - TEST_BINDER(case0196), - TEST_BINDER(case0197), - TEST_BINDER(case0198), - TEST_BINDER(case0199), + TEST_BINDER(case0100), TEST_BINDER(case0101), TEST_BINDER(case0102), + TEST_BINDER(case0103), TEST_BINDER(case0104), TEST_BINDER(case0105), + TEST_BINDER(case0106), TEST_BINDER(case0107), TEST_BINDER(case0108), + TEST_BINDER(case0109), TEST_BINDER(case0110), TEST_BINDER(case0111), + TEST_BINDER(case0112), TEST_BINDER(case0113), TEST_BINDER(case0114), + TEST_BINDER(case0115), TEST_BINDER(case0116), TEST_BINDER(case0117), + TEST_BINDER(case0118), TEST_BINDER(case0119), TEST_BINDER(case0120), + TEST_BINDER(case0121), TEST_BINDER(case0122), TEST_BINDER(case0123), + TEST_BINDER(case0124), TEST_BINDER(case0125), TEST_BINDER(case0126), + TEST_BINDER(case0127), TEST_BINDER(case0128), TEST_BINDER(case0129), + TEST_BINDER(case0130), TEST_BINDER(case0131), TEST_BINDER(case0132), + TEST_BINDER(case0133), TEST_BINDER(case0134), TEST_BINDER(case0135), + TEST_BINDER(case0136), TEST_BINDER(case0137), TEST_BINDER(case0138), + TEST_BINDER(case0139), TEST_BINDER(case0140), TEST_BINDER(case0141), + TEST_BINDER(case0142), TEST_BINDER(case0143), TEST_BINDER(case0144), + TEST_BINDER(case0145), TEST_BINDER(case0146), TEST_BINDER(case0147), + TEST_BINDER(case0148), TEST_BINDER(case0149), TEST_BINDER(case0150), + TEST_BINDER(case0151), TEST_BINDER(case0152), TEST_BINDER(case0153), + TEST_BINDER(case0154), TEST_BINDER(case0155), TEST_BINDER(case0156), + TEST_BINDER(case0157), TEST_BINDER(case0158), TEST_BINDER(case0159), + TEST_BINDER(case0160), TEST_BINDER(case0161), TEST_BINDER(case0162), + TEST_BINDER(case0163), TEST_BINDER(case0164), TEST_BINDER(case0165), + TEST_BINDER(case0166), TEST_BINDER(case0167), TEST_BINDER(case0168), + TEST_BINDER(case0169), TEST_BINDER(case0170), TEST_BINDER(case0171), + TEST_BINDER(case0172), TEST_BINDER(case0173), TEST_BINDER(case0174), + TEST_BINDER(case0175), TEST_BINDER(case0176), TEST_BINDER(case0177), + TEST_BINDER(case0178), TEST_BINDER(case0179), TEST_BINDER(case0180), + TEST_BINDER(case0181), TEST_BINDER(case0182), TEST_BINDER(case0183), + TEST_BINDER(case0184), TEST_BINDER(case0185), TEST_BINDER(case0186), + TEST_BINDER(case0187), TEST_BINDER(case0188), TEST_BINDER(case0189), + TEST_BINDER(case0190), TEST_BINDER(case0191), TEST_BINDER(case0192), + TEST_BINDER(case0193), TEST_BINDER(case0194), TEST_BINDER(case0195), + TEST_BINDER(case0196), TEST_BINDER(case0197), TEST_BINDER(case0198), + TEST_BINDER(case0199), - TEST_BINDER(case0200), - TEST_BINDER(case0201), - TEST_BINDER(case0202), - TEST_BINDER(case0203), - TEST_BINDER(case0204), - TEST_BINDER(case0205), - TEST_BINDER(case0206), - TEST_BINDER(case0207), - TEST_BINDER(case0208), - TEST_BINDER(case0209), - TEST_BINDER(case0210), - TEST_BINDER(case0211), - TEST_BINDER(case0212), - TEST_BINDER(case0213), - TEST_BINDER(case0214), - TEST_BINDER(case0215), - TEST_BINDER(case0216), - TEST_BINDER(case0217), - TEST_BINDER(case0218), - TEST_BINDER(case0219), - TEST_BINDER(case0220), - TEST_BINDER(case0221), - TEST_BINDER(case0222), - TEST_BINDER(case0223), - TEST_BINDER(case0224), - TEST_BINDER(case0225), - TEST_BINDER(case0226), - TEST_BINDER(case0227), - TEST_BINDER(case0228), - TEST_BINDER(case0229), - TEST_BINDER(case0230), - TEST_BINDER(case0231), - TEST_BINDER(case0232), - TEST_BINDER(case0233), - TEST_BINDER(case0234), - TEST_BINDER(case0235), - TEST_BINDER(case0236), - TEST_BINDER(case0237), - TEST_BINDER(case0238), - TEST_BINDER(case0239), - TEST_BINDER(case0240), - TEST_BINDER(case0241), - TEST_BINDER(case0242), - TEST_BINDER(case0243), - TEST_BINDER(case0244), - TEST_BINDER(case0245), - TEST_BINDER(case0246), - TEST_BINDER(case0247), - TEST_BINDER(case0248), - TEST_BINDER(case0249), - TEST_BINDER(case0250), - TEST_BINDER(case0251), - TEST_BINDER(case0252), - TEST_BINDER(case0253), - TEST_BINDER(case0254), - TEST_BINDER(case0255), - TEST_BINDER(case0256), - TEST_BINDER(case0257), - TEST_BINDER(case0258), - TEST_BINDER(case0259), - TEST_BINDER(case0260), - TEST_BINDER(case0261), - TEST_BINDER(case0262), - TEST_BINDER(case0263), - TEST_BINDER(case0264), - TEST_BINDER(case0265), - TEST_BINDER(case0266), - TEST_BINDER(case0267), - TEST_BINDER(case0268), - TEST_BINDER(case0269), - TEST_BINDER(case0270), - TEST_BINDER(case0271), - TEST_BINDER(case0272), - TEST_BINDER(case0273), - TEST_BINDER(case0274), - TEST_BINDER(case0275), - TEST_BINDER(case0276), - TEST_BINDER(case0277), - TEST_BINDER(case0278), - TEST_BINDER(case0279), - TEST_BINDER(case0280), - TEST_BINDER(case0281), - TEST_BINDER(case0282), - TEST_BINDER(case0283), - TEST_BINDER(case0284), - TEST_BINDER(case0285), - TEST_BINDER(case0286), - TEST_BINDER(case0287), - TEST_BINDER(case0288), - TEST_BINDER(case0289), - TEST_BINDER(case0290), - TEST_BINDER(case0291), - TEST_BINDER(case0292), - TEST_BINDER(case0293), - TEST_BINDER(case0294), - TEST_BINDER(case0295), - TEST_BINDER(case0296), - TEST_BINDER(case0297), - TEST_BINDER(case0298), - TEST_BINDER(case0299), + TEST_BINDER(case0200), TEST_BINDER(case0201), TEST_BINDER(case0202), + TEST_BINDER(case0203), TEST_BINDER(case0204), TEST_BINDER(case0205), + TEST_BINDER(case0206), TEST_BINDER(case0207), TEST_BINDER(case0208), + TEST_BINDER(case0209), TEST_BINDER(case0210), TEST_BINDER(case0211), + TEST_BINDER(case0212), TEST_BINDER(case0213), TEST_BINDER(case0214), + TEST_BINDER(case0215), TEST_BINDER(case0216), TEST_BINDER(case0217), + TEST_BINDER(case0218), TEST_BINDER(case0219), TEST_BINDER(case0220), + TEST_BINDER(case0221), TEST_BINDER(case0222), TEST_BINDER(case0223), + TEST_BINDER(case0224), TEST_BINDER(case0225), TEST_BINDER(case0226), + TEST_BINDER(case0227), TEST_BINDER(case0228), TEST_BINDER(case0229), + TEST_BINDER(case0230), TEST_BINDER(case0231), TEST_BINDER(case0232), + TEST_BINDER(case0233), TEST_BINDER(case0234), TEST_BINDER(case0235), + TEST_BINDER(case0236), TEST_BINDER(case0237), TEST_BINDER(case0238), + TEST_BINDER(case0239), TEST_BINDER(case0240), TEST_BINDER(case0241), + TEST_BINDER(case0242), TEST_BINDER(case0243), TEST_BINDER(case0244), + TEST_BINDER(case0245), TEST_BINDER(case0246), TEST_BINDER(case0247), + TEST_BINDER(case0248), TEST_BINDER(case0249), TEST_BINDER(case0250), + TEST_BINDER(case0251), TEST_BINDER(case0252), TEST_BINDER(case0253), + TEST_BINDER(case0254), TEST_BINDER(case0255), TEST_BINDER(case0256), + TEST_BINDER(case0257), TEST_BINDER(case0258), TEST_BINDER(case0259), + TEST_BINDER(case0260), TEST_BINDER(case0261), TEST_BINDER(case0262), + TEST_BINDER(case0263), TEST_BINDER(case0264), TEST_BINDER(case0265), + TEST_BINDER(case0266), TEST_BINDER(case0267), TEST_BINDER(case0268), + TEST_BINDER(case0269), TEST_BINDER(case0270), TEST_BINDER(case0271), + TEST_BINDER(case0272), TEST_BINDER(case0273), TEST_BINDER(case0274), + TEST_BINDER(case0275), TEST_BINDER(case0276), TEST_BINDER(case0277), + TEST_BINDER(case0278), TEST_BINDER(case0279), TEST_BINDER(case0280), + TEST_BINDER(case0281), TEST_BINDER(case0282), TEST_BINDER(case0283), + TEST_BINDER(case0284), TEST_BINDER(case0285), TEST_BINDER(case0286), + TEST_BINDER(case0287), TEST_BINDER(case0288), TEST_BINDER(case0289), + TEST_BINDER(case0290), TEST_BINDER(case0291), TEST_BINDER(case0292), + TEST_BINDER(case0293), TEST_BINDER(case0294), TEST_BINDER(case0295), + TEST_BINDER(case0296), TEST_BINDER(case0297), TEST_BINDER(case0298), + TEST_BINDER(case0299), - TEST_BINDER(case0300), - TEST_BINDER(case0301), - TEST_BINDER(case0302), - TEST_BINDER(case0303), - TEST_BINDER(case0304), - TEST_BINDER(case0305), - TEST_BINDER(case0306), - TEST_BINDER(case0307), - TEST_BINDER(case0308), - TEST_BINDER(case0309), - TEST_BINDER(case0310), - TEST_BINDER(case0311), - TEST_BINDER(case0312), - TEST_BINDER(case0313), - TEST_BINDER(case0314), - TEST_BINDER(case0315), - TEST_BINDER(case0316), - TEST_BINDER(case0317), - TEST_BINDER(case0318), - TEST_BINDER(case0319), - TEST_BINDER(case0320), - TEST_BINDER(case0321), - TEST_BINDER(case0322), - TEST_BINDER(case0323), - TEST_BINDER(case0324), - TEST_BINDER(case0325), - TEST_BINDER(case0326), - TEST_BINDER(case0327), - TEST_BINDER(case0328), - TEST_BINDER(case0329), - TEST_BINDER(case0330), - TEST_BINDER(case0331), - TEST_BINDER(case0332), - TEST_BINDER(case0333), - TEST_BINDER(case0334), - TEST_BINDER(case0335), - TEST_BINDER(case0336), - TEST_BINDER(case0337), - TEST_BINDER(case0338), - TEST_BINDER(case0339), - TEST_BINDER(case0340), - TEST_BINDER(case0341), - TEST_BINDER(case0342), - TEST_BINDER(case0343), - TEST_BINDER(case0344), - TEST_BINDER(case0345), - TEST_BINDER(case0346), - TEST_BINDER(case0347), - TEST_BINDER(case0348), - TEST_BINDER(case0349), - TEST_BINDER(case0350), - TEST_BINDER(case0351), - TEST_BINDER(case0352), - TEST_BINDER(case0353), - TEST_BINDER(case0354), - TEST_BINDER(case0355), - TEST_BINDER(case0356), - TEST_BINDER(case0357), - TEST_BINDER(case0358), - TEST_BINDER(case0359), - TEST_BINDER(case0360), - TEST_BINDER(case0361), - TEST_BINDER(case0362), - TEST_BINDER(case0363), - TEST_BINDER(case0364), - TEST_BINDER(case0365), - TEST_BINDER(case0366), - TEST_BINDER(case0367), - TEST_BINDER(case0368), - TEST_BINDER(case0369), - TEST_BINDER(case0370), - TEST_BINDER(case0371), - TEST_BINDER(case0372), - TEST_BINDER(case0373), - TEST_BINDER(case0374), - TEST_BINDER(case0375), - TEST_BINDER(case0376), - TEST_BINDER(case0377), - TEST_BINDER(case0378), - TEST_BINDER(case0379), - TEST_BINDER(case0380), - TEST_BINDER(case0381), - TEST_BINDER(case0382), - TEST_BINDER(case0383), - TEST_BINDER(case0384), - TEST_BINDER(case0385), - TEST_BINDER(case0386), - TEST_BINDER(case0387), - TEST_BINDER(case0388), - TEST_BINDER(case0389), - TEST_BINDER(case0390), - TEST_BINDER(case0391), - TEST_BINDER(case0392), - TEST_BINDER(case0393), - TEST_BINDER(case0394), - TEST_BINDER(case0395), - TEST_BINDER(case0396), - TEST_BINDER(case0397), - TEST_BINDER(case0398), - TEST_BINDER(case0399), + TEST_BINDER(case0300), TEST_BINDER(case0301), TEST_BINDER(case0302), + TEST_BINDER(case0303), TEST_BINDER(case0304), TEST_BINDER(case0305), + TEST_BINDER(case0306), TEST_BINDER(case0307), TEST_BINDER(case0308), + TEST_BINDER(case0309), TEST_BINDER(case0310), TEST_BINDER(case0311), + TEST_BINDER(case0312), TEST_BINDER(case0313), TEST_BINDER(case0314), + TEST_BINDER(case0315), TEST_BINDER(case0316), TEST_BINDER(case0317), + TEST_BINDER(case0318), TEST_BINDER(case0319), TEST_BINDER(case0320), + TEST_BINDER(case0321), TEST_BINDER(case0322), TEST_BINDER(case0323), + TEST_BINDER(case0324), TEST_BINDER(case0325), TEST_BINDER(case0326), + TEST_BINDER(case0327), TEST_BINDER(case0328), TEST_BINDER(case0329), + TEST_BINDER(case0330), TEST_BINDER(case0331), TEST_BINDER(case0332), + TEST_BINDER(case0333), TEST_BINDER(case0334), TEST_BINDER(case0335), + TEST_BINDER(case0336), TEST_BINDER(case0337), TEST_BINDER(case0338), + TEST_BINDER(case0339), TEST_BINDER(case0340), TEST_BINDER(case0341), + TEST_BINDER(case0342), TEST_BINDER(case0343), TEST_BINDER(case0344), + TEST_BINDER(case0345), TEST_BINDER(case0346), TEST_BINDER(case0347), + TEST_BINDER(case0348), TEST_BINDER(case0349), TEST_BINDER(case0350), + TEST_BINDER(case0351), TEST_BINDER(case0352), TEST_BINDER(case0353), + TEST_BINDER(case0354), TEST_BINDER(case0355), TEST_BINDER(case0356), + TEST_BINDER(case0357), TEST_BINDER(case0358), TEST_BINDER(case0359), + TEST_BINDER(case0360), TEST_BINDER(case0361), TEST_BINDER(case0362), + TEST_BINDER(case0363), TEST_BINDER(case0364), TEST_BINDER(case0365), + TEST_BINDER(case0366), TEST_BINDER(case0367), TEST_BINDER(case0368), + TEST_BINDER(case0369), TEST_BINDER(case0370), TEST_BINDER(case0371), + TEST_BINDER(case0372), TEST_BINDER(case0373), TEST_BINDER(case0374), + TEST_BINDER(case0375), TEST_BINDER(case0376), TEST_BINDER(case0377), + TEST_BINDER(case0378), TEST_BINDER(case0379), TEST_BINDER(case0380), + TEST_BINDER(case0381), TEST_BINDER(case0382), TEST_BINDER(case0383), + TEST_BINDER(case0384), TEST_BINDER(case0385), TEST_BINDER(case0386), + TEST_BINDER(case0387), TEST_BINDER(case0388), TEST_BINDER(case0389), + TEST_BINDER(case0390), TEST_BINDER(case0391), TEST_BINDER(case0392), + TEST_BINDER(case0393), TEST_BINDER(case0394), TEST_BINDER(case0395), + TEST_BINDER(case0396), TEST_BINDER(case0397), TEST_BINDER(case0398), + TEST_BINDER(case0399), - TEST_BINDER(case0400), - TEST_BINDER(case0401), - TEST_BINDER(case0402), - TEST_BINDER(case0403), - TEST_BINDER(case0404), - TEST_BINDER(case0405), - TEST_BINDER(case0406), - TEST_BINDER(case0407), - TEST_BINDER(case0408), - TEST_BINDER(case0409), - TEST_BINDER(case0410), - TEST_BINDER(case0411), - TEST_BINDER(case0412), - TEST_BINDER(case0413), - TEST_BINDER(case0414), - TEST_BINDER(case0415), - TEST_BINDER(case0416), - TEST_BINDER(case0417), - TEST_BINDER(case0418), - TEST_BINDER(case0419), - TEST_BINDER(case0420), - TEST_BINDER(case0421), - TEST_BINDER(case0422), - TEST_BINDER(case0423), - TEST_BINDER(case0424), - TEST_BINDER(case0425), - TEST_BINDER(case0426), - TEST_BINDER(case0427), - TEST_BINDER(case0428), - TEST_BINDER(case0429), - TEST_BINDER(case0430), - TEST_BINDER(case0431), - TEST_BINDER(case0432), - TEST_BINDER(case0433), - TEST_BINDER(case0434), - TEST_BINDER(case0435), - TEST_BINDER(case0436), - TEST_BINDER(case0437), - TEST_BINDER(case0438), - TEST_BINDER(case0439), - TEST_BINDER(case0440), - TEST_BINDER(case0441), - TEST_BINDER(case0442), - TEST_BINDER(case0443), - TEST_BINDER(case0444), - TEST_BINDER(case0445), - TEST_BINDER(case0446), - TEST_BINDER(case0447), - TEST_BINDER(case0448), - TEST_BINDER(case0449), - TEST_BINDER(case0450), - TEST_BINDER(case0451), - TEST_BINDER(case0452), - TEST_BINDER(case0453), - TEST_BINDER(case0454), - TEST_BINDER(case0455), - TEST_BINDER(case0456), - TEST_BINDER(case0457), - TEST_BINDER(case0458), - TEST_BINDER(case0459), - TEST_BINDER(case0460), - TEST_BINDER(case0461), - TEST_BINDER(case0462), - TEST_BINDER(case0463), - TEST_BINDER(case0464), - TEST_BINDER(case0465), - TEST_BINDER(case0466), - TEST_BINDER(case0467), - TEST_BINDER(case0468), - TEST_BINDER(case0469), - TEST_BINDER(case0470), - TEST_BINDER(case0471), - TEST_BINDER(case0472), - TEST_BINDER(case0473), - TEST_BINDER(case0474), - TEST_BINDER(case0475), - TEST_BINDER(case0476), - TEST_BINDER(case0477), - TEST_BINDER(case0478), - TEST_BINDER(case0479), - TEST_BINDER(case0480), - TEST_BINDER(case0481), - TEST_BINDER(case0482), - TEST_BINDER(case0483), - TEST_BINDER(case0484), - TEST_BINDER(case0485), - TEST_BINDER(case0486), - TEST_BINDER(case0487), - TEST_BINDER(case0488), - TEST_BINDER(case0489), - TEST_BINDER(case0490), - TEST_BINDER(case0491), - TEST_BINDER(case0492), - TEST_BINDER(case0493), - TEST_BINDER(case0494), - TEST_BINDER(case0495), - TEST_BINDER(case0496), - TEST_BINDER(case0497), - TEST_BINDER(case0498), - TEST_BINDER(case0499), + TEST_BINDER(case0400), TEST_BINDER(case0401), TEST_BINDER(case0402), + TEST_BINDER(case0403), TEST_BINDER(case0404), TEST_BINDER(case0405), + TEST_BINDER(case0406), TEST_BINDER(case0407), TEST_BINDER(case0408), + TEST_BINDER(case0409), TEST_BINDER(case0410), TEST_BINDER(case0411), + TEST_BINDER(case0412), TEST_BINDER(case0413), TEST_BINDER(case0414), + TEST_BINDER(case0415), TEST_BINDER(case0416), TEST_BINDER(case0417), + TEST_BINDER(case0418), TEST_BINDER(case0419), TEST_BINDER(case0420), + TEST_BINDER(case0421), TEST_BINDER(case0422), TEST_BINDER(case0423), + TEST_BINDER(case0424), TEST_BINDER(case0425), TEST_BINDER(case0426), + TEST_BINDER(case0427), TEST_BINDER(case0428), TEST_BINDER(case0429), + TEST_BINDER(case0430), TEST_BINDER(case0431), TEST_BINDER(case0432), + TEST_BINDER(case0433), TEST_BINDER(case0434), TEST_BINDER(case0435), + TEST_BINDER(case0436), TEST_BINDER(case0437), TEST_BINDER(case0438), + TEST_BINDER(case0439), TEST_BINDER(case0440), TEST_BINDER(case0441), + TEST_BINDER(case0442), TEST_BINDER(case0443), TEST_BINDER(case0444), + TEST_BINDER(case0445), TEST_BINDER(case0446), TEST_BINDER(case0447), + TEST_BINDER(case0448), TEST_BINDER(case0449), TEST_BINDER(case0450), + TEST_BINDER(case0451), TEST_BINDER(case0452), TEST_BINDER(case0453), + TEST_BINDER(case0454), TEST_BINDER(case0455), TEST_BINDER(case0456), + TEST_BINDER(case0457), TEST_BINDER(case0458), TEST_BINDER(case0459), + TEST_BINDER(case0460), TEST_BINDER(case0461), TEST_BINDER(case0462), + TEST_BINDER(case0463), TEST_BINDER(case0464), TEST_BINDER(case0465), + TEST_BINDER(case0466), TEST_BINDER(case0467), TEST_BINDER(case0468), + TEST_BINDER(case0469), TEST_BINDER(case0470), TEST_BINDER(case0471), + TEST_BINDER(case0472), TEST_BINDER(case0473), TEST_BINDER(case0474), + TEST_BINDER(case0475), TEST_BINDER(case0476), TEST_BINDER(case0477), + TEST_BINDER(case0478), TEST_BINDER(case0479), TEST_BINDER(case0480), + TEST_BINDER(case0481), TEST_BINDER(case0482), TEST_BINDER(case0483), + TEST_BINDER(case0484), TEST_BINDER(case0485), TEST_BINDER(case0486), + TEST_BINDER(case0487), TEST_BINDER(case0488), TEST_BINDER(case0489), + TEST_BINDER(case0490), TEST_BINDER(case0491), TEST_BINDER(case0492), + TEST_BINDER(case0493), TEST_BINDER(case0494), TEST_BINDER(case0495), + TEST_BINDER(case0496), TEST_BINDER(case0497), TEST_BINDER(case0498), + TEST_BINDER(case0499), - TEST_BINDER(case0500), - TEST_BINDER(case0501), - TEST_BINDER(case0502), - TEST_BINDER(case0503), - TEST_BINDER(case0504), - TEST_BINDER(case0505), - TEST_BINDER(case0506), - TEST_BINDER(case0507), - TEST_BINDER(case0508), - TEST_BINDER(case0509), - TEST_BINDER(case0510), - TEST_BINDER(case0511), - TEST_BINDER(case0512), - TEST_BINDER(case0513), - TEST_BINDER(case0514), - TEST_BINDER(case0515), - TEST_BINDER(case0516), - TEST_BINDER(case0517), - TEST_BINDER(case0518), - TEST_BINDER(case0519), - TEST_BINDER(case0520), - TEST_BINDER(case0521), - TEST_BINDER(case0522), - TEST_BINDER(case0523), - TEST_BINDER(case0524), - TEST_BINDER(case0525), - TEST_BINDER(case0526), - TEST_BINDER(case0527), - TEST_BINDER(case0528), - TEST_BINDER(case0529), - TEST_BINDER(case0530), - TEST_BINDER(case0531), - TEST_BINDER(case0532), - TEST_BINDER(case0533), - TEST_BINDER(case0534), - TEST_BINDER(case0535), - TEST_BINDER(case0536), - TEST_BINDER(case0537), - TEST_BINDER(case0538), - TEST_BINDER(case0539), - TEST_BINDER(case0540), - TEST_BINDER(case0541), - TEST_BINDER(case0542), - TEST_BINDER(case0543), - TEST_BINDER(case0544), - TEST_BINDER(case0545), - TEST_BINDER(case0546), - TEST_BINDER(case0547), - TEST_BINDER(case0548), - TEST_BINDER(case0549), - TEST_BINDER(case0550), - TEST_BINDER(case0551), - TEST_BINDER(case0552), - TEST_BINDER(case0553), - TEST_BINDER(case0554), - TEST_BINDER(case0555), - TEST_BINDER(case0556), - TEST_BINDER(case0557), - TEST_BINDER(case0558), - TEST_BINDER(case0559), - TEST_BINDER(case0560), - TEST_BINDER(case0561), - TEST_BINDER(case0562), - TEST_BINDER(case0563), - TEST_BINDER(case0564), - TEST_BINDER(case0565), - TEST_BINDER(case0566), - TEST_BINDER(case0567), - TEST_BINDER(case0568), - TEST_BINDER(case0569), - TEST_BINDER(case0570), - TEST_BINDER(case0571), - TEST_BINDER(case0572), - TEST_BINDER(case0573), - TEST_BINDER(case0574), - TEST_BINDER(case0575), - TEST_BINDER(case0576), - TEST_BINDER(case0577), - TEST_BINDER(case0578), - TEST_BINDER(case0579), - TEST_BINDER(case0580), - TEST_BINDER(case0581), - TEST_BINDER(case0582), - TEST_BINDER(case0583), - TEST_BINDER(case0584), - TEST_BINDER(case0585), - TEST_BINDER(case0586), - TEST_BINDER(case0587), - TEST_BINDER(case0588), - TEST_BINDER(case0589), - TEST_BINDER(case0590), - TEST_BINDER(case0591), - TEST_BINDER(case0592), - TEST_BINDER(case0593), - TEST_BINDER(case0594), - TEST_BINDER(case0595), - TEST_BINDER(case0596), - TEST_BINDER(case0597), - TEST_BINDER(case0598), - TEST_BINDER(case0599), + TEST_BINDER(case0500), TEST_BINDER(case0501), TEST_BINDER(case0502), + TEST_BINDER(case0503), TEST_BINDER(case0504), TEST_BINDER(case0505), + TEST_BINDER(case0506), TEST_BINDER(case0507), TEST_BINDER(case0508), + TEST_BINDER(case0509), TEST_BINDER(case0510), TEST_BINDER(case0511), + TEST_BINDER(case0512), TEST_BINDER(case0513), TEST_BINDER(case0514), + TEST_BINDER(case0515), TEST_BINDER(case0516), TEST_BINDER(case0517), + TEST_BINDER(case0518), TEST_BINDER(case0519), TEST_BINDER(case0520), + TEST_BINDER(case0521), TEST_BINDER(case0522), TEST_BINDER(case0523), + TEST_BINDER(case0524), TEST_BINDER(case0525), TEST_BINDER(case0526), + TEST_BINDER(case0527), TEST_BINDER(case0528), TEST_BINDER(case0529), + TEST_BINDER(case0530), TEST_BINDER(case0531), TEST_BINDER(case0532), + TEST_BINDER(case0533), TEST_BINDER(case0534), TEST_BINDER(case0535), + TEST_BINDER(case0536), TEST_BINDER(case0537), TEST_BINDER(case0538), + TEST_BINDER(case0539), TEST_BINDER(case0540), TEST_BINDER(case0541), + TEST_BINDER(case0542), TEST_BINDER(case0543), TEST_BINDER(case0544), + TEST_BINDER(case0545), TEST_BINDER(case0546), TEST_BINDER(case0547), + TEST_BINDER(case0548), TEST_BINDER(case0549), TEST_BINDER(case0550), + TEST_BINDER(case0551), TEST_BINDER(case0552), TEST_BINDER(case0553), + TEST_BINDER(case0554), TEST_BINDER(case0555), TEST_BINDER(case0556), + TEST_BINDER(case0557), TEST_BINDER(case0558), TEST_BINDER(case0559), + TEST_BINDER(case0560), TEST_BINDER(case0561), TEST_BINDER(case0562), + TEST_BINDER(case0563), TEST_BINDER(case0564), TEST_BINDER(case0565), + TEST_BINDER(case0566), TEST_BINDER(case0567), TEST_BINDER(case0568), + TEST_BINDER(case0569), TEST_BINDER(case0570), TEST_BINDER(case0571), + TEST_BINDER(case0572), TEST_BINDER(case0573), TEST_BINDER(case0574), + TEST_BINDER(case0575), TEST_BINDER(case0576), TEST_BINDER(case0577), + TEST_BINDER(case0578), TEST_BINDER(case0579), TEST_BINDER(case0580), + TEST_BINDER(case0581), TEST_BINDER(case0582), TEST_BINDER(case0583), + TEST_BINDER(case0584), TEST_BINDER(case0585), TEST_BINDER(case0586), + TEST_BINDER(case0587), TEST_BINDER(case0588), TEST_BINDER(case0589), + TEST_BINDER(case0590), TEST_BINDER(case0591), TEST_BINDER(case0592), + TEST_BINDER(case0593), TEST_BINDER(case0594), TEST_BINDER(case0595), + TEST_BINDER(case0596), TEST_BINDER(case0597), TEST_BINDER(case0598), + TEST_BINDER(case0599), - TEST_BINDER(case1000), - TEST_BINDER(case1001), - TEST_BINDER(case1002), - TEST_BINDER(case1003), - TEST_BINDER(case1004), - TEST_BINDER(case1005), - TEST_BINDER(case1006), - TEST_BINDER(case1007), - TEST_BINDER(case1008), - TEST_BINDER(case1009), - TEST_BINDER(case1010), - TEST_BINDER(case1011), - TEST_BINDER(case1012), - TEST_BINDER(case1013), - TEST_BINDER(case1014), - TEST_BINDER(case1015), - TEST_BINDER(case1016), - TEST_BINDER(case1017), - TEST_BINDER(case1018), - TEST_BINDER(case1019), - TEST_BINDER(case1020), - TEST_BINDER(case1021), - TEST_BINDER(case1022), - TEST_BINDER(case1023), - TEST_BINDER(case1024), - TEST_BINDER(case1025), - TEST_BINDER(case1026), - TEST_BINDER(case1027), - TEST_BINDER(case1028), - TEST_BINDER(case1029), - TEST_BINDER(case1030), - TEST_BINDER(case1031), - TEST_BINDER(case1032), - TEST_BINDER(case1033), - TEST_BINDER(case1034), - TEST_BINDER(case1035), - TEST_BINDER(case1036), - TEST_BINDER(case1037), - TEST_BINDER(case1038), - TEST_BINDER(case1039), - TEST_BINDER(case1040), - TEST_BINDER(case1041), - TEST_BINDER(case1042), - TEST_BINDER(case1043), - TEST_BINDER(case1044), - TEST_BINDER(case1045), - TEST_BINDER(case1046), - TEST_BINDER(case1047), - TEST_BINDER(case1048), - TEST_BINDER(case1049), - TEST_BINDER(case1050), - TEST_BINDER(case1051), - TEST_BINDER(case1052), - TEST_BINDER(case1053), - TEST_BINDER(case1054), - TEST_BINDER(case1055), - TEST_BINDER(case1056), - TEST_BINDER(case1057), - TEST_BINDER(case1058), - TEST_BINDER(case1059), - TEST_BINDER(case1060), - TEST_BINDER(case1061), - TEST_BINDER(case1062), - TEST_BINDER(case1063), - TEST_BINDER(case1064), - TEST_BINDER(case1065), - TEST_BINDER(case1066), - TEST_BINDER(case1067), - TEST_BINDER(case1068), - TEST_BINDER(case1069), - TEST_BINDER(case1070), - TEST_BINDER(case1071), - TEST_BINDER(case1072), - TEST_BINDER(case1073), - TEST_BINDER(case1074), - TEST_BINDER(case1075), - TEST_BINDER(case1076), - TEST_BINDER(case1077), - TEST_BINDER(case1078), - TEST_BINDER(case1079), - TEST_BINDER(case1080), - TEST_BINDER(case1081), - TEST_BINDER(case1082), - TEST_BINDER(case1083), - TEST_BINDER(case1084), - TEST_BINDER(case1085), - TEST_BINDER(case1086), - TEST_BINDER(case1087), - TEST_BINDER(case1088), - TEST_BINDER(case1089), - TEST_BINDER(case1090), - TEST_BINDER(case1091), - TEST_BINDER(case1092), - TEST_BINDER(case1093), - TEST_BINDER(case1094), - TEST_BINDER(case1095), - TEST_BINDER(case1096), - TEST_BINDER(case1097), - TEST_BINDER(case1098), - TEST_BINDER(case1099), + TEST_BINDER(case1000), TEST_BINDER(case1001), TEST_BINDER(case1002), + TEST_BINDER(case1003), TEST_BINDER(case1004), TEST_BINDER(case1005), + TEST_BINDER(case1006), TEST_BINDER(case1007), TEST_BINDER(case1008), + TEST_BINDER(case1009), TEST_BINDER(case1010), TEST_BINDER(case1011), + TEST_BINDER(case1012), TEST_BINDER(case1013), TEST_BINDER(case1014), + TEST_BINDER(case1015), TEST_BINDER(case1016), TEST_BINDER(case1017), + TEST_BINDER(case1018), TEST_BINDER(case1019), TEST_BINDER(case1020), + TEST_BINDER(case1021), TEST_BINDER(case1022), TEST_BINDER(case1023), + TEST_BINDER(case1024), TEST_BINDER(case1025), TEST_BINDER(case1026), + TEST_BINDER(case1027), TEST_BINDER(case1028), TEST_BINDER(case1029), + TEST_BINDER(case1030), TEST_BINDER(case1031), TEST_BINDER(case1032), + TEST_BINDER(case1033), TEST_BINDER(case1034), TEST_BINDER(case1035), + TEST_BINDER(case1036), TEST_BINDER(case1037), TEST_BINDER(case1038), + TEST_BINDER(case1039), TEST_BINDER(case1040), TEST_BINDER(case1041), + TEST_BINDER(case1042), TEST_BINDER(case1043), TEST_BINDER(case1044), + TEST_BINDER(case1045), TEST_BINDER(case1046), TEST_BINDER(case1047), + TEST_BINDER(case1048), TEST_BINDER(case1049), TEST_BINDER(case1050), + TEST_BINDER(case1051), TEST_BINDER(case1052), TEST_BINDER(case1053), + TEST_BINDER(case1054), TEST_BINDER(case1055), TEST_BINDER(case1056), + TEST_BINDER(case1057), TEST_BINDER(case1058), TEST_BINDER(case1059), + TEST_BINDER(case1060), TEST_BINDER(case1061), TEST_BINDER(case1062), + TEST_BINDER(case1063), TEST_BINDER(case1064), TEST_BINDER(case1065), + TEST_BINDER(case1066), TEST_BINDER(case1067), TEST_BINDER(case1068), + TEST_BINDER(case1069), TEST_BINDER(case1070), TEST_BINDER(case1071), + TEST_BINDER(case1072), TEST_BINDER(case1073), TEST_BINDER(case1074), + TEST_BINDER(case1075), TEST_BINDER(case1076), TEST_BINDER(case1077), + TEST_BINDER(case1078), TEST_BINDER(case1079), TEST_BINDER(case1080), + TEST_BINDER(case1081), TEST_BINDER(case1082), TEST_BINDER(case1083), + TEST_BINDER(case1084), TEST_BINDER(case1085), TEST_BINDER(case1086), + TEST_BINDER(case1087), TEST_BINDER(case1088), TEST_BINDER(case1089), + TEST_BINDER(case1090), TEST_BINDER(case1091), TEST_BINDER(case1092), + TEST_BINDER(case1093), TEST_BINDER(case1094), TEST_BINDER(case1095), + TEST_BINDER(case1096), TEST_BINDER(case1097), TEST_BINDER(case1098), + TEST_BINDER(case1099), - TEST_BINDER(case1100), - TEST_BINDER(case1101), - TEST_BINDER(case1102), - TEST_BINDER(case1103), - TEST_BINDER(case1104), - TEST_BINDER(case1105), - TEST_BINDER(case1106), - TEST_BINDER(case1107), - TEST_BINDER(case1108), - TEST_BINDER(case1109), - TEST_BINDER(case1110), - TEST_BINDER(case1111), - TEST_BINDER(case1112), - TEST_BINDER(case1113), - TEST_BINDER(case1114), - TEST_BINDER(case1115), - TEST_BINDER(case1116), - TEST_BINDER(case1117), - TEST_BINDER(case1118), - TEST_BINDER(case1119), - TEST_BINDER(case1120), - TEST_BINDER(case1121), - TEST_BINDER(case1122), - TEST_BINDER(case1123), - TEST_BINDER(case1124), - TEST_BINDER(case1125), - TEST_BINDER(case1126), - TEST_BINDER(case1127), - TEST_BINDER(case1128), - TEST_BINDER(case1129), - TEST_BINDER(case1130), - TEST_BINDER(case1131), - TEST_BINDER(case1132), - TEST_BINDER(case1133), - TEST_BINDER(case1134), - TEST_BINDER(case1135), - TEST_BINDER(case1136), - TEST_BINDER(case1137), - TEST_BINDER(case1138), - TEST_BINDER(case1139), - TEST_BINDER(case1140), - TEST_BINDER(case1141), - TEST_BINDER(case1142), - TEST_BINDER(case1143), - TEST_BINDER(case1144), - TEST_BINDER(case1145), - TEST_BINDER(case1146), - TEST_BINDER(case1147), - TEST_BINDER(case1148), - TEST_BINDER(case1149), - TEST_BINDER(case1150), - TEST_BINDER(case1151), - TEST_BINDER(case1152), - TEST_BINDER(case1153), - TEST_BINDER(case1154), - TEST_BINDER(case1155), - TEST_BINDER(case1156), - TEST_BINDER(case1157), - TEST_BINDER(case1158), - TEST_BINDER(case1159), - TEST_BINDER(case1160), - TEST_BINDER(case1161), - TEST_BINDER(case1162), - TEST_BINDER(case1163), - TEST_BINDER(case1164), - TEST_BINDER(case1165), - TEST_BINDER(case1166), - TEST_BINDER(case1167), - TEST_BINDER(case1168), - TEST_BINDER(case1169), - TEST_BINDER(case1170), - TEST_BINDER(case1171), - TEST_BINDER(case1172), - TEST_BINDER(case1173), - TEST_BINDER(case1174), - TEST_BINDER(case1175), - TEST_BINDER(case1176), - TEST_BINDER(case1177), - TEST_BINDER(case1178), - TEST_BINDER(case1179), - TEST_BINDER(case1180), - TEST_BINDER(case1181), - TEST_BINDER(case1182), - TEST_BINDER(case1183), - TEST_BINDER(case1184), - TEST_BINDER(case1185), - TEST_BINDER(case1186), - TEST_BINDER(case1187), - TEST_BINDER(case1188), - TEST_BINDER(case1189), - TEST_BINDER(case1190), - TEST_BINDER(case1191), - TEST_BINDER(case1192), - TEST_BINDER(case1193), - TEST_BINDER(case1194), - TEST_BINDER(case1195), - TEST_BINDER(case1196), - TEST_BINDER(case1197), - TEST_BINDER(case1198), - TEST_BINDER(case1199), + TEST_BINDER(case1100), TEST_BINDER(case1101), TEST_BINDER(case1102), + TEST_BINDER(case1103), TEST_BINDER(case1104), TEST_BINDER(case1105), + TEST_BINDER(case1106), TEST_BINDER(case1107), TEST_BINDER(case1108), + TEST_BINDER(case1109), TEST_BINDER(case1110), TEST_BINDER(case1111), + TEST_BINDER(case1112), TEST_BINDER(case1113), TEST_BINDER(case1114), + TEST_BINDER(case1115), TEST_BINDER(case1116), TEST_BINDER(case1117), + TEST_BINDER(case1118), TEST_BINDER(case1119), TEST_BINDER(case1120), + TEST_BINDER(case1121), TEST_BINDER(case1122), TEST_BINDER(case1123), + TEST_BINDER(case1124), TEST_BINDER(case1125), TEST_BINDER(case1126), + TEST_BINDER(case1127), TEST_BINDER(case1128), TEST_BINDER(case1129), + TEST_BINDER(case1130), TEST_BINDER(case1131), TEST_BINDER(case1132), + TEST_BINDER(case1133), TEST_BINDER(case1134), TEST_BINDER(case1135), + TEST_BINDER(case1136), TEST_BINDER(case1137), TEST_BINDER(case1138), + TEST_BINDER(case1139), TEST_BINDER(case1140), TEST_BINDER(case1141), + TEST_BINDER(case1142), TEST_BINDER(case1143), TEST_BINDER(case1144), + TEST_BINDER(case1145), TEST_BINDER(case1146), TEST_BINDER(case1147), + TEST_BINDER(case1148), TEST_BINDER(case1149), TEST_BINDER(case1150), + TEST_BINDER(case1151), TEST_BINDER(case1152), TEST_BINDER(case1153), + TEST_BINDER(case1154), TEST_BINDER(case1155), TEST_BINDER(case1156), + TEST_BINDER(case1157), TEST_BINDER(case1158), TEST_BINDER(case1159), + TEST_BINDER(case1160), TEST_BINDER(case1161), TEST_BINDER(case1162), + TEST_BINDER(case1163), TEST_BINDER(case1164), TEST_BINDER(case1165), + TEST_BINDER(case1166), TEST_BINDER(case1167), TEST_BINDER(case1168), + TEST_BINDER(case1169), TEST_BINDER(case1170), TEST_BINDER(case1171), + TEST_BINDER(case1172), TEST_BINDER(case1173), TEST_BINDER(case1174), + TEST_BINDER(case1175), TEST_BINDER(case1176), TEST_BINDER(case1177), + TEST_BINDER(case1178), TEST_BINDER(case1179), TEST_BINDER(case1180), + TEST_BINDER(case1181), TEST_BINDER(case1182), TEST_BINDER(case1183), + TEST_BINDER(case1184), TEST_BINDER(case1185), TEST_BINDER(case1186), + TEST_BINDER(case1187), TEST_BINDER(case1188), TEST_BINDER(case1189), + TEST_BINDER(case1190), TEST_BINDER(case1191), TEST_BINDER(case1192), + TEST_BINDER(case1193), TEST_BINDER(case1194), TEST_BINDER(case1195), + TEST_BINDER(case1196), TEST_BINDER(case1197), TEST_BINDER(case1198), + TEST_BINDER(case1199), - TEST_BINDER(case1200), - TEST_BINDER(case1201), - TEST_BINDER(case1202), - TEST_BINDER(case1203), - TEST_BINDER(case1204), - TEST_BINDER(case1205), - TEST_BINDER(case1206), - TEST_BINDER(case1207), - TEST_BINDER(case1208), - TEST_BINDER(case1209), - TEST_BINDER(case1210), - TEST_BINDER(case1211), - TEST_BINDER(case1212), - TEST_BINDER(case1213), - TEST_BINDER(case1214), - TEST_BINDER(case1215), - TEST_BINDER(case1216), - TEST_BINDER(case1217), - TEST_BINDER(case1218), - TEST_BINDER(case1219), - TEST_BINDER(case1220), - TEST_BINDER(case1221), - TEST_BINDER(case1222), - TEST_BINDER(case1223), - TEST_BINDER(case1224), - TEST_BINDER(case1225), - TEST_BINDER(case1226), - TEST_BINDER(case1227), - TEST_BINDER(case1228), - TEST_BINDER(case1229), - TEST_BINDER(case1230), - TEST_BINDER(case1231), - TEST_BINDER(case1232), - TEST_BINDER(case1233), - TEST_BINDER(case1234), - TEST_BINDER(case1235), - TEST_BINDER(case1236), - TEST_BINDER(case1237), - TEST_BINDER(case1238), - TEST_BINDER(case1239), - TEST_BINDER(case1240), - TEST_BINDER(case1241), - TEST_BINDER(case1242), - TEST_BINDER(case1243), - TEST_BINDER(case1244), - TEST_BINDER(case1245), - TEST_BINDER(case1246), - TEST_BINDER(case1247), - TEST_BINDER(case1248), - TEST_BINDER(case1249), - TEST_BINDER(case1250), - TEST_BINDER(case1251), - TEST_BINDER(case1252), - TEST_BINDER(case1253), - TEST_BINDER(case1254), - TEST_BINDER(case1255), - TEST_BINDER(case1256), - TEST_BINDER(case1257), - TEST_BINDER(case1258), - TEST_BINDER(case1259), - TEST_BINDER(case1260), - TEST_BINDER(case1261), - TEST_BINDER(case1262), - TEST_BINDER(case1263), - TEST_BINDER(case1264), - TEST_BINDER(case1265), - TEST_BINDER(case1266), - TEST_BINDER(case1267), - TEST_BINDER(case1268), - TEST_BINDER(case1269), - TEST_BINDER(case1270), - TEST_BINDER(case1271), - TEST_BINDER(case1272), - TEST_BINDER(case1273), - TEST_BINDER(case1274), - TEST_BINDER(case1275), - TEST_BINDER(case1276), - TEST_BINDER(case1277), - TEST_BINDER(case1278), - TEST_BINDER(case1279), - TEST_BINDER(case1280), - TEST_BINDER(case1281), - TEST_BINDER(case1282), - TEST_BINDER(case1283), - TEST_BINDER(case1284), - TEST_BINDER(case1285), - TEST_BINDER(case1286), - TEST_BINDER(case1287), - TEST_BINDER(case1288), - TEST_BINDER(case1289), - TEST_BINDER(case1290), - TEST_BINDER(case1291), - TEST_BINDER(case1292), - TEST_BINDER(case1293), - TEST_BINDER(case1294), - TEST_BINDER(case1295), - TEST_BINDER(case1296), - TEST_BINDER(case1297), - TEST_BINDER(case1298), - TEST_BINDER(case1299), + TEST_BINDER(case1200), TEST_BINDER(case1201), TEST_BINDER(case1202), + TEST_BINDER(case1203), TEST_BINDER(case1204), TEST_BINDER(case1205), + TEST_BINDER(case1206), TEST_BINDER(case1207), TEST_BINDER(case1208), + TEST_BINDER(case1209), TEST_BINDER(case1210), TEST_BINDER(case1211), + TEST_BINDER(case1212), TEST_BINDER(case1213), TEST_BINDER(case1214), + TEST_BINDER(case1215), TEST_BINDER(case1216), TEST_BINDER(case1217), + TEST_BINDER(case1218), TEST_BINDER(case1219), TEST_BINDER(case1220), + TEST_BINDER(case1221), TEST_BINDER(case1222), TEST_BINDER(case1223), + TEST_BINDER(case1224), TEST_BINDER(case1225), TEST_BINDER(case1226), + TEST_BINDER(case1227), TEST_BINDER(case1228), TEST_BINDER(case1229), + TEST_BINDER(case1230), TEST_BINDER(case1231), TEST_BINDER(case1232), + TEST_BINDER(case1233), TEST_BINDER(case1234), TEST_BINDER(case1235), + TEST_BINDER(case1236), TEST_BINDER(case1237), TEST_BINDER(case1238), + TEST_BINDER(case1239), TEST_BINDER(case1240), TEST_BINDER(case1241), + TEST_BINDER(case1242), TEST_BINDER(case1243), TEST_BINDER(case1244), + TEST_BINDER(case1245), TEST_BINDER(case1246), TEST_BINDER(case1247), + TEST_BINDER(case1248), TEST_BINDER(case1249), TEST_BINDER(case1250), + TEST_BINDER(case1251), TEST_BINDER(case1252), TEST_BINDER(case1253), + TEST_BINDER(case1254), TEST_BINDER(case1255), TEST_BINDER(case1256), + TEST_BINDER(case1257), TEST_BINDER(case1258), TEST_BINDER(case1259), + TEST_BINDER(case1260), TEST_BINDER(case1261), TEST_BINDER(case1262), + TEST_BINDER(case1263), TEST_BINDER(case1264), TEST_BINDER(case1265), + TEST_BINDER(case1266), TEST_BINDER(case1267), TEST_BINDER(case1268), + TEST_BINDER(case1269), TEST_BINDER(case1270), TEST_BINDER(case1271), + TEST_BINDER(case1272), TEST_BINDER(case1273), TEST_BINDER(case1274), + TEST_BINDER(case1275), TEST_BINDER(case1276), TEST_BINDER(case1277), + TEST_BINDER(case1278), TEST_BINDER(case1279), TEST_BINDER(case1280), + TEST_BINDER(case1281), TEST_BINDER(case1282), TEST_BINDER(case1283), + TEST_BINDER(case1284), TEST_BINDER(case1285), TEST_BINDER(case1286), + TEST_BINDER(case1287), TEST_BINDER(case1288), TEST_BINDER(case1289), + TEST_BINDER(case1290), TEST_BINDER(case1291), TEST_BINDER(case1292), + TEST_BINDER(case1293), TEST_BINDER(case1294), TEST_BINDER(case1295), + TEST_BINDER(case1296), TEST_BINDER(case1297), TEST_BINDER(case1298), + TEST_BINDER(case1299), - TEST_BINDER(case1300), - TEST_BINDER(case1301), - TEST_BINDER(case1302), - TEST_BINDER(case1303), - TEST_BINDER(case1304), - TEST_BINDER(case1305), - TEST_BINDER(case1306), - TEST_BINDER(case1307), - TEST_BINDER(case1308), - TEST_BINDER(case1309), - TEST_BINDER(case1310), - TEST_BINDER(case1311), - TEST_BINDER(case1312), - TEST_BINDER(case1313), - TEST_BINDER(case1314), - TEST_BINDER(case1315), - TEST_BINDER(case1316), - TEST_BINDER(case1317), - TEST_BINDER(case1318), - TEST_BINDER(case1319), - TEST_BINDER(case1320), - TEST_BINDER(case1321), - TEST_BINDER(case1322), - TEST_BINDER(case1323), - TEST_BINDER(case1324), - TEST_BINDER(case1325), - TEST_BINDER(case1326), - TEST_BINDER(case1327), - TEST_BINDER(case1328), - TEST_BINDER(case1329), - TEST_BINDER(case1330), - TEST_BINDER(case1331), - TEST_BINDER(case1332), - TEST_BINDER(case1333), - TEST_BINDER(case1334), - TEST_BINDER(case1335), - TEST_BINDER(case1336), - TEST_BINDER(case1337), - TEST_BINDER(case1338), - TEST_BINDER(case1339), - TEST_BINDER(case1340), - TEST_BINDER(case1341), - TEST_BINDER(case1342), - TEST_BINDER(case1343), - TEST_BINDER(case1344), - TEST_BINDER(case1345), - TEST_BINDER(case1346), - TEST_BINDER(case1347), - TEST_BINDER(case1348), - TEST_BINDER(case1349), - TEST_BINDER(case1350), - TEST_BINDER(case1351), - TEST_BINDER(case1352), - TEST_BINDER(case1353), - TEST_BINDER(case1354), - TEST_BINDER(case1355), - TEST_BINDER(case1356), - TEST_BINDER(case1357), - TEST_BINDER(case1358), - TEST_BINDER(case1359), - TEST_BINDER(case1360), - TEST_BINDER(case1361), - TEST_BINDER(case1362), - TEST_BINDER(case1363), - TEST_BINDER(case1364), - TEST_BINDER(case1365), - TEST_BINDER(case1366), - TEST_BINDER(case1367), - TEST_BINDER(case1368), - TEST_BINDER(case1369), - TEST_BINDER(case1370), - TEST_BINDER(case1371), - TEST_BINDER(case1372), - TEST_BINDER(case1373), - TEST_BINDER(case1374), - TEST_BINDER(case1375), - TEST_BINDER(case1376), - TEST_BINDER(case1377), - TEST_BINDER(case1378), - TEST_BINDER(case1379), - TEST_BINDER(case1380), - TEST_BINDER(case1381), - TEST_BINDER(case1382), - TEST_BINDER(case1383), - TEST_BINDER(case1384), - TEST_BINDER(case1385), - TEST_BINDER(case1386), - TEST_BINDER(case1387), - TEST_BINDER(case1388), - TEST_BINDER(case1389), - TEST_BINDER(case1390), - TEST_BINDER(case1391), - TEST_BINDER(case1392), - TEST_BINDER(case1393), - TEST_BINDER(case1394), - TEST_BINDER(case1395), - TEST_BINDER(case1396), - TEST_BINDER(case1397), - TEST_BINDER(case1398), - TEST_BINDER(case1399), + TEST_BINDER(case1300), TEST_BINDER(case1301), TEST_BINDER(case1302), + TEST_BINDER(case1303), TEST_BINDER(case1304), TEST_BINDER(case1305), + TEST_BINDER(case1306), TEST_BINDER(case1307), TEST_BINDER(case1308), + TEST_BINDER(case1309), TEST_BINDER(case1310), TEST_BINDER(case1311), + TEST_BINDER(case1312), TEST_BINDER(case1313), TEST_BINDER(case1314), + TEST_BINDER(case1315), TEST_BINDER(case1316), TEST_BINDER(case1317), + TEST_BINDER(case1318), TEST_BINDER(case1319), TEST_BINDER(case1320), + TEST_BINDER(case1321), TEST_BINDER(case1322), TEST_BINDER(case1323), + TEST_BINDER(case1324), TEST_BINDER(case1325), TEST_BINDER(case1326), + TEST_BINDER(case1327), TEST_BINDER(case1328), TEST_BINDER(case1329), + TEST_BINDER(case1330), TEST_BINDER(case1331), TEST_BINDER(case1332), + TEST_BINDER(case1333), TEST_BINDER(case1334), TEST_BINDER(case1335), + TEST_BINDER(case1336), TEST_BINDER(case1337), TEST_BINDER(case1338), + TEST_BINDER(case1339), TEST_BINDER(case1340), TEST_BINDER(case1341), + TEST_BINDER(case1342), TEST_BINDER(case1343), TEST_BINDER(case1344), + TEST_BINDER(case1345), TEST_BINDER(case1346), TEST_BINDER(case1347), + TEST_BINDER(case1348), TEST_BINDER(case1349), TEST_BINDER(case1350), + TEST_BINDER(case1351), TEST_BINDER(case1352), TEST_BINDER(case1353), + TEST_BINDER(case1354), TEST_BINDER(case1355), TEST_BINDER(case1356), + TEST_BINDER(case1357), TEST_BINDER(case1358), TEST_BINDER(case1359), + TEST_BINDER(case1360), TEST_BINDER(case1361), TEST_BINDER(case1362), + TEST_BINDER(case1363), TEST_BINDER(case1364), TEST_BINDER(case1365), + TEST_BINDER(case1366), TEST_BINDER(case1367), TEST_BINDER(case1368), + TEST_BINDER(case1369), TEST_BINDER(case1370), TEST_BINDER(case1371), + TEST_BINDER(case1372), TEST_BINDER(case1373), TEST_BINDER(case1374), + TEST_BINDER(case1375), TEST_BINDER(case1376), TEST_BINDER(case1377), + TEST_BINDER(case1378), TEST_BINDER(case1379), TEST_BINDER(case1380), + TEST_BINDER(case1381), TEST_BINDER(case1382), TEST_BINDER(case1383), + TEST_BINDER(case1384), TEST_BINDER(case1385), TEST_BINDER(case1386), + TEST_BINDER(case1387), TEST_BINDER(case1388), TEST_BINDER(case1389), + TEST_BINDER(case1390), TEST_BINDER(case1391), TEST_BINDER(case1392), + TEST_BINDER(case1393), TEST_BINDER(case1394), TEST_BINDER(case1395), + TEST_BINDER(case1396), TEST_BINDER(case1397), TEST_BINDER(case1398), + TEST_BINDER(case1399), - TEST_BINDER(case2000), - TEST_BINDER(case2001), - TEST_BINDER(case2002), - TEST_BINDER(case2003), - TEST_BINDER(case2004), - TEST_BINDER(case2005), - TEST_BINDER(case2006), - TEST_BINDER(case2007), - TEST_BINDER(case2008), - TEST_BINDER(case2009), - TEST_BINDER(case2010), - TEST_BINDER(case2011), - TEST_BINDER(case2012), - TEST_BINDER(case2013), - TEST_BINDER(case2014), - TEST_BINDER(case2015), - TEST_BINDER(case2016), - TEST_BINDER(case2017), - TEST_BINDER(case2018), - TEST_BINDER(case2019), - TEST_BINDER(case2020), - TEST_BINDER(case2021), - TEST_BINDER(case2022), - TEST_BINDER(case2023), - TEST_BINDER(case2024), - TEST_BINDER(case2025), - TEST_BINDER(case2026), - TEST_BINDER(case2027), - TEST_BINDER(case2028), - TEST_BINDER(case2029), - TEST_BINDER(case2030), - TEST_BINDER(case2031), - TEST_BINDER(case2032), - TEST_BINDER(case2033), - TEST_BINDER(case2034), - TEST_BINDER(case2035), - TEST_BINDER(case2036), - TEST_BINDER(case2037), - TEST_BINDER(case2038), - TEST_BINDER(case2039), - TEST_BINDER(case2040), - TEST_BINDER(case2041), - TEST_BINDER(case2042), - TEST_BINDER(case2043), - TEST_BINDER(case2044), - TEST_BINDER(case2045), - TEST_BINDER(case2046), - TEST_BINDER(case2047), - TEST_BINDER(case2048), - TEST_BINDER(case2049), - TEST_BINDER(case2050), - TEST_BINDER(case2051), - TEST_BINDER(case2052), - TEST_BINDER(case2053), - TEST_BINDER(case2054), - TEST_BINDER(case2055), - TEST_BINDER(case2056), - TEST_BINDER(case2057), - TEST_BINDER(case2058), - TEST_BINDER(case2059), - TEST_BINDER(case2060), - TEST_BINDER(case2061), - TEST_BINDER(case2062), - TEST_BINDER(case2063), - TEST_BINDER(case2064), - TEST_BINDER(case2065), - TEST_BINDER(case2066), - TEST_BINDER(case2067), - TEST_BINDER(case2068), - TEST_BINDER(case2069), - TEST_BINDER(case2070), - TEST_BINDER(case2071), - TEST_BINDER(case2072), - TEST_BINDER(case2073), - TEST_BINDER(case2074), - TEST_BINDER(case2075), - TEST_BINDER(case2076), - TEST_BINDER(case2077), - TEST_BINDER(case2078), - TEST_BINDER(case2079), - TEST_BINDER(case2080), - TEST_BINDER(case2081), - TEST_BINDER(case2082), - TEST_BINDER(case2083), - TEST_BINDER(case2084), - TEST_BINDER(case2085), - TEST_BINDER(case2086), - TEST_BINDER(case2087), - TEST_BINDER(case2088), - TEST_BINDER(case2089), - TEST_BINDER(case2090), - TEST_BINDER(case2091), - TEST_BINDER(case2092), - TEST_BINDER(case2093), - TEST_BINDER(case2094), - TEST_BINDER(case2095), - TEST_BINDER(case2096), - TEST_BINDER(case2097), - TEST_BINDER(case2098), - TEST_BINDER(case2099), + TEST_BINDER(case2000), TEST_BINDER(case2001), TEST_BINDER(case2002), + TEST_BINDER(case2003), TEST_BINDER(case2004), TEST_BINDER(case2005), + TEST_BINDER(case2006), TEST_BINDER(case2007), TEST_BINDER(case2008), + TEST_BINDER(case2009), TEST_BINDER(case2010), TEST_BINDER(case2011), + TEST_BINDER(case2012), TEST_BINDER(case2013), TEST_BINDER(case2014), + TEST_BINDER(case2015), TEST_BINDER(case2016), TEST_BINDER(case2017), + TEST_BINDER(case2018), TEST_BINDER(case2019), TEST_BINDER(case2020), + TEST_BINDER(case2021), TEST_BINDER(case2022), TEST_BINDER(case2023), + TEST_BINDER(case2024), TEST_BINDER(case2025), TEST_BINDER(case2026), + TEST_BINDER(case2027), TEST_BINDER(case2028), TEST_BINDER(case2029), + TEST_BINDER(case2030), TEST_BINDER(case2031), TEST_BINDER(case2032), + TEST_BINDER(case2033), TEST_BINDER(case2034), TEST_BINDER(case2035), + TEST_BINDER(case2036), TEST_BINDER(case2037), TEST_BINDER(case2038), + TEST_BINDER(case2039), TEST_BINDER(case2040), TEST_BINDER(case2041), + TEST_BINDER(case2042), TEST_BINDER(case2043), TEST_BINDER(case2044), + TEST_BINDER(case2045), TEST_BINDER(case2046), TEST_BINDER(case2047), + TEST_BINDER(case2048), TEST_BINDER(case2049), TEST_BINDER(case2050), + TEST_BINDER(case2051), TEST_BINDER(case2052), TEST_BINDER(case2053), + TEST_BINDER(case2054), TEST_BINDER(case2055), TEST_BINDER(case2056), + TEST_BINDER(case2057), TEST_BINDER(case2058), TEST_BINDER(case2059), + TEST_BINDER(case2060), TEST_BINDER(case2061), TEST_BINDER(case2062), + TEST_BINDER(case2063), TEST_BINDER(case2064), TEST_BINDER(case2065), + TEST_BINDER(case2066), TEST_BINDER(case2067), TEST_BINDER(case2068), + TEST_BINDER(case2069), TEST_BINDER(case2070), TEST_BINDER(case2071), + TEST_BINDER(case2072), TEST_BINDER(case2073), TEST_BINDER(case2074), + TEST_BINDER(case2075), TEST_BINDER(case2076), TEST_BINDER(case2077), + TEST_BINDER(case2078), TEST_BINDER(case2079), TEST_BINDER(case2080), + TEST_BINDER(case2081), TEST_BINDER(case2082), TEST_BINDER(case2083), + TEST_BINDER(case2084), TEST_BINDER(case2085), TEST_BINDER(case2086), + TEST_BINDER(case2087), TEST_BINDER(case2088), TEST_BINDER(case2089), + TEST_BINDER(case2090), TEST_BINDER(case2091), TEST_BINDER(case2092), + TEST_BINDER(case2093), TEST_BINDER(case2094), TEST_BINDER(case2095), + TEST_BINDER(case2096), TEST_BINDER(case2097), TEST_BINDER(case2098), + TEST_BINDER(case2099), - TEST_BINDER(case2100), - TEST_BINDER(case2101), - TEST_BINDER(case2102), - TEST_BINDER(case2103), - TEST_BINDER(case2104), - TEST_BINDER(case2105), - TEST_BINDER(case2106), - TEST_BINDER(case2107), - TEST_BINDER(case2108), - TEST_BINDER(case2109), - TEST_BINDER(case2110), - TEST_BINDER(case2111), - TEST_BINDER(case2112), - TEST_BINDER(case2113), - TEST_BINDER(case2114), - TEST_BINDER(case2115), - TEST_BINDER(case2116), - TEST_BINDER(case2117), - TEST_BINDER(case2118), - TEST_BINDER(case2119), - TEST_BINDER(case2120), - TEST_BINDER(case2121), - TEST_BINDER(case2122), - TEST_BINDER(case2123), - TEST_BINDER(case2124), - TEST_BINDER(case2125), - TEST_BINDER(case2126), - TEST_BINDER(case2127), - TEST_BINDER(case2128), - TEST_BINDER(case2129), - TEST_BINDER(case2130), - TEST_BINDER(case2131), - TEST_BINDER(case2132), - TEST_BINDER(case2133), - TEST_BINDER(case2134), - TEST_BINDER(case2135), - TEST_BINDER(case2136), - TEST_BINDER(case2137), - TEST_BINDER(case2138), - TEST_BINDER(case2139), - TEST_BINDER(case2140), - TEST_BINDER(case2141), - TEST_BINDER(case2142), - TEST_BINDER(case2143), - TEST_BINDER(case2144), - TEST_BINDER(case2145), - TEST_BINDER(case2146), - TEST_BINDER(case2147), - TEST_BINDER(case2148), - TEST_BINDER(case2149), - TEST_BINDER(case2150), - TEST_BINDER(case2151), - TEST_BINDER(case2152), - TEST_BINDER(case2153), - TEST_BINDER(case2154), - TEST_BINDER(case2155), - TEST_BINDER(case2156), - TEST_BINDER(case2157), - TEST_BINDER(case2158), - TEST_BINDER(case2159), - TEST_BINDER(case2160), - TEST_BINDER(case2161), - TEST_BINDER(case2162), - TEST_BINDER(case2163), - TEST_BINDER(case2164), - TEST_BINDER(case2165), - TEST_BINDER(case2166), - TEST_BINDER(case2167), - TEST_BINDER(case2168), - TEST_BINDER(case2169), - TEST_BINDER(case2170), - TEST_BINDER(case2171), - TEST_BINDER(case2172), - TEST_BINDER(case2173), - TEST_BINDER(case2174), - TEST_BINDER(case2175), - TEST_BINDER(case2176), - TEST_BINDER(case2177), - TEST_BINDER(case2178), - TEST_BINDER(case2179), - TEST_BINDER(case2180), - TEST_BINDER(case2181), - TEST_BINDER(case2182), - TEST_BINDER(case2183), - TEST_BINDER(case2184), - TEST_BINDER(case2185), - TEST_BINDER(case2186), - TEST_BINDER(case2187), - TEST_BINDER(case2188), - TEST_BINDER(case2189), - TEST_BINDER(case2190), - TEST_BINDER(case2191), - TEST_BINDER(case2192), - TEST_BINDER(case2193), - TEST_BINDER(case2194), - TEST_BINDER(case2195), - TEST_BINDER(case2196), - TEST_BINDER(case2197), - TEST_BINDER(case2198), - TEST_BINDER(case2199), + TEST_BINDER(case2100), TEST_BINDER(case2101), TEST_BINDER(case2102), + TEST_BINDER(case2103), TEST_BINDER(case2104), TEST_BINDER(case2105), + TEST_BINDER(case2106), TEST_BINDER(case2107), TEST_BINDER(case2108), + TEST_BINDER(case2109), TEST_BINDER(case2110), TEST_BINDER(case2111), + TEST_BINDER(case2112), TEST_BINDER(case2113), TEST_BINDER(case2114), + TEST_BINDER(case2115), TEST_BINDER(case2116), TEST_BINDER(case2117), + TEST_BINDER(case2118), TEST_BINDER(case2119), TEST_BINDER(case2120), + TEST_BINDER(case2121), TEST_BINDER(case2122), TEST_BINDER(case2123), + TEST_BINDER(case2124), TEST_BINDER(case2125), TEST_BINDER(case2126), + TEST_BINDER(case2127), TEST_BINDER(case2128), TEST_BINDER(case2129), + TEST_BINDER(case2130), TEST_BINDER(case2131), TEST_BINDER(case2132), + TEST_BINDER(case2133), TEST_BINDER(case2134), TEST_BINDER(case2135), + TEST_BINDER(case2136), TEST_BINDER(case2137), TEST_BINDER(case2138), + TEST_BINDER(case2139), TEST_BINDER(case2140), TEST_BINDER(case2141), + TEST_BINDER(case2142), TEST_BINDER(case2143), TEST_BINDER(case2144), + TEST_BINDER(case2145), TEST_BINDER(case2146), TEST_BINDER(case2147), + TEST_BINDER(case2148), TEST_BINDER(case2149), TEST_BINDER(case2150), + TEST_BINDER(case2151), TEST_BINDER(case2152), TEST_BINDER(case2153), + TEST_BINDER(case2154), TEST_BINDER(case2155), TEST_BINDER(case2156), + TEST_BINDER(case2157), TEST_BINDER(case2158), TEST_BINDER(case2159), + TEST_BINDER(case2160), TEST_BINDER(case2161), TEST_BINDER(case2162), + TEST_BINDER(case2163), TEST_BINDER(case2164), TEST_BINDER(case2165), + TEST_BINDER(case2166), TEST_BINDER(case2167), TEST_BINDER(case2168), + TEST_BINDER(case2169), TEST_BINDER(case2170), TEST_BINDER(case2171), + TEST_BINDER(case2172), TEST_BINDER(case2173), TEST_BINDER(case2174), + TEST_BINDER(case2175), TEST_BINDER(case2176), TEST_BINDER(case2177), + TEST_BINDER(case2178), TEST_BINDER(case2179), TEST_BINDER(case2180), + TEST_BINDER(case2181), TEST_BINDER(case2182), TEST_BINDER(case2183), + TEST_BINDER(case2184), TEST_BINDER(case2185), TEST_BINDER(case2186), + TEST_BINDER(case2187), TEST_BINDER(case2188), TEST_BINDER(case2189), + TEST_BINDER(case2190), TEST_BINDER(case2191), TEST_BINDER(case2192), + TEST_BINDER(case2193), TEST_BINDER(case2194), TEST_BINDER(case2195), + TEST_BINDER(case2196), TEST_BINDER(case2197), TEST_BINDER(case2198), + TEST_BINDER(case2199), - TEST_BINDER(case2200), - TEST_BINDER(case2201), - TEST_BINDER(case2202), - TEST_BINDER(case2203), - TEST_BINDER(case2204), - TEST_BINDER(case2205), - TEST_BINDER(case2206), - TEST_BINDER(case2207), - TEST_BINDER(case2208), - TEST_BINDER(case2209), - TEST_BINDER(case2210), - TEST_BINDER(case2211), - TEST_BINDER(case2212), - TEST_BINDER(case2213), - TEST_BINDER(case2214), - TEST_BINDER(case2215), - TEST_BINDER(case2216), - TEST_BINDER(case2217), - TEST_BINDER(case2218), - TEST_BINDER(case2219), - TEST_BINDER(case2220), - TEST_BINDER(case2221), - TEST_BINDER(case2222), - TEST_BINDER(case2223), - TEST_BINDER(case2224), - TEST_BINDER(case2225), - TEST_BINDER(case2226), - TEST_BINDER(case2227), - TEST_BINDER(case2228), - TEST_BINDER(case2229), - TEST_BINDER(case2230), - TEST_BINDER(case2231), - TEST_BINDER(case2232), - TEST_BINDER(case2233), - TEST_BINDER(case2234), - TEST_BINDER(case2235), - TEST_BINDER(case2236), - TEST_BINDER(case2237), - TEST_BINDER(case2238), - TEST_BINDER(case2239), - TEST_BINDER(case2240), - TEST_BINDER(case2241), - TEST_BINDER(case2242), - TEST_BINDER(case2243), - TEST_BINDER(case2244), - TEST_BINDER(case2245), - TEST_BINDER(case2246), - TEST_BINDER(case2247), - TEST_BINDER(case2248), - TEST_BINDER(case2249), - TEST_BINDER(case2250), - TEST_BINDER(case2251), - TEST_BINDER(case2252), - TEST_BINDER(case2253), - TEST_BINDER(case2254), - TEST_BINDER(case2255), - TEST_BINDER(case2256), - TEST_BINDER(case2257), - TEST_BINDER(case2258), - TEST_BINDER(case2259), - TEST_BINDER(case2260), - TEST_BINDER(case2261), - TEST_BINDER(case2262), - TEST_BINDER(case2263), - TEST_BINDER(case2264), - TEST_BINDER(case2265), - TEST_BINDER(case2266), - TEST_BINDER(case2267), - TEST_BINDER(case2268), - TEST_BINDER(case2269), - TEST_BINDER(case2270), - TEST_BINDER(case2271), - TEST_BINDER(case2272), - TEST_BINDER(case2273), - TEST_BINDER(case2274), - TEST_BINDER(case2275), - TEST_BINDER(case2276), - TEST_BINDER(case2277), - TEST_BINDER(case2278), - TEST_BINDER(case2279), - TEST_BINDER(case2280), - TEST_BINDER(case2281), - TEST_BINDER(case2282), - TEST_BINDER(case2283), - TEST_BINDER(case2284), - TEST_BINDER(case2285), - TEST_BINDER(case2286), - TEST_BINDER(case2287), - TEST_BINDER(case2288), - TEST_BINDER(case2289), - TEST_BINDER(case2290), - TEST_BINDER(case2291), - TEST_BINDER(case2292), - TEST_BINDER(case2293), - TEST_BINDER(case2294), - TEST_BINDER(case2295), - TEST_BINDER(case2296), - TEST_BINDER(case2297), - TEST_BINDER(case2298), - TEST_BINDER(case2299), + TEST_BINDER(case2200), TEST_BINDER(case2201), TEST_BINDER(case2202), + TEST_BINDER(case2203), TEST_BINDER(case2204), TEST_BINDER(case2205), + TEST_BINDER(case2206), TEST_BINDER(case2207), TEST_BINDER(case2208), + TEST_BINDER(case2209), TEST_BINDER(case2210), TEST_BINDER(case2211), + TEST_BINDER(case2212), TEST_BINDER(case2213), TEST_BINDER(case2214), + TEST_BINDER(case2215), TEST_BINDER(case2216), TEST_BINDER(case2217), + TEST_BINDER(case2218), TEST_BINDER(case2219), TEST_BINDER(case2220), + TEST_BINDER(case2221), TEST_BINDER(case2222), TEST_BINDER(case2223), + TEST_BINDER(case2224), TEST_BINDER(case2225), TEST_BINDER(case2226), + TEST_BINDER(case2227), TEST_BINDER(case2228), TEST_BINDER(case2229), + TEST_BINDER(case2230), TEST_BINDER(case2231), TEST_BINDER(case2232), + TEST_BINDER(case2233), TEST_BINDER(case2234), TEST_BINDER(case2235), + TEST_BINDER(case2236), TEST_BINDER(case2237), TEST_BINDER(case2238), + TEST_BINDER(case2239), TEST_BINDER(case2240), TEST_BINDER(case2241), + TEST_BINDER(case2242), TEST_BINDER(case2243), TEST_BINDER(case2244), + TEST_BINDER(case2245), TEST_BINDER(case2246), TEST_BINDER(case2247), + TEST_BINDER(case2248), TEST_BINDER(case2249), TEST_BINDER(case2250), + TEST_BINDER(case2251), TEST_BINDER(case2252), TEST_BINDER(case2253), + TEST_BINDER(case2254), TEST_BINDER(case2255), TEST_BINDER(case2256), + TEST_BINDER(case2257), TEST_BINDER(case2258), TEST_BINDER(case2259), + TEST_BINDER(case2260), TEST_BINDER(case2261), TEST_BINDER(case2262), + TEST_BINDER(case2263), TEST_BINDER(case2264), TEST_BINDER(case2265), + TEST_BINDER(case2266), TEST_BINDER(case2267), TEST_BINDER(case2268), + TEST_BINDER(case2269), TEST_BINDER(case2270), TEST_BINDER(case2271), + TEST_BINDER(case2272), TEST_BINDER(case2273), TEST_BINDER(case2274), + TEST_BINDER(case2275), TEST_BINDER(case2276), TEST_BINDER(case2277), + TEST_BINDER(case2278), TEST_BINDER(case2279), TEST_BINDER(case2280), + TEST_BINDER(case2281), TEST_BINDER(case2282), TEST_BINDER(case2283), + TEST_BINDER(case2284), TEST_BINDER(case2285), TEST_BINDER(case2286), + TEST_BINDER(case2287), TEST_BINDER(case2288), TEST_BINDER(case2289), + TEST_BINDER(case2290), TEST_BINDER(case2291), TEST_BINDER(case2292), + TEST_BINDER(case2293), TEST_BINDER(case2294), TEST_BINDER(case2295), + TEST_BINDER(case2296), TEST_BINDER(case2297), TEST_BINDER(case2298), + TEST_BINDER(case2299), - TEST_BINDER(case2300), - TEST_BINDER(case2301), - TEST_BINDER(case2302), - TEST_BINDER(case2303), - TEST_BINDER(case2304), - TEST_BINDER(case2305), - TEST_BINDER(case2306), - TEST_BINDER(case2307), - TEST_BINDER(case2308), - TEST_BINDER(case2309), - TEST_BINDER(case2310), - TEST_BINDER(case2311), - TEST_BINDER(case2312), - TEST_BINDER(case2313), - TEST_BINDER(case2314), - TEST_BINDER(case2315), - TEST_BINDER(case2316), - TEST_BINDER(case2317), - TEST_BINDER(case2318), - TEST_BINDER(case2319), - TEST_BINDER(case2320), - TEST_BINDER(case2321), - TEST_BINDER(case2322), - TEST_BINDER(case2323), - TEST_BINDER(case2324), - TEST_BINDER(case2325), - TEST_BINDER(case2326), - TEST_BINDER(case2327), - TEST_BINDER(case2328), - TEST_BINDER(case2329), - TEST_BINDER(case2330), - TEST_BINDER(case2331), - TEST_BINDER(case2332), - TEST_BINDER(case2333), - TEST_BINDER(case2334), - TEST_BINDER(case2335), - TEST_BINDER(case2336), - TEST_BINDER(case2337), - TEST_BINDER(case2338), - TEST_BINDER(case2339), - TEST_BINDER(case2340), - TEST_BINDER(case2341), - TEST_BINDER(case2342), - TEST_BINDER(case2343), - TEST_BINDER(case2344), - TEST_BINDER(case2345), - TEST_BINDER(case2346), - TEST_BINDER(case2347), - TEST_BINDER(case2348), - TEST_BINDER(case2349), - TEST_BINDER(case2350), - TEST_BINDER(case2351), - TEST_BINDER(case2352), - TEST_BINDER(case2353), - TEST_BINDER(case2354), - TEST_BINDER(case2355), - TEST_BINDER(case2356), - TEST_BINDER(case2357), - TEST_BINDER(case2358), - TEST_BINDER(case2359), - TEST_BINDER(case2360), - TEST_BINDER(case2361), - TEST_BINDER(case2362), - TEST_BINDER(case2363), - TEST_BINDER(case2364), - TEST_BINDER(case2365), - TEST_BINDER(case2366), - TEST_BINDER(case2367), - TEST_BINDER(case2368), - TEST_BINDER(case2369), - TEST_BINDER(case2370), - TEST_BINDER(case2371), - TEST_BINDER(case2372), - TEST_BINDER(case2373), - TEST_BINDER(case2374), - TEST_BINDER(case2375), - TEST_BINDER(case2376), - TEST_BINDER(case2377), - TEST_BINDER(case2378), - TEST_BINDER(case2379), - TEST_BINDER(case2380), - TEST_BINDER(case2381), - TEST_BINDER(case2382), - TEST_BINDER(case2383), - TEST_BINDER(case2384), - TEST_BINDER(case2385), - TEST_BINDER(case2386), - TEST_BINDER(case2387), - TEST_BINDER(case2388), - TEST_BINDER(case2389), - TEST_BINDER(case2390), - TEST_BINDER(case2391), - TEST_BINDER(case2392), - TEST_BINDER(case2393), - TEST_BINDER(case2394), - TEST_BINDER(case2395), - TEST_BINDER(case2396), - TEST_BINDER(case2397), - TEST_BINDER(case2398), - TEST_BINDER(case2399), + TEST_BINDER(case2300), TEST_BINDER(case2301), TEST_BINDER(case2302), + TEST_BINDER(case2303), TEST_BINDER(case2304), TEST_BINDER(case2305), + TEST_BINDER(case2306), TEST_BINDER(case2307), TEST_BINDER(case2308), + TEST_BINDER(case2309), TEST_BINDER(case2310), TEST_BINDER(case2311), + TEST_BINDER(case2312), TEST_BINDER(case2313), TEST_BINDER(case2314), + TEST_BINDER(case2315), TEST_BINDER(case2316), TEST_BINDER(case2317), + TEST_BINDER(case2318), TEST_BINDER(case2319), TEST_BINDER(case2320), + TEST_BINDER(case2321), TEST_BINDER(case2322), TEST_BINDER(case2323), + TEST_BINDER(case2324), TEST_BINDER(case2325), TEST_BINDER(case2326), + TEST_BINDER(case2327), TEST_BINDER(case2328), TEST_BINDER(case2329), + TEST_BINDER(case2330), TEST_BINDER(case2331), TEST_BINDER(case2332), + TEST_BINDER(case2333), TEST_BINDER(case2334), TEST_BINDER(case2335), + TEST_BINDER(case2336), TEST_BINDER(case2337), TEST_BINDER(case2338), + TEST_BINDER(case2339), TEST_BINDER(case2340), TEST_BINDER(case2341), + TEST_BINDER(case2342), TEST_BINDER(case2343), TEST_BINDER(case2344), + TEST_BINDER(case2345), TEST_BINDER(case2346), TEST_BINDER(case2347), + TEST_BINDER(case2348), TEST_BINDER(case2349), TEST_BINDER(case2350), + TEST_BINDER(case2351), TEST_BINDER(case2352), TEST_BINDER(case2353), + TEST_BINDER(case2354), TEST_BINDER(case2355), TEST_BINDER(case2356), + TEST_BINDER(case2357), TEST_BINDER(case2358), TEST_BINDER(case2359), + TEST_BINDER(case2360), TEST_BINDER(case2361), TEST_BINDER(case2362), + TEST_BINDER(case2363), TEST_BINDER(case2364), TEST_BINDER(case2365), + TEST_BINDER(case2366), TEST_BINDER(case2367), TEST_BINDER(case2368), + TEST_BINDER(case2369), TEST_BINDER(case2370), TEST_BINDER(case2371), + TEST_BINDER(case2372), TEST_BINDER(case2373), TEST_BINDER(case2374), + TEST_BINDER(case2375), TEST_BINDER(case2376), TEST_BINDER(case2377), + TEST_BINDER(case2378), TEST_BINDER(case2379), TEST_BINDER(case2380), + TEST_BINDER(case2381), TEST_BINDER(case2382), TEST_BINDER(case2383), + TEST_BINDER(case2384), TEST_BINDER(case2385), TEST_BINDER(case2386), + TEST_BINDER(case2387), TEST_BINDER(case2388), TEST_BINDER(case2389), + TEST_BINDER(case2390), TEST_BINDER(case2391), TEST_BINDER(case2392), + TEST_BINDER(case2393), TEST_BINDER(case2394), TEST_BINDER(case2395), + TEST_BINDER(case2396), TEST_BINDER(case2397), TEST_BINDER(case2398), + TEST_BINDER(case2399), - TEST_BINDER(case3001), - TEST_BINDER(case3002), - TEST_BINDER(case3003), - TEST_BINDER(case3004), - TEST_BINDER(case3005), - TEST_BINDER(case3006), - TEST_BINDER(case3007), - TEST_BINDER(case3008), - TEST_BINDER(case3009), - TEST_BINDER(case3010), - TEST_BINDER(case3011), - TEST_BINDER(case3012), - TEST_BINDER(case3013), - TEST_BINDER(case3014), - TEST_BINDER(case3015), - TEST_BINDER(case3016), - TEST_BINDER(case3017), - TEST_BINDER(case3018), - TEST_BINDER(case3019), - TEST_BINDER(case3020), - TEST_BINDER(case3021), - TEST_BINDER(case3022), - TEST_BINDER(case3023), - TEST_BINDER(case3024), - TEST_BINDER(case3025), - TEST_BINDER(case3026), - TEST_BINDER(case3027), - TEST_BINDER(case3028), - TEST_BINDER(case3029), - TEST_BINDER(case3030), - TEST_BINDER(case3031), - TEST_BINDER(case3032), - TEST_BINDER(case3033), - TEST_BINDER(case3034), - TEST_BINDER(case3035), - TEST_BINDER(case3036), - TEST_BINDER(case3037), - TEST_BINDER(case3038), - TEST_BINDER(case3039), - TEST_BINDER(case3040), - TEST_BINDER(case3041), - TEST_BINDER(case3042), - TEST_BINDER(case3043), - TEST_BINDER(case3044), - TEST_BINDER(case3045), - TEST_BINDER(case3046), - TEST_BINDER(case3047), - TEST_BINDER(case3048), - TEST_BINDER(case3049), - TEST_BINDER(case3050), - TEST_BINDER(case3051), - TEST_BINDER(case3052), - TEST_BINDER(case3053), - TEST_BINDER(case3054), - TEST_BINDER(case3055), - TEST_BINDER(case3056), - TEST_BINDER(case3057), - TEST_BINDER(case3058), - TEST_BINDER(case3059), - TEST_BINDER(case3060), - TEST_BINDER(case3061), - TEST_BINDER(case3062), - TEST_BINDER(case3063), - TEST_BINDER(case3064), - TEST_BINDER(case3065), - TEST_BINDER(case3066), - TEST_BINDER(case3067), - TEST_BINDER(case3068), - TEST_BINDER(case3069), - TEST_BINDER(case3070), - TEST_BINDER(case3071), - TEST_BINDER(case3072), - TEST_BINDER(case3073), - TEST_BINDER(case3074), - TEST_BINDER(case3075), - TEST_BINDER(case3076), - TEST_BINDER(case3077), - TEST_BINDER(case3078), - TEST_BINDER(case3079), - TEST_BINDER(case3080), - TEST_BINDER(case3081), - TEST_BINDER(case3082), - TEST_BINDER(case3083), - TEST_BINDER(case3084), - TEST_BINDER(case3085), - TEST_BINDER(case3086), - TEST_BINDER(case3087), - TEST_BINDER(case3088), - TEST_BINDER(case3089), - TEST_BINDER(case3090), - TEST_BINDER(case3091), - TEST_BINDER(case3092), - TEST_BINDER(case3093), - TEST_BINDER(case3094), - TEST_BINDER(case3095), - TEST_BINDER(case3096), - TEST_BINDER(case3097), - TEST_BINDER(case3098), - TEST_BINDER(case3099), + TEST_BINDER(case3001), TEST_BINDER(case3002), TEST_BINDER(case3003), + TEST_BINDER(case3004), TEST_BINDER(case3005), TEST_BINDER(case3006), + TEST_BINDER(case3007), TEST_BINDER(case3008), TEST_BINDER(case3009), + TEST_BINDER(case3010), TEST_BINDER(case3011), TEST_BINDER(case3012), + TEST_BINDER(case3013), TEST_BINDER(case3014), TEST_BINDER(case3015), + TEST_BINDER(case3016), TEST_BINDER(case3017), TEST_BINDER(case3018), + TEST_BINDER(case3019), TEST_BINDER(case3020), TEST_BINDER(case3021), + TEST_BINDER(case3022), TEST_BINDER(case3023), TEST_BINDER(case3024), + TEST_BINDER(case3025), TEST_BINDER(case3026), TEST_BINDER(case3027), + TEST_BINDER(case3028), TEST_BINDER(case3029), TEST_BINDER(case3030), + TEST_BINDER(case3031), TEST_BINDER(case3032), TEST_BINDER(case3033), + TEST_BINDER(case3034), TEST_BINDER(case3035), TEST_BINDER(case3036), + TEST_BINDER(case3037), TEST_BINDER(case3038), TEST_BINDER(case3039), + TEST_BINDER(case3040), TEST_BINDER(case3041), TEST_BINDER(case3042), + TEST_BINDER(case3043), TEST_BINDER(case3044), TEST_BINDER(case3045), + TEST_BINDER(case3046), TEST_BINDER(case3047), TEST_BINDER(case3048), + TEST_BINDER(case3049), TEST_BINDER(case3050), TEST_BINDER(case3051), + TEST_BINDER(case3052), TEST_BINDER(case3053), TEST_BINDER(case3054), + TEST_BINDER(case3055), TEST_BINDER(case3056), TEST_BINDER(case3057), + TEST_BINDER(case3058), TEST_BINDER(case3059), TEST_BINDER(case3060), + TEST_BINDER(case3061), TEST_BINDER(case3062), TEST_BINDER(case3063), + TEST_BINDER(case3064), TEST_BINDER(case3065), TEST_BINDER(case3066), + TEST_BINDER(case3067), TEST_BINDER(case3068), TEST_BINDER(case3069), + TEST_BINDER(case3070), TEST_BINDER(case3071), TEST_BINDER(case3072), + TEST_BINDER(case3073), TEST_BINDER(case3074), TEST_BINDER(case3075), + TEST_BINDER(case3076), TEST_BINDER(case3077), TEST_BINDER(case3078), + TEST_BINDER(case3079), TEST_BINDER(case3080), TEST_BINDER(case3081), + TEST_BINDER(case3082), TEST_BINDER(case3083), TEST_BINDER(case3084), + TEST_BINDER(case3085), TEST_BINDER(case3086), TEST_BINDER(case3087), + TEST_BINDER(case3088), TEST_BINDER(case3089), TEST_BINDER(case3090), + TEST_BINDER(case3091), TEST_BINDER(case3092), TEST_BINDER(case3093), + TEST_BINDER(case3094), TEST_BINDER(case3095), TEST_BINDER(case3096), + TEST_BINDER(case3097), TEST_BINDER(case3098), TEST_BINDER(case3099), - TEST_BINDER(case3100), - TEST_BINDER(case3101), - TEST_BINDER(case3102), - TEST_BINDER(case3103), - TEST_BINDER(case3104), - TEST_BINDER(case3105), - TEST_BINDER(case3106), - TEST_BINDER(case3107), - TEST_BINDER(case3108), - TEST_BINDER(case3109), - TEST_BINDER(case3110), - TEST_BINDER(case3111), - TEST_BINDER(case3112), - TEST_BINDER(case3113), - TEST_BINDER(case3114), - TEST_BINDER(case3115), - TEST_BINDER(case3116), - TEST_BINDER(case3117), - TEST_BINDER(case3118), - TEST_BINDER(case3119), - TEST_BINDER(case3120), - TEST_BINDER(case3121), - TEST_BINDER(case3122), - TEST_BINDER(case3123), - TEST_BINDER(case3124), - TEST_BINDER(case3125), - TEST_BINDER(case3126), - TEST_BINDER(case3127), - TEST_BINDER(case3128), - TEST_BINDER(case3129), - TEST_BINDER(case3130), - TEST_BINDER(case3131), - TEST_BINDER(case3132), - TEST_BINDER(case3133), - TEST_BINDER(case3134), - TEST_BINDER(case3135), - TEST_BINDER(case3136), - TEST_BINDER(case3137), - TEST_BINDER(case3138), - TEST_BINDER(case3139), - TEST_BINDER(case3140), - TEST_BINDER(case3141), - TEST_BINDER(case3142), - TEST_BINDER(case3143), - TEST_BINDER(case3144), - TEST_BINDER(case3145), - TEST_BINDER(case3146), - TEST_BINDER(case3147), - TEST_BINDER(case3148), - TEST_BINDER(case3149), - TEST_BINDER(case3150), - TEST_BINDER(case3151), - TEST_BINDER(case3152), - TEST_BINDER(case3153), - TEST_BINDER(case3154), - TEST_BINDER(case3155), - TEST_BINDER(case3156), - TEST_BINDER(case3157), - TEST_BINDER(case3158), - TEST_BINDER(case3159), - TEST_BINDER(case3160), - TEST_BINDER(case3161), - TEST_BINDER(case3162), - TEST_BINDER(case3163), - TEST_BINDER(case3164), - TEST_BINDER(case3165), - TEST_BINDER(case3166), - TEST_BINDER(case3167), - TEST_BINDER(case3168), - TEST_BINDER(case3169), - TEST_BINDER(case3170), - TEST_BINDER(case3171), - TEST_BINDER(case3172), - TEST_BINDER(case3173), - TEST_BINDER(case3174), - TEST_BINDER(case3175), - TEST_BINDER(case3176), - TEST_BINDER(case3177), - TEST_BINDER(case3178), - TEST_BINDER(case3179), - TEST_BINDER(case3180), - TEST_BINDER(case3181), - TEST_BINDER(case3182), - TEST_BINDER(case3183), - TEST_BINDER(case3184), - TEST_BINDER(case3185), - TEST_BINDER(case3186), - TEST_BINDER(case3187), - TEST_BINDER(case3188), - TEST_BINDER(case3189), - TEST_BINDER(case3190), - TEST_BINDER(case3191), - TEST_BINDER(case3192), - TEST_BINDER(case3193), - TEST_BINDER(case3194), - TEST_BINDER(case3195), - TEST_BINDER(case3196), - TEST_BINDER(case3197), - TEST_BINDER(case3198), - TEST_BINDER(case3199), + TEST_BINDER(case3100), TEST_BINDER(case3101), TEST_BINDER(case3102), + TEST_BINDER(case3103), TEST_BINDER(case3104), TEST_BINDER(case3105), + TEST_BINDER(case3106), TEST_BINDER(case3107), TEST_BINDER(case3108), + TEST_BINDER(case3109), TEST_BINDER(case3110), TEST_BINDER(case3111), + TEST_BINDER(case3112), TEST_BINDER(case3113), TEST_BINDER(case3114), + TEST_BINDER(case3115), TEST_BINDER(case3116), TEST_BINDER(case3117), + TEST_BINDER(case3118), TEST_BINDER(case3119), TEST_BINDER(case3120), + TEST_BINDER(case3121), TEST_BINDER(case3122), TEST_BINDER(case3123), + TEST_BINDER(case3124), TEST_BINDER(case3125), TEST_BINDER(case3126), + TEST_BINDER(case3127), TEST_BINDER(case3128), TEST_BINDER(case3129), + TEST_BINDER(case3130), TEST_BINDER(case3131), TEST_BINDER(case3132), + TEST_BINDER(case3133), TEST_BINDER(case3134), TEST_BINDER(case3135), + TEST_BINDER(case3136), TEST_BINDER(case3137), TEST_BINDER(case3138), + TEST_BINDER(case3139), TEST_BINDER(case3140), TEST_BINDER(case3141), + TEST_BINDER(case3142), TEST_BINDER(case3143), TEST_BINDER(case3144), + TEST_BINDER(case3145), TEST_BINDER(case3146), TEST_BINDER(case3147), + TEST_BINDER(case3148), TEST_BINDER(case3149), TEST_BINDER(case3150), + TEST_BINDER(case3151), TEST_BINDER(case3152), TEST_BINDER(case3153), + TEST_BINDER(case3154), TEST_BINDER(case3155), TEST_BINDER(case3156), + TEST_BINDER(case3157), TEST_BINDER(case3158), TEST_BINDER(case3159), + TEST_BINDER(case3160), TEST_BINDER(case3161), TEST_BINDER(case3162), + TEST_BINDER(case3163), TEST_BINDER(case3164), TEST_BINDER(case3165), + TEST_BINDER(case3166), TEST_BINDER(case3167), TEST_BINDER(case3168), + TEST_BINDER(case3169), TEST_BINDER(case3170), TEST_BINDER(case3171), + TEST_BINDER(case3172), TEST_BINDER(case3173), TEST_BINDER(case3174), + TEST_BINDER(case3175), TEST_BINDER(case3176), TEST_BINDER(case3177), + TEST_BINDER(case3178), TEST_BINDER(case3179), TEST_BINDER(case3180), + TEST_BINDER(case3181), TEST_BINDER(case3182), TEST_BINDER(case3183), + TEST_BINDER(case3184), TEST_BINDER(case3185), TEST_BINDER(case3186), + TEST_BINDER(case3187), TEST_BINDER(case3188), TEST_BINDER(case3189), + TEST_BINDER(case3190), TEST_BINDER(case3191), TEST_BINDER(case3192), + TEST_BINDER(case3193), TEST_BINDER(case3194), TEST_BINDER(case3195), + TEST_BINDER(case3196), TEST_BINDER(case3197), TEST_BINDER(case3198), + TEST_BINDER(case3199), - TEST_BINDER(case3200), - TEST_BINDER(case3201), - TEST_BINDER(case3202), - TEST_BINDER(case3203), - TEST_BINDER(case3204), - TEST_BINDER(case3205), - TEST_BINDER(case3206), - TEST_BINDER(case3207), - TEST_BINDER(case3208), - TEST_BINDER(case3209), - TEST_BINDER(case3210), - TEST_BINDER(case3211), - TEST_BINDER(case3212), - TEST_BINDER(case3213), - TEST_BINDER(case3214), - TEST_BINDER(case3215), - TEST_BINDER(case3216), - TEST_BINDER(case3217), - TEST_BINDER(case3218), - TEST_BINDER(case3219), - TEST_BINDER(case3220), - TEST_BINDER(case3221), - TEST_BINDER(case3222), - TEST_BINDER(case3223), - TEST_BINDER(case3224), - TEST_BINDER(case3225), - TEST_BINDER(case3226), - TEST_BINDER(case3227), - TEST_BINDER(case3228), - TEST_BINDER(case3229), - TEST_BINDER(case3230), - TEST_BINDER(case3231), - TEST_BINDER(case3232), - TEST_BINDER(case3233), - TEST_BINDER(case3234), - TEST_BINDER(case3235), - TEST_BINDER(case3236), - TEST_BINDER(case3237), - TEST_BINDER(case3238), - TEST_BINDER(case3239), - TEST_BINDER(case3240), - TEST_BINDER(case3241), - TEST_BINDER(case3242), - TEST_BINDER(case3243), - TEST_BINDER(case3244), - TEST_BINDER(case3245), - TEST_BINDER(case3246), - TEST_BINDER(case3247), - TEST_BINDER(case3248), - TEST_BINDER(case3249), - TEST_BINDER(case3250), - TEST_BINDER(case3251), - TEST_BINDER(case3252), - TEST_BINDER(case3253), - TEST_BINDER(case3254), - TEST_BINDER(case3255), - TEST_BINDER(case3256), - TEST_BINDER(case3257), - TEST_BINDER(case3258), - TEST_BINDER(case3259), - TEST_BINDER(case3260), - TEST_BINDER(case3261), - TEST_BINDER(case3262), - TEST_BINDER(case3263), - TEST_BINDER(case3264), - TEST_BINDER(case3265), - TEST_BINDER(case3266), - TEST_BINDER(case3267), - TEST_BINDER(case3268), - TEST_BINDER(case3269), - TEST_BINDER(case3270), - TEST_BINDER(case3271), - TEST_BINDER(case3272), - TEST_BINDER(case3273), - TEST_BINDER(case3274), - TEST_BINDER(case3275), - TEST_BINDER(case3276), - TEST_BINDER(case3277), - TEST_BINDER(case3278), - TEST_BINDER(case3279), - TEST_BINDER(case3280), - TEST_BINDER(case3281), - TEST_BINDER(case3282), - TEST_BINDER(case3283), - TEST_BINDER(case3284), - TEST_BINDER(case3285), - TEST_BINDER(case3286), - TEST_BINDER(case3287), - TEST_BINDER(case3288), - TEST_BINDER(case3289), - TEST_BINDER(case3290), - TEST_BINDER(case3291), - TEST_BINDER(case3292), - TEST_BINDER(case3293), - TEST_BINDER(case3294), - TEST_BINDER(case3295), - TEST_BINDER(case3296), - TEST_BINDER(case3297), - TEST_BINDER(case3298), - TEST_BINDER(case3299), + TEST_BINDER(case3200), TEST_BINDER(case3201), TEST_BINDER(case3202), + TEST_BINDER(case3203), TEST_BINDER(case3204), TEST_BINDER(case3205), + TEST_BINDER(case3206), TEST_BINDER(case3207), TEST_BINDER(case3208), + TEST_BINDER(case3209), TEST_BINDER(case3210), TEST_BINDER(case3211), + TEST_BINDER(case3212), TEST_BINDER(case3213), TEST_BINDER(case3214), + TEST_BINDER(case3215), TEST_BINDER(case3216), TEST_BINDER(case3217), + TEST_BINDER(case3218), TEST_BINDER(case3219), TEST_BINDER(case3220), + TEST_BINDER(case3221), TEST_BINDER(case3222), TEST_BINDER(case3223), + TEST_BINDER(case3224), TEST_BINDER(case3225), TEST_BINDER(case3226), + TEST_BINDER(case3227), TEST_BINDER(case3228), TEST_BINDER(case3229), + TEST_BINDER(case3230), TEST_BINDER(case3231), TEST_BINDER(case3232), + TEST_BINDER(case3233), TEST_BINDER(case3234), TEST_BINDER(case3235), + TEST_BINDER(case3236), TEST_BINDER(case3237), TEST_BINDER(case3238), + TEST_BINDER(case3239), TEST_BINDER(case3240), TEST_BINDER(case3241), + TEST_BINDER(case3242), TEST_BINDER(case3243), TEST_BINDER(case3244), + TEST_BINDER(case3245), TEST_BINDER(case3246), TEST_BINDER(case3247), + TEST_BINDER(case3248), TEST_BINDER(case3249), TEST_BINDER(case3250), + TEST_BINDER(case3251), TEST_BINDER(case3252), TEST_BINDER(case3253), + TEST_BINDER(case3254), TEST_BINDER(case3255), TEST_BINDER(case3256), + TEST_BINDER(case3257), TEST_BINDER(case3258), TEST_BINDER(case3259), + TEST_BINDER(case3260), TEST_BINDER(case3261), TEST_BINDER(case3262), + TEST_BINDER(case3263), TEST_BINDER(case3264), TEST_BINDER(case3265), + TEST_BINDER(case3266), TEST_BINDER(case3267), TEST_BINDER(case3268), + TEST_BINDER(case3269), TEST_BINDER(case3270), TEST_BINDER(case3271), + TEST_BINDER(case3272), TEST_BINDER(case3273), TEST_BINDER(case3274), + TEST_BINDER(case3275), TEST_BINDER(case3276), TEST_BINDER(case3277), + TEST_BINDER(case3278), TEST_BINDER(case3279), TEST_BINDER(case3280), + TEST_BINDER(case3281), TEST_BINDER(case3282), TEST_BINDER(case3283), + TEST_BINDER(case3284), TEST_BINDER(case3285), TEST_BINDER(case3286), + TEST_BINDER(case3287), TEST_BINDER(case3288), TEST_BINDER(case3289), + TEST_BINDER(case3290), TEST_BINDER(case3291), TEST_BINDER(case3292), + TEST_BINDER(case3293), TEST_BINDER(case3294), TEST_BINDER(case3295), + TEST_BINDER(case3296), TEST_BINDER(case3297), TEST_BINDER(case3298), + TEST_BINDER(case3299), - TEST_BINDER(case3300), - TEST_BINDER(case3301), - TEST_BINDER(case3302), - TEST_BINDER(case3303), - TEST_BINDER(case3304), - TEST_BINDER(case3305), - TEST_BINDER(case3306), - TEST_BINDER(case3307), - TEST_BINDER(case3308), - TEST_BINDER(case3309), - TEST_BINDER(case3310), - TEST_BINDER(case3311), - TEST_BINDER(case3312), - TEST_BINDER(case3313), - TEST_BINDER(case3314), - TEST_BINDER(case3315), - TEST_BINDER(case3316), - TEST_BINDER(case3317), - TEST_BINDER(case3318), - TEST_BINDER(case3319), - TEST_BINDER(case3320), - TEST_BINDER(case3321), - TEST_BINDER(case3322), - TEST_BINDER(case3323), - TEST_BINDER(case3324), - TEST_BINDER(case3325), - TEST_BINDER(case3326), - TEST_BINDER(case3327), - TEST_BINDER(case3328), - TEST_BINDER(case3329), - TEST_BINDER(case3330), - TEST_BINDER(case3331), - TEST_BINDER(case3332), - TEST_BINDER(case3333), - TEST_BINDER(case3334), - TEST_BINDER(case3335), - TEST_BINDER(case3336), - TEST_BINDER(case3337), - TEST_BINDER(case3338), - TEST_BINDER(case3339), - TEST_BINDER(case3340), - TEST_BINDER(case3341), - TEST_BINDER(case3342), - TEST_BINDER(case3343), - TEST_BINDER(case3344), - TEST_BINDER(case3345), - TEST_BINDER(case3346), - TEST_BINDER(case3347), - TEST_BINDER(case3348), - TEST_BINDER(case3349), - TEST_BINDER(case3350), - TEST_BINDER(case3351), - TEST_BINDER(case3352), - TEST_BINDER(case3353), - TEST_BINDER(case3354), - TEST_BINDER(case3355), - TEST_BINDER(case3356), - TEST_BINDER(case3357), - TEST_BINDER(case3358), - TEST_BINDER(case3359), - TEST_BINDER(case3360), - TEST_BINDER(case3361), - TEST_BINDER(case3362), - TEST_BINDER(case3363), - TEST_BINDER(case3364), - TEST_BINDER(case3365), - TEST_BINDER(case3366), - TEST_BINDER(case3367), - TEST_BINDER(case3368), - TEST_BINDER(case3369), - TEST_BINDER(case3370), - TEST_BINDER(case3371), - TEST_BINDER(case3372), - TEST_BINDER(case3373), - TEST_BINDER(case3374), - TEST_BINDER(case3375), - TEST_BINDER(case3376), - TEST_BINDER(case3377), - TEST_BINDER(case3378), - TEST_BINDER(case3379), - TEST_BINDER(case3380), - TEST_BINDER(case3381), - TEST_BINDER(case3382), - TEST_BINDER(case3383), - TEST_BINDER(case3384), - TEST_BINDER(case3385), - TEST_BINDER(case3386), - TEST_BINDER(case3387), - TEST_BINDER(case3388), - TEST_BINDER(case3389), - TEST_BINDER(case3390), - TEST_BINDER(case3391), - TEST_BINDER(case3392), - TEST_BINDER(case3393), - TEST_BINDER(case3394), - TEST_BINDER(case3395), - TEST_BINDER(case3396), - TEST_BINDER(case3397), - TEST_BINDER(case3398), - TEST_BINDER(case3399), + TEST_BINDER(case3300), TEST_BINDER(case3301), TEST_BINDER(case3302), + TEST_BINDER(case3303), TEST_BINDER(case3304), TEST_BINDER(case3305), + TEST_BINDER(case3306), TEST_BINDER(case3307), TEST_BINDER(case3308), + TEST_BINDER(case3309), TEST_BINDER(case3310), TEST_BINDER(case3311), + TEST_BINDER(case3312), TEST_BINDER(case3313), TEST_BINDER(case3314), + TEST_BINDER(case3315), TEST_BINDER(case3316), TEST_BINDER(case3317), + TEST_BINDER(case3318), TEST_BINDER(case3319), TEST_BINDER(case3320), + TEST_BINDER(case3321), TEST_BINDER(case3322), TEST_BINDER(case3323), + TEST_BINDER(case3324), TEST_BINDER(case3325), TEST_BINDER(case3326), + TEST_BINDER(case3327), TEST_BINDER(case3328), TEST_BINDER(case3329), + TEST_BINDER(case3330), TEST_BINDER(case3331), TEST_BINDER(case3332), + TEST_BINDER(case3333), TEST_BINDER(case3334), TEST_BINDER(case3335), + TEST_BINDER(case3336), TEST_BINDER(case3337), TEST_BINDER(case3338), + TEST_BINDER(case3339), TEST_BINDER(case3340), TEST_BINDER(case3341), + TEST_BINDER(case3342), TEST_BINDER(case3343), TEST_BINDER(case3344), + TEST_BINDER(case3345), TEST_BINDER(case3346), TEST_BINDER(case3347), + TEST_BINDER(case3348), TEST_BINDER(case3349), TEST_BINDER(case3350), + TEST_BINDER(case3351), TEST_BINDER(case3352), TEST_BINDER(case3353), + TEST_BINDER(case3354), TEST_BINDER(case3355), TEST_BINDER(case3356), + TEST_BINDER(case3357), TEST_BINDER(case3358), TEST_BINDER(case3359), + TEST_BINDER(case3360), TEST_BINDER(case3361), TEST_BINDER(case3362), + TEST_BINDER(case3363), TEST_BINDER(case3364), TEST_BINDER(case3365), + TEST_BINDER(case3366), TEST_BINDER(case3367), TEST_BINDER(case3368), + TEST_BINDER(case3369), TEST_BINDER(case3370), TEST_BINDER(case3371), + TEST_BINDER(case3372), TEST_BINDER(case3373), TEST_BINDER(case3374), + TEST_BINDER(case3375), TEST_BINDER(case3376), TEST_BINDER(case3377), + TEST_BINDER(case3378), TEST_BINDER(case3379), TEST_BINDER(case3380), + TEST_BINDER(case3381), TEST_BINDER(case3382), TEST_BINDER(case3383), + TEST_BINDER(case3384), TEST_BINDER(case3385), TEST_BINDER(case3386), + TEST_BINDER(case3387), TEST_BINDER(case3388), TEST_BINDER(case3389), + TEST_BINDER(case3390), TEST_BINDER(case3391), TEST_BINDER(case3392), + TEST_BINDER(case3393), TEST_BINDER(case3394), TEST_BINDER(case3395), + TEST_BINDER(case3396), TEST_BINDER(case3397), TEST_BINDER(case3398), + TEST_BINDER(case3399), - TEST_BINDER(case3400), - TEST_BINDER(case3401), - TEST_BINDER(case3402), - TEST_BINDER(case3403), - TEST_BINDER(case3404), - TEST_BINDER(case3405), - TEST_BINDER(case3406), - TEST_BINDER(case3407), - TEST_BINDER(case3408), - TEST_BINDER(case3409), - TEST_BINDER(case3410), - TEST_BINDER(case3411), - TEST_BINDER(case3412), - TEST_BINDER(case3413), - TEST_BINDER(case3414), - TEST_BINDER(case3415), - TEST_BINDER(case3416), - TEST_BINDER(case3417), - TEST_BINDER(case3418), - TEST_BINDER(case3419), - TEST_BINDER(case3420), - TEST_BINDER(case3421), - TEST_BINDER(case3422), - TEST_BINDER(case3423), - TEST_BINDER(case3424), - TEST_BINDER(case3425), - TEST_BINDER(case3426), - TEST_BINDER(case3427), - TEST_BINDER(case3428), - TEST_BINDER(case3429), - TEST_BINDER(case3430), - TEST_BINDER(case3431), - TEST_BINDER(case3432), - TEST_BINDER(case3433), - TEST_BINDER(case3434), - TEST_BINDER(case3435), - TEST_BINDER(case3436), - TEST_BINDER(case3437), - TEST_BINDER(case3438), - TEST_BINDER(case3439), - TEST_BINDER(case3440), - TEST_BINDER(case3441), - TEST_BINDER(case3442), - TEST_BINDER(case3443), - TEST_BINDER(case3444), - TEST_BINDER(case3445), - TEST_BINDER(case3446), - TEST_BINDER(case3447), - TEST_BINDER(case3448), - TEST_BINDER(case3449), - TEST_BINDER(case3450), - TEST_BINDER(case3451), - TEST_BINDER(case3452), - TEST_BINDER(case3453), - TEST_BINDER(case3454), - TEST_BINDER(case3455), - TEST_BINDER(case3456), - TEST_BINDER(case3457), - TEST_BINDER(case3458), - TEST_BINDER(case3459), - TEST_BINDER(case3460), - TEST_BINDER(case3461), - TEST_BINDER(case3462), - TEST_BINDER(case3463), - TEST_BINDER(case3464), - TEST_BINDER(case3465), - TEST_BINDER(case3466), - TEST_BINDER(case3467), - TEST_BINDER(case3468), - TEST_BINDER(case3469), - TEST_BINDER(case3470), - TEST_BINDER(case3471), - TEST_BINDER(case3472), - TEST_BINDER(case3473), - TEST_BINDER(case3474), - TEST_BINDER(case3475), - TEST_BINDER(case3476), - TEST_BINDER(case3477), - TEST_BINDER(case3478), - TEST_BINDER(case3479), - TEST_BINDER(case3480), - TEST_BINDER(case3481), - TEST_BINDER(case3482), - TEST_BINDER(case3483), - TEST_BINDER(case3484), - TEST_BINDER(case3485), - TEST_BINDER(case3486), - TEST_BINDER(case3487), - TEST_BINDER(case3488), - TEST_BINDER(case3489), - TEST_BINDER(case3490), - TEST_BINDER(case3491), - TEST_BINDER(case3492), - TEST_BINDER(case3493), - TEST_BINDER(case3494), - TEST_BINDER(case3495), - TEST_BINDER(case3496), - TEST_BINDER(case3497), - TEST_BINDER(case3498), - TEST_BINDER(case3499), + TEST_BINDER(case3400), TEST_BINDER(case3401), TEST_BINDER(case3402), + TEST_BINDER(case3403), TEST_BINDER(case3404), TEST_BINDER(case3405), + TEST_BINDER(case3406), TEST_BINDER(case3407), TEST_BINDER(case3408), + TEST_BINDER(case3409), TEST_BINDER(case3410), TEST_BINDER(case3411), + TEST_BINDER(case3412), TEST_BINDER(case3413), TEST_BINDER(case3414), + TEST_BINDER(case3415), TEST_BINDER(case3416), TEST_BINDER(case3417), + TEST_BINDER(case3418), TEST_BINDER(case3419), TEST_BINDER(case3420), + TEST_BINDER(case3421), TEST_BINDER(case3422), TEST_BINDER(case3423), + TEST_BINDER(case3424), TEST_BINDER(case3425), TEST_BINDER(case3426), + TEST_BINDER(case3427), TEST_BINDER(case3428), TEST_BINDER(case3429), + TEST_BINDER(case3430), TEST_BINDER(case3431), TEST_BINDER(case3432), + TEST_BINDER(case3433), TEST_BINDER(case3434), TEST_BINDER(case3435), + TEST_BINDER(case3436), TEST_BINDER(case3437), TEST_BINDER(case3438), + TEST_BINDER(case3439), TEST_BINDER(case3440), TEST_BINDER(case3441), + TEST_BINDER(case3442), TEST_BINDER(case3443), TEST_BINDER(case3444), + TEST_BINDER(case3445), TEST_BINDER(case3446), TEST_BINDER(case3447), + TEST_BINDER(case3448), TEST_BINDER(case3449), TEST_BINDER(case3450), + TEST_BINDER(case3451), TEST_BINDER(case3452), TEST_BINDER(case3453), + TEST_BINDER(case3454), TEST_BINDER(case3455), TEST_BINDER(case3456), + TEST_BINDER(case3457), TEST_BINDER(case3458), TEST_BINDER(case3459), + TEST_BINDER(case3460), TEST_BINDER(case3461), TEST_BINDER(case3462), + TEST_BINDER(case3463), TEST_BINDER(case3464), TEST_BINDER(case3465), + TEST_BINDER(case3466), TEST_BINDER(case3467), TEST_BINDER(case3468), + TEST_BINDER(case3469), TEST_BINDER(case3470), TEST_BINDER(case3471), + TEST_BINDER(case3472), TEST_BINDER(case3473), TEST_BINDER(case3474), + TEST_BINDER(case3475), TEST_BINDER(case3476), TEST_BINDER(case3477), + TEST_BINDER(case3478), TEST_BINDER(case3479), TEST_BINDER(case3480), + TEST_BINDER(case3481), TEST_BINDER(case3482), TEST_BINDER(case3483), + TEST_BINDER(case3484), TEST_BINDER(case3485), TEST_BINDER(case3486), + TEST_BINDER(case3487), TEST_BINDER(case3488), TEST_BINDER(case3489), + TEST_BINDER(case3490), TEST_BINDER(case3491), TEST_BINDER(case3492), + TEST_BINDER(case3493), TEST_BINDER(case3494), TEST_BINDER(case3495), + TEST_BINDER(case3496), TEST_BINDER(case3497), TEST_BINDER(case3498), + TEST_BINDER(case3499), - TEST_BINDER(case3500), - TEST_BINDER(case3501), - TEST_BINDER(case3502), - TEST_BINDER(case3503), - TEST_BINDER(case3504), - TEST_BINDER(case3505), - TEST_BINDER(case3506), - TEST_BINDER(case3507), - TEST_BINDER(case3508), - TEST_BINDER(case3509), - TEST_BINDER(case3510), - TEST_BINDER(case3511), - TEST_BINDER(case3512), - TEST_BINDER(case3513), - TEST_BINDER(case3514), - TEST_BINDER(case3515), - TEST_BINDER(case3516), - TEST_BINDER(case3517), - TEST_BINDER(case3518), - TEST_BINDER(case3519), - TEST_BINDER(case3520), - TEST_BINDER(case3521), - TEST_BINDER(case3522), - TEST_BINDER(case3523), - TEST_BINDER(case3524), - TEST_BINDER(case3525), - TEST_BINDER(case3526), - TEST_BINDER(case3527), - TEST_BINDER(case3528), - TEST_BINDER(case3529), - TEST_BINDER(case3530), - TEST_BINDER(case3531), - TEST_BINDER(case3532), - TEST_BINDER(case3533), - TEST_BINDER(case3534), - TEST_BINDER(case3535), - TEST_BINDER(case3536), - TEST_BINDER(case3537), - TEST_BINDER(case3538), - TEST_BINDER(case3539), - TEST_BINDER(case3540), - TEST_BINDER(case3541), - TEST_BINDER(case3542), - TEST_BINDER(case3543), - TEST_BINDER(case3544), - TEST_BINDER(case3545), - TEST_BINDER(case3546), - TEST_BINDER(case3547), - TEST_BINDER(case3548), - TEST_BINDER(case3549), - TEST_BINDER(case3550), - TEST_BINDER(case3551), - TEST_BINDER(case3552), - TEST_BINDER(case3553), - TEST_BINDER(case3554), - TEST_BINDER(case3555), - TEST_BINDER(case3556), - TEST_BINDER(case3557), - TEST_BINDER(case3558), - TEST_BINDER(case3559), - TEST_BINDER(case3560), - TEST_BINDER(case3561), - TEST_BINDER(case3562), - TEST_BINDER(case3563), - TEST_BINDER(case3564), - TEST_BINDER(case3565), - TEST_BINDER(case3566), - TEST_BINDER(case3567), - TEST_BINDER(case3568), - TEST_BINDER(case3569), - TEST_BINDER(case3570), - TEST_BINDER(case3571), - TEST_BINDER(case3572), - TEST_BINDER(case3573), - TEST_BINDER(case3574), - TEST_BINDER(case3575), - TEST_BINDER(case3576), - TEST_BINDER(case3577), - TEST_BINDER(case3578), - TEST_BINDER(case3579), - TEST_BINDER(case3580), - TEST_BINDER(case3581), - TEST_BINDER(case3582), - TEST_BINDER(case3583), - TEST_BINDER(case3584), - TEST_BINDER(case3585), - TEST_BINDER(case3586), - TEST_BINDER(case3587), - TEST_BINDER(case3588), - TEST_BINDER(case3589), - TEST_BINDER(case3590), - TEST_BINDER(case3591), - TEST_BINDER(case3592), - TEST_BINDER(case3593), - TEST_BINDER(case3594), - TEST_BINDER(case3595), - TEST_BINDER(case3596), - TEST_BINDER(case3597), - TEST_BINDER(case3598), - TEST_BINDER(case3599), + TEST_BINDER(case3500), TEST_BINDER(case3501), TEST_BINDER(case3502), + TEST_BINDER(case3503), TEST_BINDER(case3504), TEST_BINDER(case3505), + TEST_BINDER(case3506), TEST_BINDER(case3507), TEST_BINDER(case3508), + TEST_BINDER(case3509), TEST_BINDER(case3510), TEST_BINDER(case3511), + TEST_BINDER(case3512), TEST_BINDER(case3513), TEST_BINDER(case3514), + TEST_BINDER(case3515), TEST_BINDER(case3516), TEST_BINDER(case3517), + TEST_BINDER(case3518), TEST_BINDER(case3519), TEST_BINDER(case3520), + TEST_BINDER(case3521), TEST_BINDER(case3522), TEST_BINDER(case3523), + TEST_BINDER(case3524), TEST_BINDER(case3525), TEST_BINDER(case3526), + TEST_BINDER(case3527), TEST_BINDER(case3528), TEST_BINDER(case3529), + TEST_BINDER(case3530), TEST_BINDER(case3531), TEST_BINDER(case3532), + TEST_BINDER(case3533), TEST_BINDER(case3534), TEST_BINDER(case3535), + TEST_BINDER(case3536), TEST_BINDER(case3537), TEST_BINDER(case3538), + TEST_BINDER(case3539), TEST_BINDER(case3540), TEST_BINDER(case3541), + TEST_BINDER(case3542), TEST_BINDER(case3543), TEST_BINDER(case3544), + TEST_BINDER(case3545), TEST_BINDER(case3546), TEST_BINDER(case3547), + TEST_BINDER(case3548), TEST_BINDER(case3549), TEST_BINDER(case3550), + TEST_BINDER(case3551), TEST_BINDER(case3552), TEST_BINDER(case3553), + TEST_BINDER(case3554), TEST_BINDER(case3555), TEST_BINDER(case3556), + TEST_BINDER(case3557), TEST_BINDER(case3558), TEST_BINDER(case3559), + TEST_BINDER(case3560), TEST_BINDER(case3561), TEST_BINDER(case3562), + TEST_BINDER(case3563), TEST_BINDER(case3564), TEST_BINDER(case3565), + TEST_BINDER(case3566), TEST_BINDER(case3567), TEST_BINDER(case3568), + TEST_BINDER(case3569), TEST_BINDER(case3570), TEST_BINDER(case3571), + TEST_BINDER(case3572), TEST_BINDER(case3573), TEST_BINDER(case3574), + TEST_BINDER(case3575), TEST_BINDER(case3576), TEST_BINDER(case3577), + TEST_BINDER(case3578), TEST_BINDER(case3579), TEST_BINDER(case3580), + TEST_BINDER(case3581), TEST_BINDER(case3582), TEST_BINDER(case3583), + TEST_BINDER(case3584), TEST_BINDER(case3585), TEST_BINDER(case3586), + TEST_BINDER(case3587), TEST_BINDER(case3588), TEST_BINDER(case3589), + TEST_BINDER(case3590), TEST_BINDER(case3591), TEST_BINDER(case3592), + TEST_BINDER(case3593), TEST_BINDER(case3594), TEST_BINDER(case3595), + TEST_BINDER(case3596), TEST_BINDER(case3597), TEST_BINDER(case3598), + TEST_BINDER(case3599), - }; + }; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/tests/BinderTester_0000_0999.cpp b/C/tests/BinderTester_0000_0999.cpp index 7ef34b146..4f675a984 100644 --- a/C/tests/BinderTester_0000_0999.cpp +++ b/C/tests/BinderTester_0000_0999.cpp @@ -22,2508 +22,2956 @@ #include "ParserTester.h" #include "binder/ConstraintsInDeclarators.h" -#include "syntax/SyntaxLexeme_ALL.h" #include "parser/Unparser.h" +#include "syntax/SyntaxLexeme_ALL.h" #include "syntax/SyntaxNodes.h" #include #include #include -#include #include +#include using namespace psy; using namespace C; -void BinderTester::case0001() -{ - bind("void x ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.deriv(TypeKind::Function) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void))); -} - -void BinderTester::case0002() -{ - bind("int x ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0003() -{ - bind("void * x ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0004() -{ - bind("int * x ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0005() -{ - bind("x y ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("y") - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0006() -{ - bind("int * ( x ) ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0007() -{ - bind("int * ( ( x ) ) ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0008() -{ - bind("int * * x ( ) ;", - Expectation() - .binding(DeclSummary().Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0009() -{ - bind("x * y ( ) ;", - Expectation() - .binding(DeclSummary().Function("y") - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0010() -{ -} - -void BinderTester::case0011() -{ -} - -void BinderTester::case0012() -{ -} - -void BinderTester::case0013() -{ -} - -void BinderTester::case0014() -{ -} - -void BinderTester::case0015(){} -void BinderTester::case0016(){} -void BinderTester::case0017(){} -void BinderTester::case0018(){} -void BinderTester::case0019(){} -void BinderTester::case0020(){} -void BinderTester::case0021(){} -void BinderTester::case0022(){} -void BinderTester::case0023(){} -void BinderTester::case0024(){} -void BinderTester::case0025(){} -void BinderTester::case0026(){} - -void BinderTester::case0027(){} -void BinderTester::case0028(){} -void BinderTester::case0029(){} -void BinderTester::case0030(){} -void BinderTester::case0031(){} -void BinderTester::case0032(){} -void BinderTester::case0033(){} -void BinderTester::case0034(){} -void BinderTester::case0035(){} -void BinderTester::case0036(){} -void BinderTester::case0037(){} -void BinderTester::case0038(){} -void BinderTester::case0039(){} -void BinderTester::case0040(){} -void BinderTester::case0041(){} -void BinderTester::case0042(){} -void BinderTester::case0043(){} -void BinderTester::case0044(){} -void BinderTester::case0045(){} -void BinderTester::case0046(){} -void BinderTester::case0047(){} -void BinderTester::case0048(){} -void BinderTester::case0049(){} - -void BinderTester::case0050() -{ - bind("void x ( int y ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case0051() -{ - bind("void x ( int y , double z ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); -} - -void BinderTester::case0052() -{ - bind("void x ( int * y ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0053() -{ - bind("void x ( int * y , double * z) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0054() -{ - bind("void x ( int * * y , double * * z) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0055() -{ - bind("void x ( int * * y , double z) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); -} - -void BinderTester::case0056() -{ - bind("void x ( int y , double * * z) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0057() -{ - bind("void x ( y z , w * * v ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec.Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("v", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("w", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0058() -{ - bind("x y ( z const * w , u * v) ;", - Expectation() - .binding(DeclSummary() - .Function("y", ScopeKind::File) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("u", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("z", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("v", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("u", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0059() -{ - bind("x y ( z * const w , u * v) ;", - Expectation() - .binding(DeclSummary() - .Function("y", ScopeKind::File) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::Const) - .TySpec.Parameter().basis("u", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("z", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer, CVR::Const)) - .binding(DeclSummary() - .Value("v", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("u", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0060() -{ - bind("x * y ( z w) ;", - Expectation() - .binding(DeclSummary() - .Function("y", ScopeKind::File) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("z", NamedTypeKind::Synonym))); -} - -void BinderTester::case0061(){} -void BinderTester::case0062(){} -void BinderTester::case0063(){} -void BinderTester::case0064(){} -void BinderTester::case0065(){} -void BinderTester::case0066(){} -void BinderTester::case0067(){} -void BinderTester::case0068(){} -void BinderTester::case0069(){} -void BinderTester::case0070(){} -void BinderTester::case0071(){} -void BinderTester::case0072(){} -void BinderTester::case0073(){} -void BinderTester::case0074(){} -void BinderTester::case0075(){} -void BinderTester::case0076(){} -void BinderTester::case0077(){} -void BinderTester::case0078(){} -void BinderTester::case0079(){} -void BinderTester::case0080(){} -void BinderTester::case0081(){} -void BinderTester::case0082(){} -void BinderTester::case0083(){} -void BinderTester::case0084(){} -void BinderTester::case0085(){} -void BinderTester::case0086(){} -void BinderTester::case0087(){} -void BinderTester::case0088(){} -void BinderTester::case0089(){} -void BinderTester::case0090(){} -void BinderTester::case0091(){} -void BinderTester::case0092(){} -void BinderTester::case0093(){} -void BinderTester::case0094(){} -void BinderTester::case0095(){} -void BinderTester::case0096(){} -void BinderTester::case0097(){} -void BinderTester::case0098(){} -void BinderTester::case0099(){} -void BinderTester::case0100(){} - -void BinderTester::case0101() -{ - bind("void x ( ) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0102() -{ - bind("int x ( ) { return 1 ; }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0103() -{ - bind("void * x ( ) { return 1 ; }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0104() -{ - bind("int * x ( ) { return 1 ; }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0105() -{ - bind("x y ( ) { return 1 ; }", - Expectation() - .binding(DeclSummary() - .Function("y") - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0106() -{ - bind("int * ( x ) ( ) { return 1 ; }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0107() -{ - bind("int * ( ( x ) ) ( ) { return 1 ; }", - Expectation() - .binding(DeclSummary().Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0108() -{ - bind("int * * x ( ) { return 1 ; }", - Expectation() - .binding(DeclSummary().Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0109() -{ - bind("x * y ( ) { return 1 ; }", - Expectation() - .binding(DeclSummary().Function("y") - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0110() -{ -} - -void BinderTester::case0111() -{ -} - -void BinderTester::case0112() -{ -} - -void BinderTester::case0113() -{ -} - -void BinderTester::case0114() -{ -} - -void BinderTester::case0115(){} -void BinderTester::case0116(){} -void BinderTester::case0117(){} -void BinderTester::case0118(){} -void BinderTester::case0119(){} -void BinderTester::case0120(){} -void BinderTester::case0121(){} -void BinderTester::case0122(){} -void BinderTester::case0123(){} -void BinderTester::case0124(){} -void BinderTester::case0125(){} -void BinderTester::case0126(){} -void BinderTester::case0127(){} -void BinderTester::case0128(){} -void BinderTester::case0129(){} -void BinderTester::case0130(){} -void BinderTester::case0131(){} -void BinderTester::case0132(){} -void BinderTester::case0133(){} -void BinderTester::case0134(){} -void BinderTester::case0135(){} -void BinderTester::case0136(){} -void BinderTester::case0137(){} -void BinderTester::case0138(){} -void BinderTester::case0139(){} -void BinderTester::case0140(){} -void BinderTester::case0141(){} -void BinderTester::case0142(){} -void BinderTester::case0143(){} -void BinderTester::case0144(){} -void BinderTester::case0145(){} -void BinderTester::case0146(){} -void BinderTester::case0147(){} -void BinderTester::case0148(){} -void BinderTester::case0149(){} - -void BinderTester::case0150() -{ - bind("void x ( int y ) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case0151() -{ - bind("void x ( int y , double z ) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); - -} - -void BinderTester::case0152() -{ - bind("void x ( int * y ) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0153() -{ - bind("void x ( int * y , double * z) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0154() -{ - bind("void x ( int * * y , double * * z) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0155() -{ - bind("void x ( int * * y , double z) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); -} - -void BinderTester::case0156() -{ - bind("void x ( int y , double * * z) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0157() -{ - bind("void x ( y z , w * * v ) { }", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec.Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("y", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("v", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("w", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0158() -{ - bind("x y ( z const * w , u * v) { }", - Expectation() - .binding(DeclSummary() - .Function("y", ScopeKind::File) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("u", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("z", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("v", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("u", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0159() -{ - bind("x y ( z * const w , u * v) { }", - Expectation() - .binding(DeclSummary() - .Function("y", ScopeKind::File) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::Const) - .TySpec.Parameter().basis("u", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("z", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer, CVR::Const)) - .binding(DeclSummary() - .Value("v", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("u", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0160() -{ - bind("x * y ( z w) { }", - Expectation() - .binding(DeclSummary() - .Function("y", ScopeKind::File) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::Block) - .TySpec.basis("z", NamedTypeKind::Synonym))); -} - -void BinderTester::case0161(){} -void BinderTester::case0162(){} -void BinderTester::case0163(){} -void BinderTester::case0164(){} -void BinderTester::case0165(){} -void BinderTester::case0166(){} -void BinderTester::case0167(){} -void BinderTester::case0168(){} -void BinderTester::case0169(){} -void BinderTester::case0170(){} -void BinderTester::case0171(){} -void BinderTester::case0172(){} -void BinderTester::case0173(){} -void BinderTester::case0174(){} -void BinderTester::case0175(){} -void BinderTester::case0176(){} -void BinderTester::case0177(){} -void BinderTester::case0178(){} -void BinderTester::case0179(){} -void BinderTester::case0180(){} -void BinderTester::case0181(){} -void BinderTester::case0182(){} -void BinderTester::case0183(){} -void BinderTester::case0184(){} -void BinderTester::case0185(){} -void BinderTester::case0186(){} -void BinderTester::case0187(){} -void BinderTester::case0188(){} -void BinderTester::case0189(){} -void BinderTester::case0190(){} -void BinderTester::case0191(){} -void BinderTester::case0192(){} -void BinderTester::case0193(){} -void BinderTester::case0194(){} -void BinderTester::case0195(){} -void BinderTester::case0196(){} -void BinderTester::case0197(){} -void BinderTester::case0198(){} -void BinderTester::case0199(){} - -void BinderTester::case0200() -{ - bind("void x ( int ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case0201() -{ - bind("void x ( y ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym))); -} - -void BinderTester::case0202() -{ - bind("void x ( int , y ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym))); -} - -void BinderTester::case0203() -{ - bind("void x ( y , int ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym))); +void BinderTester::case0001() { + bind("void x ( ) ;", + Expectation().binding(DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.deriv(TypeKind::Function) + .TySpec.basis("void", NamedTypeKind::Builtin, + BuiltinTypeKind::Void))); +} + +void BinderTester::case0002() { + bind( + "int x ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0003() { + bind("void * x ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0004() { + bind( + "int * x ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0005() { + bind("x y ( ) ;", + Expectation().binding(DeclSummary() + .Function("y") + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0006() { + bind( + "int * ( x ) ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0007() { + bind( + "int * ( ( x ) ) ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0008() { + bind( + "int * * x ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0009() { + bind("x * y ( ) ;", + Expectation().binding(DeclSummary() + .Function("y") + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0010() {} + +void BinderTester::case0011() {} + +void BinderTester::case0012() {} + +void BinderTester::case0013() {} + +void BinderTester::case0014() {} + +void BinderTester::case0015() {} +void BinderTester::case0016() {} +void BinderTester::case0017() {} +void BinderTester::case0018() {} +void BinderTester::case0019() {} +void BinderTester::case0020() {} +void BinderTester::case0021() {} +void BinderTester::case0022() {} +void BinderTester::case0023() {} +void BinderTester::case0024() {} +void BinderTester::case0025() {} +void BinderTester::case0026() {} + +void BinderTester::case0027() {} +void BinderTester::case0028() {} +void BinderTester::case0029() {} +void BinderTester::case0030() {} +void BinderTester::case0031() {} +void BinderTester::case0032() {} +void BinderTester::case0033() {} +void BinderTester::case0034() {} +void BinderTester::case0035() {} +void BinderTester::case0036() {} +void BinderTester::case0037() {} +void BinderTester::case0038() {} +void BinderTester::case0039() {} +void BinderTester::case0040() {} +void BinderTester::case0041() {} +void BinderTester::case0042() {} +void BinderTester::case0043() {} +void BinderTester::case0044() {} +void BinderTester::case0045() {} +void BinderTester::case0046() {} +void BinderTester::case0047() {} +void BinderTester::case0048() {} +void BinderTester::case0049() {} + +void BinderTester::case0050() { + bind("void x ( int y ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case0051() { + bind("void x ( int y , double z ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double)) + .binding(DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case0052() { + bind("void x ( int * y ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0204() -{ - bind("void x ( y , z ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("z", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym))); - +void BinderTester::case0053() { + bind("void x ( int * y , double * z) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0054() { + bind("void x ( int * * y , double * * z) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0055() { + bind("void x ( int * * y , double z) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case0056() { + bind("void x ( int y , double * * z) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0057() { + bind("void x ( y z , w * * v ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec.Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("v", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("w", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0058() { + bind("x y ( z const * w , u * v) ;", + Expectation() + .binding(DeclSummary() + .Function("y", ScopeKind::File) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::Const) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("u", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("z", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::Const) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("v", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("u", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0059() { + bind("x y ( z * const w , u * v) ;", + Expectation() + .binding(DeclSummary() + .Function("y", ScopeKind::File) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::Const) + .TySpec.Parameter() + .basis("u", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("z", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer, CVR::Const)) + .binding(DeclSummary() + .Value("v", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("u", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0060() { + bind("x * y ( z w) ;", + Expectation() + .binding(DeclSummary() + .Function("y", ScopeKind::File) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("z", NamedTypeKind::Synonym))); +} + +void BinderTester::case0061() {} +void BinderTester::case0062() {} +void BinderTester::case0063() {} +void BinderTester::case0064() {} +void BinderTester::case0065() {} +void BinderTester::case0066() {} +void BinderTester::case0067() {} +void BinderTester::case0068() {} +void BinderTester::case0069() {} +void BinderTester::case0070() {} +void BinderTester::case0071() {} +void BinderTester::case0072() {} +void BinderTester::case0073() {} +void BinderTester::case0074() {} +void BinderTester::case0075() {} +void BinderTester::case0076() {} +void BinderTester::case0077() {} +void BinderTester::case0078() {} +void BinderTester::case0079() {} +void BinderTester::case0080() {} +void BinderTester::case0081() {} +void BinderTester::case0082() {} +void BinderTester::case0083() {} +void BinderTester::case0084() {} +void BinderTester::case0085() {} +void BinderTester::case0086() {} +void BinderTester::case0087() {} +void BinderTester::case0088() {} +void BinderTester::case0089() {} +void BinderTester::case0090() {} +void BinderTester::case0091() {} +void BinderTester::case0092() {} +void BinderTester::case0093() {} +void BinderTester::case0094() {} +void BinderTester::case0095() {} +void BinderTester::case0096() {} +void BinderTester::case0097() {} +void BinderTester::case0098() {} +void BinderTester::case0099() {} +void BinderTester::case0100() {} + +void BinderTester::case0101() { + bind("void x ( ) { }", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0102() { + bind( + "int x ( ) { return 1 ; }", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0103() { + bind("void * x ( ) { return 1 ; }", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0104() { + bind( + "int * x ( ) { return 1 ; }", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0105() { + bind("x y ( ) { return 1 ; }", + Expectation().binding(DeclSummary() + .Function("y") + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0106() { + bind( + "int * ( x ) ( ) { return 1 ; }", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0107() { + bind( + "int * ( ( x ) ) ( ) { return 1 ; }", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0108() { + bind( + "int * * x ( ) { return 1 ; }", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0109() { + bind("x * y ( ) { return 1 ; }", + Expectation().binding(DeclSummary() + .Function("y") + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0110() {} + +void BinderTester::case0111() {} + +void BinderTester::case0112() {} + +void BinderTester::case0113() {} + +void BinderTester::case0114() {} + +void BinderTester::case0115() {} +void BinderTester::case0116() {} +void BinderTester::case0117() {} +void BinderTester::case0118() {} +void BinderTester::case0119() {} +void BinderTester::case0120() {} +void BinderTester::case0121() {} +void BinderTester::case0122() {} +void BinderTester::case0123() {} +void BinderTester::case0124() {} +void BinderTester::case0125() {} +void BinderTester::case0126() {} +void BinderTester::case0127() {} +void BinderTester::case0128() {} +void BinderTester::case0129() {} +void BinderTester::case0130() {} +void BinderTester::case0131() {} +void BinderTester::case0132() {} +void BinderTester::case0133() {} +void BinderTester::case0134() {} +void BinderTester::case0135() {} +void BinderTester::case0136() {} +void BinderTester::case0137() {} +void BinderTester::case0138() {} +void BinderTester::case0139() {} +void BinderTester::case0140() {} +void BinderTester::case0141() {} +void BinderTester::case0142() {} +void BinderTester::case0143() {} +void BinderTester::case0144() {} +void BinderTester::case0145() {} +void BinderTester::case0146() {} +void BinderTester::case0147() {} +void BinderTester::case0148() {} +void BinderTester::case0149() {} + +void BinderTester::case0150() { + bind("void x ( int y ) { }", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("y", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case0151() { + bind("void x ( int y , double z ) { }", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double)) + .binding(DeclSummary() + .Value("y", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case0152() { + bind("void x ( int * y ) { }", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, ScopeKind::Block) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0205() -{ - bind("void x ( int * ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() +void BinderTester::case0153() { + bind("void x ( int * y , double * z) { }", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, ScopeKind::Block) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, ScopeKind::Block) + .TySpec + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0154() { + bind("void x ( int * * y , double * * z) { }", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, ScopeKind::Block) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, ScopeKind::Block) + .TySpec + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0155() { + bind("void x ( int * * y , double z) { }", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, ScopeKind::Block) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case0156() { + bind("void x ( int y , double * * z) { }", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("y", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, ScopeKind::Block) + .TySpec + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0157() { + bind("void x ( y z , w * * v ) { }", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec.Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("y", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("v", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("w", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0158() { + bind("x y ( z const * w , u * v) { }", + Expectation() + .binding(DeclSummary() + .Function("y", ScopeKind::File) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::Const) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("u", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, ScopeKind::Block) + .TySpec + .basis("z", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::Const) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("v", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("u", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0159() { + bind("x y ( z * const w , u * v) { }", + Expectation() + .binding(DeclSummary() + .Function("y", ScopeKind::File) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::Const) + .TySpec.Parameter() + .basis("u", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("z", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer, CVR::Const)) + .binding(DeclSummary() + .Value("v", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("u", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0160() { + bind("x * y ( z w) { }", + Expectation() + .binding(DeclSummary() + .Function("y", ScopeKind::File) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, ScopeKind::Block) + .TySpec.basis("z", NamedTypeKind::Synonym))); +} + +void BinderTester::case0161() {} +void BinderTester::case0162() {} +void BinderTester::case0163() {} +void BinderTester::case0164() {} +void BinderTester::case0165() {} +void BinderTester::case0166() {} +void BinderTester::case0167() {} +void BinderTester::case0168() {} +void BinderTester::case0169() {} +void BinderTester::case0170() {} +void BinderTester::case0171() {} +void BinderTester::case0172() {} +void BinderTester::case0173() {} +void BinderTester::case0174() {} +void BinderTester::case0175() {} +void BinderTester::case0176() {} +void BinderTester::case0177() {} +void BinderTester::case0178() {} +void BinderTester::case0179() {} +void BinderTester::case0180() {} +void BinderTester::case0181() {} +void BinderTester::case0182() {} +void BinderTester::case0183() {} +void BinderTester::case0184() {} +void BinderTester::case0185() {} +void BinderTester::case0186() {} +void BinderTester::case0187() {} +void BinderTester::case0188() {} +void BinderTester::case0189() {} +void BinderTester::case0190() {} +void BinderTester::case0191() {} +void BinderTester::case0192() {} +void BinderTester::case0193() {} +void BinderTester::case0194() {} +void BinderTester::case0195() {} +void BinderTester::case0196() {} +void BinderTester::case0197() {} +void BinderTester::case0198() {} +void BinderTester::case0199() {} + +void BinderTester::case0200() { + bind("void x ( int ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case0201() { + bind("void x ( y ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym))); +} + +void BinderTester::case0202() { + bind("void x ( int , y ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym))); +} + +void BinderTester::case0203() { + bind("void x ( y , int ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym))); +} + +void BinderTester::case0204() { + bind("void x ( y , z ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("z", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym))); +} + +void BinderTester::case0205() { + bind( + "void x ( int * ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0206() -{ - bind("void x ( int [ ] ) ;", - Expectation() - .binding(DeclSummary() +void BinderTester::case0206() { + bind( + "void x ( int [ ] ) ;", + Expectation() + .binding( + DeclSummary() .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding( + DeclSummary() .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0207() -{ - bind("void x ( int [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); +} + +void BinderTester::case0207() { + bind( + "void x ( int [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding( + DeclSummary() .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0208(){} -void BinderTester::case0209(){} -void BinderTester::case0210(){} -void BinderTester::case0211(){} -void BinderTester::case0212(){} -void BinderTester::case0213(){} -void BinderTester::case0214(){} -void BinderTester::case0215(){} -void BinderTester::case0216(){} -void BinderTester::case0217(){} -void BinderTester::case0218(){} -void BinderTester::case0219(){} -void BinderTester::case0220(){} -void BinderTester::case0221(){} -void BinderTester::case0222(){} -void BinderTester::case0223(){} -void BinderTester::case0224(){} -void BinderTester::case0225(){} -void BinderTester::case0226(){} -void BinderTester::case0227(){} -void BinderTester::case0228(){} -void BinderTester::case0229(){} -void BinderTester::case0230(){} -void BinderTester::case0231(){} -void BinderTester::case0232(){} -void BinderTester::case0233(){} -void BinderTester::case0234(){} -void BinderTester::case0235(){} -void BinderTester::case0236(){} -void BinderTester::case0237(){} -void BinderTester::case0238(){} -void BinderTester::case0239(){} -void BinderTester::case0240(){} - -void BinderTester::case0241(){} -void BinderTester::case0242(){} -void BinderTester::case0243(){} -void BinderTester::case0244(){} -void BinderTester::case0245(){} -void BinderTester::case0246(){} -void BinderTester::case0247(){} -void BinderTester::case0248(){} -void BinderTester::case0249(){} -void BinderTester::case0250(){} -void BinderTester::case0251(){} -void BinderTester::case0252(){} -void BinderTester::case0253(){} -void BinderTester::case0254(){} -void BinderTester::case0255(){} -void BinderTester::case0256(){} -void BinderTester::case0257(){} -void BinderTester::case0258(){} -void BinderTester::case0259(){} -void BinderTester::case0260(){} -void BinderTester::case0261(){} -void BinderTester::case0262(){} -void BinderTester::case0263(){} -void BinderTester::case0264(){} -void BinderTester::case0265(){} -void BinderTester::case0266(){} -void BinderTester::case0267(){} -void BinderTester::case0268(){} -void BinderTester::case0269(){} -void BinderTester::case0270(){} -void BinderTester::case0271(){} -void BinderTester::case0272(){} -void BinderTester::case0273(){} -void BinderTester::case0274(){} -void BinderTester::case0275(){} -void BinderTester::case0276(){} -void BinderTester::case0277(){} -void BinderTester::case0278(){} -void BinderTester::case0279(){} -void BinderTester::case0280(){} -void BinderTester::case0281(){} -void BinderTester::case0282(){} -void BinderTester::case0283(){} -void BinderTester::case0284(){} -void BinderTester::case0285(){} -void BinderTester::case0286(){} -void BinderTester::case0287(){} -void BinderTester::case0288(){} -void BinderTester::case0289(){} -void BinderTester::case0290(){} -void BinderTester::case0291(){} -void BinderTester::case0292(){} -void BinderTester::case0293(){} -void BinderTester::case0294(){} -void BinderTester::case0295(){} -void BinderTester::case0296(){} -void BinderTester::case0297(){} -void BinderTester::case0298(){} -void BinderTester::case0299(){} - -void BinderTester::case0300() -{ - bind("void x ( int ( * y ) ( double ) ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0301() -{ - bind("void x ( int ( * y ) ( double ) , char ( * z ) ( float ) ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("float", NamedTypeKind::Builtin, BuiltinTypeKind::Float) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("float", NamedTypeKind::Builtin, BuiltinTypeKind::Float) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0302() -{ - bind("void x ( int * ( * y ) ( double ) ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0303() -{ - bind("void x ( int ( * * y ) ( double ) ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0304() -{ - bind("void x ( y ( * z ) ( w ) ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0305() -{ - bind("void x ( y * * ( * z ) ( w ) ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0306() -{ - bind("void x ( y * * ( * z ) ( double ) , int * u ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("u", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0307() -{ - bind("void x ( int ( * y ) ( z ) , int * w ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); +} + +void BinderTester::case0208() {} +void BinderTester::case0209() {} +void BinderTester::case0210() {} +void BinderTester::case0211() {} +void BinderTester::case0212() {} +void BinderTester::case0213() {} +void BinderTester::case0214() {} +void BinderTester::case0215() {} +void BinderTester::case0216() {} +void BinderTester::case0217() {} +void BinderTester::case0218() {} +void BinderTester::case0219() {} +void BinderTester::case0220() {} +void BinderTester::case0221() {} +void BinderTester::case0222() {} +void BinderTester::case0223() {} +void BinderTester::case0224() {} +void BinderTester::case0225() {} +void BinderTester::case0226() {} +void BinderTester::case0227() {} +void BinderTester::case0228() {} +void BinderTester::case0229() {} +void BinderTester::case0230() {} +void BinderTester::case0231() {} +void BinderTester::case0232() {} +void BinderTester::case0233() {} +void BinderTester::case0234() {} +void BinderTester::case0235() {} +void BinderTester::case0236() {} +void BinderTester::case0237() {} +void BinderTester::case0238() {} +void BinderTester::case0239() {} +void BinderTester::case0240() {} + +void BinderTester::case0241() {} +void BinderTester::case0242() {} +void BinderTester::case0243() {} +void BinderTester::case0244() {} +void BinderTester::case0245() {} +void BinderTester::case0246() {} +void BinderTester::case0247() {} +void BinderTester::case0248() {} +void BinderTester::case0249() {} +void BinderTester::case0250() {} +void BinderTester::case0251() {} +void BinderTester::case0252() {} +void BinderTester::case0253() {} +void BinderTester::case0254() {} +void BinderTester::case0255() {} +void BinderTester::case0256() {} +void BinderTester::case0257() {} +void BinderTester::case0258() {} +void BinderTester::case0259() {} +void BinderTester::case0260() {} +void BinderTester::case0261() {} +void BinderTester::case0262() {} +void BinderTester::case0263() {} +void BinderTester::case0264() {} +void BinderTester::case0265() {} +void BinderTester::case0266() {} +void BinderTester::case0267() {} +void BinderTester::case0268() {} +void BinderTester::case0269() {} +void BinderTester::case0270() {} +void BinderTester::case0271() {} +void BinderTester::case0272() {} +void BinderTester::case0273() {} +void BinderTester::case0274() {} +void BinderTester::case0275() {} +void BinderTester::case0276() {} +void BinderTester::case0277() {} +void BinderTester::case0278() {} +void BinderTester::case0279() {} +void BinderTester::case0280() {} +void BinderTester::case0281() {} +void BinderTester::case0282() {} +void BinderTester::case0283() {} +void BinderTester::case0284() {} +void BinderTester::case0285() {} +void BinderTester::case0286() {} +void BinderTester::case0287() {} +void BinderTester::case0288() {} +void BinderTester::case0289() {} +void BinderTester::case0290() {} +void BinderTester::case0291() {} +void BinderTester::case0292() {} +void BinderTester::case0293() {} +void BinderTester::case0294() {} +void BinderTester::case0295() {} +void BinderTester::case0296() {} +void BinderTester::case0297() {} +void BinderTester::case0298() {} +void BinderTester::case0299() {} + +void BinderTester::case0300() { + bind("void x ( int ( * y ) ( double ) ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0308() -{ - bind("void x ( int * y , int ( * z ) ( w ) ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0301() { + bind("void x ( int ( * y ) ( double ) , char ( * z ) ( float ) ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("float", NamedTypeKind::Builtin, + BuiltinTypeKind::Float) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("float", NamedTypeKind::Builtin, + BuiltinTypeKind::Float) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0309() -{ - bind("void x ( int ( * y ) ( z * ) , int * w ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec._AtParam_()._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0302() { + bind("void x ( int * ( * y ) ( double ) ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0310(){} -void BinderTester::case0311(){} -void BinderTester::case0312(){} -void BinderTester::case0313(){} -void BinderTester::case0314(){} -void BinderTester::case0315(){} -void BinderTester::case0316(){} -void BinderTester::case0317(){} -void BinderTester::case0318(){} -void BinderTester::case0319(){} -void BinderTester::case0320(){} -void BinderTester::case0321(){} -void BinderTester::case0322(){} -void BinderTester::case0323(){} -void BinderTester::case0324(){} -void BinderTester::case0325(){} -void BinderTester::case0326(){} -void BinderTester::case0327(){} -void BinderTester::case0328(){} -void BinderTester::case0329(){} -void BinderTester::case0330(){} -void BinderTester::case0331(){} -void BinderTester::case0332(){} -void BinderTester::case0333(){} -void BinderTester::case0334(){} - -void BinderTester::case0335() -{ - bind("void x ( int y ( double ) ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromFunctionToFunctionPointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromFunctionToFunctionPointer))); -} - -void BinderTester::case0336(){} -void BinderTester::case0337(){} -void BinderTester::case0338(){} -void BinderTester::case0339(){} -void BinderTester::case0340(){} -void BinderTester::case0341(){} -void BinderTester::case0342(){} -void BinderTester::case0343(){} -void BinderTester::case0344(){} -void BinderTester::case0345(){} -void BinderTester::case0346(){} -void BinderTester::case0347(){} -void BinderTester::case0348(){} -void BinderTester::case0349(){} - -void BinderTester::case0350() -{ - bind("void x ( int ( * y ) [ ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0303() { + bind("void x ( int ( * * y ) ( double ) ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0351() -{ - bind("void x ( int ( * y ) [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0304() { + bind("void x ( y ( * z ) ( w ) ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0305() { + bind("void x ( y * * ( * z ) ( w ) ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0306() { + bind("void x ( y * * ( * z ) ( double ) , int * u ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("u", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0352() -{ - bind("void x ( int * ( * y ) [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0307() { + bind("void x ( int ( * y ) ( z ) , int * w ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0353() -{ - bind("void x ( y ( * z ) [ ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0308() { + bind("void x ( int * y , int ( * z ) ( w ) ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0354() -{ - bind("void x ( y * ( * z ) [ ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0309() { + bind("void x ( int ( * y ) ( z * ) , int * w ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec._AtParam_() + ._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0355() -{ - bind("void x ( int w , y * ( * z ) [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0310() {} +void BinderTester::case0311() {} +void BinderTester::case0312() {} +void BinderTester::case0313() {} +void BinderTester::case0314() {} +void BinderTester::case0315() {} +void BinderTester::case0316() {} +void BinderTester::case0317() {} +void BinderTester::case0318() {} +void BinderTester::case0319() {} +void BinderTester::case0320() {} +void BinderTester::case0321() {} +void BinderTester::case0322() {} +void BinderTester::case0323() {} +void BinderTester::case0324() {} +void BinderTester::case0325() {} +void BinderTester::case0326() {} +void BinderTester::case0327() {} +void BinderTester::case0328() {} +void BinderTester::case0329() {} +void BinderTester::case0330() {} +void BinderTester::case0331() {} +void BinderTester::case0332() {} +void BinderTester::case0333() {} +void BinderTester::case0334() {} + +void BinderTester::case0335() { + bind("void x ( int y ( double ) ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromFunctionToFunctionPointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromFunctionToFunctionPointer))); +} + +void BinderTester::case0336() {} +void BinderTester::case0337() {} +void BinderTester::case0338() {} +void BinderTester::case0339() {} +void BinderTester::case0340() {} +void BinderTester::case0341() {} +void BinderTester::case0342() {} +void BinderTester::case0343() {} +void BinderTester::case0344() {} +void BinderTester::case0345() {} +void BinderTester::case0346() {} +void BinderTester::case0347() {} +void BinderTester::case0348() {} +void BinderTester::case0349() {} + +void BinderTester::case0350() { + bind("void x ( int ( * y ) [ ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0356() -{ - bind("void x ( y * ( * z ) [ 1 ] , int w ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case0351() { + bind("void x ( int ( * y ) [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0357() -{ - bind("void x ( v w , y * ( * z ) [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() +void BinderTester::case0352() { + bind("void x ( int * ( * y ) [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("v", NamedTypeKind::Synonym) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("v", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) .TySpec.deriv(TypeKind::Pointer) .TySpec.deriv(TypeKind::Array) .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case0358() -{ - bind("void x ( y * ( * z ) [ 1 ] , v w ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Array) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("v", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("w", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("v", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case0359(){} -void BinderTester::case0360(){} -void BinderTester::case0361(){} -void BinderTester::case0362(){} -void BinderTester::case0363(){} -void BinderTester::case0364(){} -void BinderTester::case0365(){} -void BinderTester::case0366(){} -void BinderTester::case0367(){} -void BinderTester::case0368(){} -void BinderTester::case0369(){} -void BinderTester::case0370(){} -void BinderTester::case0371(){} -void BinderTester::case0372(){} -void BinderTester::case0373(){} -void BinderTester::case0374(){} -void BinderTester::case0375(){} -void BinderTester::case0376(){} -void BinderTester::case0377(){} -void BinderTester::case0378(){} -void BinderTester::case0379(){} -void BinderTester::case0380(){} -void BinderTester::case0381(){} -void BinderTester::case0382(){} -void BinderTester::case0383(){} -void BinderTester::case0384(){} - -void BinderTester::case0385() -{ - bind("void x ( int y [ ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0386() -{ - bind("void x ( y z [ ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0387() -{ - bind("void x ( int * y [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0388() -{ - bind("void x ( y * z [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0389() -{ - bind("void x ( int * * y [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() - .Value("y", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0390() -{ - bind("void x ( y const * z [ 1 ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0391() -{ - bind("void x ( y z [ ] , w z ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer) - .TySpec.Parameter().basis("w", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("w", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0392() -{ - bind("void x ( w z , y z [ ] ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("w", NamedTypeKind::Synonym) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("w", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("z", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer, CVR::None, Decay::FromArrayToPointer))); -} - -void BinderTester::case0393(){} -void BinderTester::case0394(){} -void BinderTester::case0395(){} -void BinderTester::case0396(){} -void BinderTester::case0397(){} -void BinderTester::case0398(){} -void BinderTester::case0399(){} - -void BinderTester::case0400() -{ - bind("void ( * x ( ) ) ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0401() -{ - bind("void ( * x ( ) ) ( int ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0402() -{ - bind("void ( * x ( int ) ) ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case0403() -{ - bind("void ( * x ( double ) ) ( int ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); -} - -void BinderTester::case0404() -{ - bind("void * ( * x ( double ) ) ( int ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); -} - -void BinderTester::case0405() -{ - bind("void * ( * x ( double , char ) ) ( int , long ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.Parameter().basis("long", NamedTypeKind::Builtin, BuiltinTypeKind::Long) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.Parameter().basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char))); -} - -void BinderTester::case0406() -{ - bind("void * ( * x ( double * , char ) ) ( void * ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.Parameter().basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char))); -} - -void BinderTester::case0407() -{ - bind("void ( * x ( ) ) ( y ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0408() -{ - bind("void ( * x ( y ) ) ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym))); -} - -void BinderTester::case0409() -{ - bind("void ( * x ( y ) ) ( z ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym))); +void BinderTester::case0353() { + bind("void x ( y ( * z ) [ ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0354() { + bind("void x ( y * ( * z ) [ ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0355() { + bind("void x ( int w , y * ( * z ) [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0356() { + bind("void x ( y * ( * z ) [ 1 ] , int w ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0357() { + bind("void x ( v w , y * ( * z ) [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("v", NamedTypeKind::Synonym) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("v", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0358() { + bind("void x ( y * ( * z ) [ 1 ] , v w ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Array) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("v", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("w", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("v", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case0359() {} +void BinderTester::case0360() {} +void BinderTester::case0361() {} +void BinderTester::case0362() {} +void BinderTester::case0363() {} +void BinderTester::case0364() {} +void BinderTester::case0365() {} +void BinderTester::case0366() {} +void BinderTester::case0367() {} +void BinderTester::case0368() {} +void BinderTester::case0369() {} +void BinderTester::case0370() {} +void BinderTester::case0371() {} +void BinderTester::case0372() {} +void BinderTester::case0373() {} +void BinderTester::case0374() {} +void BinderTester::case0375() {} +void BinderTester::case0376() {} +void BinderTester::case0377() {} +void BinderTester::case0378() {} +void BinderTester::case0379() {} +void BinderTester::case0380() {} +void BinderTester::case0381() {} +void BinderTester::case0382() {} +void BinderTester::case0383() {} +void BinderTester::case0384() {} + +void BinderTester::case0385() { + bind("void x ( int y [ ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); +} + +void BinderTester::case0386() { + bind("void x ( y z [ ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); +} + +void BinderTester::case0387() { + bind("void x ( int * y [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); } -void BinderTester::case0410() -{ - bind("void ( * x ( y * ) ) ( z ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("z", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec._AtParam_().deriv(TypeKind::Pointer))); +void BinderTester::case0388() { + bind("void x ( y * z [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); +} + +void BinderTester::case0389() { + bind("void x ( int * * y [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); } -void BinderTester::case0411() -{ - // The `signal' function: http://c-faq.com/decl/spiral.anderson.html +void BinderTester::case0390() { + bind("void x ( y const * z [ 1 ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::Const) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec + .basis("y", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::Const) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); +} + +void BinderTester::case0391() { + bind("void x ( y z [ ] , w z ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer) + .TySpec.Parameter() + .basis("w", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("w", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); +} + +void BinderTester::case0392() { + bind("void x ( w z , y z [ ] ) ;", + Expectation() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("w", NamedTypeKind::Synonym) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("w", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("z", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer, CVR::None, + Decay::FromArrayToPointer))); +} + +void BinderTester::case0393() {} +void BinderTester::case0394() {} +void BinderTester::case0395() {} +void BinderTester::case0396() {} +void BinderTester::case0397() {} +void BinderTester::case0398() {} +void BinderTester::case0399() {} + +void BinderTester::case0400() { + bind("void ( * x ( ) ) ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0401() { + bind("void ( * x ( ) ) ( int ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0402() { + bind("void ( * x ( int ) ) ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); +} + +void BinderTester::case0403() { + bind("void ( * x ( double ) ) ( int ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case0404() { + bind("void * ( * x ( double ) ) ( int ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case0405() { + bind("void * ( * x ( double , char ) ) ( int , long ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.Parameter() + .basis("long", NamedTypeKind::Builtin, BuiltinTypeKind::Long) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) + .TySpec.Parameter() + .basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char))); +} + +void BinderTester::case0406() { + bind("void * ( * x ( double * , char ) ) ( void * ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.Parameter() + .basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char))); +} + +void BinderTester::case0407() { + bind("void ( * x ( ) ) ( y ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0408() { + bind("void ( * x ( y ) ) ( ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym))); +} + +void BinderTester::case0409() { + bind("void ( * x ( y ) ) ( z ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym))); +} + +void BinderTester::case0410() { + bind("void ( * x ( y * ) ) ( z ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("z", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer))); +} + +void BinderTester::case0411() { + // The `signal' function: http://c-faq.com/decl/spiral.anderson.html + + bind(" void ( * x ( int , void ( * y ) ( int ) ) ) ( int ) ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.Parameter() + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer))); +} + +void BinderTester::case0412() { + bind("x ( * y ( ) ) ( ) ;", + Expectation().binding(DeclSummary() + .Function("y", ScopeKind::File) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} +void BinderTester::case0413() { + bind("void x ( ) ( ) ;", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Error, + ConstraintsInDeclarators::ID_FunctionReturningFunction) + .ContinueTestDespiteOfErrors() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0414() { + bind("void ( x ( ) ) ( ) ;", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Error, + ConstraintsInDeclarators::ID_FunctionReturningFunction) + .ContinueTestDespiteOfErrors() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} +void BinderTester::case0415() {} +void BinderTester::case0416() {} +void BinderTester::case0417() {} +void BinderTester::case0418() {} +void BinderTester::case0419() {} +void BinderTester::case0420() {} +void BinderTester::case0421() {} +void BinderTester::case0422() {} +void BinderTester::case0423() {} +void BinderTester::case0424() {} + +void BinderTester::case0425() { + bind( + "int ( * x ( ) ) [] ;", + Expectation().binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0426() { + bind("x ( * y ( ) ) [] ;", + Expectation().binding(DeclSummary() + .Function("y", ScopeKind::File) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0427() { + bind("int x ( ) [] ;", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Error, + ConstraintsInDeclarators::ID_FunctionReturningArray) + .ContinueTestDespiteOfErrors() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Array) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0428() { + bind("int ( x ) ( ) [] ;", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Error, + ConstraintsInDeclarators::ID_FunctionReturningArray) + .ContinueTestDespiteOfErrors() + .binding( + DeclSummary() + .Function("x", ScopeKind::File) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Array) + .TySpec.NestAsReturn() + .TySpec.deriv(TypeKind::Function))); +} + +void BinderTester::case0429() {} +void BinderTester::case0430() {} +void BinderTester::case0431() {} +void BinderTester::case0432() {} +void BinderTester::case0433() {} +void BinderTester::case0434() {} +void BinderTester::case0435() {} +void BinderTester::case0436() {} +void BinderTester::case0437() {} +void BinderTester::case0438() {} +void BinderTester::case0439() {} +void BinderTester::case0440() {} + +void BinderTester::case0441() {} +void BinderTester::case0442() {} +void BinderTester::case0443() {} +void BinderTester::case0444() {} +void BinderTester::case0445() {} +void BinderTester::case0446() {} +void BinderTester::case0447() {} +void BinderTester::case0448() {} +void BinderTester::case0449() {} + +void BinderTester::case0450() {} + +void BinderTester::case0451() {} + +void BinderTester::case0452() {} +void BinderTester::case0453() {} +void BinderTester::case0454() {} +void BinderTester::case0455() {} +void BinderTester::case0456() {} +void BinderTester::case0457() {} +void BinderTester::case0458() {} +void BinderTester::case0459() {} +void BinderTester::case0460() {} +void BinderTester::case0461() {} +void BinderTester::case0462() {} +void BinderTester::case0463() {} +void BinderTester::case0464() {} +void BinderTester::case0465() {} +void BinderTester::case0466() {} +void BinderTester::case0467() {} +void BinderTester::case0468() {} +void BinderTester::case0469() {} +void BinderTester::case0470() {} +void BinderTester::case0471() {} +void BinderTester::case0472() {} +void BinderTester::case0473() {} +void BinderTester::case0474() {} +void BinderTester::case0475() {} +void BinderTester::case0476() {} +void BinderTester::case0477() {} +void BinderTester::case0478() {} +void BinderTester::case0479() {} +void BinderTester::case0480() {} +void BinderTester::case0481() {} +void BinderTester::case0482() {} +void BinderTester::case0483() {} +void BinderTester::case0484() {} +void BinderTester::case0485() {} +void BinderTester::case0486() {} +void BinderTester::case0487() {} +void BinderTester::case0488() {} +void BinderTester::case0489() {} +void BinderTester::case0490() {} +void BinderTester::case0491() {} +void BinderTester::case0492() {} +void BinderTester::case0493() {} +void BinderTester::case0494() {} +void BinderTester::case0495() {} +void BinderTester::case0496() {} +void BinderTester::case0497() {} +void BinderTester::case0498() {} +void BinderTester::case0499() {} + +void BinderTester::case0500() {} +void BinderTester::case0501() {} +void BinderTester::case0502() {} +void BinderTester::case0503() {} +void BinderTester::case0504() {} +void BinderTester::case0505() {} +void BinderTester::case0506() {} +void BinderTester::case0507() {} +void BinderTester::case0508() {} +void BinderTester::case0509() {} +void BinderTester::case0510() {} +void BinderTester::case0511() {} +void BinderTester::case0512() {} +void BinderTester::case0513() {} +void BinderTester::case0514() {} +void BinderTester::case0515() {} +void BinderTester::case0516() {} +void BinderTester::case0517() {} +void BinderTester::case0518() {} +void BinderTester::case0519() {} +void BinderTester::case0520() {} +void BinderTester::case0521() {} +void BinderTester::case0522() {} +void BinderTester::case0523() {} +void BinderTester::case0524() {} +void BinderTester::case0525() {} +void BinderTester::case0526() {} +void BinderTester::case0527() {} +void BinderTester::case0528() {} +void BinderTester::case0529() {} +void BinderTester::case0530() {} +void BinderTester::case0531() {} +void BinderTester::case0532() {} +void BinderTester::case0533() {} +void BinderTester::case0534() {} +void BinderTester::case0535() {} +void BinderTester::case0536() {} +void BinderTester::case0537() {} +void BinderTester::case0538() {} +void BinderTester::case0539() {} +void BinderTester::case0540() {} +void BinderTester::case0541() {} +void BinderTester::case0542() {} +void BinderTester::case0543() {} +void BinderTester::case0544() {} +void BinderTester::case0545() {} +void BinderTester::case0546() {} +void BinderTester::case0547() {} +void BinderTester::case0548() {} +void BinderTester::case0549() {} +void BinderTester::case0550() {} +void BinderTester::case0551() {} +void BinderTester::case0552() {} +void BinderTester::case0553() {} +void BinderTester::case0554() {} +void BinderTester::case0555() {} +void BinderTester::case0556() {} +void BinderTester::case0557() {} +void BinderTester::case0558() {} +void BinderTester::case0559() {} +void BinderTester::case0560() {} +void BinderTester::case0561() {} +void BinderTester::case0562() {} +void BinderTester::case0563() {} +void BinderTester::case0564() {} +void BinderTester::case0565() {} +void BinderTester::case0566() {} +void BinderTester::case0567() {} +void BinderTester::case0568() {} +void BinderTester::case0569() {} +void BinderTester::case0570() {} +void BinderTester::case0571() {} +void BinderTester::case0572() {} +void BinderTester::case0573() {} +void BinderTester::case0574() {} +void BinderTester::case0575() {} +void BinderTester::case0576() {} +void BinderTester::case0577() {} +void BinderTester::case0578() {} +void BinderTester::case0579() {} +void BinderTester::case0580() {} +void BinderTester::case0581() {} +void BinderTester::case0582() {} +void BinderTester::case0583() {} +void BinderTester::case0584() {} +void BinderTester::case0585() {} +void BinderTester::case0586() {} +void BinderTester::case0587() {} +void BinderTester::case0588() {} +void BinderTester::case0589() {} +void BinderTester::case0590() {} +void BinderTester::case0591() {} +void BinderTester::case0592() {} +void BinderTester::case0593() {} +void BinderTester::case0594() {} +void BinderTester::case0595() {} +void BinderTester::case0596() {} +void BinderTester::case0597() {} +void BinderTester::case0598() {} +void BinderTester::case0599() {} - bind(" void ( * x ( int , void ( * y ) ( int ) ) ) ( int ) ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.Parameter().basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Pointer))); -} - -void BinderTester::case0412() -{ - bind("x ( * y ( ) ) ( ) ;", - Expectation() - .binding(DeclSummary() - .Function("y", ScopeKind::File) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} -void BinderTester::case0413() -{ - bind("void x ( ) ( ) ;", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Error, - ConstraintsInDeclarators::ID_FunctionReturningFunction) - .ContinueTestDespiteOfErrors() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0414() -{ - bind("void ( x ( ) ) ( ) ;", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Error, - ConstraintsInDeclarators::ID_FunctionReturningFunction) - .ContinueTestDespiteOfErrors() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} -void BinderTester::case0415(){} -void BinderTester::case0416(){} -void BinderTester::case0417(){} -void BinderTester::case0418(){} -void BinderTester::case0419(){} -void BinderTester::case0420(){} -void BinderTester::case0421(){} -void BinderTester::case0422(){} -void BinderTester::case0423(){} -void BinderTester::case0424(){} - -void BinderTester::case0425() -{ - bind("int ( * x ( ) ) [] ;", - Expectation() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0426() -{ - bind("x ( * y ( ) ) [] ;", - Expectation() - .binding(DeclSummary() - .Function("y", ScopeKind::File) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0427() -{ - bind("int x ( ) [] ;", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Error, - ConstraintsInDeclarators::ID_FunctionReturningArray) - .ContinueTestDespiteOfErrors() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Array) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0428() -{ - bind("int ( x ) ( ) [] ;", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Error, - ConstraintsInDeclarators::ID_FunctionReturningArray) - .ContinueTestDespiteOfErrors() - .binding(DeclSummary() - .Function("x", ScopeKind::File) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Array) - .TySpec.NestAsReturn() - .TySpec.deriv(TypeKind::Function))); -} - -void BinderTester::case0429(){} -void BinderTester::case0430(){} -void BinderTester::case0431(){} -void BinderTester::case0432(){} -void BinderTester::case0433(){} -void BinderTester::case0434(){} -void BinderTester::case0435(){} -void BinderTester::case0436(){} -void BinderTester::case0437(){} -void BinderTester::case0438(){} -void BinderTester::case0439(){} -void BinderTester::case0440() -{ -} - -void BinderTester::case0441(){} -void BinderTester::case0442(){} -void BinderTester::case0443(){} -void BinderTester::case0444(){} -void BinderTester::case0445(){} -void BinderTester::case0446(){} -void BinderTester::case0447(){} -void BinderTester::case0448(){} -void BinderTester::case0449(){} - -void BinderTester::case0450() -{ -} - -void BinderTester::case0451() -{ -} - -void BinderTester::case0452(){} -void BinderTester::case0453(){} -void BinderTester::case0454(){} -void BinderTester::case0455(){} -void BinderTester::case0456(){} -void BinderTester::case0457(){} -void BinderTester::case0458(){} -void BinderTester::case0459(){} -void BinderTester::case0460(){} -void BinderTester::case0461(){} -void BinderTester::case0462(){} -void BinderTester::case0463(){} -void BinderTester::case0464(){} -void BinderTester::case0465(){} -void BinderTester::case0466(){} -void BinderTester::case0467(){} -void BinderTester::case0468(){} -void BinderTester::case0469(){} -void BinderTester::case0470(){} -void BinderTester::case0471(){} -void BinderTester::case0472(){} -void BinderTester::case0473(){} -void BinderTester::case0474(){} -void BinderTester::case0475(){} -void BinderTester::case0476(){} -void BinderTester::case0477(){} -void BinderTester::case0478(){} -void BinderTester::case0479(){} -void BinderTester::case0480(){} -void BinderTester::case0481(){} -void BinderTester::case0482(){} -void BinderTester::case0483(){} -void BinderTester::case0484(){} -void BinderTester::case0485(){} -void BinderTester::case0486(){} -void BinderTester::case0487(){} -void BinderTester::case0488(){} -void BinderTester::case0489(){} -void BinderTester::case0490(){} -void BinderTester::case0491(){} -void BinderTester::case0492(){} -void BinderTester::case0493(){} -void BinderTester::case0494(){} -void BinderTester::case0495(){} -void BinderTester::case0496(){} -void BinderTester::case0497(){} -void BinderTester::case0498(){} -void BinderTester::case0499(){} - -void BinderTester::case0500(){} -void BinderTester::case0501(){} -void BinderTester::case0502(){} -void BinderTester::case0503(){} -void BinderTester::case0504(){} -void BinderTester::case0505(){} -void BinderTester::case0506(){} -void BinderTester::case0507(){} -void BinderTester::case0508(){} -void BinderTester::case0509(){} -void BinderTester::case0510(){} -void BinderTester::case0511(){} -void BinderTester::case0512(){} -void BinderTester::case0513(){} -void BinderTester::case0514(){} -void BinderTester::case0515(){} -void BinderTester::case0516(){} -void BinderTester::case0517(){} -void BinderTester::case0518(){} -void BinderTester::case0519(){} -void BinderTester::case0520(){} -void BinderTester::case0521(){} -void BinderTester::case0522(){} -void BinderTester::case0523(){} -void BinderTester::case0524(){} -void BinderTester::case0525(){} -void BinderTester::case0526(){} -void BinderTester::case0527(){} -void BinderTester::case0528(){} -void BinderTester::case0529(){} -void BinderTester::case0530(){} -void BinderTester::case0531(){} -void BinderTester::case0532(){} -void BinderTester::case0533(){} -void BinderTester::case0534(){} -void BinderTester::case0535(){} -void BinderTester::case0536(){} -void BinderTester::case0537(){} -void BinderTester::case0538(){} -void BinderTester::case0539(){} -void BinderTester::case0540(){} -void BinderTester::case0541(){} -void BinderTester::case0542(){} -void BinderTester::case0543(){} -void BinderTester::case0544(){} -void BinderTester::case0545(){} -void BinderTester::case0546(){} -void BinderTester::case0547(){} -void BinderTester::case0548(){} -void BinderTester::case0549(){} -void BinderTester::case0550(){} -void BinderTester::case0551(){} -void BinderTester::case0552(){} -void BinderTester::case0553(){} -void BinderTester::case0554(){} -void BinderTester::case0555(){} -void BinderTester::case0556(){} -void BinderTester::case0557(){} -void BinderTester::case0558(){} -void BinderTester::case0559(){} -void BinderTester::case0560(){} -void BinderTester::case0561(){} -void BinderTester::case0562(){} -void BinderTester::case0563(){} -void BinderTester::case0564(){} -void BinderTester::case0565(){} -void BinderTester::case0566(){} -void BinderTester::case0567(){} -void BinderTester::case0568(){} -void BinderTester::case0569(){} -void BinderTester::case0570(){} -void BinderTester::case0571(){} -void BinderTester::case0572(){} -void BinderTester::case0573(){} -void BinderTester::case0574(){} -void BinderTester::case0575(){} -void BinderTester::case0576(){} -void BinderTester::case0577(){} -void BinderTester::case0578(){} -void BinderTester::case0579(){} -void BinderTester::case0580(){} -void BinderTester::case0581(){} -void BinderTester::case0582(){} -void BinderTester::case0583(){} -void BinderTester::case0584(){} -void BinderTester::case0585(){} -void BinderTester::case0586(){} -void BinderTester::case0587(){} -void BinderTester::case0588(){} -void BinderTester::case0589(){} -void BinderTester::case0590(){} -void BinderTester::case0591(){} -void BinderTester::case0592(){} -void BinderTester::case0593(){} -void BinderTester::case0594(){} -void BinderTester::case0595(){} -void BinderTester::case0596(){} -void BinderTester::case0597(){} -void BinderTester::case0598(){} -void BinderTester::case0599(){} - - - - - - -void BinderTester::case0901() -{ - CROSS_REFERENCE_TEST(ParserTester::case0028); +void BinderTester::case0901() { + CROSS_REFERENCE_TEST(ParserTester::case0028); - bind("const int ;"); + bind("const int ;"); } -void BinderTester::case0902() -{ - bind("int x ;"); -} +void BinderTester::case0902() { bind("int x ;"); } -void BinderTester::case0903() -{ - bind("void x ( ) ;"); -} +void BinderTester::case0903() { bind("void x ( ) ;"); } -void BinderTester::case0904() -{ - bind("int x ( ) ;"); -} +void BinderTester::case0904() { bind("int x ( ) ;"); } -void BinderTester::case0905() -{ - CROSS_REFERENCE_TEST(ParserTester::case0021); +void BinderTester::case0905() { + CROSS_REFERENCE_TEST(ParserTester::case0021); - bind("int double x ;"); + bind("int double x ;"); } -void BinderTester::case0906() -{ - CROSS_REFERENCE_TEST(ParserTester::case0416); +void BinderTester::case0906() { + CROSS_REFERENCE_TEST(ParserTester::case0416); - bind("struct x { y ; } ;"); + bind("struct x { y ; } ;"); } -void BinderTester::case0907() -{ - CROSS_REFERENCE_TEST(ParserTester::case0422); +void BinderTester::case0907() { + CROSS_REFERENCE_TEST(ParserTester::case0422); - bind("struct x { int ; } ;"); + bind("struct x { int ; } ;"); } -void BinderTester::case0908() -{ - CROSS_REFERENCE_TEST(ParserTester::case0204); +void BinderTester::case0908() { + CROSS_REFERENCE_TEST(ParserTester::case0204); - // Function returning a function. + // Function returning a function. - bind("void x ( ) ( ) { }"); + bind("void x ( ) ( ) { }"); } -void BinderTester::case0909() -{ - CROSS_REFERENCE_TEST(ParserTester::case0205); +void BinderTester::case0909() { + CROSS_REFERENCE_TEST(ParserTester::case0205); - // Function returning a function. + // Function returning a function. - bind("void x ( ) ( ) ;"); + bind("void x ( ) ( ) ;"); } -void BinderTester::case0910() -{ - CROSS_REFERENCE_TEST(ParserTester::case0206); +void BinderTester::case0910() { + CROSS_REFERENCE_TEST(ParserTester::case0206); - // Function returning an array. + // Function returning an array. - bind("int x ( ) [ ] ;"); + bind("int x ( ) [ ] ;"); } -void BinderTester::case0911() -{ - CROSS_REFERENCE_TEST(ParserTester::case0207); +void BinderTester::case0911() { + CROSS_REFERENCE_TEST(ParserTester::case0207); - bind("int ( x ) ( ) [ ] ;"); + bind("int ( x ) ( ) [ ] ;"); } -void BinderTester::case0912() -{ - CROSS_REFERENCE_TEST(ParserTester::case0212); +void BinderTester::case0912() { + CROSS_REFERENCE_TEST(ParserTester::case0212); - // 6.9.1-5 + // 6.9.1-5 - bind("void x ( int ) { }"); + bind("void x ( int ) { }"); } -void BinderTester::case0913() -{ - CROSS_REFERENCE_TEST(ParserTester::case0040); +void BinderTester::case0913() { + CROSS_REFERENCE_TEST(ParserTester::case0040); - bind("int ;"); + bind("int ;"); } -void BinderTester::case0914() -{ - CROSS_REFERENCE_TEST(ParserTester::case0406); +void BinderTester::case0914() { + CROSS_REFERENCE_TEST(ParserTester::case0406); - // Anonymous `struct' declaration without any variable declared - // with such type. + // Anonymous `struct' declaration without any variable declared + // with such type. - bind("struct { int x ; } ;"); + bind("struct { int x ; } ;"); } -void BinderTester::case0915() -{ - CROSS_REFERENCE_TEST(ParserTester::case0632); +void BinderTester::case0915() { + CROSS_REFERENCE_TEST(ParserTester::case0632); - bind("void x ( ) { __thread x y ; }"); + bind("void x ( ) { __thread x y ; }"); } -void BinderTester::case0916() -{ - CROSS_REFERENCE_TEST(ParserTester::case0050); +void BinderTester::case0916() { + CROSS_REFERENCE_TEST(ParserTester::case0050); - bind("double _Complex int x ;"); + bind("double _Complex int x ;"); } -void BinderTester::case0917() -{ - CROSS_REFERENCE_TEST(ParserTester::case0052); +void BinderTester::case0917() { + CROSS_REFERENCE_TEST(ParserTester::case0052); - bind("int int x ;"); + bind("int int x ;"); } -void BinderTester::case0918() -{ - CROSS_REFERENCE_TEST(ParserTester::case0053); +void BinderTester::case0918() { + CROSS_REFERENCE_TEST(ParserTester::case0053); - bind("_Complex _Complex x ;"); + bind("_Complex _Complex x ;"); } -void BinderTester::case0919() -{ - CROSS_REFERENCE_TEST(ParserTester::case0435); +void BinderTester::case0919() { + CROSS_REFERENCE_TEST(ParserTester::case0435); - bind("int struct x { int y ; } z ;"); + bind("int struct x { int y ; } z ;"); } -void BinderTester::case0920() -{ - CROSS_REFERENCE_TEST(ParserTester::case0436); +void BinderTester::case0920() { + CROSS_REFERENCE_TEST(ParserTester::case0436); - bind("struct x struct { int y ; } z ;"); + bind("struct x struct { int y ; } z ;"); } -void BinderTester::case0921() -{ - CROSS_REFERENCE_TEST(ParserTester::case0437); +void BinderTester::case0921() { + CROSS_REFERENCE_TEST(ParserTester::case0437); - bind("int struct x y ;"); + bind("int struct x y ;"); } -void BinderTester::case0922() -{ - CROSS_REFERENCE_TEST(ParserTester::case0438); +void BinderTester::case0922() { + CROSS_REFERENCE_TEST(ParserTester::case0438); - bind("struct x int y ;"); + bind("struct x int y ;"); } -void BinderTester::case0923() -{ - CROSS_REFERENCE_TEST(ParserTester::case0737); +void BinderTester::case0923() { + CROSS_REFERENCE_TEST(ParserTester::case0737); - bind("int __attribute__ ( ( ) ) double ;"); + bind("int __attribute__ ( ( ) ) double ;"); } -void BinderTester::case0924() -{ - CROSS_REFERENCE_TEST(ParserTester::case0738); +void BinderTester::case0924() { + CROSS_REFERENCE_TEST(ParserTester::case0738); - bind("x __attribute__ ( ( ) ) int ;"); + bind("x __attribute__ ( ( ) ) int ;"); } -void BinderTester::case0925() -{ - CROSS_REFERENCE_TEST(ParserTester::case0297); +void BinderTester::case0925() { + CROSS_REFERENCE_TEST(ParserTester::case0297); - bind("void x ( int y ) int y ; { }"); + bind("void x ( int y ) int y ; { }"); } -void BinderTester::case0926() -{ - CROSS_REFERENCE_TEST(ParserTester::case0298); +void BinderTester::case0926() { + CROSS_REFERENCE_TEST(ParserTester::case0298); - bind("int x ( int y ) z y ; { }"); + bind("int x ( int y ) z y ; { }"); } -void BinderTester::case0927() -{ - bind("*1;"); -} +void BinderTester::case0927() { bind("*1;"); } -void BinderTester::case0928() -{ - bind("&1;"); -} +void BinderTester::case0928() { bind("&1;"); } -void BinderTester::case0929() -{ - CROSS_REFERENCE_TEST(ParserTester::case0446); +void BinderTester::case0929() { + CROSS_REFERENCE_TEST(ParserTester::case0446); - bind("struct x { struct y { int z ; } ; } ;"); + bind("struct x { struct y { int z ; } ; } ;"); } -void BinderTester::case0930(){} -void BinderTester::case0931(){} -void BinderTester::case0932(){} -void BinderTester::case0933(){} -void BinderTester::case0934(){} -void BinderTester::case0935(){} -void BinderTester::case0936(){} -void BinderTester::case0937(){} -void BinderTester::case0938(){} -void BinderTester::case0939(){} -void BinderTester::case0940(){} -void BinderTester::case0941(){} -void BinderTester::case0942(){} -void BinderTester::case0943(){} -void BinderTester::case0944(){} -void BinderTester::case0945(){} -void BinderTester::case0946(){} -void BinderTester::case0947(){} -void BinderTester::case0948(){} -void BinderTester::case0949(){} -void BinderTester::case0950(){} -void BinderTester::case0951(){} -void BinderTester::case0952(){} -void BinderTester::case0953(){} -void BinderTester::case0954(){} -void BinderTester::case0955(){} -void BinderTester::case0956(){} -void BinderTester::case0957(){} -void BinderTester::case0958(){} -void BinderTester::case0959(){} -void BinderTester::case0960(){} -void BinderTester::case0961(){} -void BinderTester::case0962(){} -void BinderTester::case0963(){} -void BinderTester::case0964(){} -void BinderTester::case0965(){} -void BinderTester::case0966(){} -void BinderTester::case0967(){} -void BinderTester::case0968(){} -void BinderTester::case0969(){} -void BinderTester::case0970(){} -void BinderTester::case0971(){} -void BinderTester::case0972(){} -void BinderTester::case0973(){} -void BinderTester::case0974(){} -void BinderTester::case0975(){} -void BinderTester::case0976(){} -void BinderTester::case0977(){} -void BinderTester::case0978(){} -void BinderTester::case0979(){} -void BinderTester::case0980(){} -void BinderTester::case0981(){} -void BinderTester::case0982(){} -void BinderTester::case0983(){} -void BinderTester::case0984(){} -void BinderTester::case0985(){} -void BinderTester::case0986(){} -void BinderTester::case0987(){} -void BinderTester::case0988(){} -void BinderTester::case0989(){} -void BinderTester::case0990(){} -void BinderTester::case0991(){} -void BinderTester::case0992(){} -void BinderTester::case0993(){} -void BinderTester::case0994(){} -void BinderTester::case0995(){} -void BinderTester::case0996(){} -void BinderTester::case0997(){} -void BinderTester::case0998(){} -void BinderTester::case0999(){} +void BinderTester::case0930() {} +void BinderTester::case0931() {} +void BinderTester::case0932() {} +void BinderTester::case0933() {} +void BinderTester::case0934() {} +void BinderTester::case0935() {} +void BinderTester::case0936() {} +void BinderTester::case0937() {} +void BinderTester::case0938() {} +void BinderTester::case0939() {} +void BinderTester::case0940() {} +void BinderTester::case0941() {} +void BinderTester::case0942() {} +void BinderTester::case0943() {} +void BinderTester::case0944() {} +void BinderTester::case0945() {} +void BinderTester::case0946() {} +void BinderTester::case0947() {} +void BinderTester::case0948() {} +void BinderTester::case0949() {} +void BinderTester::case0950() {} +void BinderTester::case0951() {} +void BinderTester::case0952() {} +void BinderTester::case0953() {} +void BinderTester::case0954() {} +void BinderTester::case0955() {} +void BinderTester::case0956() {} +void BinderTester::case0957() {} +void BinderTester::case0958() {} +void BinderTester::case0959() {} +void BinderTester::case0960() {} +void BinderTester::case0961() {} +void BinderTester::case0962() {} +void BinderTester::case0963() {} +void BinderTester::case0964() {} +void BinderTester::case0965() {} +void BinderTester::case0966() {} +void BinderTester::case0967() {} +void BinderTester::case0968() {} +void BinderTester::case0969() {} +void BinderTester::case0970() {} +void BinderTester::case0971() {} +void BinderTester::case0972() {} +void BinderTester::case0973() {} +void BinderTester::case0974() {} +void BinderTester::case0975() {} +void BinderTester::case0976() {} +void BinderTester::case0977() {} +void BinderTester::case0978() {} +void BinderTester::case0979() {} +void BinderTester::case0980() {} +void BinderTester::case0981() {} +void BinderTester::case0982() {} +void BinderTester::case0983() {} +void BinderTester::case0984() {} +void BinderTester::case0985() {} +void BinderTester::case0986() {} +void BinderTester::case0987() {} +void BinderTester::case0988() {} +void BinderTester::case0989() {} +void BinderTester::case0990() {} +void BinderTester::case0991() {} +void BinderTester::case0992() {} +void BinderTester::case0993() {} +void BinderTester::case0994() {} +void BinderTester::case0995() {} +void BinderTester::case0996() {} +void BinderTester::case0997() {} +void BinderTester::case0998() {} +void BinderTester::case0999() {} diff --git a/C/tests/BinderTester_1000_1999.cpp b/C/tests/BinderTester_1000_1999.cpp index 20a9c1153..30778ea91 100644 --- a/C/tests/BinderTester_1000_1999.cpp +++ b/C/tests/BinderTester_1000_1999.cpp @@ -32,176 +32,187 @@ #include #include #include -#include #include +#include using namespace psy; using namespace C; -void BinderTester::case1000() -{ - bind("double x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); -} - -void BinderTester::case1001() -{ - bind("int x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case1002() -{ - bind("int x ; int y ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case1003() -{ - bind("int x , y ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case1004() -{ - bind("x y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case1005() -{ - bind("x y , z ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED)) - .binding(DeclSummary().Value("z", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED))); - -} - -void BinderTester::case1006() -{ - bind("int x = 1 ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case1007() -{ - bind("x y = 1 ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case1008() -{ - bind("int float x ;", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - ConstraintsInTypeSpecifiers::ID_TwoOrMoreDataTypesInDeclarationSpecifiers)); -} +void BinderTester::case1000() { + bind("double x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case1001() { + bind("int x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case1002() { + bind("int x ; int y ;", + Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case1003() { + bind("int x , y ;", + Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case1004() { + bind("x y ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case1005() { + bind("x y , z ;", + Expectation() + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED)) + .binding(DeclSummary() + .Value("z", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case1006() { + bind("int x = 1 ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case1007() { + bind("x y = 1 ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case1008() { + bind("int float x ;", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + ConstraintsInTypeSpecifiers:: + ID_TwoOrMoreDataTypesInDeclarationSpecifiers)); +} + +void BinderTester::case1009() { + bind("struct x y ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("struct x", + NamedTypeKind::Structure, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case1010() { + bind("union x y ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("union x", NamedTypeKind::Union, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case1011() { + bind("enum x y ;", Expectation().binding( + DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("enum x", NamedTypeKind::Enumeration, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case1012() { + bind("struct x y , z ;", + Expectation() + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("struct x", NamedTypeKind::Structure, + BuiltinTypeKind::UNSPECIFIED)) + .binding(DeclSummary() + .Value("z", ValueKind::Variable) + .TySpec.basis("struct x", NamedTypeKind::Structure, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case1013() { + bind("struct x { int y ; } z ;", + Expectation().binding(DeclSummary() + .Value("z", ValueKind::Variable) + .TySpec.basis("struct x", + NamedTypeKind::Structure, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case1014() { + bind("long x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("long", NamedTypeKind::Builtin, + BuiltinTypeKind::Long))); +} + +void BinderTester::case1015() { + bind("long int x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("long", NamedTypeKind::Builtin, + BuiltinTypeKind::Long))); +} + +void BinderTester::case1016() { + bind("int long x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("long", NamedTypeKind::Builtin, + BuiltinTypeKind::Long))); +} + +void BinderTester::case1017() { + bind("signed x ;", Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("signed int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int_S))); +} + +void BinderTester::case1018() { + bind("signed int x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("signed int", + NamedTypeKind::Builtin, + BuiltinTypeKind::Int_S))); +} -void BinderTester::case1009() -{ - bind("struct x y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("struct x", NamedTypeKind::Structure, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case1010() -{ - bind("union x y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("union x", NamedTypeKind::Union, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case1011() -{ - bind("enum x y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("enum x", NamedTypeKind::Enumeration, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case1012() -{ - bind("struct x y , z ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("struct x", NamedTypeKind::Structure, BuiltinTypeKind::UNSPECIFIED)) - .binding(DeclSummary().Value("z", ValueKind::Variable) - .TySpec.basis("struct x", NamedTypeKind::Structure, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case1013() -{ - bind("struct x { int y ; } z ;", - Expectation() - .binding(DeclSummary().Value("z", ValueKind::Variable) - .TySpec.basis("struct x", NamedTypeKind::Structure, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case1014() -{ - bind("long x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("long", NamedTypeKind::Builtin, BuiltinTypeKind::Long))); -} - -void BinderTester::case1015() -{ - bind("long int x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("long", NamedTypeKind::Builtin, BuiltinTypeKind::Long))); -} - -void BinderTester::case1016() -{ - bind("int long x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("long", NamedTypeKind::Builtin, BuiltinTypeKind::Long))); -} - -void BinderTester::case1017() -{ - bind("signed x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("signed int", NamedTypeKind::Builtin, BuiltinTypeKind::Int_S))); -} - -void BinderTester::case1018() -{ - bind("signed int x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("signed int", NamedTypeKind::Builtin, BuiltinTypeKind::Int_S))); -} - -void BinderTester::case1019() -{ -} +void BinderTester::case1019() {} void BinderTester::case1020() {} void BinderTester::case1021() {} @@ -234,44 +245,47 @@ void BinderTester::case1047() {} void BinderTester::case1048() {} void BinderTester::case1049() {} -void BinderTester::case1050() -{ - bind("const int x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const))); +void BinderTester::case1050() { + bind("const int x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, + CVR::Const))); } -void BinderTester::case1051() -{ - bind("const x y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const))); +void BinderTester::case1051() { + bind("const x y ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, + CVR::Const))); } -void BinderTester::case1052() -{ - bind("const x ;", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - ConstraintsInTypeSpecifiers::ID_TypeSpecifierMissingDefaultsToInt)); +void BinderTester::case1052() { + bind("const x ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + ConstraintsInTypeSpecifiers::ID_TypeSpecifierMissingDefaultsToInt)); } -void BinderTester::case1053() -{ - bind("int const x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const))); +void BinderTester::case1053() { + bind("int const x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, + CVR::Const))); } -void BinderTester::case1054() -{ - bind("x const y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const))); +void BinderTester::case1054() { + bind("x const y ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, + CVR::Const))); } void BinderTester::case1055() {} @@ -320,88 +334,99 @@ void BinderTester::case1097() {} void BinderTester::case1098() {} void BinderTester::case1099() {} -void BinderTester::case1100() -{ - bind("int * x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1101() -{ - bind("x * y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1102() -{ - bind("int * x ; y * z ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary().Value("z", ValueKind::Variable) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1103() -{ - bind("int * x , * y ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1104() -{ - bind("int ( * x ) [ 1 ];", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1105() -{ - bind("int * * x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1106() -{ - bind("int * * * x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1107() -{ - bind("int * ( * x ) [ 1 ] ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None))); +void BinderTester::case1100() { + bind( + "int * x ;", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1101() { + bind("x * y ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1102() { + bind("int * x ; y * z ;", + Expectation() + .binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Variable) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1103() { + bind("int * x , * y ;", Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1104() { + bind( + "int ( * x ) [ 1 ];", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1105() { + bind( + "int * * x ;", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1106() { + bind( + "int * * * x ;", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1107() { + bind("int * ( * x ) [ 1 ] ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None))); } void BinderTester::case1108() {} @@ -427,118 +452,151 @@ void BinderTester::case1127() {} void BinderTester::case1128() {} void BinderTester::case1129() {} -void BinderTester::case1130() -{ - bind("int ( * x ) ( ) ;", - Expectation() - .binding(DeclSummary() - .Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1131() -{ - bind("x ( * y ) ( ) ;", - Expectation() - .binding(DeclSummary() - .Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case1132() -{ - bind("int ( * x ) ( double ) ;", - Expectation() - .binding(DeclSummary() - .Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); -} - -void BinderTester::case1133() -{ - bind("x ( * y ) ( double ) ;", - Expectation() - .binding(DeclSummary() - .Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); -} - -void BinderTester::case1134() -{ - bind("int ( * x ) ( double , char ) ;", - Expectation() - .binding(DeclSummary() - .Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.Parameter().basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char))); -} - -void BinderTester::case1135() -{ - bind("int ( * x ) ( y , char ) ;", - Expectation() - .binding(DeclSummary() - .Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("y", NamedTypeKind::Synonym) - .TySpec.Parameter().basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("y", NamedTypeKind::Synonym)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char))); -} - -void BinderTester::case1136() -{ - bind("void ( * x ) ( int ( * ) ( double) ) ;", - Expectation() - .binding(DeclSummary() - .Value("x", ValueKind::Variable) - .TySpec.basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec._AtParam_().deriv(TypeKind::Function) - .TySpec._AtParam_().Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec._AtParam_().deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Function) - .TySpec.Parameter().basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary() - .Value("", ValueKind::Parameter, ScopeKind::FunctionPrototype) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); +void BinderTester::case1130() { + bind( + "int ( * x ) ( ) ;", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1131() { + bind("x ( * y ) ( ) ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case1132() { + bind("int ( * x ) ( double ) ;", + Expectation() + .binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case1133() { + bind("x ( * y ) ( double ) ;", + Expectation() + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); +} + +void BinderTester::case1134() { + bind("int ( * x ) ( double , char ) ;", + Expectation() + .binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.Parameter() + .basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("char", NamedTypeKind::Builtin, + BuiltinTypeKind::Char))); +} + +void BinderTester::case1135() { + bind("int ( * x ) ( y , char ) ;", + Expectation() + .binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("y", NamedTypeKind::Synonym) + .TySpec.Parameter() + .basis("char", NamedTypeKind::Builtin, BuiltinTypeKind::Char) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("y", NamedTypeKind::Synonym)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("char", NamedTypeKind::Builtin, + BuiltinTypeKind::Char))); +} + +void BinderTester::case1136() { + bind("void ( * x ) ( int ( * ) ( double) ) ;", + Expectation() + .binding( + DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("void", NamedTypeKind::Builtin, BuiltinTypeKind::Void) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec._AtParam_() + .deriv(TypeKind::Function) + .TySpec._AtParam_() + .Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec._AtParam_() + .deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("", ValueKind::Parameter) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Function) + .TySpec.Parameter() + .basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("", ValueKind::Parameter, + ScopeKind::FunctionPrototype) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); } void BinderTester::case1137() {} @@ -555,22 +613,24 @@ void BinderTester::case1147() {} void BinderTester::case1148() {} void BinderTester::case1149() {} -void BinderTester::case1150() -{ - bind("const int * x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case1150() { + bind("const int * x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::Const) + .TySpec.deriv(TypeKind::Pointer))); } -void BinderTester::case1151() -{ - bind("const x * y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const) - .TySpec.deriv(TypeKind::Pointer))); +void BinderTester::case1151() { + bind("const x * y ;", Expectation().binding( + DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::Const) + .TySpec.deriv(TypeKind::Pointer))); } void BinderTester::case1152() {} @@ -620,313 +680,333 @@ void BinderTester::case1195() {} void BinderTester::case1196() {} void BinderTester::case1197() {} void BinderTester::case1198() {} -void BinderTester::case1199() -{} - -void BinderTester::case1200() -{ - bind("const int * const x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const) - .TySpec.deriv(TypeKind::Pointer, CVR::Const))); -} - -void BinderTester::case1201() { } -void BinderTester::case1202() { } -void BinderTester::case1203() { } -void BinderTester::case1204() { } -void BinderTester::case1205() { } -void BinderTester::case1206() { } -void BinderTester::case1207() { } -void BinderTester::case1208() { } -void BinderTester::case1209() { } -void BinderTester::case1210() { } -void BinderTester::case1211() { } -void BinderTester::case1212() { } -void BinderTester::case1213() { } -void BinderTester::case1214() { } -void BinderTester::case1215() { } -void BinderTester::case1216() { } -void BinderTester::case1217() { } -void BinderTester::case1218() { } -void BinderTester::case1219() { } -void BinderTester::case1220() { } -void BinderTester::case1221() { } -void BinderTester::case1222() { } -void BinderTester::case1223() { } -void BinderTester::case1224() { } -void BinderTester::case1225() { } -void BinderTester::case1226() { } -void BinderTester::case1227() { } -void BinderTester::case1228() { } -void BinderTester::case1229() { } -void BinderTester::case1230() { } -void BinderTester::case1231() { } -void BinderTester::case1232() { } -void BinderTester::case1233() { } -void BinderTester::case1234() { } -void BinderTester::case1235() { } -void BinderTester::case1236() { } -void BinderTester::case1237() { } -void BinderTester::case1238() { } -void BinderTester::case1239() { } -void BinderTester::case1240() { } -void BinderTester::case1241() { } -void BinderTester::case1242() { } -void BinderTester::case1243() { } -void BinderTester::case1244() { } -void BinderTester::case1245() { } -void BinderTester::case1246() { } -void BinderTester::case1247() { } -void BinderTester::case1248() { } -void BinderTester::case1249() { } - -void BinderTester::case1250() -{ - bind("int * const x ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::Const))); -} - -void BinderTester::case1251() -{ - bind("x * const y ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::Const))); -} - -void BinderTester::case1252() { } -void BinderTester::case1253() { } -void BinderTester::case1254() { } -void BinderTester::case1255() { } -void BinderTester::case1256() { } -void BinderTester::case1257() { } -void BinderTester::case1258() { } -void BinderTester::case1259() { } -void BinderTester::case1260() { } -void BinderTester::case1261() { } -void BinderTester::case1262() { } -void BinderTester::case1263() { } -void BinderTester::case1264() { } -void BinderTester::case1265() { } -void BinderTester::case1266() { } -void BinderTester::case1267() { } -void BinderTester::case1268() { } -void BinderTester::case1269() { } -void BinderTester::case1270() { } -void BinderTester::case1271() { } -void BinderTester::case1272() { } -void BinderTester::case1273() { } -void BinderTester::case1274() { } -void BinderTester::case1275() { } -void BinderTester::case1276() { } -void BinderTester::case1277() { } -void BinderTester::case1278() { } -void BinderTester::case1279() { } -void BinderTester::case1280() { } -void BinderTester::case1281() { } -void BinderTester::case1282() { } -void BinderTester::case1283() { } -void BinderTester::case1284() { } -void BinderTester::case1285() { } -void BinderTester::case1286() { } -void BinderTester::case1287() { } -void BinderTester::case1288() { } -void BinderTester::case1289() { } -void BinderTester::case1290() { } -void BinderTester::case1291() { } -void BinderTester::case1292() { } -void BinderTester::case1293() { } -void BinderTester::case1294() { } -void BinderTester::case1295() { } -void BinderTester::case1296() { } -void BinderTester::case1297() { } -void BinderTester::case1298() { } -void BinderTester::case1299() { } - -void BinderTester::case1300() -{ - bind("int x [ 1 ] ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case1301() -{ - bind("x y [ 1 ] ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case1302() -{ - bind("int x [ 1 ] , y [ 2 ] ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None)) - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case1303() -{ - bind("x y [ 1 ] , z [ 2 ] ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None)) - .binding(DeclSummary().Value("z", ValueKind::Variable) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case1304() -{ - bind("int * x [ 1 ] ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case1305() -{ - bind("int x [ 1 ] , * y [ 2 ] ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None)) - .binding(DeclSummary().Value("y", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case1306() -{ - bind("int * * x [ 1 ] ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case1307() -{ -} - -void BinderTester::case1308(){ } -void BinderTester::case1309(){ } -void BinderTester::case1310(){ } -void BinderTester::case1311(){ } -void BinderTester::case1312(){ } -void BinderTester::case1313(){ } -void BinderTester::case1314(){ } -void BinderTester::case1315(){ } -void BinderTester::case1316(){ } -void BinderTester::case1317(){ } -void BinderTester::case1318(){ } -void BinderTester::case1319(){ } -void BinderTester::case1320(){ } -void BinderTester::case1321(){ } -void BinderTester::case1322(){ } -void BinderTester::case1323(){ } -void BinderTester::case1324(){ } -void BinderTester::case1325(){ } -void BinderTester::case1326(){ } -void BinderTester::case1327(){ } -void BinderTester::case1328(){ } -void BinderTester::case1329(){ } -void BinderTester::case1330(){ } -void BinderTester::case1331(){ } -void BinderTester::case1332(){ } -void BinderTester::case1333(){ } -void BinderTester::case1334(){ } -void BinderTester::case1335(){ } -void BinderTester::case1336(){ } -void BinderTester::case1337(){ } -void BinderTester::case1338(){ } -void BinderTester::case1339(){ } -void BinderTester::case1340(){ } -void BinderTester::case1341(){ } -void BinderTester::case1342(){ } -void BinderTester::case1343(){ } -void BinderTester::case1344(){ } -void BinderTester::case1345(){ } -void BinderTester::case1346(){ } -void BinderTester::case1347(){ } -void BinderTester::case1348(){ } -void BinderTester::case1349(){ } - -void BinderTester::case1350() -{ - bind("const int x [ 1 ] ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Variable) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case1351(){ } -void BinderTester::case1352(){ } -void BinderTester::case1353(){ } -void BinderTester::case1354(){ } -void BinderTester::case1355(){ } -void BinderTester::case1356(){ } -void BinderTester::case1357(){ } -void BinderTester::case1358(){ } -void BinderTester::case1359(){ } -void BinderTester::case1360(){ } -void BinderTester::case1361(){ } -void BinderTester::case1362(){ } -void BinderTester::case1363(){ } -void BinderTester::case1364(){ } -void BinderTester::case1365(){ } -void BinderTester::case1366(){ } -void BinderTester::case1367(){ } -void BinderTester::case1368(){ } -void BinderTester::case1369(){ } -void BinderTester::case1370(){ } -void BinderTester::case1371(){ } -void BinderTester::case1372(){ } -void BinderTester::case1373(){ } -void BinderTester::case1374(){ } -void BinderTester::case1375(){ } -void BinderTester::case1376(){ } -void BinderTester::case1377(){ } -void BinderTester::case1378(){ } -void BinderTester::case1379(){ } -void BinderTester::case1380(){ } -void BinderTester::case1381(){ } -void BinderTester::case1382(){ } -void BinderTester::case1383(){ } -void BinderTester::case1384(){ } -void BinderTester::case1385(){ } -void BinderTester::case1386(){ } -void BinderTester::case1387(){ } -void BinderTester::case1388(){ } -void BinderTester::case1389(){ } -void BinderTester::case1390(){ } -void BinderTester::case1391(){ } -void BinderTester::case1392(){ } -void BinderTester::case1393(){ } -void BinderTester::case1394(){ } -void BinderTester::case1395(){ } -void BinderTester::case1396(){ } -void BinderTester::case1397(){ } -void BinderTester::case1398(){ } -void BinderTester::case1399(){ } +void BinderTester::case1199() {} + +void BinderTester::case1200() { + bind("const int * const x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::Const) + .TySpec.deriv(TypeKind::Pointer, CVR::Const))); +} + +void BinderTester::case1201() {} +void BinderTester::case1202() {} +void BinderTester::case1203() {} +void BinderTester::case1204() {} +void BinderTester::case1205() {} +void BinderTester::case1206() {} +void BinderTester::case1207() {} +void BinderTester::case1208() {} +void BinderTester::case1209() {} +void BinderTester::case1210() {} +void BinderTester::case1211() {} +void BinderTester::case1212() {} +void BinderTester::case1213() {} +void BinderTester::case1214() {} +void BinderTester::case1215() {} +void BinderTester::case1216() {} +void BinderTester::case1217() {} +void BinderTester::case1218() {} +void BinderTester::case1219() {} +void BinderTester::case1220() {} +void BinderTester::case1221() {} +void BinderTester::case1222() {} +void BinderTester::case1223() {} +void BinderTester::case1224() {} +void BinderTester::case1225() {} +void BinderTester::case1226() {} +void BinderTester::case1227() {} +void BinderTester::case1228() {} +void BinderTester::case1229() {} +void BinderTester::case1230() {} +void BinderTester::case1231() {} +void BinderTester::case1232() {} +void BinderTester::case1233() {} +void BinderTester::case1234() {} +void BinderTester::case1235() {} +void BinderTester::case1236() {} +void BinderTester::case1237() {} +void BinderTester::case1238() {} +void BinderTester::case1239() {} +void BinderTester::case1240() {} +void BinderTester::case1241() {} +void BinderTester::case1242() {} +void BinderTester::case1243() {} +void BinderTester::case1244() {} +void BinderTester::case1245() {} +void BinderTester::case1246() {} +void BinderTester::case1247() {} +void BinderTester::case1248() {} +void BinderTester::case1249() {} + +void BinderTester::case1250() { + bind("int * const x ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::Const))); +} + +void BinderTester::case1251() { + bind("x * const y ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::Const))); +} + +void BinderTester::case1252() {} +void BinderTester::case1253() {} +void BinderTester::case1254() {} +void BinderTester::case1255() {} +void BinderTester::case1256() {} +void BinderTester::case1257() {} +void BinderTester::case1258() {} +void BinderTester::case1259() {} +void BinderTester::case1260() {} +void BinderTester::case1261() {} +void BinderTester::case1262() {} +void BinderTester::case1263() {} +void BinderTester::case1264() {} +void BinderTester::case1265() {} +void BinderTester::case1266() {} +void BinderTester::case1267() {} +void BinderTester::case1268() {} +void BinderTester::case1269() {} +void BinderTester::case1270() {} +void BinderTester::case1271() {} +void BinderTester::case1272() {} +void BinderTester::case1273() {} +void BinderTester::case1274() {} +void BinderTester::case1275() {} +void BinderTester::case1276() {} +void BinderTester::case1277() {} +void BinderTester::case1278() {} +void BinderTester::case1279() {} +void BinderTester::case1280() {} +void BinderTester::case1281() {} +void BinderTester::case1282() {} +void BinderTester::case1283() {} +void BinderTester::case1284() {} +void BinderTester::case1285() {} +void BinderTester::case1286() {} +void BinderTester::case1287() {} +void BinderTester::case1288() {} +void BinderTester::case1289() {} +void BinderTester::case1290() {} +void BinderTester::case1291() {} +void BinderTester::case1292() {} +void BinderTester::case1293() {} +void BinderTester::case1294() {} +void BinderTester::case1295() {} +void BinderTester::case1296() {} +void BinderTester::case1297() {} +void BinderTester::case1298() {} +void BinderTester::case1299() {} + +void BinderTester::case1300() { + bind("int x [ 1 ] ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case1301() { + bind("x y [ 1 ] ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case1302() { + bind("int x [ 1 ] , y [ 2 ] ;", + Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None)) + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case1303() { + bind("x y [ 1 ] , z [ 2 ] ;", + Expectation() + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None)) + .binding(DeclSummary() + .Value("z", ValueKind::Variable) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case1304() { + bind("int * x [ 1 ] ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case1305() { + bind("int x [ 1 ] , * y [ 2 ] ;", + Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None)) + .binding(DeclSummary() + .Value("y", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case1306() { + bind("int * * x [ 1 ] ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case1307() {} + +void BinderTester::case1308() {} +void BinderTester::case1309() {} +void BinderTester::case1310() {} +void BinderTester::case1311() {} +void BinderTester::case1312() {} +void BinderTester::case1313() {} +void BinderTester::case1314() {} +void BinderTester::case1315() {} +void BinderTester::case1316() {} +void BinderTester::case1317() {} +void BinderTester::case1318() {} +void BinderTester::case1319() {} +void BinderTester::case1320() {} +void BinderTester::case1321() {} +void BinderTester::case1322() {} +void BinderTester::case1323() {} +void BinderTester::case1324() {} +void BinderTester::case1325() {} +void BinderTester::case1326() {} +void BinderTester::case1327() {} +void BinderTester::case1328() {} +void BinderTester::case1329() {} +void BinderTester::case1330() {} +void BinderTester::case1331() {} +void BinderTester::case1332() {} +void BinderTester::case1333() {} +void BinderTester::case1334() {} +void BinderTester::case1335() {} +void BinderTester::case1336() {} +void BinderTester::case1337() {} +void BinderTester::case1338() {} +void BinderTester::case1339() {} +void BinderTester::case1340() {} +void BinderTester::case1341() {} +void BinderTester::case1342() {} +void BinderTester::case1343() {} +void BinderTester::case1344() {} +void BinderTester::case1345() {} +void BinderTester::case1346() {} +void BinderTester::case1347() {} +void BinderTester::case1348() {} +void BinderTester::case1349() {} + +void BinderTester::case1350() { + bind("const int x [ 1 ] ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Variable) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::Const) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case1351() {} +void BinderTester::case1352() {} +void BinderTester::case1353() {} +void BinderTester::case1354() {} +void BinderTester::case1355() {} +void BinderTester::case1356() {} +void BinderTester::case1357() {} +void BinderTester::case1358() {} +void BinderTester::case1359() {} +void BinderTester::case1360() {} +void BinderTester::case1361() {} +void BinderTester::case1362() {} +void BinderTester::case1363() {} +void BinderTester::case1364() {} +void BinderTester::case1365() {} +void BinderTester::case1366() {} +void BinderTester::case1367() {} +void BinderTester::case1368() {} +void BinderTester::case1369() {} +void BinderTester::case1370() {} +void BinderTester::case1371() {} +void BinderTester::case1372() {} +void BinderTester::case1373() {} +void BinderTester::case1374() {} +void BinderTester::case1375() {} +void BinderTester::case1376() {} +void BinderTester::case1377() {} +void BinderTester::case1378() {} +void BinderTester::case1379() {} +void BinderTester::case1380() {} +void BinderTester::case1381() {} +void BinderTester::case1382() {} +void BinderTester::case1383() {} +void BinderTester::case1384() {} +void BinderTester::case1385() {} +void BinderTester::case1386() {} +void BinderTester::case1387() {} +void BinderTester::case1388() {} +void BinderTester::case1389() {} +void BinderTester::case1390() {} +void BinderTester::case1391() {} +void BinderTester::case1392() {} +void BinderTester::case1393() {} +void BinderTester::case1394() {} +void BinderTester::case1395() {} +void BinderTester::case1396() {} +void BinderTester::case1397() {} +void BinderTester::case1398() {} +void BinderTester::case1399() {} diff --git a/C/tests/BinderTester_2000_2999.cpp b/C/tests/BinderTester_2000_2999.cpp index e4041e3e9..0ba07eb06 100644 --- a/C/tests/BinderTester_2000_2999.cpp +++ b/C/tests/BinderTester_2000_2999.cpp @@ -33,833 +33,882 @@ #include #include #include -#include #include +#include using namespace psy; using namespace C; -void BinderTester::case2000() -{ - bind(R"( +void BinderTester::case2000() { + bind(R"( struct { double x ; }; )", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("double", NamedTypeKind::Builtin, BuiltinTypeKind::Double))); + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("double", NamedTypeKind::Builtin, + BuiltinTypeKind::Double))); } -void BinderTester::case2001() -{ - bind(R"( +void BinderTester::case2001() { + bind(R"( struct { int x ; }; )", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); } -void BinderTester::case2002() -{ - bind(R"( +void BinderTester::case2002() { + bind(R"( struct w { int x ; int y ; }; )", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case2003() -{ - bind(R"( + Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case2003() { + bind(R"( struct { int x , y ; }; )", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); -} - -void BinderTester::case2004() -{ - bind(R"( + Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); +} + +void BinderTester::case2004() { + bind(R"( struct { x y ; }; )", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED))); + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED))); } -void BinderTester::case2005() -{ - bind(R"( +void BinderTester::case2005() { + bind(R"( struct { x y , z ; }; )", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED)) - .binding(DeclSummary().Value("z", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED))); + Expectation() + .binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED)) + .binding(DeclSummary() + .Value("z", ValueKind::Field) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED))); } -void BinderTester::case2006() -{ - // Non-field correspondent - CROSS_REFERENCE_TEST(BinderTester::case2006); +void BinderTester::case2006() { + // Non-field correspondent + CROSS_REFERENCE_TEST(BinderTester::case2006); - // Syntax error - CROSS_REFERENCE_TEST(ParserTester::case0439); + // Syntax error + CROSS_REFERENCE_TEST(ParserTester::case0439); } -void BinderTester::case2007() -{ - // Non-field correspondent - CROSS_REFERENCE_TEST(BinderTester::case2007); +void BinderTester::case2007() { + // Non-field correspondent + CROSS_REFERENCE_TEST(BinderTester::case2007); - // Syntax error - CROSS_REFERENCE_TEST(ParserTester::case0440); + // Syntax error + CROSS_REFERENCE_TEST(ParserTester::case0440); } -void BinderTester::case2008() -{ - bind(R"( +void BinderTester::case2008() { + bind(R"( struct { int float x ; }; )", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - ConstraintsInTypeSpecifiers::ID_TwoOrMoreDataTypesInDeclarationSpecifiers)); + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + ConstraintsInTypeSpecifiers:: + ID_TwoOrMoreDataTypesInDeclarationSpecifiers)); } -void BinderTester::case2009() -{ - bind(R"( +void BinderTester::case2009() { + bind(R"( struct { struct x y ; }; )", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("struct x", NamedTypeKind::Structure, BuiltinTypeKind::UNSPECIFIED))); + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("struct x", + NamedTypeKind::Structure, + BuiltinTypeKind::UNSPECIFIED))); } -void BinderTester::case2010() -{ - bind(R"( +void BinderTester::case2010() { + bind(R"( struct { union x y ; }; )", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("union x", NamedTypeKind::Union, BuiltinTypeKind::UNSPECIFIED))); + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("union x", NamedTypeKind::Union, + BuiltinTypeKind::UNSPECIFIED))); } -void BinderTester::case2011() -{ - bind(R"( +void BinderTester::case2011() { + bind(R"( struct { enum x y ; }; )", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("enum x", NamedTypeKind::Enumeration, BuiltinTypeKind::UNSPECIFIED))); + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("enum x", + NamedTypeKind::Enumeration, + BuiltinTypeKind::UNSPECIFIED))); } -void BinderTester::case2012() -{ - bind(R"( +void BinderTester::case2012() { + bind(R"( struct { struct x y , z ; }; )", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("struct x", NamedTypeKind::Structure, BuiltinTypeKind::UNSPECIFIED)) - .binding(DeclSummary().Value("z", ValueKind::Field) - .TySpec.basis("struct x", NamedTypeKind::Structure, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case2013() -{ - bind(R"( + Expectation() + .binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("struct x", NamedTypeKind::Structure, + BuiltinTypeKind::UNSPECIFIED)) + .binding(DeclSummary() + .Value("z", ValueKind::Field) + .TySpec.basis("struct x", NamedTypeKind::Structure, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case2013() { + bind(R"( struct { struct x { int y ; } z ; }; )", - Expectation() - .binding(DeclSummary().Value("z", ValueKind::Field) - .TySpec.basis("struct x", NamedTypeKind::Structure, BuiltinTypeKind::UNSPECIFIED))); -} - -void BinderTester::case2014(){ } -void BinderTester::case2015(){ } -void BinderTester::case2016(){ } -void BinderTester::case2017(){ } -void BinderTester::case2018(){ } -void BinderTester::case2019(){ } -void BinderTester::case2020(){ } -void BinderTester::case2021(){ } -void BinderTester::case2022(){ } -void BinderTester::case2023(){ } -void BinderTester::case2024(){ } -void BinderTester::case2025(){ } -void BinderTester::case2026(){ } -void BinderTester::case2027(){ } -void BinderTester::case2028(){ } -void BinderTester::case2029(){ } -void BinderTester::case2030(){ } -void BinderTester::case2031(){ } -void BinderTester::case2032(){ } -void BinderTester::case2033(){ } -void BinderTester::case2034(){ } -void BinderTester::case2035(){ } -void BinderTester::case2036(){ } -void BinderTester::case2037(){ } -void BinderTester::case2038(){ } -void BinderTester::case2039(){ } -void BinderTester::case2040(){ } -void BinderTester::case2041(){ } -void BinderTester::case2042(){ } -void BinderTester::case2043(){ } -void BinderTester::case2044(){ } -void BinderTester::case2045(){ } -void BinderTester::case2046(){ } -void BinderTester::case2047(){ } -void BinderTester::case2048(){ } -void BinderTester::case2049(){ } - -void BinderTester::case2050() -{ - bind("struct { const int x ; } ;", - Expectation() - .binding(DeclSummary() - .Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const))); -} - -void BinderTester::case2051() -{ - bind("struct { const x y ; } ;", - Expectation() - .binding(DeclSummary() - .Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const))); -} - -void BinderTester::case2052() -{ - bind("struct { const x ; } ;", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - ConstraintsInDeclarations::ID_of_UselessDeclaration)); -} - -void BinderTester::case2053() -{ - bind("struct { int const x ; } ;", - Expectation() - .binding(DeclSummary() - .Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const))); -} - -void BinderTester::case2054() -{ - bind("struct { x const y ; } ;", - Expectation() - .binding(DeclSummary() - .Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const))); -} - -void BinderTester::case2055(){ } -void BinderTester::case2056(){ } -void BinderTester::case2057(){ } -void BinderTester::case2058(){ } -void BinderTester::case2059(){ } -void BinderTester::case2060(){ } -void BinderTester::case2061(){ } -void BinderTester::case2062(){ } -void BinderTester::case2063(){ } -void BinderTester::case2064(){ } -void BinderTester::case2065(){ } -void BinderTester::case2066(){ } -void BinderTester::case2067(){ } -void BinderTester::case2068(){ } -void BinderTester::case2069(){ } -void BinderTester::case2070(){ } -void BinderTester::case2071(){ } -void BinderTester::case2072(){ } -void BinderTester::case2073(){ } -void BinderTester::case2074(){ } -void BinderTester::case2075(){ } -void BinderTester::case2076(){ } -void BinderTester::case2077(){ } -void BinderTester::case2078(){ } -void BinderTester::case2079(){ } -void BinderTester::case2080(){ } -void BinderTester::case2081(){ } -void BinderTester::case2082(){ } -void BinderTester::case2083(){ } -void BinderTester::case2084(){ } -void BinderTester::case2085(){ } -void BinderTester::case2086(){ } -void BinderTester::case2087(){ } -void BinderTester::case2088(){ } -void BinderTester::case2089(){ } -void BinderTester::case2090(){ } -void BinderTester::case2091(){ } -void BinderTester::case2092(){ } -void BinderTester::case2093(){ } -void BinderTester::case2094(){ } -void BinderTester::case2095(){ } -void BinderTester::case2096(){ } -void BinderTester::case2097(){ } -void BinderTester::case2098(){ } -void BinderTester::case2099(){ } - -void BinderTester::case2100() -{ - bind("struct { int * x ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2101() -{ - bind("struct { x * y ; } ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2102() -{ - bind("struct { int * x ; y * z ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary().Value("z", ValueKind::Field) - .TySpec.basis("y", NamedTypeKind::Synonym) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2103() -{ - bind("struct { int * x , * y ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer)) - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2104() -{ - bind("struct { int ( * x ) [ 1 ]; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Array) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2105() -{ - bind("struct { int * * x ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2106() -{ - bind("struct { int * * * x ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2107() -{ - bind("struct { int * ( * x ) [ 1 ] ; };", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None))); -} - -void BinderTester::case2108(){ } -void BinderTester::case2109(){ } -void BinderTester::case2110(){ } -void BinderTester::case2111(){ } -void BinderTester::case2112(){ } -void BinderTester::case2113(){ } -void BinderTester::case2114(){ } -void BinderTester::case2115(){ } -void BinderTester::case2116(){ } -void BinderTester::case2117(){ } -void BinderTester::case2118(){ } -void BinderTester::case2119(){ } -void BinderTester::case2120(){ } -void BinderTester::case2121(){ } -void BinderTester::case2122(){ } -void BinderTester::case2123(){ } -void BinderTester::case2124(){ } -void BinderTester::case2125(){ } -void BinderTester::case2126(){ } -void BinderTester::case2127(){ } -void BinderTester::case2128(){ } -void BinderTester::case2129(){ } -void BinderTester::case2130(){ } -void BinderTester::case2131(){ } -void BinderTester::case2132(){ } -void BinderTester::case2133(){ } -void BinderTester::case2134(){ } -void BinderTester::case2135(){ } -void BinderTester::case2136(){ } -void BinderTester::case2137(){ } -void BinderTester::case2138(){ } -void BinderTester::case2139(){ } -void BinderTester::case2140(){ } -void BinderTester::case2141(){ } -void BinderTester::case2142(){ } -void BinderTester::case2143(){ } -void BinderTester::case2144(){ } -void BinderTester::case2145(){ } -void BinderTester::case2146(){ } -void BinderTester::case2147(){ } -void BinderTester::case2148(){ } -void BinderTester::case2149(){ } - -void BinderTester::case2150() -{ - bind("struct { const int * x ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2151() -{ - bind("struct { const x * y ; } ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::Const) - .TySpec.deriv(TypeKind::Pointer))); -} - -void BinderTester::case2152(){ } -void BinderTester::case2153(){ } -void BinderTester::case2154(){ } -void BinderTester::case2155(){ } -void BinderTester::case2156(){ } -void BinderTester::case2157(){ } -void BinderTester::case2158(){ } -void BinderTester::case2159(){ } -void BinderTester::case2160(){ } -void BinderTester::case2161(){ } -void BinderTester::case2162(){ } -void BinderTester::case2163(){ } -void BinderTester::case2164(){ } -void BinderTester::case2165(){ } -void BinderTester::case2166(){ } -void BinderTester::case2167(){ } -void BinderTester::case2168(){ } -void BinderTester::case2169(){ } -void BinderTester::case2170(){ } -void BinderTester::case2171(){ } -void BinderTester::case2172(){ } -void BinderTester::case2173(){ } -void BinderTester::case2174(){ } -void BinderTester::case2175(){ } -void BinderTester::case2176(){ } -void BinderTester::case2177(){ } -void BinderTester::case2178(){ } -void BinderTester::case2179(){ } -void BinderTester::case2180(){ } -void BinderTester::case2181(){ } -void BinderTester::case2182(){ } -void BinderTester::case2183(){ } -void BinderTester::case2184(){ } -void BinderTester::case2185(){ } -void BinderTester::case2186(){ } -void BinderTester::case2187(){ } -void BinderTester::case2188(){ } -void BinderTester::case2189(){ } -void BinderTester::case2190(){ } -void BinderTester::case2191(){ } -void BinderTester::case2192(){ } -void BinderTester::case2193(){ } -void BinderTester::case2194(){ } -void BinderTester::case2195(){ } -void BinderTester::case2196(){ } -void BinderTester::case2197(){ } -void BinderTester::case2198(){ } -void BinderTester::case2199(){ } - -void BinderTester::case2200() -{ - bind("struct { const int * const x ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const) - .TySpec.deriv(TypeKind::Pointer, CVR::Const))); -} - - -void BinderTester::case2201(){ } -void BinderTester::case2202(){ } -void BinderTester::case2203(){ } -void BinderTester::case2204(){ } -void BinderTester::case2205(){ } -void BinderTester::case2206(){ } -void BinderTester::case2207(){ } -void BinderTester::case2208(){ } -void BinderTester::case2209(){ } -void BinderTester::case2210(){ } -void BinderTester::case2211(){ } -void BinderTester::case2212(){ } -void BinderTester::case2213(){ } -void BinderTester::case2214(){ } -void BinderTester::case2215(){ } -void BinderTester::case2216(){ } -void BinderTester::case2217(){ } -void BinderTester::case2218(){ } -void BinderTester::case2219(){ } -void BinderTester::case2220(){ } -void BinderTester::case2221(){ } -void BinderTester::case2222(){ } -void BinderTester::case2223(){ } -void BinderTester::case2224(){ } -void BinderTester::case2225(){ } -void BinderTester::case2226(){ } -void BinderTester::case2227(){ } -void BinderTester::case2228(){ } -void BinderTester::case2229(){ } -void BinderTester::case2230(){ } -void BinderTester::case2231(){ } -void BinderTester::case2232(){ } -void BinderTester::case2233(){ } -void BinderTester::case2234(){ } -void BinderTester::case2235(){ } -void BinderTester::case2236(){ } -void BinderTester::case2237(){ } -void BinderTester::case2238(){ } -void BinderTester::case2239(){ } -void BinderTester::case2240(){ } -void BinderTester::case2241(){ } -void BinderTester::case2242(){ } -void BinderTester::case2243(){ } -void BinderTester::case2244(){ } -void BinderTester::case2245(){ } -void BinderTester::case2246(){ } -void BinderTester::case2247(){ } -void BinderTester::case2248(){ } -void BinderTester::case2249(){ } - -void BinderTester::case2250() -{ - bind("struct { int * const x ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::Const))); -} - -void BinderTester::case2251() -{ - bind("struct { x * const y ; } ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::Const))); -} - -void BinderTester::case2252(){ } -void BinderTester::case2253(){ } -void BinderTester::case2254(){ } -void BinderTester::case2255(){ } -void BinderTester::case2256(){ } -void BinderTester::case2257(){ } -void BinderTester::case2258(){ } -void BinderTester::case2259(){ } -void BinderTester::case2260(){ } -void BinderTester::case2261(){ } -void BinderTester::case2262(){ } -void BinderTester::case2263(){ } -void BinderTester::case2264(){ } -void BinderTester::case2265(){ } -void BinderTester::case2266(){ } -void BinderTester::case2267(){ } -void BinderTester::case2268(){ } -void BinderTester::case2269(){ } -void BinderTester::case2270(){ } -void BinderTester::case2271(){ } -void BinderTester::case2272(){ } -void BinderTester::case2273(){ } -void BinderTester::case2274(){ } -void BinderTester::case2275(){ } -void BinderTester::case2276(){ } -void BinderTester::case2277(){ } -void BinderTester::case2278(){ } -void BinderTester::case2279(){ } -void BinderTester::case2280(){ } -void BinderTester::case2281(){ } -void BinderTester::case2282(){ } -void BinderTester::case2283(){ } -void BinderTester::case2284(){ } -void BinderTester::case2285(){ } -void BinderTester::case2286(){ } -void BinderTester::case2287(){ } -void BinderTester::case2288(){ } -void BinderTester::case2289(){ } -void BinderTester::case2290(){ } -void BinderTester::case2291(){ } -void BinderTester::case2292(){ } -void BinderTester::case2293(){ } -void BinderTester::case2294(){ } -void BinderTester::case2295(){ } -void BinderTester::case2296(){ } -void BinderTester::case2297(){ } -void BinderTester::case2298(){ } -void BinderTester::case2299(){ } - -void BinderTester::case2300() -{ - bind(R"( + Expectation().binding(DeclSummary() + .Value("z", ValueKind::Field) + .TySpec.basis("struct x", + NamedTypeKind::Structure, + BuiltinTypeKind::UNSPECIFIED))); +} + +void BinderTester::case2014() {} +void BinderTester::case2015() {} +void BinderTester::case2016() {} +void BinderTester::case2017() {} +void BinderTester::case2018() {} +void BinderTester::case2019() {} +void BinderTester::case2020() {} +void BinderTester::case2021() {} +void BinderTester::case2022() {} +void BinderTester::case2023() {} +void BinderTester::case2024() {} +void BinderTester::case2025() {} +void BinderTester::case2026() {} +void BinderTester::case2027() {} +void BinderTester::case2028() {} +void BinderTester::case2029() {} +void BinderTester::case2030() {} +void BinderTester::case2031() {} +void BinderTester::case2032() {} +void BinderTester::case2033() {} +void BinderTester::case2034() {} +void BinderTester::case2035() {} +void BinderTester::case2036() {} +void BinderTester::case2037() {} +void BinderTester::case2038() {} +void BinderTester::case2039() {} +void BinderTester::case2040() {} +void BinderTester::case2041() {} +void BinderTester::case2042() {} +void BinderTester::case2043() {} +void BinderTester::case2044() {} +void BinderTester::case2045() {} +void BinderTester::case2046() {} +void BinderTester::case2047() {} +void BinderTester::case2048() {} +void BinderTester::case2049() {} + +void BinderTester::case2050() { + bind("struct { const int x ; } ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, + CVR::Const))); +} + +void BinderTester::case2051() { + bind("struct { const x y ; } ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, + CVR::Const))); +} + +void BinderTester::case2052() { + bind("struct { const x ; } ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + ConstraintsInDeclarations::ID_of_UselessDeclaration)); +} + +void BinderTester::case2053() { + bind("struct { int const x ; } ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, + CVR::Const))); +} + +void BinderTester::case2054() { + bind("struct { x const y ; } ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, + CVR::Const))); +} + +void BinderTester::case2055() {} +void BinderTester::case2056() {} +void BinderTester::case2057() {} +void BinderTester::case2058() {} +void BinderTester::case2059() {} +void BinderTester::case2060() {} +void BinderTester::case2061() {} +void BinderTester::case2062() {} +void BinderTester::case2063() {} +void BinderTester::case2064() {} +void BinderTester::case2065() {} +void BinderTester::case2066() {} +void BinderTester::case2067() {} +void BinderTester::case2068() {} +void BinderTester::case2069() {} +void BinderTester::case2070() {} +void BinderTester::case2071() {} +void BinderTester::case2072() {} +void BinderTester::case2073() {} +void BinderTester::case2074() {} +void BinderTester::case2075() {} +void BinderTester::case2076() {} +void BinderTester::case2077() {} +void BinderTester::case2078() {} +void BinderTester::case2079() {} +void BinderTester::case2080() {} +void BinderTester::case2081() {} +void BinderTester::case2082() {} +void BinderTester::case2083() {} +void BinderTester::case2084() {} +void BinderTester::case2085() {} +void BinderTester::case2086() {} +void BinderTester::case2087() {} +void BinderTester::case2088() {} +void BinderTester::case2089() {} +void BinderTester::case2090() {} +void BinderTester::case2091() {} +void BinderTester::case2092() {} +void BinderTester::case2093() {} +void BinderTester::case2094() {} +void BinderTester::case2095() {} +void BinderTester::case2096() {} +void BinderTester::case2097() {} +void BinderTester::case2098() {} +void BinderTester::case2099() {} + +void BinderTester::case2100() { + bind( + "struct { int * x ; } ;", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2101() { + bind("struct { x * y ; } ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec.basis("x", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2102() { + bind("struct { int * x ; y * z ; } ;", + Expectation() + .binding( + DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer)) + .binding(DeclSummary() + .Value("z", ValueKind::Field) + .TySpec.basis("y", NamedTypeKind::Synonym) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2103() { + bind("struct { int * x , * y ; } ;", + Expectation() + .binding( + DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer)) + .binding( + DeclSummary() + .Value("y", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2104() { + bind( + "struct { int ( * x ) [ 1 ]; } ;", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Array) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2105() { + bind( + "struct { int * * x ; } ;", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2106() { + bind( + "struct { int * * * x ; } ;", + Expectation().binding( + DeclSummary() + .Value("x", ValueKind::Field) + .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2107() { + bind("struct { int * ( * x ) [ 1 ] ; };", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None))); +} + +void BinderTester::case2108() {} +void BinderTester::case2109() {} +void BinderTester::case2110() {} +void BinderTester::case2111() {} +void BinderTester::case2112() {} +void BinderTester::case2113() {} +void BinderTester::case2114() {} +void BinderTester::case2115() {} +void BinderTester::case2116() {} +void BinderTester::case2117() {} +void BinderTester::case2118() {} +void BinderTester::case2119() {} +void BinderTester::case2120() {} +void BinderTester::case2121() {} +void BinderTester::case2122() {} +void BinderTester::case2123() {} +void BinderTester::case2124() {} +void BinderTester::case2125() {} +void BinderTester::case2126() {} +void BinderTester::case2127() {} +void BinderTester::case2128() {} +void BinderTester::case2129() {} +void BinderTester::case2130() {} +void BinderTester::case2131() {} +void BinderTester::case2132() {} +void BinderTester::case2133() {} +void BinderTester::case2134() {} +void BinderTester::case2135() {} +void BinderTester::case2136() {} +void BinderTester::case2137() {} +void BinderTester::case2138() {} +void BinderTester::case2139() {} +void BinderTester::case2140() {} +void BinderTester::case2141() {} +void BinderTester::case2142() {} +void BinderTester::case2143() {} +void BinderTester::case2144() {} +void BinderTester::case2145() {} +void BinderTester::case2146() {} +void BinderTester::case2147() {} +void BinderTester::case2148() {} +void BinderTester::case2149() {} + +void BinderTester::case2150() { + bind("struct { const int * x ; } ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::Const) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2151() { + bind( + "struct { const x * y ; } ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::Const) + .TySpec.deriv(TypeKind::Pointer))); +} + +void BinderTester::case2152() {} +void BinderTester::case2153() {} +void BinderTester::case2154() {} +void BinderTester::case2155() {} +void BinderTester::case2156() {} +void BinderTester::case2157() {} +void BinderTester::case2158() {} +void BinderTester::case2159() {} +void BinderTester::case2160() {} +void BinderTester::case2161() {} +void BinderTester::case2162() {} +void BinderTester::case2163() {} +void BinderTester::case2164() {} +void BinderTester::case2165() {} +void BinderTester::case2166() {} +void BinderTester::case2167() {} +void BinderTester::case2168() {} +void BinderTester::case2169() {} +void BinderTester::case2170() {} +void BinderTester::case2171() {} +void BinderTester::case2172() {} +void BinderTester::case2173() {} +void BinderTester::case2174() {} +void BinderTester::case2175() {} +void BinderTester::case2176() {} +void BinderTester::case2177() {} +void BinderTester::case2178() {} +void BinderTester::case2179() {} +void BinderTester::case2180() {} +void BinderTester::case2181() {} +void BinderTester::case2182() {} +void BinderTester::case2183() {} +void BinderTester::case2184() {} +void BinderTester::case2185() {} +void BinderTester::case2186() {} +void BinderTester::case2187() {} +void BinderTester::case2188() {} +void BinderTester::case2189() {} +void BinderTester::case2190() {} +void BinderTester::case2191() {} +void BinderTester::case2192() {} +void BinderTester::case2193() {} +void BinderTester::case2194() {} +void BinderTester::case2195() {} +void BinderTester::case2196() {} +void BinderTester::case2197() {} +void BinderTester::case2198() {} +void BinderTester::case2199() {} + +void BinderTester::case2200() { + bind("struct { const int * const x ; } ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::Const) + .TySpec.deriv(TypeKind::Pointer, CVR::Const))); +} + +void BinderTester::case2201() {} +void BinderTester::case2202() {} +void BinderTester::case2203() {} +void BinderTester::case2204() {} +void BinderTester::case2205() {} +void BinderTester::case2206() {} +void BinderTester::case2207() {} +void BinderTester::case2208() {} +void BinderTester::case2209() {} +void BinderTester::case2210() {} +void BinderTester::case2211() {} +void BinderTester::case2212() {} +void BinderTester::case2213() {} +void BinderTester::case2214() {} +void BinderTester::case2215() {} +void BinderTester::case2216() {} +void BinderTester::case2217() {} +void BinderTester::case2218() {} +void BinderTester::case2219() {} +void BinderTester::case2220() {} +void BinderTester::case2221() {} +void BinderTester::case2222() {} +void BinderTester::case2223() {} +void BinderTester::case2224() {} +void BinderTester::case2225() {} +void BinderTester::case2226() {} +void BinderTester::case2227() {} +void BinderTester::case2228() {} +void BinderTester::case2229() {} +void BinderTester::case2230() {} +void BinderTester::case2231() {} +void BinderTester::case2232() {} +void BinderTester::case2233() {} +void BinderTester::case2234() {} +void BinderTester::case2235() {} +void BinderTester::case2236() {} +void BinderTester::case2237() {} +void BinderTester::case2238() {} +void BinderTester::case2239() {} +void BinderTester::case2240() {} +void BinderTester::case2241() {} +void BinderTester::case2242() {} +void BinderTester::case2243() {} +void BinderTester::case2244() {} +void BinderTester::case2245() {} +void BinderTester::case2246() {} +void BinderTester::case2247() {} +void BinderTester::case2248() {} +void BinderTester::case2249() {} + +void BinderTester::case2250() { + bind("struct { int * const x ; } ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::Const))); +} + +void BinderTester::case2251() { + bind("struct { x * const y ; } ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::Const))); +} + +void BinderTester::case2252() {} +void BinderTester::case2253() {} +void BinderTester::case2254() {} +void BinderTester::case2255() {} +void BinderTester::case2256() {} +void BinderTester::case2257() {} +void BinderTester::case2258() {} +void BinderTester::case2259() {} +void BinderTester::case2260() {} +void BinderTester::case2261() {} +void BinderTester::case2262() {} +void BinderTester::case2263() {} +void BinderTester::case2264() {} +void BinderTester::case2265() {} +void BinderTester::case2266() {} +void BinderTester::case2267() {} +void BinderTester::case2268() {} +void BinderTester::case2269() {} +void BinderTester::case2270() {} +void BinderTester::case2271() {} +void BinderTester::case2272() {} +void BinderTester::case2273() {} +void BinderTester::case2274() {} +void BinderTester::case2275() {} +void BinderTester::case2276() {} +void BinderTester::case2277() {} +void BinderTester::case2278() {} +void BinderTester::case2279() {} +void BinderTester::case2280() {} +void BinderTester::case2281() {} +void BinderTester::case2282() {} +void BinderTester::case2283() {} +void BinderTester::case2284() {} +void BinderTester::case2285() {} +void BinderTester::case2286() {} +void BinderTester::case2287() {} +void BinderTester::case2288() {} +void BinderTester::case2289() {} +void BinderTester::case2290() {} +void BinderTester::case2291() {} +void BinderTester::case2292() {} +void BinderTester::case2293() {} +void BinderTester::case2294() {} +void BinderTester::case2295() {} +void BinderTester::case2296() {} +void BinderTester::case2297() {} +void BinderTester::case2298() {} +void BinderTester::case2299() {} + +void BinderTester::case2300() { + bind(R"( struct { int x [ 1 ] ; }; )", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case2301() -{ - bind("struct { x y [ 1 ] ; } ;", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case2302() -{ - bind(R"( + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case2301() { + bind("struct { x y [ 1 ] ; } ;", + Expectation().binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case2302() { + bind(R"( struct { int x [ 1 ] , y [ 2 ] ; }; )", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None)) - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case2303() -{ - bind(R"( + Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None)) + .binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case2303() { + bind(R"( struct { x y [ 1 ] , z [ 2 ] ; }; )", - Expectation() - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None)) - .binding(DeclSummary().Value("z", ValueKind::Field) - .TySpec.basis("x", NamedTypeKind::Synonym, BuiltinTypeKind::UNSPECIFIED, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case2304() -{ - bind("struct { int * x [ 1 ] ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case2305() -{ - bind("struct { int x [ 1 ] , * y [ 2 ] ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None)) - .binding(DeclSummary().Value("y", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case2306() -{ - bind("struct { int * * x [ 1 ] ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Pointer, CVR::None) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case2307(){ } -void BinderTester::case2308(){ } -void BinderTester::case2309(){ } -void BinderTester::case2310(){ } -void BinderTester::case2311(){ } -void BinderTester::case2312(){ } -void BinderTester::case2313(){ } -void BinderTester::case2314(){ } -void BinderTester::case2315(){ } -void BinderTester::case2316(){ } -void BinderTester::case2317(){ } -void BinderTester::case2318(){ } -void BinderTester::case2319(){ } -void BinderTester::case2320(){ } -void BinderTester::case2321(){ } -void BinderTester::case2322(){ } -void BinderTester::case2323(){ } -void BinderTester::case2324(){ } -void BinderTester::case2325(){ } -void BinderTester::case2326(){ } -void BinderTester::case2327(){ } -void BinderTester::case2328(){ } -void BinderTester::case2329(){ } -void BinderTester::case2330(){ } -void BinderTester::case2331(){ } -void BinderTester::case2332(){ } -void BinderTester::case2333(){ } -void BinderTester::case2334(){ } -void BinderTester::case2335(){ } -void BinderTester::case2336(){ } -void BinderTester::case2337(){ } -void BinderTester::case2338(){ } -void BinderTester::case2339(){ } -void BinderTester::case2340(){ } -void BinderTester::case2341(){ } -void BinderTester::case2342(){ } -void BinderTester::case2343(){ } -void BinderTester::case2344(){ } -void BinderTester::case2345(){ } -void BinderTester::case2346(){ } -void BinderTester::case2347(){ } -void BinderTester::case2348(){ } -void BinderTester::case2349(){ } - -void BinderTester::case2350() -{ - bind("struct { const int x [ 1 ] ; } ;", - Expectation() - .binding(DeclSummary().Value("x", ValueKind::Field) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int, CVR::Const) - .TySpec.deriv(TypeKind::Array, CVR::None))); -} - -void BinderTester::case2351(){ } -void BinderTester::case2352(){ } -void BinderTester::case2353(){ } -void BinderTester::case2354(){ } -void BinderTester::case2355(){ } -void BinderTester::case2356(){ } -void BinderTester::case2357(){ } -void BinderTester::case2358(){ } -void BinderTester::case2359(){ } -void BinderTester::case2360(){ } -void BinderTester::case2361(){ } -void BinderTester::case2362(){ } -void BinderTester::case2363(){ } -void BinderTester::case2364(){ } -void BinderTester::case2365(){ } -void BinderTester::case2366(){ } -void BinderTester::case2367(){ } -void BinderTester::case2368(){ } -void BinderTester::case2369(){ } -void BinderTester::case2370(){ } -void BinderTester::case2371(){ } -void BinderTester::case2372(){ } -void BinderTester::case2373(){ } -void BinderTester::case2374(){ } -void BinderTester::case2375(){ } -void BinderTester::case2376(){ } -void BinderTester::case2377(){ } -void BinderTester::case2378(){ } -void BinderTester::case2379(){ } -void BinderTester::case2380(){ } -void BinderTester::case2381(){ } -void BinderTester::case2382(){ } -void BinderTester::case2383(){ } -void BinderTester::case2384(){ } -void BinderTester::case2385(){ } -void BinderTester::case2386(){ } -void BinderTester::case2387(){ } -void BinderTester::case2388(){ } -void BinderTester::case2389(){ } -void BinderTester::case2390(){ } -void BinderTester::case2391(){ } -void BinderTester::case2392(){ } -void BinderTester::case2393(){ } -void BinderTester::case2394(){ } -void BinderTester::case2395(){ } -void BinderTester::case2396(){ } -void BinderTester::case2397(){ } -void BinderTester::case2398(){ } -void BinderTester::case2399(){ } + Expectation() + .binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None)) + .binding(DeclSummary() + .Value("z", ValueKind::Field) + .TySpec + .basis("x", NamedTypeKind::Synonym, + BuiltinTypeKind::UNSPECIFIED, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case2304() { + bind("struct { int * x [ 1 ] ; } ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case2305() { + bind("struct { int x [ 1 ] , * y [ 2 ] ; } ;", + Expectation() + .binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None)) + .binding(DeclSummary() + .Value("y", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case2306() { + bind("struct { int * * x [ 1 ] ; } ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Pointer, CVR::None) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case2307() {} +void BinderTester::case2308() {} +void BinderTester::case2309() {} +void BinderTester::case2310() {} +void BinderTester::case2311() {} +void BinderTester::case2312() {} +void BinderTester::case2313() {} +void BinderTester::case2314() {} +void BinderTester::case2315() {} +void BinderTester::case2316() {} +void BinderTester::case2317() {} +void BinderTester::case2318() {} +void BinderTester::case2319() {} +void BinderTester::case2320() {} +void BinderTester::case2321() {} +void BinderTester::case2322() {} +void BinderTester::case2323() {} +void BinderTester::case2324() {} +void BinderTester::case2325() {} +void BinderTester::case2326() {} +void BinderTester::case2327() {} +void BinderTester::case2328() {} +void BinderTester::case2329() {} +void BinderTester::case2330() {} +void BinderTester::case2331() {} +void BinderTester::case2332() {} +void BinderTester::case2333() {} +void BinderTester::case2334() {} +void BinderTester::case2335() {} +void BinderTester::case2336() {} +void BinderTester::case2337() {} +void BinderTester::case2338() {} +void BinderTester::case2339() {} +void BinderTester::case2340() {} +void BinderTester::case2341() {} +void BinderTester::case2342() {} +void BinderTester::case2343() {} +void BinderTester::case2344() {} +void BinderTester::case2345() {} +void BinderTester::case2346() {} +void BinderTester::case2347() {} +void BinderTester::case2348() {} +void BinderTester::case2349() {} + +void BinderTester::case2350() { + bind("struct { const int x [ 1 ] ; } ;", + Expectation().binding(DeclSummary() + .Value("x", ValueKind::Field) + .TySpec + .basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int, CVR::Const) + .TySpec.deriv(TypeKind::Array, CVR::None))); +} + +void BinderTester::case2351() {} +void BinderTester::case2352() {} +void BinderTester::case2353() {} +void BinderTester::case2354() {} +void BinderTester::case2355() {} +void BinderTester::case2356() {} +void BinderTester::case2357() {} +void BinderTester::case2358() {} +void BinderTester::case2359() {} +void BinderTester::case2360() {} +void BinderTester::case2361() {} +void BinderTester::case2362() {} +void BinderTester::case2363() {} +void BinderTester::case2364() {} +void BinderTester::case2365() {} +void BinderTester::case2366() {} +void BinderTester::case2367() {} +void BinderTester::case2368() {} +void BinderTester::case2369() {} +void BinderTester::case2370() {} +void BinderTester::case2371() {} +void BinderTester::case2372() {} +void BinderTester::case2373() {} +void BinderTester::case2374() {} +void BinderTester::case2375() {} +void BinderTester::case2376() {} +void BinderTester::case2377() {} +void BinderTester::case2378() {} +void BinderTester::case2379() {} +void BinderTester::case2380() {} +void BinderTester::case2381() {} +void BinderTester::case2382() {} +void BinderTester::case2383() {} +void BinderTester::case2384() {} +void BinderTester::case2385() {} +void BinderTester::case2386() {} +void BinderTester::case2387() {} +void BinderTester::case2388() {} +void BinderTester::case2389() {} +void BinderTester::case2390() {} +void BinderTester::case2391() {} +void BinderTester::case2392() {} +void BinderTester::case2393() {} +void BinderTester::case2394() {} +void BinderTester::case2395() {} +void BinderTester::case2396() {} +void BinderTester::case2397() {} +void BinderTester::case2398() {} +void BinderTester::case2399() {} diff --git a/C/tests/BinderTester_3000_3999.cpp b/C/tests/BinderTester_3000_3999.cpp index 41dbfbd06..8eabe402e 100644 --- a/C/tests/BinderTester_3000_3999.cpp +++ b/C/tests/BinderTester_3000_3999.cpp @@ -21,732 +21,735 @@ #include "BinderTester.h" #include "ParserTester.h" -#include "syntax/SyntaxLexeme_ALL.h" #include "parser/Unparser.h" +#include "syntax/SyntaxLexeme_ALL.h" #include "syntax/SyntaxNodes.h" #include #include #include -#include #include +#include using namespace psy; using namespace C; -void BinderTester::case3001() -{ - bind("struct x { int y ; } ;", - Expectation() - .binding(DeclSummary() - .Type("struct x", NamedTypeKind::Structure) - .withNameKind(SymbolNameKind::Tag) - .withNameSpaceKind(NameSpaceKind::Tags) - .withTagChoice(TagSymbolName::TagChoice::Struct) - .withScopeKind(ScopeKind::File))); +void BinderTester::case3001() { + bind( + "struct x { int y ; } ;", + Expectation().binding(DeclSummary() + .Type("struct x", NamedTypeKind::Structure) + .withNameKind(SymbolNameKind::Tag) + .withNameSpaceKind(NameSpaceKind::Tags) + .withTagChoice(TagSymbolName::TagChoice::Struct) + .withScopeKind(ScopeKind::File))); } -void BinderTester::case3002() -{ - bind("union x { int y ; } ;", - Expectation() - .binding(DeclSummary() - .Type("union x", NamedTypeKind::Union) - .withNameKind(SymbolNameKind::Tag) - .withNameSpaceKind(NameSpaceKind::Tags) - .withTagChoice(TagSymbolName::TagChoice::Union) - .withScopeKind(ScopeKind::File))); +void BinderTester::case3002() { + bind("union x { int y ; } ;", + Expectation().binding(DeclSummary() + .Type("union x", NamedTypeKind::Union) + .withNameKind(SymbolNameKind::Tag) + .withNameSpaceKind(NameSpaceKind::Tags) + .withTagChoice(TagSymbolName::TagChoice::Union) + .withScopeKind(ScopeKind::File))); } -void BinderTester::case3003(){} -void BinderTester::case3004(){} -void BinderTester::case3005(){} -void BinderTester::case3006(){} -void BinderTester::case3007(){} -void BinderTester::case3008(){} -void BinderTester::case3009(){} -void BinderTester::case3010(){} -void BinderTester::case3011(){} -void BinderTester::case3012(){} -void BinderTester::case3013(){} -void BinderTester::case3014(){} -void BinderTester::case3015(){} -void BinderTester::case3016(){} -void BinderTester::case3017(){} -void BinderTester::case3018(){} -void BinderTester::case3019(){} -void BinderTester::case3020(){} -void BinderTester::case3021(){} -void BinderTester::case3022(){} -void BinderTester::case3023(){} -void BinderTester::case3024(){} -void BinderTester::case3025(){} -void BinderTester::case3026(){} -void BinderTester::case3027(){} -void BinderTester::case3028(){} -void BinderTester::case3029(){} -void BinderTester::case3030(){} -void BinderTester::case3031(){} -void BinderTester::case3032(){} -void BinderTester::case3033(){} -void BinderTester::case3034(){} -void BinderTester::case3035(){} -void BinderTester::case3036(){} -void BinderTester::case3037(){} -void BinderTester::case3038(){} -void BinderTester::case3039(){} -void BinderTester::case3040(){} -void BinderTester::case3041(){} -void BinderTester::case3042(){} -void BinderTester::case3043(){} -void BinderTester::case3044(){} -void BinderTester::case3045(){} -void BinderTester::case3046(){} -void BinderTester::case3047(){} -void BinderTester::case3048(){} -void BinderTester::case3049(){} +void BinderTester::case3003() {} +void BinderTester::case3004() {} +void BinderTester::case3005() {} +void BinderTester::case3006() {} +void BinderTester::case3007() {} +void BinderTester::case3008() {} +void BinderTester::case3009() {} +void BinderTester::case3010() {} +void BinderTester::case3011() {} +void BinderTester::case3012() {} +void BinderTester::case3013() {} +void BinderTester::case3014() {} +void BinderTester::case3015() {} +void BinderTester::case3016() {} +void BinderTester::case3017() {} +void BinderTester::case3018() {} +void BinderTester::case3019() {} +void BinderTester::case3020() {} +void BinderTester::case3021() {} +void BinderTester::case3022() {} +void BinderTester::case3023() {} +void BinderTester::case3024() {} +void BinderTester::case3025() {} +void BinderTester::case3026() {} +void BinderTester::case3027() {} +void BinderTester::case3028() {} +void BinderTester::case3029() {} +void BinderTester::case3030() {} +void BinderTester::case3031() {} +void BinderTester::case3032() {} +void BinderTester::case3033() {} +void BinderTester::case3034() {} +void BinderTester::case3035() {} +void BinderTester::case3036() {} +void BinderTester::case3037() {} +void BinderTester::case3038() {} +void BinderTester::case3039() {} +void BinderTester::case3040() {} +void BinderTester::case3041() {} +void BinderTester::case3042() {} +void BinderTester::case3043() {} +void BinderTester::case3044() {} +void BinderTester::case3045() {} +void BinderTester::case3046() {} +void BinderTester::case3047() {} +void BinderTester::case3048() {} +void BinderTester::case3049() {} -void BinderTester::case3050() -{ - bind("enum x { y } ;", - Expectation() - .binding(DeclSummary() - .Type("enum x", NamedTypeKind::Enumeration) - .withNameKind(SymbolNameKind::Tag) - .withNameSpaceKind(NameSpaceKind::Tags) - .withTagChoice(TagSymbolName::TagChoice::Enum) - .withScopeKind(ScopeKind::File)) - .binding(DeclSummary() - .Value("y", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); +void BinderTester::case3050() { + bind("enum x { y } ;", + Expectation() + .binding(DeclSummary() + .Type("enum x", NamedTypeKind::Enumeration) + .withNameKind(SymbolNameKind::Tag) + .withNameSpaceKind(NameSpaceKind::Tags) + .withTagChoice(TagSymbolName::TagChoice::Enum) + .withScopeKind(ScopeKind::File)) + .binding(DeclSummary() + .Value("y", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); } -void BinderTester::case3051() -{ - bind("enum x { y , z } ;", - Expectation() - .binding(DeclSummary() - .Type("enum x", NamedTypeKind::Enumeration) - .withNameKind(SymbolNameKind::Tag) - .withNameSpaceKind(NameSpaceKind::Tags) - .withTagChoice(TagSymbolName::TagChoice::Enum) - .withScopeKind(ScopeKind::File)) - .binding(DeclSummary() - .Value("y", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); +void BinderTester::case3051() { + bind("enum x { y , z } ;", + Expectation() + .binding(DeclSummary() + .Type("enum x", NamedTypeKind::Enumeration) + .withNameKind(SymbolNameKind::Tag) + .withNameSpaceKind(NameSpaceKind::Tags) + .withTagChoice(TagSymbolName::TagChoice::Enum) + .withScopeKind(ScopeKind::File)) + .binding(DeclSummary() + .Value("y", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); } -void BinderTester::case3052() -{ - bind("enum x { y = 0 , z } ;", - Expectation() - .binding(DeclSummary() - .Type("enum x", NamedTypeKind::Enumeration) - .withNameKind(SymbolNameKind::Tag) - .withNameSpaceKind(NameSpaceKind::Tags) - .withTagChoice(TagSymbolName::TagChoice::Enum) - .withScopeKind(ScopeKind::File)) - .binding(DeclSummary() - .Value("y", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); +void BinderTester::case3052() { + bind("enum x { y = 0 , z } ;", + Expectation() + .binding(DeclSummary() + .Type("enum x", NamedTypeKind::Enumeration) + .withNameKind(SymbolNameKind::Tag) + .withNameSpaceKind(NameSpaceKind::Tags) + .withTagChoice(TagSymbolName::TagChoice::Enum) + .withScopeKind(ScopeKind::File)) + .binding(DeclSummary() + .Value("y", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); } -void BinderTester::case3053() -{ - bind("enum x { y , z , w } ;", - Expectation() - .binding(DeclSummary() - .Type("enum x", NamedTypeKind::Enumeration) - .withNameKind(SymbolNameKind::Tag) - .withNameSpaceKind(NameSpaceKind::Tags) - .withTagChoice(TagSymbolName::TagChoice::Enum) - .withScopeKind(ScopeKind::File)) - .binding(DeclSummary() - .Value("y", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("w", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); +void BinderTester::case3053() { + bind("enum x { y , z , w } ;", + Expectation() + .binding(DeclSummary() + .Type("enum x", NamedTypeKind::Enumeration) + .withNameKind(SymbolNameKind::Tag) + .withNameSpaceKind(NameSpaceKind::Tags) + .withTagChoice(TagSymbolName::TagChoice::Enum) + .withScopeKind(ScopeKind::File)) + .binding(DeclSummary() + .Value("y", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("w", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); } -void BinderTester::case3054() -{ - bind("enum x { y , z = 0 , w } ;", - Expectation() - .binding(DeclSummary() - .Type("enum x", NamedTypeKind::Enumeration) - .withNameKind(SymbolNameKind::Tag) - .withNameSpaceKind(NameSpaceKind::Tags) - .withTagChoice(TagSymbolName::TagChoice::Enum) - .withScopeKind(ScopeKind::File)) - .binding(DeclSummary() - .Value("y", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("z", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int)) - .binding(DeclSummary() - .Value("w", ValueKind::Enumerator) - .TySpec.basis("int", NamedTypeKind::Builtin, BuiltinTypeKind::Int))); +void BinderTester::case3054() { + bind("enum x { y , z = 0 , w } ;", + Expectation() + .binding(DeclSummary() + .Type("enum x", NamedTypeKind::Enumeration) + .withNameKind(SymbolNameKind::Tag) + .withNameSpaceKind(NameSpaceKind::Tags) + .withTagChoice(TagSymbolName::TagChoice::Enum) + .withScopeKind(ScopeKind::File)) + .binding(DeclSummary() + .Value("y", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("z", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int)) + .binding(DeclSummary() + .Value("w", ValueKind::Enumerator) + .TySpec.basis("int", NamedTypeKind::Builtin, + BuiltinTypeKind::Int))); } -void BinderTester::case3055(){} -void BinderTester::case3056(){} -void BinderTester::case3057(){} -void BinderTester::case3058(){} -void BinderTester::case3059(){} -void BinderTester::case3060(){} -void BinderTester::case3061(){} -void BinderTester::case3062(){} -void BinderTester::case3063(){} -void BinderTester::case3064(){} -void BinderTester::case3065(){} -void BinderTester::case3066(){} -void BinderTester::case3067(){} -void BinderTester::case3068(){} -void BinderTester::case3069(){} -void BinderTester::case3070(){} -void BinderTester::case3071(){} -void BinderTester::case3072(){} -void BinderTester::case3073(){} -void BinderTester::case3074(){} -void BinderTester::case3075(){} -void BinderTester::case3076(){} -void BinderTester::case3077(){} -void BinderTester::case3078(){} -void BinderTester::case3079(){} -void BinderTester::case3080(){} -void BinderTester::case3081(){} -void BinderTester::case3082(){} -void BinderTester::case3083(){} -void BinderTester::case3084(){} -void BinderTester::case3085(){} -void BinderTester::case3086(){} -void BinderTester::case3087(){} -void BinderTester::case3088(){} -void BinderTester::case3089(){} -void BinderTester::case3090(){} -void BinderTester::case3091(){} -void BinderTester::case3092(){} -void BinderTester::case3093(){} -void BinderTester::case3094(){} -void BinderTester::case3095(){} -void BinderTester::case3096(){} -void BinderTester::case3097(){} -void BinderTester::case3098(){} -void BinderTester::case3099(){} +void BinderTester::case3055() {} +void BinderTester::case3056() {} +void BinderTester::case3057() {} +void BinderTester::case3058() {} +void BinderTester::case3059() {} +void BinderTester::case3060() {} +void BinderTester::case3061() {} +void BinderTester::case3062() {} +void BinderTester::case3063() {} +void BinderTester::case3064() {} +void BinderTester::case3065() {} +void BinderTester::case3066() {} +void BinderTester::case3067() {} +void BinderTester::case3068() {} +void BinderTester::case3069() {} +void BinderTester::case3070() {} +void BinderTester::case3071() {} +void BinderTester::case3072() {} +void BinderTester::case3073() {} +void BinderTester::case3074() {} +void BinderTester::case3075() {} +void BinderTester::case3076() {} +void BinderTester::case3077() {} +void BinderTester::case3078() {} +void BinderTester::case3079() {} +void BinderTester::case3080() {} +void BinderTester::case3081() {} +void BinderTester::case3082() {} +void BinderTester::case3083() {} +void BinderTester::case3084() {} +void BinderTester::case3085() {} +void BinderTester::case3086() {} +void BinderTester::case3087() {} +void BinderTester::case3088() {} +void BinderTester::case3089() {} +void BinderTester::case3090() {} +void BinderTester::case3091() {} +void BinderTester::case3092() {} +void BinderTester::case3093() {} +void BinderTester::case3094() {} +void BinderTester::case3095() {} +void BinderTester::case3096() {} +void BinderTester::case3097() {} +void BinderTester::case3098() {} +void BinderTester::case3099() {} -void BinderTester::case3100(){} -void BinderTester::case3101(){} -void BinderTester::case3102(){} -void BinderTester::case3103(){} -void BinderTester::case3104(){} -void BinderTester::case3105(){} -void BinderTester::case3106(){} -void BinderTester::case3107(){} -void BinderTester::case3108(){} -void BinderTester::case3109(){} -void BinderTester::case3110(){} -void BinderTester::case3111(){} -void BinderTester::case3112(){} -void BinderTester::case3113(){} -void BinderTester::case3114(){} -void BinderTester::case3115(){} -void BinderTester::case3116(){} -void BinderTester::case3117(){} -void BinderTester::case3118(){} -void BinderTester::case3119(){} -void BinderTester::case3120(){} -void BinderTester::case3121(){} -void BinderTester::case3122(){} -void BinderTester::case3123(){} -void BinderTester::case3124(){} -void BinderTester::case3125(){} -void BinderTester::case3126(){} -void BinderTester::case3127(){} -void BinderTester::case3128(){} -void BinderTester::case3129(){} -void BinderTester::case3130(){} -void BinderTester::case3131(){} -void BinderTester::case3132(){} -void BinderTester::case3133(){} -void BinderTester::case3134(){} -void BinderTester::case3135(){} -void BinderTester::case3136(){} -void BinderTester::case3137(){} -void BinderTester::case3138(){} -void BinderTester::case3139(){} -void BinderTester::case3140(){} -void BinderTester::case3141(){} -void BinderTester::case3142(){} -void BinderTester::case3143(){} -void BinderTester::case3144(){} -void BinderTester::case3145(){} -void BinderTester::case3146(){} -void BinderTester::case3147(){} -void BinderTester::case3148(){} -void BinderTester::case3149(){} -void BinderTester::case3150(){} -void BinderTester::case3151(){} -void BinderTester::case3152(){} -void BinderTester::case3153(){} -void BinderTester::case3154(){} -void BinderTester::case3155(){} -void BinderTester::case3156(){} -void BinderTester::case3157(){} -void BinderTester::case3158(){} -void BinderTester::case3159(){} -void BinderTester::case3160(){} -void BinderTester::case3161(){} -void BinderTester::case3162(){} -void BinderTester::case3163(){} -void BinderTester::case3164(){} -void BinderTester::case3165(){} -void BinderTester::case3166(){} -void BinderTester::case3167(){} -void BinderTester::case3168(){} -void BinderTester::case3169(){} -void BinderTester::case3170(){} -void BinderTester::case3171(){} -void BinderTester::case3172(){} -void BinderTester::case3173(){} -void BinderTester::case3174(){} -void BinderTester::case3175(){} -void BinderTester::case3176(){} -void BinderTester::case3177(){} -void BinderTester::case3178(){} -void BinderTester::case3179(){} -void BinderTester::case3180(){} -void BinderTester::case3181(){} -void BinderTester::case3182(){} -void BinderTester::case3183(){} -void BinderTester::case3184(){} -void BinderTester::case3185(){} -void BinderTester::case3186(){} -void BinderTester::case3187(){} -void BinderTester::case3188(){} -void BinderTester::case3189(){} -void BinderTester::case3190(){} -void BinderTester::case3191(){} -void BinderTester::case3192(){} -void BinderTester::case3193(){} -void BinderTester::case3194(){} -void BinderTester::case3195(){} -void BinderTester::case3196(){} -void BinderTester::case3197(){} -void BinderTester::case3198(){} -void BinderTester::case3199(){} +void BinderTester::case3100() {} +void BinderTester::case3101() {} +void BinderTester::case3102() {} +void BinderTester::case3103() {} +void BinderTester::case3104() {} +void BinderTester::case3105() {} +void BinderTester::case3106() {} +void BinderTester::case3107() {} +void BinderTester::case3108() {} +void BinderTester::case3109() {} +void BinderTester::case3110() {} +void BinderTester::case3111() {} +void BinderTester::case3112() {} +void BinderTester::case3113() {} +void BinderTester::case3114() {} +void BinderTester::case3115() {} +void BinderTester::case3116() {} +void BinderTester::case3117() {} +void BinderTester::case3118() {} +void BinderTester::case3119() {} +void BinderTester::case3120() {} +void BinderTester::case3121() {} +void BinderTester::case3122() {} +void BinderTester::case3123() {} +void BinderTester::case3124() {} +void BinderTester::case3125() {} +void BinderTester::case3126() {} +void BinderTester::case3127() {} +void BinderTester::case3128() {} +void BinderTester::case3129() {} +void BinderTester::case3130() {} +void BinderTester::case3131() {} +void BinderTester::case3132() {} +void BinderTester::case3133() {} +void BinderTester::case3134() {} +void BinderTester::case3135() {} +void BinderTester::case3136() {} +void BinderTester::case3137() {} +void BinderTester::case3138() {} +void BinderTester::case3139() {} +void BinderTester::case3140() {} +void BinderTester::case3141() {} +void BinderTester::case3142() {} +void BinderTester::case3143() {} +void BinderTester::case3144() {} +void BinderTester::case3145() {} +void BinderTester::case3146() {} +void BinderTester::case3147() {} +void BinderTester::case3148() {} +void BinderTester::case3149() {} +void BinderTester::case3150() {} +void BinderTester::case3151() {} +void BinderTester::case3152() {} +void BinderTester::case3153() {} +void BinderTester::case3154() {} +void BinderTester::case3155() {} +void BinderTester::case3156() {} +void BinderTester::case3157() {} +void BinderTester::case3158() {} +void BinderTester::case3159() {} +void BinderTester::case3160() {} +void BinderTester::case3161() {} +void BinderTester::case3162() {} +void BinderTester::case3163() {} +void BinderTester::case3164() {} +void BinderTester::case3165() {} +void BinderTester::case3166() {} +void BinderTester::case3167() {} +void BinderTester::case3168() {} +void BinderTester::case3169() {} +void BinderTester::case3170() {} +void BinderTester::case3171() {} +void BinderTester::case3172() {} +void BinderTester::case3173() {} +void BinderTester::case3174() {} +void BinderTester::case3175() {} +void BinderTester::case3176() {} +void BinderTester::case3177() {} +void BinderTester::case3178() {} +void BinderTester::case3179() {} +void BinderTester::case3180() {} +void BinderTester::case3181() {} +void BinderTester::case3182() {} +void BinderTester::case3183() {} +void BinderTester::case3184() {} +void BinderTester::case3185() {} +void BinderTester::case3186() {} +void BinderTester::case3187() {} +void BinderTester::case3188() {} +void BinderTester::case3189() {} +void BinderTester::case3190() {} +void BinderTester::case3191() {} +void BinderTester::case3192() {} +void BinderTester::case3193() {} +void BinderTester::case3194() {} +void BinderTester::case3195() {} +void BinderTester::case3196() {} +void BinderTester::case3197() {} +void BinderTester::case3198() {} +void BinderTester::case3199() {} -void BinderTester::case3200(){} -void BinderTester::case3201(){} -void BinderTester::case3202(){} -void BinderTester::case3203(){} -void BinderTester::case3204(){} -void BinderTester::case3205(){} -void BinderTester::case3206(){} -void BinderTester::case3207(){} -void BinderTester::case3208(){} -void BinderTester::case3209(){} -void BinderTester::case3210(){} -void BinderTester::case3211(){} -void BinderTester::case3212(){} -void BinderTester::case3213(){} -void BinderTester::case3214(){} -void BinderTester::case3215(){} -void BinderTester::case3216(){} -void BinderTester::case3217(){} -void BinderTester::case3218(){} -void BinderTester::case3219(){} -void BinderTester::case3220(){} -void BinderTester::case3221(){} -void BinderTester::case3222(){} -void BinderTester::case3223(){} -void BinderTester::case3224(){} -void BinderTester::case3225(){} -void BinderTester::case3226(){} -void BinderTester::case3227(){} -void BinderTester::case3228(){} -void BinderTester::case3229(){} -void BinderTester::case3230(){} -void BinderTester::case3231(){} -void BinderTester::case3232(){} -void BinderTester::case3233(){} -void BinderTester::case3234(){} -void BinderTester::case3235(){} -void BinderTester::case3236(){} -void BinderTester::case3237(){} -void BinderTester::case3238(){} -void BinderTester::case3239(){} -void BinderTester::case3240(){} -void BinderTester::case3241(){} -void BinderTester::case3242(){} -void BinderTester::case3243(){} -void BinderTester::case3244(){} -void BinderTester::case3245(){} -void BinderTester::case3246(){} -void BinderTester::case3247(){} -void BinderTester::case3248(){} -void BinderTester::case3249(){} -void BinderTester::case3250(){} -void BinderTester::case3251(){} -void BinderTester::case3252(){} -void BinderTester::case3253(){} -void BinderTester::case3254(){} -void BinderTester::case3255(){} -void BinderTester::case3256(){} -void BinderTester::case3257(){} -void BinderTester::case3258(){} -void BinderTester::case3259(){} -void BinderTester::case3260(){} -void BinderTester::case3261(){} -void BinderTester::case3262(){} -void BinderTester::case3263(){} -void BinderTester::case3264(){} -void BinderTester::case3265(){} -void BinderTester::case3266(){} -void BinderTester::case3267(){} -void BinderTester::case3268(){} -void BinderTester::case3269(){} -void BinderTester::case3270(){} -void BinderTester::case3271(){} -void BinderTester::case3272(){} -void BinderTester::case3273(){} -void BinderTester::case3274(){} -void BinderTester::case3275(){} -void BinderTester::case3276(){} -void BinderTester::case3277(){} -void BinderTester::case3278(){} -void BinderTester::case3279(){} -void BinderTester::case3280(){} -void BinderTester::case3281(){} -void BinderTester::case3282(){} -void BinderTester::case3283(){} -void BinderTester::case3284(){} -void BinderTester::case3285(){} -void BinderTester::case3286(){} -void BinderTester::case3287(){} -void BinderTester::case3288(){} -void BinderTester::case3289(){} -void BinderTester::case3290(){} -void BinderTester::case3291(){} -void BinderTester::case3292(){} -void BinderTester::case3293(){} -void BinderTester::case3294(){} -void BinderTester::case3295(){} -void BinderTester::case3296(){} -void BinderTester::case3297(){} -void BinderTester::case3298(){} -void BinderTester::case3299(){} +void BinderTester::case3200() {} +void BinderTester::case3201() {} +void BinderTester::case3202() {} +void BinderTester::case3203() {} +void BinderTester::case3204() {} +void BinderTester::case3205() {} +void BinderTester::case3206() {} +void BinderTester::case3207() {} +void BinderTester::case3208() {} +void BinderTester::case3209() {} +void BinderTester::case3210() {} +void BinderTester::case3211() {} +void BinderTester::case3212() {} +void BinderTester::case3213() {} +void BinderTester::case3214() {} +void BinderTester::case3215() {} +void BinderTester::case3216() {} +void BinderTester::case3217() {} +void BinderTester::case3218() {} +void BinderTester::case3219() {} +void BinderTester::case3220() {} +void BinderTester::case3221() {} +void BinderTester::case3222() {} +void BinderTester::case3223() {} +void BinderTester::case3224() {} +void BinderTester::case3225() {} +void BinderTester::case3226() {} +void BinderTester::case3227() {} +void BinderTester::case3228() {} +void BinderTester::case3229() {} +void BinderTester::case3230() {} +void BinderTester::case3231() {} +void BinderTester::case3232() {} +void BinderTester::case3233() {} +void BinderTester::case3234() {} +void BinderTester::case3235() {} +void BinderTester::case3236() {} +void BinderTester::case3237() {} +void BinderTester::case3238() {} +void BinderTester::case3239() {} +void BinderTester::case3240() {} +void BinderTester::case3241() {} +void BinderTester::case3242() {} +void BinderTester::case3243() {} +void BinderTester::case3244() {} +void BinderTester::case3245() {} +void BinderTester::case3246() {} +void BinderTester::case3247() {} +void BinderTester::case3248() {} +void BinderTester::case3249() {} +void BinderTester::case3250() {} +void BinderTester::case3251() {} +void BinderTester::case3252() {} +void BinderTester::case3253() {} +void BinderTester::case3254() {} +void BinderTester::case3255() {} +void BinderTester::case3256() {} +void BinderTester::case3257() {} +void BinderTester::case3258() {} +void BinderTester::case3259() {} +void BinderTester::case3260() {} +void BinderTester::case3261() {} +void BinderTester::case3262() {} +void BinderTester::case3263() {} +void BinderTester::case3264() {} +void BinderTester::case3265() {} +void BinderTester::case3266() {} +void BinderTester::case3267() {} +void BinderTester::case3268() {} +void BinderTester::case3269() {} +void BinderTester::case3270() {} +void BinderTester::case3271() {} +void BinderTester::case3272() {} +void BinderTester::case3273() {} +void BinderTester::case3274() {} +void BinderTester::case3275() {} +void BinderTester::case3276() {} +void BinderTester::case3277() {} +void BinderTester::case3278() {} +void BinderTester::case3279() {} +void BinderTester::case3280() {} +void BinderTester::case3281() {} +void BinderTester::case3282() {} +void BinderTester::case3283() {} +void BinderTester::case3284() {} +void BinderTester::case3285() {} +void BinderTester::case3286() {} +void BinderTester::case3287() {} +void BinderTester::case3288() {} +void BinderTester::case3289() {} +void BinderTester::case3290() {} +void BinderTester::case3291() {} +void BinderTester::case3292() {} +void BinderTester::case3293() {} +void BinderTester::case3294() {} +void BinderTester::case3295() {} +void BinderTester::case3296() {} +void BinderTester::case3297() {} +void BinderTester::case3298() {} +void BinderTester::case3299() {} -void BinderTester::case3300(){} -void BinderTester::case3301(){} -void BinderTester::case3302(){} -void BinderTester::case3303(){} -void BinderTester::case3304(){} -void BinderTester::case3305(){} -void BinderTester::case3306(){} -void BinderTester::case3307(){} -void BinderTester::case3308(){} -void BinderTester::case3309(){} -void BinderTester::case3310(){} -void BinderTester::case3311(){} -void BinderTester::case3312(){} -void BinderTester::case3313(){} -void BinderTester::case3314(){} -void BinderTester::case3315(){} -void BinderTester::case3316(){} -void BinderTester::case3317(){} -void BinderTester::case3318(){} -void BinderTester::case3319(){} -void BinderTester::case3320(){} -void BinderTester::case3321(){} -void BinderTester::case3322(){} -void BinderTester::case3323(){} -void BinderTester::case3324(){} -void BinderTester::case3325(){} -void BinderTester::case3326(){} -void BinderTester::case3327(){} -void BinderTester::case3328(){} -void BinderTester::case3329(){} -void BinderTester::case3330(){} -void BinderTester::case3331(){} -void BinderTester::case3332(){} -void BinderTester::case3333(){} -void BinderTester::case3334(){} -void BinderTester::case3335(){} -void BinderTester::case3336(){} -void BinderTester::case3337(){} -void BinderTester::case3338(){} -void BinderTester::case3339(){} -void BinderTester::case3340(){} -void BinderTester::case3341(){} -void BinderTester::case3342(){} -void BinderTester::case3343(){} -void BinderTester::case3344(){} -void BinderTester::case3345(){} -void BinderTester::case3346(){} -void BinderTester::case3347(){} -void BinderTester::case3348(){} -void BinderTester::case3349(){} -void BinderTester::case3350(){} -void BinderTester::case3351(){} -void BinderTester::case3352(){} -void BinderTester::case3353(){} -void BinderTester::case3354(){} -void BinderTester::case3355(){} -void BinderTester::case3356(){} -void BinderTester::case3357(){} -void BinderTester::case3358(){} -void BinderTester::case3359(){} -void BinderTester::case3360(){} -void BinderTester::case3361(){} -void BinderTester::case3362(){} -void BinderTester::case3363(){} -void BinderTester::case3364(){} -void BinderTester::case3365(){} -void BinderTester::case3366(){} -void BinderTester::case3367(){} -void BinderTester::case3368(){} -void BinderTester::case3369(){} -void BinderTester::case3370(){} -void BinderTester::case3371(){} -void BinderTester::case3372(){} -void BinderTester::case3373(){} -void BinderTester::case3374(){} -void BinderTester::case3375(){} -void BinderTester::case3376(){} -void BinderTester::case3377(){} -void BinderTester::case3378(){} -void BinderTester::case3379(){} -void BinderTester::case3380(){} -void BinderTester::case3381(){} -void BinderTester::case3382(){} -void BinderTester::case3383(){} -void BinderTester::case3384(){} -void BinderTester::case3385(){} -void BinderTester::case3386(){} -void BinderTester::case3387(){} -void BinderTester::case3388(){} -void BinderTester::case3389(){} -void BinderTester::case3390(){} -void BinderTester::case3391(){} -void BinderTester::case3392(){} -void BinderTester::case3393(){} -void BinderTester::case3394(){} -void BinderTester::case3395(){} -void BinderTester::case3396(){} -void BinderTester::case3397(){} -void BinderTester::case3398(){} -void BinderTester::case3399(){} +void BinderTester::case3300() {} +void BinderTester::case3301() {} +void BinderTester::case3302() {} +void BinderTester::case3303() {} +void BinderTester::case3304() {} +void BinderTester::case3305() {} +void BinderTester::case3306() {} +void BinderTester::case3307() {} +void BinderTester::case3308() {} +void BinderTester::case3309() {} +void BinderTester::case3310() {} +void BinderTester::case3311() {} +void BinderTester::case3312() {} +void BinderTester::case3313() {} +void BinderTester::case3314() {} +void BinderTester::case3315() {} +void BinderTester::case3316() {} +void BinderTester::case3317() {} +void BinderTester::case3318() {} +void BinderTester::case3319() {} +void BinderTester::case3320() {} +void BinderTester::case3321() {} +void BinderTester::case3322() {} +void BinderTester::case3323() {} +void BinderTester::case3324() {} +void BinderTester::case3325() {} +void BinderTester::case3326() {} +void BinderTester::case3327() {} +void BinderTester::case3328() {} +void BinderTester::case3329() {} +void BinderTester::case3330() {} +void BinderTester::case3331() {} +void BinderTester::case3332() {} +void BinderTester::case3333() {} +void BinderTester::case3334() {} +void BinderTester::case3335() {} +void BinderTester::case3336() {} +void BinderTester::case3337() {} +void BinderTester::case3338() {} +void BinderTester::case3339() {} +void BinderTester::case3340() {} +void BinderTester::case3341() {} +void BinderTester::case3342() {} +void BinderTester::case3343() {} +void BinderTester::case3344() {} +void BinderTester::case3345() {} +void BinderTester::case3346() {} +void BinderTester::case3347() {} +void BinderTester::case3348() {} +void BinderTester::case3349() {} +void BinderTester::case3350() {} +void BinderTester::case3351() {} +void BinderTester::case3352() {} +void BinderTester::case3353() {} +void BinderTester::case3354() {} +void BinderTester::case3355() {} +void BinderTester::case3356() {} +void BinderTester::case3357() {} +void BinderTester::case3358() {} +void BinderTester::case3359() {} +void BinderTester::case3360() {} +void BinderTester::case3361() {} +void BinderTester::case3362() {} +void BinderTester::case3363() {} +void BinderTester::case3364() {} +void BinderTester::case3365() {} +void BinderTester::case3366() {} +void BinderTester::case3367() {} +void BinderTester::case3368() {} +void BinderTester::case3369() {} +void BinderTester::case3370() {} +void BinderTester::case3371() {} +void BinderTester::case3372() {} +void BinderTester::case3373() {} +void BinderTester::case3374() {} +void BinderTester::case3375() {} +void BinderTester::case3376() {} +void BinderTester::case3377() {} +void BinderTester::case3378() {} +void BinderTester::case3379() {} +void BinderTester::case3380() {} +void BinderTester::case3381() {} +void BinderTester::case3382() {} +void BinderTester::case3383() {} +void BinderTester::case3384() {} +void BinderTester::case3385() {} +void BinderTester::case3386() {} +void BinderTester::case3387() {} +void BinderTester::case3388() {} +void BinderTester::case3389() {} +void BinderTester::case3390() {} +void BinderTester::case3391() {} +void BinderTester::case3392() {} +void BinderTester::case3393() {} +void BinderTester::case3394() {} +void BinderTester::case3395() {} +void BinderTester::case3396() {} +void BinderTester::case3397() {} +void BinderTester::case3398() {} +void BinderTester::case3399() {} -void BinderTester::case3400(){} -void BinderTester::case3401(){} -void BinderTester::case3402(){} -void BinderTester::case3403(){} -void BinderTester::case3404(){} -void BinderTester::case3405(){} -void BinderTester::case3406(){} -void BinderTester::case3407(){} -void BinderTester::case3408(){} -void BinderTester::case3409(){} -void BinderTester::case3410(){} -void BinderTester::case3411(){} -void BinderTester::case3412(){} -void BinderTester::case3413(){} -void BinderTester::case3414(){} -void BinderTester::case3415(){} -void BinderTester::case3416(){} -void BinderTester::case3417(){} -void BinderTester::case3418(){} -void BinderTester::case3419(){} -void BinderTester::case3420(){} -void BinderTester::case3421(){} -void BinderTester::case3422(){} -void BinderTester::case3423(){} -void BinderTester::case3424(){} -void BinderTester::case3425(){} -void BinderTester::case3426(){} -void BinderTester::case3427(){} -void BinderTester::case3428(){} -void BinderTester::case3429(){} -void BinderTester::case3430(){} -void BinderTester::case3431(){} -void BinderTester::case3432(){} -void BinderTester::case3433(){} -void BinderTester::case3434(){} -void BinderTester::case3435(){} -void BinderTester::case3436(){} -void BinderTester::case3437(){} -void BinderTester::case3438(){} -void BinderTester::case3439(){} -void BinderTester::case3440(){} -void BinderTester::case3441(){} -void BinderTester::case3442(){} -void BinderTester::case3443(){} -void BinderTester::case3444(){} -void BinderTester::case3445(){} -void BinderTester::case3446(){} -void BinderTester::case3447(){} -void BinderTester::case3448(){} -void BinderTester::case3449(){} -void BinderTester::case3450(){} -void BinderTester::case3451(){} -void BinderTester::case3452(){} -void BinderTester::case3453(){} -void BinderTester::case3454(){} -void BinderTester::case3455(){} -void BinderTester::case3456(){} -void BinderTester::case3457(){} -void BinderTester::case3458(){} -void BinderTester::case3459(){} -void BinderTester::case3460(){} -void BinderTester::case3461(){} -void BinderTester::case3462(){} -void BinderTester::case3463(){} -void BinderTester::case3464(){} -void BinderTester::case3465(){} -void BinderTester::case3466(){} -void BinderTester::case3467(){} -void BinderTester::case3468(){} -void BinderTester::case3469(){} -void BinderTester::case3470(){} -void BinderTester::case3471(){} -void BinderTester::case3472(){} -void BinderTester::case3473(){} -void BinderTester::case3474(){} -void BinderTester::case3475(){} -void BinderTester::case3476(){} -void BinderTester::case3477(){} -void BinderTester::case3478(){} -void BinderTester::case3479(){} -void BinderTester::case3480(){} -void BinderTester::case3481(){} -void BinderTester::case3482(){} -void BinderTester::case3483(){} -void BinderTester::case3484(){} -void BinderTester::case3485(){} -void BinderTester::case3486(){} -void BinderTester::case3487(){} -void BinderTester::case3488(){} -void BinderTester::case3489(){} -void BinderTester::case3490(){} -void BinderTester::case3491(){} -void BinderTester::case3492(){} -void BinderTester::case3493(){} -void BinderTester::case3494(){} -void BinderTester::case3495(){} -void BinderTester::case3496(){} -void BinderTester::case3497(){} -void BinderTester::case3498(){} -void BinderTester::case3499(){} +void BinderTester::case3400() {} +void BinderTester::case3401() {} +void BinderTester::case3402() {} +void BinderTester::case3403() {} +void BinderTester::case3404() {} +void BinderTester::case3405() {} +void BinderTester::case3406() {} +void BinderTester::case3407() {} +void BinderTester::case3408() {} +void BinderTester::case3409() {} +void BinderTester::case3410() {} +void BinderTester::case3411() {} +void BinderTester::case3412() {} +void BinderTester::case3413() {} +void BinderTester::case3414() {} +void BinderTester::case3415() {} +void BinderTester::case3416() {} +void BinderTester::case3417() {} +void BinderTester::case3418() {} +void BinderTester::case3419() {} +void BinderTester::case3420() {} +void BinderTester::case3421() {} +void BinderTester::case3422() {} +void BinderTester::case3423() {} +void BinderTester::case3424() {} +void BinderTester::case3425() {} +void BinderTester::case3426() {} +void BinderTester::case3427() {} +void BinderTester::case3428() {} +void BinderTester::case3429() {} +void BinderTester::case3430() {} +void BinderTester::case3431() {} +void BinderTester::case3432() {} +void BinderTester::case3433() {} +void BinderTester::case3434() {} +void BinderTester::case3435() {} +void BinderTester::case3436() {} +void BinderTester::case3437() {} +void BinderTester::case3438() {} +void BinderTester::case3439() {} +void BinderTester::case3440() {} +void BinderTester::case3441() {} +void BinderTester::case3442() {} +void BinderTester::case3443() {} +void BinderTester::case3444() {} +void BinderTester::case3445() {} +void BinderTester::case3446() {} +void BinderTester::case3447() {} +void BinderTester::case3448() {} +void BinderTester::case3449() {} +void BinderTester::case3450() {} +void BinderTester::case3451() {} +void BinderTester::case3452() {} +void BinderTester::case3453() {} +void BinderTester::case3454() {} +void BinderTester::case3455() {} +void BinderTester::case3456() {} +void BinderTester::case3457() {} +void BinderTester::case3458() {} +void BinderTester::case3459() {} +void BinderTester::case3460() {} +void BinderTester::case3461() {} +void BinderTester::case3462() {} +void BinderTester::case3463() {} +void BinderTester::case3464() {} +void BinderTester::case3465() {} +void BinderTester::case3466() {} +void BinderTester::case3467() {} +void BinderTester::case3468() {} +void BinderTester::case3469() {} +void BinderTester::case3470() {} +void BinderTester::case3471() {} +void BinderTester::case3472() {} +void BinderTester::case3473() {} +void BinderTester::case3474() {} +void BinderTester::case3475() {} +void BinderTester::case3476() {} +void BinderTester::case3477() {} +void BinderTester::case3478() {} +void BinderTester::case3479() {} +void BinderTester::case3480() {} +void BinderTester::case3481() {} +void BinderTester::case3482() {} +void BinderTester::case3483() {} +void BinderTester::case3484() {} +void BinderTester::case3485() {} +void BinderTester::case3486() {} +void BinderTester::case3487() {} +void BinderTester::case3488() {} +void BinderTester::case3489() {} +void BinderTester::case3490() {} +void BinderTester::case3491() {} +void BinderTester::case3492() {} +void BinderTester::case3493() {} +void BinderTester::case3494() {} +void BinderTester::case3495() {} +void BinderTester::case3496() {} +void BinderTester::case3497() {} +void BinderTester::case3498() {} +void BinderTester::case3499() {} -void BinderTester::case3500(){} -void BinderTester::case3501(){} -void BinderTester::case3502(){} -void BinderTester::case3503(){} -void BinderTester::case3504(){} -void BinderTester::case3505(){} -void BinderTester::case3506(){} -void BinderTester::case3507(){} -void BinderTester::case3508(){} -void BinderTester::case3509(){} -void BinderTester::case3510(){} -void BinderTester::case3511(){} -void BinderTester::case3512(){} -void BinderTester::case3513(){} -void BinderTester::case3514(){} -void BinderTester::case3515(){} -void BinderTester::case3516(){} -void BinderTester::case3517(){} -void BinderTester::case3518(){} -void BinderTester::case3519(){} -void BinderTester::case3520(){} -void BinderTester::case3521(){} -void BinderTester::case3522(){} -void BinderTester::case3523(){} -void BinderTester::case3524(){} -void BinderTester::case3525(){} -void BinderTester::case3526(){} -void BinderTester::case3527(){} -void BinderTester::case3528(){} -void BinderTester::case3529(){} -void BinderTester::case3530(){} -void BinderTester::case3531(){} -void BinderTester::case3532(){} -void BinderTester::case3533(){} -void BinderTester::case3534(){} -void BinderTester::case3535(){} -void BinderTester::case3536(){} -void BinderTester::case3537(){} -void BinderTester::case3538(){} -void BinderTester::case3539(){} -void BinderTester::case3540(){} -void BinderTester::case3541(){} -void BinderTester::case3542(){} -void BinderTester::case3543(){} -void BinderTester::case3544(){} -void BinderTester::case3545(){} -void BinderTester::case3546(){} -void BinderTester::case3547(){} -void BinderTester::case3548(){} -void BinderTester::case3549(){} -void BinderTester::case3550(){} -void BinderTester::case3551(){} -void BinderTester::case3552(){} -void BinderTester::case3553(){} -void BinderTester::case3554(){} -void BinderTester::case3555(){} -void BinderTester::case3556(){} -void BinderTester::case3557(){} -void BinderTester::case3558(){} -void BinderTester::case3559(){} -void BinderTester::case3560(){} -void BinderTester::case3561(){} -void BinderTester::case3562(){} -void BinderTester::case3563(){} -void BinderTester::case3564(){} -void BinderTester::case3565(){} -void BinderTester::case3566(){} -void BinderTester::case3567(){} -void BinderTester::case3568(){} -void BinderTester::case3569(){} -void BinderTester::case3570(){} -void BinderTester::case3571(){} -void BinderTester::case3572(){} -void BinderTester::case3573(){} -void BinderTester::case3574(){} -void BinderTester::case3575(){} -void BinderTester::case3576(){} -void BinderTester::case3577(){} -void BinderTester::case3578(){} -void BinderTester::case3579(){} -void BinderTester::case3580(){} -void BinderTester::case3581(){} -void BinderTester::case3582(){} -void BinderTester::case3583(){} -void BinderTester::case3584(){} -void BinderTester::case3585(){} -void BinderTester::case3586(){} -void BinderTester::case3587(){} -void BinderTester::case3588(){} -void BinderTester::case3589(){} -void BinderTester::case3590(){} -void BinderTester::case3591(){} -void BinderTester::case3592(){} -void BinderTester::case3593(){} -void BinderTester::case3594(){} -void BinderTester::case3595(){} -void BinderTester::case3596(){} -void BinderTester::case3597(){} -void BinderTester::case3598(){} -void BinderTester::case3599(){} +void BinderTester::case3500() {} +void BinderTester::case3501() {} +void BinderTester::case3502() {} +void BinderTester::case3503() {} +void BinderTester::case3504() {} +void BinderTester::case3505() {} +void BinderTester::case3506() {} +void BinderTester::case3507() {} +void BinderTester::case3508() {} +void BinderTester::case3509() {} +void BinderTester::case3510() {} +void BinderTester::case3511() {} +void BinderTester::case3512() {} +void BinderTester::case3513() {} +void BinderTester::case3514() {} +void BinderTester::case3515() {} +void BinderTester::case3516() {} +void BinderTester::case3517() {} +void BinderTester::case3518() {} +void BinderTester::case3519() {} +void BinderTester::case3520() {} +void BinderTester::case3521() {} +void BinderTester::case3522() {} +void BinderTester::case3523() {} +void BinderTester::case3524() {} +void BinderTester::case3525() {} +void BinderTester::case3526() {} +void BinderTester::case3527() {} +void BinderTester::case3528() {} +void BinderTester::case3529() {} +void BinderTester::case3530() {} +void BinderTester::case3531() {} +void BinderTester::case3532() {} +void BinderTester::case3533() {} +void BinderTester::case3534() {} +void BinderTester::case3535() {} +void BinderTester::case3536() {} +void BinderTester::case3537() {} +void BinderTester::case3538() {} +void BinderTester::case3539() {} +void BinderTester::case3540() {} +void BinderTester::case3541() {} +void BinderTester::case3542() {} +void BinderTester::case3543() {} +void BinderTester::case3544() {} +void BinderTester::case3545() {} +void BinderTester::case3546() {} +void BinderTester::case3547() {} +void BinderTester::case3548() {} +void BinderTester::case3549() {} +void BinderTester::case3550() {} +void BinderTester::case3551() {} +void BinderTester::case3552() {} +void BinderTester::case3553() {} +void BinderTester::case3554() {} +void BinderTester::case3555() {} +void BinderTester::case3556() {} +void BinderTester::case3557() {} +void BinderTester::case3558() {} +void BinderTester::case3559() {} +void BinderTester::case3560() {} +void BinderTester::case3561() {} +void BinderTester::case3562() {} +void BinderTester::case3563() {} +void BinderTester::case3564() {} +void BinderTester::case3565() {} +void BinderTester::case3566() {} +void BinderTester::case3567() {} +void BinderTester::case3568() {} +void BinderTester::case3569() {} +void BinderTester::case3570() {} +void BinderTester::case3571() {} +void BinderTester::case3572() {} +void BinderTester::case3573() {} +void BinderTester::case3574() {} +void BinderTester::case3575() {} +void BinderTester::case3576() {} +void BinderTester::case3577() {} +void BinderTester::case3578() {} +void BinderTester::case3579() {} +void BinderTester::case3580() {} +void BinderTester::case3581() {} +void BinderTester::case3582() {} +void BinderTester::case3583() {} +void BinderTester::case3584() {} +void BinderTester::case3585() {} +void BinderTester::case3586() {} +void BinderTester::case3587() {} +void BinderTester::case3588() {} +void BinderTester::case3589() {} +void BinderTester::case3590() {} +void BinderTester::case3591() {} +void BinderTester::case3592() {} +void BinderTester::case3593() {} +void BinderTester::case3594() {} +void BinderTester::case3595() {} +void BinderTester::case3596() {} +void BinderTester::case3597() {} +void BinderTester::case3598() {} +void BinderTester::case3599() {} diff --git a/C/tests/ParserTester.cpp b/C/tests/ParserTester.cpp index afec0f076..270e8756b 100644 --- a/C/tests/ParserTester.cpp +++ b/C/tests/ParserTester.cpp @@ -25,34 +25,25 @@ using namespace C; const std::string ParserTester::Name = "PARSER"; -void ParserTester::testParser() -{ - return run(tests_); -} +void ParserTester::testParser() { return run(tests_); } -void ParserTester::parseDeclaration(std::string text, Expectation X) -{ - (static_cast(suite_)->parseDeclaration(text, X)); +void ParserTester::parseDeclaration(std::string text, Expectation X) { + (static_cast(suite_)->parseDeclaration(text, X)); } -void ParserTester::parseExpression(std::string text, Expectation X) -{ - (static_cast(suite_)->parseExpression(text, X)); +void ParserTester::parseExpression(std::string text, Expectation X) { + (static_cast(suite_)->parseExpression(text, X)); } -void ParserTester::parseStatement(std::string text, Expectation X) -{ - (static_cast(suite_)->parseStatement(text, X)); +void ParserTester::parseStatement(std::string text, Expectation X) { + (static_cast(suite_)->parseStatement(text, X)); } -void ParserTester::parse(std::string text, Expectation X, SyntaxTree::SyntaxCategory synCat) -{ - (static_cast(suite_)->parse(text, X, synCat)); +void ParserTester::parse(std::string text, Expectation X, + SyntaxTree::SyntaxCategory synCat) { + (static_cast(suite_)->parse(text, X, synCat)); } -void ParserTester::setUp() -{} +void ParserTester::setUp() {} -void ParserTester::tearDown() -{ -} +void ParserTester::tearDown() {} diff --git a/C/tests/ParserTester.h b/C/tests/ParserTester.h index 050ffd709..74ecc7b17 100644 --- a/C/tests/ParserTester.h +++ b/C/tests/ParserTester.h @@ -25,8186 +25,5543 @@ #include "TestSuite_Internals.h" #include "tests/Tester.h" -#define TEST_PARSER(Function) TestFunction { &ParserTester::Function, #Function } +#define TEST_PARSER(Function) \ + TestFunction { &ParserTester::Function, #Function } namespace psy { namespace C { -class ParserTester final : public Tester -{ +class ParserTester final : public Tester { public: - ParserTester(TestSuite* suite) - : Tester(suite) - {} + ParserTester(TestSuite *suite) : Tester(suite) {} - static const std::string Name; - virtual std::string name() const override { return Name; } - virtual void setUp() override; - virtual void tearDown() override; + static const std::string Name; + virtual std::string name() const override { return Name; } + virtual void setUp() override; + virtual void tearDown() override; - void testParser(); + void testParser(); - void parseDeclaration(std::string text, Expectation X = Expectation()); - void parseExpression(std::string text, Expectation X = Expectation()); - void parseStatement(std::string text, Expectation X = Expectation()); - void parse(std::string text, - Expectation X = Expectation(), - SyntaxTree::SyntaxCategory synCat = SyntaxTree::SyntaxCategory::UNSPECIFIED); + void parseDeclaration(std::string text, Expectation X = Expectation()); + void parseExpression(std::string text, Expectation X = Expectation()); + void parseStatement(std::string text, Expectation X = Expectation()); + void parse(std::string text, Expectation X = Expectation(), + SyntaxTree::SyntaxCategory synCat = + SyntaxTree::SyntaxCategory::UNSPECIFIED); - using TestFunction = std::pair, const char*>; + using TestFunction = + std::pair, const char *>; - /* - Declarations: - + 0000-0099 -> object declarations - + 0100-0199 -> object declarations of array and function types - + 0200-0279 -> function declarations/definitions - + 0280-0299 -> function definitions K&R - + 0300-0399 -> array declarations - + 0400-0499 -> `struct' and `union' declarations and type specifiers - + 0500-0599 -> `enum' declarations and type specifiers - + 0600-0649 -> storage class specifiers - + 0650-0669 -> `_Static_assert' - + 0670-0699 -> GNU: `__extension__' - + 0700-0779 -> GNU: `__attribute__' - + 0780-0799 -> GNU: `__asm__' (file scope and labels) - + 0800-0849 -> brace-enclosed initializaters - + 0850-0899 -> designated initializers - + 0900-0949 -> GNU: `__typeof__' (w/ ambiguity) - + 0950-0999 -> `__Alignas' + /* + Declarations: + + 0000-0099 -> object declarations + + 0100-0199 -> object declarations of array and function types + + 0200-0279 -> function declarations/definitions + + 0280-0299 -> function definitions K&R + + 0300-0399 -> array declarations + + 0400-0499 -> `struct' and `union' declarations and type specifiers + + 0500-0599 -> `enum' declarations and type specifiers + + 0600-0649 -> storage class specifiers + + 0650-0669 -> `_Static_assert' + + 0670-0699 -> GNU: `__extension__' + + 0700-0779 -> GNU: `__attribute__' + + 0780-0799 -> GNU: `__asm__' (file scope and labels) + + 0800-0849 -> brace-enclosed initializaters + + 0850-0899 -> designated initializers + + 0900-0949 -> GNU: `__typeof__' (w/ ambiguity) + + 0950-0999 -> `__Alignas' - Expressions: - + 1000-1099 -> identifiers, constants, and string-literals - + 1100-1199 -> parenthesized expression - + 1200-1249 -> generic selection - + 1250-1299 -> compound literal - + 1300-1349 -> (pre/post) increment and decrement - + 1350-1399 -> unary arithmetic - + 1400-1449 -> `sizeof' - + 1450-1499 -> `_Alignof' - + 1500-1549 -> member access - + 1550-1599 -> array element access - + 1600-1649 -> calls - + 1650-1699 -> address-of and indirection - + 1700-1749 -> casts (w/ ambiguity) - + 1750-1799 -> conditional - + 1800-1849 -> binary and sequencing - + 1850-1899 -> assignment - + 1900-1949 -> GNU: statement-expressions - + 1950-1959 -> GNU: `__builtin_va_arg' - + 1960-1969 -> GNU: `__builtin_offsetof' - + 1970-1979 -> GNU: `__builtin_choose_expr' - + 1980-1989 -> GNU: `__FUNCTION__' and `__PRETTY_FUNCTION__' - + 1990-1999 -> GNU: `__real__' and `__imag__' + Expressions: + + 1000-1099 -> identifiers, constants, and string-literals + + 1100-1199 -> parenthesized expression + + 1200-1249 -> generic selection + + 1250-1299 -> compound literal + + 1300-1349 -> (pre/post) increment and decrement + + 1350-1399 -> unary arithmetic + + 1400-1449 -> `sizeof' + + 1450-1499 -> `_Alignof' + + 1500-1549 -> member access + + 1550-1599 -> array element access + + 1600-1649 -> calls + + 1650-1699 -> address-of and indirection + + 1700-1749 -> casts (w/ ambiguity) + + 1750-1799 -> conditional + + 1800-1849 -> binary and sequencing + + 1850-1899 -> assignment + + 1900-1949 -> GNU: statement-expressions + + 1950-1959 -> GNU: `__builtin_va_arg' + + 1960-1969 -> GNU: `__builtin_offsetof' + + 1970-1979 -> GNU: `__builtin_choose_expr' + + 1980-1989 -> GNU: `__FUNCTION__' and `__PRETTY_FUNCTION__' + + 1990-1999 -> GNU: `__real__' and `__imag__' - Statements: - + 2000-2019 -> `goto' and identifier labels - + 2020-2099 -> compound statements - + 2100-2199 -> expression statements - + 2200-2299 -> declaration statements (w/ ambiguity) - + 2300-2349 -> `if' - + 2350-2399 -> `switch', `case', and `default' - + 2400-2449 -> `while'and `do' - + 2450-2499 -> `for' - + 2500-2549 -> `break', `continue', and `return' - + 2550-2599 -> - + 2600-2699 -> GNU: `__asm__' + Statements: + + 2000-2019 -> `goto' and identifier labels + + 2020-2099 -> compound statements + + 2100-2199 -> expression statements + + 2200-2299 -> declaration statements (w/ ambiguity) + + 2300-2349 -> `if' + + 2350-2399 -> `switch', `case', and `default' + + 2400-2449 -> `while'and `do' + + 2450-2499 -> `for' + + 2500-2549 -> `break', `continue', and `return' + + 2550-2599 -> + + 2600-2699 -> GNU: `__asm__' - Macro translation: - + 3000-3009 -> `va_arg' - + 3010-3019 -> `offsetof' - + 3020-3029 -> `__func__' - + 3030-3039 -> - + 3040-3099 -> - + 3100-3199 -> - + 3200-3299 -> - + 3300-3399 -> - + 3400-3499 -> - + 3500-3599 -> - */ + Macro translation: + + 3000-3009 -> `va_arg' + + 3010-3019 -> `offsetof' + + 3020-3029 -> `__func__' + + 3030-3039 -> + + 3040-3099 -> + + 3100-3199 -> + + 3200-3299 -> + + 3300-3399 -> + + 3400-3499 -> + + 3500-3599 -> + */ - void case0001(); - void case0002(); - void case0003(); - void case0004(); - void case0005(); - void case0006(); - void case0007(); - void case0008(); - void case0009(); - void case0010(); - void case0011(); - void case0012(); - void case0013(); - void case0014(); - void case0015(); - void case0016(); - void case0017(); - void case0018(); - void case0019(); - void case0020(); - void case0021(); - void case0022(); - void case0023(); - void case0024(); - void case0025(); - void case0026(); - void case0027(); - void case0028(); - void case0029(); - void case0030(); - void case0031(); - void case0032(); - void case0033(); - void case0034(); - void case0035(); - void case0036(); - void case0037(); - void case0038(); - void case0039(); - void case0040(); - void case0041(); - void case0042(); - void case0043(); - void case0044(); - void case0045(); - void case0046(); - void case0047(); - void case0048(); - void case0049(); - void case0050(); - void case0051(); - void case0052(); - void case0053(); - void case0054(); - void case0055(); - void case0056(); - void case0057(); - void case0058(); - void case0059(); - void case0060(); - void case0061(); - void case0062(); - void case0063(); - void case0064(); - void case0065(); - void case0066(); - void case0067(); - void case0068(); - void case0069(); - void case0070(); - void case0071(); - void case0072(); - void case0073(); - void case0074(); - void case0075(); - void case0076(); - void case0077(); - void case0078(); - void case0079(); - void case0080(); - void case0081(); - void case0082(); - void case0083(); - void case0084(); - void case0085(); - void case0086(); - void case0087(); - void case0088(); - void case0089(); - void case0090(); - void case0091(); - void case0092(); - void case0093(); - void case0094(); - void case0095(); - void case0096(); - void case0097(); - void case0098(); - void case0099(); + void case0001(); + void case0002(); + void case0003(); + void case0004(); + void case0005(); + void case0006(); + void case0007(); + void case0008(); + void case0009(); + void case0010(); + void case0011(); + void case0012(); + void case0013(); + void case0014(); + void case0015(); + void case0016(); + void case0017(); + void case0018(); + void case0019(); + void case0020(); + void case0021(); + void case0022(); + void case0023(); + void case0024(); + void case0025(); + void case0026(); + void case0027(); + void case0028(); + void case0029(); + void case0030(); + void case0031(); + void case0032(); + void case0033(); + void case0034(); + void case0035(); + void case0036(); + void case0037(); + void case0038(); + void case0039(); + void case0040(); + void case0041(); + void case0042(); + void case0043(); + void case0044(); + void case0045(); + void case0046(); + void case0047(); + void case0048(); + void case0049(); + void case0050(); + void case0051(); + void case0052(); + void case0053(); + void case0054(); + void case0055(); + void case0056(); + void case0057(); + void case0058(); + void case0059(); + void case0060(); + void case0061(); + void case0062(); + void case0063(); + void case0064(); + void case0065(); + void case0066(); + void case0067(); + void case0068(); + void case0069(); + void case0070(); + void case0071(); + void case0072(); + void case0073(); + void case0074(); + void case0075(); + void case0076(); + void case0077(); + void case0078(); + void case0079(); + void case0080(); + void case0081(); + void case0082(); + void case0083(); + void case0084(); + void case0085(); + void case0086(); + void case0087(); + void case0088(); + void case0089(); + void case0090(); + void case0091(); + void case0092(); + void case0093(); + void case0094(); + void case0095(); + void case0096(); + void case0097(); + void case0098(); + void case0099(); - void case0100(); - void case0101(); - void case0102(); - void case0103(); - void case0104(); - void case0105(); - void case0106(); - void case0107(); - void case0108(); - void case0109(); - void case0110(); - void case0111(); - void case0112(); - void case0113(); - void case0114(); - void case0115(); - void case0116(); - void case0117(); - void case0118(); - void case0119(); - void case0120(); - void case0121(); - void case0122(); - void case0123(); - void case0124(); - void case0125(); - void case0126(); - void case0127(); - void case0128(); - void case0129(); - void case0130(); - void case0131(); - void case0132(); - void case0133(); - void case0134(); - void case0135(); - void case0136(); - void case0137(); - void case0138(); - void case0139(); - void case0140(); - void case0141(); - void case0142(); - void case0143(); - void case0144(); - void case0145(); - void case0146(); - void case0147(); - void case0148(); - void case0149(); - void case0150(); - void case0151(); - void case0152(); - void case0153(); - void case0154(); - void case0155(); - void case0156(); - void case0157(); - void case0158(); - void case0159(); - void case0160(); - void case0161(); - void case0162(); - void case0163(); - void case0164(); - void case0165(); - void case0166(); - void case0167(); - void case0168(); - void case0169(); - void case0170(); - void case0171(); - void case0172(); - void case0173(); - void case0174(); - void case0175(); - void case0176(); - void case0177(); - void case0178(); - void case0179(); - void case0180(); - void case0181(); - void case0182(); - void case0183(); - void case0184(); - void case0185(); - void case0186(); - void case0187(); - void case0188(); - void case0189(); - void case0190(); - void case0191(); - void case0192(); - void case0193(); - void case0194(); - void case0195(); - void case0196(); - void case0197(); - void case0198(); - void case0199(); + void case0100(); + void case0101(); + void case0102(); + void case0103(); + void case0104(); + void case0105(); + void case0106(); + void case0107(); + void case0108(); + void case0109(); + void case0110(); + void case0111(); + void case0112(); + void case0113(); + void case0114(); + void case0115(); + void case0116(); + void case0117(); + void case0118(); + void case0119(); + void case0120(); + void case0121(); + void case0122(); + void case0123(); + void case0124(); + void case0125(); + void case0126(); + void case0127(); + void case0128(); + void case0129(); + void case0130(); + void case0131(); + void case0132(); + void case0133(); + void case0134(); + void case0135(); + void case0136(); + void case0137(); + void case0138(); + void case0139(); + void case0140(); + void case0141(); + void case0142(); + void case0143(); + void case0144(); + void case0145(); + void case0146(); + void case0147(); + void case0148(); + void case0149(); + void case0150(); + void case0151(); + void case0152(); + void case0153(); + void case0154(); + void case0155(); + void case0156(); + void case0157(); + void case0158(); + void case0159(); + void case0160(); + void case0161(); + void case0162(); + void case0163(); + void case0164(); + void case0165(); + void case0166(); + void case0167(); + void case0168(); + void case0169(); + void case0170(); + void case0171(); + void case0172(); + void case0173(); + void case0174(); + void case0175(); + void case0176(); + void case0177(); + void case0178(); + void case0179(); + void case0180(); + void case0181(); + void case0182(); + void case0183(); + void case0184(); + void case0185(); + void case0186(); + void case0187(); + void case0188(); + void case0189(); + void case0190(); + void case0191(); + void case0192(); + void case0193(); + void case0194(); + void case0195(); + void case0196(); + void case0197(); + void case0198(); + void case0199(); - void case0200(); - void case0201(); - void case0202(); - void case0203(); - void case0204(); - void case0205(); - void case0206(); - void case0207(); - void case0208(); - void case0209(); - void case0210(); - void case0211(); - void case0212(); - void case0213(); - void case0214(); - void case0215(); - void case0216(); - void case0217(); - void case0218(); - void case0219(); - void case0220(); - void case0221(); - void case0222(); - void case0223(); - void case0224(); - void case0225(); - void case0226(); - void case0227(); - void case0228(); - void case0229(); - void case0230(); - void case0231(); - void case0232(); - void case0233(); - void case0234(); - void case0235(); - void case0236(); - void case0237(); - void case0238(); - void case0239(); - void case0240(); - void case0241(); - void case0242(); - void case0243(); - void case0244(); - void case0245(); - void case0246(); - void case0247(); - void case0248(); - void case0249(); - void case0250(); - void case0251(); - void case0252(); - void case0253(); - void case0254(); - void case0255(); - void case0256(); - void case0257(); - void case0258(); - void case0259(); - void case0260(); - void case0261(); - void case0262(); - void case0263(); - void case0264(); - void case0265(); - void case0266(); - void case0267(); - void case0268(); - void case0269(); - void case0270(); - void case0271(); - void case0272(); - void case0273(); - void case0274(); - void case0275(); - void case0276(); - void case0277(); - void case0278(); - void case0279(); - void case0280(); - void case0281(); - void case0282(); - void case0283(); - void case0284(); - void case0285(); - void case0286(); - void case0287(); - void case0288(); - void case0289(); - void case0290(); - void case0291(); - void case0292(); - void case0293(); - void case0294(); - void case0295(); - void case0296(); - void case0297(); - void case0298(); - void case0299(); + void case0200(); + void case0201(); + void case0202(); + void case0203(); + void case0204(); + void case0205(); + void case0206(); + void case0207(); + void case0208(); + void case0209(); + void case0210(); + void case0211(); + void case0212(); + void case0213(); + void case0214(); + void case0215(); + void case0216(); + void case0217(); + void case0218(); + void case0219(); + void case0220(); + void case0221(); + void case0222(); + void case0223(); + void case0224(); + void case0225(); + void case0226(); + void case0227(); + void case0228(); + void case0229(); + void case0230(); + void case0231(); + void case0232(); + void case0233(); + void case0234(); + void case0235(); + void case0236(); + void case0237(); + void case0238(); + void case0239(); + void case0240(); + void case0241(); + void case0242(); + void case0243(); + void case0244(); + void case0245(); + void case0246(); + void case0247(); + void case0248(); + void case0249(); + void case0250(); + void case0251(); + void case0252(); + void case0253(); + void case0254(); + void case0255(); + void case0256(); + void case0257(); + void case0258(); + void case0259(); + void case0260(); + void case0261(); + void case0262(); + void case0263(); + void case0264(); + void case0265(); + void case0266(); + void case0267(); + void case0268(); + void case0269(); + void case0270(); + void case0271(); + void case0272(); + void case0273(); + void case0274(); + void case0275(); + void case0276(); + void case0277(); + void case0278(); + void case0279(); + void case0280(); + void case0281(); + void case0282(); + void case0283(); + void case0284(); + void case0285(); + void case0286(); + void case0287(); + void case0288(); + void case0289(); + void case0290(); + void case0291(); + void case0292(); + void case0293(); + void case0294(); + void case0295(); + void case0296(); + void case0297(); + void case0298(); + void case0299(); - void case0300(); - void case0301(); - void case0302(); - void case0303(); - void case0304(); - void case0305(); - void case0306(); - void case0307(); - void case0308(); - void case0309(); - void case0310(); - void case0311(); - void case0312(); - void case0313(); - void case0314(); - void case0315(); - void case0316(); - void case0317(); - void case0318(); - void case0319(); - void case0320(); - void case0321(); - void case0322(); - void case0323(); - void case0324(); - void case0325(); - void case0326(); - void case0327(); - void case0328(); - void case0329(); - void case0330(); - void case0331(); - void case0332(); - void case0333(); - void case0334(); - void case0335(); - void case0336(); - void case0337(); - void case0338(); - void case0339(); - void case0340(); - void case0341(); - void case0342(); - void case0343(); - void case0344(); - void case0345(); - void case0346(); - void case0347(); - void case0348(); - void case0349(); - void case0350(); - void case0351(); - void case0352(); - void case0353(); - void case0354(); - void case0355(); - void case0356(); - void case0357(); - void case0358(); - void case0359(); - void case0360(); - void case0361(); - void case0362(); - void case0363(); - void case0364(); - void case0365(); - void case0366(); - void case0367(); - void case0368(); - void case0369(); - void case0370(); - void case0371(); - void case0372(); - void case0373(); - void case0374(); - void case0375(); - void case0376(); - void case0377(); - void case0378(); - void case0379(); - void case0380(); - void case0381(); - void case0382(); - void case0383(); - void case0384(); - void case0385(); - void case0386(); - void case0387(); - void case0388(); - void case0389(); - void case0390(); - void case0391(); - void case0392(); - void case0393(); - void case0394(); - void case0395(); - void case0396(); - void case0397(); - void case0398(); - void case0399(); + void case0300(); + void case0301(); + void case0302(); + void case0303(); + void case0304(); + void case0305(); + void case0306(); + void case0307(); + void case0308(); + void case0309(); + void case0310(); + void case0311(); + void case0312(); + void case0313(); + void case0314(); + void case0315(); + void case0316(); + void case0317(); + void case0318(); + void case0319(); + void case0320(); + void case0321(); + void case0322(); + void case0323(); + void case0324(); + void case0325(); + void case0326(); + void case0327(); + void case0328(); + void case0329(); + void case0330(); + void case0331(); + void case0332(); + void case0333(); + void case0334(); + void case0335(); + void case0336(); + void case0337(); + void case0338(); + void case0339(); + void case0340(); + void case0341(); + void case0342(); + void case0343(); + void case0344(); + void case0345(); + void case0346(); + void case0347(); + void case0348(); + void case0349(); + void case0350(); + void case0351(); + void case0352(); + void case0353(); + void case0354(); + void case0355(); + void case0356(); + void case0357(); + void case0358(); + void case0359(); + void case0360(); + void case0361(); + void case0362(); + void case0363(); + void case0364(); + void case0365(); + void case0366(); + void case0367(); + void case0368(); + void case0369(); + void case0370(); + void case0371(); + void case0372(); + void case0373(); + void case0374(); + void case0375(); + void case0376(); + void case0377(); + void case0378(); + void case0379(); + void case0380(); + void case0381(); + void case0382(); + void case0383(); + void case0384(); + void case0385(); + void case0386(); + void case0387(); + void case0388(); + void case0389(); + void case0390(); + void case0391(); + void case0392(); + void case0393(); + void case0394(); + void case0395(); + void case0396(); + void case0397(); + void case0398(); + void case0399(); - void case0400(); - void case0401(); - void case0402(); - void case0403(); - void case0404(); - void case0405(); - void case0406(); - void case0407(); - void case0408(); - void case0409(); - void case0410(); - void case0411(); - void case0412(); - void case0413(); - void case0414(); - void case0415(); - void case0416(); - void case0417(); - void case0418(); - void case0419(); - void case0420(); - void case0421(); - void case0422(); - void case0423(); - void case0424(); - void case0425(); - void case0426(); - void case0427(); - void case0428(); - void case0429(); - void case0430(); - void case0431(); - void case0432(); - void case0433(); - void case0434(); - void case0435(); - void case0436(); - void case0437(); - void case0438(); - void case0439(); - void case0440(); - void case0441(); - void case0442(); - void case0443(); - void case0444(); - void case0445(); - void case0446(); - void case0447(); - void case0448(); - void case0449(); - void case0450(); - void case0451(); - void case0452(); - void case0453(); - void case0454(); - void case0455(); - void case0456(); - void case0457(); - void case0458(); - void case0459(); - void case0460(); - void case0461(); - void case0462(); - void case0463(); - void case0464(); - void case0465(); - void case0466(); - void case0467(); - void case0468(); - void case0469(); - void case0470(); - void case0471(); - void case0472(); - void case0473(); - void case0474(); - void case0475(); - void case0476(); - void case0477(); - void case0478(); - void case0479(); - void case0480(); - void case0481(); - void case0482(); - void case0483(); - void case0484(); - void case0485(); - void case0486(); - void case0487(); - void case0488(); - void case0489(); - void case0490(); - void case0491(); - void case0492(); - void case0493(); - void case0494(); - void case0495(); - void case0496(); - void case0497(); - void case0498(); - void case0499(); + void case0400(); + void case0401(); + void case0402(); + void case0403(); + void case0404(); + void case0405(); + void case0406(); + void case0407(); + void case0408(); + void case0409(); + void case0410(); + void case0411(); + void case0412(); + void case0413(); + void case0414(); + void case0415(); + void case0416(); + void case0417(); + void case0418(); + void case0419(); + void case0420(); + void case0421(); + void case0422(); + void case0423(); + void case0424(); + void case0425(); + void case0426(); + void case0427(); + void case0428(); + void case0429(); + void case0430(); + void case0431(); + void case0432(); + void case0433(); + void case0434(); + void case0435(); + void case0436(); + void case0437(); + void case0438(); + void case0439(); + void case0440(); + void case0441(); + void case0442(); + void case0443(); + void case0444(); + void case0445(); + void case0446(); + void case0447(); + void case0448(); + void case0449(); + void case0450(); + void case0451(); + void case0452(); + void case0453(); + void case0454(); + void case0455(); + void case0456(); + void case0457(); + void case0458(); + void case0459(); + void case0460(); + void case0461(); + void case0462(); + void case0463(); + void case0464(); + void case0465(); + void case0466(); + void case0467(); + void case0468(); + void case0469(); + void case0470(); + void case0471(); + void case0472(); + void case0473(); + void case0474(); + void case0475(); + void case0476(); + void case0477(); + void case0478(); + void case0479(); + void case0480(); + void case0481(); + void case0482(); + void case0483(); + void case0484(); + void case0485(); + void case0486(); + void case0487(); + void case0488(); + void case0489(); + void case0490(); + void case0491(); + void case0492(); + void case0493(); + void case0494(); + void case0495(); + void case0496(); + void case0497(); + void case0498(); + void case0499(); - void case0500(); - void case0501(); - void case0502(); - void case0503(); - void case0504(); - void case0505(); - void case0506(); - void case0507(); - void case0508(); - void case0509(); - void case0510(); - void case0511(); - void case0512(); - void case0513(); - void case0514(); - void case0515(); - void case0516(); - void case0517(); - void case0518(); - void case0519(); - void case0520(); - void case0521(); - void case0522(); - void case0523(); - void case0524(); - void case0525(); - void case0526(); - void case0527(); - void case0528(); - void case0529(); - void case0530(); - void case0531(); - void case0532(); - void case0533(); - void case0534(); - void case0535(); - void case0536(); - void case0537(); - void case0538(); - void case0539(); - void case0540(); - void case0541(); - void case0542(); - void case0543(); - void case0544(); - void case0545(); - void case0546(); - void case0547(); - void case0548(); - void case0549(); - void case0550(); - void case0551(); - void case0552(); - void case0553(); - void case0554(); - void case0555(); - void case0556(); - void case0557(); - void case0558(); - void case0559(); - void case0560(); - void case0561(); - void case0562(); - void case0563(); - void case0564(); - void case0565(); - void case0566(); - void case0567(); - void case0568(); - void case0569(); - void case0570(); - void case0571(); - void case0572(); - void case0573(); - void case0574(); - void case0575(); - void case0576(); - void case0577(); - void case0578(); - void case0579(); - void case0580(); - void case0581(); - void case0582(); - void case0583(); - void case0584(); - void case0585(); - void case0586(); - void case0587(); - void case0588(); - void case0589(); - void case0590(); - void case0591(); - void case0592(); - void case0593(); - void case0594(); - void case0595(); - void case0596(); - void case0597(); - void case0598(); - void case0599(); + void case0500(); + void case0501(); + void case0502(); + void case0503(); + void case0504(); + void case0505(); + void case0506(); + void case0507(); + void case0508(); + void case0509(); + void case0510(); + void case0511(); + void case0512(); + void case0513(); + void case0514(); + void case0515(); + void case0516(); + void case0517(); + void case0518(); + void case0519(); + void case0520(); + void case0521(); + void case0522(); + void case0523(); + void case0524(); + void case0525(); + void case0526(); + void case0527(); + void case0528(); + void case0529(); + void case0530(); + void case0531(); + void case0532(); + void case0533(); + void case0534(); + void case0535(); + void case0536(); + void case0537(); + void case0538(); + void case0539(); + void case0540(); + void case0541(); + void case0542(); + void case0543(); + void case0544(); + void case0545(); + void case0546(); + void case0547(); + void case0548(); + void case0549(); + void case0550(); + void case0551(); + void case0552(); + void case0553(); + void case0554(); + void case0555(); + void case0556(); + void case0557(); + void case0558(); + void case0559(); + void case0560(); + void case0561(); + void case0562(); + void case0563(); + void case0564(); + void case0565(); + void case0566(); + void case0567(); + void case0568(); + void case0569(); + void case0570(); + void case0571(); + void case0572(); + void case0573(); + void case0574(); + void case0575(); + void case0576(); + void case0577(); + void case0578(); + void case0579(); + void case0580(); + void case0581(); + void case0582(); + void case0583(); + void case0584(); + void case0585(); + void case0586(); + void case0587(); + void case0588(); + void case0589(); + void case0590(); + void case0591(); + void case0592(); + void case0593(); + void case0594(); + void case0595(); + void case0596(); + void case0597(); + void case0598(); + void case0599(); - void case0600(); - void case0601(); - void case0602(); - void case0603(); - void case0604(); - void case0605(); - void case0606(); - void case0607(); - void case0608(); - void case0609(); - void case0610(); - void case0611(); - void case0612(); - void case0613(); - void case0614(); - void case0615(); - void case0616(); - void case0617(); - void case0618(); - void case0619(); - void case0620(); - void case0621(); - void case0622(); - void case0623(); - void case0624(); - void case0625(); - void case0626(); - void case0627(); - void case0628(); - void case0629(); - void case0630(); - void case0631(); - void case0632(); - void case0633(); - void case0634(); - void case0635(); - void case0636(); - void case0637(); - void case0638(); - void case0639(); - void case0640(); - void case0641(); - void case0642(); - void case0643(); - void case0644(); - void case0645(); - void case0646(); - void case0647(); - void case0648(); - void case0649(); - void case0650(); - void case0651(); - void case0652(); - void case0653(); - void case0654(); - void case0655(); - void case0656(); - void case0657(); - void case0658(); - void case0659(); - void case0660(); - void case0661(); - void case0662(); - void case0663(); - void case0664(); - void case0665(); - void case0666(); - void case0667(); - void case0668(); - void case0669(); - void case0670(); - void case0671(); - void case0672(); - void case0673(); - void case0674(); - void case0675(); - void case0676(); - void case0677(); - void case0678(); - void case0679(); - void case0680(); - void case0681(); - void case0682(); - void case0683(); - void case0684(); - void case0685(); - void case0686(); - void case0687(); - void case0688(); - void case0689(); - void case0690(); - void case0691(); - void case0692(); - void case0693(); - void case0694(); - void case0695(); - void case0696(); - void case0697(); - void case0698(); - void case0699(); + void case0600(); + void case0601(); + void case0602(); + void case0603(); + void case0604(); + void case0605(); + void case0606(); + void case0607(); + void case0608(); + void case0609(); + void case0610(); + void case0611(); + void case0612(); + void case0613(); + void case0614(); + void case0615(); + void case0616(); + void case0617(); + void case0618(); + void case0619(); + void case0620(); + void case0621(); + void case0622(); + void case0623(); + void case0624(); + void case0625(); + void case0626(); + void case0627(); + void case0628(); + void case0629(); + void case0630(); + void case0631(); + void case0632(); + void case0633(); + void case0634(); + void case0635(); + void case0636(); + void case0637(); + void case0638(); + void case0639(); + void case0640(); + void case0641(); + void case0642(); + void case0643(); + void case0644(); + void case0645(); + void case0646(); + void case0647(); + void case0648(); + void case0649(); + void case0650(); + void case0651(); + void case0652(); + void case0653(); + void case0654(); + void case0655(); + void case0656(); + void case0657(); + void case0658(); + void case0659(); + void case0660(); + void case0661(); + void case0662(); + void case0663(); + void case0664(); + void case0665(); + void case0666(); + void case0667(); + void case0668(); + void case0669(); + void case0670(); + void case0671(); + void case0672(); + void case0673(); + void case0674(); + void case0675(); + void case0676(); + void case0677(); + void case0678(); + void case0679(); + void case0680(); + void case0681(); + void case0682(); + void case0683(); + void case0684(); + void case0685(); + void case0686(); + void case0687(); + void case0688(); + void case0689(); + void case0690(); + void case0691(); + void case0692(); + void case0693(); + void case0694(); + void case0695(); + void case0696(); + void case0697(); + void case0698(); + void case0699(); - void case0700(); - void case0701(); - void case0702(); - void case0703(); - void case0704(); - void case0705(); - void case0706(); - void case0707(); - void case0708(); - void case0709(); - void case0710(); - void case0711(); - void case0712(); - void case0713(); - void case0714(); - void case0715(); - void case0716(); - void case0717(); - void case0718(); - void case0719(); - void case0720(); - void case0721(); - void case0722(); - void case0723(); - void case0724(); - void case0725(); - void case0726(); - void case0727(); - void case0728(); - void case0729(); - void case0730(); - void case0731(); - void case0732(); - void case0733(); - void case0734(); - void case0735(); - void case0736(); - void case0737(); - void case0738(); - void case0739(); - void case0740(); - void case0741(); - void case0742(); - void case0743(); - void case0744(); - void case0745(); - void case0746(); - void case0747(); - void case0748(); - void case0749(); - void case0750(); - void case0751(); - void case0752(); - void case0753(); - void case0754(); - void case0755(); - void case0756(); - void case0757(); - void case0758(); - void case0759(); - void case0760(); - void case0761(); - void case0762(); - void case0763(); - void case0764(); - void case0765(); - void case0766(); - void case0767(); - void case0768(); - void case0769(); - void case0770(); - void case0771(); - void case0772(); - void case0773(); - void case0774(); - void case0775(); - void case0776(); - void case0777(); - void case0778(); - void case0779(); - void case0780(); - void case0781(); - void case0782(); - void case0783(); - void case0784(); - void case0785(); - void case0786(); - void case0787(); - void case0788(); - void case0789(); - void case0790(); - void case0791(); - void case0792(); - void case0793(); - void case0794(); - void case0795(); - void case0796(); - void case0797(); - void case0798(); - void case0799(); + void case0700(); + void case0701(); + void case0702(); + void case0703(); + void case0704(); + void case0705(); + void case0706(); + void case0707(); + void case0708(); + void case0709(); + void case0710(); + void case0711(); + void case0712(); + void case0713(); + void case0714(); + void case0715(); + void case0716(); + void case0717(); + void case0718(); + void case0719(); + void case0720(); + void case0721(); + void case0722(); + void case0723(); + void case0724(); + void case0725(); + void case0726(); + void case0727(); + void case0728(); + void case0729(); + void case0730(); + void case0731(); + void case0732(); + void case0733(); + void case0734(); + void case0735(); + void case0736(); + void case0737(); + void case0738(); + void case0739(); + void case0740(); + void case0741(); + void case0742(); + void case0743(); + void case0744(); + void case0745(); + void case0746(); + void case0747(); + void case0748(); + void case0749(); + void case0750(); + void case0751(); + void case0752(); + void case0753(); + void case0754(); + void case0755(); + void case0756(); + void case0757(); + void case0758(); + void case0759(); + void case0760(); + void case0761(); + void case0762(); + void case0763(); + void case0764(); + void case0765(); + void case0766(); + void case0767(); + void case0768(); + void case0769(); + void case0770(); + void case0771(); + void case0772(); + void case0773(); + void case0774(); + void case0775(); + void case0776(); + void case0777(); + void case0778(); + void case0779(); + void case0780(); + void case0781(); + void case0782(); + void case0783(); + void case0784(); + void case0785(); + void case0786(); + void case0787(); + void case0788(); + void case0789(); + void case0790(); + void case0791(); + void case0792(); + void case0793(); + void case0794(); + void case0795(); + void case0796(); + void case0797(); + void case0798(); + void case0799(); - void case0800(); - void case0801(); - void case0802(); - void case0803(); - void case0804(); - void case0805(); - void case0806(); - void case0807(); - void case0808(); - void case0809(); - void case0810(); - void case0811(); - void case0812(); - void case0813(); - void case0814(); - void case0815(); - void case0816(); - void case0817(); - void case0818(); - void case0819(); - void case0820(); - void case0821(); - void case0822(); - void case0823(); - void case0824(); - void case0825(); - void case0826(); - void case0827(); - void case0828(); - void case0829(); - void case0830(); - void case0831(); - void case0832(); - void case0833(); - void case0834(); - void case0835(); - void case0836(); - void case0837(); - void case0838(); - void case0839(); - void case0840(); - void case0841(); - void case0842(); - void case0843(); - void case0844(); - void case0845(); - void case0846(); - void case0847(); - void case0848(); - void case0849(); - void case0850(); - void case0851(); - void case0852(); - void case0853(); - void case0854(); - void case0855(); - void case0856(); - void case0857(); - void case0858(); - void case0859(); - void case0860(); - void case0861(); - void case0862(); - void case0863(); - void case0864(); - void case0865(); - void case0866(); - void case0867(); - void case0868(); - void case0869(); - void case0870(); - void case0871(); - void case0872(); - void case0873(); - void case0874(); - void case0875(); - void case0876(); - void case0877(); - void case0878(); - void case0879(); - void case0880(); - void case0881(); - void case0882(); - void case0883(); - void case0884(); - void case0885(); - void case0886(); - void case0887(); - void case0888(); - void case0889(); - void case0890(); - void case0891(); - void case0892(); - void case0893(); - void case0894(); - void case0895(); - void case0896(); - void case0897(); - void case0898(); - void case0899(); + void case0800(); + void case0801(); + void case0802(); + void case0803(); + void case0804(); + void case0805(); + void case0806(); + void case0807(); + void case0808(); + void case0809(); + void case0810(); + void case0811(); + void case0812(); + void case0813(); + void case0814(); + void case0815(); + void case0816(); + void case0817(); + void case0818(); + void case0819(); + void case0820(); + void case0821(); + void case0822(); + void case0823(); + void case0824(); + void case0825(); + void case0826(); + void case0827(); + void case0828(); + void case0829(); + void case0830(); + void case0831(); + void case0832(); + void case0833(); + void case0834(); + void case0835(); + void case0836(); + void case0837(); + void case0838(); + void case0839(); + void case0840(); + void case0841(); + void case0842(); + void case0843(); + void case0844(); + void case0845(); + void case0846(); + void case0847(); + void case0848(); + void case0849(); + void case0850(); + void case0851(); + void case0852(); + void case0853(); + void case0854(); + void case0855(); + void case0856(); + void case0857(); + void case0858(); + void case0859(); + void case0860(); + void case0861(); + void case0862(); + void case0863(); + void case0864(); + void case0865(); + void case0866(); + void case0867(); + void case0868(); + void case0869(); + void case0870(); + void case0871(); + void case0872(); + void case0873(); + void case0874(); + void case0875(); + void case0876(); + void case0877(); + void case0878(); + void case0879(); + void case0880(); + void case0881(); + void case0882(); + void case0883(); + void case0884(); + void case0885(); + void case0886(); + void case0887(); + void case0888(); + void case0889(); + void case0890(); + void case0891(); + void case0892(); + void case0893(); + void case0894(); + void case0895(); + void case0896(); + void case0897(); + void case0898(); + void case0899(); - void case0900(); - void case0901(); - void case0902(); - void case0903(); - void case0904(); - void case0905(); - void case0906(); - void case0907(); - void case0908(); - void case0909(); - void case0910(); - void case0911(); - void case0912(); - void case0913(); - void case0914(); - void case0915(); - void case0916(); - void case0917(); - void case0918(); - void case0919(); - void case0920(); - void case0921(); - void case0922(); - void case0923(); - void case0924(); - void case0925(); - void case0926(); - void case0927(); - void case0928(); - void case0929(); - void case0930(); - void case0931(); - void case0932(); - void case0933(); - void case0934(); - void case0935(); - void case0936(); - void case0937(); - void case0938(); - void case0939(); - void case0940(); - void case0941(); - void case0942(); - void case0943(); - void case0944(); - void case0945(); - void case0946(); - void case0947(); - void case0948(); - void case0949(); - void case0950(); - void case0951(); - void case0952(); - void case0953(); - void case0954(); - void case0955(); - void case0956(); - void case0957(); - void case0958(); - void case0959(); - void case0960(); - void case0961(); - void case0962(); - void case0963(); - void case0964(); - void case0965(); - void case0966(); - void case0967(); - void case0968(); - void case0969(); - void case0970(); - void case0971(); - void case0972(); - void case0973(); - void case0974(); - void case0975(); - void case0976(); - void case0977(); - void case0978(); - void case0979(); - void case0980(); - void case0981(); - void case0982(); - void case0983(); - void case0984(); - void case0985(); - void case0986(); - void case0987(); - void case0988(); - void case0989(); - void case0990(); - void case0991(); - void case0992(); - void case0993(); - void case0994(); - void case0995(); - void case0996(); - void case0997(); - void case0998(); - void case0999(); + void case0900(); + void case0901(); + void case0902(); + void case0903(); + void case0904(); + void case0905(); + void case0906(); + void case0907(); + void case0908(); + void case0909(); + void case0910(); + void case0911(); + void case0912(); + void case0913(); + void case0914(); + void case0915(); + void case0916(); + void case0917(); + void case0918(); + void case0919(); + void case0920(); + void case0921(); + void case0922(); + void case0923(); + void case0924(); + void case0925(); + void case0926(); + void case0927(); + void case0928(); + void case0929(); + void case0930(); + void case0931(); + void case0932(); + void case0933(); + void case0934(); + void case0935(); + void case0936(); + void case0937(); + void case0938(); + void case0939(); + void case0940(); + void case0941(); + void case0942(); + void case0943(); + void case0944(); + void case0945(); + void case0946(); + void case0947(); + void case0948(); + void case0949(); + void case0950(); + void case0951(); + void case0952(); + void case0953(); + void case0954(); + void case0955(); + void case0956(); + void case0957(); + void case0958(); + void case0959(); + void case0960(); + void case0961(); + void case0962(); + void case0963(); + void case0964(); + void case0965(); + void case0966(); + void case0967(); + void case0968(); + void case0969(); + void case0970(); + void case0971(); + void case0972(); + void case0973(); + void case0974(); + void case0975(); + void case0976(); + void case0977(); + void case0978(); + void case0979(); + void case0980(); + void case0981(); + void case0982(); + void case0983(); + void case0984(); + void case0985(); + void case0986(); + void case0987(); + void case0988(); + void case0989(); + void case0990(); + void case0991(); + void case0992(); + void case0993(); + void case0994(); + void case0995(); + void case0996(); + void case0997(); + void case0998(); + void case0999(); - void case1000(); - void case1001(); - void case1002(); - void case1003(); - void case1004(); - void case1005(); - void case1006(); - void case1007(); - void case1008(); - void case1009(); - void case1010(); - void case1011(); - void case1012(); - void case1013(); - void case1014(); - void case1015(); - void case1016(); - void case1017(); - void case1018(); - void case1019(); - void case1020(); - void case1021(); - void case1022(); - void case1023(); - void case1024(); - void case1025(); - void case1026(); - void case1027(); - void case1028(); - void case1029(); - void case1030(); - void case1031(); - void case1032(); - void case1033(); - void case1034(); - void case1035(); - void case1036(); - void case1037(); - void case1038(); - void case1039(); - void case1040(); - void case1041(); - void case1042(); - void case1043(); - void case1044(); - void case1045(); - void case1046(); - void case1047(); - void case1048(); - void case1049(); - void case1050(); - void case1051(); - void case1052(); - void case1053(); - void case1054(); - void case1055(); - void case1056(); - void case1057(); - void case1058(); - void case1059(); - void case1060(); - void case1061(); - void case1062(); - void case1063(); - void case1064(); - void case1065(); - void case1066(); - void case1067(); - void case1068(); - void case1069(); - void case1070(); - void case1071(); - void case1072(); - void case1073(); - void case1074(); - void case1075(); - void case1076(); - void case1077(); - void case1078(); - void case1079(); - void case1080(); - void case1081(); - void case1082(); - void case1083(); - void case1084(); - void case1085(); - void case1086(); - void case1087(); - void case1088(); - void case1089(); - void case1090(); - void case1091(); - void case1092(); - void case1093(); - void case1094(); - void case1095(); - void case1096(); - void case1097(); - void case1098(); - void case1099(); + void case1000(); + void case1001(); + void case1002(); + void case1003(); + void case1004(); + void case1005(); + void case1006(); + void case1007(); + void case1008(); + void case1009(); + void case1010(); + void case1011(); + void case1012(); + void case1013(); + void case1014(); + void case1015(); + void case1016(); + void case1017(); + void case1018(); + void case1019(); + void case1020(); + void case1021(); + void case1022(); + void case1023(); + void case1024(); + void case1025(); + void case1026(); + void case1027(); + void case1028(); + void case1029(); + void case1030(); + void case1031(); + void case1032(); + void case1033(); + void case1034(); + void case1035(); + void case1036(); + void case1037(); + void case1038(); + void case1039(); + void case1040(); + void case1041(); + void case1042(); + void case1043(); + void case1044(); + void case1045(); + void case1046(); + void case1047(); + void case1048(); + void case1049(); + void case1050(); + void case1051(); + void case1052(); + void case1053(); + void case1054(); + void case1055(); + void case1056(); + void case1057(); + void case1058(); + void case1059(); + void case1060(); + void case1061(); + void case1062(); + void case1063(); + void case1064(); + void case1065(); + void case1066(); + void case1067(); + void case1068(); + void case1069(); + void case1070(); + void case1071(); + void case1072(); + void case1073(); + void case1074(); + void case1075(); + void case1076(); + void case1077(); + void case1078(); + void case1079(); + void case1080(); + void case1081(); + void case1082(); + void case1083(); + void case1084(); + void case1085(); + void case1086(); + void case1087(); + void case1088(); + void case1089(); + void case1090(); + void case1091(); + void case1092(); + void case1093(); + void case1094(); + void case1095(); + void case1096(); + void case1097(); + void case1098(); + void case1099(); - void case1100(); - void case1101(); - void case1102(); - void case1103(); - void case1104(); - void case1105(); - void case1106(); - void case1107(); - void case1108(); - void case1109(); - void case1110(); - void case1111(); - void case1112(); - void case1113(); - void case1114(); - void case1115(); - void case1116(); - void case1117(); - void case1118(); - void case1119(); - void case1120(); - void case1121(); - void case1122(); - void case1123(); - void case1124(); - void case1125(); - void case1126(); - void case1127(); - void case1128(); - void case1129(); - void case1130(); - void case1131(); - void case1132(); - void case1133(); - void case1134(); - void case1135(); - void case1136(); - void case1137(); - void case1138(); - void case1139(); - void case1140(); - void case1141(); - void case1142(); - void case1143(); - void case1144(); - void case1145(); - void case1146(); - void case1147(); - void case1148(); - void case1149(); - void case1150(); - void case1151(); - void case1152(); - void case1153(); - void case1154(); - void case1155(); - void case1156(); - void case1157(); - void case1158(); - void case1159(); - void case1160(); - void case1161(); - void case1162(); - void case1163(); - void case1164(); - void case1165(); - void case1166(); - void case1167(); - void case1168(); - void case1169(); - void case1170(); - void case1171(); - void case1172(); - void case1173(); - void case1174(); - void case1175(); - void case1176(); - void case1177(); - void case1178(); - void case1179(); - void case1180(); - void case1181(); - void case1182(); - void case1183(); - void case1184(); - void case1185(); - void case1186(); - void case1187(); - void case1188(); - void case1189(); - void case1190(); - void case1191(); - void case1192(); - void case1193(); - void case1194(); - void case1195(); - void case1196(); - void case1197(); - void case1198(); - void case1199(); + void case1100(); + void case1101(); + void case1102(); + void case1103(); + void case1104(); + void case1105(); + void case1106(); + void case1107(); + void case1108(); + void case1109(); + void case1110(); + void case1111(); + void case1112(); + void case1113(); + void case1114(); + void case1115(); + void case1116(); + void case1117(); + void case1118(); + void case1119(); + void case1120(); + void case1121(); + void case1122(); + void case1123(); + void case1124(); + void case1125(); + void case1126(); + void case1127(); + void case1128(); + void case1129(); + void case1130(); + void case1131(); + void case1132(); + void case1133(); + void case1134(); + void case1135(); + void case1136(); + void case1137(); + void case1138(); + void case1139(); + void case1140(); + void case1141(); + void case1142(); + void case1143(); + void case1144(); + void case1145(); + void case1146(); + void case1147(); + void case1148(); + void case1149(); + void case1150(); + void case1151(); + void case1152(); + void case1153(); + void case1154(); + void case1155(); + void case1156(); + void case1157(); + void case1158(); + void case1159(); + void case1160(); + void case1161(); + void case1162(); + void case1163(); + void case1164(); + void case1165(); + void case1166(); + void case1167(); + void case1168(); + void case1169(); + void case1170(); + void case1171(); + void case1172(); + void case1173(); + void case1174(); + void case1175(); + void case1176(); + void case1177(); + void case1178(); + void case1179(); + void case1180(); + void case1181(); + void case1182(); + void case1183(); + void case1184(); + void case1185(); + void case1186(); + void case1187(); + void case1188(); + void case1189(); + void case1190(); + void case1191(); + void case1192(); + void case1193(); + void case1194(); + void case1195(); + void case1196(); + void case1197(); + void case1198(); + void case1199(); - void case1200(); - void case1201(); - void case1202(); - void case1203(); - void case1204(); - void case1205(); - void case1206(); - void case1207(); - void case1208(); - void case1209(); - void case1210(); - void case1211(); - void case1212(); - void case1213(); - void case1214(); - void case1215(); - void case1216(); - void case1217(); - void case1218(); - void case1219(); - void case1220(); - void case1221(); - void case1222(); - void case1223(); - void case1224(); - void case1225(); - void case1226(); - void case1227(); - void case1228(); - void case1229(); - void case1230(); - void case1231(); - void case1232(); - void case1233(); - void case1234(); - void case1235(); - void case1236(); - void case1237(); - void case1238(); - void case1239(); - void case1240(); - void case1241(); - void case1242(); - void case1243(); - void case1244(); - void case1245(); - void case1246(); - void case1247(); - void case1248(); - void case1249(); - void case1250(); - void case1251(); - void case1252(); - void case1253(); - void case1254(); - void case1255(); - void case1256(); - void case1257(); - void case1258(); - void case1259(); - void case1260(); - void case1261(); - void case1262(); - void case1263(); - void case1264(); - void case1265(); - void case1266(); - void case1267(); - void case1268(); - void case1269(); - void case1270(); - void case1271(); - void case1272(); - void case1273(); - void case1274(); - void case1275(); - void case1276(); - void case1277(); - void case1278(); - void case1279(); - void case1280(); - void case1281(); - void case1282(); - void case1283(); - void case1284(); - void case1285(); - void case1286(); - void case1287(); - void case1288(); - void case1289(); - void case1290(); - void case1291(); - void case1292(); - void case1293(); - void case1294(); - void case1295(); - void case1296(); - void case1297(); - void case1298(); - void case1299(); + void case1200(); + void case1201(); + void case1202(); + void case1203(); + void case1204(); + void case1205(); + void case1206(); + void case1207(); + void case1208(); + void case1209(); + void case1210(); + void case1211(); + void case1212(); + void case1213(); + void case1214(); + void case1215(); + void case1216(); + void case1217(); + void case1218(); + void case1219(); + void case1220(); + void case1221(); + void case1222(); + void case1223(); + void case1224(); + void case1225(); + void case1226(); + void case1227(); + void case1228(); + void case1229(); + void case1230(); + void case1231(); + void case1232(); + void case1233(); + void case1234(); + void case1235(); + void case1236(); + void case1237(); + void case1238(); + void case1239(); + void case1240(); + void case1241(); + void case1242(); + void case1243(); + void case1244(); + void case1245(); + void case1246(); + void case1247(); + void case1248(); + void case1249(); + void case1250(); + void case1251(); + void case1252(); + void case1253(); + void case1254(); + void case1255(); + void case1256(); + void case1257(); + void case1258(); + void case1259(); + void case1260(); + void case1261(); + void case1262(); + void case1263(); + void case1264(); + void case1265(); + void case1266(); + void case1267(); + void case1268(); + void case1269(); + void case1270(); + void case1271(); + void case1272(); + void case1273(); + void case1274(); + void case1275(); + void case1276(); + void case1277(); + void case1278(); + void case1279(); + void case1280(); + void case1281(); + void case1282(); + void case1283(); + void case1284(); + void case1285(); + void case1286(); + void case1287(); + void case1288(); + void case1289(); + void case1290(); + void case1291(); + void case1292(); + void case1293(); + void case1294(); + void case1295(); + void case1296(); + void case1297(); + void case1298(); + void case1299(); - void case1300(); - void case1301(); - void case1302(); - void case1303(); - void case1304(); - void case1305(); - void case1306(); - void case1307(); - void case1308(); - void case1309(); - void case1310(); - void case1311(); - void case1312(); - void case1313(); - void case1314(); - void case1315(); - void case1316(); - void case1317(); - void case1318(); - void case1319(); - void case1320(); - void case1321(); - void case1322(); - void case1323(); - void case1324(); - void case1325(); - void case1326(); - void case1327(); - void case1328(); - void case1329(); - void case1330(); - void case1331(); - void case1332(); - void case1333(); - void case1334(); - void case1335(); - void case1336(); - void case1337(); - void case1338(); - void case1339(); - void case1340(); - void case1341(); - void case1342(); - void case1343(); - void case1344(); - void case1345(); - void case1346(); - void case1347(); - void case1348(); - void case1349(); - void case1350(); - void case1351(); - void case1352(); - void case1353(); - void case1354(); - void case1355(); - void case1356(); - void case1357(); - void case1358(); - void case1359(); - void case1360(); - void case1361(); - void case1362(); - void case1363(); - void case1364(); - void case1365(); - void case1366(); - void case1367(); - void case1368(); - void case1369(); - void case1370(); - void case1371(); - void case1372(); - void case1373(); - void case1374(); - void case1375(); - void case1376(); - void case1377(); - void case1378(); - void case1379(); - void case1380(); - void case1381(); - void case1382(); - void case1383(); - void case1384(); - void case1385(); - void case1386(); - void case1387(); - void case1388(); - void case1389(); - void case1390(); - void case1391(); - void case1392(); - void case1393(); - void case1394(); - void case1395(); - void case1396(); - void case1397(); - void case1398(); - void case1399(); + void case1300(); + void case1301(); + void case1302(); + void case1303(); + void case1304(); + void case1305(); + void case1306(); + void case1307(); + void case1308(); + void case1309(); + void case1310(); + void case1311(); + void case1312(); + void case1313(); + void case1314(); + void case1315(); + void case1316(); + void case1317(); + void case1318(); + void case1319(); + void case1320(); + void case1321(); + void case1322(); + void case1323(); + void case1324(); + void case1325(); + void case1326(); + void case1327(); + void case1328(); + void case1329(); + void case1330(); + void case1331(); + void case1332(); + void case1333(); + void case1334(); + void case1335(); + void case1336(); + void case1337(); + void case1338(); + void case1339(); + void case1340(); + void case1341(); + void case1342(); + void case1343(); + void case1344(); + void case1345(); + void case1346(); + void case1347(); + void case1348(); + void case1349(); + void case1350(); + void case1351(); + void case1352(); + void case1353(); + void case1354(); + void case1355(); + void case1356(); + void case1357(); + void case1358(); + void case1359(); + void case1360(); + void case1361(); + void case1362(); + void case1363(); + void case1364(); + void case1365(); + void case1366(); + void case1367(); + void case1368(); + void case1369(); + void case1370(); + void case1371(); + void case1372(); + void case1373(); + void case1374(); + void case1375(); + void case1376(); + void case1377(); + void case1378(); + void case1379(); + void case1380(); + void case1381(); + void case1382(); + void case1383(); + void case1384(); + void case1385(); + void case1386(); + void case1387(); + void case1388(); + void case1389(); + void case1390(); + void case1391(); + void case1392(); + void case1393(); + void case1394(); + void case1395(); + void case1396(); + void case1397(); + void case1398(); + void case1399(); - void case1400(); - void case1401(); - void case1402(); - void case1403(); - void case1404(); - void case1405(); - void case1406(); - void case1407(); - void case1408(); - void case1409(); - void case1410(); - void case1411(); - void case1412(); - void case1413(); - void case1414(); - void case1415(); - void case1416(); - void case1417(); - void case1418(); - void case1419(); - void case1420(); - void case1421(); - void case1422(); - void case1423(); - void case1424(); - void case1425(); - void case1426(); - void case1427(); - void case1428(); - void case1429(); - void case1430(); - void case1431(); - void case1432(); - void case1433(); - void case1434(); - void case1435(); - void case1436(); - void case1437(); - void case1438(); - void case1439(); - void case1440(); - void case1441(); - void case1442(); - void case1443(); - void case1444(); - void case1445(); - void case1446(); - void case1447(); - void case1448(); - void case1449(); - void case1450(); - void case1451(); - void case1452(); - void case1453(); - void case1454(); - void case1455(); - void case1456(); - void case1457(); - void case1458(); - void case1459(); - void case1460(); - void case1461(); - void case1462(); - void case1463(); - void case1464(); - void case1465(); - void case1466(); - void case1467(); - void case1468(); - void case1469(); - void case1470(); - void case1471(); - void case1472(); - void case1473(); - void case1474(); - void case1475(); - void case1476(); - void case1477(); - void case1478(); - void case1479(); - void case1480(); - void case1481(); - void case1482(); - void case1483(); - void case1484(); - void case1485(); - void case1486(); - void case1487(); - void case1488(); - void case1489(); - void case1490(); - void case1491(); - void case1492(); - void case1493(); - void case1494(); - void case1495(); - void case1496(); - void case1497(); - void case1498(); - void case1499(); + void case1400(); + void case1401(); + void case1402(); + void case1403(); + void case1404(); + void case1405(); + void case1406(); + void case1407(); + void case1408(); + void case1409(); + void case1410(); + void case1411(); + void case1412(); + void case1413(); + void case1414(); + void case1415(); + void case1416(); + void case1417(); + void case1418(); + void case1419(); + void case1420(); + void case1421(); + void case1422(); + void case1423(); + void case1424(); + void case1425(); + void case1426(); + void case1427(); + void case1428(); + void case1429(); + void case1430(); + void case1431(); + void case1432(); + void case1433(); + void case1434(); + void case1435(); + void case1436(); + void case1437(); + void case1438(); + void case1439(); + void case1440(); + void case1441(); + void case1442(); + void case1443(); + void case1444(); + void case1445(); + void case1446(); + void case1447(); + void case1448(); + void case1449(); + void case1450(); + void case1451(); + void case1452(); + void case1453(); + void case1454(); + void case1455(); + void case1456(); + void case1457(); + void case1458(); + void case1459(); + void case1460(); + void case1461(); + void case1462(); + void case1463(); + void case1464(); + void case1465(); + void case1466(); + void case1467(); + void case1468(); + void case1469(); + void case1470(); + void case1471(); + void case1472(); + void case1473(); + void case1474(); + void case1475(); + void case1476(); + void case1477(); + void case1478(); + void case1479(); + void case1480(); + void case1481(); + void case1482(); + void case1483(); + void case1484(); + void case1485(); + void case1486(); + void case1487(); + void case1488(); + void case1489(); + void case1490(); + void case1491(); + void case1492(); + void case1493(); + void case1494(); + void case1495(); + void case1496(); + void case1497(); + void case1498(); + void case1499(); - void case1500(); - void case1501(); - void case1502(); - void case1503(); - void case1504(); - void case1505(); - void case1506(); - void case1507(); - void case1508(); - void case1509(); - void case1510(); - void case1511(); - void case1512(); - void case1513(); - void case1514(); - void case1515(); - void case1516(); - void case1517(); - void case1518(); - void case1519(); - void case1520(); - void case1521(); - void case1522(); - void case1523(); - void case1524(); - void case1525(); - void case1526(); - void case1527(); - void case1528(); - void case1529(); - void case1530(); - void case1531(); - void case1532(); - void case1533(); - void case1534(); - void case1535(); - void case1536(); - void case1537(); - void case1538(); - void case1539(); - void case1540(); - void case1541(); - void case1542(); - void case1543(); - void case1544(); - void case1545(); - void case1546(); - void case1547(); - void case1548(); - void case1549(); - void case1550(); - void case1551(); - void case1552(); - void case1553(); - void case1554(); - void case1555(); - void case1556(); - void case1557(); - void case1558(); - void case1559(); - void case1560(); - void case1561(); - void case1562(); - void case1563(); - void case1564(); - void case1565(); - void case1566(); - void case1567(); - void case1568(); - void case1569(); - void case1570(); - void case1571(); - void case1572(); - void case1573(); - void case1574(); - void case1575(); - void case1576(); - void case1577(); - void case1578(); - void case1579(); - void case1580(); - void case1581(); - void case1582(); - void case1583(); - void case1584(); - void case1585(); - void case1586(); - void case1587(); - void case1588(); - void case1589(); - void case1590(); - void case1591(); - void case1592(); - void case1593(); - void case1594(); - void case1595(); - void case1596(); - void case1597(); - void case1598(); - void case1599(); + void case1500(); + void case1501(); + void case1502(); + void case1503(); + void case1504(); + void case1505(); + void case1506(); + void case1507(); + void case1508(); + void case1509(); + void case1510(); + void case1511(); + void case1512(); + void case1513(); + void case1514(); + void case1515(); + void case1516(); + void case1517(); + void case1518(); + void case1519(); + void case1520(); + void case1521(); + void case1522(); + void case1523(); + void case1524(); + void case1525(); + void case1526(); + void case1527(); + void case1528(); + void case1529(); + void case1530(); + void case1531(); + void case1532(); + void case1533(); + void case1534(); + void case1535(); + void case1536(); + void case1537(); + void case1538(); + void case1539(); + void case1540(); + void case1541(); + void case1542(); + void case1543(); + void case1544(); + void case1545(); + void case1546(); + void case1547(); + void case1548(); + void case1549(); + void case1550(); + void case1551(); + void case1552(); + void case1553(); + void case1554(); + void case1555(); + void case1556(); + void case1557(); + void case1558(); + void case1559(); + void case1560(); + void case1561(); + void case1562(); + void case1563(); + void case1564(); + void case1565(); + void case1566(); + void case1567(); + void case1568(); + void case1569(); + void case1570(); + void case1571(); + void case1572(); + void case1573(); + void case1574(); + void case1575(); + void case1576(); + void case1577(); + void case1578(); + void case1579(); + void case1580(); + void case1581(); + void case1582(); + void case1583(); + void case1584(); + void case1585(); + void case1586(); + void case1587(); + void case1588(); + void case1589(); + void case1590(); + void case1591(); + void case1592(); + void case1593(); + void case1594(); + void case1595(); + void case1596(); + void case1597(); + void case1598(); + void case1599(); - void case1600(); - void case1601(); - void case1602(); - void case1603(); - void case1604(); - void case1605(); - void case1606(); - void case1607(); - void case1608(); - void case1609(); - void case1610(); - void case1611(); - void case1612(); - void case1613(); - void case1614(); - void case1615(); - void case1616(); - void case1617(); - void case1618(); - void case1619(); - void case1620(); - void case1621(); - void case1622(); - void case1623(); - void case1624(); - void case1625(); - void case1626(); - void case1627(); - void case1628(); - void case1629(); - void case1630(); - void case1631(); - void case1632(); - void case1633(); - void case1634(); - void case1635(); - void case1636(); - void case1637(); - void case1638(); - void case1639(); - void case1640(); - void case1641(); - void case1642(); - void case1643(); - void case1644(); - void case1645(); - void case1646(); - void case1647(); - void case1648(); - void case1649(); - void case1650(); - void case1651(); - void case1652(); - void case1653(); - void case1654(); - void case1655(); - void case1656(); - void case1657(); - void case1658(); - void case1659(); - void case1660(); - void case1661(); - void case1662(); - void case1663(); - void case1664(); - void case1665(); - void case1666(); - void case1667(); - void case1668(); - void case1669(); - void case1670(); - void case1671(); - void case1672(); - void case1673(); - void case1674(); - void case1675(); - void case1676(); - void case1677(); - void case1678(); - void case1679(); - void case1680(); - void case1681(); - void case1682(); - void case1683(); - void case1684(); - void case1685(); - void case1686(); - void case1687(); - void case1688(); - void case1689(); - void case1690(); - void case1691(); - void case1692(); - void case1693(); - void case1694(); - void case1695(); - void case1696(); - void case1697(); - void case1698(); - void case1699(); + void case1600(); + void case1601(); + void case1602(); + void case1603(); + void case1604(); + void case1605(); + void case1606(); + void case1607(); + void case1608(); + void case1609(); + void case1610(); + void case1611(); + void case1612(); + void case1613(); + void case1614(); + void case1615(); + void case1616(); + void case1617(); + void case1618(); + void case1619(); + void case1620(); + void case1621(); + void case1622(); + void case1623(); + void case1624(); + void case1625(); + void case1626(); + void case1627(); + void case1628(); + void case1629(); + void case1630(); + void case1631(); + void case1632(); + void case1633(); + void case1634(); + void case1635(); + void case1636(); + void case1637(); + void case1638(); + void case1639(); + void case1640(); + void case1641(); + void case1642(); + void case1643(); + void case1644(); + void case1645(); + void case1646(); + void case1647(); + void case1648(); + void case1649(); + void case1650(); + void case1651(); + void case1652(); + void case1653(); + void case1654(); + void case1655(); + void case1656(); + void case1657(); + void case1658(); + void case1659(); + void case1660(); + void case1661(); + void case1662(); + void case1663(); + void case1664(); + void case1665(); + void case1666(); + void case1667(); + void case1668(); + void case1669(); + void case1670(); + void case1671(); + void case1672(); + void case1673(); + void case1674(); + void case1675(); + void case1676(); + void case1677(); + void case1678(); + void case1679(); + void case1680(); + void case1681(); + void case1682(); + void case1683(); + void case1684(); + void case1685(); + void case1686(); + void case1687(); + void case1688(); + void case1689(); + void case1690(); + void case1691(); + void case1692(); + void case1693(); + void case1694(); + void case1695(); + void case1696(); + void case1697(); + void case1698(); + void case1699(); - void case1700(); - void case1701(); - void case1702(); - void case1703(); - void case1704(); - void case1705(); - void case1706(); - void case1707(); - void case1708(); - void case1709(); - void case1710(); - void case1711(); - void case1712(); - void case1713(); - void case1714(); - void case1715(); - void case1716(); - void case1717(); - void case1718(); - void case1719(); - void case1720(); - void case1721(); - void case1722(); - void case1723(); - void case1724(); - void case1725(); - void case1726(); - void case1727(); - void case1728(); - void case1729(); - void case1730(); - void case1731(); - void case1732(); - void case1733(); - void case1734(); - void case1735(); - void case1736(); - void case1737(); - void case1738(); - void case1739(); - void case1740(); - void case1741(); - void case1742(); - void case1743(); - void case1744(); - void case1745(); - void case1746(); - void case1747(); - void case1748(); - void case1749(); - void case1750(); - void case1751(); - void case1752(); - void case1753(); - void case1754(); - void case1755(); - void case1756(); - void case1757(); - void case1758(); - void case1759(); - void case1760(); - void case1761(); - void case1762(); - void case1763(); - void case1764(); - void case1765(); - void case1766(); - void case1767(); - void case1768(); - void case1769(); - void case1770(); - void case1771(); - void case1772(); - void case1773(); - void case1774(); - void case1775(); - void case1776(); - void case1777(); - void case1778(); - void case1779(); - void case1780(); - void case1781(); - void case1782(); - void case1783(); - void case1784(); - void case1785(); - void case1786(); - void case1787(); - void case1788(); - void case1789(); - void case1790(); - void case1791(); - void case1792(); - void case1793(); - void case1794(); - void case1795(); - void case1796(); - void case1797(); - void case1798(); - void case1799(); + void case1700(); + void case1701(); + void case1702(); + void case1703(); + void case1704(); + void case1705(); + void case1706(); + void case1707(); + void case1708(); + void case1709(); + void case1710(); + void case1711(); + void case1712(); + void case1713(); + void case1714(); + void case1715(); + void case1716(); + void case1717(); + void case1718(); + void case1719(); + void case1720(); + void case1721(); + void case1722(); + void case1723(); + void case1724(); + void case1725(); + void case1726(); + void case1727(); + void case1728(); + void case1729(); + void case1730(); + void case1731(); + void case1732(); + void case1733(); + void case1734(); + void case1735(); + void case1736(); + void case1737(); + void case1738(); + void case1739(); + void case1740(); + void case1741(); + void case1742(); + void case1743(); + void case1744(); + void case1745(); + void case1746(); + void case1747(); + void case1748(); + void case1749(); + void case1750(); + void case1751(); + void case1752(); + void case1753(); + void case1754(); + void case1755(); + void case1756(); + void case1757(); + void case1758(); + void case1759(); + void case1760(); + void case1761(); + void case1762(); + void case1763(); + void case1764(); + void case1765(); + void case1766(); + void case1767(); + void case1768(); + void case1769(); + void case1770(); + void case1771(); + void case1772(); + void case1773(); + void case1774(); + void case1775(); + void case1776(); + void case1777(); + void case1778(); + void case1779(); + void case1780(); + void case1781(); + void case1782(); + void case1783(); + void case1784(); + void case1785(); + void case1786(); + void case1787(); + void case1788(); + void case1789(); + void case1790(); + void case1791(); + void case1792(); + void case1793(); + void case1794(); + void case1795(); + void case1796(); + void case1797(); + void case1798(); + void case1799(); - void case1800(); - void case1801(); - void case1802(); - void case1803(); - void case1804(); - void case1805(); - void case1806(); - void case1807(); - void case1808(); - void case1809(); - void case1810(); - void case1811(); - void case1812(); - void case1813(); - void case1814(); - void case1815(); - void case1816(); - void case1817(); - void case1818(); - void case1819(); - void case1820(); - void case1821(); - void case1822(); - void case1823(); - void case1824(); - void case1825(); - void case1826(); - void case1827(); - void case1828(); - void case1829(); - void case1830(); - void case1831(); - void case1832(); - void case1833(); - void case1834(); - void case1835(); - void case1836(); - void case1837(); - void case1838(); - void case1839(); - void case1840(); - void case1841(); - void case1842(); - void case1843(); - void case1844(); - void case1845(); - void case1846(); - void case1847(); - void case1848(); - void case1849(); - void case1850(); - void case1851(); - void case1852(); - void case1853(); - void case1854(); - void case1855(); - void case1856(); - void case1857(); - void case1858(); - void case1859(); - void case1860(); - void case1861(); - void case1862(); - void case1863(); - void case1864(); - void case1865(); - void case1866(); - void case1867(); - void case1868(); - void case1869(); - void case1870(); - void case1871(); - void case1872(); - void case1873(); - void case1874(); - void case1875(); - void case1876(); - void case1877(); - void case1878(); - void case1879(); - void case1880(); - void case1881(); - void case1882(); - void case1883(); - void case1884(); - void case1885(); - void case1886(); - void case1887(); - void case1888(); - void case1889(); - void case1890(); - void case1891(); - void case1892(); - void case1893(); - void case1894(); - void case1895(); - void case1896(); - void case1897(); - void case1898(); - void case1899(); + void case1800(); + void case1801(); + void case1802(); + void case1803(); + void case1804(); + void case1805(); + void case1806(); + void case1807(); + void case1808(); + void case1809(); + void case1810(); + void case1811(); + void case1812(); + void case1813(); + void case1814(); + void case1815(); + void case1816(); + void case1817(); + void case1818(); + void case1819(); + void case1820(); + void case1821(); + void case1822(); + void case1823(); + void case1824(); + void case1825(); + void case1826(); + void case1827(); + void case1828(); + void case1829(); + void case1830(); + void case1831(); + void case1832(); + void case1833(); + void case1834(); + void case1835(); + void case1836(); + void case1837(); + void case1838(); + void case1839(); + void case1840(); + void case1841(); + void case1842(); + void case1843(); + void case1844(); + void case1845(); + void case1846(); + void case1847(); + void case1848(); + void case1849(); + void case1850(); + void case1851(); + void case1852(); + void case1853(); + void case1854(); + void case1855(); + void case1856(); + void case1857(); + void case1858(); + void case1859(); + void case1860(); + void case1861(); + void case1862(); + void case1863(); + void case1864(); + void case1865(); + void case1866(); + void case1867(); + void case1868(); + void case1869(); + void case1870(); + void case1871(); + void case1872(); + void case1873(); + void case1874(); + void case1875(); + void case1876(); + void case1877(); + void case1878(); + void case1879(); + void case1880(); + void case1881(); + void case1882(); + void case1883(); + void case1884(); + void case1885(); + void case1886(); + void case1887(); + void case1888(); + void case1889(); + void case1890(); + void case1891(); + void case1892(); + void case1893(); + void case1894(); + void case1895(); + void case1896(); + void case1897(); + void case1898(); + void case1899(); - void case1900(); - void case1901(); - void case1902(); - void case1903(); - void case1904(); - void case1905(); - void case1906(); - void case1907(); - void case1908(); - void case1909(); - void case1910(); - void case1911(); - void case1912(); - void case1913(); - void case1914(); - void case1915(); - void case1916(); - void case1917(); - void case1918(); - void case1919(); - void case1920(); - void case1921(); - void case1922(); - void case1923(); - void case1924(); - void case1925(); - void case1926(); - void case1927(); - void case1928(); - void case1929(); - void case1930(); - void case1931(); - void case1932(); - void case1933(); - void case1934(); - void case1935(); - void case1936(); - void case1937(); - void case1938(); - void case1939(); - void case1940(); - void case1941(); - void case1942(); - void case1943(); - void case1944(); - void case1945(); - void case1946(); - void case1947(); - void case1948(); - void case1949(); - void case1950(); - void case1951(); - void case1952(); - void case1953(); - void case1954(); - void case1955(); - void case1956(); - void case1957(); - void case1958(); - void case1959(); - void case1960(); - void case1961(); - void case1962(); - void case1963(); - void case1964(); - void case1965(); - void case1966(); - void case1967(); - void case1968(); - void case1969(); - void case1970(); - void case1971(); - void case1972(); - void case1973(); - void case1974(); - void case1975(); - void case1976(); - void case1977(); - void case1978(); - void case1979(); - void case1980(); - void case1981(); - void case1982(); - void case1983(); - void case1984(); - void case1985(); - void case1986(); - void case1987(); - void case1988(); - void case1989(); - void case1990(); - void case1991(); - void case1992(); - void case1993(); - void case1994(); - void case1995(); - void case1996(); - void case1997(); - void case1998(); - void case1999(); + void case1900(); + void case1901(); + void case1902(); + void case1903(); + void case1904(); + void case1905(); + void case1906(); + void case1907(); + void case1908(); + void case1909(); + void case1910(); + void case1911(); + void case1912(); + void case1913(); + void case1914(); + void case1915(); + void case1916(); + void case1917(); + void case1918(); + void case1919(); + void case1920(); + void case1921(); + void case1922(); + void case1923(); + void case1924(); + void case1925(); + void case1926(); + void case1927(); + void case1928(); + void case1929(); + void case1930(); + void case1931(); + void case1932(); + void case1933(); + void case1934(); + void case1935(); + void case1936(); + void case1937(); + void case1938(); + void case1939(); + void case1940(); + void case1941(); + void case1942(); + void case1943(); + void case1944(); + void case1945(); + void case1946(); + void case1947(); + void case1948(); + void case1949(); + void case1950(); + void case1951(); + void case1952(); + void case1953(); + void case1954(); + void case1955(); + void case1956(); + void case1957(); + void case1958(); + void case1959(); + void case1960(); + void case1961(); + void case1962(); + void case1963(); + void case1964(); + void case1965(); + void case1966(); + void case1967(); + void case1968(); + void case1969(); + void case1970(); + void case1971(); + void case1972(); + void case1973(); + void case1974(); + void case1975(); + void case1976(); + void case1977(); + void case1978(); + void case1979(); + void case1980(); + void case1981(); + void case1982(); + void case1983(); + void case1984(); + void case1985(); + void case1986(); + void case1987(); + void case1988(); + void case1989(); + void case1990(); + void case1991(); + void case1992(); + void case1993(); + void case1994(); + void case1995(); + void case1996(); + void case1997(); + void case1998(); + void case1999(); - void case2000(); - void case2001(); - void case2002(); - void case2003(); - void case2004(); - void case2005(); - void case2006(); - void case2007(); - void case2008(); - void case2009(); - void case2010(); - void case2011(); - void case2012(); - void case2013(); - void case2014(); - void case2015(); - void case2016(); - void case2017(); - void case2018(); - void case2019(); - void case2020(); - void case2021(); - void case2022(); - void case2023(); - void case2024(); - void case2025(); - void case2026(); - void case2027(); - void case2028(); - void case2029(); - void case2030(); - void case2031(); - void case2032(); - void case2033(); - void case2034(); - void case2035(); - void case2036(); - void case2037(); - void case2038(); - void case2039(); - void case2040(); - void case2041(); - void case2042(); - void case2043(); - void case2044(); - void case2045(); - void case2046(); - void case2047(); - void case2048(); - void case2049(); - void case2050(); - void case2051(); - void case2052(); - void case2053(); - void case2054(); - void case2055(); - void case2056(); - void case2057(); - void case2058(); - void case2059(); - void case2060(); - void case2061(); - void case2062(); - void case2063(); - void case2064(); - void case2065(); - void case2066(); - void case2067(); - void case2068(); - void case2069(); - void case2070(); - void case2071(); - void case2072(); - void case2073(); - void case2074(); - void case2075(); - void case2076(); - void case2077(); - void case2078(); - void case2079(); - void case2080(); - void case2081(); - void case2082(); - void case2083(); - void case2084(); - void case2085(); - void case2086(); - void case2087(); - void case2088(); - void case2089(); - void case2090(); - void case2091(); - void case2092(); - void case2093(); - void case2094(); - void case2095(); - void case2096(); - void case2097(); - void case2098(); - void case2099(); + void case2000(); + void case2001(); + void case2002(); + void case2003(); + void case2004(); + void case2005(); + void case2006(); + void case2007(); + void case2008(); + void case2009(); + void case2010(); + void case2011(); + void case2012(); + void case2013(); + void case2014(); + void case2015(); + void case2016(); + void case2017(); + void case2018(); + void case2019(); + void case2020(); + void case2021(); + void case2022(); + void case2023(); + void case2024(); + void case2025(); + void case2026(); + void case2027(); + void case2028(); + void case2029(); + void case2030(); + void case2031(); + void case2032(); + void case2033(); + void case2034(); + void case2035(); + void case2036(); + void case2037(); + void case2038(); + void case2039(); + void case2040(); + void case2041(); + void case2042(); + void case2043(); + void case2044(); + void case2045(); + void case2046(); + void case2047(); + void case2048(); + void case2049(); + void case2050(); + void case2051(); + void case2052(); + void case2053(); + void case2054(); + void case2055(); + void case2056(); + void case2057(); + void case2058(); + void case2059(); + void case2060(); + void case2061(); + void case2062(); + void case2063(); + void case2064(); + void case2065(); + void case2066(); + void case2067(); + void case2068(); + void case2069(); + void case2070(); + void case2071(); + void case2072(); + void case2073(); + void case2074(); + void case2075(); + void case2076(); + void case2077(); + void case2078(); + void case2079(); + void case2080(); + void case2081(); + void case2082(); + void case2083(); + void case2084(); + void case2085(); + void case2086(); + void case2087(); + void case2088(); + void case2089(); + void case2090(); + void case2091(); + void case2092(); + void case2093(); + void case2094(); + void case2095(); + void case2096(); + void case2097(); + void case2098(); + void case2099(); - void case2100(); - void case2101(); - void case2102(); - void case2103(); - void case2104(); - void case2105(); - void case2106(); - void case2107(); - void case2108(); - void case2109(); - void case2110(); - void case2111(); - void case2112(); - void case2113(); - void case2114(); - void case2115(); - void case2116(); - void case2117(); - void case2118(); - void case2119(); - void case2120(); - void case2121(); - void case2122(); - void case2123(); - void case2124(); - void case2125(); - void case2126(); - void case2127(); - void case2128(); - void case2129(); - void case2130(); - void case2131(); - void case2132(); - void case2133(); - void case2134(); - void case2135(); - void case2136(); - void case2137(); - void case2138(); - void case2139(); - void case2140(); - void case2141(); - void case2142(); - void case2143(); - void case2144(); - void case2145(); - void case2146(); - void case2147(); - void case2148(); - void case2149(); - void case2150(); - void case2151(); - void case2152(); - void case2153(); - void case2154(); - void case2155(); - void case2156(); - void case2157(); - void case2158(); - void case2159(); - void case2160(); - void case2161(); - void case2162(); - void case2163(); - void case2164(); - void case2165(); - void case2166(); - void case2167(); - void case2168(); - void case2169(); - void case2170(); - void case2171(); - void case2172(); - void case2173(); - void case2174(); - void case2175(); - void case2176(); - void case2177(); - void case2178(); - void case2179(); - void case2180(); - void case2181(); - void case2182(); - void case2183(); - void case2184(); - void case2185(); - void case2186(); - void case2187(); - void case2188(); - void case2189(); - void case2190(); - void case2191(); - void case2192(); - void case2193(); - void case2194(); - void case2195(); - void case2196(); - void case2197(); - void case2198(); - void case2199(); + void case2100(); + void case2101(); + void case2102(); + void case2103(); + void case2104(); + void case2105(); + void case2106(); + void case2107(); + void case2108(); + void case2109(); + void case2110(); + void case2111(); + void case2112(); + void case2113(); + void case2114(); + void case2115(); + void case2116(); + void case2117(); + void case2118(); + void case2119(); + void case2120(); + void case2121(); + void case2122(); + void case2123(); + void case2124(); + void case2125(); + void case2126(); + void case2127(); + void case2128(); + void case2129(); + void case2130(); + void case2131(); + void case2132(); + void case2133(); + void case2134(); + void case2135(); + void case2136(); + void case2137(); + void case2138(); + void case2139(); + void case2140(); + void case2141(); + void case2142(); + void case2143(); + void case2144(); + void case2145(); + void case2146(); + void case2147(); + void case2148(); + void case2149(); + void case2150(); + void case2151(); + void case2152(); + void case2153(); + void case2154(); + void case2155(); + void case2156(); + void case2157(); + void case2158(); + void case2159(); + void case2160(); + void case2161(); + void case2162(); + void case2163(); + void case2164(); + void case2165(); + void case2166(); + void case2167(); + void case2168(); + void case2169(); + void case2170(); + void case2171(); + void case2172(); + void case2173(); + void case2174(); + void case2175(); + void case2176(); + void case2177(); + void case2178(); + void case2179(); + void case2180(); + void case2181(); + void case2182(); + void case2183(); + void case2184(); + void case2185(); + void case2186(); + void case2187(); + void case2188(); + void case2189(); + void case2190(); + void case2191(); + void case2192(); + void case2193(); + void case2194(); + void case2195(); + void case2196(); + void case2197(); + void case2198(); + void case2199(); - void case2200(); - void case2201(); - void case2202(); - void case2203(); - void case2204(); - void case2205(); - void case2206(); - void case2207(); - void case2208(); - void case2209(); - void case2210(); - void case2211(); - void case2212(); - void case2213(); - void case2214(); - void case2215(); - void case2216(); - void case2217(); - void case2218(); - void case2219(); - void case2220(); - void case2221(); - void case2222(); - void case2223(); - void case2224(); - void case2225(); - void case2226(); - void case2227(); - void case2228(); - void case2229(); - void case2230(); - void case2231(); - void case2232(); - void case2233(); - void case2234(); - void case2235(); - void case2236(); - void case2237(); - void case2238(); - void case2239(); - void case2240(); - void case2241(); - void case2242(); - void case2243(); - void case2244(); - void case2245(); - void case2246(); - void case2247(); - void case2248(); - void case2249(); - void case2250(); - void case2251(); - void case2252(); - void case2253(); - void case2254(); - void case2255(); - void case2256(); - void case2257(); - void case2258(); - void case2259(); - void case2260(); - void case2261(); - void case2262(); - void case2263(); - void case2264(); - void case2265(); - void case2266(); - void case2267(); - void case2268(); - void case2269(); - void case2270(); - void case2271(); - void case2272(); - void case2273(); - void case2274(); - void case2275(); - void case2276(); - void case2277(); - void case2278(); - void case2279(); - void case2280(); - void case2281(); - void case2282(); - void case2283(); - void case2284(); - void case2285(); - void case2286(); - void case2287(); - void case2288(); - void case2289(); - void case2290(); - void case2291(); - void case2292(); - void case2293(); - void case2294(); - void case2295(); - void case2296(); - void case2297(); - void case2298(); - void case2299(); + void case2200(); + void case2201(); + void case2202(); + void case2203(); + void case2204(); + void case2205(); + void case2206(); + void case2207(); + void case2208(); + void case2209(); + void case2210(); + void case2211(); + void case2212(); + void case2213(); + void case2214(); + void case2215(); + void case2216(); + void case2217(); + void case2218(); + void case2219(); + void case2220(); + void case2221(); + void case2222(); + void case2223(); + void case2224(); + void case2225(); + void case2226(); + void case2227(); + void case2228(); + void case2229(); + void case2230(); + void case2231(); + void case2232(); + void case2233(); + void case2234(); + void case2235(); + void case2236(); + void case2237(); + void case2238(); + void case2239(); + void case2240(); + void case2241(); + void case2242(); + void case2243(); + void case2244(); + void case2245(); + void case2246(); + void case2247(); + void case2248(); + void case2249(); + void case2250(); + void case2251(); + void case2252(); + void case2253(); + void case2254(); + void case2255(); + void case2256(); + void case2257(); + void case2258(); + void case2259(); + void case2260(); + void case2261(); + void case2262(); + void case2263(); + void case2264(); + void case2265(); + void case2266(); + void case2267(); + void case2268(); + void case2269(); + void case2270(); + void case2271(); + void case2272(); + void case2273(); + void case2274(); + void case2275(); + void case2276(); + void case2277(); + void case2278(); + void case2279(); + void case2280(); + void case2281(); + void case2282(); + void case2283(); + void case2284(); + void case2285(); + void case2286(); + void case2287(); + void case2288(); + void case2289(); + void case2290(); + void case2291(); + void case2292(); + void case2293(); + void case2294(); + void case2295(); + void case2296(); + void case2297(); + void case2298(); + void case2299(); - void case2300(); - void case2301(); - void case2302(); - void case2303(); - void case2304(); - void case2305(); - void case2306(); - void case2307(); - void case2308(); - void case2309(); - void case2310(); - void case2311(); - void case2312(); - void case2313(); - void case2314(); - void case2315(); - void case2316(); - void case2317(); - void case2318(); - void case2319(); - void case2320(); - void case2321(); - void case2322(); - void case2323(); - void case2324(); - void case2325(); - void case2326(); - void case2327(); - void case2328(); - void case2329(); - void case2330(); - void case2331(); - void case2332(); - void case2333(); - void case2334(); - void case2335(); - void case2336(); - void case2337(); - void case2338(); - void case2339(); - void case2340(); - void case2341(); - void case2342(); - void case2343(); - void case2344(); - void case2345(); - void case2346(); - void case2347(); - void case2348(); - void case2349(); - void case2350(); - void case2351(); - void case2352(); - void case2353(); - void case2354(); - void case2355(); - void case2356(); - void case2357(); - void case2358(); - void case2359(); - void case2360(); - void case2361(); - void case2362(); - void case2363(); - void case2364(); - void case2365(); - void case2366(); - void case2367(); - void case2368(); - void case2369(); - void case2370(); - void case2371(); - void case2372(); - void case2373(); - void case2374(); - void case2375(); - void case2376(); - void case2377(); - void case2378(); - void case2379(); - void case2380(); - void case2381(); - void case2382(); - void case2383(); - void case2384(); - void case2385(); - void case2386(); - void case2387(); - void case2388(); - void case2389(); - void case2390(); - void case2391(); - void case2392(); - void case2393(); - void case2394(); - void case2395(); - void case2396(); - void case2397(); - void case2398(); - void case2399(); + void case2300(); + void case2301(); + void case2302(); + void case2303(); + void case2304(); + void case2305(); + void case2306(); + void case2307(); + void case2308(); + void case2309(); + void case2310(); + void case2311(); + void case2312(); + void case2313(); + void case2314(); + void case2315(); + void case2316(); + void case2317(); + void case2318(); + void case2319(); + void case2320(); + void case2321(); + void case2322(); + void case2323(); + void case2324(); + void case2325(); + void case2326(); + void case2327(); + void case2328(); + void case2329(); + void case2330(); + void case2331(); + void case2332(); + void case2333(); + void case2334(); + void case2335(); + void case2336(); + void case2337(); + void case2338(); + void case2339(); + void case2340(); + void case2341(); + void case2342(); + void case2343(); + void case2344(); + void case2345(); + void case2346(); + void case2347(); + void case2348(); + void case2349(); + void case2350(); + void case2351(); + void case2352(); + void case2353(); + void case2354(); + void case2355(); + void case2356(); + void case2357(); + void case2358(); + void case2359(); + void case2360(); + void case2361(); + void case2362(); + void case2363(); + void case2364(); + void case2365(); + void case2366(); + void case2367(); + void case2368(); + void case2369(); + void case2370(); + void case2371(); + void case2372(); + void case2373(); + void case2374(); + void case2375(); + void case2376(); + void case2377(); + void case2378(); + void case2379(); + void case2380(); + void case2381(); + void case2382(); + void case2383(); + void case2384(); + void case2385(); + void case2386(); + void case2387(); + void case2388(); + void case2389(); + void case2390(); + void case2391(); + void case2392(); + void case2393(); + void case2394(); + void case2395(); + void case2396(); + void case2397(); + void case2398(); + void case2399(); - void case2400(); - void case2401(); - void case2402(); - void case2403(); - void case2404(); - void case2405(); - void case2406(); - void case2407(); - void case2408(); - void case2409(); - void case2410(); - void case2411(); - void case2412(); - void case2413(); - void case2414(); - void case2415(); - void case2416(); - void case2417(); - void case2418(); - void case2419(); - void case2420(); - void case2421(); - void case2422(); - void case2423(); - void case2424(); - void case2425(); - void case2426(); - void case2427(); - void case2428(); - void case2429(); - void case2430(); - void case2431(); - void case2432(); - void case2433(); - void case2434(); - void case2435(); - void case2436(); - void case2437(); - void case2438(); - void case2439(); - void case2440(); - void case2441(); - void case2442(); - void case2443(); - void case2444(); - void case2445(); - void case2446(); - void case2447(); - void case2448(); - void case2449(); - void case2450(); - void case2451(); - void case2452(); - void case2453(); - void case2454(); - void case2455(); - void case2456(); - void case2457(); - void case2458(); - void case2459(); - void case2460(); - void case2461(); - void case2462(); - void case2463(); - void case2464(); - void case2465(); - void case2466(); - void case2467(); - void case2468(); - void case2469(); - void case2470(); - void case2471(); - void case2472(); - void case2473(); - void case2474(); - void case2475(); - void case2476(); - void case2477(); - void case2478(); - void case2479(); - void case2480(); - void case2481(); - void case2482(); - void case2483(); - void case2484(); - void case2485(); - void case2486(); - void case2487(); - void case2488(); - void case2489(); - void case2490(); - void case2491(); - void case2492(); - void case2493(); - void case2494(); - void case2495(); - void case2496(); - void case2497(); - void case2498(); - void case2499(); + void case2400(); + void case2401(); + void case2402(); + void case2403(); + void case2404(); + void case2405(); + void case2406(); + void case2407(); + void case2408(); + void case2409(); + void case2410(); + void case2411(); + void case2412(); + void case2413(); + void case2414(); + void case2415(); + void case2416(); + void case2417(); + void case2418(); + void case2419(); + void case2420(); + void case2421(); + void case2422(); + void case2423(); + void case2424(); + void case2425(); + void case2426(); + void case2427(); + void case2428(); + void case2429(); + void case2430(); + void case2431(); + void case2432(); + void case2433(); + void case2434(); + void case2435(); + void case2436(); + void case2437(); + void case2438(); + void case2439(); + void case2440(); + void case2441(); + void case2442(); + void case2443(); + void case2444(); + void case2445(); + void case2446(); + void case2447(); + void case2448(); + void case2449(); + void case2450(); + void case2451(); + void case2452(); + void case2453(); + void case2454(); + void case2455(); + void case2456(); + void case2457(); + void case2458(); + void case2459(); + void case2460(); + void case2461(); + void case2462(); + void case2463(); + void case2464(); + void case2465(); + void case2466(); + void case2467(); + void case2468(); + void case2469(); + void case2470(); + void case2471(); + void case2472(); + void case2473(); + void case2474(); + void case2475(); + void case2476(); + void case2477(); + void case2478(); + void case2479(); + void case2480(); + void case2481(); + void case2482(); + void case2483(); + void case2484(); + void case2485(); + void case2486(); + void case2487(); + void case2488(); + void case2489(); + void case2490(); + void case2491(); + void case2492(); + void case2493(); + void case2494(); + void case2495(); + void case2496(); + void case2497(); + void case2498(); + void case2499(); - void case2500(); - void case2501(); - void case2502(); - void case2503(); - void case2504(); - void case2505(); - void case2506(); - void case2507(); - void case2508(); - void case2509(); - void case2510(); - void case2511(); - void case2512(); - void case2513(); - void case2514(); - void case2515(); - void case2516(); - void case2517(); - void case2518(); - void case2519(); - void case2520(); - void case2521(); - void case2522(); - void case2523(); - void case2524(); - void case2525(); - void case2526(); - void case2527(); - void case2528(); - void case2529(); - void case2530(); - void case2531(); - void case2532(); - void case2533(); - void case2534(); - void case2535(); - void case2536(); - void case2537(); - void case2538(); - void case2539(); - void case2540(); - void case2541(); - void case2542(); - void case2543(); - void case2544(); - void case2545(); - void case2546(); - void case2547(); - void case2548(); - void case2549(); - void case2550(); - void case2551(); - void case2552(); - void case2553(); - void case2554(); - void case2555(); - void case2556(); - void case2557(); - void case2558(); - void case2559(); - void case2560(); - void case2561(); - void case2562(); - void case2563(); - void case2564(); - void case2565(); - void case2566(); - void case2567(); - void case2568(); - void case2569(); - void case2570(); - void case2571(); - void case2572(); - void case2573(); - void case2574(); - void case2575(); - void case2576(); - void case2577(); - void case2578(); - void case2579(); - void case2580(); - void case2581(); - void case2582(); - void case2583(); - void case2584(); - void case2585(); - void case2586(); - void case2587(); - void case2588(); - void case2589(); - void case2590(); - void case2591(); - void case2592(); - void case2593(); - void case2594(); - void case2595(); - void case2596(); - void case2597(); - void case2598(); - void case2599(); + void case2500(); + void case2501(); + void case2502(); + void case2503(); + void case2504(); + void case2505(); + void case2506(); + void case2507(); + void case2508(); + void case2509(); + void case2510(); + void case2511(); + void case2512(); + void case2513(); + void case2514(); + void case2515(); + void case2516(); + void case2517(); + void case2518(); + void case2519(); + void case2520(); + void case2521(); + void case2522(); + void case2523(); + void case2524(); + void case2525(); + void case2526(); + void case2527(); + void case2528(); + void case2529(); + void case2530(); + void case2531(); + void case2532(); + void case2533(); + void case2534(); + void case2535(); + void case2536(); + void case2537(); + void case2538(); + void case2539(); + void case2540(); + void case2541(); + void case2542(); + void case2543(); + void case2544(); + void case2545(); + void case2546(); + void case2547(); + void case2548(); + void case2549(); + void case2550(); + void case2551(); + void case2552(); + void case2553(); + void case2554(); + void case2555(); + void case2556(); + void case2557(); + void case2558(); + void case2559(); + void case2560(); + void case2561(); + void case2562(); + void case2563(); + void case2564(); + void case2565(); + void case2566(); + void case2567(); + void case2568(); + void case2569(); + void case2570(); + void case2571(); + void case2572(); + void case2573(); + void case2574(); + void case2575(); + void case2576(); + void case2577(); + void case2578(); + void case2579(); + void case2580(); + void case2581(); + void case2582(); + void case2583(); + void case2584(); + void case2585(); + void case2586(); + void case2587(); + void case2588(); + void case2589(); + void case2590(); + void case2591(); + void case2592(); + void case2593(); + void case2594(); + void case2595(); + void case2596(); + void case2597(); + void case2598(); + void case2599(); - void case2600(); - void case2601(); - void case2602(); - void case2603(); - void case2604(); - void case2605(); - void case2606(); - void case2607(); - void case2608(); - void case2609(); - void case2610(); - void case2611(); - void case2612(); - void case2613(); - void case2614(); - void case2615(); - void case2616(); - void case2617(); - void case2618(); - void case2619(); - void case2620(); - void case2621(); - void case2622(); - void case2623(); - void case2624(); - void case2625(); - void case2626(); - void case2627(); - void case2628(); - void case2629(); - void case2630(); - void case2631(); - void case2632(); - void case2633(); - void case2634(); - void case2635(); - void case2636(); - void case2637(); - void case2638(); - void case2639(); - void case2640(); - void case2641(); - void case2642(); - void case2643(); - void case2644(); - void case2645(); - void case2646(); - void case2647(); - void case2648(); - void case2649(); - void case2650(); - void case2651(); - void case2652(); - void case2653(); - void case2654(); - void case2655(); - void case2656(); - void case2657(); - void case2658(); - void case2659(); - void case2660(); - void case2661(); - void case2662(); - void case2663(); - void case2664(); - void case2665(); - void case2666(); - void case2667(); - void case2668(); - void case2669(); - void case2670(); - void case2671(); - void case2672(); - void case2673(); - void case2674(); - void case2675(); - void case2676(); - void case2677(); - void case2678(); - void case2679(); - void case2680(); - void case2681(); - void case2682(); - void case2683(); - void case2684(); - void case2685(); - void case2686(); - void case2687(); - void case2688(); - void case2689(); - void case2690(); - void case2691(); - void case2692(); - void case2693(); - void case2694(); - void case2695(); - void case2696(); - void case2697(); - void case2698(); - void case2699(); + void case2600(); + void case2601(); + void case2602(); + void case2603(); + void case2604(); + void case2605(); + void case2606(); + void case2607(); + void case2608(); + void case2609(); + void case2610(); + void case2611(); + void case2612(); + void case2613(); + void case2614(); + void case2615(); + void case2616(); + void case2617(); + void case2618(); + void case2619(); + void case2620(); + void case2621(); + void case2622(); + void case2623(); + void case2624(); + void case2625(); + void case2626(); + void case2627(); + void case2628(); + void case2629(); + void case2630(); + void case2631(); + void case2632(); + void case2633(); + void case2634(); + void case2635(); + void case2636(); + void case2637(); + void case2638(); + void case2639(); + void case2640(); + void case2641(); + void case2642(); + void case2643(); + void case2644(); + void case2645(); + void case2646(); + void case2647(); + void case2648(); + void case2649(); + void case2650(); + void case2651(); + void case2652(); + void case2653(); + void case2654(); + void case2655(); + void case2656(); + void case2657(); + void case2658(); + void case2659(); + void case2660(); + void case2661(); + void case2662(); + void case2663(); + void case2664(); + void case2665(); + void case2666(); + void case2667(); + void case2668(); + void case2669(); + void case2670(); + void case2671(); + void case2672(); + void case2673(); + void case2674(); + void case2675(); + void case2676(); + void case2677(); + void case2678(); + void case2679(); + void case2680(); + void case2681(); + void case2682(); + void case2683(); + void case2684(); + void case2685(); + void case2686(); + void case2687(); + void case2688(); + void case2689(); + void case2690(); + void case2691(); + void case2692(); + void case2693(); + void case2694(); + void case2695(); + void case2696(); + void case2697(); + void case2698(); + void case2699(); - void case2700(); - void case2701(); - void case2702(); - void case2703(); - void case2704(); - void case2705(); - void case2706(); - void case2707(); - void case2708(); - void case2709(); - void case2710(); - void case2711(); - void case2712(); - void case2713(); - void case2714(); - void case2715(); - void case2716(); - void case2717(); - void case2718(); - void case2719(); - void case2720(); - void case2721(); - void case2722(); - void case2723(); - void case2724(); - void case2725(); - void case2726(); - void case2727(); - void case2728(); - void case2729(); - void case2730(); - void case2731(); - void case2732(); - void case2733(); - void case2734(); - void case2735(); - void case2736(); - void case2737(); - void case2738(); - void case2739(); - void case2740(); - void case2741(); - void case2742(); - void case2743(); - void case2744(); - void case2745(); - void case2746(); - void case2747(); - void case2748(); - void case2749(); - void case2750(); - void case2751(); - void case2752(); - void case2753(); - void case2754(); - void case2755(); - void case2756(); - void case2757(); - void case2758(); - void case2759(); - void case2760(); - void case2761(); - void case2762(); - void case2763(); - void case2764(); - void case2765(); - void case2766(); - void case2767(); - void case2768(); - void case2769(); - void case2770(); - void case2771(); - void case2772(); - void case2773(); - void case2774(); - void case2775(); - void case2776(); - void case2777(); - void case2778(); - void case2779(); - void case2780(); - void case2781(); - void case2782(); - void case2783(); - void case2784(); - void case2785(); - void case2786(); - void case2787(); - void case2788(); - void case2789(); - void case2790(); - void case2791(); - void case2792(); - void case2793(); - void case2794(); - void case2795(); - void case2796(); - void case2797(); - void case2798(); - void case2799(); + void case2700(); + void case2701(); + void case2702(); + void case2703(); + void case2704(); + void case2705(); + void case2706(); + void case2707(); + void case2708(); + void case2709(); + void case2710(); + void case2711(); + void case2712(); + void case2713(); + void case2714(); + void case2715(); + void case2716(); + void case2717(); + void case2718(); + void case2719(); + void case2720(); + void case2721(); + void case2722(); + void case2723(); + void case2724(); + void case2725(); + void case2726(); + void case2727(); + void case2728(); + void case2729(); + void case2730(); + void case2731(); + void case2732(); + void case2733(); + void case2734(); + void case2735(); + void case2736(); + void case2737(); + void case2738(); + void case2739(); + void case2740(); + void case2741(); + void case2742(); + void case2743(); + void case2744(); + void case2745(); + void case2746(); + void case2747(); + void case2748(); + void case2749(); + void case2750(); + void case2751(); + void case2752(); + void case2753(); + void case2754(); + void case2755(); + void case2756(); + void case2757(); + void case2758(); + void case2759(); + void case2760(); + void case2761(); + void case2762(); + void case2763(); + void case2764(); + void case2765(); + void case2766(); + void case2767(); + void case2768(); + void case2769(); + void case2770(); + void case2771(); + void case2772(); + void case2773(); + void case2774(); + void case2775(); + void case2776(); + void case2777(); + void case2778(); + void case2779(); + void case2780(); + void case2781(); + void case2782(); + void case2783(); + void case2784(); + void case2785(); + void case2786(); + void case2787(); + void case2788(); + void case2789(); + void case2790(); + void case2791(); + void case2792(); + void case2793(); + void case2794(); + void case2795(); + void case2796(); + void case2797(); + void case2798(); + void case2799(); - void case2800(); - void case2801(); - void case2802(); - void case2803(); - void case2804(); - void case2805(); - void case2806(); - void case2807(); - void case2808(); - void case2809(); - void case2810(); - void case2811(); - void case2812(); - void case2813(); - void case2814(); - void case2815(); - void case2816(); - void case2817(); - void case2818(); - void case2819(); - void case2820(); - void case2821(); - void case2822(); - void case2823(); - void case2824(); - void case2825(); - void case2826(); - void case2827(); - void case2828(); - void case2829(); - void case2830(); - void case2831(); - void case2832(); - void case2833(); - void case2834(); - void case2835(); - void case2836(); - void case2837(); - void case2838(); - void case2839(); - void case2840(); - void case2841(); - void case2842(); - void case2843(); - void case2844(); - void case2845(); - void case2846(); - void case2847(); - void case2848(); - void case2849(); - void case2850(); - void case2851(); - void case2852(); - void case2853(); - void case2854(); - void case2855(); - void case2856(); - void case2857(); - void case2858(); - void case2859(); - void case2860(); - void case2861(); - void case2862(); - void case2863(); - void case2864(); - void case2865(); - void case2866(); - void case2867(); - void case2868(); - void case2869(); - void case2870(); - void case2871(); - void case2872(); - void case2873(); - void case2874(); - void case2875(); - void case2876(); - void case2877(); - void case2878(); - void case2879(); - void case2880(); - void case2881(); - void case2882(); - void case2883(); - void case2884(); - void case2885(); - void case2886(); - void case2887(); - void case2888(); - void case2889(); - void case2890(); - void case2891(); - void case2892(); - void case2893(); - void case2894(); - void case2895(); - void case2896(); - void case2897(); - void case2898(); - void case2899(); + void case2800(); + void case2801(); + void case2802(); + void case2803(); + void case2804(); + void case2805(); + void case2806(); + void case2807(); + void case2808(); + void case2809(); + void case2810(); + void case2811(); + void case2812(); + void case2813(); + void case2814(); + void case2815(); + void case2816(); + void case2817(); + void case2818(); + void case2819(); + void case2820(); + void case2821(); + void case2822(); + void case2823(); + void case2824(); + void case2825(); + void case2826(); + void case2827(); + void case2828(); + void case2829(); + void case2830(); + void case2831(); + void case2832(); + void case2833(); + void case2834(); + void case2835(); + void case2836(); + void case2837(); + void case2838(); + void case2839(); + void case2840(); + void case2841(); + void case2842(); + void case2843(); + void case2844(); + void case2845(); + void case2846(); + void case2847(); + void case2848(); + void case2849(); + void case2850(); + void case2851(); + void case2852(); + void case2853(); + void case2854(); + void case2855(); + void case2856(); + void case2857(); + void case2858(); + void case2859(); + void case2860(); + void case2861(); + void case2862(); + void case2863(); + void case2864(); + void case2865(); + void case2866(); + void case2867(); + void case2868(); + void case2869(); + void case2870(); + void case2871(); + void case2872(); + void case2873(); + void case2874(); + void case2875(); + void case2876(); + void case2877(); + void case2878(); + void case2879(); + void case2880(); + void case2881(); + void case2882(); + void case2883(); + void case2884(); + void case2885(); + void case2886(); + void case2887(); + void case2888(); + void case2889(); + void case2890(); + void case2891(); + void case2892(); + void case2893(); + void case2894(); + void case2895(); + void case2896(); + void case2897(); + void case2898(); + void case2899(); - void case2900(); - void case2901(); - void case2902(); - void case2903(); - void case2904(); - void case2905(); - void case2906(); - void case2907(); - void case2908(); - void case2909(); - void case2910(); - void case2911(); - void case2912(); - void case2913(); - void case2914(); - void case2915(); - void case2916(); - void case2917(); - void case2918(); - void case2919(); - void case2920(); - void case2921(); - void case2922(); - void case2923(); - void case2924(); - void case2925(); - void case2926(); - void case2927(); - void case2928(); - void case2929(); - void case2930(); - void case2931(); - void case2932(); - void case2933(); - void case2934(); - void case2935(); - void case2936(); - void case2937(); - void case2938(); - void case2939(); - void case2940(); - void case2941(); - void case2942(); - void case2943(); - void case2944(); - void case2945(); - void case2946(); - void case2947(); - void case2948(); - void case2949(); - void case2950(); - void case2951(); - void case2952(); - void case2953(); - void case2954(); - void case2955(); - void case2956(); - void case2957(); - void case2958(); - void case2959(); - void case2960(); - void case2961(); - void case2962(); - void case2963(); - void case2964(); - void case2965(); - void case2966(); - void case2967(); - void case2968(); - void case2969(); - void case2970(); - void case2971(); - void case2972(); - void case2973(); - void case2974(); - void case2975(); - void case2976(); - void case2977(); - void case2978(); - void case2979(); - void case2980(); - void case2981(); - void case2982(); - void case2983(); - void case2984(); - void case2985(); - void case2986(); - void case2987(); - void case2988(); - void case2989(); - void case2990(); - void case2991(); - void case2992(); - void case2993(); - void case2994(); - void case2995(); - void case2996(); - void case2997(); - void case2998(); - void case2999(); + void case2900(); + void case2901(); + void case2902(); + void case2903(); + void case2904(); + void case2905(); + void case2906(); + void case2907(); + void case2908(); + void case2909(); + void case2910(); + void case2911(); + void case2912(); + void case2913(); + void case2914(); + void case2915(); + void case2916(); + void case2917(); + void case2918(); + void case2919(); + void case2920(); + void case2921(); + void case2922(); + void case2923(); + void case2924(); + void case2925(); + void case2926(); + void case2927(); + void case2928(); + void case2929(); + void case2930(); + void case2931(); + void case2932(); + void case2933(); + void case2934(); + void case2935(); + void case2936(); + void case2937(); + void case2938(); + void case2939(); + void case2940(); + void case2941(); + void case2942(); + void case2943(); + void case2944(); + void case2945(); + void case2946(); + void case2947(); + void case2948(); + void case2949(); + void case2950(); + void case2951(); + void case2952(); + void case2953(); + void case2954(); + void case2955(); + void case2956(); + void case2957(); + void case2958(); + void case2959(); + void case2960(); + void case2961(); + void case2962(); + void case2963(); + void case2964(); + void case2965(); + void case2966(); + void case2967(); + void case2968(); + void case2969(); + void case2970(); + void case2971(); + void case2972(); + void case2973(); + void case2974(); + void case2975(); + void case2976(); + void case2977(); + void case2978(); + void case2979(); + void case2980(); + void case2981(); + void case2982(); + void case2983(); + void case2984(); + void case2985(); + void case2986(); + void case2987(); + void case2988(); + void case2989(); + void case2990(); + void case2991(); + void case2992(); + void case2993(); + void case2994(); + void case2995(); + void case2996(); + void case2997(); + void case2998(); + void case2999(); - void case3000(); - void case3001(); - void case3002(); - void case3003(); - void case3004(); - void case3005(); - void case3006(); - void case3007(); - void case3008(); - void case3009(); - void case3010(); - void case3011(); - void case3012(); - void case3013(); - void case3014(); - void case3015(); - void case3016(); - void case3017(); - void case3018(); - void case3019(); - void case3020(); - void case3021(); - void case3022(); - void case3023(); - void case3024(); - void case3025(); - void case3026(); - void case3027(); - void case3028(); - void case3029(); - void case3030(); - void case3031(); - void case3032(); - void case3033(); - void case3034(); - void case3035(); - void case3036(); - void case3037(); - void case3038(); - void case3039(); - void case3040(); - void case3041(); - void case3042(); - void case3043(); - void case3044(); - void case3045(); - void case3046(); - void case3047(); - void case3048(); - void case3049(); - void case3050(); - void case3051(); - void case3052(); - void case3053(); - void case3054(); - void case3055(); - void case3056(); - void case3057(); - void case3058(); - void case3059(); - void case3060(); - void case3061(); - void case3062(); - void case3063(); - void case3064(); - void case3065(); - void case3066(); - void case3067(); - void case3068(); - void case3069(); - void case3070(); - void case3071(); - void case3072(); - void case3073(); - void case3074(); - void case3075(); - void case3076(); - void case3077(); - void case3078(); - void case3079(); - void case3080(); - void case3081(); - void case3082(); - void case3083(); - void case3084(); - void case3085(); - void case3086(); - void case3087(); - void case3088(); - void case3089(); - void case3090(); - void case3091(); - void case3092(); - void case3093(); - void case3094(); - void case3095(); - void case3096(); - void case3097(); - void case3098(); - void case3099(); + void case3000(); + void case3001(); + void case3002(); + void case3003(); + void case3004(); + void case3005(); + void case3006(); + void case3007(); + void case3008(); + void case3009(); + void case3010(); + void case3011(); + void case3012(); + void case3013(); + void case3014(); + void case3015(); + void case3016(); + void case3017(); + void case3018(); + void case3019(); + void case3020(); + void case3021(); + void case3022(); + void case3023(); + void case3024(); + void case3025(); + void case3026(); + void case3027(); + void case3028(); + void case3029(); + void case3030(); + void case3031(); + void case3032(); + void case3033(); + void case3034(); + void case3035(); + void case3036(); + void case3037(); + void case3038(); + void case3039(); + void case3040(); + void case3041(); + void case3042(); + void case3043(); + void case3044(); + void case3045(); + void case3046(); + void case3047(); + void case3048(); + void case3049(); + void case3050(); + void case3051(); + void case3052(); + void case3053(); + void case3054(); + void case3055(); + void case3056(); + void case3057(); + void case3058(); + void case3059(); + void case3060(); + void case3061(); + void case3062(); + void case3063(); + void case3064(); + void case3065(); + void case3066(); + void case3067(); + void case3068(); + void case3069(); + void case3070(); + void case3071(); + void case3072(); + void case3073(); + void case3074(); + void case3075(); + void case3076(); + void case3077(); + void case3078(); + void case3079(); + void case3080(); + void case3081(); + void case3082(); + void case3083(); + void case3084(); + void case3085(); + void case3086(); + void case3087(); + void case3088(); + void case3089(); + void case3090(); + void case3091(); + void case3092(); + void case3093(); + void case3094(); + void case3095(); + void case3096(); + void case3097(); + void case3098(); + void case3099(); - void case3100(); - void case3101(); - void case3102(); - void case3103(); - void case3104(); - void case3105(); - void case3106(); - void case3107(); - void case3108(); - void case3109(); - void case3110(); - void case3111(); - void case3112(); - void case3113(); - void case3114(); - void case3115(); - void case3116(); - void case3117(); - void case3118(); - void case3119(); - void case3120(); - void case3121(); - void case3122(); - void case3123(); - void case3124(); - void case3125(); - void case3126(); - void case3127(); - void case3128(); - void case3129(); - void case3130(); - void case3131(); - void case3132(); - void case3133(); - void case3134(); - void case3135(); - void case3136(); - void case3137(); - void case3138(); - void case3139(); - void case3140(); - void case3141(); - void case3142(); - void case3143(); - void case3144(); - void case3145(); - void case3146(); - void case3147(); - void case3148(); - void case3149(); - void case3150(); - void case3151(); - void case3152(); - void case3153(); - void case3154(); - void case3155(); - void case3156(); - void case3157(); - void case3158(); - void case3159(); - void case3160(); - void case3161(); - void case3162(); - void case3163(); - void case3164(); - void case3165(); - void case3166(); - void case3167(); - void case3168(); - void case3169(); - void case3170(); - void case3171(); - void case3172(); - void case3173(); - void case3174(); - void case3175(); - void case3176(); - void case3177(); - void case3178(); - void case3179(); - void case3180(); - void case3181(); - void case3182(); - void case3183(); - void case3184(); - void case3185(); - void case3186(); - void case3187(); - void case3188(); - void case3189(); - void case3190(); - void case3191(); - void case3192(); - void case3193(); - void case3194(); - void case3195(); - void case3196(); - void case3197(); - void case3198(); - void case3199(); + void case3100(); + void case3101(); + void case3102(); + void case3103(); + void case3104(); + void case3105(); + void case3106(); + void case3107(); + void case3108(); + void case3109(); + void case3110(); + void case3111(); + void case3112(); + void case3113(); + void case3114(); + void case3115(); + void case3116(); + void case3117(); + void case3118(); + void case3119(); + void case3120(); + void case3121(); + void case3122(); + void case3123(); + void case3124(); + void case3125(); + void case3126(); + void case3127(); + void case3128(); + void case3129(); + void case3130(); + void case3131(); + void case3132(); + void case3133(); + void case3134(); + void case3135(); + void case3136(); + void case3137(); + void case3138(); + void case3139(); + void case3140(); + void case3141(); + void case3142(); + void case3143(); + void case3144(); + void case3145(); + void case3146(); + void case3147(); + void case3148(); + void case3149(); + void case3150(); + void case3151(); + void case3152(); + void case3153(); + void case3154(); + void case3155(); + void case3156(); + void case3157(); + void case3158(); + void case3159(); + void case3160(); + void case3161(); + void case3162(); + void case3163(); + void case3164(); + void case3165(); + void case3166(); + void case3167(); + void case3168(); + void case3169(); + void case3170(); + void case3171(); + void case3172(); + void case3173(); + void case3174(); + void case3175(); + void case3176(); + void case3177(); + void case3178(); + void case3179(); + void case3180(); + void case3181(); + void case3182(); + void case3183(); + void case3184(); + void case3185(); + void case3186(); + void case3187(); + void case3188(); + void case3189(); + void case3190(); + void case3191(); + void case3192(); + void case3193(); + void case3194(); + void case3195(); + void case3196(); + void case3197(); + void case3198(); + void case3199(); - void case3200(); - void case3201(); - void case3202(); - void case3203(); - void case3204(); - void case3205(); - void case3206(); - void case3207(); - void case3208(); - void case3209(); - void case3210(); - void case3211(); - void case3212(); - void case3213(); - void case3214(); - void case3215(); - void case3216(); - void case3217(); - void case3218(); - void case3219(); - void case3220(); - void case3221(); - void case3222(); - void case3223(); - void case3224(); - void case3225(); - void case3226(); - void case3227(); - void case3228(); - void case3229(); - void case3230(); - void case3231(); - void case3232(); - void case3233(); - void case3234(); - void case3235(); - void case3236(); - void case3237(); - void case3238(); - void case3239(); - void case3240(); - void case3241(); - void case3242(); - void case3243(); - void case3244(); - void case3245(); - void case3246(); - void case3247(); - void case3248(); - void case3249(); - void case3250(); - void case3251(); - void case3252(); - void case3253(); - void case3254(); - void case3255(); - void case3256(); - void case3257(); - void case3258(); - void case3259(); - void case3260(); - void case3261(); - void case3262(); - void case3263(); - void case3264(); - void case3265(); - void case3266(); - void case3267(); - void case3268(); - void case3269(); - void case3270(); - void case3271(); - void case3272(); - void case3273(); - void case3274(); - void case3275(); - void case3276(); - void case3277(); - void case3278(); - void case3279(); - void case3280(); - void case3281(); - void case3282(); - void case3283(); - void case3284(); - void case3285(); - void case3286(); - void case3287(); - void case3288(); - void case3289(); - void case3290(); - void case3291(); - void case3292(); - void case3293(); - void case3294(); - void case3295(); - void case3296(); - void case3297(); - void case3298(); - void case3299(); + void case3200(); + void case3201(); + void case3202(); + void case3203(); + void case3204(); + void case3205(); + void case3206(); + void case3207(); + void case3208(); + void case3209(); + void case3210(); + void case3211(); + void case3212(); + void case3213(); + void case3214(); + void case3215(); + void case3216(); + void case3217(); + void case3218(); + void case3219(); + void case3220(); + void case3221(); + void case3222(); + void case3223(); + void case3224(); + void case3225(); + void case3226(); + void case3227(); + void case3228(); + void case3229(); + void case3230(); + void case3231(); + void case3232(); + void case3233(); + void case3234(); + void case3235(); + void case3236(); + void case3237(); + void case3238(); + void case3239(); + void case3240(); + void case3241(); + void case3242(); + void case3243(); + void case3244(); + void case3245(); + void case3246(); + void case3247(); + void case3248(); + void case3249(); + void case3250(); + void case3251(); + void case3252(); + void case3253(); + void case3254(); + void case3255(); + void case3256(); + void case3257(); + void case3258(); + void case3259(); + void case3260(); + void case3261(); + void case3262(); + void case3263(); + void case3264(); + void case3265(); + void case3266(); + void case3267(); + void case3268(); + void case3269(); + void case3270(); + void case3271(); + void case3272(); + void case3273(); + void case3274(); + void case3275(); + void case3276(); + void case3277(); + void case3278(); + void case3279(); + void case3280(); + void case3281(); + void case3282(); + void case3283(); + void case3284(); + void case3285(); + void case3286(); + void case3287(); + void case3288(); + void case3289(); + void case3290(); + void case3291(); + void case3292(); + void case3293(); + void case3294(); + void case3295(); + void case3296(); + void case3297(); + void case3298(); + void case3299(); - void case3300(); - void case3301(); - void case3302(); - void case3303(); - void case3304(); - void case3305(); - void case3306(); - void case3307(); - void case3308(); - void case3309(); - void case3310(); - void case3311(); - void case3312(); - void case3313(); - void case3314(); - void case3315(); - void case3316(); - void case3317(); - void case3318(); - void case3319(); - void case3320(); - void case3321(); - void case3322(); - void case3323(); - void case3324(); - void case3325(); - void case3326(); - void case3327(); - void case3328(); - void case3329(); - void case3330(); - void case3331(); - void case3332(); - void case3333(); - void case3334(); - void case3335(); - void case3336(); - void case3337(); - void case3338(); - void case3339(); - void case3340(); - void case3341(); - void case3342(); - void case3343(); - void case3344(); - void case3345(); - void case3346(); - void case3347(); - void case3348(); - void case3349(); - void case3350(); - void case3351(); - void case3352(); - void case3353(); - void case3354(); - void case3355(); - void case3356(); - void case3357(); - void case3358(); - void case3359(); - void case3360(); - void case3361(); - void case3362(); - void case3363(); - void case3364(); - void case3365(); - void case3366(); - void case3367(); - void case3368(); - void case3369(); - void case3370(); - void case3371(); - void case3372(); - void case3373(); - void case3374(); - void case3375(); - void case3376(); - void case3377(); - void case3378(); - void case3379(); - void case3380(); - void case3381(); - void case3382(); - void case3383(); - void case3384(); - void case3385(); - void case3386(); - void case3387(); - void case3388(); - void case3389(); - void case3390(); - void case3391(); - void case3392(); - void case3393(); - void case3394(); - void case3395(); - void case3396(); - void case3397(); - void case3398(); - void case3399(); + void case3300(); + void case3301(); + void case3302(); + void case3303(); + void case3304(); + void case3305(); + void case3306(); + void case3307(); + void case3308(); + void case3309(); + void case3310(); + void case3311(); + void case3312(); + void case3313(); + void case3314(); + void case3315(); + void case3316(); + void case3317(); + void case3318(); + void case3319(); + void case3320(); + void case3321(); + void case3322(); + void case3323(); + void case3324(); + void case3325(); + void case3326(); + void case3327(); + void case3328(); + void case3329(); + void case3330(); + void case3331(); + void case3332(); + void case3333(); + void case3334(); + void case3335(); + void case3336(); + void case3337(); + void case3338(); + void case3339(); + void case3340(); + void case3341(); + void case3342(); + void case3343(); + void case3344(); + void case3345(); + void case3346(); + void case3347(); + void case3348(); + void case3349(); + void case3350(); + void case3351(); + void case3352(); + void case3353(); + void case3354(); + void case3355(); + void case3356(); + void case3357(); + void case3358(); + void case3359(); + void case3360(); + void case3361(); + void case3362(); + void case3363(); + void case3364(); + void case3365(); + void case3366(); + void case3367(); + void case3368(); + void case3369(); + void case3370(); + void case3371(); + void case3372(); + void case3373(); + void case3374(); + void case3375(); + void case3376(); + void case3377(); + void case3378(); + void case3379(); + void case3380(); + void case3381(); + void case3382(); + void case3383(); + void case3384(); + void case3385(); + void case3386(); + void case3387(); + void case3388(); + void case3389(); + void case3390(); + void case3391(); + void case3392(); + void case3393(); + void case3394(); + void case3395(); + void case3396(); + void case3397(); + void case3398(); + void case3399(); - void case3400(); - void case3401(); - void case3402(); - void case3403(); - void case3404(); - void case3405(); - void case3406(); - void case3407(); - void case3408(); - void case3409(); - void case3410(); - void case3411(); - void case3412(); - void case3413(); - void case3414(); - void case3415(); - void case3416(); - void case3417(); - void case3418(); - void case3419(); - void case3420(); - void case3421(); - void case3422(); - void case3423(); - void case3424(); - void case3425(); - void case3426(); - void case3427(); - void case3428(); - void case3429(); - void case3430(); - void case3431(); - void case3432(); - void case3433(); - void case3434(); - void case3435(); - void case3436(); - void case3437(); - void case3438(); - void case3439(); - void case3440(); - void case3441(); - void case3442(); - void case3443(); - void case3444(); - void case3445(); - void case3446(); - void case3447(); - void case3448(); - void case3449(); - void case3450(); - void case3451(); - void case3452(); - void case3453(); - void case3454(); - void case3455(); - void case3456(); - void case3457(); - void case3458(); - void case3459(); - void case3460(); - void case3461(); - void case3462(); - void case3463(); - void case3464(); - void case3465(); - void case3466(); - void case3467(); - void case3468(); - void case3469(); - void case3470(); - void case3471(); - void case3472(); - void case3473(); - void case3474(); - void case3475(); - void case3476(); - void case3477(); - void case3478(); - void case3479(); - void case3480(); - void case3481(); - void case3482(); - void case3483(); - void case3484(); - void case3485(); - void case3486(); - void case3487(); - void case3488(); - void case3489(); - void case3490(); - void case3491(); - void case3492(); - void case3493(); - void case3494(); - void case3495(); - void case3496(); - void case3497(); - void case3498(); - void case3499(); + void case3400(); + void case3401(); + void case3402(); + void case3403(); + void case3404(); + void case3405(); + void case3406(); + void case3407(); + void case3408(); + void case3409(); + void case3410(); + void case3411(); + void case3412(); + void case3413(); + void case3414(); + void case3415(); + void case3416(); + void case3417(); + void case3418(); + void case3419(); + void case3420(); + void case3421(); + void case3422(); + void case3423(); + void case3424(); + void case3425(); + void case3426(); + void case3427(); + void case3428(); + void case3429(); + void case3430(); + void case3431(); + void case3432(); + void case3433(); + void case3434(); + void case3435(); + void case3436(); + void case3437(); + void case3438(); + void case3439(); + void case3440(); + void case3441(); + void case3442(); + void case3443(); + void case3444(); + void case3445(); + void case3446(); + void case3447(); + void case3448(); + void case3449(); + void case3450(); + void case3451(); + void case3452(); + void case3453(); + void case3454(); + void case3455(); + void case3456(); + void case3457(); + void case3458(); + void case3459(); + void case3460(); + void case3461(); + void case3462(); + void case3463(); + void case3464(); + void case3465(); + void case3466(); + void case3467(); + void case3468(); + void case3469(); + void case3470(); + void case3471(); + void case3472(); + void case3473(); + void case3474(); + void case3475(); + void case3476(); + void case3477(); + void case3478(); + void case3479(); + void case3480(); + void case3481(); + void case3482(); + void case3483(); + void case3484(); + void case3485(); + void case3486(); + void case3487(); + void case3488(); + void case3489(); + void case3490(); + void case3491(); + void case3492(); + void case3493(); + void case3494(); + void case3495(); + void case3496(); + void case3497(); + void case3498(); + void case3499(); - void case3500(); - void case3501(); - void case3502(); - void case3503(); - void case3504(); - void case3505(); - void case3506(); - void case3507(); - void case3508(); - void case3509(); - void case3510(); - void case3511(); - void case3512(); - void case3513(); - void case3514(); - void case3515(); - void case3516(); - void case3517(); - void case3518(); - void case3519(); - void case3520(); - void case3521(); - void case3522(); - void case3523(); - void case3524(); - void case3525(); - void case3526(); - void case3527(); - void case3528(); - void case3529(); - void case3530(); - void case3531(); - void case3532(); - void case3533(); - void case3534(); - void case3535(); - void case3536(); - void case3537(); - void case3538(); - void case3539(); - void case3540(); - void case3541(); - void case3542(); - void case3543(); - void case3544(); - void case3545(); - void case3546(); - void case3547(); - void case3548(); - void case3549(); - void case3550(); - void case3551(); - void case3552(); - void case3553(); - void case3554(); - void case3555(); - void case3556(); - void case3557(); - void case3558(); - void case3559(); - void case3560(); - void case3561(); - void case3562(); - void case3563(); - void case3564(); - void case3565(); - void case3566(); - void case3567(); - void case3568(); - void case3569(); - void case3570(); - void case3571(); - void case3572(); - void case3573(); - void case3574(); - void case3575(); - void case3576(); - void case3577(); - void case3578(); - void case3579(); - void case3580(); - void case3581(); - void case3582(); - void case3583(); - void case3584(); - void case3585(); - void case3586(); - void case3587(); - void case3588(); - void case3589(); - void case3590(); - void case3591(); - void case3592(); - void case3593(); - void case3594(); - void case3595(); - void case3596(); - void case3597(); - void case3598(); - void case3599(); + void case3500(); + void case3501(); + void case3502(); + void case3503(); + void case3504(); + void case3505(); + void case3506(); + void case3507(); + void case3508(); + void case3509(); + void case3510(); + void case3511(); + void case3512(); + void case3513(); + void case3514(); + void case3515(); + void case3516(); + void case3517(); + void case3518(); + void case3519(); + void case3520(); + void case3521(); + void case3522(); + void case3523(); + void case3524(); + void case3525(); + void case3526(); + void case3527(); + void case3528(); + void case3529(); + void case3530(); + void case3531(); + void case3532(); + void case3533(); + void case3534(); + void case3535(); + void case3536(); + void case3537(); + void case3538(); + void case3539(); + void case3540(); + void case3541(); + void case3542(); + void case3543(); + void case3544(); + void case3545(); + void case3546(); + void case3547(); + void case3548(); + void case3549(); + void case3550(); + void case3551(); + void case3552(); + void case3553(); + void case3554(); + void case3555(); + void case3556(); + void case3557(); + void case3558(); + void case3559(); + void case3560(); + void case3561(); + void case3562(); + void case3563(); + void case3564(); + void case3565(); + void case3566(); + void case3567(); + void case3568(); + void case3569(); + void case3570(); + void case3571(); + void case3572(); + void case3573(); + void case3574(); + void case3575(); + void case3576(); + void case3577(); + void case3578(); + void case3579(); + void case3580(); + void case3581(); + void case3582(); + void case3583(); + void case3584(); + void case3585(); + void case3586(); + void case3587(); + void case3588(); + void case3589(); + void case3590(); + void case3591(); + void case3592(); + void case3593(); + void case3594(); + void case3595(); + void case3596(); + void case3597(); + void case3598(); + void case3599(); - void case3600(); - void case3601(); - void case3602(); - void case3603(); - void case3604(); - void case3605(); - void case3606(); - void case3607(); - void case3608(); - void case3609(); - void case3610(); - void case3611(); - void case3612(); - void case3613(); - void case3614(); - void case3615(); - void case3616(); - void case3617(); - void case3618(); - void case3619(); - void case3620(); - void case3621(); - void case3622(); - void case3623(); - void case3624(); - void case3625(); - void case3626(); - void case3627(); - void case3628(); - void case3629(); - void case3630(); - void case3631(); - void case3632(); - void case3633(); - void case3634(); - void case3635(); - void case3636(); - void case3637(); - void case3638(); - void case3639(); - void case3640(); - void case3641(); - void case3642(); - void case3643(); - void case3644(); - void case3645(); - void case3646(); - void case3647(); - void case3648(); - void case3649(); - void case3650(); - void case3651(); - void case3652(); - void case3653(); - void case3654(); - void case3655(); - void case3656(); - void case3657(); - void case3658(); - void case3659(); - void case3660(); - void case3661(); - void case3662(); - void case3663(); - void case3664(); - void case3665(); - void case3666(); - void case3667(); - void case3668(); - void case3669(); - void case3670(); - void case3671(); - void case3672(); - void case3673(); - void case3674(); - void case3675(); - void case3676(); - void case3677(); - void case3678(); - void case3679(); - void case3680(); - void case3681(); - void case3682(); - void case3683(); - void case3684(); - void case3685(); - void case3686(); - void case3687(); - void case3688(); - void case3689(); - void case3690(); - void case3691(); - void case3692(); - void case3693(); - void case3694(); - void case3695(); - void case3696(); - void case3697(); - void case3698(); - void case3699(); + void case3600(); + void case3601(); + void case3602(); + void case3603(); + void case3604(); + void case3605(); + void case3606(); + void case3607(); + void case3608(); + void case3609(); + void case3610(); + void case3611(); + void case3612(); + void case3613(); + void case3614(); + void case3615(); + void case3616(); + void case3617(); + void case3618(); + void case3619(); + void case3620(); + void case3621(); + void case3622(); + void case3623(); + void case3624(); + void case3625(); + void case3626(); + void case3627(); + void case3628(); + void case3629(); + void case3630(); + void case3631(); + void case3632(); + void case3633(); + void case3634(); + void case3635(); + void case3636(); + void case3637(); + void case3638(); + void case3639(); + void case3640(); + void case3641(); + void case3642(); + void case3643(); + void case3644(); + void case3645(); + void case3646(); + void case3647(); + void case3648(); + void case3649(); + void case3650(); + void case3651(); + void case3652(); + void case3653(); + void case3654(); + void case3655(); + void case3656(); + void case3657(); + void case3658(); + void case3659(); + void case3660(); + void case3661(); + void case3662(); + void case3663(); + void case3664(); + void case3665(); + void case3666(); + void case3667(); + void case3668(); + void case3669(); + void case3670(); + void case3671(); + void case3672(); + void case3673(); + void case3674(); + void case3675(); + void case3676(); + void case3677(); + void case3678(); + void case3679(); + void case3680(); + void case3681(); + void case3682(); + void case3683(); + void case3684(); + void case3685(); + void case3686(); + void case3687(); + void case3688(); + void case3689(); + void case3690(); + void case3691(); + void case3692(); + void case3693(); + void case3694(); + void case3695(); + void case3696(); + void case3697(); + void case3698(); + void case3699(); - void case3700(); - void case3701(); - void case3702(); - void case3703(); - void case3704(); - void case3705(); - void case3706(); - void case3707(); - void case3708(); - void case3709(); - void case3710(); - void case3711(); - void case3712(); - void case3713(); - void case3714(); - void case3715(); - void case3716(); - void case3717(); - void case3718(); - void case3719(); - void case3720(); - void case3721(); - void case3722(); - void case3723(); - void case3724(); - void case3725(); - void case3726(); - void case3727(); - void case3728(); - void case3729(); - void case3730(); - void case3731(); - void case3732(); - void case3733(); - void case3734(); - void case3735(); - void case3736(); - void case3737(); - void case3738(); - void case3739(); - void case3740(); - void case3741(); - void case3742(); - void case3743(); - void case3744(); - void case3745(); - void case3746(); - void case3747(); - void case3748(); - void case3749(); - void case3750(); - void case3751(); - void case3752(); - void case3753(); - void case3754(); - void case3755(); - void case3756(); - void case3757(); - void case3758(); - void case3759(); - void case3760(); - void case3761(); - void case3762(); - void case3763(); - void case3764(); - void case3765(); - void case3766(); - void case3767(); - void case3768(); - void case3769(); - void case3770(); - void case3771(); - void case3772(); - void case3773(); - void case3774(); - void case3775(); - void case3776(); - void case3777(); - void case3778(); - void case3779(); - void case3780(); - void case3781(); - void case3782(); - void case3783(); - void case3784(); - void case3785(); - void case3786(); - void case3787(); - void case3788(); - void case3789(); - void case3790(); - void case3791(); - void case3792(); - void case3793(); - void case3794(); - void case3795(); - void case3796(); - void case3797(); - void case3798(); - void case3799(); + void case3700(); + void case3701(); + void case3702(); + void case3703(); + void case3704(); + void case3705(); + void case3706(); + void case3707(); + void case3708(); + void case3709(); + void case3710(); + void case3711(); + void case3712(); + void case3713(); + void case3714(); + void case3715(); + void case3716(); + void case3717(); + void case3718(); + void case3719(); + void case3720(); + void case3721(); + void case3722(); + void case3723(); + void case3724(); + void case3725(); + void case3726(); + void case3727(); + void case3728(); + void case3729(); + void case3730(); + void case3731(); + void case3732(); + void case3733(); + void case3734(); + void case3735(); + void case3736(); + void case3737(); + void case3738(); + void case3739(); + void case3740(); + void case3741(); + void case3742(); + void case3743(); + void case3744(); + void case3745(); + void case3746(); + void case3747(); + void case3748(); + void case3749(); + void case3750(); + void case3751(); + void case3752(); + void case3753(); + void case3754(); + void case3755(); + void case3756(); + void case3757(); + void case3758(); + void case3759(); + void case3760(); + void case3761(); + void case3762(); + void case3763(); + void case3764(); + void case3765(); + void case3766(); + void case3767(); + void case3768(); + void case3769(); + void case3770(); + void case3771(); + void case3772(); + void case3773(); + void case3774(); + void case3775(); + void case3776(); + void case3777(); + void case3778(); + void case3779(); + void case3780(); + void case3781(); + void case3782(); + void case3783(); + void case3784(); + void case3785(); + void case3786(); + void case3787(); + void case3788(); + void case3789(); + void case3790(); + void case3791(); + void case3792(); + void case3793(); + void case3794(); + void case3795(); + void case3796(); + void case3797(); + void case3798(); + void case3799(); - void case3800(); - void case3801(); - void case3802(); - void case3803(); - void case3804(); - void case3805(); - void case3806(); - void case3807(); - void case3808(); - void case3809(); - void case3810(); - void case3811(); - void case3812(); - void case3813(); - void case3814(); - void case3815(); - void case3816(); - void case3817(); - void case3818(); - void case3819(); - void case3820(); - void case3821(); - void case3822(); - void case3823(); - void case3824(); - void case3825(); - void case3826(); - void case3827(); - void case3828(); - void case3829(); - void case3830(); - void case3831(); - void case3832(); - void case3833(); - void case3834(); - void case3835(); - void case3836(); - void case3837(); - void case3838(); - void case3839(); - void case3840(); - void case3841(); - void case3842(); - void case3843(); - void case3844(); - void case3845(); - void case3846(); - void case3847(); - void case3848(); - void case3849(); - void case3850(); - void case3851(); - void case3852(); - void case3853(); - void case3854(); - void case3855(); - void case3856(); - void case3857(); - void case3858(); - void case3859(); - void case3860(); - void case3861(); - void case3862(); - void case3863(); - void case3864(); - void case3865(); - void case3866(); - void case3867(); - void case3868(); - void case3869(); - void case3870(); - void case3871(); - void case3872(); - void case3873(); - void case3874(); - void case3875(); - void case3876(); - void case3877(); - void case3878(); - void case3879(); - void case3880(); - void case3881(); - void case3882(); - void case3883(); - void case3884(); - void case3885(); - void case3886(); - void case3887(); - void case3888(); - void case3889(); - void case3890(); - void case3891(); - void case3892(); - void case3893(); - void case3894(); - void case3895(); - void case3896(); - void case3897(); - void case3898(); - void case3899(); + void case3800(); + void case3801(); + void case3802(); + void case3803(); + void case3804(); + void case3805(); + void case3806(); + void case3807(); + void case3808(); + void case3809(); + void case3810(); + void case3811(); + void case3812(); + void case3813(); + void case3814(); + void case3815(); + void case3816(); + void case3817(); + void case3818(); + void case3819(); + void case3820(); + void case3821(); + void case3822(); + void case3823(); + void case3824(); + void case3825(); + void case3826(); + void case3827(); + void case3828(); + void case3829(); + void case3830(); + void case3831(); + void case3832(); + void case3833(); + void case3834(); + void case3835(); + void case3836(); + void case3837(); + void case3838(); + void case3839(); + void case3840(); + void case3841(); + void case3842(); + void case3843(); + void case3844(); + void case3845(); + void case3846(); + void case3847(); + void case3848(); + void case3849(); + void case3850(); + void case3851(); + void case3852(); + void case3853(); + void case3854(); + void case3855(); + void case3856(); + void case3857(); + void case3858(); + void case3859(); + void case3860(); + void case3861(); + void case3862(); + void case3863(); + void case3864(); + void case3865(); + void case3866(); + void case3867(); + void case3868(); + void case3869(); + void case3870(); + void case3871(); + void case3872(); + void case3873(); + void case3874(); + void case3875(); + void case3876(); + void case3877(); + void case3878(); + void case3879(); + void case3880(); + void case3881(); + void case3882(); + void case3883(); + void case3884(); + void case3885(); + void case3886(); + void case3887(); + void case3888(); + void case3889(); + void case3890(); + void case3891(); + void case3892(); + void case3893(); + void case3894(); + void case3895(); + void case3896(); + void case3897(); + void case3898(); + void case3899(); - void case3900(); - void case3901(); - void case3902(); - void case3903(); - void case3904(); - void case3905(); - void case3906(); - void case3907(); - void case3908(); - void case3909(); - void case3910(); - void case3911(); - void case3912(); - void case3913(); - void case3914(); - void case3915(); - void case3916(); - void case3917(); - void case3918(); - void case3919(); - void case3920(); - void case3921(); - void case3922(); - void case3923(); - void case3924(); - void case3925(); - void case3926(); - void case3927(); - void case3928(); - void case3929(); - void case3930(); - void case3931(); - void case3932(); - void case3933(); - void case3934(); - void case3935(); - void case3936(); - void case3937(); - void case3938(); - void case3939(); - void case3940(); - void case3941(); - void case3942(); - void case3943(); - void case3944(); - void case3945(); - void case3946(); - void case3947(); - void case3948(); - void case3949(); - void case3950(); - void case3951(); - void case3952(); - void case3953(); - void case3954(); - void case3955(); - void case3956(); - void case3957(); - void case3958(); - void case3959(); - void case3960(); - void case3961(); - void case3962(); - void case3963(); - void case3964(); - void case3965(); - void case3966(); - void case3967(); - void case3968(); - void case3969(); - void case3970(); - void case3971(); - void case3972(); - void case3973(); - void case3974(); - void case3975(); - void case3976(); - void case3977(); - void case3978(); - void case3979(); - void case3980(); - void case3981(); - void case3982(); - void case3983(); - void case3984(); - void case3985(); - void case3986(); - void case3987(); - void case3988(); - void case3989(); - void case3990(); - void case3991(); - void case3992(); - void case3993(); - void case3994(); - void case3995(); - void case3996(); - void case3997(); - void case3998(); - void case3999(); + void case3900(); + void case3901(); + void case3902(); + void case3903(); + void case3904(); + void case3905(); + void case3906(); + void case3907(); + void case3908(); + void case3909(); + void case3910(); + void case3911(); + void case3912(); + void case3913(); + void case3914(); + void case3915(); + void case3916(); + void case3917(); + void case3918(); + void case3919(); + void case3920(); + void case3921(); + void case3922(); + void case3923(); + void case3924(); + void case3925(); + void case3926(); + void case3927(); + void case3928(); + void case3929(); + void case3930(); + void case3931(); + void case3932(); + void case3933(); + void case3934(); + void case3935(); + void case3936(); + void case3937(); + void case3938(); + void case3939(); + void case3940(); + void case3941(); + void case3942(); + void case3943(); + void case3944(); + void case3945(); + void case3946(); + void case3947(); + void case3948(); + void case3949(); + void case3950(); + void case3951(); + void case3952(); + void case3953(); + void case3954(); + void case3955(); + void case3956(); + void case3957(); + void case3958(); + void case3959(); + void case3960(); + void case3961(); + void case3962(); + void case3963(); + void case3964(); + void case3965(); + void case3966(); + void case3967(); + void case3968(); + void case3969(); + void case3970(); + void case3971(); + void case3972(); + void case3973(); + void case3974(); + void case3975(); + void case3976(); + void case3977(); + void case3978(); + void case3979(); + void case3980(); + void case3981(); + void case3982(); + void case3983(); + void case3984(); + void case3985(); + void case3986(); + void case3987(); + void case3988(); + void case3989(); + void case3990(); + void case3991(); + void case3992(); + void case3993(); + void case3994(); + void case3995(); + void case3996(); + void case3997(); + void case3998(); + void case3999(); - std::vector tests_ - { - TEST_PARSER(case0001), - TEST_PARSER(case0002), - TEST_PARSER(case0003), - TEST_PARSER(case0004), - TEST_PARSER(case0005), - TEST_PARSER(case0006), - TEST_PARSER(case0007), - TEST_PARSER(case0008), - TEST_PARSER(case0009), - TEST_PARSER(case0010), - TEST_PARSER(case0011), - TEST_PARSER(case0012), - TEST_PARSER(case0013), - TEST_PARSER(case0014), - TEST_PARSER(case0015), - TEST_PARSER(case0016), - TEST_PARSER(case0017), - TEST_PARSER(case0018), - TEST_PARSER(case0019), - TEST_PARSER(case0020), - TEST_PARSER(case0021), - TEST_PARSER(case0022), - TEST_PARSER(case0023), - TEST_PARSER(case0024), - TEST_PARSER(case0025), - TEST_PARSER(case0026), - TEST_PARSER(case0027), - TEST_PARSER(case0028), - TEST_PARSER(case0029), - TEST_PARSER(case0030), - TEST_PARSER(case0031), - TEST_PARSER(case0032), - TEST_PARSER(case0033), - TEST_PARSER(case0034), - TEST_PARSER(case0035), - TEST_PARSER(case0036), - TEST_PARSER(case0037), - TEST_PARSER(case0038), - TEST_PARSER(case0039), - TEST_PARSER(case0040), - TEST_PARSER(case0041), - TEST_PARSER(case0042), - TEST_PARSER(case0043), - TEST_PARSER(case0044), - TEST_PARSER(case0045), - TEST_PARSER(case0046), - TEST_PARSER(case0047), - TEST_PARSER(case0048), - TEST_PARSER(case0049), - TEST_PARSER(case0050), - TEST_PARSER(case0051), - TEST_PARSER(case0052), - TEST_PARSER(case0053), - TEST_PARSER(case0054), - TEST_PARSER(case0055), - TEST_PARSER(case0056), - TEST_PARSER(case0057), - TEST_PARSER(case0058), - TEST_PARSER(case0059), - TEST_PARSER(case0060), - TEST_PARSER(case0061), - TEST_PARSER(case0062), - TEST_PARSER(case0063), - TEST_PARSER(case0064), - TEST_PARSER(case0065), - TEST_PARSER(case0066), - TEST_PARSER(case0067), - TEST_PARSER(case0068), - TEST_PARSER(case0069), - TEST_PARSER(case0070), - TEST_PARSER(case0071), - TEST_PARSER(case0072), - TEST_PARSER(case0073), - TEST_PARSER(case0074), - TEST_PARSER(case0075), - TEST_PARSER(case0076), - TEST_PARSER(case0077), - TEST_PARSER(case0078), - TEST_PARSER(case0079), - TEST_PARSER(case0080), - TEST_PARSER(case0081), - TEST_PARSER(case0082), - TEST_PARSER(case0083), - TEST_PARSER(case0084), - TEST_PARSER(case0085), - TEST_PARSER(case0086), - TEST_PARSER(case0087), - TEST_PARSER(case0088), - TEST_PARSER(case0089), - TEST_PARSER(case0090), - TEST_PARSER(case0091), - TEST_PARSER(case0092), - TEST_PARSER(case0093), - TEST_PARSER(case0094), - TEST_PARSER(case0095), - TEST_PARSER(case0096), - TEST_PARSER(case0097), - TEST_PARSER(case0098), - TEST_PARSER(case0099), + std::vector tests_{ + TEST_PARSER(case0001), TEST_PARSER(case0002), TEST_PARSER(case0003), + TEST_PARSER(case0004), TEST_PARSER(case0005), TEST_PARSER(case0006), + TEST_PARSER(case0007), TEST_PARSER(case0008), TEST_PARSER(case0009), + TEST_PARSER(case0010), TEST_PARSER(case0011), TEST_PARSER(case0012), + TEST_PARSER(case0013), TEST_PARSER(case0014), TEST_PARSER(case0015), + TEST_PARSER(case0016), TEST_PARSER(case0017), TEST_PARSER(case0018), + TEST_PARSER(case0019), TEST_PARSER(case0020), TEST_PARSER(case0021), + TEST_PARSER(case0022), TEST_PARSER(case0023), TEST_PARSER(case0024), + TEST_PARSER(case0025), TEST_PARSER(case0026), TEST_PARSER(case0027), + TEST_PARSER(case0028), TEST_PARSER(case0029), TEST_PARSER(case0030), + TEST_PARSER(case0031), TEST_PARSER(case0032), TEST_PARSER(case0033), + TEST_PARSER(case0034), TEST_PARSER(case0035), TEST_PARSER(case0036), + TEST_PARSER(case0037), TEST_PARSER(case0038), TEST_PARSER(case0039), + TEST_PARSER(case0040), TEST_PARSER(case0041), TEST_PARSER(case0042), + TEST_PARSER(case0043), TEST_PARSER(case0044), TEST_PARSER(case0045), + TEST_PARSER(case0046), TEST_PARSER(case0047), TEST_PARSER(case0048), + TEST_PARSER(case0049), TEST_PARSER(case0050), TEST_PARSER(case0051), + TEST_PARSER(case0052), TEST_PARSER(case0053), TEST_PARSER(case0054), + TEST_PARSER(case0055), TEST_PARSER(case0056), TEST_PARSER(case0057), + TEST_PARSER(case0058), TEST_PARSER(case0059), TEST_PARSER(case0060), + TEST_PARSER(case0061), TEST_PARSER(case0062), TEST_PARSER(case0063), + TEST_PARSER(case0064), TEST_PARSER(case0065), TEST_PARSER(case0066), + TEST_PARSER(case0067), TEST_PARSER(case0068), TEST_PARSER(case0069), + TEST_PARSER(case0070), TEST_PARSER(case0071), TEST_PARSER(case0072), + TEST_PARSER(case0073), TEST_PARSER(case0074), TEST_PARSER(case0075), + TEST_PARSER(case0076), TEST_PARSER(case0077), TEST_PARSER(case0078), + TEST_PARSER(case0079), TEST_PARSER(case0080), TEST_PARSER(case0081), + TEST_PARSER(case0082), TEST_PARSER(case0083), TEST_PARSER(case0084), + TEST_PARSER(case0085), TEST_PARSER(case0086), TEST_PARSER(case0087), + TEST_PARSER(case0088), TEST_PARSER(case0089), TEST_PARSER(case0090), + TEST_PARSER(case0091), TEST_PARSER(case0092), TEST_PARSER(case0093), + TEST_PARSER(case0094), TEST_PARSER(case0095), TEST_PARSER(case0096), + TEST_PARSER(case0097), TEST_PARSER(case0098), TEST_PARSER(case0099), - TEST_PARSER(case0100), - TEST_PARSER(case0101), - TEST_PARSER(case0102), - TEST_PARSER(case0103), - TEST_PARSER(case0104), - TEST_PARSER(case0105), - TEST_PARSER(case0106), - TEST_PARSER(case0107), - TEST_PARSER(case0108), - TEST_PARSER(case0109), - TEST_PARSER(case0110), - TEST_PARSER(case0111), - TEST_PARSER(case0112), - TEST_PARSER(case0113), - TEST_PARSER(case0114), - TEST_PARSER(case0115), - TEST_PARSER(case0116), - TEST_PARSER(case0117), - TEST_PARSER(case0118), - TEST_PARSER(case0119), - TEST_PARSER(case0120), - TEST_PARSER(case0121), - TEST_PARSER(case0122), - TEST_PARSER(case0123), - TEST_PARSER(case0124), - TEST_PARSER(case0125), - TEST_PARSER(case0126), - TEST_PARSER(case0127), - TEST_PARSER(case0128), - TEST_PARSER(case0129), - TEST_PARSER(case0130), - TEST_PARSER(case0131), - TEST_PARSER(case0132), - TEST_PARSER(case0133), - TEST_PARSER(case0134), - TEST_PARSER(case0135), - TEST_PARSER(case0136), - TEST_PARSER(case0137), - TEST_PARSER(case0138), - TEST_PARSER(case0139), - TEST_PARSER(case0140), - TEST_PARSER(case0141), - TEST_PARSER(case0142), - TEST_PARSER(case0143), - TEST_PARSER(case0144), - TEST_PARSER(case0145), - TEST_PARSER(case0146), - TEST_PARSER(case0147), - TEST_PARSER(case0148), - TEST_PARSER(case0149), - TEST_PARSER(case0150), - TEST_PARSER(case0151), - TEST_PARSER(case0152), - TEST_PARSER(case0153), - TEST_PARSER(case0154), - TEST_PARSER(case0155), - TEST_PARSER(case0156), - TEST_PARSER(case0157), - TEST_PARSER(case0158), - TEST_PARSER(case0159), - TEST_PARSER(case0160), - TEST_PARSER(case0161), - TEST_PARSER(case0162), - TEST_PARSER(case0163), - TEST_PARSER(case0164), - TEST_PARSER(case0165), - TEST_PARSER(case0166), - TEST_PARSER(case0167), - TEST_PARSER(case0168), - TEST_PARSER(case0169), - TEST_PARSER(case0170), - TEST_PARSER(case0171), - TEST_PARSER(case0172), - TEST_PARSER(case0173), - TEST_PARSER(case0174), - TEST_PARSER(case0175), - TEST_PARSER(case0176), - TEST_PARSER(case0177), - TEST_PARSER(case0178), - TEST_PARSER(case0179), - TEST_PARSER(case0180), - TEST_PARSER(case0181), - TEST_PARSER(case0182), - TEST_PARSER(case0183), - TEST_PARSER(case0184), - TEST_PARSER(case0185), - TEST_PARSER(case0186), - TEST_PARSER(case0187), - TEST_PARSER(case0188), - TEST_PARSER(case0189), - TEST_PARSER(case0190), - TEST_PARSER(case0191), - TEST_PARSER(case0192), - TEST_PARSER(case0193), - TEST_PARSER(case0194), - TEST_PARSER(case0195), - TEST_PARSER(case0196), - TEST_PARSER(case0197), - TEST_PARSER(case0198), - TEST_PARSER(case0199), + TEST_PARSER(case0100), TEST_PARSER(case0101), TEST_PARSER(case0102), + TEST_PARSER(case0103), TEST_PARSER(case0104), TEST_PARSER(case0105), + TEST_PARSER(case0106), TEST_PARSER(case0107), TEST_PARSER(case0108), + TEST_PARSER(case0109), TEST_PARSER(case0110), TEST_PARSER(case0111), + TEST_PARSER(case0112), TEST_PARSER(case0113), TEST_PARSER(case0114), + TEST_PARSER(case0115), TEST_PARSER(case0116), TEST_PARSER(case0117), + TEST_PARSER(case0118), TEST_PARSER(case0119), TEST_PARSER(case0120), + TEST_PARSER(case0121), TEST_PARSER(case0122), TEST_PARSER(case0123), + TEST_PARSER(case0124), TEST_PARSER(case0125), TEST_PARSER(case0126), + TEST_PARSER(case0127), TEST_PARSER(case0128), TEST_PARSER(case0129), + TEST_PARSER(case0130), TEST_PARSER(case0131), TEST_PARSER(case0132), + TEST_PARSER(case0133), TEST_PARSER(case0134), TEST_PARSER(case0135), + TEST_PARSER(case0136), TEST_PARSER(case0137), TEST_PARSER(case0138), + TEST_PARSER(case0139), TEST_PARSER(case0140), TEST_PARSER(case0141), + TEST_PARSER(case0142), TEST_PARSER(case0143), TEST_PARSER(case0144), + TEST_PARSER(case0145), TEST_PARSER(case0146), TEST_PARSER(case0147), + TEST_PARSER(case0148), TEST_PARSER(case0149), TEST_PARSER(case0150), + TEST_PARSER(case0151), TEST_PARSER(case0152), TEST_PARSER(case0153), + TEST_PARSER(case0154), TEST_PARSER(case0155), TEST_PARSER(case0156), + TEST_PARSER(case0157), TEST_PARSER(case0158), TEST_PARSER(case0159), + TEST_PARSER(case0160), TEST_PARSER(case0161), TEST_PARSER(case0162), + TEST_PARSER(case0163), TEST_PARSER(case0164), TEST_PARSER(case0165), + TEST_PARSER(case0166), TEST_PARSER(case0167), TEST_PARSER(case0168), + TEST_PARSER(case0169), TEST_PARSER(case0170), TEST_PARSER(case0171), + TEST_PARSER(case0172), TEST_PARSER(case0173), TEST_PARSER(case0174), + TEST_PARSER(case0175), TEST_PARSER(case0176), TEST_PARSER(case0177), + TEST_PARSER(case0178), TEST_PARSER(case0179), TEST_PARSER(case0180), + TEST_PARSER(case0181), TEST_PARSER(case0182), TEST_PARSER(case0183), + TEST_PARSER(case0184), TEST_PARSER(case0185), TEST_PARSER(case0186), + TEST_PARSER(case0187), TEST_PARSER(case0188), TEST_PARSER(case0189), + TEST_PARSER(case0190), TEST_PARSER(case0191), TEST_PARSER(case0192), + TEST_PARSER(case0193), TEST_PARSER(case0194), TEST_PARSER(case0195), + TEST_PARSER(case0196), TEST_PARSER(case0197), TEST_PARSER(case0198), + TEST_PARSER(case0199), - TEST_PARSER(case0200), - TEST_PARSER(case0201), - TEST_PARSER(case0202), - TEST_PARSER(case0203), - TEST_PARSER(case0204), - TEST_PARSER(case0205), - TEST_PARSER(case0206), - TEST_PARSER(case0207), - TEST_PARSER(case0208), - TEST_PARSER(case0209), - TEST_PARSER(case0210), - TEST_PARSER(case0211), - TEST_PARSER(case0212), - TEST_PARSER(case0213), - TEST_PARSER(case0214), - TEST_PARSER(case0215), - TEST_PARSER(case0216), - TEST_PARSER(case0217), - TEST_PARSER(case0218), - TEST_PARSER(case0219), - TEST_PARSER(case0220), - TEST_PARSER(case0221), - TEST_PARSER(case0222), - TEST_PARSER(case0223), - TEST_PARSER(case0224), - TEST_PARSER(case0225), - TEST_PARSER(case0226), - TEST_PARSER(case0227), - TEST_PARSER(case0228), - TEST_PARSER(case0229), - TEST_PARSER(case0230), - TEST_PARSER(case0231), - TEST_PARSER(case0232), - TEST_PARSER(case0233), - TEST_PARSER(case0234), - TEST_PARSER(case0235), - TEST_PARSER(case0236), - TEST_PARSER(case0237), - TEST_PARSER(case0238), - TEST_PARSER(case0239), - TEST_PARSER(case0240), - TEST_PARSER(case0241), - TEST_PARSER(case0242), - TEST_PARSER(case0243), - TEST_PARSER(case0244), - TEST_PARSER(case0245), - TEST_PARSER(case0246), - TEST_PARSER(case0247), - TEST_PARSER(case0248), - TEST_PARSER(case0249), - TEST_PARSER(case0250), - TEST_PARSER(case0251), - TEST_PARSER(case0252), - TEST_PARSER(case0253), - TEST_PARSER(case0254), - TEST_PARSER(case0255), - TEST_PARSER(case0256), - TEST_PARSER(case0257), - TEST_PARSER(case0258), - TEST_PARSER(case0259), - TEST_PARSER(case0260), - TEST_PARSER(case0261), - TEST_PARSER(case0262), - TEST_PARSER(case0263), - TEST_PARSER(case0264), - TEST_PARSER(case0265), - TEST_PARSER(case0266), - TEST_PARSER(case0267), - TEST_PARSER(case0268), - TEST_PARSER(case0269), - TEST_PARSER(case0270), - TEST_PARSER(case0271), - TEST_PARSER(case0272), - TEST_PARSER(case0273), - TEST_PARSER(case0274), - TEST_PARSER(case0275), - TEST_PARSER(case0276), - TEST_PARSER(case0277), - TEST_PARSER(case0278), - TEST_PARSER(case0279), - TEST_PARSER(case0280), - TEST_PARSER(case0281), - TEST_PARSER(case0282), - TEST_PARSER(case0283), - TEST_PARSER(case0284), - TEST_PARSER(case0285), - TEST_PARSER(case0286), - TEST_PARSER(case0287), - TEST_PARSER(case0288), - TEST_PARSER(case0289), - TEST_PARSER(case0290), - TEST_PARSER(case0291), - TEST_PARSER(case0292), - TEST_PARSER(case0293), - TEST_PARSER(case0294), - TEST_PARSER(case0295), - TEST_PARSER(case0296), - TEST_PARSER(case0297), - TEST_PARSER(case0298), - TEST_PARSER(case0299), + TEST_PARSER(case0200), TEST_PARSER(case0201), TEST_PARSER(case0202), + TEST_PARSER(case0203), TEST_PARSER(case0204), TEST_PARSER(case0205), + TEST_PARSER(case0206), TEST_PARSER(case0207), TEST_PARSER(case0208), + TEST_PARSER(case0209), TEST_PARSER(case0210), TEST_PARSER(case0211), + TEST_PARSER(case0212), TEST_PARSER(case0213), TEST_PARSER(case0214), + TEST_PARSER(case0215), TEST_PARSER(case0216), TEST_PARSER(case0217), + TEST_PARSER(case0218), TEST_PARSER(case0219), TEST_PARSER(case0220), + TEST_PARSER(case0221), TEST_PARSER(case0222), TEST_PARSER(case0223), + TEST_PARSER(case0224), TEST_PARSER(case0225), TEST_PARSER(case0226), + TEST_PARSER(case0227), TEST_PARSER(case0228), TEST_PARSER(case0229), + TEST_PARSER(case0230), TEST_PARSER(case0231), TEST_PARSER(case0232), + TEST_PARSER(case0233), TEST_PARSER(case0234), TEST_PARSER(case0235), + TEST_PARSER(case0236), TEST_PARSER(case0237), TEST_PARSER(case0238), + TEST_PARSER(case0239), TEST_PARSER(case0240), TEST_PARSER(case0241), + TEST_PARSER(case0242), TEST_PARSER(case0243), TEST_PARSER(case0244), + TEST_PARSER(case0245), TEST_PARSER(case0246), TEST_PARSER(case0247), + TEST_PARSER(case0248), TEST_PARSER(case0249), TEST_PARSER(case0250), + TEST_PARSER(case0251), TEST_PARSER(case0252), TEST_PARSER(case0253), + TEST_PARSER(case0254), TEST_PARSER(case0255), TEST_PARSER(case0256), + TEST_PARSER(case0257), TEST_PARSER(case0258), TEST_PARSER(case0259), + TEST_PARSER(case0260), TEST_PARSER(case0261), TEST_PARSER(case0262), + TEST_PARSER(case0263), TEST_PARSER(case0264), TEST_PARSER(case0265), + TEST_PARSER(case0266), TEST_PARSER(case0267), TEST_PARSER(case0268), + TEST_PARSER(case0269), TEST_PARSER(case0270), TEST_PARSER(case0271), + TEST_PARSER(case0272), TEST_PARSER(case0273), TEST_PARSER(case0274), + TEST_PARSER(case0275), TEST_PARSER(case0276), TEST_PARSER(case0277), + TEST_PARSER(case0278), TEST_PARSER(case0279), TEST_PARSER(case0280), + TEST_PARSER(case0281), TEST_PARSER(case0282), TEST_PARSER(case0283), + TEST_PARSER(case0284), TEST_PARSER(case0285), TEST_PARSER(case0286), + TEST_PARSER(case0287), TEST_PARSER(case0288), TEST_PARSER(case0289), + TEST_PARSER(case0290), TEST_PARSER(case0291), TEST_PARSER(case0292), + TEST_PARSER(case0293), TEST_PARSER(case0294), TEST_PARSER(case0295), + TEST_PARSER(case0296), TEST_PARSER(case0297), TEST_PARSER(case0298), + TEST_PARSER(case0299), - TEST_PARSER(case0300), - TEST_PARSER(case0301), - TEST_PARSER(case0302), - TEST_PARSER(case0303), - TEST_PARSER(case0304), - TEST_PARSER(case0305), - TEST_PARSER(case0306), - TEST_PARSER(case0307), - TEST_PARSER(case0308), - TEST_PARSER(case0309), - TEST_PARSER(case0310), - TEST_PARSER(case0311), - TEST_PARSER(case0312), - TEST_PARSER(case0313), - TEST_PARSER(case0314), - TEST_PARSER(case0315), - TEST_PARSER(case0316), - TEST_PARSER(case0317), - TEST_PARSER(case0318), - TEST_PARSER(case0319), - TEST_PARSER(case0320), - TEST_PARSER(case0321), - TEST_PARSER(case0322), - TEST_PARSER(case0323), - TEST_PARSER(case0324), - TEST_PARSER(case0325), - TEST_PARSER(case0326), - TEST_PARSER(case0327), - TEST_PARSER(case0328), - TEST_PARSER(case0329), - TEST_PARSER(case0330), - TEST_PARSER(case0331), - TEST_PARSER(case0332), - TEST_PARSER(case0333), - TEST_PARSER(case0334), - TEST_PARSER(case0335), - TEST_PARSER(case0336), - TEST_PARSER(case0337), - TEST_PARSER(case0338), - TEST_PARSER(case0339), - TEST_PARSER(case0340), - TEST_PARSER(case0341), - TEST_PARSER(case0342), - TEST_PARSER(case0343), - TEST_PARSER(case0344), - TEST_PARSER(case0345), - TEST_PARSER(case0346), - TEST_PARSER(case0347), - TEST_PARSER(case0348), - TEST_PARSER(case0349), - TEST_PARSER(case0350), - TEST_PARSER(case0351), - TEST_PARSER(case0352), - TEST_PARSER(case0353), - TEST_PARSER(case0354), - TEST_PARSER(case0355), - TEST_PARSER(case0356), - TEST_PARSER(case0357), - TEST_PARSER(case0358), - TEST_PARSER(case0359), - TEST_PARSER(case0360), - TEST_PARSER(case0361), - TEST_PARSER(case0362), - TEST_PARSER(case0363), - TEST_PARSER(case0364), - TEST_PARSER(case0365), - TEST_PARSER(case0366), - TEST_PARSER(case0367), - TEST_PARSER(case0368), - TEST_PARSER(case0369), - TEST_PARSER(case0370), - TEST_PARSER(case0371), - TEST_PARSER(case0372), - TEST_PARSER(case0373), - TEST_PARSER(case0374), - TEST_PARSER(case0375), - TEST_PARSER(case0376), - TEST_PARSER(case0377), - TEST_PARSER(case0378), - TEST_PARSER(case0379), - TEST_PARSER(case0380), - TEST_PARSER(case0381), - TEST_PARSER(case0382), - TEST_PARSER(case0383), - TEST_PARSER(case0384), - TEST_PARSER(case0385), - TEST_PARSER(case0386), - TEST_PARSER(case0387), - TEST_PARSER(case0388), - TEST_PARSER(case0389), - TEST_PARSER(case0390), - TEST_PARSER(case0391), - TEST_PARSER(case0392), - TEST_PARSER(case0393), - TEST_PARSER(case0394), - TEST_PARSER(case0395), - TEST_PARSER(case0396), - TEST_PARSER(case0397), - TEST_PARSER(case0398), - TEST_PARSER(case0399), + TEST_PARSER(case0300), TEST_PARSER(case0301), TEST_PARSER(case0302), + TEST_PARSER(case0303), TEST_PARSER(case0304), TEST_PARSER(case0305), + TEST_PARSER(case0306), TEST_PARSER(case0307), TEST_PARSER(case0308), + TEST_PARSER(case0309), TEST_PARSER(case0310), TEST_PARSER(case0311), + TEST_PARSER(case0312), TEST_PARSER(case0313), TEST_PARSER(case0314), + TEST_PARSER(case0315), TEST_PARSER(case0316), TEST_PARSER(case0317), + TEST_PARSER(case0318), TEST_PARSER(case0319), TEST_PARSER(case0320), + TEST_PARSER(case0321), TEST_PARSER(case0322), TEST_PARSER(case0323), + TEST_PARSER(case0324), TEST_PARSER(case0325), TEST_PARSER(case0326), + TEST_PARSER(case0327), TEST_PARSER(case0328), TEST_PARSER(case0329), + TEST_PARSER(case0330), TEST_PARSER(case0331), TEST_PARSER(case0332), + TEST_PARSER(case0333), TEST_PARSER(case0334), TEST_PARSER(case0335), + TEST_PARSER(case0336), TEST_PARSER(case0337), TEST_PARSER(case0338), + TEST_PARSER(case0339), TEST_PARSER(case0340), TEST_PARSER(case0341), + TEST_PARSER(case0342), TEST_PARSER(case0343), TEST_PARSER(case0344), + TEST_PARSER(case0345), TEST_PARSER(case0346), TEST_PARSER(case0347), + TEST_PARSER(case0348), TEST_PARSER(case0349), TEST_PARSER(case0350), + TEST_PARSER(case0351), TEST_PARSER(case0352), TEST_PARSER(case0353), + TEST_PARSER(case0354), TEST_PARSER(case0355), TEST_PARSER(case0356), + TEST_PARSER(case0357), TEST_PARSER(case0358), TEST_PARSER(case0359), + TEST_PARSER(case0360), TEST_PARSER(case0361), TEST_PARSER(case0362), + TEST_PARSER(case0363), TEST_PARSER(case0364), TEST_PARSER(case0365), + TEST_PARSER(case0366), TEST_PARSER(case0367), TEST_PARSER(case0368), + TEST_PARSER(case0369), TEST_PARSER(case0370), TEST_PARSER(case0371), + TEST_PARSER(case0372), TEST_PARSER(case0373), TEST_PARSER(case0374), + TEST_PARSER(case0375), TEST_PARSER(case0376), TEST_PARSER(case0377), + TEST_PARSER(case0378), TEST_PARSER(case0379), TEST_PARSER(case0380), + TEST_PARSER(case0381), TEST_PARSER(case0382), TEST_PARSER(case0383), + TEST_PARSER(case0384), TEST_PARSER(case0385), TEST_PARSER(case0386), + TEST_PARSER(case0387), TEST_PARSER(case0388), TEST_PARSER(case0389), + TEST_PARSER(case0390), TEST_PARSER(case0391), TEST_PARSER(case0392), + TEST_PARSER(case0393), TEST_PARSER(case0394), TEST_PARSER(case0395), + TEST_PARSER(case0396), TEST_PARSER(case0397), TEST_PARSER(case0398), + TEST_PARSER(case0399), - TEST_PARSER(case0400), - TEST_PARSER(case0401), - TEST_PARSER(case0402), - TEST_PARSER(case0403), - TEST_PARSER(case0404), - TEST_PARSER(case0405), - TEST_PARSER(case0406), - TEST_PARSER(case0407), - TEST_PARSER(case0408), - TEST_PARSER(case0409), - TEST_PARSER(case0410), - TEST_PARSER(case0411), - TEST_PARSER(case0412), - TEST_PARSER(case0413), - TEST_PARSER(case0414), - TEST_PARSER(case0415), - TEST_PARSER(case0416), - TEST_PARSER(case0417), - TEST_PARSER(case0418), - TEST_PARSER(case0419), - TEST_PARSER(case0420), - TEST_PARSER(case0421), - TEST_PARSER(case0422), - TEST_PARSER(case0423), - TEST_PARSER(case0424), - TEST_PARSER(case0425), - TEST_PARSER(case0426), - TEST_PARSER(case0427), - TEST_PARSER(case0428), - TEST_PARSER(case0429), - TEST_PARSER(case0430), - TEST_PARSER(case0431), - TEST_PARSER(case0432), - TEST_PARSER(case0433), - TEST_PARSER(case0434), - TEST_PARSER(case0435), - TEST_PARSER(case0436), - TEST_PARSER(case0437), - TEST_PARSER(case0438), - TEST_PARSER(case0439), - TEST_PARSER(case0440), - TEST_PARSER(case0441), - TEST_PARSER(case0442), - TEST_PARSER(case0443), - TEST_PARSER(case0444), - TEST_PARSER(case0445), - TEST_PARSER(case0446), - TEST_PARSER(case0447), - TEST_PARSER(case0448), - TEST_PARSER(case0449), - TEST_PARSER(case0450), - TEST_PARSER(case0451), - TEST_PARSER(case0452), - TEST_PARSER(case0453), - TEST_PARSER(case0454), - TEST_PARSER(case0455), - TEST_PARSER(case0456), - TEST_PARSER(case0457), - TEST_PARSER(case0458), - TEST_PARSER(case0459), - TEST_PARSER(case0460), - TEST_PARSER(case0461), - TEST_PARSER(case0462), - TEST_PARSER(case0463), - TEST_PARSER(case0464), - TEST_PARSER(case0465), - TEST_PARSER(case0466), - TEST_PARSER(case0467), - TEST_PARSER(case0468), - TEST_PARSER(case0469), - TEST_PARSER(case0470), - TEST_PARSER(case0471), - TEST_PARSER(case0472), - TEST_PARSER(case0473), - TEST_PARSER(case0474), - TEST_PARSER(case0475), - TEST_PARSER(case0476), - TEST_PARSER(case0477), - TEST_PARSER(case0478), - TEST_PARSER(case0479), - TEST_PARSER(case0480), - TEST_PARSER(case0481), - TEST_PARSER(case0482), - TEST_PARSER(case0483), - TEST_PARSER(case0484), - TEST_PARSER(case0485), - TEST_PARSER(case0486), - TEST_PARSER(case0487), - TEST_PARSER(case0488), - TEST_PARSER(case0489), - TEST_PARSER(case0490), - TEST_PARSER(case0491), - TEST_PARSER(case0492), - TEST_PARSER(case0493), - TEST_PARSER(case0494), - TEST_PARSER(case0495), - TEST_PARSER(case0496), - TEST_PARSER(case0497), - TEST_PARSER(case0498), - TEST_PARSER(case0499), + TEST_PARSER(case0400), TEST_PARSER(case0401), TEST_PARSER(case0402), + TEST_PARSER(case0403), TEST_PARSER(case0404), TEST_PARSER(case0405), + TEST_PARSER(case0406), TEST_PARSER(case0407), TEST_PARSER(case0408), + TEST_PARSER(case0409), TEST_PARSER(case0410), TEST_PARSER(case0411), + TEST_PARSER(case0412), TEST_PARSER(case0413), TEST_PARSER(case0414), + TEST_PARSER(case0415), TEST_PARSER(case0416), TEST_PARSER(case0417), + TEST_PARSER(case0418), TEST_PARSER(case0419), TEST_PARSER(case0420), + TEST_PARSER(case0421), TEST_PARSER(case0422), TEST_PARSER(case0423), + TEST_PARSER(case0424), TEST_PARSER(case0425), TEST_PARSER(case0426), + TEST_PARSER(case0427), TEST_PARSER(case0428), TEST_PARSER(case0429), + TEST_PARSER(case0430), TEST_PARSER(case0431), TEST_PARSER(case0432), + TEST_PARSER(case0433), TEST_PARSER(case0434), TEST_PARSER(case0435), + TEST_PARSER(case0436), TEST_PARSER(case0437), TEST_PARSER(case0438), + TEST_PARSER(case0439), TEST_PARSER(case0440), TEST_PARSER(case0441), + TEST_PARSER(case0442), TEST_PARSER(case0443), TEST_PARSER(case0444), + TEST_PARSER(case0445), TEST_PARSER(case0446), TEST_PARSER(case0447), + TEST_PARSER(case0448), TEST_PARSER(case0449), TEST_PARSER(case0450), + TEST_PARSER(case0451), TEST_PARSER(case0452), TEST_PARSER(case0453), + TEST_PARSER(case0454), TEST_PARSER(case0455), TEST_PARSER(case0456), + TEST_PARSER(case0457), TEST_PARSER(case0458), TEST_PARSER(case0459), + TEST_PARSER(case0460), TEST_PARSER(case0461), TEST_PARSER(case0462), + TEST_PARSER(case0463), TEST_PARSER(case0464), TEST_PARSER(case0465), + TEST_PARSER(case0466), TEST_PARSER(case0467), TEST_PARSER(case0468), + TEST_PARSER(case0469), TEST_PARSER(case0470), TEST_PARSER(case0471), + TEST_PARSER(case0472), TEST_PARSER(case0473), TEST_PARSER(case0474), + TEST_PARSER(case0475), TEST_PARSER(case0476), TEST_PARSER(case0477), + TEST_PARSER(case0478), TEST_PARSER(case0479), TEST_PARSER(case0480), + TEST_PARSER(case0481), TEST_PARSER(case0482), TEST_PARSER(case0483), + TEST_PARSER(case0484), TEST_PARSER(case0485), TEST_PARSER(case0486), + TEST_PARSER(case0487), TEST_PARSER(case0488), TEST_PARSER(case0489), + TEST_PARSER(case0490), TEST_PARSER(case0491), TEST_PARSER(case0492), + TEST_PARSER(case0493), TEST_PARSER(case0494), TEST_PARSER(case0495), + TEST_PARSER(case0496), TEST_PARSER(case0497), TEST_PARSER(case0498), + TEST_PARSER(case0499), - TEST_PARSER(case0500), - TEST_PARSER(case0501), - TEST_PARSER(case0502), - TEST_PARSER(case0503), - TEST_PARSER(case0504), - TEST_PARSER(case0505), - TEST_PARSER(case0506), - TEST_PARSER(case0507), - TEST_PARSER(case0508), - TEST_PARSER(case0509), - TEST_PARSER(case0510), - TEST_PARSER(case0511), - TEST_PARSER(case0512), - TEST_PARSER(case0513), - TEST_PARSER(case0514), - TEST_PARSER(case0515), - TEST_PARSER(case0516), - TEST_PARSER(case0517), - TEST_PARSER(case0518), - TEST_PARSER(case0519), - TEST_PARSER(case0520), - TEST_PARSER(case0521), - TEST_PARSER(case0522), - TEST_PARSER(case0523), - TEST_PARSER(case0524), - TEST_PARSER(case0525), - TEST_PARSER(case0526), - TEST_PARSER(case0527), - TEST_PARSER(case0528), - TEST_PARSER(case0529), - TEST_PARSER(case0530), - TEST_PARSER(case0531), - TEST_PARSER(case0532), - TEST_PARSER(case0533), - TEST_PARSER(case0534), - TEST_PARSER(case0535), - TEST_PARSER(case0536), - TEST_PARSER(case0537), - TEST_PARSER(case0538), - TEST_PARSER(case0539), - TEST_PARSER(case0540), - TEST_PARSER(case0541), - TEST_PARSER(case0542), - TEST_PARSER(case0543), - TEST_PARSER(case0544), - TEST_PARSER(case0545), - TEST_PARSER(case0546), - TEST_PARSER(case0547), - TEST_PARSER(case0548), - TEST_PARSER(case0549), - TEST_PARSER(case0550), - TEST_PARSER(case0551), - TEST_PARSER(case0552), - TEST_PARSER(case0553), - TEST_PARSER(case0554), - TEST_PARSER(case0555), - TEST_PARSER(case0556), - TEST_PARSER(case0557), - TEST_PARSER(case0558), - TEST_PARSER(case0559), - TEST_PARSER(case0560), - TEST_PARSER(case0561), - TEST_PARSER(case0562), - TEST_PARSER(case0563), - TEST_PARSER(case0564), - TEST_PARSER(case0565), - TEST_PARSER(case0566), - TEST_PARSER(case0567), - TEST_PARSER(case0568), - TEST_PARSER(case0569), - TEST_PARSER(case0570), - TEST_PARSER(case0571), - TEST_PARSER(case0572), - TEST_PARSER(case0573), - TEST_PARSER(case0574), - TEST_PARSER(case0575), - TEST_PARSER(case0576), - TEST_PARSER(case0577), - TEST_PARSER(case0578), - TEST_PARSER(case0579), - TEST_PARSER(case0580), - TEST_PARSER(case0581), - TEST_PARSER(case0582), - TEST_PARSER(case0583), - TEST_PARSER(case0584), - TEST_PARSER(case0585), - TEST_PARSER(case0586), - TEST_PARSER(case0587), - TEST_PARSER(case0588), - TEST_PARSER(case0589), - TEST_PARSER(case0590), - TEST_PARSER(case0591), - TEST_PARSER(case0592), - TEST_PARSER(case0593), - TEST_PARSER(case0594), - TEST_PARSER(case0595), - TEST_PARSER(case0596), - TEST_PARSER(case0597), - TEST_PARSER(case0598), - TEST_PARSER(case0599), + TEST_PARSER(case0500), TEST_PARSER(case0501), TEST_PARSER(case0502), + TEST_PARSER(case0503), TEST_PARSER(case0504), TEST_PARSER(case0505), + TEST_PARSER(case0506), TEST_PARSER(case0507), TEST_PARSER(case0508), + TEST_PARSER(case0509), TEST_PARSER(case0510), TEST_PARSER(case0511), + TEST_PARSER(case0512), TEST_PARSER(case0513), TEST_PARSER(case0514), + TEST_PARSER(case0515), TEST_PARSER(case0516), TEST_PARSER(case0517), + TEST_PARSER(case0518), TEST_PARSER(case0519), TEST_PARSER(case0520), + TEST_PARSER(case0521), TEST_PARSER(case0522), TEST_PARSER(case0523), + TEST_PARSER(case0524), TEST_PARSER(case0525), TEST_PARSER(case0526), + TEST_PARSER(case0527), TEST_PARSER(case0528), TEST_PARSER(case0529), + TEST_PARSER(case0530), TEST_PARSER(case0531), TEST_PARSER(case0532), + TEST_PARSER(case0533), TEST_PARSER(case0534), TEST_PARSER(case0535), + TEST_PARSER(case0536), TEST_PARSER(case0537), TEST_PARSER(case0538), + TEST_PARSER(case0539), TEST_PARSER(case0540), TEST_PARSER(case0541), + TEST_PARSER(case0542), TEST_PARSER(case0543), TEST_PARSER(case0544), + TEST_PARSER(case0545), TEST_PARSER(case0546), TEST_PARSER(case0547), + TEST_PARSER(case0548), TEST_PARSER(case0549), TEST_PARSER(case0550), + TEST_PARSER(case0551), TEST_PARSER(case0552), TEST_PARSER(case0553), + TEST_PARSER(case0554), TEST_PARSER(case0555), TEST_PARSER(case0556), + TEST_PARSER(case0557), TEST_PARSER(case0558), TEST_PARSER(case0559), + TEST_PARSER(case0560), TEST_PARSER(case0561), TEST_PARSER(case0562), + TEST_PARSER(case0563), TEST_PARSER(case0564), TEST_PARSER(case0565), + TEST_PARSER(case0566), TEST_PARSER(case0567), TEST_PARSER(case0568), + TEST_PARSER(case0569), TEST_PARSER(case0570), TEST_PARSER(case0571), + TEST_PARSER(case0572), TEST_PARSER(case0573), TEST_PARSER(case0574), + TEST_PARSER(case0575), TEST_PARSER(case0576), TEST_PARSER(case0577), + TEST_PARSER(case0578), TEST_PARSER(case0579), TEST_PARSER(case0580), + TEST_PARSER(case0581), TEST_PARSER(case0582), TEST_PARSER(case0583), + TEST_PARSER(case0584), TEST_PARSER(case0585), TEST_PARSER(case0586), + TEST_PARSER(case0587), TEST_PARSER(case0588), TEST_PARSER(case0589), + TEST_PARSER(case0590), TEST_PARSER(case0591), TEST_PARSER(case0592), + TEST_PARSER(case0593), TEST_PARSER(case0594), TEST_PARSER(case0595), + TEST_PARSER(case0596), TEST_PARSER(case0597), TEST_PARSER(case0598), + TEST_PARSER(case0599), - TEST_PARSER(case0600), - TEST_PARSER(case0601), - TEST_PARSER(case0602), - TEST_PARSER(case0603), - TEST_PARSER(case0604), - TEST_PARSER(case0605), - TEST_PARSER(case0606), - TEST_PARSER(case0607), - TEST_PARSER(case0608), - TEST_PARSER(case0609), - TEST_PARSER(case0610), - TEST_PARSER(case0611), - TEST_PARSER(case0612), - TEST_PARSER(case0613), - TEST_PARSER(case0614), - TEST_PARSER(case0615), - TEST_PARSER(case0616), - TEST_PARSER(case0617), - TEST_PARSER(case0618), - TEST_PARSER(case0619), - TEST_PARSER(case0620), - TEST_PARSER(case0621), - TEST_PARSER(case0622), - TEST_PARSER(case0623), - TEST_PARSER(case0624), - TEST_PARSER(case0625), - TEST_PARSER(case0626), - TEST_PARSER(case0627), - TEST_PARSER(case0628), - TEST_PARSER(case0629), - TEST_PARSER(case0630), - TEST_PARSER(case0631), - TEST_PARSER(case0632), - TEST_PARSER(case0633), - TEST_PARSER(case0634), - TEST_PARSER(case0635), - TEST_PARSER(case0636), - TEST_PARSER(case0637), - TEST_PARSER(case0638), - TEST_PARSER(case0639), - TEST_PARSER(case0640), - TEST_PARSER(case0641), - TEST_PARSER(case0642), - TEST_PARSER(case0643), - TEST_PARSER(case0644), - TEST_PARSER(case0645), - TEST_PARSER(case0646), - TEST_PARSER(case0647), - TEST_PARSER(case0648), - TEST_PARSER(case0649), - TEST_PARSER(case0650), - TEST_PARSER(case0651), - TEST_PARSER(case0652), - TEST_PARSER(case0653), - TEST_PARSER(case0654), - TEST_PARSER(case0655), - TEST_PARSER(case0656), - TEST_PARSER(case0657), - TEST_PARSER(case0658), - TEST_PARSER(case0659), - TEST_PARSER(case0660), - TEST_PARSER(case0661), - TEST_PARSER(case0662), - TEST_PARSER(case0663), - TEST_PARSER(case0664), - TEST_PARSER(case0665), - TEST_PARSER(case0666), - TEST_PARSER(case0667), - TEST_PARSER(case0668), - TEST_PARSER(case0669), - TEST_PARSER(case0670), - TEST_PARSER(case0671), - TEST_PARSER(case0672), - TEST_PARSER(case0673), - TEST_PARSER(case0674), - TEST_PARSER(case0675), - TEST_PARSER(case0676), - TEST_PARSER(case0677), - TEST_PARSER(case0678), - TEST_PARSER(case0679), - TEST_PARSER(case0680), - TEST_PARSER(case0681), - TEST_PARSER(case0682), - TEST_PARSER(case0683), - TEST_PARSER(case0684), - TEST_PARSER(case0685), - TEST_PARSER(case0686), - TEST_PARSER(case0687), - TEST_PARSER(case0688), - TEST_PARSER(case0689), - TEST_PARSER(case0690), - TEST_PARSER(case0691), - TEST_PARSER(case0692), - TEST_PARSER(case0693), - TEST_PARSER(case0694), - TEST_PARSER(case0695), - TEST_PARSER(case0696), - TEST_PARSER(case0697), - TEST_PARSER(case0698), - TEST_PARSER(case0699), + TEST_PARSER(case0600), TEST_PARSER(case0601), TEST_PARSER(case0602), + TEST_PARSER(case0603), TEST_PARSER(case0604), TEST_PARSER(case0605), + TEST_PARSER(case0606), TEST_PARSER(case0607), TEST_PARSER(case0608), + TEST_PARSER(case0609), TEST_PARSER(case0610), TEST_PARSER(case0611), + TEST_PARSER(case0612), TEST_PARSER(case0613), TEST_PARSER(case0614), + TEST_PARSER(case0615), TEST_PARSER(case0616), TEST_PARSER(case0617), + TEST_PARSER(case0618), TEST_PARSER(case0619), TEST_PARSER(case0620), + TEST_PARSER(case0621), TEST_PARSER(case0622), TEST_PARSER(case0623), + TEST_PARSER(case0624), TEST_PARSER(case0625), TEST_PARSER(case0626), + TEST_PARSER(case0627), TEST_PARSER(case0628), TEST_PARSER(case0629), + TEST_PARSER(case0630), TEST_PARSER(case0631), TEST_PARSER(case0632), + TEST_PARSER(case0633), TEST_PARSER(case0634), TEST_PARSER(case0635), + TEST_PARSER(case0636), TEST_PARSER(case0637), TEST_PARSER(case0638), + TEST_PARSER(case0639), TEST_PARSER(case0640), TEST_PARSER(case0641), + TEST_PARSER(case0642), TEST_PARSER(case0643), TEST_PARSER(case0644), + TEST_PARSER(case0645), TEST_PARSER(case0646), TEST_PARSER(case0647), + TEST_PARSER(case0648), TEST_PARSER(case0649), TEST_PARSER(case0650), + TEST_PARSER(case0651), TEST_PARSER(case0652), TEST_PARSER(case0653), + TEST_PARSER(case0654), TEST_PARSER(case0655), TEST_PARSER(case0656), + TEST_PARSER(case0657), TEST_PARSER(case0658), TEST_PARSER(case0659), + TEST_PARSER(case0660), TEST_PARSER(case0661), TEST_PARSER(case0662), + TEST_PARSER(case0663), TEST_PARSER(case0664), TEST_PARSER(case0665), + TEST_PARSER(case0666), TEST_PARSER(case0667), TEST_PARSER(case0668), + TEST_PARSER(case0669), TEST_PARSER(case0670), TEST_PARSER(case0671), + TEST_PARSER(case0672), TEST_PARSER(case0673), TEST_PARSER(case0674), + TEST_PARSER(case0675), TEST_PARSER(case0676), TEST_PARSER(case0677), + TEST_PARSER(case0678), TEST_PARSER(case0679), TEST_PARSER(case0680), + TEST_PARSER(case0681), TEST_PARSER(case0682), TEST_PARSER(case0683), + TEST_PARSER(case0684), TEST_PARSER(case0685), TEST_PARSER(case0686), + TEST_PARSER(case0687), TEST_PARSER(case0688), TEST_PARSER(case0689), + TEST_PARSER(case0690), TEST_PARSER(case0691), TEST_PARSER(case0692), + TEST_PARSER(case0693), TEST_PARSER(case0694), TEST_PARSER(case0695), + TEST_PARSER(case0696), TEST_PARSER(case0697), TEST_PARSER(case0698), + TEST_PARSER(case0699), - TEST_PARSER(case0700), - TEST_PARSER(case0701), - TEST_PARSER(case0702), - TEST_PARSER(case0703), - TEST_PARSER(case0704), - TEST_PARSER(case0705), - TEST_PARSER(case0706), - TEST_PARSER(case0707), - TEST_PARSER(case0708), - TEST_PARSER(case0709), - TEST_PARSER(case0710), - TEST_PARSER(case0711), - TEST_PARSER(case0712), - TEST_PARSER(case0713), - TEST_PARSER(case0714), - TEST_PARSER(case0715), - TEST_PARSER(case0716), - TEST_PARSER(case0717), - TEST_PARSER(case0718), - TEST_PARSER(case0719), - TEST_PARSER(case0720), - TEST_PARSER(case0721), - TEST_PARSER(case0722), - TEST_PARSER(case0723), - TEST_PARSER(case0724), - TEST_PARSER(case0725), - TEST_PARSER(case0726), - TEST_PARSER(case0727), - TEST_PARSER(case0728), - TEST_PARSER(case0729), - TEST_PARSER(case0730), - TEST_PARSER(case0731), - TEST_PARSER(case0732), - TEST_PARSER(case0733), - TEST_PARSER(case0734), - TEST_PARSER(case0735), - TEST_PARSER(case0736), - TEST_PARSER(case0737), - TEST_PARSER(case0738), - TEST_PARSER(case0739), - TEST_PARSER(case0740), - TEST_PARSER(case0741), - TEST_PARSER(case0742), - TEST_PARSER(case0743), - TEST_PARSER(case0744), - TEST_PARSER(case0745), - TEST_PARSER(case0746), - TEST_PARSER(case0747), - TEST_PARSER(case0748), - TEST_PARSER(case0749), - TEST_PARSER(case0750), - TEST_PARSER(case0751), - TEST_PARSER(case0752), - TEST_PARSER(case0753), - TEST_PARSER(case0754), - TEST_PARSER(case0755), - TEST_PARSER(case0756), - TEST_PARSER(case0757), - TEST_PARSER(case0758), - TEST_PARSER(case0759), - TEST_PARSER(case0760), - TEST_PARSER(case0761), - TEST_PARSER(case0762), - TEST_PARSER(case0763), - TEST_PARSER(case0764), - TEST_PARSER(case0765), - TEST_PARSER(case0766), - TEST_PARSER(case0767), - TEST_PARSER(case0768), - TEST_PARSER(case0769), - TEST_PARSER(case0770), - TEST_PARSER(case0771), - TEST_PARSER(case0772), - TEST_PARSER(case0773), - TEST_PARSER(case0774), - TEST_PARSER(case0775), - TEST_PARSER(case0776), - TEST_PARSER(case0777), - TEST_PARSER(case0778), - TEST_PARSER(case0779), - TEST_PARSER(case0780), - TEST_PARSER(case0781), - TEST_PARSER(case0782), - TEST_PARSER(case0783), - TEST_PARSER(case0784), - TEST_PARSER(case0785), - TEST_PARSER(case0786), - TEST_PARSER(case0787), - TEST_PARSER(case0788), - TEST_PARSER(case0789), - TEST_PARSER(case0790), - TEST_PARSER(case0791), - TEST_PARSER(case0792), - TEST_PARSER(case0793), - TEST_PARSER(case0794), - TEST_PARSER(case0795), - TEST_PARSER(case0796), - TEST_PARSER(case0797), - TEST_PARSER(case0798), - TEST_PARSER(case0799), + TEST_PARSER(case0700), TEST_PARSER(case0701), TEST_PARSER(case0702), + TEST_PARSER(case0703), TEST_PARSER(case0704), TEST_PARSER(case0705), + TEST_PARSER(case0706), TEST_PARSER(case0707), TEST_PARSER(case0708), + TEST_PARSER(case0709), TEST_PARSER(case0710), TEST_PARSER(case0711), + TEST_PARSER(case0712), TEST_PARSER(case0713), TEST_PARSER(case0714), + TEST_PARSER(case0715), TEST_PARSER(case0716), TEST_PARSER(case0717), + TEST_PARSER(case0718), TEST_PARSER(case0719), TEST_PARSER(case0720), + TEST_PARSER(case0721), TEST_PARSER(case0722), TEST_PARSER(case0723), + TEST_PARSER(case0724), TEST_PARSER(case0725), TEST_PARSER(case0726), + TEST_PARSER(case0727), TEST_PARSER(case0728), TEST_PARSER(case0729), + TEST_PARSER(case0730), TEST_PARSER(case0731), TEST_PARSER(case0732), + TEST_PARSER(case0733), TEST_PARSER(case0734), TEST_PARSER(case0735), + TEST_PARSER(case0736), TEST_PARSER(case0737), TEST_PARSER(case0738), + TEST_PARSER(case0739), TEST_PARSER(case0740), TEST_PARSER(case0741), + TEST_PARSER(case0742), TEST_PARSER(case0743), TEST_PARSER(case0744), + TEST_PARSER(case0745), TEST_PARSER(case0746), TEST_PARSER(case0747), + TEST_PARSER(case0748), TEST_PARSER(case0749), TEST_PARSER(case0750), + TEST_PARSER(case0751), TEST_PARSER(case0752), TEST_PARSER(case0753), + TEST_PARSER(case0754), TEST_PARSER(case0755), TEST_PARSER(case0756), + TEST_PARSER(case0757), TEST_PARSER(case0758), TEST_PARSER(case0759), + TEST_PARSER(case0760), TEST_PARSER(case0761), TEST_PARSER(case0762), + TEST_PARSER(case0763), TEST_PARSER(case0764), TEST_PARSER(case0765), + TEST_PARSER(case0766), TEST_PARSER(case0767), TEST_PARSER(case0768), + TEST_PARSER(case0769), TEST_PARSER(case0770), TEST_PARSER(case0771), + TEST_PARSER(case0772), TEST_PARSER(case0773), TEST_PARSER(case0774), + TEST_PARSER(case0775), TEST_PARSER(case0776), TEST_PARSER(case0777), + TEST_PARSER(case0778), TEST_PARSER(case0779), TEST_PARSER(case0780), + TEST_PARSER(case0781), TEST_PARSER(case0782), TEST_PARSER(case0783), + TEST_PARSER(case0784), TEST_PARSER(case0785), TEST_PARSER(case0786), + TEST_PARSER(case0787), TEST_PARSER(case0788), TEST_PARSER(case0789), + TEST_PARSER(case0790), TEST_PARSER(case0791), TEST_PARSER(case0792), + TEST_PARSER(case0793), TEST_PARSER(case0794), TEST_PARSER(case0795), + TEST_PARSER(case0796), TEST_PARSER(case0797), TEST_PARSER(case0798), + TEST_PARSER(case0799), - TEST_PARSER(case0800), - TEST_PARSER(case0801), - TEST_PARSER(case0802), - TEST_PARSER(case0803), - TEST_PARSER(case0804), - TEST_PARSER(case0805), - TEST_PARSER(case0806), - TEST_PARSER(case0807), - TEST_PARSER(case0808), - TEST_PARSER(case0809), - TEST_PARSER(case0810), - TEST_PARSER(case0811), - TEST_PARSER(case0812), - TEST_PARSER(case0813), - TEST_PARSER(case0814), - TEST_PARSER(case0815), - TEST_PARSER(case0816), - TEST_PARSER(case0817), - TEST_PARSER(case0818), - TEST_PARSER(case0819), - TEST_PARSER(case0820), - TEST_PARSER(case0821), - TEST_PARSER(case0822), - TEST_PARSER(case0823), - TEST_PARSER(case0824), - TEST_PARSER(case0825), - TEST_PARSER(case0826), - TEST_PARSER(case0827), - TEST_PARSER(case0828), - TEST_PARSER(case0829), - TEST_PARSER(case0830), - TEST_PARSER(case0831), - TEST_PARSER(case0832), - TEST_PARSER(case0833), - TEST_PARSER(case0834), - TEST_PARSER(case0835), - TEST_PARSER(case0836), - TEST_PARSER(case0837), - TEST_PARSER(case0838), - TEST_PARSER(case0839), - TEST_PARSER(case0840), - TEST_PARSER(case0841), - TEST_PARSER(case0842), - TEST_PARSER(case0843), - TEST_PARSER(case0844), - TEST_PARSER(case0845), - TEST_PARSER(case0846), - TEST_PARSER(case0847), - TEST_PARSER(case0848), - TEST_PARSER(case0849), - TEST_PARSER(case0850), - TEST_PARSER(case0851), - TEST_PARSER(case0852), - TEST_PARSER(case0853), - TEST_PARSER(case0854), - TEST_PARSER(case0855), - TEST_PARSER(case0856), - TEST_PARSER(case0857), - TEST_PARSER(case0858), - TEST_PARSER(case0859), - TEST_PARSER(case0860), - TEST_PARSER(case0861), - TEST_PARSER(case0862), - TEST_PARSER(case0863), - TEST_PARSER(case0864), - TEST_PARSER(case0865), - TEST_PARSER(case0866), - TEST_PARSER(case0867), - TEST_PARSER(case0868), - TEST_PARSER(case0869), - TEST_PARSER(case0870), - TEST_PARSER(case0871), - TEST_PARSER(case0872), - TEST_PARSER(case0873), - TEST_PARSER(case0874), - TEST_PARSER(case0875), - TEST_PARSER(case0876), - TEST_PARSER(case0877), - TEST_PARSER(case0878), - TEST_PARSER(case0879), - TEST_PARSER(case0880), - TEST_PARSER(case0881), - TEST_PARSER(case0882), - TEST_PARSER(case0883), - TEST_PARSER(case0884), - TEST_PARSER(case0885), - TEST_PARSER(case0886), - TEST_PARSER(case0887), - TEST_PARSER(case0888), - TEST_PARSER(case0889), - TEST_PARSER(case0890), - TEST_PARSER(case0891), - TEST_PARSER(case0892), - TEST_PARSER(case0893), - TEST_PARSER(case0894), - TEST_PARSER(case0895), - TEST_PARSER(case0896), - TEST_PARSER(case0897), - TEST_PARSER(case0898), - TEST_PARSER(case0899), + TEST_PARSER(case0800), TEST_PARSER(case0801), TEST_PARSER(case0802), + TEST_PARSER(case0803), TEST_PARSER(case0804), TEST_PARSER(case0805), + TEST_PARSER(case0806), TEST_PARSER(case0807), TEST_PARSER(case0808), + TEST_PARSER(case0809), TEST_PARSER(case0810), TEST_PARSER(case0811), + TEST_PARSER(case0812), TEST_PARSER(case0813), TEST_PARSER(case0814), + TEST_PARSER(case0815), TEST_PARSER(case0816), TEST_PARSER(case0817), + TEST_PARSER(case0818), TEST_PARSER(case0819), TEST_PARSER(case0820), + TEST_PARSER(case0821), TEST_PARSER(case0822), TEST_PARSER(case0823), + TEST_PARSER(case0824), TEST_PARSER(case0825), TEST_PARSER(case0826), + TEST_PARSER(case0827), TEST_PARSER(case0828), TEST_PARSER(case0829), + TEST_PARSER(case0830), TEST_PARSER(case0831), TEST_PARSER(case0832), + TEST_PARSER(case0833), TEST_PARSER(case0834), TEST_PARSER(case0835), + TEST_PARSER(case0836), TEST_PARSER(case0837), TEST_PARSER(case0838), + TEST_PARSER(case0839), TEST_PARSER(case0840), TEST_PARSER(case0841), + TEST_PARSER(case0842), TEST_PARSER(case0843), TEST_PARSER(case0844), + TEST_PARSER(case0845), TEST_PARSER(case0846), TEST_PARSER(case0847), + TEST_PARSER(case0848), TEST_PARSER(case0849), TEST_PARSER(case0850), + TEST_PARSER(case0851), TEST_PARSER(case0852), TEST_PARSER(case0853), + TEST_PARSER(case0854), TEST_PARSER(case0855), TEST_PARSER(case0856), + TEST_PARSER(case0857), TEST_PARSER(case0858), TEST_PARSER(case0859), + TEST_PARSER(case0860), TEST_PARSER(case0861), TEST_PARSER(case0862), + TEST_PARSER(case0863), TEST_PARSER(case0864), TEST_PARSER(case0865), + TEST_PARSER(case0866), TEST_PARSER(case0867), TEST_PARSER(case0868), + TEST_PARSER(case0869), TEST_PARSER(case0870), TEST_PARSER(case0871), + TEST_PARSER(case0872), TEST_PARSER(case0873), TEST_PARSER(case0874), + TEST_PARSER(case0875), TEST_PARSER(case0876), TEST_PARSER(case0877), + TEST_PARSER(case0878), TEST_PARSER(case0879), TEST_PARSER(case0880), + TEST_PARSER(case0881), TEST_PARSER(case0882), TEST_PARSER(case0883), + TEST_PARSER(case0884), TEST_PARSER(case0885), TEST_PARSER(case0886), + TEST_PARSER(case0887), TEST_PARSER(case0888), TEST_PARSER(case0889), + TEST_PARSER(case0890), TEST_PARSER(case0891), TEST_PARSER(case0892), + TEST_PARSER(case0893), TEST_PARSER(case0894), TEST_PARSER(case0895), + TEST_PARSER(case0896), TEST_PARSER(case0897), TEST_PARSER(case0898), + TEST_PARSER(case0899), - TEST_PARSER(case0900), - TEST_PARSER(case0901), - TEST_PARSER(case0902), - TEST_PARSER(case0903), - TEST_PARSER(case0904), - TEST_PARSER(case0905), - TEST_PARSER(case0906), - TEST_PARSER(case0907), - TEST_PARSER(case0908), - TEST_PARSER(case0909), - TEST_PARSER(case0910), - TEST_PARSER(case0911), - TEST_PARSER(case0912), - TEST_PARSER(case0913), - TEST_PARSER(case0914), - TEST_PARSER(case0915), - TEST_PARSER(case0916), - TEST_PARSER(case0917), - TEST_PARSER(case0918), - TEST_PARSER(case0919), - TEST_PARSER(case0920), - TEST_PARSER(case0921), - TEST_PARSER(case0922), - TEST_PARSER(case0923), - TEST_PARSER(case0924), - TEST_PARSER(case0925), - TEST_PARSER(case0926), - TEST_PARSER(case0927), - TEST_PARSER(case0928), - TEST_PARSER(case0929), - TEST_PARSER(case0930), - TEST_PARSER(case0931), - TEST_PARSER(case0932), - TEST_PARSER(case0933), - TEST_PARSER(case0934), - TEST_PARSER(case0935), - TEST_PARSER(case0936), - TEST_PARSER(case0937), - TEST_PARSER(case0938), - TEST_PARSER(case0939), - TEST_PARSER(case0940), - TEST_PARSER(case0941), - TEST_PARSER(case0942), - TEST_PARSER(case0943), - TEST_PARSER(case0944), - TEST_PARSER(case0945), - TEST_PARSER(case0946), - TEST_PARSER(case0947), - TEST_PARSER(case0948), - TEST_PARSER(case0949), - TEST_PARSER(case0950), - TEST_PARSER(case0951), - TEST_PARSER(case0952), - TEST_PARSER(case0953), - TEST_PARSER(case0954), - TEST_PARSER(case0955), - TEST_PARSER(case0956), - TEST_PARSER(case0957), - TEST_PARSER(case0958), - TEST_PARSER(case0959), - TEST_PARSER(case0960), - TEST_PARSER(case0961), - TEST_PARSER(case0962), - TEST_PARSER(case0963), - TEST_PARSER(case0964), - TEST_PARSER(case0965), - TEST_PARSER(case0966), - TEST_PARSER(case0967), - TEST_PARSER(case0968), - TEST_PARSER(case0969), - TEST_PARSER(case0970), - TEST_PARSER(case0971), - TEST_PARSER(case0972), - TEST_PARSER(case0973), - TEST_PARSER(case0974), - TEST_PARSER(case0975), - TEST_PARSER(case0976), - TEST_PARSER(case0977), - TEST_PARSER(case0978), - TEST_PARSER(case0979), - TEST_PARSER(case0980), - TEST_PARSER(case0981), - TEST_PARSER(case0982), - TEST_PARSER(case0983), - TEST_PARSER(case0984), - TEST_PARSER(case0985), - TEST_PARSER(case0986), - TEST_PARSER(case0987), - TEST_PARSER(case0988), - TEST_PARSER(case0989), - TEST_PARSER(case0990), - TEST_PARSER(case0991), - TEST_PARSER(case0992), - TEST_PARSER(case0993), - TEST_PARSER(case0994), - TEST_PARSER(case0995), - TEST_PARSER(case0996), - TEST_PARSER(case0997), - TEST_PARSER(case0998), - TEST_PARSER(case0999), + TEST_PARSER(case0900), TEST_PARSER(case0901), TEST_PARSER(case0902), + TEST_PARSER(case0903), TEST_PARSER(case0904), TEST_PARSER(case0905), + TEST_PARSER(case0906), TEST_PARSER(case0907), TEST_PARSER(case0908), + TEST_PARSER(case0909), TEST_PARSER(case0910), TEST_PARSER(case0911), + TEST_PARSER(case0912), TEST_PARSER(case0913), TEST_PARSER(case0914), + TEST_PARSER(case0915), TEST_PARSER(case0916), TEST_PARSER(case0917), + TEST_PARSER(case0918), TEST_PARSER(case0919), TEST_PARSER(case0920), + TEST_PARSER(case0921), TEST_PARSER(case0922), TEST_PARSER(case0923), + TEST_PARSER(case0924), TEST_PARSER(case0925), TEST_PARSER(case0926), + TEST_PARSER(case0927), TEST_PARSER(case0928), TEST_PARSER(case0929), + TEST_PARSER(case0930), TEST_PARSER(case0931), TEST_PARSER(case0932), + TEST_PARSER(case0933), TEST_PARSER(case0934), TEST_PARSER(case0935), + TEST_PARSER(case0936), TEST_PARSER(case0937), TEST_PARSER(case0938), + TEST_PARSER(case0939), TEST_PARSER(case0940), TEST_PARSER(case0941), + TEST_PARSER(case0942), TEST_PARSER(case0943), TEST_PARSER(case0944), + TEST_PARSER(case0945), TEST_PARSER(case0946), TEST_PARSER(case0947), + TEST_PARSER(case0948), TEST_PARSER(case0949), TEST_PARSER(case0950), + TEST_PARSER(case0951), TEST_PARSER(case0952), TEST_PARSER(case0953), + TEST_PARSER(case0954), TEST_PARSER(case0955), TEST_PARSER(case0956), + TEST_PARSER(case0957), TEST_PARSER(case0958), TEST_PARSER(case0959), + TEST_PARSER(case0960), TEST_PARSER(case0961), TEST_PARSER(case0962), + TEST_PARSER(case0963), TEST_PARSER(case0964), TEST_PARSER(case0965), + TEST_PARSER(case0966), TEST_PARSER(case0967), TEST_PARSER(case0968), + TEST_PARSER(case0969), TEST_PARSER(case0970), TEST_PARSER(case0971), + TEST_PARSER(case0972), TEST_PARSER(case0973), TEST_PARSER(case0974), + TEST_PARSER(case0975), TEST_PARSER(case0976), TEST_PARSER(case0977), + TEST_PARSER(case0978), TEST_PARSER(case0979), TEST_PARSER(case0980), + TEST_PARSER(case0981), TEST_PARSER(case0982), TEST_PARSER(case0983), + TEST_PARSER(case0984), TEST_PARSER(case0985), TEST_PARSER(case0986), + TEST_PARSER(case0987), TEST_PARSER(case0988), TEST_PARSER(case0989), + TEST_PARSER(case0990), TEST_PARSER(case0991), TEST_PARSER(case0992), + TEST_PARSER(case0993), TEST_PARSER(case0994), TEST_PARSER(case0995), + TEST_PARSER(case0996), TEST_PARSER(case0997), TEST_PARSER(case0998), + TEST_PARSER(case0999), - TEST_PARSER(case1000), - TEST_PARSER(case1001), - TEST_PARSER(case1002), - TEST_PARSER(case1003), - TEST_PARSER(case1004), - TEST_PARSER(case1005), - TEST_PARSER(case1006), - TEST_PARSER(case1007), - TEST_PARSER(case1008), - TEST_PARSER(case1009), - TEST_PARSER(case1010), - TEST_PARSER(case1011), - TEST_PARSER(case1012), - TEST_PARSER(case1013), - TEST_PARSER(case1014), - TEST_PARSER(case1015), - TEST_PARSER(case1016), - TEST_PARSER(case1017), - TEST_PARSER(case1018), - TEST_PARSER(case1019), - TEST_PARSER(case1020), - TEST_PARSER(case1021), - TEST_PARSER(case1022), - TEST_PARSER(case1023), - TEST_PARSER(case1024), - TEST_PARSER(case1025), - TEST_PARSER(case1026), - TEST_PARSER(case1027), - TEST_PARSER(case1028), - TEST_PARSER(case1029), - TEST_PARSER(case1030), - TEST_PARSER(case1031), - TEST_PARSER(case1032), - TEST_PARSER(case1033), - TEST_PARSER(case1034), - TEST_PARSER(case1035), - TEST_PARSER(case1036), - TEST_PARSER(case1037), - TEST_PARSER(case1038), - TEST_PARSER(case1039), - TEST_PARSER(case1040), - TEST_PARSER(case1041), - TEST_PARSER(case1042), - TEST_PARSER(case1043), - TEST_PARSER(case1044), - TEST_PARSER(case1045), - TEST_PARSER(case1046), - TEST_PARSER(case1047), - TEST_PARSER(case1048), - TEST_PARSER(case1049), - TEST_PARSER(case1050), - TEST_PARSER(case1051), - TEST_PARSER(case1052), - TEST_PARSER(case1053), - TEST_PARSER(case1054), - TEST_PARSER(case1055), - TEST_PARSER(case1056), - TEST_PARSER(case1057), - TEST_PARSER(case1058), - TEST_PARSER(case1059), - TEST_PARSER(case1060), - TEST_PARSER(case1061), - TEST_PARSER(case1062), - TEST_PARSER(case1063), - TEST_PARSER(case1064), - TEST_PARSER(case1065), - TEST_PARSER(case1066), - TEST_PARSER(case1067), - TEST_PARSER(case1068), - TEST_PARSER(case1069), - TEST_PARSER(case1070), - TEST_PARSER(case1071), - TEST_PARSER(case1072), - TEST_PARSER(case1073), - TEST_PARSER(case1074), - TEST_PARSER(case1075), - TEST_PARSER(case1076), - TEST_PARSER(case1077), - TEST_PARSER(case1078), - TEST_PARSER(case1079), - TEST_PARSER(case1080), - TEST_PARSER(case1081), - TEST_PARSER(case1082), - TEST_PARSER(case1083), - TEST_PARSER(case1084), - TEST_PARSER(case1085), - TEST_PARSER(case1086), - TEST_PARSER(case1087), - TEST_PARSER(case1088), - TEST_PARSER(case1089), - TEST_PARSER(case1090), - TEST_PARSER(case1091), - TEST_PARSER(case1092), - TEST_PARSER(case1093), - TEST_PARSER(case1094), - TEST_PARSER(case1095), - TEST_PARSER(case1096), - TEST_PARSER(case1097), - TEST_PARSER(case1098), - TEST_PARSER(case1099), + TEST_PARSER(case1000), TEST_PARSER(case1001), TEST_PARSER(case1002), + TEST_PARSER(case1003), TEST_PARSER(case1004), TEST_PARSER(case1005), + TEST_PARSER(case1006), TEST_PARSER(case1007), TEST_PARSER(case1008), + TEST_PARSER(case1009), TEST_PARSER(case1010), TEST_PARSER(case1011), + TEST_PARSER(case1012), TEST_PARSER(case1013), TEST_PARSER(case1014), + TEST_PARSER(case1015), TEST_PARSER(case1016), TEST_PARSER(case1017), + TEST_PARSER(case1018), TEST_PARSER(case1019), TEST_PARSER(case1020), + TEST_PARSER(case1021), TEST_PARSER(case1022), TEST_PARSER(case1023), + TEST_PARSER(case1024), TEST_PARSER(case1025), TEST_PARSER(case1026), + TEST_PARSER(case1027), TEST_PARSER(case1028), TEST_PARSER(case1029), + TEST_PARSER(case1030), TEST_PARSER(case1031), TEST_PARSER(case1032), + TEST_PARSER(case1033), TEST_PARSER(case1034), TEST_PARSER(case1035), + TEST_PARSER(case1036), TEST_PARSER(case1037), TEST_PARSER(case1038), + TEST_PARSER(case1039), TEST_PARSER(case1040), TEST_PARSER(case1041), + TEST_PARSER(case1042), TEST_PARSER(case1043), TEST_PARSER(case1044), + TEST_PARSER(case1045), TEST_PARSER(case1046), TEST_PARSER(case1047), + TEST_PARSER(case1048), TEST_PARSER(case1049), TEST_PARSER(case1050), + TEST_PARSER(case1051), TEST_PARSER(case1052), TEST_PARSER(case1053), + TEST_PARSER(case1054), TEST_PARSER(case1055), TEST_PARSER(case1056), + TEST_PARSER(case1057), TEST_PARSER(case1058), TEST_PARSER(case1059), + TEST_PARSER(case1060), TEST_PARSER(case1061), TEST_PARSER(case1062), + TEST_PARSER(case1063), TEST_PARSER(case1064), TEST_PARSER(case1065), + TEST_PARSER(case1066), TEST_PARSER(case1067), TEST_PARSER(case1068), + TEST_PARSER(case1069), TEST_PARSER(case1070), TEST_PARSER(case1071), + TEST_PARSER(case1072), TEST_PARSER(case1073), TEST_PARSER(case1074), + TEST_PARSER(case1075), TEST_PARSER(case1076), TEST_PARSER(case1077), + TEST_PARSER(case1078), TEST_PARSER(case1079), TEST_PARSER(case1080), + TEST_PARSER(case1081), TEST_PARSER(case1082), TEST_PARSER(case1083), + TEST_PARSER(case1084), TEST_PARSER(case1085), TEST_PARSER(case1086), + TEST_PARSER(case1087), TEST_PARSER(case1088), TEST_PARSER(case1089), + TEST_PARSER(case1090), TEST_PARSER(case1091), TEST_PARSER(case1092), + TEST_PARSER(case1093), TEST_PARSER(case1094), TEST_PARSER(case1095), + TEST_PARSER(case1096), TEST_PARSER(case1097), TEST_PARSER(case1098), + TEST_PARSER(case1099), - TEST_PARSER(case1100), - TEST_PARSER(case1101), - TEST_PARSER(case1102), - TEST_PARSER(case1103), - TEST_PARSER(case1104), - TEST_PARSER(case1105), - TEST_PARSER(case1106), - TEST_PARSER(case1107), - TEST_PARSER(case1108), - TEST_PARSER(case1109), - TEST_PARSER(case1110), - TEST_PARSER(case1111), - TEST_PARSER(case1112), - TEST_PARSER(case1113), - TEST_PARSER(case1114), - TEST_PARSER(case1115), - TEST_PARSER(case1116), - TEST_PARSER(case1117), - TEST_PARSER(case1118), - TEST_PARSER(case1119), - TEST_PARSER(case1120), - TEST_PARSER(case1121), - TEST_PARSER(case1122), - TEST_PARSER(case1123), - TEST_PARSER(case1124), - TEST_PARSER(case1125), - TEST_PARSER(case1126), - TEST_PARSER(case1127), - TEST_PARSER(case1128), - TEST_PARSER(case1129), - TEST_PARSER(case1130), - TEST_PARSER(case1131), - TEST_PARSER(case1132), - TEST_PARSER(case1133), - TEST_PARSER(case1134), - TEST_PARSER(case1135), - TEST_PARSER(case1136), - TEST_PARSER(case1137), - TEST_PARSER(case1138), - TEST_PARSER(case1139), - TEST_PARSER(case1140), - TEST_PARSER(case1141), - TEST_PARSER(case1142), - TEST_PARSER(case1143), - TEST_PARSER(case1144), - TEST_PARSER(case1145), - TEST_PARSER(case1146), - TEST_PARSER(case1147), - TEST_PARSER(case1148), - TEST_PARSER(case1149), - TEST_PARSER(case1150), - TEST_PARSER(case1151), - TEST_PARSER(case1152), - TEST_PARSER(case1153), - TEST_PARSER(case1154), - TEST_PARSER(case1155), - TEST_PARSER(case1156), - TEST_PARSER(case1157), - TEST_PARSER(case1158), - TEST_PARSER(case1159), - TEST_PARSER(case1160), - TEST_PARSER(case1161), - TEST_PARSER(case1162), - TEST_PARSER(case1163), - TEST_PARSER(case1164), - TEST_PARSER(case1165), - TEST_PARSER(case1166), - TEST_PARSER(case1167), - TEST_PARSER(case1168), - TEST_PARSER(case1169), - TEST_PARSER(case1170), - TEST_PARSER(case1171), - TEST_PARSER(case1172), - TEST_PARSER(case1173), - TEST_PARSER(case1174), - TEST_PARSER(case1175), - TEST_PARSER(case1176), - TEST_PARSER(case1177), - TEST_PARSER(case1178), - TEST_PARSER(case1179), - TEST_PARSER(case1180), - TEST_PARSER(case1181), - TEST_PARSER(case1182), - TEST_PARSER(case1183), - TEST_PARSER(case1184), - TEST_PARSER(case1185), - TEST_PARSER(case1186), - TEST_PARSER(case1187), - TEST_PARSER(case1188), - TEST_PARSER(case1189), - TEST_PARSER(case1190), - TEST_PARSER(case1191), - TEST_PARSER(case1192), - TEST_PARSER(case1193), - TEST_PARSER(case1194), - TEST_PARSER(case1195), - TEST_PARSER(case1196), - TEST_PARSER(case1197), - TEST_PARSER(case1198), - TEST_PARSER(case1199), + TEST_PARSER(case1100), TEST_PARSER(case1101), TEST_PARSER(case1102), + TEST_PARSER(case1103), TEST_PARSER(case1104), TEST_PARSER(case1105), + TEST_PARSER(case1106), TEST_PARSER(case1107), TEST_PARSER(case1108), + TEST_PARSER(case1109), TEST_PARSER(case1110), TEST_PARSER(case1111), + TEST_PARSER(case1112), TEST_PARSER(case1113), TEST_PARSER(case1114), + TEST_PARSER(case1115), TEST_PARSER(case1116), TEST_PARSER(case1117), + TEST_PARSER(case1118), TEST_PARSER(case1119), TEST_PARSER(case1120), + TEST_PARSER(case1121), TEST_PARSER(case1122), TEST_PARSER(case1123), + TEST_PARSER(case1124), TEST_PARSER(case1125), TEST_PARSER(case1126), + TEST_PARSER(case1127), TEST_PARSER(case1128), TEST_PARSER(case1129), + TEST_PARSER(case1130), TEST_PARSER(case1131), TEST_PARSER(case1132), + TEST_PARSER(case1133), TEST_PARSER(case1134), TEST_PARSER(case1135), + TEST_PARSER(case1136), TEST_PARSER(case1137), TEST_PARSER(case1138), + TEST_PARSER(case1139), TEST_PARSER(case1140), TEST_PARSER(case1141), + TEST_PARSER(case1142), TEST_PARSER(case1143), TEST_PARSER(case1144), + TEST_PARSER(case1145), TEST_PARSER(case1146), TEST_PARSER(case1147), + TEST_PARSER(case1148), TEST_PARSER(case1149), TEST_PARSER(case1150), + TEST_PARSER(case1151), TEST_PARSER(case1152), TEST_PARSER(case1153), + TEST_PARSER(case1154), TEST_PARSER(case1155), TEST_PARSER(case1156), + TEST_PARSER(case1157), TEST_PARSER(case1158), TEST_PARSER(case1159), + TEST_PARSER(case1160), TEST_PARSER(case1161), TEST_PARSER(case1162), + TEST_PARSER(case1163), TEST_PARSER(case1164), TEST_PARSER(case1165), + TEST_PARSER(case1166), TEST_PARSER(case1167), TEST_PARSER(case1168), + TEST_PARSER(case1169), TEST_PARSER(case1170), TEST_PARSER(case1171), + TEST_PARSER(case1172), TEST_PARSER(case1173), TEST_PARSER(case1174), + TEST_PARSER(case1175), TEST_PARSER(case1176), TEST_PARSER(case1177), + TEST_PARSER(case1178), TEST_PARSER(case1179), TEST_PARSER(case1180), + TEST_PARSER(case1181), TEST_PARSER(case1182), TEST_PARSER(case1183), + TEST_PARSER(case1184), TEST_PARSER(case1185), TEST_PARSER(case1186), + TEST_PARSER(case1187), TEST_PARSER(case1188), TEST_PARSER(case1189), + TEST_PARSER(case1190), TEST_PARSER(case1191), TEST_PARSER(case1192), + TEST_PARSER(case1193), TEST_PARSER(case1194), TEST_PARSER(case1195), + TEST_PARSER(case1196), TEST_PARSER(case1197), TEST_PARSER(case1198), + TEST_PARSER(case1199), - TEST_PARSER(case1200), - TEST_PARSER(case1201), - TEST_PARSER(case1202), - TEST_PARSER(case1203), - TEST_PARSER(case1204), - TEST_PARSER(case1205), - TEST_PARSER(case1206), - TEST_PARSER(case1207), - TEST_PARSER(case1208), - TEST_PARSER(case1209), - TEST_PARSER(case1210), - TEST_PARSER(case1211), - TEST_PARSER(case1212), - TEST_PARSER(case1213), - TEST_PARSER(case1214), - TEST_PARSER(case1215), - TEST_PARSER(case1216), - TEST_PARSER(case1217), - TEST_PARSER(case1218), - TEST_PARSER(case1219), - TEST_PARSER(case1220), - TEST_PARSER(case1221), - TEST_PARSER(case1222), - TEST_PARSER(case1223), - TEST_PARSER(case1224), - TEST_PARSER(case1225), - TEST_PARSER(case1226), - TEST_PARSER(case1227), - TEST_PARSER(case1228), - TEST_PARSER(case1229), - TEST_PARSER(case1230), - TEST_PARSER(case1231), - TEST_PARSER(case1232), - TEST_PARSER(case1233), - TEST_PARSER(case1234), - TEST_PARSER(case1235), - TEST_PARSER(case1236), - TEST_PARSER(case1237), - TEST_PARSER(case1238), - TEST_PARSER(case1239), - TEST_PARSER(case1240), - TEST_PARSER(case1241), - TEST_PARSER(case1242), - TEST_PARSER(case1243), - TEST_PARSER(case1244), - TEST_PARSER(case1245), - TEST_PARSER(case1246), - TEST_PARSER(case1247), - TEST_PARSER(case1248), - TEST_PARSER(case1249), - TEST_PARSER(case1250), - TEST_PARSER(case1251), - TEST_PARSER(case1252), - TEST_PARSER(case1253), - TEST_PARSER(case1254), - TEST_PARSER(case1255), - TEST_PARSER(case1256), - TEST_PARSER(case1257), - TEST_PARSER(case1258), - TEST_PARSER(case1259), - TEST_PARSER(case1260), - TEST_PARSER(case1261), - TEST_PARSER(case1262), - TEST_PARSER(case1263), - TEST_PARSER(case1264), - TEST_PARSER(case1265), - TEST_PARSER(case1266), - TEST_PARSER(case1267), - TEST_PARSER(case1268), - TEST_PARSER(case1269), - TEST_PARSER(case1270), - TEST_PARSER(case1271), - TEST_PARSER(case1272), - TEST_PARSER(case1273), - TEST_PARSER(case1274), - TEST_PARSER(case1275), - TEST_PARSER(case1276), - TEST_PARSER(case1277), - TEST_PARSER(case1278), - TEST_PARSER(case1279), - TEST_PARSER(case1280), - TEST_PARSER(case1281), - TEST_PARSER(case1282), - TEST_PARSER(case1283), - TEST_PARSER(case1284), - TEST_PARSER(case1285), - TEST_PARSER(case1286), - TEST_PARSER(case1287), - TEST_PARSER(case1288), - TEST_PARSER(case1289), - TEST_PARSER(case1290), - TEST_PARSER(case1291), - TEST_PARSER(case1292), - TEST_PARSER(case1293), - TEST_PARSER(case1294), - TEST_PARSER(case1295), - TEST_PARSER(case1296), - TEST_PARSER(case1297), - TEST_PARSER(case1298), - TEST_PARSER(case1299), + TEST_PARSER(case1200), TEST_PARSER(case1201), TEST_PARSER(case1202), + TEST_PARSER(case1203), TEST_PARSER(case1204), TEST_PARSER(case1205), + TEST_PARSER(case1206), TEST_PARSER(case1207), TEST_PARSER(case1208), + TEST_PARSER(case1209), TEST_PARSER(case1210), TEST_PARSER(case1211), + TEST_PARSER(case1212), TEST_PARSER(case1213), TEST_PARSER(case1214), + TEST_PARSER(case1215), TEST_PARSER(case1216), TEST_PARSER(case1217), + TEST_PARSER(case1218), TEST_PARSER(case1219), TEST_PARSER(case1220), + TEST_PARSER(case1221), TEST_PARSER(case1222), TEST_PARSER(case1223), + TEST_PARSER(case1224), TEST_PARSER(case1225), TEST_PARSER(case1226), + TEST_PARSER(case1227), TEST_PARSER(case1228), TEST_PARSER(case1229), + TEST_PARSER(case1230), TEST_PARSER(case1231), TEST_PARSER(case1232), + TEST_PARSER(case1233), TEST_PARSER(case1234), TEST_PARSER(case1235), + TEST_PARSER(case1236), TEST_PARSER(case1237), TEST_PARSER(case1238), + TEST_PARSER(case1239), TEST_PARSER(case1240), TEST_PARSER(case1241), + TEST_PARSER(case1242), TEST_PARSER(case1243), TEST_PARSER(case1244), + TEST_PARSER(case1245), TEST_PARSER(case1246), TEST_PARSER(case1247), + TEST_PARSER(case1248), TEST_PARSER(case1249), TEST_PARSER(case1250), + TEST_PARSER(case1251), TEST_PARSER(case1252), TEST_PARSER(case1253), + TEST_PARSER(case1254), TEST_PARSER(case1255), TEST_PARSER(case1256), + TEST_PARSER(case1257), TEST_PARSER(case1258), TEST_PARSER(case1259), + TEST_PARSER(case1260), TEST_PARSER(case1261), TEST_PARSER(case1262), + TEST_PARSER(case1263), TEST_PARSER(case1264), TEST_PARSER(case1265), + TEST_PARSER(case1266), TEST_PARSER(case1267), TEST_PARSER(case1268), + TEST_PARSER(case1269), TEST_PARSER(case1270), TEST_PARSER(case1271), + TEST_PARSER(case1272), TEST_PARSER(case1273), TEST_PARSER(case1274), + TEST_PARSER(case1275), TEST_PARSER(case1276), TEST_PARSER(case1277), + TEST_PARSER(case1278), TEST_PARSER(case1279), TEST_PARSER(case1280), + TEST_PARSER(case1281), TEST_PARSER(case1282), TEST_PARSER(case1283), + TEST_PARSER(case1284), TEST_PARSER(case1285), TEST_PARSER(case1286), + TEST_PARSER(case1287), TEST_PARSER(case1288), TEST_PARSER(case1289), + TEST_PARSER(case1290), TEST_PARSER(case1291), TEST_PARSER(case1292), + TEST_PARSER(case1293), TEST_PARSER(case1294), TEST_PARSER(case1295), + TEST_PARSER(case1296), TEST_PARSER(case1297), TEST_PARSER(case1298), + TEST_PARSER(case1299), - TEST_PARSER(case1300), - TEST_PARSER(case1301), - TEST_PARSER(case1302), - TEST_PARSER(case1303), - TEST_PARSER(case1304), - TEST_PARSER(case1305), - TEST_PARSER(case1306), - TEST_PARSER(case1307), - TEST_PARSER(case1308), - TEST_PARSER(case1309), - TEST_PARSER(case1310), - TEST_PARSER(case1311), - TEST_PARSER(case1312), - TEST_PARSER(case1313), - TEST_PARSER(case1314), - TEST_PARSER(case1315), - TEST_PARSER(case1316), - TEST_PARSER(case1317), - TEST_PARSER(case1318), - TEST_PARSER(case1319), - TEST_PARSER(case1320), - TEST_PARSER(case1321), - TEST_PARSER(case1322), - TEST_PARSER(case1323), - TEST_PARSER(case1324), - TEST_PARSER(case1325), - TEST_PARSER(case1326), - TEST_PARSER(case1327), - TEST_PARSER(case1328), - TEST_PARSER(case1329), - TEST_PARSER(case1330), - TEST_PARSER(case1331), - TEST_PARSER(case1332), - TEST_PARSER(case1333), - TEST_PARSER(case1334), - TEST_PARSER(case1335), - TEST_PARSER(case1336), - TEST_PARSER(case1337), - TEST_PARSER(case1338), - TEST_PARSER(case1339), - TEST_PARSER(case1340), - TEST_PARSER(case1341), - TEST_PARSER(case1342), - TEST_PARSER(case1343), - TEST_PARSER(case1344), - TEST_PARSER(case1345), - TEST_PARSER(case1346), - TEST_PARSER(case1347), - TEST_PARSER(case1348), - TEST_PARSER(case1349), - TEST_PARSER(case1350), - TEST_PARSER(case1351), - TEST_PARSER(case1352), - TEST_PARSER(case1353), - TEST_PARSER(case1354), - TEST_PARSER(case1355), - TEST_PARSER(case1356), - TEST_PARSER(case1357), - TEST_PARSER(case1358), - TEST_PARSER(case1359), - TEST_PARSER(case1360), - TEST_PARSER(case1361), - TEST_PARSER(case1362), - TEST_PARSER(case1363), - TEST_PARSER(case1364), - TEST_PARSER(case1365), - TEST_PARSER(case1366), - TEST_PARSER(case1367), - TEST_PARSER(case1368), - TEST_PARSER(case1369), - TEST_PARSER(case1370), - TEST_PARSER(case1371), - TEST_PARSER(case1372), - TEST_PARSER(case1373), - TEST_PARSER(case1374), - TEST_PARSER(case1375), - TEST_PARSER(case1376), - TEST_PARSER(case1377), - TEST_PARSER(case1378), - TEST_PARSER(case1379), - TEST_PARSER(case1380), - TEST_PARSER(case1381), - TEST_PARSER(case1382), - TEST_PARSER(case1383), - TEST_PARSER(case1384), - TEST_PARSER(case1385), - TEST_PARSER(case1386), - TEST_PARSER(case1387), - TEST_PARSER(case1388), - TEST_PARSER(case1389), - TEST_PARSER(case1390), - TEST_PARSER(case1391), - TEST_PARSER(case1392), - TEST_PARSER(case1393), - TEST_PARSER(case1394), - TEST_PARSER(case1395), - TEST_PARSER(case1396), - TEST_PARSER(case1397), - TEST_PARSER(case1398), - TEST_PARSER(case1399), + TEST_PARSER(case1300), TEST_PARSER(case1301), TEST_PARSER(case1302), + TEST_PARSER(case1303), TEST_PARSER(case1304), TEST_PARSER(case1305), + TEST_PARSER(case1306), TEST_PARSER(case1307), TEST_PARSER(case1308), + TEST_PARSER(case1309), TEST_PARSER(case1310), TEST_PARSER(case1311), + TEST_PARSER(case1312), TEST_PARSER(case1313), TEST_PARSER(case1314), + TEST_PARSER(case1315), TEST_PARSER(case1316), TEST_PARSER(case1317), + TEST_PARSER(case1318), TEST_PARSER(case1319), TEST_PARSER(case1320), + TEST_PARSER(case1321), TEST_PARSER(case1322), TEST_PARSER(case1323), + TEST_PARSER(case1324), TEST_PARSER(case1325), TEST_PARSER(case1326), + TEST_PARSER(case1327), TEST_PARSER(case1328), TEST_PARSER(case1329), + TEST_PARSER(case1330), TEST_PARSER(case1331), TEST_PARSER(case1332), + TEST_PARSER(case1333), TEST_PARSER(case1334), TEST_PARSER(case1335), + TEST_PARSER(case1336), TEST_PARSER(case1337), TEST_PARSER(case1338), + TEST_PARSER(case1339), TEST_PARSER(case1340), TEST_PARSER(case1341), + TEST_PARSER(case1342), TEST_PARSER(case1343), TEST_PARSER(case1344), + TEST_PARSER(case1345), TEST_PARSER(case1346), TEST_PARSER(case1347), + TEST_PARSER(case1348), TEST_PARSER(case1349), TEST_PARSER(case1350), + TEST_PARSER(case1351), TEST_PARSER(case1352), TEST_PARSER(case1353), + TEST_PARSER(case1354), TEST_PARSER(case1355), TEST_PARSER(case1356), + TEST_PARSER(case1357), TEST_PARSER(case1358), TEST_PARSER(case1359), + TEST_PARSER(case1360), TEST_PARSER(case1361), TEST_PARSER(case1362), + TEST_PARSER(case1363), TEST_PARSER(case1364), TEST_PARSER(case1365), + TEST_PARSER(case1366), TEST_PARSER(case1367), TEST_PARSER(case1368), + TEST_PARSER(case1369), TEST_PARSER(case1370), TEST_PARSER(case1371), + TEST_PARSER(case1372), TEST_PARSER(case1373), TEST_PARSER(case1374), + TEST_PARSER(case1375), TEST_PARSER(case1376), TEST_PARSER(case1377), + TEST_PARSER(case1378), TEST_PARSER(case1379), TEST_PARSER(case1380), + TEST_PARSER(case1381), TEST_PARSER(case1382), TEST_PARSER(case1383), + TEST_PARSER(case1384), TEST_PARSER(case1385), TEST_PARSER(case1386), + TEST_PARSER(case1387), TEST_PARSER(case1388), TEST_PARSER(case1389), + TEST_PARSER(case1390), TEST_PARSER(case1391), TEST_PARSER(case1392), + TEST_PARSER(case1393), TEST_PARSER(case1394), TEST_PARSER(case1395), + TEST_PARSER(case1396), TEST_PARSER(case1397), TEST_PARSER(case1398), + TEST_PARSER(case1399), - TEST_PARSER(case1400), - TEST_PARSER(case1401), - TEST_PARSER(case1402), - TEST_PARSER(case1403), - TEST_PARSER(case1404), - TEST_PARSER(case1405), - TEST_PARSER(case1406), - TEST_PARSER(case1407), - TEST_PARSER(case1408), - TEST_PARSER(case1409), - TEST_PARSER(case1410), - TEST_PARSER(case1411), - TEST_PARSER(case1412), - TEST_PARSER(case1413), - TEST_PARSER(case1414), - TEST_PARSER(case1415), - TEST_PARSER(case1416), - TEST_PARSER(case1417), - TEST_PARSER(case1418), - TEST_PARSER(case1419), - TEST_PARSER(case1420), - TEST_PARSER(case1421), - TEST_PARSER(case1422), - TEST_PARSER(case1423), - TEST_PARSER(case1424), - TEST_PARSER(case1425), - TEST_PARSER(case1426), - TEST_PARSER(case1427), - TEST_PARSER(case1428), - TEST_PARSER(case1429), - TEST_PARSER(case1430), - TEST_PARSER(case1431), - TEST_PARSER(case1432), - TEST_PARSER(case1433), - TEST_PARSER(case1434), - TEST_PARSER(case1435), - TEST_PARSER(case1436), - TEST_PARSER(case1437), - TEST_PARSER(case1438), - TEST_PARSER(case1439), - TEST_PARSER(case1440), - TEST_PARSER(case1441), - TEST_PARSER(case1442), - TEST_PARSER(case1443), - TEST_PARSER(case1444), - TEST_PARSER(case1445), - TEST_PARSER(case1446), - TEST_PARSER(case1447), - TEST_PARSER(case1448), - TEST_PARSER(case1449), - TEST_PARSER(case1450), - TEST_PARSER(case1451), - TEST_PARSER(case1452), - TEST_PARSER(case1453), - TEST_PARSER(case1454), - TEST_PARSER(case1455), - TEST_PARSER(case1456), - TEST_PARSER(case1457), - TEST_PARSER(case1458), - TEST_PARSER(case1459), - TEST_PARSER(case1460), - TEST_PARSER(case1461), - TEST_PARSER(case1462), - TEST_PARSER(case1463), - TEST_PARSER(case1464), - TEST_PARSER(case1465), - TEST_PARSER(case1466), - TEST_PARSER(case1467), - TEST_PARSER(case1468), - TEST_PARSER(case1469), - TEST_PARSER(case1470), - TEST_PARSER(case1471), - TEST_PARSER(case1472), - TEST_PARSER(case1473), - TEST_PARSER(case1474), - TEST_PARSER(case1475), - TEST_PARSER(case1476), - TEST_PARSER(case1477), - TEST_PARSER(case1478), - TEST_PARSER(case1479), - TEST_PARSER(case1480), - TEST_PARSER(case1481), - TEST_PARSER(case1482), - TEST_PARSER(case1483), - TEST_PARSER(case1484), - TEST_PARSER(case1485), - TEST_PARSER(case1486), - TEST_PARSER(case1487), - TEST_PARSER(case1488), - TEST_PARSER(case1489), - TEST_PARSER(case1490), - TEST_PARSER(case1491), - TEST_PARSER(case1492), - TEST_PARSER(case1493), - TEST_PARSER(case1494), - TEST_PARSER(case1495), - TEST_PARSER(case1496), - TEST_PARSER(case1497), - TEST_PARSER(case1498), - TEST_PARSER(case1499), + TEST_PARSER(case1400), TEST_PARSER(case1401), TEST_PARSER(case1402), + TEST_PARSER(case1403), TEST_PARSER(case1404), TEST_PARSER(case1405), + TEST_PARSER(case1406), TEST_PARSER(case1407), TEST_PARSER(case1408), + TEST_PARSER(case1409), TEST_PARSER(case1410), TEST_PARSER(case1411), + TEST_PARSER(case1412), TEST_PARSER(case1413), TEST_PARSER(case1414), + TEST_PARSER(case1415), TEST_PARSER(case1416), TEST_PARSER(case1417), + TEST_PARSER(case1418), TEST_PARSER(case1419), TEST_PARSER(case1420), + TEST_PARSER(case1421), TEST_PARSER(case1422), TEST_PARSER(case1423), + TEST_PARSER(case1424), TEST_PARSER(case1425), TEST_PARSER(case1426), + TEST_PARSER(case1427), TEST_PARSER(case1428), TEST_PARSER(case1429), + TEST_PARSER(case1430), TEST_PARSER(case1431), TEST_PARSER(case1432), + TEST_PARSER(case1433), TEST_PARSER(case1434), TEST_PARSER(case1435), + TEST_PARSER(case1436), TEST_PARSER(case1437), TEST_PARSER(case1438), + TEST_PARSER(case1439), TEST_PARSER(case1440), TEST_PARSER(case1441), + TEST_PARSER(case1442), TEST_PARSER(case1443), TEST_PARSER(case1444), + TEST_PARSER(case1445), TEST_PARSER(case1446), TEST_PARSER(case1447), + TEST_PARSER(case1448), TEST_PARSER(case1449), TEST_PARSER(case1450), + TEST_PARSER(case1451), TEST_PARSER(case1452), TEST_PARSER(case1453), + TEST_PARSER(case1454), TEST_PARSER(case1455), TEST_PARSER(case1456), + TEST_PARSER(case1457), TEST_PARSER(case1458), TEST_PARSER(case1459), + TEST_PARSER(case1460), TEST_PARSER(case1461), TEST_PARSER(case1462), + TEST_PARSER(case1463), TEST_PARSER(case1464), TEST_PARSER(case1465), + TEST_PARSER(case1466), TEST_PARSER(case1467), TEST_PARSER(case1468), + TEST_PARSER(case1469), TEST_PARSER(case1470), TEST_PARSER(case1471), + TEST_PARSER(case1472), TEST_PARSER(case1473), TEST_PARSER(case1474), + TEST_PARSER(case1475), TEST_PARSER(case1476), TEST_PARSER(case1477), + TEST_PARSER(case1478), TEST_PARSER(case1479), TEST_PARSER(case1480), + TEST_PARSER(case1481), TEST_PARSER(case1482), TEST_PARSER(case1483), + TEST_PARSER(case1484), TEST_PARSER(case1485), TEST_PARSER(case1486), + TEST_PARSER(case1487), TEST_PARSER(case1488), TEST_PARSER(case1489), + TEST_PARSER(case1490), TEST_PARSER(case1491), TEST_PARSER(case1492), + TEST_PARSER(case1493), TEST_PARSER(case1494), TEST_PARSER(case1495), + TEST_PARSER(case1496), TEST_PARSER(case1497), TEST_PARSER(case1498), + TEST_PARSER(case1499), - TEST_PARSER(case1500), - TEST_PARSER(case1501), - TEST_PARSER(case1502), - TEST_PARSER(case1503), - TEST_PARSER(case1504), - TEST_PARSER(case1505), - TEST_PARSER(case1506), - TEST_PARSER(case1507), - TEST_PARSER(case1508), - TEST_PARSER(case1509), - TEST_PARSER(case1510), - TEST_PARSER(case1511), - TEST_PARSER(case1512), - TEST_PARSER(case1513), - TEST_PARSER(case1514), - TEST_PARSER(case1515), - TEST_PARSER(case1516), - TEST_PARSER(case1517), - TEST_PARSER(case1518), - TEST_PARSER(case1519), - TEST_PARSER(case1520), - TEST_PARSER(case1521), - TEST_PARSER(case1522), - TEST_PARSER(case1523), - TEST_PARSER(case1524), - TEST_PARSER(case1525), - TEST_PARSER(case1526), - TEST_PARSER(case1527), - TEST_PARSER(case1528), - TEST_PARSER(case1529), - TEST_PARSER(case1530), - TEST_PARSER(case1531), - TEST_PARSER(case1532), - TEST_PARSER(case1533), - TEST_PARSER(case1534), - TEST_PARSER(case1535), - TEST_PARSER(case1536), - TEST_PARSER(case1537), - TEST_PARSER(case1538), - TEST_PARSER(case1539), - TEST_PARSER(case1540), - TEST_PARSER(case1541), - TEST_PARSER(case1542), - TEST_PARSER(case1543), - TEST_PARSER(case1544), - TEST_PARSER(case1545), - TEST_PARSER(case1546), - TEST_PARSER(case1547), - TEST_PARSER(case1548), - TEST_PARSER(case1549), - TEST_PARSER(case1550), - TEST_PARSER(case1551), - TEST_PARSER(case1552), - TEST_PARSER(case1553), - TEST_PARSER(case1554), - TEST_PARSER(case1555), - TEST_PARSER(case1556), - TEST_PARSER(case1557), - TEST_PARSER(case1558), - TEST_PARSER(case1559), - TEST_PARSER(case1560), - TEST_PARSER(case1561), - TEST_PARSER(case1562), - TEST_PARSER(case1563), - TEST_PARSER(case1564), - TEST_PARSER(case1565), - TEST_PARSER(case1566), - TEST_PARSER(case1567), - TEST_PARSER(case1568), - TEST_PARSER(case1569), - TEST_PARSER(case1570), - TEST_PARSER(case1571), - TEST_PARSER(case1572), - TEST_PARSER(case1573), - TEST_PARSER(case1574), - TEST_PARSER(case1575), - TEST_PARSER(case1576), - TEST_PARSER(case1577), - TEST_PARSER(case1578), - TEST_PARSER(case1579), - TEST_PARSER(case1580), - TEST_PARSER(case1581), - TEST_PARSER(case1582), - TEST_PARSER(case1583), - TEST_PARSER(case1584), - TEST_PARSER(case1585), - TEST_PARSER(case1586), - TEST_PARSER(case1587), - TEST_PARSER(case1588), - TEST_PARSER(case1589), - TEST_PARSER(case1590), - TEST_PARSER(case1591), - TEST_PARSER(case1592), - TEST_PARSER(case1593), - TEST_PARSER(case1594), - TEST_PARSER(case1595), - TEST_PARSER(case1596), - TEST_PARSER(case1597), - TEST_PARSER(case1598), - TEST_PARSER(case1599), + TEST_PARSER(case1500), TEST_PARSER(case1501), TEST_PARSER(case1502), + TEST_PARSER(case1503), TEST_PARSER(case1504), TEST_PARSER(case1505), + TEST_PARSER(case1506), TEST_PARSER(case1507), TEST_PARSER(case1508), + TEST_PARSER(case1509), TEST_PARSER(case1510), TEST_PARSER(case1511), + TEST_PARSER(case1512), TEST_PARSER(case1513), TEST_PARSER(case1514), + TEST_PARSER(case1515), TEST_PARSER(case1516), TEST_PARSER(case1517), + TEST_PARSER(case1518), TEST_PARSER(case1519), TEST_PARSER(case1520), + TEST_PARSER(case1521), TEST_PARSER(case1522), TEST_PARSER(case1523), + TEST_PARSER(case1524), TEST_PARSER(case1525), TEST_PARSER(case1526), + TEST_PARSER(case1527), TEST_PARSER(case1528), TEST_PARSER(case1529), + TEST_PARSER(case1530), TEST_PARSER(case1531), TEST_PARSER(case1532), + TEST_PARSER(case1533), TEST_PARSER(case1534), TEST_PARSER(case1535), + TEST_PARSER(case1536), TEST_PARSER(case1537), TEST_PARSER(case1538), + TEST_PARSER(case1539), TEST_PARSER(case1540), TEST_PARSER(case1541), + TEST_PARSER(case1542), TEST_PARSER(case1543), TEST_PARSER(case1544), + TEST_PARSER(case1545), TEST_PARSER(case1546), TEST_PARSER(case1547), + TEST_PARSER(case1548), TEST_PARSER(case1549), TEST_PARSER(case1550), + TEST_PARSER(case1551), TEST_PARSER(case1552), TEST_PARSER(case1553), + TEST_PARSER(case1554), TEST_PARSER(case1555), TEST_PARSER(case1556), + TEST_PARSER(case1557), TEST_PARSER(case1558), TEST_PARSER(case1559), + TEST_PARSER(case1560), TEST_PARSER(case1561), TEST_PARSER(case1562), + TEST_PARSER(case1563), TEST_PARSER(case1564), TEST_PARSER(case1565), + TEST_PARSER(case1566), TEST_PARSER(case1567), TEST_PARSER(case1568), + TEST_PARSER(case1569), TEST_PARSER(case1570), TEST_PARSER(case1571), + TEST_PARSER(case1572), TEST_PARSER(case1573), TEST_PARSER(case1574), + TEST_PARSER(case1575), TEST_PARSER(case1576), TEST_PARSER(case1577), + TEST_PARSER(case1578), TEST_PARSER(case1579), TEST_PARSER(case1580), + TEST_PARSER(case1581), TEST_PARSER(case1582), TEST_PARSER(case1583), + TEST_PARSER(case1584), TEST_PARSER(case1585), TEST_PARSER(case1586), + TEST_PARSER(case1587), TEST_PARSER(case1588), TEST_PARSER(case1589), + TEST_PARSER(case1590), TEST_PARSER(case1591), TEST_PARSER(case1592), + TEST_PARSER(case1593), TEST_PARSER(case1594), TEST_PARSER(case1595), + TEST_PARSER(case1596), TEST_PARSER(case1597), TEST_PARSER(case1598), + TEST_PARSER(case1599), - TEST_PARSER(case1600), - TEST_PARSER(case1601), - TEST_PARSER(case1602), - TEST_PARSER(case1603), - TEST_PARSER(case1604), - TEST_PARSER(case1605), - TEST_PARSER(case1606), - TEST_PARSER(case1607), - TEST_PARSER(case1608), - TEST_PARSER(case1609), - TEST_PARSER(case1610), - TEST_PARSER(case1611), - TEST_PARSER(case1612), - TEST_PARSER(case1613), - TEST_PARSER(case1614), - TEST_PARSER(case1615), - TEST_PARSER(case1616), - TEST_PARSER(case1617), - TEST_PARSER(case1618), - TEST_PARSER(case1619), - TEST_PARSER(case1620), - TEST_PARSER(case1621), - TEST_PARSER(case1622), - TEST_PARSER(case1623), - TEST_PARSER(case1624), - TEST_PARSER(case1625), - TEST_PARSER(case1626), - TEST_PARSER(case1627), - TEST_PARSER(case1628), - TEST_PARSER(case1629), - TEST_PARSER(case1630), - TEST_PARSER(case1631), - TEST_PARSER(case1632), - TEST_PARSER(case1633), - TEST_PARSER(case1634), - TEST_PARSER(case1635), - TEST_PARSER(case1636), - TEST_PARSER(case1637), - TEST_PARSER(case1638), - TEST_PARSER(case1639), - TEST_PARSER(case1640), - TEST_PARSER(case1641), - TEST_PARSER(case1642), - TEST_PARSER(case1643), - TEST_PARSER(case1644), - TEST_PARSER(case1645), - TEST_PARSER(case1646), - TEST_PARSER(case1647), - TEST_PARSER(case1648), - TEST_PARSER(case1649), - TEST_PARSER(case1650), - TEST_PARSER(case1651), - TEST_PARSER(case1652), - TEST_PARSER(case1653), - TEST_PARSER(case1654), - TEST_PARSER(case1655), - TEST_PARSER(case1656), - TEST_PARSER(case1657), - TEST_PARSER(case1658), - TEST_PARSER(case1659), - TEST_PARSER(case1660), - TEST_PARSER(case1661), - TEST_PARSER(case1662), - TEST_PARSER(case1663), - TEST_PARSER(case1664), - TEST_PARSER(case1665), - TEST_PARSER(case1666), - TEST_PARSER(case1667), - TEST_PARSER(case1668), - TEST_PARSER(case1669), - TEST_PARSER(case1670), - TEST_PARSER(case1671), - TEST_PARSER(case1672), - TEST_PARSER(case1673), - TEST_PARSER(case1674), - TEST_PARSER(case1675), - TEST_PARSER(case1676), - TEST_PARSER(case1677), - TEST_PARSER(case1678), - TEST_PARSER(case1679), - TEST_PARSER(case1680), - TEST_PARSER(case1681), - TEST_PARSER(case1682), - TEST_PARSER(case1683), - TEST_PARSER(case1684), - TEST_PARSER(case1685), - TEST_PARSER(case1686), - TEST_PARSER(case1687), - TEST_PARSER(case1688), - TEST_PARSER(case1689), - TEST_PARSER(case1690), - TEST_PARSER(case1691), - TEST_PARSER(case1692), - TEST_PARSER(case1693), - TEST_PARSER(case1694), - TEST_PARSER(case1695), - TEST_PARSER(case1696), - TEST_PARSER(case1697), - TEST_PARSER(case1698), - TEST_PARSER(case1699), + TEST_PARSER(case1600), TEST_PARSER(case1601), TEST_PARSER(case1602), + TEST_PARSER(case1603), TEST_PARSER(case1604), TEST_PARSER(case1605), + TEST_PARSER(case1606), TEST_PARSER(case1607), TEST_PARSER(case1608), + TEST_PARSER(case1609), TEST_PARSER(case1610), TEST_PARSER(case1611), + TEST_PARSER(case1612), TEST_PARSER(case1613), TEST_PARSER(case1614), + TEST_PARSER(case1615), TEST_PARSER(case1616), TEST_PARSER(case1617), + TEST_PARSER(case1618), TEST_PARSER(case1619), TEST_PARSER(case1620), + TEST_PARSER(case1621), TEST_PARSER(case1622), TEST_PARSER(case1623), + TEST_PARSER(case1624), TEST_PARSER(case1625), TEST_PARSER(case1626), + TEST_PARSER(case1627), TEST_PARSER(case1628), TEST_PARSER(case1629), + TEST_PARSER(case1630), TEST_PARSER(case1631), TEST_PARSER(case1632), + TEST_PARSER(case1633), TEST_PARSER(case1634), TEST_PARSER(case1635), + TEST_PARSER(case1636), TEST_PARSER(case1637), TEST_PARSER(case1638), + TEST_PARSER(case1639), TEST_PARSER(case1640), TEST_PARSER(case1641), + TEST_PARSER(case1642), TEST_PARSER(case1643), TEST_PARSER(case1644), + TEST_PARSER(case1645), TEST_PARSER(case1646), TEST_PARSER(case1647), + TEST_PARSER(case1648), TEST_PARSER(case1649), TEST_PARSER(case1650), + TEST_PARSER(case1651), TEST_PARSER(case1652), TEST_PARSER(case1653), + TEST_PARSER(case1654), TEST_PARSER(case1655), TEST_PARSER(case1656), + TEST_PARSER(case1657), TEST_PARSER(case1658), TEST_PARSER(case1659), + TEST_PARSER(case1660), TEST_PARSER(case1661), TEST_PARSER(case1662), + TEST_PARSER(case1663), TEST_PARSER(case1664), TEST_PARSER(case1665), + TEST_PARSER(case1666), TEST_PARSER(case1667), TEST_PARSER(case1668), + TEST_PARSER(case1669), TEST_PARSER(case1670), TEST_PARSER(case1671), + TEST_PARSER(case1672), TEST_PARSER(case1673), TEST_PARSER(case1674), + TEST_PARSER(case1675), TEST_PARSER(case1676), TEST_PARSER(case1677), + TEST_PARSER(case1678), TEST_PARSER(case1679), TEST_PARSER(case1680), + TEST_PARSER(case1681), TEST_PARSER(case1682), TEST_PARSER(case1683), + TEST_PARSER(case1684), TEST_PARSER(case1685), TEST_PARSER(case1686), + TEST_PARSER(case1687), TEST_PARSER(case1688), TEST_PARSER(case1689), + TEST_PARSER(case1690), TEST_PARSER(case1691), TEST_PARSER(case1692), + TEST_PARSER(case1693), TEST_PARSER(case1694), TEST_PARSER(case1695), + TEST_PARSER(case1696), TEST_PARSER(case1697), TEST_PARSER(case1698), + TEST_PARSER(case1699), - TEST_PARSER(case1700), - TEST_PARSER(case1701), - TEST_PARSER(case1702), - TEST_PARSER(case1703), - TEST_PARSER(case1704), - TEST_PARSER(case1705), - TEST_PARSER(case1706), - TEST_PARSER(case1707), - TEST_PARSER(case1708), - TEST_PARSER(case1709), - TEST_PARSER(case1710), - TEST_PARSER(case1711), - TEST_PARSER(case1712), - TEST_PARSER(case1713), - TEST_PARSER(case1714), - TEST_PARSER(case1715), - TEST_PARSER(case1716), - TEST_PARSER(case1717), - TEST_PARSER(case1718), - TEST_PARSER(case1719), - TEST_PARSER(case1720), - TEST_PARSER(case1721), - TEST_PARSER(case1722), - TEST_PARSER(case1723), - TEST_PARSER(case1724), - TEST_PARSER(case1725), - TEST_PARSER(case1726), - TEST_PARSER(case1727), - TEST_PARSER(case1728), - TEST_PARSER(case1729), - TEST_PARSER(case1730), - TEST_PARSER(case1731), - TEST_PARSER(case1732), - TEST_PARSER(case1733), - TEST_PARSER(case1734), - TEST_PARSER(case1735), - TEST_PARSER(case1736), - TEST_PARSER(case1737), - TEST_PARSER(case1738), - TEST_PARSER(case1739), - TEST_PARSER(case1740), - TEST_PARSER(case1741), - TEST_PARSER(case1742), - TEST_PARSER(case1743), - TEST_PARSER(case1744), - TEST_PARSER(case1745), - TEST_PARSER(case1746), - TEST_PARSER(case1747), - TEST_PARSER(case1748), - TEST_PARSER(case1749), - TEST_PARSER(case1750), - TEST_PARSER(case1751), - TEST_PARSER(case1752), - TEST_PARSER(case1753), - TEST_PARSER(case1754), - TEST_PARSER(case1755), - TEST_PARSER(case1756), - TEST_PARSER(case1757), - TEST_PARSER(case1758), - TEST_PARSER(case1759), - TEST_PARSER(case1760), - TEST_PARSER(case1761), - TEST_PARSER(case1762), - TEST_PARSER(case1763), - TEST_PARSER(case1764), - TEST_PARSER(case1765), - TEST_PARSER(case1766), - TEST_PARSER(case1767), - TEST_PARSER(case1768), - TEST_PARSER(case1769), - TEST_PARSER(case1770), - TEST_PARSER(case1771), - TEST_PARSER(case1772), - TEST_PARSER(case1773), - TEST_PARSER(case1774), - TEST_PARSER(case1775), - TEST_PARSER(case1776), - TEST_PARSER(case1777), - TEST_PARSER(case1778), - TEST_PARSER(case1779), - TEST_PARSER(case1780), - TEST_PARSER(case1781), - TEST_PARSER(case1782), - TEST_PARSER(case1783), - TEST_PARSER(case1784), - TEST_PARSER(case1785), - TEST_PARSER(case1786), - TEST_PARSER(case1787), - TEST_PARSER(case1788), - TEST_PARSER(case1789), - TEST_PARSER(case1790), - TEST_PARSER(case1791), - TEST_PARSER(case1792), - TEST_PARSER(case1793), - TEST_PARSER(case1794), - TEST_PARSER(case1795), - TEST_PARSER(case1796), - TEST_PARSER(case1797), - TEST_PARSER(case1798), - TEST_PARSER(case1799), + TEST_PARSER(case1700), TEST_PARSER(case1701), TEST_PARSER(case1702), + TEST_PARSER(case1703), TEST_PARSER(case1704), TEST_PARSER(case1705), + TEST_PARSER(case1706), TEST_PARSER(case1707), TEST_PARSER(case1708), + TEST_PARSER(case1709), TEST_PARSER(case1710), TEST_PARSER(case1711), + TEST_PARSER(case1712), TEST_PARSER(case1713), TEST_PARSER(case1714), + TEST_PARSER(case1715), TEST_PARSER(case1716), TEST_PARSER(case1717), + TEST_PARSER(case1718), TEST_PARSER(case1719), TEST_PARSER(case1720), + TEST_PARSER(case1721), TEST_PARSER(case1722), TEST_PARSER(case1723), + TEST_PARSER(case1724), TEST_PARSER(case1725), TEST_PARSER(case1726), + TEST_PARSER(case1727), TEST_PARSER(case1728), TEST_PARSER(case1729), + TEST_PARSER(case1730), TEST_PARSER(case1731), TEST_PARSER(case1732), + TEST_PARSER(case1733), TEST_PARSER(case1734), TEST_PARSER(case1735), + TEST_PARSER(case1736), TEST_PARSER(case1737), TEST_PARSER(case1738), + TEST_PARSER(case1739), TEST_PARSER(case1740), TEST_PARSER(case1741), + TEST_PARSER(case1742), TEST_PARSER(case1743), TEST_PARSER(case1744), + TEST_PARSER(case1745), TEST_PARSER(case1746), TEST_PARSER(case1747), + TEST_PARSER(case1748), TEST_PARSER(case1749), TEST_PARSER(case1750), + TEST_PARSER(case1751), TEST_PARSER(case1752), TEST_PARSER(case1753), + TEST_PARSER(case1754), TEST_PARSER(case1755), TEST_PARSER(case1756), + TEST_PARSER(case1757), TEST_PARSER(case1758), TEST_PARSER(case1759), + TEST_PARSER(case1760), TEST_PARSER(case1761), TEST_PARSER(case1762), + TEST_PARSER(case1763), TEST_PARSER(case1764), TEST_PARSER(case1765), + TEST_PARSER(case1766), TEST_PARSER(case1767), TEST_PARSER(case1768), + TEST_PARSER(case1769), TEST_PARSER(case1770), TEST_PARSER(case1771), + TEST_PARSER(case1772), TEST_PARSER(case1773), TEST_PARSER(case1774), + TEST_PARSER(case1775), TEST_PARSER(case1776), TEST_PARSER(case1777), + TEST_PARSER(case1778), TEST_PARSER(case1779), TEST_PARSER(case1780), + TEST_PARSER(case1781), TEST_PARSER(case1782), TEST_PARSER(case1783), + TEST_PARSER(case1784), TEST_PARSER(case1785), TEST_PARSER(case1786), + TEST_PARSER(case1787), TEST_PARSER(case1788), TEST_PARSER(case1789), + TEST_PARSER(case1790), TEST_PARSER(case1791), TEST_PARSER(case1792), + TEST_PARSER(case1793), TEST_PARSER(case1794), TEST_PARSER(case1795), + TEST_PARSER(case1796), TEST_PARSER(case1797), TEST_PARSER(case1798), + TEST_PARSER(case1799), - TEST_PARSER(case1800), - TEST_PARSER(case1801), - TEST_PARSER(case1802), - TEST_PARSER(case1803), - TEST_PARSER(case1804), - TEST_PARSER(case1805), - TEST_PARSER(case1806), - TEST_PARSER(case1807), - TEST_PARSER(case1808), - TEST_PARSER(case1809), - TEST_PARSER(case1810), - TEST_PARSER(case1811), - TEST_PARSER(case1812), - TEST_PARSER(case1813), - TEST_PARSER(case1814), - TEST_PARSER(case1815), - TEST_PARSER(case1816), - TEST_PARSER(case1817), - TEST_PARSER(case1818), - TEST_PARSER(case1819), - TEST_PARSER(case1820), - TEST_PARSER(case1821), - TEST_PARSER(case1822), - TEST_PARSER(case1823), - TEST_PARSER(case1824), - TEST_PARSER(case1825), - TEST_PARSER(case1826), - TEST_PARSER(case1827), - TEST_PARSER(case1828), - TEST_PARSER(case1829), - TEST_PARSER(case1830), - TEST_PARSER(case1831), - TEST_PARSER(case1832), - TEST_PARSER(case1833), - TEST_PARSER(case1834), - TEST_PARSER(case1835), - TEST_PARSER(case1836), - TEST_PARSER(case1837), - TEST_PARSER(case1838), - TEST_PARSER(case1839), - TEST_PARSER(case1840), - TEST_PARSER(case1841), - TEST_PARSER(case1842), - TEST_PARSER(case1843), - TEST_PARSER(case1844), - TEST_PARSER(case1845), - TEST_PARSER(case1846), - TEST_PARSER(case1847), - TEST_PARSER(case1848), - TEST_PARSER(case1849), - TEST_PARSER(case1850), - TEST_PARSER(case1851), - TEST_PARSER(case1852), - TEST_PARSER(case1853), - TEST_PARSER(case1854), - TEST_PARSER(case1855), - TEST_PARSER(case1856), - TEST_PARSER(case1857), - TEST_PARSER(case1858), - TEST_PARSER(case1859), - TEST_PARSER(case1860), - TEST_PARSER(case1861), - TEST_PARSER(case1862), - TEST_PARSER(case1863), - TEST_PARSER(case1864), - TEST_PARSER(case1865), - TEST_PARSER(case1866), - TEST_PARSER(case1867), - TEST_PARSER(case1868), - TEST_PARSER(case1869), - TEST_PARSER(case1870), - TEST_PARSER(case1871), - TEST_PARSER(case1872), - TEST_PARSER(case1873), - TEST_PARSER(case1874), - TEST_PARSER(case1875), - TEST_PARSER(case1876), - TEST_PARSER(case1877), - TEST_PARSER(case1878), - TEST_PARSER(case1879), - TEST_PARSER(case1880), - TEST_PARSER(case1881), - TEST_PARSER(case1882), - TEST_PARSER(case1883), - TEST_PARSER(case1884), - TEST_PARSER(case1885), - TEST_PARSER(case1886), - TEST_PARSER(case1887), - TEST_PARSER(case1888), - TEST_PARSER(case1889), - TEST_PARSER(case1890), - TEST_PARSER(case1891), - TEST_PARSER(case1892), - TEST_PARSER(case1893), - TEST_PARSER(case1894), - TEST_PARSER(case1895), - TEST_PARSER(case1896), - TEST_PARSER(case1897), - TEST_PARSER(case1898), - TEST_PARSER(case1899), + TEST_PARSER(case1800), TEST_PARSER(case1801), TEST_PARSER(case1802), + TEST_PARSER(case1803), TEST_PARSER(case1804), TEST_PARSER(case1805), + TEST_PARSER(case1806), TEST_PARSER(case1807), TEST_PARSER(case1808), + TEST_PARSER(case1809), TEST_PARSER(case1810), TEST_PARSER(case1811), + TEST_PARSER(case1812), TEST_PARSER(case1813), TEST_PARSER(case1814), + TEST_PARSER(case1815), TEST_PARSER(case1816), TEST_PARSER(case1817), + TEST_PARSER(case1818), TEST_PARSER(case1819), TEST_PARSER(case1820), + TEST_PARSER(case1821), TEST_PARSER(case1822), TEST_PARSER(case1823), + TEST_PARSER(case1824), TEST_PARSER(case1825), TEST_PARSER(case1826), + TEST_PARSER(case1827), TEST_PARSER(case1828), TEST_PARSER(case1829), + TEST_PARSER(case1830), TEST_PARSER(case1831), TEST_PARSER(case1832), + TEST_PARSER(case1833), TEST_PARSER(case1834), TEST_PARSER(case1835), + TEST_PARSER(case1836), TEST_PARSER(case1837), TEST_PARSER(case1838), + TEST_PARSER(case1839), TEST_PARSER(case1840), TEST_PARSER(case1841), + TEST_PARSER(case1842), TEST_PARSER(case1843), TEST_PARSER(case1844), + TEST_PARSER(case1845), TEST_PARSER(case1846), TEST_PARSER(case1847), + TEST_PARSER(case1848), TEST_PARSER(case1849), TEST_PARSER(case1850), + TEST_PARSER(case1851), TEST_PARSER(case1852), TEST_PARSER(case1853), + TEST_PARSER(case1854), TEST_PARSER(case1855), TEST_PARSER(case1856), + TEST_PARSER(case1857), TEST_PARSER(case1858), TEST_PARSER(case1859), + TEST_PARSER(case1860), TEST_PARSER(case1861), TEST_PARSER(case1862), + TEST_PARSER(case1863), TEST_PARSER(case1864), TEST_PARSER(case1865), + TEST_PARSER(case1866), TEST_PARSER(case1867), TEST_PARSER(case1868), + TEST_PARSER(case1869), TEST_PARSER(case1870), TEST_PARSER(case1871), + TEST_PARSER(case1872), TEST_PARSER(case1873), TEST_PARSER(case1874), + TEST_PARSER(case1875), TEST_PARSER(case1876), TEST_PARSER(case1877), + TEST_PARSER(case1878), TEST_PARSER(case1879), TEST_PARSER(case1880), + TEST_PARSER(case1881), TEST_PARSER(case1882), TEST_PARSER(case1883), + TEST_PARSER(case1884), TEST_PARSER(case1885), TEST_PARSER(case1886), + TEST_PARSER(case1887), TEST_PARSER(case1888), TEST_PARSER(case1889), + TEST_PARSER(case1890), TEST_PARSER(case1891), TEST_PARSER(case1892), + TEST_PARSER(case1893), TEST_PARSER(case1894), TEST_PARSER(case1895), + TEST_PARSER(case1896), TEST_PARSER(case1897), TEST_PARSER(case1898), + TEST_PARSER(case1899), - TEST_PARSER(case1900), - TEST_PARSER(case1901), - TEST_PARSER(case1902), - TEST_PARSER(case1903), - TEST_PARSER(case1904), - TEST_PARSER(case1905), - TEST_PARSER(case1906), - TEST_PARSER(case1907), - TEST_PARSER(case1908), - TEST_PARSER(case1909), - TEST_PARSER(case1910), - TEST_PARSER(case1911), - TEST_PARSER(case1912), - TEST_PARSER(case1913), - TEST_PARSER(case1914), - TEST_PARSER(case1915), - TEST_PARSER(case1916), - TEST_PARSER(case1917), - TEST_PARSER(case1918), - TEST_PARSER(case1919), - TEST_PARSER(case1920), - TEST_PARSER(case1921), - TEST_PARSER(case1922), - TEST_PARSER(case1923), - TEST_PARSER(case1924), - TEST_PARSER(case1925), - TEST_PARSER(case1926), - TEST_PARSER(case1927), - TEST_PARSER(case1928), - TEST_PARSER(case1929), - TEST_PARSER(case1930), - TEST_PARSER(case1931), - TEST_PARSER(case1932), - TEST_PARSER(case1933), - TEST_PARSER(case1934), - TEST_PARSER(case1935), - TEST_PARSER(case1936), - TEST_PARSER(case1937), - TEST_PARSER(case1938), - TEST_PARSER(case1939), - TEST_PARSER(case1940), - TEST_PARSER(case1941), - TEST_PARSER(case1942), - TEST_PARSER(case1943), - TEST_PARSER(case1944), - TEST_PARSER(case1945), - TEST_PARSER(case1946), - TEST_PARSER(case1947), - TEST_PARSER(case1948), - TEST_PARSER(case1949), - TEST_PARSER(case1950), - TEST_PARSER(case1951), - TEST_PARSER(case1952), - TEST_PARSER(case1953), - TEST_PARSER(case1954), - TEST_PARSER(case1955), - TEST_PARSER(case1956), - TEST_PARSER(case1957), - TEST_PARSER(case1958), - TEST_PARSER(case1959), - TEST_PARSER(case1960), - TEST_PARSER(case1961), - TEST_PARSER(case1962), - TEST_PARSER(case1963), - TEST_PARSER(case1964), - TEST_PARSER(case1965), - TEST_PARSER(case1966), - TEST_PARSER(case1967), - TEST_PARSER(case1968), - TEST_PARSER(case1969), - TEST_PARSER(case1970), - TEST_PARSER(case1971), - TEST_PARSER(case1972), - TEST_PARSER(case1973), - TEST_PARSER(case1974), - TEST_PARSER(case1975), - TEST_PARSER(case1976), - TEST_PARSER(case1977), - TEST_PARSER(case1978), - TEST_PARSER(case1979), - TEST_PARSER(case1980), - TEST_PARSER(case1981), - TEST_PARSER(case1982), - TEST_PARSER(case1983), - TEST_PARSER(case1984), - TEST_PARSER(case1985), - TEST_PARSER(case1986), - TEST_PARSER(case1987), - TEST_PARSER(case1988), - TEST_PARSER(case1989), - TEST_PARSER(case1990), - TEST_PARSER(case1991), - TEST_PARSER(case1992), - TEST_PARSER(case1993), - TEST_PARSER(case1994), - TEST_PARSER(case1995), - TEST_PARSER(case1996), - TEST_PARSER(case1997), - TEST_PARSER(case1998), - TEST_PARSER(case1999), + TEST_PARSER(case1900), TEST_PARSER(case1901), TEST_PARSER(case1902), + TEST_PARSER(case1903), TEST_PARSER(case1904), TEST_PARSER(case1905), + TEST_PARSER(case1906), TEST_PARSER(case1907), TEST_PARSER(case1908), + TEST_PARSER(case1909), TEST_PARSER(case1910), TEST_PARSER(case1911), + TEST_PARSER(case1912), TEST_PARSER(case1913), TEST_PARSER(case1914), + TEST_PARSER(case1915), TEST_PARSER(case1916), TEST_PARSER(case1917), + TEST_PARSER(case1918), TEST_PARSER(case1919), TEST_PARSER(case1920), + TEST_PARSER(case1921), TEST_PARSER(case1922), TEST_PARSER(case1923), + TEST_PARSER(case1924), TEST_PARSER(case1925), TEST_PARSER(case1926), + TEST_PARSER(case1927), TEST_PARSER(case1928), TEST_PARSER(case1929), + TEST_PARSER(case1930), TEST_PARSER(case1931), TEST_PARSER(case1932), + TEST_PARSER(case1933), TEST_PARSER(case1934), TEST_PARSER(case1935), + TEST_PARSER(case1936), TEST_PARSER(case1937), TEST_PARSER(case1938), + TEST_PARSER(case1939), TEST_PARSER(case1940), TEST_PARSER(case1941), + TEST_PARSER(case1942), TEST_PARSER(case1943), TEST_PARSER(case1944), + TEST_PARSER(case1945), TEST_PARSER(case1946), TEST_PARSER(case1947), + TEST_PARSER(case1948), TEST_PARSER(case1949), TEST_PARSER(case1950), + TEST_PARSER(case1951), TEST_PARSER(case1952), TEST_PARSER(case1953), + TEST_PARSER(case1954), TEST_PARSER(case1955), TEST_PARSER(case1956), + TEST_PARSER(case1957), TEST_PARSER(case1958), TEST_PARSER(case1959), + TEST_PARSER(case1960), TEST_PARSER(case1961), TEST_PARSER(case1962), + TEST_PARSER(case1963), TEST_PARSER(case1964), TEST_PARSER(case1965), + TEST_PARSER(case1966), TEST_PARSER(case1967), TEST_PARSER(case1968), + TEST_PARSER(case1969), TEST_PARSER(case1970), TEST_PARSER(case1971), + TEST_PARSER(case1972), TEST_PARSER(case1973), TEST_PARSER(case1974), + TEST_PARSER(case1975), TEST_PARSER(case1976), TEST_PARSER(case1977), + TEST_PARSER(case1978), TEST_PARSER(case1979), TEST_PARSER(case1980), + TEST_PARSER(case1981), TEST_PARSER(case1982), TEST_PARSER(case1983), + TEST_PARSER(case1984), TEST_PARSER(case1985), TEST_PARSER(case1986), + TEST_PARSER(case1987), TEST_PARSER(case1988), TEST_PARSER(case1989), + TEST_PARSER(case1990), TEST_PARSER(case1991), TEST_PARSER(case1992), + TEST_PARSER(case1993), TEST_PARSER(case1994), TEST_PARSER(case1995), + TEST_PARSER(case1996), TEST_PARSER(case1997), TEST_PARSER(case1998), + TEST_PARSER(case1999), - TEST_PARSER(case2000), - TEST_PARSER(case2001), - TEST_PARSER(case2002), - TEST_PARSER(case2003), - TEST_PARSER(case2004), - TEST_PARSER(case2005), - TEST_PARSER(case2006), - TEST_PARSER(case2007), - TEST_PARSER(case2008), - TEST_PARSER(case2009), - TEST_PARSER(case2010), - TEST_PARSER(case2011), - TEST_PARSER(case2012), - TEST_PARSER(case2013), - TEST_PARSER(case2014), - TEST_PARSER(case2015), - TEST_PARSER(case2016), - TEST_PARSER(case2017), - TEST_PARSER(case2018), - TEST_PARSER(case2019), - TEST_PARSER(case2020), - TEST_PARSER(case2021), - TEST_PARSER(case2022), - TEST_PARSER(case2023), - TEST_PARSER(case2024), - TEST_PARSER(case2025), - TEST_PARSER(case2026), - TEST_PARSER(case2027), - TEST_PARSER(case2028), - TEST_PARSER(case2029), - TEST_PARSER(case2030), - TEST_PARSER(case2031), - TEST_PARSER(case2032), - TEST_PARSER(case2033), - TEST_PARSER(case2034), - TEST_PARSER(case2035), - TEST_PARSER(case2036), - TEST_PARSER(case2037), - TEST_PARSER(case2038), - TEST_PARSER(case2039), - TEST_PARSER(case2040), - TEST_PARSER(case2041), - TEST_PARSER(case2042), - TEST_PARSER(case2043), - TEST_PARSER(case2044), - TEST_PARSER(case2045), - TEST_PARSER(case2046), - TEST_PARSER(case2047), - TEST_PARSER(case2048), - TEST_PARSER(case2049), - TEST_PARSER(case2050), - TEST_PARSER(case2051), - TEST_PARSER(case2052), - TEST_PARSER(case2053), - TEST_PARSER(case2054), - TEST_PARSER(case2055), - TEST_PARSER(case2056), - TEST_PARSER(case2057), - TEST_PARSER(case2058), - TEST_PARSER(case2059), - TEST_PARSER(case2060), - TEST_PARSER(case2061), - TEST_PARSER(case2062), - TEST_PARSER(case2063), - TEST_PARSER(case2064), - TEST_PARSER(case2065), - TEST_PARSER(case2066), - TEST_PARSER(case2067), - TEST_PARSER(case2068), - TEST_PARSER(case2069), - TEST_PARSER(case2070), - TEST_PARSER(case2071), - TEST_PARSER(case2072), - TEST_PARSER(case2073), - TEST_PARSER(case2074), - TEST_PARSER(case2075), - TEST_PARSER(case2076), - TEST_PARSER(case2077), - TEST_PARSER(case2078), - TEST_PARSER(case2079), - TEST_PARSER(case2080), - TEST_PARSER(case2081), - TEST_PARSER(case2082), - TEST_PARSER(case2083), - TEST_PARSER(case2084), - TEST_PARSER(case2085), - TEST_PARSER(case2086), - TEST_PARSER(case2087), - TEST_PARSER(case2088), - TEST_PARSER(case2089), - TEST_PARSER(case2090), - TEST_PARSER(case2091), - TEST_PARSER(case2092), - TEST_PARSER(case2093), - TEST_PARSER(case2094), - TEST_PARSER(case2095), - TEST_PARSER(case2096), - TEST_PARSER(case2097), - TEST_PARSER(case2098), - TEST_PARSER(case2099), + TEST_PARSER(case2000), TEST_PARSER(case2001), TEST_PARSER(case2002), + TEST_PARSER(case2003), TEST_PARSER(case2004), TEST_PARSER(case2005), + TEST_PARSER(case2006), TEST_PARSER(case2007), TEST_PARSER(case2008), + TEST_PARSER(case2009), TEST_PARSER(case2010), TEST_PARSER(case2011), + TEST_PARSER(case2012), TEST_PARSER(case2013), TEST_PARSER(case2014), + TEST_PARSER(case2015), TEST_PARSER(case2016), TEST_PARSER(case2017), + TEST_PARSER(case2018), TEST_PARSER(case2019), TEST_PARSER(case2020), + TEST_PARSER(case2021), TEST_PARSER(case2022), TEST_PARSER(case2023), + TEST_PARSER(case2024), TEST_PARSER(case2025), TEST_PARSER(case2026), + TEST_PARSER(case2027), TEST_PARSER(case2028), TEST_PARSER(case2029), + TEST_PARSER(case2030), TEST_PARSER(case2031), TEST_PARSER(case2032), + TEST_PARSER(case2033), TEST_PARSER(case2034), TEST_PARSER(case2035), + TEST_PARSER(case2036), TEST_PARSER(case2037), TEST_PARSER(case2038), + TEST_PARSER(case2039), TEST_PARSER(case2040), TEST_PARSER(case2041), + TEST_PARSER(case2042), TEST_PARSER(case2043), TEST_PARSER(case2044), + TEST_PARSER(case2045), TEST_PARSER(case2046), TEST_PARSER(case2047), + TEST_PARSER(case2048), TEST_PARSER(case2049), TEST_PARSER(case2050), + TEST_PARSER(case2051), TEST_PARSER(case2052), TEST_PARSER(case2053), + TEST_PARSER(case2054), TEST_PARSER(case2055), TEST_PARSER(case2056), + TEST_PARSER(case2057), TEST_PARSER(case2058), TEST_PARSER(case2059), + TEST_PARSER(case2060), TEST_PARSER(case2061), TEST_PARSER(case2062), + TEST_PARSER(case2063), TEST_PARSER(case2064), TEST_PARSER(case2065), + TEST_PARSER(case2066), TEST_PARSER(case2067), TEST_PARSER(case2068), + TEST_PARSER(case2069), TEST_PARSER(case2070), TEST_PARSER(case2071), + TEST_PARSER(case2072), TEST_PARSER(case2073), TEST_PARSER(case2074), + TEST_PARSER(case2075), TEST_PARSER(case2076), TEST_PARSER(case2077), + TEST_PARSER(case2078), TEST_PARSER(case2079), TEST_PARSER(case2080), + TEST_PARSER(case2081), TEST_PARSER(case2082), TEST_PARSER(case2083), + TEST_PARSER(case2084), TEST_PARSER(case2085), TEST_PARSER(case2086), + TEST_PARSER(case2087), TEST_PARSER(case2088), TEST_PARSER(case2089), + TEST_PARSER(case2090), TEST_PARSER(case2091), TEST_PARSER(case2092), + TEST_PARSER(case2093), TEST_PARSER(case2094), TEST_PARSER(case2095), + TEST_PARSER(case2096), TEST_PARSER(case2097), TEST_PARSER(case2098), + TEST_PARSER(case2099), - TEST_PARSER(case2100), - TEST_PARSER(case2101), - TEST_PARSER(case2102), - TEST_PARSER(case2103), - TEST_PARSER(case2104), - TEST_PARSER(case2105), - TEST_PARSER(case2106), - TEST_PARSER(case2107), - TEST_PARSER(case2108), - TEST_PARSER(case2109), - TEST_PARSER(case2110), - TEST_PARSER(case2111), - TEST_PARSER(case2112), - TEST_PARSER(case2113), - TEST_PARSER(case2114), - TEST_PARSER(case2115), - TEST_PARSER(case2116), - TEST_PARSER(case2117), - TEST_PARSER(case2118), - TEST_PARSER(case2119), - TEST_PARSER(case2120), - TEST_PARSER(case2121), - TEST_PARSER(case2122), - TEST_PARSER(case2123), - TEST_PARSER(case2124), - TEST_PARSER(case2125), - TEST_PARSER(case2126), - TEST_PARSER(case2127), - TEST_PARSER(case2128), - TEST_PARSER(case2129), - TEST_PARSER(case2130), - TEST_PARSER(case2131), - TEST_PARSER(case2132), - TEST_PARSER(case2133), - TEST_PARSER(case2134), - TEST_PARSER(case2135), - TEST_PARSER(case2136), - TEST_PARSER(case2137), - TEST_PARSER(case2138), - TEST_PARSER(case2139), - TEST_PARSER(case2140), - TEST_PARSER(case2141), - TEST_PARSER(case2142), - TEST_PARSER(case2143), - TEST_PARSER(case2144), - TEST_PARSER(case2145), - TEST_PARSER(case2146), - TEST_PARSER(case2147), - TEST_PARSER(case2148), - TEST_PARSER(case2149), - TEST_PARSER(case2150), - TEST_PARSER(case2151), - TEST_PARSER(case2152), - TEST_PARSER(case2153), - TEST_PARSER(case2154), - TEST_PARSER(case2155), - TEST_PARSER(case2156), - TEST_PARSER(case2157), - TEST_PARSER(case2158), - TEST_PARSER(case2159), - TEST_PARSER(case2160), - TEST_PARSER(case2161), - TEST_PARSER(case2162), - TEST_PARSER(case2163), - TEST_PARSER(case2164), - TEST_PARSER(case2165), - TEST_PARSER(case2166), - TEST_PARSER(case2167), - TEST_PARSER(case2168), - TEST_PARSER(case2169), - TEST_PARSER(case2170), - TEST_PARSER(case2171), - TEST_PARSER(case2172), - TEST_PARSER(case2173), - TEST_PARSER(case2174), - TEST_PARSER(case2175), - TEST_PARSER(case2176), - TEST_PARSER(case2177), - TEST_PARSER(case2178), - TEST_PARSER(case2179), - TEST_PARSER(case2180), - TEST_PARSER(case2181), - TEST_PARSER(case2182), - TEST_PARSER(case2183), - TEST_PARSER(case2184), - TEST_PARSER(case2185), - TEST_PARSER(case2186), - TEST_PARSER(case2187), - TEST_PARSER(case2188), - TEST_PARSER(case2189), - TEST_PARSER(case2190), - TEST_PARSER(case2191), - TEST_PARSER(case2192), - TEST_PARSER(case2193), - TEST_PARSER(case2194), - TEST_PARSER(case2195), - TEST_PARSER(case2196), - TEST_PARSER(case2197), - TEST_PARSER(case2198), - TEST_PARSER(case2199), + TEST_PARSER(case2100), TEST_PARSER(case2101), TEST_PARSER(case2102), + TEST_PARSER(case2103), TEST_PARSER(case2104), TEST_PARSER(case2105), + TEST_PARSER(case2106), TEST_PARSER(case2107), TEST_PARSER(case2108), + TEST_PARSER(case2109), TEST_PARSER(case2110), TEST_PARSER(case2111), + TEST_PARSER(case2112), TEST_PARSER(case2113), TEST_PARSER(case2114), + TEST_PARSER(case2115), TEST_PARSER(case2116), TEST_PARSER(case2117), + TEST_PARSER(case2118), TEST_PARSER(case2119), TEST_PARSER(case2120), + TEST_PARSER(case2121), TEST_PARSER(case2122), TEST_PARSER(case2123), + TEST_PARSER(case2124), TEST_PARSER(case2125), TEST_PARSER(case2126), + TEST_PARSER(case2127), TEST_PARSER(case2128), TEST_PARSER(case2129), + TEST_PARSER(case2130), TEST_PARSER(case2131), TEST_PARSER(case2132), + TEST_PARSER(case2133), TEST_PARSER(case2134), TEST_PARSER(case2135), + TEST_PARSER(case2136), TEST_PARSER(case2137), TEST_PARSER(case2138), + TEST_PARSER(case2139), TEST_PARSER(case2140), TEST_PARSER(case2141), + TEST_PARSER(case2142), TEST_PARSER(case2143), TEST_PARSER(case2144), + TEST_PARSER(case2145), TEST_PARSER(case2146), TEST_PARSER(case2147), + TEST_PARSER(case2148), TEST_PARSER(case2149), TEST_PARSER(case2150), + TEST_PARSER(case2151), TEST_PARSER(case2152), TEST_PARSER(case2153), + TEST_PARSER(case2154), TEST_PARSER(case2155), TEST_PARSER(case2156), + TEST_PARSER(case2157), TEST_PARSER(case2158), TEST_PARSER(case2159), + TEST_PARSER(case2160), TEST_PARSER(case2161), TEST_PARSER(case2162), + TEST_PARSER(case2163), TEST_PARSER(case2164), TEST_PARSER(case2165), + TEST_PARSER(case2166), TEST_PARSER(case2167), TEST_PARSER(case2168), + TEST_PARSER(case2169), TEST_PARSER(case2170), TEST_PARSER(case2171), + TEST_PARSER(case2172), TEST_PARSER(case2173), TEST_PARSER(case2174), + TEST_PARSER(case2175), TEST_PARSER(case2176), TEST_PARSER(case2177), + TEST_PARSER(case2178), TEST_PARSER(case2179), TEST_PARSER(case2180), + TEST_PARSER(case2181), TEST_PARSER(case2182), TEST_PARSER(case2183), + TEST_PARSER(case2184), TEST_PARSER(case2185), TEST_PARSER(case2186), + TEST_PARSER(case2187), TEST_PARSER(case2188), TEST_PARSER(case2189), + TEST_PARSER(case2190), TEST_PARSER(case2191), TEST_PARSER(case2192), + TEST_PARSER(case2193), TEST_PARSER(case2194), TEST_PARSER(case2195), + TEST_PARSER(case2196), TEST_PARSER(case2197), TEST_PARSER(case2198), + TEST_PARSER(case2199), - TEST_PARSER(case2200), - TEST_PARSER(case2201), - TEST_PARSER(case2202), - TEST_PARSER(case2203), - TEST_PARSER(case2204), - TEST_PARSER(case2205), - TEST_PARSER(case2206), - TEST_PARSER(case2207), - TEST_PARSER(case2208), - TEST_PARSER(case2209), - TEST_PARSER(case2210), - TEST_PARSER(case2211), - TEST_PARSER(case2212), - TEST_PARSER(case2213), - TEST_PARSER(case2214), - TEST_PARSER(case2215), - TEST_PARSER(case2216), - TEST_PARSER(case2217), - TEST_PARSER(case2218), - TEST_PARSER(case2219), - TEST_PARSER(case2220), - TEST_PARSER(case2221), - TEST_PARSER(case2222), - TEST_PARSER(case2223), - TEST_PARSER(case2224), - TEST_PARSER(case2225), - TEST_PARSER(case2226), - TEST_PARSER(case2227), - TEST_PARSER(case2228), - TEST_PARSER(case2229), - TEST_PARSER(case2230), - TEST_PARSER(case2231), - TEST_PARSER(case2232), - TEST_PARSER(case2233), - TEST_PARSER(case2234), - TEST_PARSER(case2235), - TEST_PARSER(case2236), - TEST_PARSER(case2237), - TEST_PARSER(case2238), - TEST_PARSER(case2239), - TEST_PARSER(case2240), - TEST_PARSER(case2241), - TEST_PARSER(case2242), - TEST_PARSER(case2243), - TEST_PARSER(case2244), - TEST_PARSER(case2245), - TEST_PARSER(case2246), - TEST_PARSER(case2247), - TEST_PARSER(case2248), - TEST_PARSER(case2249), - TEST_PARSER(case2250), - TEST_PARSER(case2251), - TEST_PARSER(case2252), - TEST_PARSER(case2253), - TEST_PARSER(case2254), - TEST_PARSER(case2255), - TEST_PARSER(case2256), - TEST_PARSER(case2257), - TEST_PARSER(case2258), - TEST_PARSER(case2259), - TEST_PARSER(case2260), - TEST_PARSER(case2261), - TEST_PARSER(case2262), - TEST_PARSER(case2263), - TEST_PARSER(case2264), - TEST_PARSER(case2265), - TEST_PARSER(case2266), - TEST_PARSER(case2267), - TEST_PARSER(case2268), - TEST_PARSER(case2269), - TEST_PARSER(case2270), - TEST_PARSER(case2271), - TEST_PARSER(case2272), - TEST_PARSER(case2273), - TEST_PARSER(case2274), - TEST_PARSER(case2275), - TEST_PARSER(case2276), - TEST_PARSER(case2277), - TEST_PARSER(case2278), - TEST_PARSER(case2279), - TEST_PARSER(case2280), - TEST_PARSER(case2281), - TEST_PARSER(case2282), - TEST_PARSER(case2283), - TEST_PARSER(case2284), - TEST_PARSER(case2285), - TEST_PARSER(case2286), - TEST_PARSER(case2287), - TEST_PARSER(case2288), - TEST_PARSER(case2289), - TEST_PARSER(case2290), - TEST_PARSER(case2291), - TEST_PARSER(case2292), - TEST_PARSER(case2293), - TEST_PARSER(case2294), - TEST_PARSER(case2295), - TEST_PARSER(case2296), - TEST_PARSER(case2297), - TEST_PARSER(case2298), - TEST_PARSER(case2299), + TEST_PARSER(case2200), TEST_PARSER(case2201), TEST_PARSER(case2202), + TEST_PARSER(case2203), TEST_PARSER(case2204), TEST_PARSER(case2205), + TEST_PARSER(case2206), TEST_PARSER(case2207), TEST_PARSER(case2208), + TEST_PARSER(case2209), TEST_PARSER(case2210), TEST_PARSER(case2211), + TEST_PARSER(case2212), TEST_PARSER(case2213), TEST_PARSER(case2214), + TEST_PARSER(case2215), TEST_PARSER(case2216), TEST_PARSER(case2217), + TEST_PARSER(case2218), TEST_PARSER(case2219), TEST_PARSER(case2220), + TEST_PARSER(case2221), TEST_PARSER(case2222), TEST_PARSER(case2223), + TEST_PARSER(case2224), TEST_PARSER(case2225), TEST_PARSER(case2226), + TEST_PARSER(case2227), TEST_PARSER(case2228), TEST_PARSER(case2229), + TEST_PARSER(case2230), TEST_PARSER(case2231), TEST_PARSER(case2232), + TEST_PARSER(case2233), TEST_PARSER(case2234), TEST_PARSER(case2235), + TEST_PARSER(case2236), TEST_PARSER(case2237), TEST_PARSER(case2238), + TEST_PARSER(case2239), TEST_PARSER(case2240), TEST_PARSER(case2241), + TEST_PARSER(case2242), TEST_PARSER(case2243), TEST_PARSER(case2244), + TEST_PARSER(case2245), TEST_PARSER(case2246), TEST_PARSER(case2247), + TEST_PARSER(case2248), TEST_PARSER(case2249), TEST_PARSER(case2250), + TEST_PARSER(case2251), TEST_PARSER(case2252), TEST_PARSER(case2253), + TEST_PARSER(case2254), TEST_PARSER(case2255), TEST_PARSER(case2256), + TEST_PARSER(case2257), TEST_PARSER(case2258), TEST_PARSER(case2259), + TEST_PARSER(case2260), TEST_PARSER(case2261), TEST_PARSER(case2262), + TEST_PARSER(case2263), TEST_PARSER(case2264), TEST_PARSER(case2265), + TEST_PARSER(case2266), TEST_PARSER(case2267), TEST_PARSER(case2268), + TEST_PARSER(case2269), TEST_PARSER(case2270), TEST_PARSER(case2271), + TEST_PARSER(case2272), TEST_PARSER(case2273), TEST_PARSER(case2274), + TEST_PARSER(case2275), TEST_PARSER(case2276), TEST_PARSER(case2277), + TEST_PARSER(case2278), TEST_PARSER(case2279), TEST_PARSER(case2280), + TEST_PARSER(case2281), TEST_PARSER(case2282), TEST_PARSER(case2283), + TEST_PARSER(case2284), TEST_PARSER(case2285), TEST_PARSER(case2286), + TEST_PARSER(case2287), TEST_PARSER(case2288), TEST_PARSER(case2289), + TEST_PARSER(case2290), TEST_PARSER(case2291), TEST_PARSER(case2292), + TEST_PARSER(case2293), TEST_PARSER(case2294), TEST_PARSER(case2295), + TEST_PARSER(case2296), TEST_PARSER(case2297), TEST_PARSER(case2298), + TEST_PARSER(case2299), - TEST_PARSER(case2300), - TEST_PARSER(case2301), - TEST_PARSER(case2302), - TEST_PARSER(case2303), - TEST_PARSER(case2304), - TEST_PARSER(case2305), - TEST_PARSER(case2306), - TEST_PARSER(case2307), - TEST_PARSER(case2308), - TEST_PARSER(case2309), - TEST_PARSER(case2310), - TEST_PARSER(case2311), - TEST_PARSER(case2312), - TEST_PARSER(case2313), - TEST_PARSER(case2314), - TEST_PARSER(case2315), - TEST_PARSER(case2316), - TEST_PARSER(case2317), - TEST_PARSER(case2318), - TEST_PARSER(case2319), - TEST_PARSER(case2320), - TEST_PARSER(case2321), - TEST_PARSER(case2322), - TEST_PARSER(case2323), - TEST_PARSER(case2324), - TEST_PARSER(case2325), - TEST_PARSER(case2326), - TEST_PARSER(case2327), - TEST_PARSER(case2328), - TEST_PARSER(case2329), - TEST_PARSER(case2330), - TEST_PARSER(case2331), - TEST_PARSER(case2332), - TEST_PARSER(case2333), - TEST_PARSER(case2334), - TEST_PARSER(case2335), - TEST_PARSER(case2336), - TEST_PARSER(case2337), - TEST_PARSER(case2338), - TEST_PARSER(case2339), - TEST_PARSER(case2340), - TEST_PARSER(case2341), - TEST_PARSER(case2342), - TEST_PARSER(case2343), - TEST_PARSER(case2344), - TEST_PARSER(case2345), - TEST_PARSER(case2346), - TEST_PARSER(case2347), - TEST_PARSER(case2348), - TEST_PARSER(case2349), - TEST_PARSER(case2350), - TEST_PARSER(case2351), - TEST_PARSER(case2352), - TEST_PARSER(case2353), - TEST_PARSER(case2354), - TEST_PARSER(case2355), - TEST_PARSER(case2356), - TEST_PARSER(case2357), - TEST_PARSER(case2358), - TEST_PARSER(case2359), - TEST_PARSER(case2360), - TEST_PARSER(case2361), - TEST_PARSER(case2362), - TEST_PARSER(case2363), - TEST_PARSER(case2364), - TEST_PARSER(case2365), - TEST_PARSER(case2366), - TEST_PARSER(case2367), - TEST_PARSER(case2368), - TEST_PARSER(case2369), - TEST_PARSER(case2370), - TEST_PARSER(case2371), - TEST_PARSER(case2372), - TEST_PARSER(case2373), - TEST_PARSER(case2374), - TEST_PARSER(case2375), - TEST_PARSER(case2376), - TEST_PARSER(case2377), - TEST_PARSER(case2378), - TEST_PARSER(case2379), - TEST_PARSER(case2380), - TEST_PARSER(case2381), - TEST_PARSER(case2382), - TEST_PARSER(case2383), - TEST_PARSER(case2384), - TEST_PARSER(case2385), - TEST_PARSER(case2386), - TEST_PARSER(case2387), - TEST_PARSER(case2388), - TEST_PARSER(case2389), - TEST_PARSER(case2390), - TEST_PARSER(case2391), - TEST_PARSER(case2392), - TEST_PARSER(case2393), - TEST_PARSER(case2394), - TEST_PARSER(case2395), - TEST_PARSER(case2396), - TEST_PARSER(case2397), - TEST_PARSER(case2398), - TEST_PARSER(case2399), + TEST_PARSER(case2300), TEST_PARSER(case2301), TEST_PARSER(case2302), + TEST_PARSER(case2303), TEST_PARSER(case2304), TEST_PARSER(case2305), + TEST_PARSER(case2306), TEST_PARSER(case2307), TEST_PARSER(case2308), + TEST_PARSER(case2309), TEST_PARSER(case2310), TEST_PARSER(case2311), + TEST_PARSER(case2312), TEST_PARSER(case2313), TEST_PARSER(case2314), + TEST_PARSER(case2315), TEST_PARSER(case2316), TEST_PARSER(case2317), + TEST_PARSER(case2318), TEST_PARSER(case2319), TEST_PARSER(case2320), + TEST_PARSER(case2321), TEST_PARSER(case2322), TEST_PARSER(case2323), + TEST_PARSER(case2324), TEST_PARSER(case2325), TEST_PARSER(case2326), + TEST_PARSER(case2327), TEST_PARSER(case2328), TEST_PARSER(case2329), + TEST_PARSER(case2330), TEST_PARSER(case2331), TEST_PARSER(case2332), + TEST_PARSER(case2333), TEST_PARSER(case2334), TEST_PARSER(case2335), + TEST_PARSER(case2336), TEST_PARSER(case2337), TEST_PARSER(case2338), + TEST_PARSER(case2339), TEST_PARSER(case2340), TEST_PARSER(case2341), + TEST_PARSER(case2342), TEST_PARSER(case2343), TEST_PARSER(case2344), + TEST_PARSER(case2345), TEST_PARSER(case2346), TEST_PARSER(case2347), + TEST_PARSER(case2348), TEST_PARSER(case2349), TEST_PARSER(case2350), + TEST_PARSER(case2351), TEST_PARSER(case2352), TEST_PARSER(case2353), + TEST_PARSER(case2354), TEST_PARSER(case2355), TEST_PARSER(case2356), + TEST_PARSER(case2357), TEST_PARSER(case2358), TEST_PARSER(case2359), + TEST_PARSER(case2360), TEST_PARSER(case2361), TEST_PARSER(case2362), + TEST_PARSER(case2363), TEST_PARSER(case2364), TEST_PARSER(case2365), + TEST_PARSER(case2366), TEST_PARSER(case2367), TEST_PARSER(case2368), + TEST_PARSER(case2369), TEST_PARSER(case2370), TEST_PARSER(case2371), + TEST_PARSER(case2372), TEST_PARSER(case2373), TEST_PARSER(case2374), + TEST_PARSER(case2375), TEST_PARSER(case2376), TEST_PARSER(case2377), + TEST_PARSER(case2378), TEST_PARSER(case2379), TEST_PARSER(case2380), + TEST_PARSER(case2381), TEST_PARSER(case2382), TEST_PARSER(case2383), + TEST_PARSER(case2384), TEST_PARSER(case2385), TEST_PARSER(case2386), + TEST_PARSER(case2387), TEST_PARSER(case2388), TEST_PARSER(case2389), + TEST_PARSER(case2390), TEST_PARSER(case2391), TEST_PARSER(case2392), + TEST_PARSER(case2393), TEST_PARSER(case2394), TEST_PARSER(case2395), + TEST_PARSER(case2396), TEST_PARSER(case2397), TEST_PARSER(case2398), + TEST_PARSER(case2399), - TEST_PARSER(case2400), - TEST_PARSER(case2401), - TEST_PARSER(case2402), - TEST_PARSER(case2403), - TEST_PARSER(case2404), - TEST_PARSER(case2405), - TEST_PARSER(case2406), - TEST_PARSER(case2407), - TEST_PARSER(case2408), - TEST_PARSER(case2409), - TEST_PARSER(case2410), - TEST_PARSER(case2411), - TEST_PARSER(case2412), - TEST_PARSER(case2413), - TEST_PARSER(case2414), - TEST_PARSER(case2415), - TEST_PARSER(case2416), - TEST_PARSER(case2417), - TEST_PARSER(case2418), - TEST_PARSER(case2419), - TEST_PARSER(case2420), - TEST_PARSER(case2421), - TEST_PARSER(case2422), - TEST_PARSER(case2423), - TEST_PARSER(case2424), - TEST_PARSER(case2425), - TEST_PARSER(case2426), - TEST_PARSER(case2427), - TEST_PARSER(case2428), - TEST_PARSER(case2429), - TEST_PARSER(case2430), - TEST_PARSER(case2431), - TEST_PARSER(case2432), - TEST_PARSER(case2433), - TEST_PARSER(case2434), - TEST_PARSER(case2435), - TEST_PARSER(case2436), - TEST_PARSER(case2437), - TEST_PARSER(case2438), - TEST_PARSER(case2439), - TEST_PARSER(case2440), - TEST_PARSER(case2441), - TEST_PARSER(case2442), - TEST_PARSER(case2443), - TEST_PARSER(case2444), - TEST_PARSER(case2445), - TEST_PARSER(case2446), - TEST_PARSER(case2447), - TEST_PARSER(case2448), - TEST_PARSER(case2449), - TEST_PARSER(case2450), - TEST_PARSER(case2451), - TEST_PARSER(case2452), - TEST_PARSER(case2453), - TEST_PARSER(case2454), - TEST_PARSER(case2455), - TEST_PARSER(case2456), - TEST_PARSER(case2457), - TEST_PARSER(case2458), - TEST_PARSER(case2459), - TEST_PARSER(case2460), - TEST_PARSER(case2461), - TEST_PARSER(case2462), - TEST_PARSER(case2463), - TEST_PARSER(case2464), - TEST_PARSER(case2465), - TEST_PARSER(case2466), - TEST_PARSER(case2467), - TEST_PARSER(case2468), - TEST_PARSER(case2469), - TEST_PARSER(case2470), - TEST_PARSER(case2471), - TEST_PARSER(case2472), - TEST_PARSER(case2473), - TEST_PARSER(case2474), - TEST_PARSER(case2475), - TEST_PARSER(case2476), - TEST_PARSER(case2477), - TEST_PARSER(case2478), - TEST_PARSER(case2479), - TEST_PARSER(case2480), - TEST_PARSER(case2481), - TEST_PARSER(case2482), - TEST_PARSER(case2483), - TEST_PARSER(case2484), - TEST_PARSER(case2485), - TEST_PARSER(case2486), - TEST_PARSER(case2487), - TEST_PARSER(case2488), - TEST_PARSER(case2489), - TEST_PARSER(case2490), - TEST_PARSER(case2491), - TEST_PARSER(case2492), - TEST_PARSER(case2493), - TEST_PARSER(case2494), - TEST_PARSER(case2495), - TEST_PARSER(case2496), - TEST_PARSER(case2497), - TEST_PARSER(case2498), - TEST_PARSER(case2499), + TEST_PARSER(case2400), TEST_PARSER(case2401), TEST_PARSER(case2402), + TEST_PARSER(case2403), TEST_PARSER(case2404), TEST_PARSER(case2405), + TEST_PARSER(case2406), TEST_PARSER(case2407), TEST_PARSER(case2408), + TEST_PARSER(case2409), TEST_PARSER(case2410), TEST_PARSER(case2411), + TEST_PARSER(case2412), TEST_PARSER(case2413), TEST_PARSER(case2414), + TEST_PARSER(case2415), TEST_PARSER(case2416), TEST_PARSER(case2417), + TEST_PARSER(case2418), TEST_PARSER(case2419), TEST_PARSER(case2420), + TEST_PARSER(case2421), TEST_PARSER(case2422), TEST_PARSER(case2423), + TEST_PARSER(case2424), TEST_PARSER(case2425), TEST_PARSER(case2426), + TEST_PARSER(case2427), TEST_PARSER(case2428), TEST_PARSER(case2429), + TEST_PARSER(case2430), TEST_PARSER(case2431), TEST_PARSER(case2432), + TEST_PARSER(case2433), TEST_PARSER(case2434), TEST_PARSER(case2435), + TEST_PARSER(case2436), TEST_PARSER(case2437), TEST_PARSER(case2438), + TEST_PARSER(case2439), TEST_PARSER(case2440), TEST_PARSER(case2441), + TEST_PARSER(case2442), TEST_PARSER(case2443), TEST_PARSER(case2444), + TEST_PARSER(case2445), TEST_PARSER(case2446), TEST_PARSER(case2447), + TEST_PARSER(case2448), TEST_PARSER(case2449), TEST_PARSER(case2450), + TEST_PARSER(case2451), TEST_PARSER(case2452), TEST_PARSER(case2453), + TEST_PARSER(case2454), TEST_PARSER(case2455), TEST_PARSER(case2456), + TEST_PARSER(case2457), TEST_PARSER(case2458), TEST_PARSER(case2459), + TEST_PARSER(case2460), TEST_PARSER(case2461), TEST_PARSER(case2462), + TEST_PARSER(case2463), TEST_PARSER(case2464), TEST_PARSER(case2465), + TEST_PARSER(case2466), TEST_PARSER(case2467), TEST_PARSER(case2468), + TEST_PARSER(case2469), TEST_PARSER(case2470), TEST_PARSER(case2471), + TEST_PARSER(case2472), TEST_PARSER(case2473), TEST_PARSER(case2474), + TEST_PARSER(case2475), TEST_PARSER(case2476), TEST_PARSER(case2477), + TEST_PARSER(case2478), TEST_PARSER(case2479), TEST_PARSER(case2480), + TEST_PARSER(case2481), TEST_PARSER(case2482), TEST_PARSER(case2483), + TEST_PARSER(case2484), TEST_PARSER(case2485), TEST_PARSER(case2486), + TEST_PARSER(case2487), TEST_PARSER(case2488), TEST_PARSER(case2489), + TEST_PARSER(case2490), TEST_PARSER(case2491), TEST_PARSER(case2492), + TEST_PARSER(case2493), TEST_PARSER(case2494), TEST_PARSER(case2495), + TEST_PARSER(case2496), TEST_PARSER(case2497), TEST_PARSER(case2498), + TEST_PARSER(case2499), - TEST_PARSER(case2500), - TEST_PARSER(case2501), - TEST_PARSER(case2502), - TEST_PARSER(case2503), - TEST_PARSER(case2504), - TEST_PARSER(case2505), - TEST_PARSER(case2506), - TEST_PARSER(case2507), - TEST_PARSER(case2508), - TEST_PARSER(case2509), - TEST_PARSER(case2510), - TEST_PARSER(case2511), - TEST_PARSER(case2512), - TEST_PARSER(case2513), - TEST_PARSER(case2514), - TEST_PARSER(case2515), - TEST_PARSER(case2516), - TEST_PARSER(case2517), - TEST_PARSER(case2518), - TEST_PARSER(case2519), - TEST_PARSER(case2520), - TEST_PARSER(case2521), - TEST_PARSER(case2522), - TEST_PARSER(case2523), - TEST_PARSER(case2524), - TEST_PARSER(case2525), - TEST_PARSER(case2526), - TEST_PARSER(case2527), - TEST_PARSER(case2528), - TEST_PARSER(case2529), - TEST_PARSER(case2530), - TEST_PARSER(case2531), - TEST_PARSER(case2532), - TEST_PARSER(case2533), - TEST_PARSER(case2534), - TEST_PARSER(case2535), - TEST_PARSER(case2536), - TEST_PARSER(case2537), - TEST_PARSER(case2538), - TEST_PARSER(case2539), - TEST_PARSER(case2540), - TEST_PARSER(case2541), - TEST_PARSER(case2542), - TEST_PARSER(case2543), - TEST_PARSER(case2544), - TEST_PARSER(case2545), - TEST_PARSER(case2546), - TEST_PARSER(case2547), - TEST_PARSER(case2548), - TEST_PARSER(case2549), - TEST_PARSER(case2550), - TEST_PARSER(case2551), - TEST_PARSER(case2552), - TEST_PARSER(case2553), - TEST_PARSER(case2554), - TEST_PARSER(case2555), - TEST_PARSER(case2556), - TEST_PARSER(case2557), - TEST_PARSER(case2558), - TEST_PARSER(case2559), - TEST_PARSER(case2560), - TEST_PARSER(case2561), - TEST_PARSER(case2562), - TEST_PARSER(case2563), - TEST_PARSER(case2564), - TEST_PARSER(case2565), - TEST_PARSER(case2566), - TEST_PARSER(case2567), - TEST_PARSER(case2568), - TEST_PARSER(case2569), - TEST_PARSER(case2570), - TEST_PARSER(case2571), - TEST_PARSER(case2572), - TEST_PARSER(case2573), - TEST_PARSER(case2574), - TEST_PARSER(case2575), - TEST_PARSER(case2576), - TEST_PARSER(case2577), - TEST_PARSER(case2578), - TEST_PARSER(case2579), - TEST_PARSER(case2580), - TEST_PARSER(case2581), - TEST_PARSER(case2582), - TEST_PARSER(case2583), - TEST_PARSER(case2584), - TEST_PARSER(case2585), - TEST_PARSER(case2586), - TEST_PARSER(case2587), - TEST_PARSER(case2588), - TEST_PARSER(case2589), - TEST_PARSER(case2590), - TEST_PARSER(case2591), - TEST_PARSER(case2592), - TEST_PARSER(case2593), - TEST_PARSER(case2594), - TEST_PARSER(case2595), - TEST_PARSER(case2596), - TEST_PARSER(case2597), - TEST_PARSER(case2598), - TEST_PARSER(case2599), + TEST_PARSER(case2500), TEST_PARSER(case2501), TEST_PARSER(case2502), + TEST_PARSER(case2503), TEST_PARSER(case2504), TEST_PARSER(case2505), + TEST_PARSER(case2506), TEST_PARSER(case2507), TEST_PARSER(case2508), + TEST_PARSER(case2509), TEST_PARSER(case2510), TEST_PARSER(case2511), + TEST_PARSER(case2512), TEST_PARSER(case2513), TEST_PARSER(case2514), + TEST_PARSER(case2515), TEST_PARSER(case2516), TEST_PARSER(case2517), + TEST_PARSER(case2518), TEST_PARSER(case2519), TEST_PARSER(case2520), + TEST_PARSER(case2521), TEST_PARSER(case2522), TEST_PARSER(case2523), + TEST_PARSER(case2524), TEST_PARSER(case2525), TEST_PARSER(case2526), + TEST_PARSER(case2527), TEST_PARSER(case2528), TEST_PARSER(case2529), + TEST_PARSER(case2530), TEST_PARSER(case2531), TEST_PARSER(case2532), + TEST_PARSER(case2533), TEST_PARSER(case2534), TEST_PARSER(case2535), + TEST_PARSER(case2536), TEST_PARSER(case2537), TEST_PARSER(case2538), + TEST_PARSER(case2539), TEST_PARSER(case2540), TEST_PARSER(case2541), + TEST_PARSER(case2542), TEST_PARSER(case2543), TEST_PARSER(case2544), + TEST_PARSER(case2545), TEST_PARSER(case2546), TEST_PARSER(case2547), + TEST_PARSER(case2548), TEST_PARSER(case2549), TEST_PARSER(case2550), + TEST_PARSER(case2551), TEST_PARSER(case2552), TEST_PARSER(case2553), + TEST_PARSER(case2554), TEST_PARSER(case2555), TEST_PARSER(case2556), + TEST_PARSER(case2557), TEST_PARSER(case2558), TEST_PARSER(case2559), + TEST_PARSER(case2560), TEST_PARSER(case2561), TEST_PARSER(case2562), + TEST_PARSER(case2563), TEST_PARSER(case2564), TEST_PARSER(case2565), + TEST_PARSER(case2566), TEST_PARSER(case2567), TEST_PARSER(case2568), + TEST_PARSER(case2569), TEST_PARSER(case2570), TEST_PARSER(case2571), + TEST_PARSER(case2572), TEST_PARSER(case2573), TEST_PARSER(case2574), + TEST_PARSER(case2575), TEST_PARSER(case2576), TEST_PARSER(case2577), + TEST_PARSER(case2578), TEST_PARSER(case2579), TEST_PARSER(case2580), + TEST_PARSER(case2581), TEST_PARSER(case2582), TEST_PARSER(case2583), + TEST_PARSER(case2584), TEST_PARSER(case2585), TEST_PARSER(case2586), + TEST_PARSER(case2587), TEST_PARSER(case2588), TEST_PARSER(case2589), + TEST_PARSER(case2590), TEST_PARSER(case2591), TEST_PARSER(case2592), + TEST_PARSER(case2593), TEST_PARSER(case2594), TEST_PARSER(case2595), + TEST_PARSER(case2596), TEST_PARSER(case2597), TEST_PARSER(case2598), + TEST_PARSER(case2599), - TEST_PARSER(case2600), - TEST_PARSER(case2601), - TEST_PARSER(case2602), - TEST_PARSER(case2603), - TEST_PARSER(case2604), - TEST_PARSER(case2605), - TEST_PARSER(case2606), - TEST_PARSER(case2607), - TEST_PARSER(case2608), - TEST_PARSER(case2609), - TEST_PARSER(case2610), - TEST_PARSER(case2611), - TEST_PARSER(case2612), - TEST_PARSER(case2613), - TEST_PARSER(case2614), - TEST_PARSER(case2615), - TEST_PARSER(case2616), - TEST_PARSER(case2617), - TEST_PARSER(case2618), - TEST_PARSER(case2619), - TEST_PARSER(case2620), - TEST_PARSER(case2621), - TEST_PARSER(case2622), - TEST_PARSER(case2623), - TEST_PARSER(case2624), - TEST_PARSER(case2625), - TEST_PARSER(case2626), - TEST_PARSER(case2627), - TEST_PARSER(case2628), - TEST_PARSER(case2629), - TEST_PARSER(case2630), - TEST_PARSER(case2631), - TEST_PARSER(case2632), - TEST_PARSER(case2633), - TEST_PARSER(case2634), - TEST_PARSER(case2635), - TEST_PARSER(case2636), - TEST_PARSER(case2637), - TEST_PARSER(case2638), - TEST_PARSER(case2639), - TEST_PARSER(case2640), - TEST_PARSER(case2641), - TEST_PARSER(case2642), - TEST_PARSER(case2643), - TEST_PARSER(case2644), - TEST_PARSER(case2645), - TEST_PARSER(case2646), - TEST_PARSER(case2647), - TEST_PARSER(case2648), - TEST_PARSER(case2649), - TEST_PARSER(case2650), - TEST_PARSER(case2651), - TEST_PARSER(case2652), - TEST_PARSER(case2653), - TEST_PARSER(case2654), - TEST_PARSER(case2655), - TEST_PARSER(case2656), - TEST_PARSER(case2657), - TEST_PARSER(case2658), - TEST_PARSER(case2659), - TEST_PARSER(case2660), - TEST_PARSER(case2661), - TEST_PARSER(case2662), - TEST_PARSER(case2663), - TEST_PARSER(case2664), - TEST_PARSER(case2665), - TEST_PARSER(case2666), - TEST_PARSER(case2667), - TEST_PARSER(case2668), - TEST_PARSER(case2669), - TEST_PARSER(case2670), - TEST_PARSER(case2671), - TEST_PARSER(case2672), - TEST_PARSER(case2673), - TEST_PARSER(case2674), - TEST_PARSER(case2675), - TEST_PARSER(case2676), - TEST_PARSER(case2677), - TEST_PARSER(case2678), - TEST_PARSER(case2679), - TEST_PARSER(case2680), - TEST_PARSER(case2681), - TEST_PARSER(case2682), - TEST_PARSER(case2683), - TEST_PARSER(case2684), - TEST_PARSER(case2685), - TEST_PARSER(case2686), - TEST_PARSER(case2687), - TEST_PARSER(case2688), - TEST_PARSER(case2689), - TEST_PARSER(case2690), - TEST_PARSER(case2691), - TEST_PARSER(case2692), - TEST_PARSER(case2693), - TEST_PARSER(case2694), - TEST_PARSER(case2695), - TEST_PARSER(case2696), - TEST_PARSER(case2697), - TEST_PARSER(case2698), - TEST_PARSER(case2699), + TEST_PARSER(case2600), TEST_PARSER(case2601), TEST_PARSER(case2602), + TEST_PARSER(case2603), TEST_PARSER(case2604), TEST_PARSER(case2605), + TEST_PARSER(case2606), TEST_PARSER(case2607), TEST_PARSER(case2608), + TEST_PARSER(case2609), TEST_PARSER(case2610), TEST_PARSER(case2611), + TEST_PARSER(case2612), TEST_PARSER(case2613), TEST_PARSER(case2614), + TEST_PARSER(case2615), TEST_PARSER(case2616), TEST_PARSER(case2617), + TEST_PARSER(case2618), TEST_PARSER(case2619), TEST_PARSER(case2620), + TEST_PARSER(case2621), TEST_PARSER(case2622), TEST_PARSER(case2623), + TEST_PARSER(case2624), TEST_PARSER(case2625), TEST_PARSER(case2626), + TEST_PARSER(case2627), TEST_PARSER(case2628), TEST_PARSER(case2629), + TEST_PARSER(case2630), TEST_PARSER(case2631), TEST_PARSER(case2632), + TEST_PARSER(case2633), TEST_PARSER(case2634), TEST_PARSER(case2635), + TEST_PARSER(case2636), TEST_PARSER(case2637), TEST_PARSER(case2638), + TEST_PARSER(case2639), TEST_PARSER(case2640), TEST_PARSER(case2641), + TEST_PARSER(case2642), TEST_PARSER(case2643), TEST_PARSER(case2644), + TEST_PARSER(case2645), TEST_PARSER(case2646), TEST_PARSER(case2647), + TEST_PARSER(case2648), TEST_PARSER(case2649), TEST_PARSER(case2650), + TEST_PARSER(case2651), TEST_PARSER(case2652), TEST_PARSER(case2653), + TEST_PARSER(case2654), TEST_PARSER(case2655), TEST_PARSER(case2656), + TEST_PARSER(case2657), TEST_PARSER(case2658), TEST_PARSER(case2659), + TEST_PARSER(case2660), TEST_PARSER(case2661), TEST_PARSER(case2662), + TEST_PARSER(case2663), TEST_PARSER(case2664), TEST_PARSER(case2665), + TEST_PARSER(case2666), TEST_PARSER(case2667), TEST_PARSER(case2668), + TEST_PARSER(case2669), TEST_PARSER(case2670), TEST_PARSER(case2671), + TEST_PARSER(case2672), TEST_PARSER(case2673), TEST_PARSER(case2674), + TEST_PARSER(case2675), TEST_PARSER(case2676), TEST_PARSER(case2677), + TEST_PARSER(case2678), TEST_PARSER(case2679), TEST_PARSER(case2680), + TEST_PARSER(case2681), TEST_PARSER(case2682), TEST_PARSER(case2683), + TEST_PARSER(case2684), TEST_PARSER(case2685), TEST_PARSER(case2686), + TEST_PARSER(case2687), TEST_PARSER(case2688), TEST_PARSER(case2689), + TEST_PARSER(case2690), TEST_PARSER(case2691), TEST_PARSER(case2692), + TEST_PARSER(case2693), TEST_PARSER(case2694), TEST_PARSER(case2695), + TEST_PARSER(case2696), TEST_PARSER(case2697), TEST_PARSER(case2698), + TEST_PARSER(case2699), - TEST_PARSER(case2700), - TEST_PARSER(case2701), - TEST_PARSER(case2702), - TEST_PARSER(case2703), - TEST_PARSER(case2704), - TEST_PARSER(case2705), - TEST_PARSER(case2706), - TEST_PARSER(case2707), - TEST_PARSER(case2708), - TEST_PARSER(case2709), - TEST_PARSER(case2710), - TEST_PARSER(case2711), - TEST_PARSER(case2712), - TEST_PARSER(case2713), - TEST_PARSER(case2714), - TEST_PARSER(case2715), - TEST_PARSER(case2716), - TEST_PARSER(case2717), - TEST_PARSER(case2718), - TEST_PARSER(case2719), - TEST_PARSER(case2720), - TEST_PARSER(case2721), - TEST_PARSER(case2722), - TEST_PARSER(case2723), - TEST_PARSER(case2724), - TEST_PARSER(case2725), - TEST_PARSER(case2726), - TEST_PARSER(case2727), - TEST_PARSER(case2728), - TEST_PARSER(case2729), - TEST_PARSER(case2730), - TEST_PARSER(case2731), - TEST_PARSER(case2732), - TEST_PARSER(case2733), - TEST_PARSER(case2734), - TEST_PARSER(case2735), - TEST_PARSER(case2736), - TEST_PARSER(case2737), - TEST_PARSER(case2738), - TEST_PARSER(case2739), - TEST_PARSER(case2740), - TEST_PARSER(case2741), - TEST_PARSER(case2742), - TEST_PARSER(case2743), - TEST_PARSER(case2744), - TEST_PARSER(case2745), - TEST_PARSER(case2746), - TEST_PARSER(case2747), - TEST_PARSER(case2748), - TEST_PARSER(case2749), - TEST_PARSER(case2750), - TEST_PARSER(case2751), - TEST_PARSER(case2752), - TEST_PARSER(case2753), - TEST_PARSER(case2754), - TEST_PARSER(case2755), - TEST_PARSER(case2756), - TEST_PARSER(case2757), - TEST_PARSER(case2758), - TEST_PARSER(case2759), - TEST_PARSER(case2760), - TEST_PARSER(case2761), - TEST_PARSER(case2762), - TEST_PARSER(case2763), - TEST_PARSER(case2764), - TEST_PARSER(case2765), - TEST_PARSER(case2766), - TEST_PARSER(case2767), - TEST_PARSER(case2768), - TEST_PARSER(case2769), - TEST_PARSER(case2770), - TEST_PARSER(case2771), - TEST_PARSER(case2772), - TEST_PARSER(case2773), - TEST_PARSER(case2774), - TEST_PARSER(case2775), - TEST_PARSER(case2776), - TEST_PARSER(case2777), - TEST_PARSER(case2778), - TEST_PARSER(case2779), - TEST_PARSER(case2780), - TEST_PARSER(case2781), - TEST_PARSER(case2782), - TEST_PARSER(case2783), - TEST_PARSER(case2784), - TEST_PARSER(case2785), - TEST_PARSER(case2786), - TEST_PARSER(case2787), - TEST_PARSER(case2788), - TEST_PARSER(case2789), - TEST_PARSER(case2790), - TEST_PARSER(case2791), - TEST_PARSER(case2792), - TEST_PARSER(case2793), - TEST_PARSER(case2794), - TEST_PARSER(case2795), - TEST_PARSER(case2796), - TEST_PARSER(case2797), - TEST_PARSER(case2798), - TEST_PARSER(case2799), + TEST_PARSER(case2700), TEST_PARSER(case2701), TEST_PARSER(case2702), + TEST_PARSER(case2703), TEST_PARSER(case2704), TEST_PARSER(case2705), + TEST_PARSER(case2706), TEST_PARSER(case2707), TEST_PARSER(case2708), + TEST_PARSER(case2709), TEST_PARSER(case2710), TEST_PARSER(case2711), + TEST_PARSER(case2712), TEST_PARSER(case2713), TEST_PARSER(case2714), + TEST_PARSER(case2715), TEST_PARSER(case2716), TEST_PARSER(case2717), + TEST_PARSER(case2718), TEST_PARSER(case2719), TEST_PARSER(case2720), + TEST_PARSER(case2721), TEST_PARSER(case2722), TEST_PARSER(case2723), + TEST_PARSER(case2724), TEST_PARSER(case2725), TEST_PARSER(case2726), + TEST_PARSER(case2727), TEST_PARSER(case2728), TEST_PARSER(case2729), + TEST_PARSER(case2730), TEST_PARSER(case2731), TEST_PARSER(case2732), + TEST_PARSER(case2733), TEST_PARSER(case2734), TEST_PARSER(case2735), + TEST_PARSER(case2736), TEST_PARSER(case2737), TEST_PARSER(case2738), + TEST_PARSER(case2739), TEST_PARSER(case2740), TEST_PARSER(case2741), + TEST_PARSER(case2742), TEST_PARSER(case2743), TEST_PARSER(case2744), + TEST_PARSER(case2745), TEST_PARSER(case2746), TEST_PARSER(case2747), + TEST_PARSER(case2748), TEST_PARSER(case2749), TEST_PARSER(case2750), + TEST_PARSER(case2751), TEST_PARSER(case2752), TEST_PARSER(case2753), + TEST_PARSER(case2754), TEST_PARSER(case2755), TEST_PARSER(case2756), + TEST_PARSER(case2757), TEST_PARSER(case2758), TEST_PARSER(case2759), + TEST_PARSER(case2760), TEST_PARSER(case2761), TEST_PARSER(case2762), + TEST_PARSER(case2763), TEST_PARSER(case2764), TEST_PARSER(case2765), + TEST_PARSER(case2766), TEST_PARSER(case2767), TEST_PARSER(case2768), + TEST_PARSER(case2769), TEST_PARSER(case2770), TEST_PARSER(case2771), + TEST_PARSER(case2772), TEST_PARSER(case2773), TEST_PARSER(case2774), + TEST_PARSER(case2775), TEST_PARSER(case2776), TEST_PARSER(case2777), + TEST_PARSER(case2778), TEST_PARSER(case2779), TEST_PARSER(case2780), + TEST_PARSER(case2781), TEST_PARSER(case2782), TEST_PARSER(case2783), + TEST_PARSER(case2784), TEST_PARSER(case2785), TEST_PARSER(case2786), + TEST_PARSER(case2787), TEST_PARSER(case2788), TEST_PARSER(case2789), + TEST_PARSER(case2790), TEST_PARSER(case2791), TEST_PARSER(case2792), + TEST_PARSER(case2793), TEST_PARSER(case2794), TEST_PARSER(case2795), + TEST_PARSER(case2796), TEST_PARSER(case2797), TEST_PARSER(case2798), + TEST_PARSER(case2799), - TEST_PARSER(case2800), - TEST_PARSER(case2801), - TEST_PARSER(case2802), - TEST_PARSER(case2803), - TEST_PARSER(case2804), - TEST_PARSER(case2805), - TEST_PARSER(case2806), - TEST_PARSER(case2807), - TEST_PARSER(case2808), - TEST_PARSER(case2809), - TEST_PARSER(case2810), - TEST_PARSER(case2811), - TEST_PARSER(case2812), - TEST_PARSER(case2813), - TEST_PARSER(case2814), - TEST_PARSER(case2815), - TEST_PARSER(case2816), - TEST_PARSER(case2817), - TEST_PARSER(case2818), - TEST_PARSER(case2819), - TEST_PARSER(case2820), - TEST_PARSER(case2821), - TEST_PARSER(case2822), - TEST_PARSER(case2823), - TEST_PARSER(case2824), - TEST_PARSER(case2825), - TEST_PARSER(case2826), - TEST_PARSER(case2827), - TEST_PARSER(case2828), - TEST_PARSER(case2829), - TEST_PARSER(case2830), - TEST_PARSER(case2831), - TEST_PARSER(case2832), - TEST_PARSER(case2833), - TEST_PARSER(case2834), - TEST_PARSER(case2835), - TEST_PARSER(case2836), - TEST_PARSER(case2837), - TEST_PARSER(case2838), - TEST_PARSER(case2839), - TEST_PARSER(case2840), - TEST_PARSER(case2841), - TEST_PARSER(case2842), - TEST_PARSER(case2843), - TEST_PARSER(case2844), - TEST_PARSER(case2845), - TEST_PARSER(case2846), - TEST_PARSER(case2847), - TEST_PARSER(case2848), - TEST_PARSER(case2849), - TEST_PARSER(case2850), - TEST_PARSER(case2851), - TEST_PARSER(case2852), - TEST_PARSER(case2853), - TEST_PARSER(case2854), - TEST_PARSER(case2855), - TEST_PARSER(case2856), - TEST_PARSER(case2857), - TEST_PARSER(case2858), - TEST_PARSER(case2859), - TEST_PARSER(case2860), - TEST_PARSER(case2861), - TEST_PARSER(case2862), - TEST_PARSER(case2863), - TEST_PARSER(case2864), - TEST_PARSER(case2865), - TEST_PARSER(case2866), - TEST_PARSER(case2867), - TEST_PARSER(case2868), - TEST_PARSER(case2869), - TEST_PARSER(case2870), - TEST_PARSER(case2871), - TEST_PARSER(case2872), - TEST_PARSER(case2873), - TEST_PARSER(case2874), - TEST_PARSER(case2875), - TEST_PARSER(case2876), - TEST_PARSER(case2877), - TEST_PARSER(case2878), - TEST_PARSER(case2879), - TEST_PARSER(case2880), - TEST_PARSER(case2881), - TEST_PARSER(case2882), - TEST_PARSER(case2883), - TEST_PARSER(case2884), - TEST_PARSER(case2885), - TEST_PARSER(case2886), - TEST_PARSER(case2887), - TEST_PARSER(case2888), - TEST_PARSER(case2889), - TEST_PARSER(case2890), - TEST_PARSER(case2891), - TEST_PARSER(case2892), - TEST_PARSER(case2893), - TEST_PARSER(case2894), - TEST_PARSER(case2895), - TEST_PARSER(case2896), - TEST_PARSER(case2897), - TEST_PARSER(case2898), - TEST_PARSER(case2899), + TEST_PARSER(case2800), TEST_PARSER(case2801), TEST_PARSER(case2802), + TEST_PARSER(case2803), TEST_PARSER(case2804), TEST_PARSER(case2805), + TEST_PARSER(case2806), TEST_PARSER(case2807), TEST_PARSER(case2808), + TEST_PARSER(case2809), TEST_PARSER(case2810), TEST_PARSER(case2811), + TEST_PARSER(case2812), TEST_PARSER(case2813), TEST_PARSER(case2814), + TEST_PARSER(case2815), TEST_PARSER(case2816), TEST_PARSER(case2817), + TEST_PARSER(case2818), TEST_PARSER(case2819), TEST_PARSER(case2820), + TEST_PARSER(case2821), TEST_PARSER(case2822), TEST_PARSER(case2823), + TEST_PARSER(case2824), TEST_PARSER(case2825), TEST_PARSER(case2826), + TEST_PARSER(case2827), TEST_PARSER(case2828), TEST_PARSER(case2829), + TEST_PARSER(case2830), TEST_PARSER(case2831), TEST_PARSER(case2832), + TEST_PARSER(case2833), TEST_PARSER(case2834), TEST_PARSER(case2835), + TEST_PARSER(case2836), TEST_PARSER(case2837), TEST_PARSER(case2838), + TEST_PARSER(case2839), TEST_PARSER(case2840), TEST_PARSER(case2841), + TEST_PARSER(case2842), TEST_PARSER(case2843), TEST_PARSER(case2844), + TEST_PARSER(case2845), TEST_PARSER(case2846), TEST_PARSER(case2847), + TEST_PARSER(case2848), TEST_PARSER(case2849), TEST_PARSER(case2850), + TEST_PARSER(case2851), TEST_PARSER(case2852), TEST_PARSER(case2853), + TEST_PARSER(case2854), TEST_PARSER(case2855), TEST_PARSER(case2856), + TEST_PARSER(case2857), TEST_PARSER(case2858), TEST_PARSER(case2859), + TEST_PARSER(case2860), TEST_PARSER(case2861), TEST_PARSER(case2862), + TEST_PARSER(case2863), TEST_PARSER(case2864), TEST_PARSER(case2865), + TEST_PARSER(case2866), TEST_PARSER(case2867), TEST_PARSER(case2868), + TEST_PARSER(case2869), TEST_PARSER(case2870), TEST_PARSER(case2871), + TEST_PARSER(case2872), TEST_PARSER(case2873), TEST_PARSER(case2874), + TEST_PARSER(case2875), TEST_PARSER(case2876), TEST_PARSER(case2877), + TEST_PARSER(case2878), TEST_PARSER(case2879), TEST_PARSER(case2880), + TEST_PARSER(case2881), TEST_PARSER(case2882), TEST_PARSER(case2883), + TEST_PARSER(case2884), TEST_PARSER(case2885), TEST_PARSER(case2886), + TEST_PARSER(case2887), TEST_PARSER(case2888), TEST_PARSER(case2889), + TEST_PARSER(case2890), TEST_PARSER(case2891), TEST_PARSER(case2892), + TEST_PARSER(case2893), TEST_PARSER(case2894), TEST_PARSER(case2895), + TEST_PARSER(case2896), TEST_PARSER(case2897), TEST_PARSER(case2898), + TEST_PARSER(case2899), - TEST_PARSER(case2900), - TEST_PARSER(case2901), - TEST_PARSER(case2902), - TEST_PARSER(case2903), - TEST_PARSER(case2904), - TEST_PARSER(case2905), - TEST_PARSER(case2906), - TEST_PARSER(case2907), - TEST_PARSER(case2908), - TEST_PARSER(case2909), - TEST_PARSER(case2910), - TEST_PARSER(case2911), - TEST_PARSER(case2912), - TEST_PARSER(case2913), - TEST_PARSER(case2914), - TEST_PARSER(case2915), - TEST_PARSER(case2916), - TEST_PARSER(case2917), - TEST_PARSER(case2918), - TEST_PARSER(case2919), - TEST_PARSER(case2920), - TEST_PARSER(case2921), - TEST_PARSER(case2922), - TEST_PARSER(case2923), - TEST_PARSER(case2924), - TEST_PARSER(case2925), - TEST_PARSER(case2926), - TEST_PARSER(case2927), - TEST_PARSER(case2928), - TEST_PARSER(case2929), - TEST_PARSER(case2930), - TEST_PARSER(case2931), - TEST_PARSER(case2932), - TEST_PARSER(case2933), - TEST_PARSER(case2934), - TEST_PARSER(case2935), - TEST_PARSER(case2936), - TEST_PARSER(case2937), - TEST_PARSER(case2938), - TEST_PARSER(case2939), - TEST_PARSER(case2940), - TEST_PARSER(case2941), - TEST_PARSER(case2942), - TEST_PARSER(case2943), - TEST_PARSER(case2944), - TEST_PARSER(case2945), - TEST_PARSER(case2946), - TEST_PARSER(case2947), - TEST_PARSER(case2948), - TEST_PARSER(case2949), - TEST_PARSER(case2950), - TEST_PARSER(case2951), - TEST_PARSER(case2952), - TEST_PARSER(case2953), - TEST_PARSER(case2954), - TEST_PARSER(case2955), - TEST_PARSER(case2956), - TEST_PARSER(case2957), - TEST_PARSER(case2958), - TEST_PARSER(case2959), - TEST_PARSER(case2960), - TEST_PARSER(case2961), - TEST_PARSER(case2962), - TEST_PARSER(case2963), - TEST_PARSER(case2964), - TEST_PARSER(case2965), - TEST_PARSER(case2966), - TEST_PARSER(case2967), - TEST_PARSER(case2968), - TEST_PARSER(case2969), - TEST_PARSER(case2970), - TEST_PARSER(case2971), - TEST_PARSER(case2972), - TEST_PARSER(case2973), - TEST_PARSER(case2974), - TEST_PARSER(case2975), - TEST_PARSER(case2976), - TEST_PARSER(case2977), - TEST_PARSER(case2978), - TEST_PARSER(case2979), - TEST_PARSER(case2980), - TEST_PARSER(case2981), - TEST_PARSER(case2982), - TEST_PARSER(case2983), - TEST_PARSER(case2984), - TEST_PARSER(case2985), - TEST_PARSER(case2986), - TEST_PARSER(case2987), - TEST_PARSER(case2988), - TEST_PARSER(case2989), - TEST_PARSER(case2990), - TEST_PARSER(case2991), - TEST_PARSER(case2992), - TEST_PARSER(case2993), - TEST_PARSER(case2994), - TEST_PARSER(case2995), - TEST_PARSER(case2996), - TEST_PARSER(case2997), - TEST_PARSER(case2998), - TEST_PARSER(case2999), + TEST_PARSER(case2900), TEST_PARSER(case2901), TEST_PARSER(case2902), + TEST_PARSER(case2903), TEST_PARSER(case2904), TEST_PARSER(case2905), + TEST_PARSER(case2906), TEST_PARSER(case2907), TEST_PARSER(case2908), + TEST_PARSER(case2909), TEST_PARSER(case2910), TEST_PARSER(case2911), + TEST_PARSER(case2912), TEST_PARSER(case2913), TEST_PARSER(case2914), + TEST_PARSER(case2915), TEST_PARSER(case2916), TEST_PARSER(case2917), + TEST_PARSER(case2918), TEST_PARSER(case2919), TEST_PARSER(case2920), + TEST_PARSER(case2921), TEST_PARSER(case2922), TEST_PARSER(case2923), + TEST_PARSER(case2924), TEST_PARSER(case2925), TEST_PARSER(case2926), + TEST_PARSER(case2927), TEST_PARSER(case2928), TEST_PARSER(case2929), + TEST_PARSER(case2930), TEST_PARSER(case2931), TEST_PARSER(case2932), + TEST_PARSER(case2933), TEST_PARSER(case2934), TEST_PARSER(case2935), + TEST_PARSER(case2936), TEST_PARSER(case2937), TEST_PARSER(case2938), + TEST_PARSER(case2939), TEST_PARSER(case2940), TEST_PARSER(case2941), + TEST_PARSER(case2942), TEST_PARSER(case2943), TEST_PARSER(case2944), + TEST_PARSER(case2945), TEST_PARSER(case2946), TEST_PARSER(case2947), + TEST_PARSER(case2948), TEST_PARSER(case2949), TEST_PARSER(case2950), + TEST_PARSER(case2951), TEST_PARSER(case2952), TEST_PARSER(case2953), + TEST_PARSER(case2954), TEST_PARSER(case2955), TEST_PARSER(case2956), + TEST_PARSER(case2957), TEST_PARSER(case2958), TEST_PARSER(case2959), + TEST_PARSER(case2960), TEST_PARSER(case2961), TEST_PARSER(case2962), + TEST_PARSER(case2963), TEST_PARSER(case2964), TEST_PARSER(case2965), + TEST_PARSER(case2966), TEST_PARSER(case2967), TEST_PARSER(case2968), + TEST_PARSER(case2969), TEST_PARSER(case2970), TEST_PARSER(case2971), + TEST_PARSER(case2972), TEST_PARSER(case2973), TEST_PARSER(case2974), + TEST_PARSER(case2975), TEST_PARSER(case2976), TEST_PARSER(case2977), + TEST_PARSER(case2978), TEST_PARSER(case2979), TEST_PARSER(case2980), + TEST_PARSER(case2981), TEST_PARSER(case2982), TEST_PARSER(case2983), + TEST_PARSER(case2984), TEST_PARSER(case2985), TEST_PARSER(case2986), + TEST_PARSER(case2987), TEST_PARSER(case2988), TEST_PARSER(case2989), + TEST_PARSER(case2990), TEST_PARSER(case2991), TEST_PARSER(case2992), + TEST_PARSER(case2993), TEST_PARSER(case2994), TEST_PARSER(case2995), + TEST_PARSER(case2996), TEST_PARSER(case2997), TEST_PARSER(case2998), + TEST_PARSER(case2999), - TEST_PARSER(case3000), - TEST_PARSER(case3001), - TEST_PARSER(case3002), - TEST_PARSER(case3003), - TEST_PARSER(case3004), - TEST_PARSER(case3005), - TEST_PARSER(case3006), - TEST_PARSER(case3007), - TEST_PARSER(case3008), - TEST_PARSER(case3009), - TEST_PARSER(case3010), - TEST_PARSER(case3011), - TEST_PARSER(case3012), - TEST_PARSER(case3013), - TEST_PARSER(case3014), - TEST_PARSER(case3015), - TEST_PARSER(case3016), - TEST_PARSER(case3017), - TEST_PARSER(case3018), - TEST_PARSER(case3019), - TEST_PARSER(case3020), - TEST_PARSER(case3021), - TEST_PARSER(case3022), - TEST_PARSER(case3023), - TEST_PARSER(case3024), - TEST_PARSER(case3025), - TEST_PARSER(case3026), - TEST_PARSER(case3027), - TEST_PARSER(case3028), - TEST_PARSER(case3029), - TEST_PARSER(case3030), - TEST_PARSER(case3031), - TEST_PARSER(case3032), - TEST_PARSER(case3033), - TEST_PARSER(case3034), - TEST_PARSER(case3035), - TEST_PARSER(case3036), - TEST_PARSER(case3037), - TEST_PARSER(case3038), - TEST_PARSER(case3039), - TEST_PARSER(case3040), - TEST_PARSER(case3041), - TEST_PARSER(case3042), - TEST_PARSER(case3043), - TEST_PARSER(case3044), - TEST_PARSER(case3045), - TEST_PARSER(case3046), - TEST_PARSER(case3047), - TEST_PARSER(case3048), - TEST_PARSER(case3049), - TEST_PARSER(case3050), - TEST_PARSER(case3051), - TEST_PARSER(case3052), - TEST_PARSER(case3053), - TEST_PARSER(case3054), - TEST_PARSER(case3055), - TEST_PARSER(case3056), - TEST_PARSER(case3057), - TEST_PARSER(case3058), - TEST_PARSER(case3059), - TEST_PARSER(case3060), - TEST_PARSER(case3061), - TEST_PARSER(case3062), - TEST_PARSER(case3063), - TEST_PARSER(case3064), - TEST_PARSER(case3065), - TEST_PARSER(case3066), - TEST_PARSER(case3067), - TEST_PARSER(case3068), - TEST_PARSER(case3069), - TEST_PARSER(case3070), - TEST_PARSER(case3071), - TEST_PARSER(case3072), - TEST_PARSER(case3073), - TEST_PARSER(case3074), - TEST_PARSER(case3075), - TEST_PARSER(case3076), - TEST_PARSER(case3077), - TEST_PARSER(case3078), - TEST_PARSER(case3079), - TEST_PARSER(case3080), - TEST_PARSER(case3081), - TEST_PARSER(case3082), - TEST_PARSER(case3083), - TEST_PARSER(case3084), - TEST_PARSER(case3085), - TEST_PARSER(case3086), - TEST_PARSER(case3087), - TEST_PARSER(case3088), - TEST_PARSER(case3089), - TEST_PARSER(case3090), - TEST_PARSER(case3091), - TEST_PARSER(case3092), - TEST_PARSER(case3093), - TEST_PARSER(case3094), - TEST_PARSER(case3095), - TEST_PARSER(case3096), - TEST_PARSER(case3097), - TEST_PARSER(case3098), - TEST_PARSER(case3099), + TEST_PARSER(case3000), TEST_PARSER(case3001), TEST_PARSER(case3002), + TEST_PARSER(case3003), TEST_PARSER(case3004), TEST_PARSER(case3005), + TEST_PARSER(case3006), TEST_PARSER(case3007), TEST_PARSER(case3008), + TEST_PARSER(case3009), TEST_PARSER(case3010), TEST_PARSER(case3011), + TEST_PARSER(case3012), TEST_PARSER(case3013), TEST_PARSER(case3014), + TEST_PARSER(case3015), TEST_PARSER(case3016), TEST_PARSER(case3017), + TEST_PARSER(case3018), TEST_PARSER(case3019), TEST_PARSER(case3020), + TEST_PARSER(case3021), TEST_PARSER(case3022), TEST_PARSER(case3023), + TEST_PARSER(case3024), TEST_PARSER(case3025), TEST_PARSER(case3026), + TEST_PARSER(case3027), TEST_PARSER(case3028), TEST_PARSER(case3029), + TEST_PARSER(case3030), TEST_PARSER(case3031), TEST_PARSER(case3032), + TEST_PARSER(case3033), TEST_PARSER(case3034), TEST_PARSER(case3035), + TEST_PARSER(case3036), TEST_PARSER(case3037), TEST_PARSER(case3038), + TEST_PARSER(case3039), TEST_PARSER(case3040), TEST_PARSER(case3041), + TEST_PARSER(case3042), TEST_PARSER(case3043), TEST_PARSER(case3044), + TEST_PARSER(case3045), TEST_PARSER(case3046), TEST_PARSER(case3047), + TEST_PARSER(case3048), TEST_PARSER(case3049), TEST_PARSER(case3050), + TEST_PARSER(case3051), TEST_PARSER(case3052), TEST_PARSER(case3053), + TEST_PARSER(case3054), TEST_PARSER(case3055), TEST_PARSER(case3056), + TEST_PARSER(case3057), TEST_PARSER(case3058), TEST_PARSER(case3059), + TEST_PARSER(case3060), TEST_PARSER(case3061), TEST_PARSER(case3062), + TEST_PARSER(case3063), TEST_PARSER(case3064), TEST_PARSER(case3065), + TEST_PARSER(case3066), TEST_PARSER(case3067), TEST_PARSER(case3068), + TEST_PARSER(case3069), TEST_PARSER(case3070), TEST_PARSER(case3071), + TEST_PARSER(case3072), TEST_PARSER(case3073), TEST_PARSER(case3074), + TEST_PARSER(case3075), TEST_PARSER(case3076), TEST_PARSER(case3077), + TEST_PARSER(case3078), TEST_PARSER(case3079), TEST_PARSER(case3080), + TEST_PARSER(case3081), TEST_PARSER(case3082), TEST_PARSER(case3083), + TEST_PARSER(case3084), TEST_PARSER(case3085), TEST_PARSER(case3086), + TEST_PARSER(case3087), TEST_PARSER(case3088), TEST_PARSER(case3089), + TEST_PARSER(case3090), TEST_PARSER(case3091), TEST_PARSER(case3092), + TEST_PARSER(case3093), TEST_PARSER(case3094), TEST_PARSER(case3095), + TEST_PARSER(case3096), TEST_PARSER(case3097), TEST_PARSER(case3098), + TEST_PARSER(case3099), - TEST_PARSER(case3100), - TEST_PARSER(case3101), - TEST_PARSER(case3102), - TEST_PARSER(case3103), - TEST_PARSER(case3104), - TEST_PARSER(case3105), - TEST_PARSER(case3106), - TEST_PARSER(case3107), - TEST_PARSER(case3108), - TEST_PARSER(case3109), - TEST_PARSER(case3110), - TEST_PARSER(case3111), - TEST_PARSER(case3112), - TEST_PARSER(case3113), - TEST_PARSER(case3114), - TEST_PARSER(case3115), - TEST_PARSER(case3116), - TEST_PARSER(case3117), - TEST_PARSER(case3118), - TEST_PARSER(case3119), - TEST_PARSER(case3120), - TEST_PARSER(case3121), - TEST_PARSER(case3122), - TEST_PARSER(case3123), - TEST_PARSER(case3124), - TEST_PARSER(case3125), - TEST_PARSER(case3126), - TEST_PARSER(case3127), - TEST_PARSER(case3128), - TEST_PARSER(case3129), - TEST_PARSER(case3130), - TEST_PARSER(case3131), - TEST_PARSER(case3132), - TEST_PARSER(case3133), - TEST_PARSER(case3134), - TEST_PARSER(case3135), - TEST_PARSER(case3136), - TEST_PARSER(case3137), - TEST_PARSER(case3138), - TEST_PARSER(case3139), - TEST_PARSER(case3140), - TEST_PARSER(case3141), - TEST_PARSER(case3142), - TEST_PARSER(case3143), - TEST_PARSER(case3144), - TEST_PARSER(case3145), - TEST_PARSER(case3146), - TEST_PARSER(case3147), - TEST_PARSER(case3148), - TEST_PARSER(case3149), - TEST_PARSER(case3150), - TEST_PARSER(case3151), - TEST_PARSER(case3152), - TEST_PARSER(case3153), - TEST_PARSER(case3154), - TEST_PARSER(case3155), - TEST_PARSER(case3156), - TEST_PARSER(case3157), - TEST_PARSER(case3158), - TEST_PARSER(case3159), - TEST_PARSER(case3160), - TEST_PARSER(case3161), - TEST_PARSER(case3162), - TEST_PARSER(case3163), - TEST_PARSER(case3164), - TEST_PARSER(case3165), - TEST_PARSER(case3166), - TEST_PARSER(case3167), - TEST_PARSER(case3168), - TEST_PARSER(case3169), - TEST_PARSER(case3170), - TEST_PARSER(case3171), - TEST_PARSER(case3172), - TEST_PARSER(case3173), - TEST_PARSER(case3174), - TEST_PARSER(case3175), - TEST_PARSER(case3176), - TEST_PARSER(case3177), - TEST_PARSER(case3178), - TEST_PARSER(case3179), - TEST_PARSER(case3180), - TEST_PARSER(case3181), - TEST_PARSER(case3182), - TEST_PARSER(case3183), - TEST_PARSER(case3184), - TEST_PARSER(case3185), - TEST_PARSER(case3186), - TEST_PARSER(case3187), - TEST_PARSER(case3188), - TEST_PARSER(case3189), - TEST_PARSER(case3190), - TEST_PARSER(case3191), - TEST_PARSER(case3192), - TEST_PARSER(case3193), - TEST_PARSER(case3194), - TEST_PARSER(case3195), - TEST_PARSER(case3196), - TEST_PARSER(case3197), - TEST_PARSER(case3198), - TEST_PARSER(case3199), + TEST_PARSER(case3100), TEST_PARSER(case3101), TEST_PARSER(case3102), + TEST_PARSER(case3103), TEST_PARSER(case3104), TEST_PARSER(case3105), + TEST_PARSER(case3106), TEST_PARSER(case3107), TEST_PARSER(case3108), + TEST_PARSER(case3109), TEST_PARSER(case3110), TEST_PARSER(case3111), + TEST_PARSER(case3112), TEST_PARSER(case3113), TEST_PARSER(case3114), + TEST_PARSER(case3115), TEST_PARSER(case3116), TEST_PARSER(case3117), + TEST_PARSER(case3118), TEST_PARSER(case3119), TEST_PARSER(case3120), + TEST_PARSER(case3121), TEST_PARSER(case3122), TEST_PARSER(case3123), + TEST_PARSER(case3124), TEST_PARSER(case3125), TEST_PARSER(case3126), + TEST_PARSER(case3127), TEST_PARSER(case3128), TEST_PARSER(case3129), + TEST_PARSER(case3130), TEST_PARSER(case3131), TEST_PARSER(case3132), + TEST_PARSER(case3133), TEST_PARSER(case3134), TEST_PARSER(case3135), + TEST_PARSER(case3136), TEST_PARSER(case3137), TEST_PARSER(case3138), + TEST_PARSER(case3139), TEST_PARSER(case3140), TEST_PARSER(case3141), + TEST_PARSER(case3142), TEST_PARSER(case3143), TEST_PARSER(case3144), + TEST_PARSER(case3145), TEST_PARSER(case3146), TEST_PARSER(case3147), + TEST_PARSER(case3148), TEST_PARSER(case3149), TEST_PARSER(case3150), + TEST_PARSER(case3151), TEST_PARSER(case3152), TEST_PARSER(case3153), + TEST_PARSER(case3154), TEST_PARSER(case3155), TEST_PARSER(case3156), + TEST_PARSER(case3157), TEST_PARSER(case3158), TEST_PARSER(case3159), + TEST_PARSER(case3160), TEST_PARSER(case3161), TEST_PARSER(case3162), + TEST_PARSER(case3163), TEST_PARSER(case3164), TEST_PARSER(case3165), + TEST_PARSER(case3166), TEST_PARSER(case3167), TEST_PARSER(case3168), + TEST_PARSER(case3169), TEST_PARSER(case3170), TEST_PARSER(case3171), + TEST_PARSER(case3172), TEST_PARSER(case3173), TEST_PARSER(case3174), + TEST_PARSER(case3175), TEST_PARSER(case3176), TEST_PARSER(case3177), + TEST_PARSER(case3178), TEST_PARSER(case3179), TEST_PARSER(case3180), + TEST_PARSER(case3181), TEST_PARSER(case3182), TEST_PARSER(case3183), + TEST_PARSER(case3184), TEST_PARSER(case3185), TEST_PARSER(case3186), + TEST_PARSER(case3187), TEST_PARSER(case3188), TEST_PARSER(case3189), + TEST_PARSER(case3190), TEST_PARSER(case3191), TEST_PARSER(case3192), + TEST_PARSER(case3193), TEST_PARSER(case3194), TEST_PARSER(case3195), + TEST_PARSER(case3196), TEST_PARSER(case3197), TEST_PARSER(case3198), + TEST_PARSER(case3199), - TEST_PARSER(case3200), - TEST_PARSER(case3201), - TEST_PARSER(case3202), - TEST_PARSER(case3203), - TEST_PARSER(case3204), - TEST_PARSER(case3205), - TEST_PARSER(case3206), - TEST_PARSER(case3207), - TEST_PARSER(case3208), - TEST_PARSER(case3209), - TEST_PARSER(case3210), - TEST_PARSER(case3211), - TEST_PARSER(case3212), - TEST_PARSER(case3213), - TEST_PARSER(case3214), - TEST_PARSER(case3215), - TEST_PARSER(case3216), - TEST_PARSER(case3217), - TEST_PARSER(case3218), - TEST_PARSER(case3219), - TEST_PARSER(case3220), - TEST_PARSER(case3221), - TEST_PARSER(case3222), - TEST_PARSER(case3223), - TEST_PARSER(case3224), - TEST_PARSER(case3225), - TEST_PARSER(case3226), - TEST_PARSER(case3227), - TEST_PARSER(case3228), - TEST_PARSER(case3229), - TEST_PARSER(case3230), - TEST_PARSER(case3231), - TEST_PARSER(case3232), - TEST_PARSER(case3233), - TEST_PARSER(case3234), - TEST_PARSER(case3235), - TEST_PARSER(case3236), - TEST_PARSER(case3237), - TEST_PARSER(case3238), - TEST_PARSER(case3239), - TEST_PARSER(case3240), - TEST_PARSER(case3241), - TEST_PARSER(case3242), - TEST_PARSER(case3243), - TEST_PARSER(case3244), - TEST_PARSER(case3245), - TEST_PARSER(case3246), - TEST_PARSER(case3247), - TEST_PARSER(case3248), - TEST_PARSER(case3249), - TEST_PARSER(case3250), - TEST_PARSER(case3251), - TEST_PARSER(case3252), - TEST_PARSER(case3253), - TEST_PARSER(case3254), - TEST_PARSER(case3255), - TEST_PARSER(case3256), - TEST_PARSER(case3257), - TEST_PARSER(case3258), - TEST_PARSER(case3259), - TEST_PARSER(case3260), - TEST_PARSER(case3261), - TEST_PARSER(case3262), - TEST_PARSER(case3263), - TEST_PARSER(case3264), - TEST_PARSER(case3265), - TEST_PARSER(case3266), - TEST_PARSER(case3267), - TEST_PARSER(case3268), - TEST_PARSER(case3269), - TEST_PARSER(case3270), - TEST_PARSER(case3271), - TEST_PARSER(case3272), - TEST_PARSER(case3273), - TEST_PARSER(case3274), - TEST_PARSER(case3275), - TEST_PARSER(case3276), - TEST_PARSER(case3277), - TEST_PARSER(case3278), - TEST_PARSER(case3279), - TEST_PARSER(case3280), - TEST_PARSER(case3281), - TEST_PARSER(case3282), - TEST_PARSER(case3283), - TEST_PARSER(case3284), - TEST_PARSER(case3285), - TEST_PARSER(case3286), - TEST_PARSER(case3287), - TEST_PARSER(case3288), - TEST_PARSER(case3289), - TEST_PARSER(case3290), - TEST_PARSER(case3291), - TEST_PARSER(case3292), - TEST_PARSER(case3293), - TEST_PARSER(case3294), - TEST_PARSER(case3295), - TEST_PARSER(case3296), - TEST_PARSER(case3297), - TEST_PARSER(case3298), - TEST_PARSER(case3299), + TEST_PARSER(case3200), TEST_PARSER(case3201), TEST_PARSER(case3202), + TEST_PARSER(case3203), TEST_PARSER(case3204), TEST_PARSER(case3205), + TEST_PARSER(case3206), TEST_PARSER(case3207), TEST_PARSER(case3208), + TEST_PARSER(case3209), TEST_PARSER(case3210), TEST_PARSER(case3211), + TEST_PARSER(case3212), TEST_PARSER(case3213), TEST_PARSER(case3214), + TEST_PARSER(case3215), TEST_PARSER(case3216), TEST_PARSER(case3217), + TEST_PARSER(case3218), TEST_PARSER(case3219), TEST_PARSER(case3220), + TEST_PARSER(case3221), TEST_PARSER(case3222), TEST_PARSER(case3223), + TEST_PARSER(case3224), TEST_PARSER(case3225), TEST_PARSER(case3226), + TEST_PARSER(case3227), TEST_PARSER(case3228), TEST_PARSER(case3229), + TEST_PARSER(case3230), TEST_PARSER(case3231), TEST_PARSER(case3232), + TEST_PARSER(case3233), TEST_PARSER(case3234), TEST_PARSER(case3235), + TEST_PARSER(case3236), TEST_PARSER(case3237), TEST_PARSER(case3238), + TEST_PARSER(case3239), TEST_PARSER(case3240), TEST_PARSER(case3241), + TEST_PARSER(case3242), TEST_PARSER(case3243), TEST_PARSER(case3244), + TEST_PARSER(case3245), TEST_PARSER(case3246), TEST_PARSER(case3247), + TEST_PARSER(case3248), TEST_PARSER(case3249), TEST_PARSER(case3250), + TEST_PARSER(case3251), TEST_PARSER(case3252), TEST_PARSER(case3253), + TEST_PARSER(case3254), TEST_PARSER(case3255), TEST_PARSER(case3256), + TEST_PARSER(case3257), TEST_PARSER(case3258), TEST_PARSER(case3259), + TEST_PARSER(case3260), TEST_PARSER(case3261), TEST_PARSER(case3262), + TEST_PARSER(case3263), TEST_PARSER(case3264), TEST_PARSER(case3265), + TEST_PARSER(case3266), TEST_PARSER(case3267), TEST_PARSER(case3268), + TEST_PARSER(case3269), TEST_PARSER(case3270), TEST_PARSER(case3271), + TEST_PARSER(case3272), TEST_PARSER(case3273), TEST_PARSER(case3274), + TEST_PARSER(case3275), TEST_PARSER(case3276), TEST_PARSER(case3277), + TEST_PARSER(case3278), TEST_PARSER(case3279), TEST_PARSER(case3280), + TEST_PARSER(case3281), TEST_PARSER(case3282), TEST_PARSER(case3283), + TEST_PARSER(case3284), TEST_PARSER(case3285), TEST_PARSER(case3286), + TEST_PARSER(case3287), TEST_PARSER(case3288), TEST_PARSER(case3289), + TEST_PARSER(case3290), TEST_PARSER(case3291), TEST_PARSER(case3292), + TEST_PARSER(case3293), TEST_PARSER(case3294), TEST_PARSER(case3295), + TEST_PARSER(case3296), TEST_PARSER(case3297), TEST_PARSER(case3298), + TEST_PARSER(case3299), - TEST_PARSER(case3300), - TEST_PARSER(case3301), - TEST_PARSER(case3302), - TEST_PARSER(case3303), - TEST_PARSER(case3304), - TEST_PARSER(case3305), - TEST_PARSER(case3306), - TEST_PARSER(case3307), - TEST_PARSER(case3308), - TEST_PARSER(case3309), - TEST_PARSER(case3310), - TEST_PARSER(case3311), - TEST_PARSER(case3312), - TEST_PARSER(case3313), - TEST_PARSER(case3314), - TEST_PARSER(case3315), - TEST_PARSER(case3316), - TEST_PARSER(case3317), - TEST_PARSER(case3318), - TEST_PARSER(case3319), - TEST_PARSER(case3320), - TEST_PARSER(case3321), - TEST_PARSER(case3322), - TEST_PARSER(case3323), - TEST_PARSER(case3324), - TEST_PARSER(case3325), - TEST_PARSER(case3326), - TEST_PARSER(case3327), - TEST_PARSER(case3328), - TEST_PARSER(case3329), - TEST_PARSER(case3330), - TEST_PARSER(case3331), - TEST_PARSER(case3332), - TEST_PARSER(case3333), - TEST_PARSER(case3334), - TEST_PARSER(case3335), - TEST_PARSER(case3336), - TEST_PARSER(case3337), - TEST_PARSER(case3338), - TEST_PARSER(case3339), - TEST_PARSER(case3340), - TEST_PARSER(case3341), - TEST_PARSER(case3342), - TEST_PARSER(case3343), - TEST_PARSER(case3344), - TEST_PARSER(case3345), - TEST_PARSER(case3346), - TEST_PARSER(case3347), - TEST_PARSER(case3348), - TEST_PARSER(case3349), - TEST_PARSER(case3350), - TEST_PARSER(case3351), - TEST_PARSER(case3352), - TEST_PARSER(case3353), - TEST_PARSER(case3354), - TEST_PARSER(case3355), - TEST_PARSER(case3356), - TEST_PARSER(case3357), - TEST_PARSER(case3358), - TEST_PARSER(case3359), - TEST_PARSER(case3360), - TEST_PARSER(case3361), - TEST_PARSER(case3362), - TEST_PARSER(case3363), - TEST_PARSER(case3364), - TEST_PARSER(case3365), - TEST_PARSER(case3366), - TEST_PARSER(case3367), - TEST_PARSER(case3368), - TEST_PARSER(case3369), - TEST_PARSER(case3370), - TEST_PARSER(case3371), - TEST_PARSER(case3372), - TEST_PARSER(case3373), - TEST_PARSER(case3374), - TEST_PARSER(case3375), - TEST_PARSER(case3376), - TEST_PARSER(case3377), - TEST_PARSER(case3378), - TEST_PARSER(case3379), - TEST_PARSER(case3380), - TEST_PARSER(case3381), - TEST_PARSER(case3382), - TEST_PARSER(case3383), - TEST_PARSER(case3384), - TEST_PARSER(case3385), - TEST_PARSER(case3386), - TEST_PARSER(case3387), - TEST_PARSER(case3388), - TEST_PARSER(case3389), - TEST_PARSER(case3390), - TEST_PARSER(case3391), - TEST_PARSER(case3392), - TEST_PARSER(case3393), - TEST_PARSER(case3394), - TEST_PARSER(case3395), - TEST_PARSER(case3396), - TEST_PARSER(case3397), - TEST_PARSER(case3398), - TEST_PARSER(case3399), + TEST_PARSER(case3300), TEST_PARSER(case3301), TEST_PARSER(case3302), + TEST_PARSER(case3303), TEST_PARSER(case3304), TEST_PARSER(case3305), + TEST_PARSER(case3306), TEST_PARSER(case3307), TEST_PARSER(case3308), + TEST_PARSER(case3309), TEST_PARSER(case3310), TEST_PARSER(case3311), + TEST_PARSER(case3312), TEST_PARSER(case3313), TEST_PARSER(case3314), + TEST_PARSER(case3315), TEST_PARSER(case3316), TEST_PARSER(case3317), + TEST_PARSER(case3318), TEST_PARSER(case3319), TEST_PARSER(case3320), + TEST_PARSER(case3321), TEST_PARSER(case3322), TEST_PARSER(case3323), + TEST_PARSER(case3324), TEST_PARSER(case3325), TEST_PARSER(case3326), + TEST_PARSER(case3327), TEST_PARSER(case3328), TEST_PARSER(case3329), + TEST_PARSER(case3330), TEST_PARSER(case3331), TEST_PARSER(case3332), + TEST_PARSER(case3333), TEST_PARSER(case3334), TEST_PARSER(case3335), + TEST_PARSER(case3336), TEST_PARSER(case3337), TEST_PARSER(case3338), + TEST_PARSER(case3339), TEST_PARSER(case3340), TEST_PARSER(case3341), + TEST_PARSER(case3342), TEST_PARSER(case3343), TEST_PARSER(case3344), + TEST_PARSER(case3345), TEST_PARSER(case3346), TEST_PARSER(case3347), + TEST_PARSER(case3348), TEST_PARSER(case3349), TEST_PARSER(case3350), + TEST_PARSER(case3351), TEST_PARSER(case3352), TEST_PARSER(case3353), + TEST_PARSER(case3354), TEST_PARSER(case3355), TEST_PARSER(case3356), + TEST_PARSER(case3357), TEST_PARSER(case3358), TEST_PARSER(case3359), + TEST_PARSER(case3360), TEST_PARSER(case3361), TEST_PARSER(case3362), + TEST_PARSER(case3363), TEST_PARSER(case3364), TEST_PARSER(case3365), + TEST_PARSER(case3366), TEST_PARSER(case3367), TEST_PARSER(case3368), + TEST_PARSER(case3369), TEST_PARSER(case3370), TEST_PARSER(case3371), + TEST_PARSER(case3372), TEST_PARSER(case3373), TEST_PARSER(case3374), + TEST_PARSER(case3375), TEST_PARSER(case3376), TEST_PARSER(case3377), + TEST_PARSER(case3378), TEST_PARSER(case3379), TEST_PARSER(case3380), + TEST_PARSER(case3381), TEST_PARSER(case3382), TEST_PARSER(case3383), + TEST_PARSER(case3384), TEST_PARSER(case3385), TEST_PARSER(case3386), + TEST_PARSER(case3387), TEST_PARSER(case3388), TEST_PARSER(case3389), + TEST_PARSER(case3390), TEST_PARSER(case3391), TEST_PARSER(case3392), + TEST_PARSER(case3393), TEST_PARSER(case3394), TEST_PARSER(case3395), + TEST_PARSER(case3396), TEST_PARSER(case3397), TEST_PARSER(case3398), + TEST_PARSER(case3399), - TEST_PARSER(case3400), - TEST_PARSER(case3401), - TEST_PARSER(case3402), - TEST_PARSER(case3403), - TEST_PARSER(case3404), - TEST_PARSER(case3405), - TEST_PARSER(case3406), - TEST_PARSER(case3407), - TEST_PARSER(case3408), - TEST_PARSER(case3409), - TEST_PARSER(case3410), - TEST_PARSER(case3411), - TEST_PARSER(case3412), - TEST_PARSER(case3413), - TEST_PARSER(case3414), - TEST_PARSER(case3415), - TEST_PARSER(case3416), - TEST_PARSER(case3417), - TEST_PARSER(case3418), - TEST_PARSER(case3419), - TEST_PARSER(case3420), - TEST_PARSER(case3421), - TEST_PARSER(case3422), - TEST_PARSER(case3423), - TEST_PARSER(case3424), - TEST_PARSER(case3425), - TEST_PARSER(case3426), - TEST_PARSER(case3427), - TEST_PARSER(case3428), - TEST_PARSER(case3429), - TEST_PARSER(case3430), - TEST_PARSER(case3431), - TEST_PARSER(case3432), - TEST_PARSER(case3433), - TEST_PARSER(case3434), - TEST_PARSER(case3435), - TEST_PARSER(case3436), - TEST_PARSER(case3437), - TEST_PARSER(case3438), - TEST_PARSER(case3439), - TEST_PARSER(case3440), - TEST_PARSER(case3441), - TEST_PARSER(case3442), - TEST_PARSER(case3443), - TEST_PARSER(case3444), - TEST_PARSER(case3445), - TEST_PARSER(case3446), - TEST_PARSER(case3447), - TEST_PARSER(case3448), - TEST_PARSER(case3449), - TEST_PARSER(case3450), - TEST_PARSER(case3451), - TEST_PARSER(case3452), - TEST_PARSER(case3453), - TEST_PARSER(case3454), - TEST_PARSER(case3455), - TEST_PARSER(case3456), - TEST_PARSER(case3457), - TEST_PARSER(case3458), - TEST_PARSER(case3459), - TEST_PARSER(case3460), - TEST_PARSER(case3461), - TEST_PARSER(case3462), - TEST_PARSER(case3463), - TEST_PARSER(case3464), - TEST_PARSER(case3465), - TEST_PARSER(case3466), - TEST_PARSER(case3467), - TEST_PARSER(case3468), - TEST_PARSER(case3469), - TEST_PARSER(case3470), - TEST_PARSER(case3471), - TEST_PARSER(case3472), - TEST_PARSER(case3473), - TEST_PARSER(case3474), - TEST_PARSER(case3475), - TEST_PARSER(case3476), - TEST_PARSER(case3477), - TEST_PARSER(case3478), - TEST_PARSER(case3479), - TEST_PARSER(case3480), - TEST_PARSER(case3481), - TEST_PARSER(case3482), - TEST_PARSER(case3483), - TEST_PARSER(case3484), - TEST_PARSER(case3485), - TEST_PARSER(case3486), - TEST_PARSER(case3487), - TEST_PARSER(case3488), - TEST_PARSER(case3489), - TEST_PARSER(case3490), - TEST_PARSER(case3491), - TEST_PARSER(case3492), - TEST_PARSER(case3493), - TEST_PARSER(case3494), - TEST_PARSER(case3495), - TEST_PARSER(case3496), - TEST_PARSER(case3497), - TEST_PARSER(case3498), - TEST_PARSER(case3499), + TEST_PARSER(case3400), TEST_PARSER(case3401), TEST_PARSER(case3402), + TEST_PARSER(case3403), TEST_PARSER(case3404), TEST_PARSER(case3405), + TEST_PARSER(case3406), TEST_PARSER(case3407), TEST_PARSER(case3408), + TEST_PARSER(case3409), TEST_PARSER(case3410), TEST_PARSER(case3411), + TEST_PARSER(case3412), TEST_PARSER(case3413), TEST_PARSER(case3414), + TEST_PARSER(case3415), TEST_PARSER(case3416), TEST_PARSER(case3417), + TEST_PARSER(case3418), TEST_PARSER(case3419), TEST_PARSER(case3420), + TEST_PARSER(case3421), TEST_PARSER(case3422), TEST_PARSER(case3423), + TEST_PARSER(case3424), TEST_PARSER(case3425), TEST_PARSER(case3426), + TEST_PARSER(case3427), TEST_PARSER(case3428), TEST_PARSER(case3429), + TEST_PARSER(case3430), TEST_PARSER(case3431), TEST_PARSER(case3432), + TEST_PARSER(case3433), TEST_PARSER(case3434), TEST_PARSER(case3435), + TEST_PARSER(case3436), TEST_PARSER(case3437), TEST_PARSER(case3438), + TEST_PARSER(case3439), TEST_PARSER(case3440), TEST_PARSER(case3441), + TEST_PARSER(case3442), TEST_PARSER(case3443), TEST_PARSER(case3444), + TEST_PARSER(case3445), TEST_PARSER(case3446), TEST_PARSER(case3447), + TEST_PARSER(case3448), TEST_PARSER(case3449), TEST_PARSER(case3450), + TEST_PARSER(case3451), TEST_PARSER(case3452), TEST_PARSER(case3453), + TEST_PARSER(case3454), TEST_PARSER(case3455), TEST_PARSER(case3456), + TEST_PARSER(case3457), TEST_PARSER(case3458), TEST_PARSER(case3459), + TEST_PARSER(case3460), TEST_PARSER(case3461), TEST_PARSER(case3462), + TEST_PARSER(case3463), TEST_PARSER(case3464), TEST_PARSER(case3465), + TEST_PARSER(case3466), TEST_PARSER(case3467), TEST_PARSER(case3468), + TEST_PARSER(case3469), TEST_PARSER(case3470), TEST_PARSER(case3471), + TEST_PARSER(case3472), TEST_PARSER(case3473), TEST_PARSER(case3474), + TEST_PARSER(case3475), TEST_PARSER(case3476), TEST_PARSER(case3477), + TEST_PARSER(case3478), TEST_PARSER(case3479), TEST_PARSER(case3480), + TEST_PARSER(case3481), TEST_PARSER(case3482), TEST_PARSER(case3483), + TEST_PARSER(case3484), TEST_PARSER(case3485), TEST_PARSER(case3486), + TEST_PARSER(case3487), TEST_PARSER(case3488), TEST_PARSER(case3489), + TEST_PARSER(case3490), TEST_PARSER(case3491), TEST_PARSER(case3492), + TEST_PARSER(case3493), TEST_PARSER(case3494), TEST_PARSER(case3495), + TEST_PARSER(case3496), TEST_PARSER(case3497), TEST_PARSER(case3498), + TEST_PARSER(case3499), - TEST_PARSER(case3500), - TEST_PARSER(case3501), - TEST_PARSER(case3502), - TEST_PARSER(case3503), - TEST_PARSER(case3504), - TEST_PARSER(case3505), - TEST_PARSER(case3506), - TEST_PARSER(case3507), - TEST_PARSER(case3508), - TEST_PARSER(case3509), - TEST_PARSER(case3510), - TEST_PARSER(case3511), - TEST_PARSER(case3512), - TEST_PARSER(case3513), - TEST_PARSER(case3514), - TEST_PARSER(case3515), - TEST_PARSER(case3516), - TEST_PARSER(case3517), - TEST_PARSER(case3518), - TEST_PARSER(case3519), - TEST_PARSER(case3520), - TEST_PARSER(case3521), - TEST_PARSER(case3522), - TEST_PARSER(case3523), - TEST_PARSER(case3524), - TEST_PARSER(case3525), - TEST_PARSER(case3526), - TEST_PARSER(case3527), - TEST_PARSER(case3528), - TEST_PARSER(case3529), - TEST_PARSER(case3530), - TEST_PARSER(case3531), - TEST_PARSER(case3532), - TEST_PARSER(case3533), - TEST_PARSER(case3534), - TEST_PARSER(case3535), - TEST_PARSER(case3536), - TEST_PARSER(case3537), - TEST_PARSER(case3538), - TEST_PARSER(case3539), - TEST_PARSER(case3540), - TEST_PARSER(case3541), - TEST_PARSER(case3542), - TEST_PARSER(case3543), - TEST_PARSER(case3544), - TEST_PARSER(case3545), - TEST_PARSER(case3546), - TEST_PARSER(case3547), - TEST_PARSER(case3548), - TEST_PARSER(case3549), - TEST_PARSER(case3550), - TEST_PARSER(case3551), - TEST_PARSER(case3552), - TEST_PARSER(case3553), - TEST_PARSER(case3554), - TEST_PARSER(case3555), - TEST_PARSER(case3556), - TEST_PARSER(case3557), - TEST_PARSER(case3558), - TEST_PARSER(case3559), - TEST_PARSER(case3560), - TEST_PARSER(case3561), - TEST_PARSER(case3562), - TEST_PARSER(case3563), - TEST_PARSER(case3564), - TEST_PARSER(case3565), - TEST_PARSER(case3566), - TEST_PARSER(case3567), - TEST_PARSER(case3568), - TEST_PARSER(case3569), - TEST_PARSER(case3570), - TEST_PARSER(case3571), - TEST_PARSER(case3572), - TEST_PARSER(case3573), - TEST_PARSER(case3574), - TEST_PARSER(case3575), - TEST_PARSER(case3576), - TEST_PARSER(case3577), - TEST_PARSER(case3578), - TEST_PARSER(case3579), - TEST_PARSER(case3580), - TEST_PARSER(case3581), - TEST_PARSER(case3582), - TEST_PARSER(case3583), - TEST_PARSER(case3584), - TEST_PARSER(case3585), - TEST_PARSER(case3586), - TEST_PARSER(case3587), - TEST_PARSER(case3588), - TEST_PARSER(case3589), - TEST_PARSER(case3590), - TEST_PARSER(case3591), - TEST_PARSER(case3592), - TEST_PARSER(case3593), - TEST_PARSER(case3594), - TEST_PARSER(case3595), - TEST_PARSER(case3596), - TEST_PARSER(case3597), - TEST_PARSER(case3598), - TEST_PARSER(case3599), + TEST_PARSER(case3500), TEST_PARSER(case3501), TEST_PARSER(case3502), + TEST_PARSER(case3503), TEST_PARSER(case3504), TEST_PARSER(case3505), + TEST_PARSER(case3506), TEST_PARSER(case3507), TEST_PARSER(case3508), + TEST_PARSER(case3509), TEST_PARSER(case3510), TEST_PARSER(case3511), + TEST_PARSER(case3512), TEST_PARSER(case3513), TEST_PARSER(case3514), + TEST_PARSER(case3515), TEST_PARSER(case3516), TEST_PARSER(case3517), + TEST_PARSER(case3518), TEST_PARSER(case3519), TEST_PARSER(case3520), + TEST_PARSER(case3521), TEST_PARSER(case3522), TEST_PARSER(case3523), + TEST_PARSER(case3524), TEST_PARSER(case3525), TEST_PARSER(case3526), + TEST_PARSER(case3527), TEST_PARSER(case3528), TEST_PARSER(case3529), + TEST_PARSER(case3530), TEST_PARSER(case3531), TEST_PARSER(case3532), + TEST_PARSER(case3533), TEST_PARSER(case3534), TEST_PARSER(case3535), + TEST_PARSER(case3536), TEST_PARSER(case3537), TEST_PARSER(case3538), + TEST_PARSER(case3539), TEST_PARSER(case3540), TEST_PARSER(case3541), + TEST_PARSER(case3542), TEST_PARSER(case3543), TEST_PARSER(case3544), + TEST_PARSER(case3545), TEST_PARSER(case3546), TEST_PARSER(case3547), + TEST_PARSER(case3548), TEST_PARSER(case3549), TEST_PARSER(case3550), + TEST_PARSER(case3551), TEST_PARSER(case3552), TEST_PARSER(case3553), + TEST_PARSER(case3554), TEST_PARSER(case3555), TEST_PARSER(case3556), + TEST_PARSER(case3557), TEST_PARSER(case3558), TEST_PARSER(case3559), + TEST_PARSER(case3560), TEST_PARSER(case3561), TEST_PARSER(case3562), + TEST_PARSER(case3563), TEST_PARSER(case3564), TEST_PARSER(case3565), + TEST_PARSER(case3566), TEST_PARSER(case3567), TEST_PARSER(case3568), + TEST_PARSER(case3569), TEST_PARSER(case3570), TEST_PARSER(case3571), + TEST_PARSER(case3572), TEST_PARSER(case3573), TEST_PARSER(case3574), + TEST_PARSER(case3575), TEST_PARSER(case3576), TEST_PARSER(case3577), + TEST_PARSER(case3578), TEST_PARSER(case3579), TEST_PARSER(case3580), + TEST_PARSER(case3581), TEST_PARSER(case3582), TEST_PARSER(case3583), + TEST_PARSER(case3584), TEST_PARSER(case3585), TEST_PARSER(case3586), + TEST_PARSER(case3587), TEST_PARSER(case3588), TEST_PARSER(case3589), + TEST_PARSER(case3590), TEST_PARSER(case3591), TEST_PARSER(case3592), + TEST_PARSER(case3593), TEST_PARSER(case3594), TEST_PARSER(case3595), + TEST_PARSER(case3596), TEST_PARSER(case3597), TEST_PARSER(case3598), + TEST_PARSER(case3599), - TEST_PARSER(case3600), - TEST_PARSER(case3601), - TEST_PARSER(case3602), - TEST_PARSER(case3603), - TEST_PARSER(case3604), - TEST_PARSER(case3605), - TEST_PARSER(case3606), - TEST_PARSER(case3607), - TEST_PARSER(case3608), - TEST_PARSER(case3609), - TEST_PARSER(case3610), - TEST_PARSER(case3611), - TEST_PARSER(case3612), - TEST_PARSER(case3613), - TEST_PARSER(case3614), - TEST_PARSER(case3615), - TEST_PARSER(case3616), - TEST_PARSER(case3617), - TEST_PARSER(case3618), - TEST_PARSER(case3619), - TEST_PARSER(case3620), - TEST_PARSER(case3621), - TEST_PARSER(case3622), - TEST_PARSER(case3623), - TEST_PARSER(case3624), - TEST_PARSER(case3625), - TEST_PARSER(case3626), - TEST_PARSER(case3627), - TEST_PARSER(case3628), - TEST_PARSER(case3629), - TEST_PARSER(case3630), - TEST_PARSER(case3631), - TEST_PARSER(case3632), - TEST_PARSER(case3633), - TEST_PARSER(case3634), - TEST_PARSER(case3635), - TEST_PARSER(case3636), - TEST_PARSER(case3637), - TEST_PARSER(case3638), - TEST_PARSER(case3639), - TEST_PARSER(case3640), - TEST_PARSER(case3641), - TEST_PARSER(case3642), - TEST_PARSER(case3643), - TEST_PARSER(case3644), - TEST_PARSER(case3645), - TEST_PARSER(case3646), - TEST_PARSER(case3647), - TEST_PARSER(case3648), - TEST_PARSER(case3649), - TEST_PARSER(case3650), - TEST_PARSER(case3651), - TEST_PARSER(case3652), - TEST_PARSER(case3653), - TEST_PARSER(case3654), - TEST_PARSER(case3655), - TEST_PARSER(case3656), - TEST_PARSER(case3657), - TEST_PARSER(case3658), - TEST_PARSER(case3659), - TEST_PARSER(case3660), - TEST_PARSER(case3661), - TEST_PARSER(case3662), - TEST_PARSER(case3663), - TEST_PARSER(case3664), - TEST_PARSER(case3665), - TEST_PARSER(case3666), - TEST_PARSER(case3667), - TEST_PARSER(case3668), - TEST_PARSER(case3669), - TEST_PARSER(case3670), - TEST_PARSER(case3671), - TEST_PARSER(case3672), - TEST_PARSER(case3673), - TEST_PARSER(case3674), - TEST_PARSER(case3675), - TEST_PARSER(case3676), - TEST_PARSER(case3677), - TEST_PARSER(case3678), - TEST_PARSER(case3679), - TEST_PARSER(case3680), - TEST_PARSER(case3681), - TEST_PARSER(case3682), - TEST_PARSER(case3683), - TEST_PARSER(case3684), - TEST_PARSER(case3685), - TEST_PARSER(case3686), - TEST_PARSER(case3687), - TEST_PARSER(case3688), - TEST_PARSER(case3689), - TEST_PARSER(case3690), - TEST_PARSER(case3691), - TEST_PARSER(case3692), - TEST_PARSER(case3693), - TEST_PARSER(case3694), - TEST_PARSER(case3695), - TEST_PARSER(case3696), - TEST_PARSER(case3697), - TEST_PARSER(case3698), - TEST_PARSER(case3699), + TEST_PARSER(case3600), TEST_PARSER(case3601), TEST_PARSER(case3602), + TEST_PARSER(case3603), TEST_PARSER(case3604), TEST_PARSER(case3605), + TEST_PARSER(case3606), TEST_PARSER(case3607), TEST_PARSER(case3608), + TEST_PARSER(case3609), TEST_PARSER(case3610), TEST_PARSER(case3611), + TEST_PARSER(case3612), TEST_PARSER(case3613), TEST_PARSER(case3614), + TEST_PARSER(case3615), TEST_PARSER(case3616), TEST_PARSER(case3617), + TEST_PARSER(case3618), TEST_PARSER(case3619), TEST_PARSER(case3620), + TEST_PARSER(case3621), TEST_PARSER(case3622), TEST_PARSER(case3623), + TEST_PARSER(case3624), TEST_PARSER(case3625), TEST_PARSER(case3626), + TEST_PARSER(case3627), TEST_PARSER(case3628), TEST_PARSER(case3629), + TEST_PARSER(case3630), TEST_PARSER(case3631), TEST_PARSER(case3632), + TEST_PARSER(case3633), TEST_PARSER(case3634), TEST_PARSER(case3635), + TEST_PARSER(case3636), TEST_PARSER(case3637), TEST_PARSER(case3638), + TEST_PARSER(case3639), TEST_PARSER(case3640), TEST_PARSER(case3641), + TEST_PARSER(case3642), TEST_PARSER(case3643), TEST_PARSER(case3644), + TEST_PARSER(case3645), TEST_PARSER(case3646), TEST_PARSER(case3647), + TEST_PARSER(case3648), TEST_PARSER(case3649), TEST_PARSER(case3650), + TEST_PARSER(case3651), TEST_PARSER(case3652), TEST_PARSER(case3653), + TEST_PARSER(case3654), TEST_PARSER(case3655), TEST_PARSER(case3656), + TEST_PARSER(case3657), TEST_PARSER(case3658), TEST_PARSER(case3659), + TEST_PARSER(case3660), TEST_PARSER(case3661), TEST_PARSER(case3662), + TEST_PARSER(case3663), TEST_PARSER(case3664), TEST_PARSER(case3665), + TEST_PARSER(case3666), TEST_PARSER(case3667), TEST_PARSER(case3668), + TEST_PARSER(case3669), TEST_PARSER(case3670), TEST_PARSER(case3671), + TEST_PARSER(case3672), TEST_PARSER(case3673), TEST_PARSER(case3674), + TEST_PARSER(case3675), TEST_PARSER(case3676), TEST_PARSER(case3677), + TEST_PARSER(case3678), TEST_PARSER(case3679), TEST_PARSER(case3680), + TEST_PARSER(case3681), TEST_PARSER(case3682), TEST_PARSER(case3683), + TEST_PARSER(case3684), TEST_PARSER(case3685), TEST_PARSER(case3686), + TEST_PARSER(case3687), TEST_PARSER(case3688), TEST_PARSER(case3689), + TEST_PARSER(case3690), TEST_PARSER(case3691), TEST_PARSER(case3692), + TEST_PARSER(case3693), TEST_PARSER(case3694), TEST_PARSER(case3695), + TEST_PARSER(case3696), TEST_PARSER(case3697), TEST_PARSER(case3698), + TEST_PARSER(case3699), - TEST_PARSER(case3700), - TEST_PARSER(case3701), - TEST_PARSER(case3702), - TEST_PARSER(case3703), - TEST_PARSER(case3704), - TEST_PARSER(case3705), - TEST_PARSER(case3706), - TEST_PARSER(case3707), - TEST_PARSER(case3708), - TEST_PARSER(case3709), - TEST_PARSER(case3710), - TEST_PARSER(case3711), - TEST_PARSER(case3712), - TEST_PARSER(case3713), - TEST_PARSER(case3714), - TEST_PARSER(case3715), - TEST_PARSER(case3716), - TEST_PARSER(case3717), - TEST_PARSER(case3718), - TEST_PARSER(case3719), - TEST_PARSER(case3720), - TEST_PARSER(case3721), - TEST_PARSER(case3722), - TEST_PARSER(case3723), - TEST_PARSER(case3724), - TEST_PARSER(case3725), - TEST_PARSER(case3726), - TEST_PARSER(case3727), - TEST_PARSER(case3728), - TEST_PARSER(case3729), - TEST_PARSER(case3730), - TEST_PARSER(case3731), - TEST_PARSER(case3732), - TEST_PARSER(case3733), - TEST_PARSER(case3734), - TEST_PARSER(case3735), - TEST_PARSER(case3736), - TEST_PARSER(case3737), - TEST_PARSER(case3738), - TEST_PARSER(case3739), - TEST_PARSER(case3740), - TEST_PARSER(case3741), - TEST_PARSER(case3742), - TEST_PARSER(case3743), - TEST_PARSER(case3744), - TEST_PARSER(case3745), - TEST_PARSER(case3746), - TEST_PARSER(case3747), - TEST_PARSER(case3748), - TEST_PARSER(case3749), - TEST_PARSER(case3750), - TEST_PARSER(case3751), - TEST_PARSER(case3752), - TEST_PARSER(case3753), - TEST_PARSER(case3754), - TEST_PARSER(case3755), - TEST_PARSER(case3756), - TEST_PARSER(case3757), - TEST_PARSER(case3758), - TEST_PARSER(case3759), - TEST_PARSER(case3760), - TEST_PARSER(case3761), - TEST_PARSER(case3762), - TEST_PARSER(case3763), - TEST_PARSER(case3764), - TEST_PARSER(case3765), - TEST_PARSER(case3766), - TEST_PARSER(case3767), - TEST_PARSER(case3768), - TEST_PARSER(case3769), - TEST_PARSER(case3770), - TEST_PARSER(case3771), - TEST_PARSER(case3772), - TEST_PARSER(case3773), - TEST_PARSER(case3774), - TEST_PARSER(case3775), - TEST_PARSER(case3776), - TEST_PARSER(case3777), - TEST_PARSER(case3778), - TEST_PARSER(case3779), - TEST_PARSER(case3780), - TEST_PARSER(case3781), - TEST_PARSER(case3782), - TEST_PARSER(case3783), - TEST_PARSER(case3784), - TEST_PARSER(case3785), - TEST_PARSER(case3786), - TEST_PARSER(case3787), - TEST_PARSER(case3788), - TEST_PARSER(case3789), - TEST_PARSER(case3790), - TEST_PARSER(case3791), - TEST_PARSER(case3792), - TEST_PARSER(case3793), - TEST_PARSER(case3794), - TEST_PARSER(case3795), - TEST_PARSER(case3796), - TEST_PARSER(case3797), - TEST_PARSER(case3798), - TEST_PARSER(case3799), + TEST_PARSER(case3700), TEST_PARSER(case3701), TEST_PARSER(case3702), + TEST_PARSER(case3703), TEST_PARSER(case3704), TEST_PARSER(case3705), + TEST_PARSER(case3706), TEST_PARSER(case3707), TEST_PARSER(case3708), + TEST_PARSER(case3709), TEST_PARSER(case3710), TEST_PARSER(case3711), + TEST_PARSER(case3712), TEST_PARSER(case3713), TEST_PARSER(case3714), + TEST_PARSER(case3715), TEST_PARSER(case3716), TEST_PARSER(case3717), + TEST_PARSER(case3718), TEST_PARSER(case3719), TEST_PARSER(case3720), + TEST_PARSER(case3721), TEST_PARSER(case3722), TEST_PARSER(case3723), + TEST_PARSER(case3724), TEST_PARSER(case3725), TEST_PARSER(case3726), + TEST_PARSER(case3727), TEST_PARSER(case3728), TEST_PARSER(case3729), + TEST_PARSER(case3730), TEST_PARSER(case3731), TEST_PARSER(case3732), + TEST_PARSER(case3733), TEST_PARSER(case3734), TEST_PARSER(case3735), + TEST_PARSER(case3736), TEST_PARSER(case3737), TEST_PARSER(case3738), + TEST_PARSER(case3739), TEST_PARSER(case3740), TEST_PARSER(case3741), + TEST_PARSER(case3742), TEST_PARSER(case3743), TEST_PARSER(case3744), + TEST_PARSER(case3745), TEST_PARSER(case3746), TEST_PARSER(case3747), + TEST_PARSER(case3748), TEST_PARSER(case3749), TEST_PARSER(case3750), + TEST_PARSER(case3751), TEST_PARSER(case3752), TEST_PARSER(case3753), + TEST_PARSER(case3754), TEST_PARSER(case3755), TEST_PARSER(case3756), + TEST_PARSER(case3757), TEST_PARSER(case3758), TEST_PARSER(case3759), + TEST_PARSER(case3760), TEST_PARSER(case3761), TEST_PARSER(case3762), + TEST_PARSER(case3763), TEST_PARSER(case3764), TEST_PARSER(case3765), + TEST_PARSER(case3766), TEST_PARSER(case3767), TEST_PARSER(case3768), + TEST_PARSER(case3769), TEST_PARSER(case3770), TEST_PARSER(case3771), + TEST_PARSER(case3772), TEST_PARSER(case3773), TEST_PARSER(case3774), + TEST_PARSER(case3775), TEST_PARSER(case3776), TEST_PARSER(case3777), + TEST_PARSER(case3778), TEST_PARSER(case3779), TEST_PARSER(case3780), + TEST_PARSER(case3781), TEST_PARSER(case3782), TEST_PARSER(case3783), + TEST_PARSER(case3784), TEST_PARSER(case3785), TEST_PARSER(case3786), + TEST_PARSER(case3787), TEST_PARSER(case3788), TEST_PARSER(case3789), + TEST_PARSER(case3790), TEST_PARSER(case3791), TEST_PARSER(case3792), + TEST_PARSER(case3793), TEST_PARSER(case3794), TEST_PARSER(case3795), + TEST_PARSER(case3796), TEST_PARSER(case3797), TEST_PARSER(case3798), + TEST_PARSER(case3799), - TEST_PARSER(case3800), - TEST_PARSER(case3801), - TEST_PARSER(case3802), - TEST_PARSER(case3803), - TEST_PARSER(case3804), - TEST_PARSER(case3805), - TEST_PARSER(case3806), - TEST_PARSER(case3807), - TEST_PARSER(case3808), - TEST_PARSER(case3809), - TEST_PARSER(case3810), - TEST_PARSER(case3811), - TEST_PARSER(case3812), - TEST_PARSER(case3813), - TEST_PARSER(case3814), - TEST_PARSER(case3815), - TEST_PARSER(case3816), - TEST_PARSER(case3817), - TEST_PARSER(case3818), - TEST_PARSER(case3819), - TEST_PARSER(case3820), - TEST_PARSER(case3821), - TEST_PARSER(case3822), - TEST_PARSER(case3823), - TEST_PARSER(case3824), - TEST_PARSER(case3825), - TEST_PARSER(case3826), - TEST_PARSER(case3827), - TEST_PARSER(case3828), - TEST_PARSER(case3829), - TEST_PARSER(case3830), - TEST_PARSER(case3831), - TEST_PARSER(case3832), - TEST_PARSER(case3833), - TEST_PARSER(case3834), - TEST_PARSER(case3835), - TEST_PARSER(case3836), - TEST_PARSER(case3837), - TEST_PARSER(case3838), - TEST_PARSER(case3839), - TEST_PARSER(case3840), - TEST_PARSER(case3841), - TEST_PARSER(case3842), - TEST_PARSER(case3843), - TEST_PARSER(case3844), - TEST_PARSER(case3845), - TEST_PARSER(case3846), - TEST_PARSER(case3847), - TEST_PARSER(case3848), - TEST_PARSER(case3849), - TEST_PARSER(case3850), - TEST_PARSER(case3851), - TEST_PARSER(case3852), - TEST_PARSER(case3853), - TEST_PARSER(case3854), - TEST_PARSER(case3855), - TEST_PARSER(case3856), - TEST_PARSER(case3857), - TEST_PARSER(case3858), - TEST_PARSER(case3859), - TEST_PARSER(case3860), - TEST_PARSER(case3861), - TEST_PARSER(case3862), - TEST_PARSER(case3863), - TEST_PARSER(case3864), - TEST_PARSER(case3865), - TEST_PARSER(case3866), - TEST_PARSER(case3867), - TEST_PARSER(case3868), - TEST_PARSER(case3869), - TEST_PARSER(case3870), - TEST_PARSER(case3871), - TEST_PARSER(case3872), - TEST_PARSER(case3873), - TEST_PARSER(case3874), - TEST_PARSER(case3875), - TEST_PARSER(case3876), - TEST_PARSER(case3877), - TEST_PARSER(case3878), - TEST_PARSER(case3879), - TEST_PARSER(case3880), - TEST_PARSER(case3881), - TEST_PARSER(case3882), - TEST_PARSER(case3883), - TEST_PARSER(case3884), - TEST_PARSER(case3885), - TEST_PARSER(case3886), - TEST_PARSER(case3887), - TEST_PARSER(case3888), - TEST_PARSER(case3889), - TEST_PARSER(case3890), - TEST_PARSER(case3891), - TEST_PARSER(case3892), - TEST_PARSER(case3893), - TEST_PARSER(case3894), - TEST_PARSER(case3895), - TEST_PARSER(case3896), - TEST_PARSER(case3897), - TEST_PARSER(case3898), - TEST_PARSER(case3899), + TEST_PARSER(case3800), TEST_PARSER(case3801), TEST_PARSER(case3802), + TEST_PARSER(case3803), TEST_PARSER(case3804), TEST_PARSER(case3805), + TEST_PARSER(case3806), TEST_PARSER(case3807), TEST_PARSER(case3808), + TEST_PARSER(case3809), TEST_PARSER(case3810), TEST_PARSER(case3811), + TEST_PARSER(case3812), TEST_PARSER(case3813), TEST_PARSER(case3814), + TEST_PARSER(case3815), TEST_PARSER(case3816), TEST_PARSER(case3817), + TEST_PARSER(case3818), TEST_PARSER(case3819), TEST_PARSER(case3820), + TEST_PARSER(case3821), TEST_PARSER(case3822), TEST_PARSER(case3823), + TEST_PARSER(case3824), TEST_PARSER(case3825), TEST_PARSER(case3826), + TEST_PARSER(case3827), TEST_PARSER(case3828), TEST_PARSER(case3829), + TEST_PARSER(case3830), TEST_PARSER(case3831), TEST_PARSER(case3832), + TEST_PARSER(case3833), TEST_PARSER(case3834), TEST_PARSER(case3835), + TEST_PARSER(case3836), TEST_PARSER(case3837), TEST_PARSER(case3838), + TEST_PARSER(case3839), TEST_PARSER(case3840), TEST_PARSER(case3841), + TEST_PARSER(case3842), TEST_PARSER(case3843), TEST_PARSER(case3844), + TEST_PARSER(case3845), TEST_PARSER(case3846), TEST_PARSER(case3847), + TEST_PARSER(case3848), TEST_PARSER(case3849), TEST_PARSER(case3850), + TEST_PARSER(case3851), TEST_PARSER(case3852), TEST_PARSER(case3853), + TEST_PARSER(case3854), TEST_PARSER(case3855), TEST_PARSER(case3856), + TEST_PARSER(case3857), TEST_PARSER(case3858), TEST_PARSER(case3859), + TEST_PARSER(case3860), TEST_PARSER(case3861), TEST_PARSER(case3862), + TEST_PARSER(case3863), TEST_PARSER(case3864), TEST_PARSER(case3865), + TEST_PARSER(case3866), TEST_PARSER(case3867), TEST_PARSER(case3868), + TEST_PARSER(case3869), TEST_PARSER(case3870), TEST_PARSER(case3871), + TEST_PARSER(case3872), TEST_PARSER(case3873), TEST_PARSER(case3874), + TEST_PARSER(case3875), TEST_PARSER(case3876), TEST_PARSER(case3877), + TEST_PARSER(case3878), TEST_PARSER(case3879), TEST_PARSER(case3880), + TEST_PARSER(case3881), TEST_PARSER(case3882), TEST_PARSER(case3883), + TEST_PARSER(case3884), TEST_PARSER(case3885), TEST_PARSER(case3886), + TEST_PARSER(case3887), TEST_PARSER(case3888), TEST_PARSER(case3889), + TEST_PARSER(case3890), TEST_PARSER(case3891), TEST_PARSER(case3892), + TEST_PARSER(case3893), TEST_PARSER(case3894), TEST_PARSER(case3895), + TEST_PARSER(case3896), TEST_PARSER(case3897), TEST_PARSER(case3898), + TEST_PARSER(case3899), - TEST_PARSER(case3900), - TEST_PARSER(case3901), - TEST_PARSER(case3902), - TEST_PARSER(case3903), - TEST_PARSER(case3904), - TEST_PARSER(case3905), - TEST_PARSER(case3906), - TEST_PARSER(case3907), - TEST_PARSER(case3908), - TEST_PARSER(case3909), - TEST_PARSER(case3910), - TEST_PARSER(case3911), - TEST_PARSER(case3912), - TEST_PARSER(case3913), - TEST_PARSER(case3914), - TEST_PARSER(case3915), - TEST_PARSER(case3916), - TEST_PARSER(case3917), - TEST_PARSER(case3918), - TEST_PARSER(case3919), - TEST_PARSER(case3920), - TEST_PARSER(case3921), - TEST_PARSER(case3922), - TEST_PARSER(case3923), - TEST_PARSER(case3924), - TEST_PARSER(case3925), - TEST_PARSER(case3926), - TEST_PARSER(case3927), - TEST_PARSER(case3928), - TEST_PARSER(case3929), - TEST_PARSER(case3930), - TEST_PARSER(case3931), - TEST_PARSER(case3932), - TEST_PARSER(case3933), - TEST_PARSER(case3934), - TEST_PARSER(case3935), - TEST_PARSER(case3936), - TEST_PARSER(case3937), - TEST_PARSER(case3938), - TEST_PARSER(case3939), - TEST_PARSER(case3940), - TEST_PARSER(case3941), - TEST_PARSER(case3942), - TEST_PARSER(case3943), - TEST_PARSER(case3944), - TEST_PARSER(case3945), - TEST_PARSER(case3946), - TEST_PARSER(case3947), - TEST_PARSER(case3948), - TEST_PARSER(case3949), - TEST_PARSER(case3950), - TEST_PARSER(case3951), - TEST_PARSER(case3952), - TEST_PARSER(case3953), - TEST_PARSER(case3954), - TEST_PARSER(case3955), - TEST_PARSER(case3956), - TEST_PARSER(case3957), - TEST_PARSER(case3958), - TEST_PARSER(case3959), - TEST_PARSER(case3960), - TEST_PARSER(case3961), - TEST_PARSER(case3962), - TEST_PARSER(case3963), - TEST_PARSER(case3964), - TEST_PARSER(case3965), - TEST_PARSER(case3966), - TEST_PARSER(case3967), - TEST_PARSER(case3968), - TEST_PARSER(case3969), - TEST_PARSER(case3970), - TEST_PARSER(case3971), - TEST_PARSER(case3972), - TEST_PARSER(case3973), - TEST_PARSER(case3974), - TEST_PARSER(case3975), - TEST_PARSER(case3976), - TEST_PARSER(case3977), - TEST_PARSER(case3978), - TEST_PARSER(case3979), - TEST_PARSER(case3980), - TEST_PARSER(case3981), - TEST_PARSER(case3982), - TEST_PARSER(case3983), - TEST_PARSER(case3984), - TEST_PARSER(case3985), - TEST_PARSER(case3986), - TEST_PARSER(case3987), - TEST_PARSER(case3988), - TEST_PARSER(case3989), - TEST_PARSER(case3990), - TEST_PARSER(case3991), - TEST_PARSER(case3992), - TEST_PARSER(case3993), - TEST_PARSER(case3994), - TEST_PARSER(case3995), - TEST_PARSER(case3996), - TEST_PARSER(case3997), - TEST_PARSER(case3998), - TEST_PARSER(case3999) - }; + TEST_PARSER(case3900), TEST_PARSER(case3901), TEST_PARSER(case3902), + TEST_PARSER(case3903), TEST_PARSER(case3904), TEST_PARSER(case3905), + TEST_PARSER(case3906), TEST_PARSER(case3907), TEST_PARSER(case3908), + TEST_PARSER(case3909), TEST_PARSER(case3910), TEST_PARSER(case3911), + TEST_PARSER(case3912), TEST_PARSER(case3913), TEST_PARSER(case3914), + TEST_PARSER(case3915), TEST_PARSER(case3916), TEST_PARSER(case3917), + TEST_PARSER(case3918), TEST_PARSER(case3919), TEST_PARSER(case3920), + TEST_PARSER(case3921), TEST_PARSER(case3922), TEST_PARSER(case3923), + TEST_PARSER(case3924), TEST_PARSER(case3925), TEST_PARSER(case3926), + TEST_PARSER(case3927), TEST_PARSER(case3928), TEST_PARSER(case3929), + TEST_PARSER(case3930), TEST_PARSER(case3931), TEST_PARSER(case3932), + TEST_PARSER(case3933), TEST_PARSER(case3934), TEST_PARSER(case3935), + TEST_PARSER(case3936), TEST_PARSER(case3937), TEST_PARSER(case3938), + TEST_PARSER(case3939), TEST_PARSER(case3940), TEST_PARSER(case3941), + TEST_PARSER(case3942), TEST_PARSER(case3943), TEST_PARSER(case3944), + TEST_PARSER(case3945), TEST_PARSER(case3946), TEST_PARSER(case3947), + TEST_PARSER(case3948), TEST_PARSER(case3949), TEST_PARSER(case3950), + TEST_PARSER(case3951), TEST_PARSER(case3952), TEST_PARSER(case3953), + TEST_PARSER(case3954), TEST_PARSER(case3955), TEST_PARSER(case3956), + TEST_PARSER(case3957), TEST_PARSER(case3958), TEST_PARSER(case3959), + TEST_PARSER(case3960), TEST_PARSER(case3961), TEST_PARSER(case3962), + TEST_PARSER(case3963), TEST_PARSER(case3964), TEST_PARSER(case3965), + TEST_PARSER(case3966), TEST_PARSER(case3967), TEST_PARSER(case3968), + TEST_PARSER(case3969), TEST_PARSER(case3970), TEST_PARSER(case3971), + TEST_PARSER(case3972), TEST_PARSER(case3973), TEST_PARSER(case3974), + TEST_PARSER(case3975), TEST_PARSER(case3976), TEST_PARSER(case3977), + TEST_PARSER(case3978), TEST_PARSER(case3979), TEST_PARSER(case3980), + TEST_PARSER(case3981), TEST_PARSER(case3982), TEST_PARSER(case3983), + TEST_PARSER(case3984), TEST_PARSER(case3985), TEST_PARSER(case3986), + TEST_PARSER(case3987), TEST_PARSER(case3988), TEST_PARSER(case3989), + TEST_PARSER(case3990), TEST_PARSER(case3991), TEST_PARSER(case3992), + TEST_PARSER(case3993), TEST_PARSER(case3994), TEST_PARSER(case3995), + TEST_PARSER(case3996), TEST_PARSER(case3997), TEST_PARSER(case3998), + TEST_PARSER(case3999)}; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/tests/ParserTester_0000_0999.cpp b/C/tests/ParserTester_0000_0999.cpp index c398e737c..5a04f6681 100644 --- a/C/tests/ParserTester_0000_0999.cpp +++ b/C/tests/ParserTester_0000_0999.cpp @@ -30,6441 +30,3642 @@ #include #include #include -#include #include +#include using namespace psy; using namespace C; -void ParserTester::case0001() -{ - parse("int x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0002() -{ - parse("x y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator })); -} - -void ParserTester::case0003() -{ - parse("int x , y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0004() -{ - parse("int x = 1;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - ExpressionInitializer, - IntegerConstantExpression })); -} - -void ParserTester::case0005() -{ - parse("int x = 1, y ;") ; -} - -void ParserTester::case0006() -{ - parse("int x = 1, y = 2;") ; -} - -void ParserTester::case0007() -{ - parse("int x , y = 3;") ; -} - -void ParserTester::case0008() -{ - parse("x y = 1 ;") ; -} - -void ParserTester::case0009() -{ - parse("const int x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - ConstQualifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0010() -{ - parse("int const x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ConstQualifier, - IdentifierDeclarator })); -} - -void ParserTester::case0011() -{ - parse("const int volatile x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - ConstQualifier, - BuiltinTypeSpecifier, - VolatileQualifier, - IdentifierDeclarator })); -} - -void ParserTester::case0012() -{ - parse("int * x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0013() -{ - parse("int * x = 0 ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator, - ExpressionInitializer, - IntegerConstantExpression })); -} - -void ParserTester::case0014() -{ - parse("int * const x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - ConstQualifier, - IdentifierDeclarator })); -} - -void ParserTester::case0015() -{ - parse("int const * x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ConstQualifier, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0016() -{ - parse("const int * x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - ConstQualifier, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0017() -{ - parse("int * x , y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0018() -{ - parse("int * x , * y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0019() -{ - parse("int * x = 0, * y = 0 ;") ; -} - -void ParserTester::case0020() -{ - parse("const int * x = 0, y ;") ; -} - -void ParserTester::case0021() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0005); - - parse("int double x ;") ; -} - -void ParserTester::case0022() -{ - /* - * Notes: - * - `long int y ;' - * Good. - * - * - `typedef int x ; long x y;' - * Good. - * - * - `x ; int y ;' - * `x' is missing a type-specifier. - */ - - parse("x int y ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator) - .diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); -} - -void ParserTester::case0023() -{ - /* - * Notes: - * - `long int y ;' - * Good. - * - * - `typedef int x ; long x y ;' - * Not Good. - */ - - parse("long x y ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); -} - -void ParserTester::case0024() -{ - parse("x * double y ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} - -void ParserTester::case0025() -{ - parse("double x * y ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); -} - -void ParserTester::case0026() -{ - parse("x * const double y ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} - -void ParserTester::case0027() -{ - parse("double * const x y ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); -} - -void ParserTester::case0028() -{ - // Not a syntactic error, but diagnoses a semantic warning. - CROSS_REFERENCE_TEST(BinderTester::case0001) ; - - parse("const int ;", - Expectation().AST({ TranslationUnit, - IncompleteDeclaration, - ConstQualifier, - BuiltinTypeSpecifier })); -} - -void ParserTester::case0029() -{ - parse("const int , double x ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} - -void ParserTester::case0030() -{ - parse("int x = 1 {", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclaratorAndInitializer)); -} - -void ParserTester::case0031() -{ - parse("int ( x ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ParenthesizedDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0032() -{ - parse("int ( ( x ) );", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0033() -{ - parse("int ( ( ( x ) ) );", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0034() -{ - parse("x ( y ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - ParenthesizedDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0035() -{ - parse("x ( ( y ) );", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0036() -{ - parse("* x ;", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier) - .AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0037() -{ - parse("* ( x ) ;", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier) - .AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - PointerDeclarator, - ParenthesizedDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0038() -{ - parse("int ( * x ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0039() -{ - parse("x ( * y ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0040() -{ - CROSS_REFERENCE_TEST(BinderTester::case0013); // Semantic warning. - - parse("int ;"); -} - -void ParserTester::case0041() -{ - parse("x ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); -} - -void ParserTester::case0042() -{ - parse("_Atomic int x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - AtomicQualifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0043() -{ - parse("_Atomic x y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - AtomicQualifier, - TypedefName, - IdentifierDeclarator })); -} - -void ParserTester::case0044() -{ - parse("_Atomic ( int ) x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - AtomicTypeSpecifier, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0045() -{ - parse("_Atomic ( x ) y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - AtomicTypeSpecifier, - TypeName, - TypedefName, - AbstractDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0046() -{ - parse("_Complex double x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0047() -{ - parse("_Complex float x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0048() -{ - parse("double _Complex x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0049() -{ - parse("float _Complex x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0050() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0016); - - parse("double _Complex int x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0051() -{ - parse("_Complex x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0052() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0016); - - parse("int int x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0053() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0018); - - parse("_Complex _Complex x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0054() -{ - parse("x int ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator) - .diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); -} - -void ParserTester::case0055() -{ - parse("const x ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - ConstQualifier, - IdentifierDeclarator })); -} - -void ParserTester::case0056() -{ - parse("const * ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); +void ParserTester::case0001() { + parse("int x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0057() -{ - parse("__complex__ x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator })); +void ParserTester::case0002() { + parse("x y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, IdentifierDeclarator})); } -void ParserTester::case0058() -{ - parse("__complex__ double x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); +void ParserTester::case0003() { + parse("int x , y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, + IdentifierDeclarator})); } -void ParserTester::case0059() -{ - parse("double __complex__ x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); +void ParserTester::case0004() { + parse("int x = 1;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, + ExpressionInitializer, IntegerConstantExpression})); } -void ParserTester::case0060() -{ - parse("__complex__ float x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} +void ParserTester::case0005() { parse("int x = 1, y ;"); } -void ParserTester::case0061() -{ - parse("float __complex__ x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); +void ParserTester::case0006() { parse("int x = 1, y = 2;"); } -} +void ParserTester::case0007() { parse("int x , y = 3;"); } -void ParserTester::case0062() -{ - parse("__complex__ int x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} +void ParserTester::case0008() { parse("x y = 1 ;"); } -void ParserTester::case0063() -{ - parse("int __complex__ x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); +void ParserTester::case0009() { + parse("const int x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + ConstQualifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0064() -{ - +void ParserTester::case0010() { + parse("int const x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ConstQualifier, + IdentifierDeclarator})); } -void ParserTester::case0065() -{ - +void ParserTester::case0011() { + parse("const int volatile x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + ConstQualifier, BuiltinTypeSpecifier, + VolatileQualifier, IdentifierDeclarator})); } -void ParserTester::case0066() -{ - +void ParserTester::case0012() { + parse("int * x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, + IdentifierDeclarator})); } -void ParserTester::case0067() -{ - +void ParserTester::case0013() { + parse("int * x = 0 ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, + IdentifierDeclarator, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case0068() -{ +void ParserTester::case0014() { + parse("int * const x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, + ConstQualifier, IdentifierDeclarator})); } -void ParserTester::case0069() -{ - +void ParserTester::case0015() { + parse("int const * x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ConstQualifier, + PointerDeclarator, IdentifierDeclarator})); } -void ParserTester::case0070() -{ - +void ParserTester::case0016() { + parse("const int * x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + ConstQualifier, BuiltinTypeSpecifier, + PointerDeclarator, IdentifierDeclarator})); } -void ParserTester::case0071() -{ - +void ParserTester::case0017() { + parse("int * x , y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, + IdentifierDeclarator, IdentifierDeclarator})); } -void ParserTester::case0072() -{ +void ParserTester::case0018() { + parse("int * x , * y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, + IdentifierDeclarator, PointerDeclarator, + IdentifierDeclarator})); } -void ParserTester::case0073() -{ +void ParserTester::case0019() { parse("int * x = 0, * y = 0 ;"); } -} +void ParserTester::case0020() { parse("const int * x = 0, y ;"); } -void ParserTester::case0074() -{ +void ParserTester::case0021() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0005); + parse("int double x ;"); } -void ParserTester::case0075() -{ +void ParserTester::case0022() { + /* + * Notes: + * - `long int y ;' + * Good. + * + * - `typedef int x ; long x y;' + * Good. + * + * - `x ; int y ;' + * `x' is missing a type-specifier. + */ + parse("x int y ;", + Expectation() + .diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator) + .diagnostic( + Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); } -void ParserTester::case0076() -{ +void ParserTester::case0023() { + /* + * Notes: + * - `long int y ;' + * Good. + * + * - `typedef int x ; long x y ;' + * Not Good. + */ + parse("long x y ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0077() -{ - +void ParserTester::case0024() { + parse( + "x * double y ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0078() -{ - +void ParserTester::case0025() { + parse("double x * y ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0079() -{ +void ParserTester::case0026() { + parse( + "x * const double y ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); +} +void ParserTester::case0027() { + parse("double * const x y ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0080() -{ +void ParserTester::case0028() { + // Not a syntactic error, but diagnoses a semantic warning. + CROSS_REFERENCE_TEST(BinderTester::case0001); + parse("const int ;", + Expectation().AST({TranslationUnit, IncompleteDeclaration, + ConstQualifier, BuiltinTypeSpecifier})); } -void ParserTester::case0081() -{ +void ParserTester::case0029() { + parse( + "const int , double x ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0082() -{ +void ParserTester::case0030() { + parse("int x = 1 {", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFOLLOWofDeclaratorAndInitializer)); } -void ParserTester::case0083() -{ - +void ParserTester::case0031() { + parse("int ( x ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ParenthesizedDeclarator, + IdentifierDeclarator})); } -void ParserTester::case0084() -{ +void ParserTester::case0032() { + parse("int ( ( x ) );", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ParenthesizedDeclarator, + ParenthesizedDeclarator, IdentifierDeclarator})); +} +void ParserTester::case0033() { + parse("int ( ( ( x ) ) );", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ParenthesizedDeclarator, + ParenthesizedDeclarator, ParenthesizedDeclarator, + IdentifierDeclarator})); } -void ParserTester::case0085() -{ +void ParserTester::case0034() { + parse("x ( y ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, ParenthesizedDeclarator, + IdentifierDeclarator})); +} +void ParserTester::case0035() { + parse("x ( ( y ) );", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, ParenthesizedDeclarator, + ParenthesizedDeclarator, IdentifierDeclarator})); } -void ParserTester::case0086() -{ +void ParserTester::case0036() { + parse( + "* x ;", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier) + .AST({TranslationUnit, VariableAndOrFunctionDeclaration, + PointerDeclarator, IdentifierDeclarator})); +} +void ParserTester::case0037() { + parse( + "* ( x ) ;", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier) + .AST({TranslationUnit, VariableAndOrFunctionDeclaration, + PointerDeclarator, ParenthesizedDeclarator, + IdentifierDeclarator})); } -void ParserTester::case0087() -{ +void ParserTester::case0038() { + parse("int ( * x ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator})); +} +void ParserTester::case0039() { + parse("x ( * y ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator})); } -void ParserTester::case0088() -{ +void ParserTester::case0040() { + CROSS_REFERENCE_TEST(BinderTester::case0013); // Semantic warning. + parse("int ;"); } -void ParserTester::case0089() -{ +void ParserTester::case0041() { + parse("x ;", Expectation().diagnostic( + Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); } -void ParserTester::case0090() -{ +void ParserTester::case0042() { + parse("_Atomic int x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + AtomicQualifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0091() -{ +void ParserTester::case0043() { + parse( + "_Atomic x y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + AtomicQualifier, TypedefName, IdentifierDeclarator})); } -void ParserTester::case0092() -{ +void ParserTester::case0044() { + parse("_Atomic ( int ) x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + AtomicTypeSpecifier, TypeName, BuiltinTypeSpecifier, + AbstractDeclarator, IdentifierDeclarator})); } -void ParserTester::case0093() -{ +void ParserTester::case0045() { + parse("_Atomic ( x ) y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + AtomicTypeSpecifier, TypeName, TypedefName, + AbstractDeclarator, IdentifierDeclarator})); +} +void ParserTester::case0046() { + parse("_Complex double x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0094() -{ +void ParserTester::case0047() { + parse("_Complex float x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0095() -{ +void ParserTester::case0048() { + parse("double _Complex x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0096() -{ +void ParserTester::case0049() { + parse("float _Complex x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0097() -{ +void ParserTester::case0050() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0016); + parse("double _Complex int x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0098() -{ +void ParserTester::case0051() { + parse("_Complex x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0099() -{ +void ParserTester::case0052() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0016); + parse("int int x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0100() -{ - parse("void ( * ) ( ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} +void ParserTester::case0053() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0018); -void ParserTester::case0101() -{ - parse("void ( * x ) ( ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix })); + parse("_Complex _Complex x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0102() -{ - parse("void ( * x ) ( ) { }", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); +void ParserTester::case0054() { + parse("x int ;", + Expectation() + .diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator) + .diagnostic( + Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); } -void ParserTester::case0103() -{ - parse("void ( ( * x ) ) ( ) { }", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); +void ParserTester::case0055() { + parse("const x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + ConstQualifier, IdentifierDeclarator})); } -void ParserTester::case0104() -{ - parse("void ( ( * x ) ) ( ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix })); +void ParserTester::case0056() { + parse( + "const * ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0105() -{ - parse("void ( * ) ( int ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); +void ParserTester::case0057() { + parse("__complex__ x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0106() -{ - parse("void ( * x ) ( int ) ;") ; +void ParserTester::case0058() { + parse("__complex__ double x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0107() -{ - parse("x ( * y ) ( int ) ;") ; +void ParserTester::case0059() { + parse("double __complex__ x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0108() -{ - // The `signal' function. - - parse("void ( * x ( int , void ( * y ) ( int ) ) ) ( int ) ;") ; +void ParserTester::case0060() { + parse("__complex__ float x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0109() -{ - parse("void ( ( * x ) ) ( ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix })); -} - -void ParserTester::case0110() -{ - parse("void ( ( ( * x ) ( ) ) );", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix })); -} - -void ParserTester::case0111() -{ - parse("void ( ( ( ( * x ) ) ( ) ) );", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - FunctionDeclarator, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix })); -} - -void ParserTester::case0112() -{ - parse("int ( * x ) [ 4 ] [ y + 1 ] ;"); -} - -void ParserTester::case0113() -{ - parse("void ( * * * x ) ( int ) ;"); -} - -void ParserTester::case0114() -{ - parse("x ( * * * y ) ( z ) ;"); -} - -void ParserTester::case0115() -{ - parse("x ( * ( * ( * y ) ) ) ( z ) ;"); -} - -void ParserTester::case0116() -{ - parse("int ( * x ) [ 1 ] ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); -} - -void ParserTester::case0117() -{ - parse("x ( * y ) [ 1 ];", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - ArrayDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); -} - -void ParserTester::case0118() -{ - parse("int ( * x ) [ 1 ] [ 3 ] ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - ArrayDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IntegerConstantExpression, - SubscriptSuffix, - IntegerConstantExpression })); +void ParserTester::case0061() { + parse("float __complex__ x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0119() -{ - parse("void ( * x ) ( ) = 0 ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ExpressionInitializer, - IntegerConstantExpression })); +void ParserTester::case0062() { + parse("__complex__ int x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0120() -{ - parse("void ( * * x ) ( ) = 0 ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ExpressionInitializer, - IntegerConstantExpression })); +void ParserTester::case0063() { + parse("int __complex__ x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, BuiltinTypeSpecifier, + IdentifierDeclarator})); } -void ParserTester::case0121() -{ - parse("void ( * ( x ) ) ( ) = 0 ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - ParenthesizedDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ExpressionInitializer, - IntegerConstantExpression })); -} +void ParserTester::case0064() {} -void ParserTester::case0122() -{ - parse("void ( * * ( x ) ) ( ) = 0 ;"); -} +void ParserTester::case0065() {} -void ParserTester::case0123() -{ - parse("void ( * ( * ( x ) ) ) ( ) = 0 ;"); -} +void ParserTester::case0066() {} -void ParserTester::case0124() -{ +void ParserTester::case0067() {} -} +void ParserTester::case0068() {} -void ParserTester::case0125() -{ +void ParserTester::case0069() {} -} +void ParserTester::case0070() {} -void ParserTester::case0126() -{ +void ParserTester::case0071() {} -} +void ParserTester::case0072() {} -void ParserTester::case0127() -{ +void ParserTester::case0073() {} -} +void ParserTester::case0074() {} -void ParserTester::case0128() -{ +void ParserTester::case0075() {} -} +void ParserTester::case0076() {} -void ParserTester::case0129() -{ +void ParserTester::case0077() {} -} +void ParserTester::case0078() {} -void ParserTester::case0130() -{ +void ParserTester::case0079() {} -} +void ParserTester::case0080() {} -void ParserTester::case0131() -{ +void ParserTester::case0081() {} -} +void ParserTester::case0082() {} -void ParserTester::case0132() -{ +void ParserTester::case0083() {} -} +void ParserTester::case0084() {} -void ParserTester::case0133() -{ +void ParserTester::case0085() {} -} +void ParserTester::case0086() {} -void ParserTester::case0134() -{ +void ParserTester::case0087() {} -} +void ParserTester::case0088() {} -void ParserTester::case0135() -{ +void ParserTester::case0089() {} -} +void ParserTester::case0090() {} -void ParserTester::case0136() -{ +void ParserTester::case0091() {} -} +void ParserTester::case0092() {} -void ParserTester::case0137() -{ +void ParserTester::case0093() {} -} +void ParserTester::case0094() {} -void ParserTester::case0138() -{ +void ParserTester::case0095() {} -} +void ParserTester::case0096() {} -void ParserTester::case0139() -{ +void ParserTester::case0097() {} -} +void ParserTester::case0098() {} -void ParserTester::case0140() -{ +void ParserTester::case0099() {} +void ParserTester::case0100() { + parse( + "void ( * ) ( ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0141() -{ - +void ParserTester::case0101() { + parse("void ( * x ) ( ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, PointerDeclarator, + IdentifierDeclarator, ParameterSuffix})); } -void ParserTester::case0142() -{ - +void ParserTester::case0102() { + parse("void ( * x ) ( ) { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0143() -{ - +void ParserTester::case0103() { + parse("void ( ( * x ) ) ( ) { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0144() -{ - +void ParserTester::case0104() { + parse("void ( ( * x ) ) ( ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + ParameterSuffix})); } -void ParserTester::case0145() -{ - +void ParserTester::case0105() { + parse( + "void ( * ) ( int ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0146() -{ +void ParserTester::case0106() { parse("void ( * x ) ( int ) ;"); } -} +void ParserTester::case0107() { parse("x ( * y ) ( int ) ;"); } -void ParserTester::case0147() -{ +void ParserTester::case0108() { + // The `signal' function. + parse("void ( * x ( int , void ( * y ) ( int ) ) ) ( int ) ;"); } -void ParserTester::case0148() -{ - +void ParserTester::case0109() { + parse("void ( ( * x ) ) ( ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + ParameterSuffix})); } -void ParserTester::case0149() -{ +void ParserTester::case0110() { + parse("void ( ( ( * x ) ( ) ) );", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ParenthesizedDeclarator, + ParenthesizedDeclarator, FunctionDeclarator, + ParenthesizedDeclarator, PointerDeclarator, + IdentifierDeclarator, ParameterSuffix})); +} +void ParserTester::case0111() { + parse("void ( ( ( ( * x ) ) ( ) ) );", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ParenthesizedDeclarator, + ParenthesizedDeclarator, FunctionDeclarator, + ParenthesizedDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + ParameterSuffix})); } -void ParserTester::case0150() -{ +void ParserTester::case0112() { parse("int ( * x ) [ 4 ] [ y + 1 ] ;"); } -} +void ParserTester::case0113() { parse("void ( * * * x ) ( int ) ;"); } -void ParserTester::case0151() -{ +void ParserTester::case0114() { parse("x ( * * * y ) ( z ) ;"); } -} +void ParserTester::case0115() { parse("x ( * ( * ( * y ) ) ) ( z ) ;"); } -void ParserTester::case0152() -{ +void ParserTester::case0116() { + parse("int ( * x ) [ 1 ] ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ArrayDeclarator, + ParenthesizedDeclarator, PointerDeclarator, + IdentifierDeclarator, SubscriptSuffix, + IntegerConstantExpression})); +} +void ParserTester::case0117() { + parse( + "x ( * y ) [ 1 ];", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, ArrayDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + SubscriptSuffix, IntegerConstantExpression})); } -void ParserTester::case0153() -{ +void ParserTester::case0118() { + parse("int ( * x ) [ 1 ] [ 3 ] ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ArrayDeclarator, + ArrayDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + SubscriptSuffix, IntegerConstantExpression, + SubscriptSuffix, IntegerConstantExpression})); +} +void ParserTester::case0119() { + parse("void ( * x ) ( ) = 0 ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, PointerDeclarator, + IdentifierDeclarator, ParameterSuffix, + ExpressionInitializer, IntegerConstantExpression})); } -void ParserTester::case0154() -{ +void ParserTester::case0120() { + parse("void ( * * x ) ( ) = 0 ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, PointerDeclarator, + PointerDeclarator, IdentifierDeclarator, + ParameterSuffix, ExpressionInitializer, + IntegerConstantExpression})); +} +void ParserTester::case0121() { + parse("void ( * ( x ) ) ( ) = 0 ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, PointerDeclarator, + ParenthesizedDeclarator, IdentifierDeclarator, + ParameterSuffix, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case0155() -{ +void ParserTester::case0122() { parse("void ( * * ( x ) ) ( ) = 0 ;"); } -} +void ParserTester::case0123() { parse("void ( * ( * ( x ) ) ) ( ) = 0 ;"); } -void ParserTester::case0156() -{ +void ParserTester::case0124() {} -} +void ParserTester::case0125() {} -void ParserTester::case0157() -{ +void ParserTester::case0126() {} -} +void ParserTester::case0127() {} -void ParserTester::case0158() -{ +void ParserTester::case0128() {} -} +void ParserTester::case0129() {} -void ParserTester::case0159() -{ +void ParserTester::case0130() {} -} +void ParserTester::case0131() {} -void ParserTester::case0160() -{ +void ParserTester::case0132() {} -} +void ParserTester::case0133() {} -void ParserTester::case0161() -{ +void ParserTester::case0134() {} -} +void ParserTester::case0135() {} -void ParserTester::case0162() -{ +void ParserTester::case0136() {} -} +void ParserTester::case0137() {} -void ParserTester::case0163() -{ +void ParserTester::case0138() {} -} +void ParserTester::case0139() {} -void ParserTester::case0164() -{ +void ParserTester::case0140() {} -} +void ParserTester::case0141() {} -void ParserTester::case0165() -{ +void ParserTester::case0142() {} -} +void ParserTester::case0143() {} -void ParserTester::case0166() -{ +void ParserTester::case0144() {} -} +void ParserTester::case0145() {} -void ParserTester::case0167() -{ +void ParserTester::case0146() {} -} +void ParserTester::case0147() {} -void ParserTester::case0168() -{ +void ParserTester::case0148() {} -} +void ParserTester::case0149() {} -void ParserTester::case0169() -{ +void ParserTester::case0150() {} -} +void ParserTester::case0151() {} -void ParserTester::case0170() -{ +void ParserTester::case0152() {} -} +void ParserTester::case0153() {} -void ParserTester::case0171() -{ +void ParserTester::case0154() {} -} +void ParserTester::case0155() {} -void ParserTester::case0172() -{ +void ParserTester::case0156() {} -} +void ParserTester::case0157() {} -void ParserTester::case0173() -{ +void ParserTester::case0158() {} -} +void ParserTester::case0159() {} -void ParserTester::case0174() -{ +void ParserTester::case0160() {} -} +void ParserTester::case0161() {} -void ParserTester::case0175() -{ +void ParserTester::case0162() {} -} +void ParserTester::case0163() {} -void ParserTester::case0176() -{ +void ParserTester::case0164() {} -} +void ParserTester::case0165() {} -void ParserTester::case0177() -{ +void ParserTester::case0166() {} -} +void ParserTester::case0167() {} -void ParserTester::case0178() -{ +void ParserTester::case0168() {} -} +void ParserTester::case0169() {} -void ParserTester::case0179() -{ +void ParserTester::case0170() {} -} +void ParserTester::case0171() {} -void ParserTester::case0180() -{ +void ParserTester::case0172() {} -} +void ParserTester::case0173() {} -void ParserTester::case0181() -{ +void ParserTester::case0174() {} -} +void ParserTester::case0175() {} -void ParserTester::case0182() -{ +void ParserTester::case0176() {} -} +void ParserTester::case0177() {} -void ParserTester::case0183() -{ +void ParserTester::case0178() {} -} +void ParserTester::case0179() {} -void ParserTester::case0184() -{ +void ParserTester::case0180() {} -} +void ParserTester::case0181() {} -void ParserTester::case0185() -{ +void ParserTester::case0182() {} -} +void ParserTester::case0183() {} -void ParserTester::case0186() -{ +void ParserTester::case0184() {} -} +void ParserTester::case0185() {} -void ParserTester::case0187() -{ +void ParserTester::case0186() {} -} +void ParserTester::case0187() {} -void ParserTester::case0188() -{ +void ParserTester::case0188() {} -} +void ParserTester::case0189() {} -void ParserTester::case0189() -{ +void ParserTester::case0190() {} -} +void ParserTester::case0191() {} -void ParserTester::case0190() -{ +void ParserTester::case0192() {} -} +void ParserTester::case0193() {} -void ParserTester::case0191() -{ +void ParserTester::case0194() {} -} +void ParserTester::case0195() {} -void ParserTester::case0192() -{ +void ParserTester::case0196() {} -} +void ParserTester::case0197() {} -void ParserTester::case0193() -{ +void ParserTester::case0198() {} +void ParserTester::case0199() {} + +void ParserTester::case0200() { + parse("void x ( ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix})); } -void ParserTester::case0194() -{ +void ParserTester::case0201() { + parse("void x ( ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + CompoundStatement})); +} +void ParserTester::case0202() { + parse("void x { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0195() -{ +void ParserTester::case0203() { + parse("void x ( ) = 1 { }", + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_UnexpectedInitializerOfDeclarator)); +} +void ParserTester::case0204() { + parse("void ( x ) ( ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, IdentifierDeclarator, + ParameterSuffix, CompoundStatement})); } -void ParserTester::case0196() -{ +void ParserTester::case0205() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0008); + parse("void x ( ) ( ) { }"); } -void ParserTester::case0197() -{ +void ParserTester::case0206() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0009); + parse("void x ( ) ( ) ;"); } -void ParserTester::case0198() -{ +void ParserTester::case0207() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0010); + parse("int x ( ) [ ] ;"); } -void ParserTester::case0199() -{ +void ParserTester::case0208() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(ParserTester::case0111); + parse("int ( x ) ( ) [ ] ;"); } -void ParserTester::case0200() -{ - parse("void x ( ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix })); +void ParserTester::case0209() { + parse("int x ( void ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator})); } -void ParserTester::case0201() -{ - parse("void x ( ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - CompoundStatement })); +void ParserTester::case0210() { + parse("int x ( void ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator, CompoundStatement})); } -void ParserTester::case0202() -{ - parse("void x { }", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); +void ParserTester::case0211() { + parse("void x ( int ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator})); } -void ParserTester::case0203() -{ - parse("void x ( ) = 1 { }", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_UnexpectedInitializerOfDeclarator)); -} +void ParserTester::case0212() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0012); -void ParserTester::case0204() -{ - parse("void ( x ) ( ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - IdentifierDeclarator, - ParameterSuffix, - CompoundStatement })); + parse("void x ( int ) { }"); } -void ParserTester::case0205() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0008) ; - - parse("void x ( ) ( ) { }") ; +void ParserTester::case0213() { + parse("void x ( int y ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, CompoundStatement})); } -void ParserTester::case0206() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0009) ; +void ParserTester::case0214() { parse("double x( int y , double z ) ;"); } - parse("void x ( ) ( ) ;") ; +void ParserTester::case0215() { + parse("double x ( double ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator})); } -void ParserTester::case0207() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0010) ; - - parse("int x ( ) [ ] ;") ; +void ParserTester::case0216() { + parse("x ( int y ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); } -void ParserTester::case0208() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(ParserTester::case0111) ; +void ParserTester::case0217() { + parse("x ( y z ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); +} - parse("int ( x ) ( ) [ ] ;") ; +void ParserTester::case0218() { + parse("void x ( y ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, TypedefName, + AbstractDeclarator})); } -void ParserTester::case0209() -{ - parse("int x ( void ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case0210() -{ - parse("int x ( void ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - CompoundStatement })); -} - -void ParserTester::case0211() -{ - parse("void x ( int ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case0212() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0012) ; - - parse("void x ( int ) { }") ; -} - -void ParserTester::case0213() -{ - parse("void x ( int y ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0214() -{ - parse("double x( int y , double z ) ;") ; -} - -void ParserTester::case0215() -{ - parse("double x ( double ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case0216() -{ - parse("x ( int y ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); -} - -void ParserTester::case0217() -{ - parse("x ( y z ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); -} - -void ParserTester::case0218() -{ - parse("void x ( y ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - AbstractDeclarator })); -} - -void ParserTester::case0219() -{ - parse("void x ( y z ) ;") ; -} - -void ParserTester::case0220() -{ - parse("void x ( ( int z ) ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofParameterDeclaration)); -} - -void ParserTester::case0221() -{ - parse("x y ( void ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - TypedefName, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - CompoundStatement })); -} - -void ParserTester::case0222() -{ - parse("void x ( int * ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - AbstractDeclarator })); -} - -void ParserTester::case0223() -{ - parse("void x ( int ( * ) ) ;") ; -} - -void ParserTester::case0224() -{ - parse("void x ( int * [ 1 ] ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - ArrayDeclarator, - AbstractDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); -} - -void ParserTester::case0225() -{ - parse("void x ( int ( * ) [ 1 ] ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - AbstractDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); -} - -void ParserTester::case0226() -{ - parse("void x ( int ( * ) [ * ] ) ;") ; -} - -void ParserTester::case0227() -{ - parse("void x ( int * ( ));") ; -} - -void ParserTester::case0228() -{ - parse("void x ( int * ( void ));") ; -} - -void ParserTester::case0229() -{ - parse("void x ( int * ( int ));") ; -} - -void ParserTester::case0230() -{ - parse("void x ( int * ( int , double ));") ; -} - -void ParserTester::case0231() -{ - parse("void x ( int ( * const [ ] ) ( unsigned int , ... ));") ; -} - -void ParserTester::case0232() -{ - parse("int x , y ( ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix })); -} - -void ParserTester::case0233() -{ - parse("void ( ( x ) ) ( ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - IdentifierDeclarator, - ParameterSuffix, - CompoundStatement })); -} - -void ParserTester::case0234() -{ - parse("void ( ( ( x ) ) ( ) ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - ParenthesizedDeclarator, - FunctionDeclarator, - ParenthesizedDeclarator, - ParenthesizedDeclarator, - IdentifierDeclarator, - ParameterSuffix, - CompoundStatement })); -} - -void ParserTester::case0235() -{ - parse("inline double x ( double y ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - InlineSpecifier, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0236() -{ - parse("inline x y ( double z ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - InlineSpecifier, - TypedefName, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0237() -{ - parse("_Noreturn x y ( ) { }") ; -} - -void ParserTester::case0238() -{ - parse("_Noreturn void x ( ) { }") ; -} - -void ParserTester::case0239() -{ - parse("int * x ( ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix })); -} - -void ParserTester::case0240() -{ - parse("x * y ( ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - PointerDeclarator, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix })); -} - -void ParserTester::case0241() -{ - parse("int * x ( ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - PointerDeclarator, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - CompoundStatement })); -} - -void ParserTester::case0242() -{ - parse("x * y ( ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - TypedefName, - PointerDeclarator, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - CompoundStatement })); -} - -void ParserTester::case0243() -{ - parse("int [ ] x ( ) { }", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} - -void ParserTester::case0244() -{ - // A function taking a parameter of type double and returning - // a pointer to a function taking int as a parameter and - // returning void. - - parse("void ( * x ( double ) ) ( int ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - CompoundStatement })); -} - -void ParserTester::case0245() -{ - parse("void x ( y ) { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0246() -{ - parse("void x ( y , int ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - AbstractDeclarator, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case0247() -{ - parse("void x ( int , y ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - ParameterDeclaration, - TypedefName, - AbstractDeclarator })); -} - -void ParserTester::case0248() -{ - parse("void x ( y , z ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - AbstractDeclarator, - ParameterDeclaration, - TypedefName, - AbstractDeclarator })); -} - -void ParserTester::case0249() -{ - parse("void x ( y * ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - PointerDeclarator, - AbstractDeclarator })); -} - -void ParserTester::case0250() -{ - parse("void x ( y * , int ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - PointerDeclarator, - AbstractDeclarator, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case0251() -{ - parse("void x ( int , y * ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - ParameterDeclaration, - TypedefName, - PointerDeclarator, - AbstractDeclarator })); -} - -void ParserTester::case0252() -{ - parse("void x ( y * , z * ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - PointerDeclarator, - AbstractDeclarator, - ParameterDeclaration, - TypedefName, - PointerDeclarator, - AbstractDeclarator })); -} - -void ParserTester::case0253() -{ - parse("void x ( y const ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - ConstQualifier, - AbstractDeclarator })); -} - -void ParserTester::case0254() -{ - parse("void x ( const y ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - ConstQualifier, - TypedefName, - AbstractDeclarator })); -} - -void ParserTester::case0255() -{ - parse("void x ( y const , int ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - ConstQualifier, - AbstractDeclarator, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case0256() -{ - parse("void x ( int , y const ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - ParameterDeclaration, - TypedefName, - ConstQualifier, - AbstractDeclarator })); -} - - -void ParserTester::case0257() -{ - parse("void x ( int * y , int ( * z ) ( w ) ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator, - ParameterDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - AbstractDeclarator })); -} - -void ParserTester::case0258() -{ - parse("void x ( int * y , int ( * z ) ( w * ) ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator, - ParameterDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - PointerDeclarator, - AbstractDeclarator })); -} - -void ParserTester::case0259() -{ - parse("void x ( int ( * y ) ( z ) , int * w ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - AbstractDeclarator, - ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0260() -{ - parse("void x ( int ( * y ) ( z * ) , int * w ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - TypedefName, - PointerDeclarator, - AbstractDeclarator, - ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator })); +void ParserTester::case0219() { parse("void x ( y z ) ;"); } + +void ParserTester::case0220() { + parse( + "void x ( ( int z ) ) ;", + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFIRSTofParameterDeclaration)); } -void ParserTester::case0261() -{ - parse("void x ( int [ ] ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - AbstractDeclarator, - SubscriptSuffix })) ; +void ParserTester::case0221() { + parse("x y ( void ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, TypedefName, + FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, + BuiltinTypeSpecifier, AbstractDeclarator, + CompoundStatement})); } -void ParserTester::case0262() -{ - parse("void x ( int [ 1 ] ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - AbstractDeclarator, - SubscriptSuffix, - IntegerConstantExpression })) ; +void ParserTester::case0222() { + parse("void x ( int * ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + PointerDeclarator, AbstractDeclarator})); } -void ParserTester::case0263() -{ +void ParserTester::case0223() { parse("void x ( int ( * ) ) ;"); } +void ParserTester::case0224() { + parse("void x ( int * [ 1 ] ) ;", + Expectation().AST( + {TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, BuiltinTypeSpecifier, + PointerDeclarator, ArrayDeclarator, AbstractDeclarator, + SubscriptSuffix, IntegerConstantExpression})); } -void ParserTester::case0264() -{ - +void ParserTester::case0225() { + parse("void x ( int ( * ) [ 1 ] ) ;", + Expectation().AST( + {TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, BuiltinTypeSpecifier, + ArrayDeclarator, ParenthesizedDeclarator, PointerDeclarator, + AbstractDeclarator, SubscriptSuffix, IntegerConstantExpression})); } -void ParserTester::case0265() -{ +void ParserTester::case0226() { parse("void x ( int ( * ) [ * ] ) ;"); } -} +void ParserTester::case0227() { parse("void x ( int * ( ));"); } -void ParserTester::case0266() -{ +void ParserTester::case0228() { parse("void x ( int * ( void ));"); } -} +void ParserTester::case0229() { parse("void x ( int * ( int ));"); } -void ParserTester::case0267() -{ +void ParserTester::case0230() { parse("void x ( int * ( int , double ));"); } +void ParserTester::case0231() { + parse("void x ( int ( * const [ ] ) ( unsigned int , ... ));"); } -void ParserTester::case0268() -{ - +void ParserTester::case0232() { + parse("int x , y ( ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, + FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix})); } -void ParserTester::case0269() -{ +void ParserTester::case0233() { + parse("void ( ( x ) ) ( ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, ParenthesizedDeclarator, + IdentifierDeclarator, ParameterSuffix, + CompoundStatement})); +} +void ParserTester::case0234() { + parse("void ( ( ( x ) ) ( ) ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, ParenthesizedDeclarator, + FunctionDeclarator, ParenthesizedDeclarator, + ParenthesizedDeclarator, IdentifierDeclarator, + ParameterSuffix, CompoundStatement})); } -void ParserTester::case0270() -{ +void ParserTester::case0235() { + parse("inline double x ( double y ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, InlineSpecifier, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, CompoundStatement})); +} +void ParserTester::case0236() { + parse("inline x y ( double z ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, InlineSpecifier, + TypedefName, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, CompoundStatement})); } -void ParserTester::case0271() -{ +void ParserTester::case0237() { parse("_Noreturn x y ( ) { }"); } -} +void ParserTester::case0238() { parse("_Noreturn void x ( ) { }"); } -void ParserTester::case0272() -{ +void ParserTester::case0239() { + parse("int * x ( ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, + FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix})); +} + +void ParserTester::case0240() { + parse("x * y ( ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, PointerDeclarator, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix})); +} +void ParserTester::case0241() { + parse("int * x ( ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, PointerDeclarator, + FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, CompoundStatement})); } -void ParserTester::case0273() -{ +void ParserTester::case0242() { + parse("x * y ( ) { }", + Expectation().AST({TranslationUnit, FunctionDefinition, TypedefName, + PointerDeclarator, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + CompoundStatement})); +} +void ParserTester::case0243() { + parse( + "int [ ] x ( ) { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); +} + +void ParserTester::case0244() { + // A function taking a parameter of type double and returning + // a pointer to a function taking int as a parameter and + // returning void. + + parse("void ( * x ( double ) ) ( int ) { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, ParenthesizedDeclarator, PointerDeclarator, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, AbstractDeclarator, + ParameterSuffix, ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator, CompoundStatement})); +} + +void ParserTester::case0245() { + parse("void x ( y ) { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0246() { + parse("void x ( y , int ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, TypedefName, + AbstractDeclarator, ParameterDeclaration, + BuiltinTypeSpecifier, AbstractDeclarator})); +} + +void ParserTester::case0247() { + parse("void x ( int , y ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator, ParameterDeclaration, + TypedefName, AbstractDeclarator})); +} + +void ParserTester::case0248() { + parse("void x ( y , z ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, TypedefName, + AbstractDeclarator, ParameterDeclaration, + TypedefName, AbstractDeclarator})); +} + +void ParserTester::case0249() { + parse("void x ( y * ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, TypedefName, PointerDeclarator, + AbstractDeclarator})); +} + +void ParserTester::case0250() { + parse("void x ( y * , int ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, TypedefName, PointerDeclarator, + AbstractDeclarator, ParameterDeclaration, + BuiltinTypeSpecifier, AbstractDeclarator})); +} + +void ParserTester::case0251() { + parse("void x ( int , y * ) ;", + Expectation().AST( + {TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator, ParameterDeclaration, TypedefName, + PointerDeclarator, AbstractDeclarator})); +} + +void ParserTester::case0252() { + parse("void x ( y * , z * ) ;", + Expectation().AST( + {TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, TypedefName, + PointerDeclarator, AbstractDeclarator, ParameterDeclaration, + TypedefName, PointerDeclarator, AbstractDeclarator})); +} + +void ParserTester::case0253() { + parse("void x ( y const ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, TypedefName, ConstQualifier, + AbstractDeclarator})); +} + +void ParserTester::case0254() { + parse("void x ( const y ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, ConstQualifier, TypedefName, + AbstractDeclarator})); +} + +void ParserTester::case0255() { + parse("void x ( y const , int ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, TypedefName, ConstQualifier, + AbstractDeclarator, ParameterDeclaration, + BuiltinTypeSpecifier, AbstractDeclarator})); +} + +void ParserTester::case0256() { + parse("void x ( int , y const ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator, ParameterDeclaration, + TypedefName, ConstQualifier, AbstractDeclarator})); +} + +void ParserTester::case0257() { + parse( + "void x ( int * y , int ( * z ) ( w ) ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + PointerDeclarator, IdentifierDeclarator, + ParameterDeclaration, BuiltinTypeSpecifier, + FunctionDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, + TypedefName, AbstractDeclarator})); +} + +void ParserTester::case0258() { + parse( + "void x ( int * y , int ( * z ) ( w * ) ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + PointerDeclarator, IdentifierDeclarator, + ParameterDeclaration, BuiltinTypeSpecifier, + FunctionDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, + TypedefName, PointerDeclarator, + AbstractDeclarator})); +} + +void ParserTester::case0259() { + parse( + "void x ( int ( * y ) ( z ) , int * w ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + FunctionDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, + TypedefName, AbstractDeclarator, + ParameterDeclaration, BuiltinTypeSpecifier, + PointerDeclarator, IdentifierDeclarator})); +} + +void ParserTester::case0260() { + parse( + "void x ( int ( * y ) ( z * ) , int * w ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + FunctionDeclarator, ParenthesizedDeclarator, + PointerDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, + TypedefName, PointerDeclarator, + AbstractDeclarator, ParameterDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, + IdentifierDeclarator})); +} + +void ParserTester::case0261() { + parse("void x ( int [ ] ) ;", + Expectation().AST( + {TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, BuiltinTypeSpecifier, + ArrayDeclarator, AbstractDeclarator, SubscriptSuffix})); +} + +void ParserTester::case0262() { + parse("void x ( int [ 1 ] ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + ArrayDeclarator, AbstractDeclarator, SubscriptSuffix, + IntegerConstantExpression})); +} + +void ParserTester::case0263() {} + +void ParserTester::case0264() {} + +void ParserTester::case0265() {} + +void ParserTester::case0266() {} + +void ParserTester::case0267() {} + +void ParserTester::case0268() {} + +void ParserTester::case0269() {} + +void ParserTester::case0270() {} + +void ParserTester::case0271() {} + +void ParserTester::case0272() {} + +void ParserTester::case0273() {} + +void ParserTester::case0274() {} + +void ParserTester::case0275() {} + +void ParserTester::case0276() {} + +void ParserTester::case0277() {} + +void ParserTester::case0278() {} + +void ParserTester::case0279() {} + +void ParserTester::case0280() { + parse("void x ( y ) int y ; { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, + ExtKR_ParameterDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0281() { + parse("void x ( y ) z y ; { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, + ExtKR_ParameterDeclaration, TypedefName, + IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0282() { + parse("void x ( y , z ) int y ; { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, ParameterDeclaration, + IdentifierDeclarator, ExtKR_ParameterDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0283() { + parse("void x ( y , z ) int y ; int z ; { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, ParameterDeclaration, + IdentifierDeclarator, ExtKR_ParameterDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, + ExtKR_ParameterDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0284() { + parse("void x ( y , z ) int y , z ; { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, ParameterDeclaration, + IdentifierDeclarator, ExtKR_ParameterDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, IdentifierDeclarator, + CompoundStatement})); +} + +void ParserTester::case0285() { + parse("void x ( y , z ) int y ; int z ( int ) ; { }", + Expectation().AST({TranslationUnit, + FunctionDefinition, + BuiltinTypeSpecifier, + FunctionDeclarator, + IdentifierDeclarator, + ParameterSuffix, + ParameterDeclaration, + IdentifierDeclarator, + ParameterDeclaration, + IdentifierDeclarator, + ExtKR_ParameterDeclaration, + BuiltinTypeSpecifier, + IdentifierDeclarator, + ExtKR_ParameterDeclaration, + BuiltinTypeSpecifier, + FunctionDeclarator, + IdentifierDeclarator, + ParameterSuffix, + ParameterDeclaration, + BuiltinTypeSpecifier, + AbstractDeclarator, + CompoundStatement})); +} + +void ParserTester::case0286() { + parse("void x ( y ) struct z y ; { }", + Expectation().AST({TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, + ExtKR_ParameterDeclaration, StructTypeSpecifier, + IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0287() { + parse("void x ( y ) int * y ; { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, + ExtKR_ParameterDeclaration, BuiltinTypeSpecifier, + PointerDeclarator, IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0288() { + parse("int x ( y , z ) int * y , z ; { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, ParameterDeclaration, + IdentifierDeclarator, ExtKR_ParameterDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, IdentifierDeclarator, + IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0289() { + parse("int x ( y , z ) int * y , * z ; { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, IdentifierDeclarator, ParameterDeclaration, + IdentifierDeclarator, ExtKR_ParameterDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, IdentifierDeclarator, + PointerDeclarator, IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case0290() { + parse("void x ( y ) int y ( float [ 1 ] ) ; { }", + Expectation().AST({TranslationUnit, + FunctionDefinition, + BuiltinTypeSpecifier, + FunctionDeclarator, + IdentifierDeclarator, + ParameterSuffix, + ParameterDeclaration, + IdentifierDeclarator, + ExtKR_ParameterDeclaration, + BuiltinTypeSpecifier, + FunctionDeclarator, + IdentifierDeclarator, + ParameterSuffix, + ParameterDeclaration, + BuiltinTypeSpecifier, + ArrayDeclarator, + AbstractDeclarator, + SubscriptSuffix, + IntegerConstantExpression, + CompoundStatement})); +} + +void ParserTester::case0291() {} + +void ParserTester::case0292() {} + +void ParserTester::case0293() { + parse("void x ( y , z ) int y , int z { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); +} + +void ParserTester::case0294() { + parse("int x ( y ) y { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); +} + +void ParserTester::case0295() { + parse("int x ( y ) int { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); +} + +void ParserTester::case0296() { + parse("int x ( y ) int y { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0274() -{ +void ParserTester::case0297() { + CROSS_REFERENCE_TEST(BinderTester::case0025); // Semantic error. + parse("void x ( int y ) int y ; { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, IdentifierDeclarator, + ExtKR_ParameterDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, CompoundStatement})); } -void ParserTester::case0275() -{ +void ParserTester::case0298() { + CROSS_REFERENCE_TEST(BinderTester::case0026); // Semantic error. + parse("int x ( int y ) z y ; { }", + Expectation().AST( + {TranslationUnit, FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, IdentifierDeclarator, + ExtKR_ParameterDeclaration, TypedefName, IdentifierDeclarator, + CompoundStatement})); } -void ParserTester::case0276() -{ +void ParserTester::case0299() {} +void ParserTester::case0300() { + parse("int x [ y ] ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ArrayDeclarator, + IdentifierDeclarator, SubscriptSuffix, + IdentifierName})); } -void ParserTester::case0277() -{ - +void ParserTester::case0301() { + parse("x y [ z ] ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, ArrayDeclarator, IdentifierDeclarator, + SubscriptSuffix, IdentifierName})); } -void ParserTester::case0278() -{ +void ParserTester::case0302() { + parse("int x [ 2 ] ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ArrayDeclarator, + IdentifierDeclarator, SubscriptSuffix, + IntegerConstantExpression})); +} +void ParserTester::case0303() { + parse("x y [ 2 ] ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, ArrayDeclarator, IdentifierDeclarator, + SubscriptSuffix, IntegerConstantExpression})); } -void ParserTester::case0279() -{ +void ParserTester::case0304() { parse("float x [ 11 ] , * y [ 17 ] ;"); } +void ParserTester::case0305() { + parse("int x [ y ] [ 6 ] [ z ] ;", + Expectation().AST( + {TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ArrayDeclarator, ArrayDeclarator, + ArrayDeclarator, IdentifierDeclarator, SubscriptSuffix, + IdentifierName, SubscriptSuffix, IntegerConstantExpression, + SubscriptSuffix, IdentifierName})); } -void ParserTester::case0280() -{ - parse("void x ( y ) int y ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - CompoundStatement })); +void ParserTester::case0306() { + parse( + "int x [ y ] [ z ] [ 6 ] ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ArrayDeclarator, ArrayDeclarator, + ArrayDeclarator, IdentifierDeclarator, SubscriptSuffix, + IdentifierName, SubscriptSuffix, IdentifierName, + SubscriptSuffix, IntegerConstantExpression})); } -void ParserTester::case0281() -{ - parse("void x ( y ) z y ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - TypedefName, - IdentifierDeclarator, - CompoundStatement })); -} +void ParserTester::case0307() { parse("int x [ y + z ] ;"); } -void ParserTester::case0282() -{ - parse("void x ( y , z ) int y ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0283() -{ - parse("void x ( y , z ) int y ; int z ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0284() -{ - parse("void x ( y , z ) int y , z ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0285() -{ - parse("void x ( y , z ) int y ; int z ( int ) ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - CompoundStatement })); -} - -void ParserTester::case0286() -{ - parse("void x ( y ) struct z y ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - StructTypeSpecifier, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0287() -{ - parse("void x ( y ) int * y ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0288() -{ - parse("int x ( y , z ) int * y , z ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0289() -{ - parse("int x ( y , z ) int * y , * z ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator, - PointerDeclarator, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0290() -{ - parse("void x ( y ) int y ( float [ 1 ] ) ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - AbstractDeclarator, - SubscriptSuffix, - IntegerConstantExpression, - CompoundStatement })); -} - -void ParserTester::case0291() -{ -} - -void ParserTester::case0292() -{ -} - -void ParserTester::case0293() -{ - parse("void x ( y , z ) int y , int z { }", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); -} - -void ParserTester::case0294() -{ - parse("int x ( y ) y { }", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); -} - -void ParserTester::case0295() -{ - parse("int x ( y ) int { }", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); -} - -void ParserTester::case0296() -{ - parse("int x ( y ) int y { }", - Expectation() - .diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); -} - -void ParserTester::case0297() -{ - CROSS_REFERENCE_TEST(BinderTester::case0025); // Semantic error. - - parse("void x ( int y ) int y ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0298() -{ - CROSS_REFERENCE_TEST(BinderTester::case0026); // Semantic error. - - parse("int x ( int y ) z y ; { }", - Expectation().AST({ TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - ExtKR_ParameterDeclaration, - TypedefName, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case0299() -{ -} - -void ParserTester::case0300() -{ - parse("int x [ y ] ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IdentifierName })); -} - -void ParserTester::case0301() -{ - parse("x y [ z ] ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IdentifierName })); -} - -void ParserTester::case0302() -{ - parse("int x [ 2 ] ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); -} - -void ParserTester::case0303() -{ - parse("x y [ 2 ] ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); -} - -void ParserTester::case0304() -{ - parse("float x [ 11 ] , * y [ 17 ] ;") ; -} - -void ParserTester::case0305() -{ - parse("int x [ y ] [ 6 ] [ z ] ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - ArrayDeclarator, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IdentifierName, - SubscriptSuffix, - IntegerConstantExpression, - SubscriptSuffix, - IdentifierName })); -} - -void ParserTester::case0306() -{ - parse("int x [ y ] [ z ] [ 6 ] ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - ArrayDeclarator, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IdentifierName, - SubscriptSuffix, - IdentifierName, - SubscriptSuffix, - IntegerConstantExpression })); -} - -void ParserTester::case0307() -{ - parse("int x [ y + z ] ;") ; -} - -void ParserTester::case0308() -{ - parse("int x [ y ] [ z ] [ 6 ] [ w ];") ; -} - -void ParserTester::case0309() -{ - parse("int x [ y ] [ z ] [ 6 ] [ w + 2 ] ;") ; -} - -void ParserTester::case0310() -{ - parse("int ( * const x [ 10 ] ) ( unsigned int , ... ) ;") ; -} - -void ParserTester::case0311() -{ - parse("int ( * const [ ] ) ( unsigned int , ... ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} - -void ParserTester::case0312() -{ - // TODO: Warn about array size. - - parse("int ( * const x [ ] ) ( unsigned int , ... ) ;") ; -} +void ParserTester::case0308() { parse("int x [ y ] [ z ] [ 6 ] [ w ];"); } -void ParserTester::case0313() -{ - parse("int * x [ 1 ];", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); -} +void ParserTester::case0309() { parse("int x [ y ] [ z ] [ 6 ] [ w + 2 ] ;"); } -void ParserTester::case0314() -{ - parse("void x ( int y [ static 1 ] ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); +void ParserTester::case0310() { + parse("int ( * const x [ 10 ] ) ( unsigned int , ... ) ;"); } -void ParserTester::case0315() -{ - parse("void x ( int [ static 1 ] ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - ArrayDeclarator, - AbstractDeclarator, - SubscriptSuffix, - IntegerConstantExpression })); +void ParserTester::case0311() { + parse( + "int ( * const [ ] ) ( unsigned int , ... ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0316() -{ - parse("int x [ static 1 ] ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator)); -} +void ParserTester::case0312() { + // TODO: Warn about array size. -void ParserTester::case0317() -{ - parse("int x ( const int y [ const 1 ] ) ;"); + parse("int ( * const x [ ] ) ( unsigned int , ... ) ;"); } -void ParserTester::case0318() -{ - parse("int x ( const int [ const 1 ] ) ;"); +void ParserTester::case0313() { + parse("int * x [ 1 ];", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, PointerDeclarator, + ArrayDeclarator, IdentifierDeclarator, + SubscriptSuffix, IntegerConstantExpression})); } -void ParserTester::case0319() -{ - parse("void x ( int y [ static restrict 1 ] ) ;"); +void ParserTester::case0314() { + parse("void x ( int y [ static 1 ] ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + ArrayDeclarator, IdentifierDeclarator, + SubscriptSuffix, IntegerConstantExpression})); } -void ParserTester::case0320() -{ - parse("void x ( int [ static restrict 1 ] ) ;"); +void ParserTester::case0315() { + parse("void x ( int [ static 1 ] ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, + ArrayDeclarator, AbstractDeclarator, SubscriptSuffix, + IntegerConstantExpression})); } -void ParserTester::case0321() -{ - parse("void x ( int [ static struct ] ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case0316() { + parse("int x [ static 1 ] ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator)); } -void ParserTester::case0322() -{ - parse("int x ( int y [ static const 1 ] ) ;"); -} +void ParserTester::case0317() { parse("int x ( const int y [ const 1 ] ) ;"); } -void ParserTester::case0323() -{ - parse("int x ( int [ static const 1 ] ) ;"); -} +void ParserTester::case0318() { parse("int x ( const int [ const 1 ] ) ;"); } -void ParserTester::case0324() -{ - parse("int x ( int y [ const static 1 ] ) ;"); +void ParserTester::case0319() { + parse("void x ( int y [ static restrict 1 ] ) ;"); } -void ParserTester::case0325() -{ - parse("int x ( int [ const static 1 ] ) ;"); +void ParserTester::case0320() { + parse("void x ( int [ static restrict 1 ] ) ;"); } -void ParserTester::case0326() -{ - parse("int x ( int y [ const * ] ) ;"); +void ParserTester::case0321() { + parse("void x ( int [ static struct ] ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case0327() -{ - parse("int x ( int y [ const volatile * ] ) ;"); -} +void ParserTester::case0322() { parse("int x ( int y [ static const 1 ] ) ;"); } -void ParserTester::case0328() -{ - parse("int x ( int y [ const static volatile * ] ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} +void ParserTester::case0323() { parse("int x ( int [ static const 1 ] ) ;"); } -void ParserTester::case0329() -{ - parse("int y [ const * ] ;", - Expectation().setErrorCnt(1)); -} +void ParserTester::case0324() { parse("int x ( int y [ const static 1 ] ) ;"); } + +void ParserTester::case0325() { parse("int x ( int [ const static 1 ] ) ;"); } -void ParserTester::case0330() -{ - parse("int y [ * ] ;", - Expectation().setErrorCnt(1)); +void ParserTester::case0326() { parse("int x ( int y [ const * ] ) ;"); } + +void ParserTester::case0327() { + parse("int x ( int y [ const volatile * ] ) ;"); } -void ParserTester::case0331() -{ - parse("int y [ const ] ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator)); +void ParserTester::case0328() { + parse( + "int x ( int y [ const static volatile * ] ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0332() -{ - parse("int x [ 1 ] const ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); +void ParserTester::case0329() { + parse("int y [ const * ] ;", Expectation().setErrorCnt(1)); } -void ParserTester::case0333() -{ - parse("int x [ 1 ] y ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); +void ParserTester::case0330() { + parse("int y [ * ] ;", Expectation().setErrorCnt(1)); } -void ParserTester::case0334() -{ +void ParserTester::case0331() { + parse("int y [ const ] ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_UnexpectedStaticOrTypeQualifierInArrayDeclarator)); } -void ParserTester::case0335() -{ +void ParserTester::case0332() { + parse("int x [ 1 ] const ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0336() -{ +void ParserTester::case0333() { + parse("int x [ 1 ] y ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDeclarator)); } -void ParserTester::case0337() -{ +void ParserTester::case0334() {} -} +void ParserTester::case0335() {} -void ParserTester::case0338() -{ -} +void ParserTester::case0336() {} -void ParserTester::case0339() -{ -} +void ParserTester::case0337() {} -void ParserTester::case0340() -{ -} +void ParserTester::case0338() {} -void ParserTester::case0341() -{ -} +void ParserTester::case0339() {} -void ParserTester::case0342() { } -void ParserTester::case0343() { } -void ParserTester::case0344() { } -void ParserTester::case0345() { } -void ParserTester::case0346() { } -void ParserTester::case0347() { } -void ParserTester::case0348() { } -void ParserTester::case0349() { } +void ParserTester::case0340() {} -void ParserTester::case0350() { } -void ParserTester::case0351() { } -void ParserTester::case0352() { } -void ParserTester::case0353() { } -void ParserTester::case0354() { } -void ParserTester::case0355() { } -void ParserTester::case0356() { } -void ParserTester::case0357() { } -void ParserTester::case0358() { } -void ParserTester::case0359() { } +void ParserTester::case0341() {} -void ParserTester::case0360() { } -void ParserTester::case0361() { } -void ParserTester::case0362() { } -void ParserTester::case0363() { } -void ParserTester::case0364() { } -void ParserTester::case0365() { } -void ParserTester::case0366() { } -void ParserTester::case0367() { } -void ParserTester::case0368() { } -void ParserTester::case0369() { } - -void ParserTester::case0370() { } -void ParserTester::case0371() { } -void ParserTester::case0372() { } -void ParserTester::case0373() { } -void ParserTester::case0374() { } -void ParserTester::case0375() { } -void ParserTester::case0376() { } -void ParserTester::case0377() { } -void ParserTester::case0378() { } -void ParserTester::case0379() { } - -void ParserTester::case0380() { } -void ParserTester::case0381() { } -void ParserTester::case0382() { } -void ParserTester::case0383() { } -void ParserTester::case0384() { } -void ParserTester::case0385() { } -void ParserTester::case0386() { } -void ParserTester::case0387() { } -void ParserTester::case0388() { } -void ParserTester::case0389() { } - -void ParserTester::case0390() { } -void ParserTester::case0391() { } -void ParserTester::case0392() { } -void ParserTester::case0393() { } -void ParserTester::case0394() { } -void ParserTester::case0395() { } -void ParserTester::case0396() { } -void ParserTester::case0397() { } -void ParserTester::case0398() { } -void ParserTester::case0399() { } - -void ParserTester::case0400() -{ - parse("struct x ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier })); -} - -void ParserTester::case0401() -{ - parse("struct x y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - StructTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0402() -{ - parse("struct x * y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - StructTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0403() -{ - // TODO: Warn of empty member list. - - parse("struct x { } ;") ; -} - -void ParserTester::case0404() -{ - parse("struct { int x ; } y ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypeDeclarationAsSpecifier, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0405() -{ - parse("struct { x y ; } z;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - TypeDeclarationAsSpecifier, - StructTypeSpecifier, - FieldDeclaration, - TypedefName, - IdentifierDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case0406() -{ - CROSS_REFERENCE_TEST(BinderTester::case0014) ; - - parse("struct { int x ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0407() -{ - parse("struct { x y ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - TypedefName, - IdentifierDeclarator })); -} - -void ParserTester::case0408() -{ - parse("struct x { void ( * y ) ( ) ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - ParenthesizedDeclarator, - PointerDeclarator, - IdentifierDeclarator, - ParameterSuffix })); -} - -void ParserTester::case0409() -{ - parse("struct;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructOrUnionOrEnum)); -} - -void ParserTester::case0410() -{ - parse("struct x { void ( * y ) ( int , double ) ; } ; ") ; -} - -void ParserTester::case0411() -{ - parse("struct x { void ( * y ) ( z , double ) ; } ; ") ; -} - -void ParserTester::case0412() -{ - parse("struct x { void ( * y ) ( z ) ; } ; ") ; -} - -void ParserTester::case0413() -{ - parse("struct x { void ( * ) ( int ) ; } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} - -void ParserTester::case0414() -{ - parse("struct x (", - Expectation().setErrorCnt(1)) ; -} - -void ParserTester::case0415() -{ - parse("struct x { :", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofSpecifierQualifier)); -} +void ParserTester::case0342() {} +void ParserTester::case0343() {} +void ParserTester::case0344() {} +void ParserTester::case0345() {} +void ParserTester::case0346() {} +void ParserTester::case0347() {} +void ParserTester::case0348() {} +void ParserTester::case0349() {} -void ParserTester::case0416() -{ - /* - * Notes: - * - `typedef int y; struct x { y ; } ;' - * Would be valid, but the declaration doesn't declare anything. - * - * - `struct x { y ; } ;' - * Would be invalid, because a specifier-qualifier-list is mandatory. - */ +void ParserTester::case0350() {} +void ParserTester::case0351() {} +void ParserTester::case0352() {} +void ParserTester::case0353() {} +void ParserTester::case0354() {} +void ParserTester::case0355() {} +void ParserTester::case0356() {} +void ParserTester::case0357() {} +void ParserTester::case0358() {} +void ParserTester::case0359() {} - CROSS_REFERENCE_TEST(BinderTester::case0006); // Semantic warning. +void ParserTester::case0360() {} +void ParserTester::case0361() {} +void ParserTester::case0362() {} +void ParserTester::case0363() {} +void ParserTester::case0364() {} +void ParserTester::case0365() {} +void ParserTester::case0366() {} +void ParserTester::case0367() {} +void ParserTester::case0368() {} +void ParserTester::case0369() {} - parse("struct x { y ; } ;"); -} +void ParserTester::case0370() {} +void ParserTester::case0371() {} +void ParserTester::case0372() {} +void ParserTester::case0373() {} +void ParserTester::case0374() {} +void ParserTester::case0375() {} +void ParserTester::case0376() {} +void ParserTester::case0377() {} +void ParserTester::case0378() {} +void ParserTester::case0379() {} -void ParserTester::case0417() -{ - parse("struct x { ( y ) ; } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofSpecifierQualifier)); -} +void ParserTester::case0380() {} +void ParserTester::case0381() {} +void ParserTester::case0382() {} +void ParserTester::case0383() {} +void ParserTester::case0384() {} +void ParserTester::case0385() {} +void ParserTester::case0386() {} +void ParserTester::case0387() {} +void ParserTester::case0388() {} +void ParserTester::case0389() {} -void ParserTester::case0418() -{ - parse("struct x { int y : 1 ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - BitfieldDeclarator, - IdentifierDeclarator, - IntegerConstantExpression })); -} +void ParserTester::case0390() {} +void ParserTester::case0391() {} +void ParserTester::case0392() {} +void ParserTester::case0393() {} +void ParserTester::case0394() {} +void ParserTester::case0395() {} +void ParserTester::case0396() {} +void ParserTester::case0397() {} +void ParserTester::case0398() {} +void ParserTester::case0399() {} -void ParserTester::case0419() -{ - parse("struct x { y z : 1 ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - TypedefName, - BitfieldDeclarator, - IdentifierDeclarator, - IntegerConstantExpression })); +void ParserTester::case0400() { + parse("struct x ;", Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier})); } -void ParserTester::case0420() -{ - parse("struct x { int : 1 ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - BitfieldDeclarator, - IntegerConstantExpression })); +void ParserTester::case0401() { + parse("struct x y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + StructTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0421() -{ - parse("struct x { y : 1 ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - TypedefName, - BitfieldDeclarator, - IntegerConstantExpression })); +void ParserTester::case0402() { + parse("struct x * y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + StructTypeSpecifier, PointerDeclarator, + IdentifierDeclarator})); } -void ParserTester::case0422() -{ - CROSS_REFERENCE_TEST(BinderTester::case0007); // Semantic warning. +void ParserTester::case0403() { + // TODO: Warn of empty member list. - parse("struct x { int ; } ;"); + parse("struct x { } ;"); } -void ParserTester::case0423() -{ -// parse("struct x { void ( * x ) ( ) : 1; } ;"); +void ParserTester::case0404() { + parse("struct { int x ; } y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypeDeclarationAsSpecifier, StructTypeSpecifier, + FieldDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, IdentifierDeclarator})); } -void ParserTester::case0424() -{ - parse("struct x { int y : 1, z : 2 ; } ;"); +void ParserTester::case0405() { + parse("struct { x y ; } z;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypeDeclarationAsSpecifier, StructTypeSpecifier, + FieldDeclaration, TypedefName, IdentifierDeclarator, + IdentifierDeclarator})); +} + +void ParserTester::case0406() { + CROSS_REFERENCE_TEST(BinderTester::case0014); + + parse("struct { int x ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0425() -{ - parse("struct x { int y : 1; z w : 2 ; } ;"); +void ParserTester::case0407() { + parse("struct { x y ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, TypedefName, + IdentifierDeclarator})); } -void ParserTester::case0426() -{ - parse("struct x { int y : 1, z ; } ;"); +void ParserTester::case0408() { + parse("struct x { void ( * y ) ( ) ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, + ParenthesizedDeclarator, PointerDeclarator, + IdentifierDeclarator, ParameterSuffix})); } -void ParserTester::case0427() -{ - parse("struct x { int y : 1, z , w : 2 ; } ;"); +void ParserTester::case0409() { + parse("struct;", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFOLLOWofStructOrUnionOrEnum)); } -void ParserTester::case0428() -{ - parse("struct { _Static_assert ( 1 , \"\" ) ; }; "); +void ParserTester::case0410() { + parse("struct x { void ( * y ) ( int , double ) ; } ; "); } -void ParserTester::case0429() -{ - parse("struct x volatile y ;"); +void ParserTester::case0411() { + parse("struct x { void ( * y ) ( z , double ) ; } ; "); } -void ParserTester::case0430() -{ - parse("struct x { int y ; } volatile z ;"); -} +void ParserTester::case0412() { parse("struct x { void ( * y ) ( z ) ; } ; "); } -void ParserTester::case0431() -{ - parse("struct { int x ; } volatile y ;"); +void ParserTester::case0413() { + parse( + "struct x { void ( * ) ( int ) ; } ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0432() -{ - parse("const struct { int x ; } volatile y ;"); +void ParserTester::case0414() { + parse("struct x (", Expectation().setErrorCnt(1)); } -void ParserTester::case0433() -{ - parse("struct { int x ; } struct y z ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); +void ParserTester::case0415() { + parse("struct x { :", + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFIRSTofSpecifierQualifier)); } -void ParserTester::case0434() -{ - parse("struct x { int y ; } int z ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} +void ParserTester::case0416() { + /* + * Notes: + * - `typedef int y; struct x { y ; } ;' + * Would be valid, but the declaration doesn't declare anything. + * + * - `struct x { y ; } ;' + * Would be invalid, because a specifier-qualifier-list is mandatory. + */ -void ParserTester::case0435() -{ - // Covered as a semantic error. - CROSS_REFERENCE_TEST(BinderTester::case0019); + CROSS_REFERENCE_TEST(BinderTester::case0006); // Semantic warning. - parse("int struct x { int y ; } z ;"); + parse("struct x { y ; } ;"); } -void ParserTester::case0436() -{ - // Covered as a semantic error. - CROSS_REFERENCE_TEST(BinderTester::case0020); - - parse("struct x struct { int y ; } z ;"); +void ParserTester::case0417() { + parse("struct x { ( y ) ; } ;", + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFIRSTofSpecifierQualifier)); } -void ParserTester::case0437() -{ - // Covered as a semantic error. - CROSS_REFERENCE_TEST(BinderTester::case0021); - - parse("int struct x y ;"); +void ParserTester::case0418() { + parse("struct x { int y : 1 ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, + BuiltinTypeSpecifier, BitfieldDeclarator, + IdentifierDeclarator, IntegerConstantExpression})); } -void ParserTester::case0438() -{ - // Covered as a semantic error. - CROSS_REFERENCE_TEST(BinderTester::case0022); - - parse("struct x int y ;"); +void ParserTester::case0419() { + parse("struct x { y z : 1 ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, TypedefName, + BitfieldDeclarator, IdentifierDeclarator, + IntegerConstantExpression})); } -void ParserTester::case0439() -{ - parse("struct { int x = 1 ; } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructDeclarator)); +void ParserTester::case0420() { + parse("struct x { int : 1 ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, + BuiltinTypeSpecifier, BitfieldDeclarator, + IntegerConstantExpression})); } -void ParserTester::case0440() -{ - parse("struct { x y = 1 ; } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructDeclarator)); +void ParserTester::case0421() { + parse("struct x { y : 1 ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, TypedefName, + BitfieldDeclarator, IntegerConstantExpression})); } -void ParserTester::case0441() -{ - parse("struct { int x : 1 = 1 ; } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructDeclarator)); -} +void ParserTester::case0422() { + CROSS_REFERENCE_TEST(BinderTester::case0007); // Semantic warning. -void ParserTester::case0442() -{ - parse("union x ;", - Expectation().AST({ TranslationUnit, - UnionDeclaration, - UnionTypeSpecifier })); + parse("struct x { int ; } ;"); } -void ParserTester::case0443() -{ - parse("struct x { int y ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator })); +void ParserTester::case0423() { + // parse("struct x { void ( * x ) ( ) : 1; } ;"); } -void ParserTester::case0444() -{ - parse("struct x { int y ; double z ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - FieldDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} +void ParserTester::case0424() { parse("struct x { int y : 1, z : 2 ; } ;"); } -void ParserTester::case0445() -{ - parse("struct x { struct y { int z ; } w ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - TypeDeclarationAsSpecifier, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - IdentifierDeclarator })); -} +void ParserTester::case0425() { parse("struct x { int y : 1; z w : 2 ; } ;"); } -void ParserTester::case0446() -{ - // Covered as a semantic error. - CROSS_REFERENCE_TEST(BinderTester::case0015); +void ParserTester::case0426() { parse("struct x { int y : 1, z ; } ;"); } - parse("struct x { struct y { int z ; } ; } ;", - Expectation().AST({ TranslationUnit, - StructDeclaration, - StructTypeSpecifier, - StructDeclaration, - StructTypeSpecifier, - FieldDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator })); +void ParserTester::case0427() { + parse("struct x { int y : 1, z , w : 2 ; } ;"); } -void ParserTester::case0447() -{ - +void ParserTester::case0428() { + parse("struct { _Static_assert ( 1 , \"\" ) ; }; "); } -void ParserTester::case0448() -{ +void ParserTester::case0429() { parse("struct x volatile y ;"); } -} +void ParserTester::case0430() { parse("struct x { int y ; } volatile z ;"); } -void ParserTester::case0449() -{ +void ParserTester::case0431() { parse("struct { int x ; } volatile y ;"); } +void ParserTester::case0432() { + parse("const struct { int x ; } volatile y ;"); } -void ParserTester::case0450() -{ +void ParserTester::case0433() { + parse( + "struct { int x ; } struct y z ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); +} +void ParserTester::case0434() { + parse( + "struct x { int y ; } int z ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0451() -{ +void ParserTester::case0435() { + // Covered as a semantic error. + CROSS_REFERENCE_TEST(BinderTester::case0019); + parse("int struct x { int y ; } z ;"); } -void ParserTester::case0452() -{ +void ParserTester::case0436() { + // Covered as a semantic error. + CROSS_REFERENCE_TEST(BinderTester::case0020); + parse("struct x struct { int y ; } z ;"); } -void ParserTester::case0453() -{ +void ParserTester::case0437() { + // Covered as a semantic error. + CROSS_REFERENCE_TEST(BinderTester::case0021); + parse("int struct x y ;"); } -void ParserTester::case0454() -{ +void ParserTester::case0438() { + // Covered as a semantic error. + CROSS_REFERENCE_TEST(BinderTester::case0022); + parse("struct x int y ;"); } -void ParserTester::case0455() -{ - +void ParserTester::case0439() { + parse( + "struct { int x = 1 ; } ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructDeclarator)); } -void ParserTester::case0456() -{ +void ParserTester::case0440() { + parse( + "struct { x y = 1 ; } ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructDeclarator)); +} +void ParserTester::case0441() { + parse( + "struct { int x : 1 = 1 ; } ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofStructDeclarator)); } -void ParserTester::case0457() -{ +void ParserTester::case0442() { + parse("union x ;", Expectation().AST({TranslationUnit, UnionDeclaration, + UnionTypeSpecifier})); +} +void ParserTester::case0443() { + parse("struct x { int y ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0458() -{ +void ParserTester::case0444() { + parse("struct x { int y ; double z ; } ;", + Expectation().AST( + {TranslationUnit, StructDeclaration, StructTypeSpecifier, + FieldDeclaration, BuiltinTypeSpecifier, IdentifierDeclarator, + FieldDeclaration, BuiltinTypeSpecifier, IdentifierDeclarator})); +} +void ParserTester::case0445() { + parse("struct x { struct y { int z ; } w ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, + TypeDeclarationAsSpecifier, StructTypeSpecifier, + FieldDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, IdentifierDeclarator})); } -void ParserTester::case0459() -{ +void ParserTester::case0446() { + // Covered as a semantic error. + CROSS_REFERENCE_TEST(BinderTester::case0015); + parse("struct x { struct y { int z ; } ; } ;", + Expectation().AST({TranslationUnit, StructDeclaration, + StructTypeSpecifier, StructDeclaration, + StructTypeSpecifier, FieldDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0460() -{ +void ParserTester::case0447() {} -} +void ParserTester::case0448() {} -void ParserTester::case0461() -{ +void ParserTester::case0449() {} -} +void ParserTester::case0450() {} -void ParserTester::case0462() -{ +void ParserTester::case0451() {} -} +void ParserTester::case0452() {} -void ParserTester::case0463() -{ +void ParserTester::case0453() {} -} +void ParserTester::case0454() {} -void ParserTester::case0464() -{ +void ParserTester::case0455() {} -} +void ParserTester::case0456() {} -void ParserTester::case0465() -{ +void ParserTester::case0457() {} -} +void ParserTester::case0458() {} -void ParserTester::case0466() -{ +void ParserTester::case0459() {} -} +void ParserTester::case0460() {} -void ParserTester::case0467() -{ +void ParserTester::case0461() {} -} +void ParserTester::case0462() {} -void ParserTester::case0468() -{ +void ParserTester::case0463() {} -} +void ParserTester::case0464() {} -void ParserTester::case0469() -{ +void ParserTester::case0465() {} -} +void ParserTester::case0466() {} -void ParserTester::case0470() -{ +void ParserTester::case0467() {} -} +void ParserTester::case0468() {} -void ParserTester::case0471() -{ +void ParserTester::case0469() {} -} +void ParserTester::case0470() {} -void ParserTester::case0472() -{ +void ParserTester::case0471() {} -} +void ParserTester::case0472() {} -void ParserTester::case0473() -{ +void ParserTester::case0473() {} -} +void ParserTester::case0474() {} -void ParserTester::case0474() -{ +void ParserTester::case0475() {} -} +void ParserTester::case0476() {} -void ParserTester::case0475() -{ +void ParserTester::case0477() {} -} +void ParserTester::case0478() {} -void ParserTester::case0476() -{ +void ParserTester::case0479() {} -} +void ParserTester::case0480() {} -void ParserTester::case0477() -{ +void ParserTester::case0481() {} -} +void ParserTester::case0482() {} -void ParserTester::case0478() -{ +void ParserTester::case0483() {} -} +void ParserTester::case0484() {} -void ParserTester::case0479() -{ +void ParserTester::case0485() {} -} +void ParserTester::case0486() {} -void ParserTester::case0480() -{ +void ParserTester::case0487() {} -} +void ParserTester::case0488() {} -void ParserTester::case0481() -{ +void ParserTester::case0489() {} -} +void ParserTester::case0490() {} -void ParserTester::case0482() -{ +void ParserTester::case0491() {} -} +void ParserTester::case0492() {} -void ParserTester::case0483() -{ +void ParserTester::case0493() {} -} +void ParserTester::case0494() {} -void ParserTester::case0484() -{ +void ParserTester::case0495() {} -} +void ParserTester::case0496() {} -void ParserTester::case0485() -{ +void ParserTester::case0497() {} -} +void ParserTester::case0498() {} -void ParserTester::case0486() -{ +void ParserTester::case0499() {} +void ParserTester::case0500() { + parse("enum x ;", Expectation().AST({TranslationUnit, IncompleteDeclaration, + EnumTypeSpecifier})); } -void ParserTester::case0487() -{ +void ParserTester::case0501() { parse("enum x y ;"); } -} +void ParserTester::case0502() { parse("enum x { } ;"); } -void ParserTester::case0488() -{ +void ParserTester::case0503() { parse("enum x { y } ;"); } -} +void ParserTester::case0504() { parse("enum x { y , z } ;"); } -void ParserTester::case0489() -{ +void ParserTester::case0505() { parse("enum x { y , z, } ;"); } -} +void ParserTester::case0506() { parse("enum x { y , z = w } ;"); } -void ParserTester::case0490() -{ +void ParserTester::case0507() { parse("enum x { y , z = w, } ;"); } -} +void ParserTester::case0508() { parse("enum x { y = 1 } ;"); } -void ParserTester::case0491() -{ +void ParserTester::case0509() { parse("enum x { y = 1, } ;"); } -} +void ParserTester::case0510() { parse("enum x { y = 1, z } ;"); } -void ParserTester::case0492() -{ +void ParserTester::case0511() { parse("enum x { y = 1, z, w = 3 } ;"); } +void ParserTester::case0512() { + parse( + "enum x (", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); } -void ParserTester::case0493() -{ +void ParserTester::case0513() { + parse("enum x { (", + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFIRSTofEnumerationConstant)); +} +void ParserTester::case0514() { + parse("enum x { y, , z, } ;", + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFIRSTofEnumerationConstant)); } -void ParserTester::case0494() -{ +void ParserTester::case0515() {} -} +void ParserTester::case0516() {} -void ParserTester::case0495() -{ +void ParserTester::case0517() {} -} +void ParserTester::case0518() {} -void ParserTester::case0496() -{ +void ParserTester::case0519() {} -} +void ParserTester::case0520() {} -void ParserTester::case0497() -{ +void ParserTester::case0521() {} -} +void ParserTester::case0522() {} -void ParserTester::case0498() -{ +void ParserTester::case0523() {} -} +void ParserTester::case0524() {} -void ParserTester::case0499() -{ +void ParserTester::case0525() {} -} +void ParserTester::case0526() {} -void ParserTester::case0500() -{ - parse("enum x ;", - Expectation().AST({ TranslationUnit, - IncompleteDeclaration, - EnumTypeSpecifier })); -} +void ParserTester::case0527() {} -void ParserTester::case0501() -{ - parse("enum x y ;"); -} +void ParserTester::case0528() {} -void ParserTester::case0502() -{ - parse("enum x { } ;"); -} +void ParserTester::case0529() {} -void ParserTester::case0503() -{ - parse("enum x { y } ;"); -} +void ParserTester::case0530() {} -void ParserTester::case0504() -{ - parse("enum x { y , z } ;"); -} +void ParserTester::case0531() {} -void ParserTester::case0505() -{ - parse("enum x { y , z, } ;"); -} +void ParserTester::case0532() {} -void ParserTester::case0506() -{ - parse("enum x { y , z = w } ;"); -} +void ParserTester::case0533() {} -void ParserTester::case0507() -{ - parse("enum x { y , z = w, } ;"); -} +void ParserTester::case0534() {} -void ParserTester::case0508() -{ - parse("enum x { y = 1 } ;"); -} +void ParserTester::case0535() {} -void ParserTester::case0509() -{ - parse("enum x { y = 1, } ;"); -} +void ParserTester::case0536() {} -void ParserTester::case0510() -{ - parse("enum x { y = 1, z } ;"); -} +void ParserTester::case0537() {} -void ParserTester::case0511() -{ - parse("enum x { y = 1, z, w = 3 } ;"); -} +void ParserTester::case0538() {} -void ParserTester::case0512() -{ - parse("enum x (", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator)); -} +void ParserTester::case0539() {} -void ParserTester::case0513() -{ - parse("enum x { (", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofEnumerationConstant)); -} +void ParserTester::case0540() {} -void ParserTester::case0514() -{ - parse("enum x { y, , z, } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofEnumerationConstant)); -} +void ParserTester::case0541() {} -void ParserTester::case0515() -{ -} +void ParserTester::case0542() {} -void ParserTester::case0516() -{ -} +void ParserTester::case0543() {} -void ParserTester::case0517() -{ +void ParserTester::case0544() {} -} +void ParserTester::case0545() {} -void ParserTester::case0518() -{ +void ParserTester::case0546() {} -} +void ParserTester::case0547() {} -void ParserTester::case0519() -{ +void ParserTester::case0548() {} -} +void ParserTester::case0549() {} -void ParserTester::case0520() -{ +void ParserTester::case0550() {} -} +void ParserTester::case0551() {} -void ParserTester::case0521() -{ +void ParserTester::case0552() {} -} +void ParserTester::case0553() {} -void ParserTester::case0522() -{ +void ParserTester::case0554() {} -} +void ParserTester::case0555() {} -void ParserTester::case0523() -{ +void ParserTester::case0556() {} -} +void ParserTester::case0557() {} -void ParserTester::case0524() -{ +void ParserTester::case0558() {} -} +void ParserTester::case0559() {} -void ParserTester::case0525() -{ +void ParserTester::case0560() {} -} +void ParserTester::case0561() {} -void ParserTester::case0526() -{ +void ParserTester::case0562() {} -} +void ParserTester::case0563() {} -void ParserTester::case0527() -{ +void ParserTester::case0564() {} -} +void ParserTester::case0565() {} -void ParserTester::case0528() -{ +void ParserTester::case0566() {} -} +void ParserTester::case0567() {} -void ParserTester::case0529() -{ +void ParserTester::case0568() {} -} +void ParserTester::case0569() {} -void ParserTester::case0530() -{ +void ParserTester::case0570() {} -} +void ParserTester::case0571() {} -void ParserTester::case0531() -{ +void ParserTester::case0572() {} -} +void ParserTester::case0573() {} -void ParserTester::case0532() -{ +void ParserTester::case0574() {} -} +void ParserTester::case0575() {} -void ParserTester::case0533() -{ +void ParserTester::case0576() {} -} +void ParserTester::case0577() {} -void ParserTester::case0534() -{ +void ParserTester::case0578() {} -} +void ParserTester::case0579() {} -void ParserTester::case0535() -{ +void ParserTester::case0580() {} -} +void ParserTester::case0581() {} -void ParserTester::case0536() -{ +void ParserTester::case0582() {} -} +void ParserTester::case0583() {} -void ParserTester::case0537() -{ +void ParserTester::case0584() {} -} +void ParserTester::case0585() {} -void ParserTester::case0538() -{ +void ParserTester::case0586() {} -} +void ParserTester::case0587() {} -void ParserTester::case0539() -{ +void ParserTester::case0588() {} -} +void ParserTester::case0589() {} -void ParserTester::case0540() -{ +void ParserTester::case0590() {} -} +void ParserTester::case0591() {} -void ParserTester::case0541() -{ +void ParserTester::case0592() {} -} +void ParserTester::case0593() {} -void ParserTester::case0542() -{ +void ParserTester::case0594() {} -} +void ParserTester::case0595() {} -void ParserTester::case0543() -{ +void ParserTester::case0596() {} -} +void ParserTester::case0597() {} -void ParserTester::case0544() -{ +void ParserTester::case0598() {} -} +void ParserTester::case0599() {} -void ParserTester::case0545() -{ +void ParserTester::case0600() { parse("extern void * x ( int ) ;"); } -} +void ParserTester::case0601() { parse("extern void * x ( y ) ;"); } -void ParserTester::case0546() -{ +void ParserTester::case0602() { parse("extern const volatile int x ;"); } -} +void ParserTester::case0603() { parse("extern const volatile x y ;"); } -void ParserTester::case0547() -{ +void ParserTester::case0604() { parse("extern int x [] ;"); } -} +void ParserTester::case0605() { parse("extern int x [ 100 ] ;"); } -void ParserTester::case0548() -{ +void ParserTester::case0606() { parse("extern x [ ] ;"); } +void ParserTester::case0607() { parse("extern x [ 100 ] ;"); } + +void ParserTester::case0608() { + parse("extern double x ( double ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + ExternStorageClass, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, + BuiltinTypeSpecifier, AbstractDeclarator})); } -void ParserTester::case0549() -{ +void ParserTester::case0609() { parse("extern int * x ;"); } -} +void ParserTester::case0610() { parse("extern x * y ;"); } -void ParserTester::case0550() -{ +void ParserTester::case0611() { parse("extern int x ;"); } -} +void ParserTester::case0612() { parse("extern x y ;"); } -void ParserTester::case0551() -{ +void ParserTester::case0613() { parse("extern int ( * x ) [ y ] ;"); } -} +void ParserTester::case0614() { parse("extern int ( * x ) [ y ] = & z ;"); } -void ParserTester::case0552() -{ +void ParserTester::case0615() { parse("extern int x = 1 ;"); } -} +void ParserTester::case0616() { parse("typedef int x ;"); } -void ParserTester::case0553() -{ +void ParserTester::case0617() { parse("typedef x y ;"); } -} +void ParserTester::case0618() { parse("typedef int * x ;"); } -void ParserTester::case0554() -{ +void ParserTester::case0619() { parse("typedef x * y ;"); } -} +void ParserTester::case0620() { parse("typedef int ( * y ) ( double ) ;"); } -void ParserTester::case0555() -{ +void ParserTester::case0621() { parse("typedef x ( * y ) ( double ) ;"); } +void ParserTester::case0622() { + parse("typedef int x __attribute__ ( ( aligned ( 8 ) ));"); } -void ParserTester::case0556() -{ - +void ParserTester::case0623() { + parse("typedef x y __attribute__ ( ( deprecated ));"); } -void ParserTester::case0557() -{ +void ParserTester::case0624() { + parse(R"(extern int __attribute__ ( ( alias ( "x" ) ) ) y ; )"); +} +void ParserTester::case0625() { + parse("extern int x __attribute__ ( ( deprecated ));"); } -void ParserTester::case0558() -{ +void ParserTester::case0626() { + parse("typedef __attribute__ ( ( alloc_size ( 1 , 2 ) ) ) void * ( * x ) ( " + "int , int ) ;"); +} +void ParserTester::case0627() { + parse("typedef __attribute__ ( ( alloc_size ( 1 , 2 ) ) ) void * ( * x ) ( y " + ", z ) ;"); } -void ParserTester::case0559() -{ +void ParserTester::case0628() { parse("_Thread_local int x ;"); } -} +void ParserTester::case0629() { parse("_Thread_local x y ;"); } -void ParserTester::case0560() -{ +void ParserTester::case0630() { parse("__thread int x ;"); } -} +void ParserTester::case0631() { parse("void x ( ) { static __thread x y ; }"); } -void ParserTester::case0561() -{ +void ParserTester::case0632() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0015); + parse("void x ( ) { __thread x y ; }"); } -void ParserTester::case0562() -{ +void ParserTester::case0633() {} -} +void ParserTester::case0634() {} -void ParserTester::case0563() -{ +void ParserTester::case0635() {} -} +void ParserTester::case0636() {} -void ParserTester::case0564() -{ +void ParserTester::case0637() {} -} +void ParserTester::case0638() {} -void ParserTester::case0565() -{ +void ParserTester::case0639() {} -} +void ParserTester::case0640() {} -void ParserTester::case0566() -{ +void ParserTester::case0641() {} -} +void ParserTester::case0642() {} -void ParserTester::case0567() -{ +void ParserTester::case0643() {} -} +void ParserTester::case0644() {} -void ParserTester::case0568() -{ +void ParserTester::case0645() {} -} +void ParserTester::case0646() {} -void ParserTester::case0569() -{ +void ParserTester::case0647() {} -} +void ParserTester::case0648() {} -void ParserTester::case0570() -{ +void ParserTester::case0649() {} -} - -void ParserTester::case0571() -{ - -} - -void ParserTester::case0572() -{ - -} - -void ParserTester::case0573() -{ - -} - -void ParserTester::case0574() -{ - -} - -void ParserTester::case0575() -{ - -} - -void ParserTester::case0576() -{ - -} - -void ParserTester::case0577() -{ - -} - -void ParserTester::case0578() -{ - -} - -void ParserTester::case0579() -{ - -} - -void ParserTester::case0580() -{ - -} - -void ParserTester::case0581() -{ - -} - -void ParserTester::case0582() -{ - -} - -void ParserTester::case0583() -{ - -} - -void ParserTester::case0584() -{ - -} - -void ParserTester::case0585() -{ - -} - -void ParserTester::case0586() -{ - -} - -void ParserTester::case0587() -{ - -} - -void ParserTester::case0588() -{ - -} - -void ParserTester::case0589() -{ - -} - -void ParserTester::case0590() -{ - -} - -void ParserTester::case0591() -{ - -} - -void ParserTester::case0592() -{ - -} - -void ParserTester::case0593() -{ - -} - -void ParserTester::case0594() -{ - -} - -void ParserTester::case0595() -{ - -} - -void ParserTester::case0596() -{ - -} - -void ParserTester::case0597() -{ - -} - -void ParserTester::case0598() -{ - -} - -void ParserTester::case0599() -{ - -} - -void ParserTester::case0600() -{ - parse("extern void * x ( int ) ;") ; -} - -void ParserTester::case0601() -{ - parse("extern void * x ( y ) ;") ; -} - -void ParserTester::case0602() -{ - parse("extern const volatile int x ;") ; -} - -void ParserTester::case0603() -{ - parse("extern const volatile x y ;") ; -} - -void ParserTester::case0604() -{ - parse("extern int x [] ;") ; -} - -void ParserTester::case0605() -{ - parse("extern int x [ 100 ] ;") ; -} - -void ParserTester::case0606() -{ - parse("extern x [ ] ;") ; -} - -void ParserTester::case0607() -{ - parse("extern x [ 100 ] ;") ; -} - -void ParserTester::case0608() -{ - parse("extern double x ( double ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - ExternStorageClass, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case0609() -{ - parse("extern int * x ;") ; -} - -void ParserTester::case0610() -{ - parse("extern x * y ;") ; -} - -void ParserTester::case0611() -{ - parse("extern int x ;") ; -} - -void ParserTester::case0612() -{ - parse("extern x y ;") ; -} - -void ParserTester::case0613() -{ - parse("extern int ( * x ) [ y ] ;") ; -} - -void ParserTester::case0614() -{ - parse("extern int ( * x ) [ y ] = & z ;") ; -} - -void ParserTester::case0615() -{ - parse("extern int x = 1 ;") ; -} - -void ParserTester::case0616() -{ - parse("typedef int x ;") ; -} - -void ParserTester::case0617() -{ - parse("typedef x y ;") ; -} - -void ParserTester::case0618() -{ - parse("typedef int * x ;") ; -} - -void ParserTester::case0619() -{ - parse("typedef x * y ;") ; -} - -void ParserTester::case0620() -{ - parse("typedef int ( * y ) ( double ) ;") ; -} - -void ParserTester::case0621() -{ - parse("typedef x ( * y ) ( double ) ;") ; -} - -void ParserTester::case0622() -{ - parse("typedef int x __attribute__ ( ( aligned ( 8 ) ));") ; -} - -void ParserTester::case0623() -{ - parse("typedef x y __attribute__ ( ( deprecated ));") ; -} - -void ParserTester::case0624() -{ - parse(R"(extern int __attribute__ ( ( alias ( "x" ) ) ) y ; )") ; -} - -void ParserTester::case0625() -{ - parse("extern int x __attribute__ ( ( deprecated ));") ; -} - -void ParserTester::case0626() -{ - parse("typedef __attribute__ ( ( alloc_size ( 1 , 2 ) ) ) void * ( * x ) ( int , int ) ;") ; -} - -void ParserTester::case0627() -{ - parse("typedef __attribute__ ( ( alloc_size ( 1 , 2 ) ) ) void * ( * x ) ( y , z ) ;") ; -} - -void ParserTester::case0628() -{ - parse("_Thread_local int x ;"); -} - -void ParserTester::case0629() -{ - parse("_Thread_local x y ;"); -} - -void ParserTester::case0630() -{ - parse("__thread int x ;"); -} - -void ParserTester::case0631() -{ - parse("void x ( ) { static __thread x y ; }"); -} - -void ParserTester::case0632() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0015); - - parse("void x ( ) { __thread x y ; }"); -} - -void ParserTester::case0633() -{ - -} - -void ParserTester::case0634() -{ - -} - -void ParserTester::case0635() -{ - -} - -void ParserTester::case0636() -{ - -} - -void ParserTester::case0637() -{ - -} - -void ParserTester::case0638() -{ - -} - -void ParserTester::case0639() -{ - -} - -void ParserTester::case0640() -{ - -} - -void ParserTester::case0641() -{ - -} - -void ParserTester::case0642() -{ - -} - -void ParserTester::case0643() -{ - -} - -void ParserTester::case0644() -{ - -} - -void ParserTester::case0645() -{ - -} - -void ParserTester::case0646() -{ - -} - -void ParserTester::case0647() -{ - -} - -void ParserTester::case0648() -{ - -} - -void ParserTester::case0649() -{ - -} - -void ParserTester::case0650() -{ - parse("_Static_assert ( 1 != 2 , \"x\" ) ;") ; -} - -void ParserTester::case0651() -{ - -} - -void ParserTester::case0652() -{ - -} - -void ParserTester::case0653() -{ - -} - -void ParserTester::case0654() -{ - -} - -void ParserTester::case0655() -{ - -} - -void ParserTester::case0656() -{ - -} - -void ParserTester::case0657() -{ - -} - -void ParserTester::case0658() -{ - -} - -void ParserTester::case0659() -{ - -} - -void ParserTester::case0660() -{ - -} - -void ParserTester::case0661() -{ - -} - -void ParserTester::case0662() -{ - -} - -void ParserTester::case0663() -{ - -} - -void ParserTester::case0664() -{ - -} - -void ParserTester::case0665() -{ - -} - -void ParserTester::case0666() -{ - -} - -void ParserTester::case0667() -{ - -} - -void ParserTester::case0668() -{ - -} - -void ParserTester::case0669() -{ - -} - -void ParserTester::case0670() -{ - parse("__extension__ int x ;"); -} - -void ParserTester::case0671() -{ - parse("__extension__ struct x { } ;"); -} - -void ParserTester::case0672() -{ - parse("struct x { __extension__ int y ; } ;"); -} - -void ParserTester::case0673() -{ - parse("int x = __extension__ 0 ;"); -} - -void ParserTester::case0674() -{ - parse("__extension__ void x ( ) { }"); -} - -void ParserTester::case0675() -{ - parse("__extension__ asm ( \"nop\" ) ;"); -} - -void ParserTester::case0676() -{ - parseStatement("{ __extension__ int x ; }"); -} - -void ParserTester::case0677() -{ - parseStatement("__extension__ for ( ; ; ) { } ", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_UnexpectedGNUExtensionFlag)); -} - -void ParserTester::case0678() -{ - // Accepted by GCC, ICC, but not by Clang (11.0.0). - - parseStatement("for ( __extension__ int x ; ; ) { } "); -} - -void ParserTester::case0679() -{ - -} - -void ParserTester::case0680() -{ - -} - -void ParserTester::case0681() -{ - -} - -void ParserTester::case0682() -{ - -} - -void ParserTester::case0683() -{ - -} - -void ParserTester::case0684() -{ - -} - -void ParserTester::case0685() -{ - -} - -void ParserTester::case0686() -{ - -} - -void ParserTester::case0687() -{ - -} - -void ParserTester::case0688() -{ - -} - -void ParserTester::case0689() -{ - -} - -void ParserTester::case0690() -{ - -} - -void ParserTester::case0691() -{ - -} - -void ParserTester::case0692() -{ - -} - -void ParserTester::case0693() -{ - -} - -void ParserTester::case0694() -{ - -} - -void ParserTester::case0695() -{ - -} - -void ParserTester::case0696() -{ - -} - -void ParserTester::case0697() -{ - -} - -void ParserTester::case0698() -{ - -} - -void ParserTester::case0699() -{ - -} - -void ParserTester::case0700() -{ - parse("void x ( void ) __attribute__ ( ( noreturn ));", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute })); -} - -void ParserTester::case0701() -{ - parse("void __attribute__ ( ( noreturn ) ) x ( void ) ;", - Expectation().AST({ TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - ParameterDeclaration, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case0702() -{ - // The attribute belongs to the variable; a type attribute would've - // been placed immediately after the `struct' keyword, or, - // alternatively, after the closing brace. - - CROSS_REFERENCE_TEST(ParserTester::case0703) ; - CROSS_REFERENCE_TEST(ParserTester::case0704) ; - - parse("struct x __attribute__ ( ( vector_size ( 16 ) ) ) y ;") ; - -} - -void ParserTester::case0703() -{ - // The attribute belongs to the type. - - CROSS_REFERENCE_TEST(ParserTester::case0702) ; - - parse("struct __attribute__ ( ( aligned ) ) x { } ;") ; -} - -void ParserTester::case0704() -{ - // The attribute belongs to the type. - - CROSS_REFERENCE_TEST(ParserTester::case0702) ; - - parse("struct x { } __attribute__ ( ( aligned ) ) ;") ; -} - -void ParserTester::case0705() -{ - // The attribute belongs to the type. - - CROSS_REFERENCE_TEST(ParserTester::case0702) ; - - parse("struct x { short y [ 3 ] ; } __attribute__ ( ( aligned ( 8 ) ) ) ;") ; -} - -void ParserTester::case0706() -{ - parse("struct x { int y [ 2 ] __attribute__ ( ( aligned ( 8 ) ) ) ; } ;") ; -} - -void ParserTester::case0707() -{ - parse("struct x { short y [ 3 ] ; } __attribute__ ( ( aligned (8) ) ) z ;") ; -} - -void ParserTester::case0708() -{ - parse("__attribute__ ( ( availability ( macosx , introduced = 10.12 ) ) ) void x ( ) ;") ; -} - -void ParserTester::case0709() -{ - parse("__attribute__ ( ( availability ( macos , introduced = 10.4 , deprecated = 10.6 , obsoleted = 10.7) ) ) void x ( ) ;") ; -} - -void ParserTester::case0710() -{ - parse("__attribute__ ( ( availability ( ios , introduced = 10 , message =\"whatever\" ) ) ) void x ( ) ;") ; -} - -void ParserTester::case0711() -{ - parse("void x ( void ) __attribute__ ( ( availability ( macos , introduced = 10.4) ));") ; -} - -void ParserTester::case0712() -{ - parse("void x ( void ) __attribute__ ( ( availability ( macos , introduced = 10.4 , deprecated = 10.6 , obsoleted=10.7) ));") ; -} - -void ParserTester::case0713() -{ - parse("void ( __attribute__ ( ( noreturn ) ) * * * * x ) ( void ) ;") ; -} - -void ParserTester::case0714() -{ - parse("char * __attribute__ ( ( aligned ( 8 ) ) ) * x ;") ; -} - -void ParserTester::case0715() -{ - parse("__attribute__ ( ( format ( printf , 111 , 222 ) ) ) x ( const char * , ... ) ;") ; -} - -void ParserTester::case0716() -{ - parse(R"( - void x ( void ), - __attribute__ ( ( format ( printf , 111, 222) ) ) y ( const char * , ... ), - z ( void ) ; - )") ; -} - -void ParserTester::case0717() -{ - parse(R"( - __attribute__ ( (noreturn) ) void x ( void ), - __attribute__ ( ( format ( printf , 111, 222) ) ) y ( const char * , ... ), - z ( void ) ; - )") ; -} - -void ParserTester::case0718() -{ - parse("int x __attribute__ ( ( aligned (16) ) ) = 0 ;") ; -} - -void ParserTester::case0719() -{ - parse("x y __attribute__ ( ( aligned (16) ) ) = 0 ;") ; -} - -void ParserTester::case0720() -{ - parse("short x [3] __attribute__ ( ( aligned ( __BIGGEST_ALIGNMENT__ ) ));") ; -} - -void ParserTester::case0721() -{ - parse("x y [3] __attribute__ ( ( aligned ( __BIGGEST_ALIGNMENT__ ) ));") ; -} - -void ParserTester::case0722() -{ - parse("enum __attribute__ ( ( aligned ) ) x { y } ;") ; -} - -void ParserTester::case0723() -{ - parse("enum x { y } __attribute__ ( ( aligned ) );") ; -} - -void ParserTester::case0724() -{ - parse("enum x { y __attribute__( ( deprecated ) ) } ;") ; -} - -void ParserTester::case0725() -{ - parse("enum x { y __attribute__( ( deprecated ) ) = 1} ;") ; -} - -void ParserTester::case0726() -{ - parse("enum x { y __attribute__( ( deprecated ) ), z } ;") ; -} - -void ParserTester::case0727() -{ - parse("enum x { y __attribute__( ( deprecated ) ) = 1, z } ;") ; -} - -void ParserTester::case0728() -{ - parse("struct x { int y : 1 __attribute__ ( ( ) ) ; } ;"); -} - -void ParserTester::case0729() -{ - parse("struct x { int __attribute__(()) y : 2 ; } ;"); -} - -void ParserTester::case0730() -{ - // The attribute belongs to the declarator. - - parse("int x __attribute__ ( ( ) ) ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute })); -} - -void ParserTester::case0731() -{ - // The attribute belongs to the declaration. - - parse("int __attribute__ ( ( ) ) x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - IdentifierDeclarator })); -} - -void ParserTester::case0732() -{ - // The attribute belongs to the declaration. - - parse("__attribute__ ( ( ) ) int x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case0733() -{ - parse("const __attribute__ ( ( ) ) int __attribute__ ( ( ) ) x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - ConstQualifier, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - BuiltinTypeSpecifier, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - IdentifierDeclarator })); -} - -void ParserTester::case0734() -{ - parse("struct x { } __attribute__ ( ( aligned ) ) y ;"); -} - -void ParserTester::case0735() -{ - parse("int __attribute__ ( ( ) ) x ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - IdentifierDeclarator })); -} - -void ParserTester::case0736() -{ - parse("x __attribute__ ( ( ) ) y ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - IdentifierDeclarator })); -} - -void ParserTester::case0737() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0023); - - // Similar but without the `__attribute__'. - CROSS_REFERENCE_TEST(ParserTester::case0021); - - parse("int __attribute__ ( ( ) ) double ;", - Expectation().AST( { TranslationUnit, - IncompleteDeclaration, - BuiltinTypeSpecifier, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - BuiltinTypeSpecifier })); -} - -void ParserTester::case0738() -{ - // Not a syntactic error, but a semantic one; covered in: - CROSS_REFERENCE_TEST(BinderTester::case0024); - - parse("x __attribute__ ( ( ) ) int ;", - Expectation().AST( { TranslationUnit, - IncompleteDeclaration, - TypedefName, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute, - BuiltinTypeSpecifier })); -} - -void ParserTester::case0739() -{ - /* - * Notes: - * - Here, and without a `typedef' for `x', GCC 11.2 diagnoses a warning - * (no type or storage class) while Clang 13.0 diagnoses an error. - */ - - parse("x __attribute__ ( ( ) ) ;", - Expectation().AST( { TranslationUnit, - IncompleteDeclaration, - TypedefName, - ExtGNU_AttributeSpecifier, - ExtGNU_Attribute })); -} - -void ParserTester::case0740() -{ - parse("x __attribute__ ( ( noinline ) ) f ( ) { return 0 ; }"); -} - -void ParserTester::case0741() -{ - -} - -void ParserTester::case0742() -{ - -} - -void ParserTester::case0743() -{ - -} - -void ParserTester::case0744() -{ - -} - -void ParserTester::case0745() -{ - -} - -void ParserTester::case0746() -{ - -} - -void ParserTester::case0747() -{ - -} - -void ParserTester::case0748() -{ - -} - -void ParserTester::case0749() -{ - -} +void ParserTester::case0650() { parse("_Static_assert ( 1 != 2 , \"x\" ) ;"); } -void ParserTester::case0750() -{ -} - -void ParserTester::case0751() -{ - -} - -void ParserTester::case0752() -{ - -} - -void ParserTester::case0753() -{ - -} - -void ParserTester::case0754() -{ - -} - -void ParserTester::case0755() -{ - -} - -void ParserTester::case0756() -{ - -} - -void ParserTester::case0757() -{ - -} - -void ParserTester::case0758() -{ - -} - -void ParserTester::case0759() -{ - -} - -void ParserTester::case0760() -{ - -} - -void ParserTester::case0761() -{ +void ParserTester::case0651() {} -} - -void ParserTester::case0762() -{ - -} - -void ParserTester::case0763() -{ - -} - -void ParserTester::case0764() -{ +void ParserTester::case0652() {} -} - -void ParserTester::case0765() -{ - -} +void ParserTester::case0653() {} -void ParserTester::case0766() -{ +void ParserTester::case0654() {} -} - -void ParserTester::case0767() -{ - -} +void ParserTester::case0655() {} -void ParserTester::case0768() -{ +void ParserTester::case0656() {} -} +void ParserTester::case0657() {} -void ParserTester::case0769() -{ +void ParserTester::case0658() {} -} +void ParserTester::case0659() {} -void ParserTester::case0770() -{ +void ParserTester::case0660() {} -} +void ParserTester::case0661() {} -void ParserTester::case0771() -{ +void ParserTester::case0662() {} -} +void ParserTester::case0663() {} -void ParserTester::case0772() -{ +void ParserTester::case0664() {} -} +void ParserTester::case0665() {} -void ParserTester::case0773() -{ +void ParserTester::case0666() {} -} +void ParserTester::case0667() {} -void ParserTester::case0774() -{ +void ParserTester::case0668() {} -} +void ParserTester::case0669() {} -void ParserTester::case0775() -{ +void ParserTester::case0670() { parse("__extension__ int x ;"); } -} +void ParserTester::case0671() { parse("__extension__ struct x { } ;"); } -void ParserTester::case0776() -{ +void ParserTester::case0672() { parse("struct x { __extension__ int y ; } ;"); } -} +void ParserTester::case0673() { parse("int x = __extension__ 0 ;"); } -void ParserTester::case0777() -{ +void ParserTester::case0674() { parse("__extension__ void x ( ) { }"); } -} +void ParserTester::case0675() { parse("__extension__ asm ( \"nop\" ) ;"); } -void ParserTester::case0778() -{ +void ParserTester::case0676() { parseStatement("{ __extension__ int x ; }"); } +void ParserTester::case0677() { + parseStatement( + "__extension__ for ( ; ; ) { } ", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_UnexpectedGNUExtensionFlag)); } -void ParserTester::case0779() -{ +void ParserTester::case0678() { + // Accepted by GCC, ICC, but not by Clang (11.0.0). + parseStatement("for ( __extension__ int x ; ; ) { } "); } -void ParserTester::case0780() -{ - parse(R"( - asm("nop \n"); - )"); -} +void ParserTester::case0679() {} -void ParserTester::case0781() -{ - parse("int x asm ( \"y\") = 1 ;"); -} +void ParserTester::case0680() {} -void ParserTester::case0782() -{ - parse("int x asm ( \"y\") __attribute__ (()) = 1 ;"); -} +void ParserTester::case0681() {} -void ParserTester::case0783() -{ - parse("int x __attribute__ (()) asm", - Expectation().setErrorCnt(2)); -} +void ParserTester::case0682() {} -void ParserTester::case0784() -{ - parse("int __attribute__ (()) x asm ( \"y\") = 1 ;"); -} +void ParserTester::case0683() {} -void ParserTester::case0785() -{ - parse("int x ( int y ) asm ( \"z\" );"); -} +void ParserTester::case0684() {} -void ParserTester::case0786() -{ +void ParserTester::case0685() {} -} +void ParserTester::case0686() {} -void ParserTester::case0787() -{ +void ParserTester::case0687() {} -} +void ParserTester::case0688() {} -void ParserTester::case0788() -{ +void ParserTester::case0689() {} -} +void ParserTester::case0690() {} -void ParserTester::case0789() -{ +void ParserTester::case0691() {} -} +void ParserTester::case0692() {} -void ParserTester::case0790() -{ +void ParserTester::case0693() {} -} +void ParserTester::case0694() {} -void ParserTester::case0791() -{ +void ParserTester::case0695() {} -} +void ParserTester::case0696() {} -void ParserTester::case0792() -{ +void ParserTester::case0697() {} -} +void ParserTester::case0698() {} -void ParserTester::case0793() -{ +void ParserTester::case0699() {} +void ParserTester::case0700() { + parse("void x ( void ) __attribute__ ( ( noreturn ));", + Expectation().AST( + {TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, ParameterDeclaration, BuiltinTypeSpecifier, + AbstractDeclarator, ExtGNU_AttributeSpecifier, ExtGNU_Attribute})); } -void ParserTester::case0794() -{ - +void ParserTester::case0701() { + parse("void __attribute__ ( ( noreturn ) ) x ( void ) ;", + Expectation().AST( + {TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ExtGNU_AttributeSpecifier, ExtGNU_Attribute, + FunctionDeclarator, IdentifierDeclarator, ParameterSuffix, + ParameterDeclaration, BuiltinTypeSpecifier, AbstractDeclarator})); } -void ParserTester::case0795() -{ - -} +void ParserTester::case0702() { + // The attribute belongs to the variable; a type attribute would've + // been placed immediately after the `struct' keyword, or, + // alternatively, after the closing brace. -void ParserTester::case0796() -{ + CROSS_REFERENCE_TEST(ParserTester::case0703); + CROSS_REFERENCE_TEST(ParserTester::case0704); + parse("struct x __attribute__ ( ( vector_size ( 16 ) ) ) y ;"); } -void ParserTester::case0797() -{ +void ParserTester::case0703() { + // The attribute belongs to the type. -} - -void ParserTester::case0798() -{ + CROSS_REFERENCE_TEST(ParserTester::case0702); + parse("struct __attribute__ ( ( aligned ) ) x { } ;"); } -void ParserTester::case0799() -{ +void ParserTester::case0704() { + // The attribute belongs to the type. -} + CROSS_REFERENCE_TEST(ParserTester::case0702); -void ParserTester::case0800() -{ - parse("x y = { z } ;") ; + parse("struct x { } __attribute__ ( ( aligned ) ) ;"); } -void ParserTester::case0801() -{ - parse("int x = { 1 } ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression })); -} +void ParserTester::case0705() { + // The attribute belongs to the type. -void ParserTester::case0802() -{ - parse("struct x y = { 1 } ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - StructTypeSpecifier, - IdentifierDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression })); -} + CROSS_REFERENCE_TEST(ParserTester::case0702); -void ParserTester::case0803() -{ - parse("struct x y = { 1, 2 } ;") ; + parse("struct x { short y [ 3 ] ; } __attribute__ ( ( aligned ( 8 ) ) ) ;"); } -void ParserTester::case0804() -{ - parse("x y = { 1, 2 } ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression, - ExpressionInitializer, - IntegerConstantExpression })); +void ParserTester::case0706() { + parse("struct x { int y [ 2 ] __attribute__ ( ( aligned ( 8 ) ) ) ; } ;"); } -void ParserTester::case0805() -{ - parse("x y = { { 1 } } ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator, - BraceEnclosedInitializer, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression })); +void ParserTester::case0707() { + parse("struct x { short y [ 3 ] ; } __attribute__ ( ( aligned (8) ) ) z ;"); } -void ParserTester::case0806() -{ - parse("int x[] = { 1, 2 } ;") ; +void ParserTester::case0708() { + parse("__attribute__ ( ( availability ( macosx , introduced = 10.12 ) ) ) " + "void x ( ) ;"); } -void ParserTester::case0807() -{ - parse("int x[2] = { 1, 2 } ;") ; +void ParserTester::case0709() { + parse("__attribute__ ( ( availability ( macos , introduced = 10.4 , " + "deprecated = 10.6 , obsoleted = 10.7) ) ) void x ( ) ;"); } -void ParserTester::case0808() -{ - parse("int x[][2] = { { 1, 2 } } ;") ; +void ParserTester::case0710() { + parse("__attribute__ ( ( availability ( ios , introduced = 10 , message " + "=\"whatever\" ) ) ) void x ( ) ;"); } -void ParserTester::case0809() -{ - parse("int x[][2] = { { 1, 2 }, { 3, 4 } } ;") ; +void ParserTester::case0711() { + parse("void x ( void ) __attribute__ ( ( availability ( macos , introduced = " + "10.4) ));"); } -void ParserTester::case0810() -{ - parse("x y[][2] = { { 1, 2 }, { 3, 4 } } ;") ; +void ParserTester::case0712() { + parse("void x ( void ) __attribute__ ( ( availability ( macos , introduced = " + "10.4 , deprecated = 10.6 , obsoleted=10.7) ));"); } -void ParserTester::case0811() -{ - parse("x y = { { 1, 2 }, { 3, 4 } } ;") ; +void ParserTester::case0713() { + parse("void ( __attribute__ ( ( noreturn ) ) * * * * x ) ( void ) ;"); } -void ParserTester::case0812() -{ - parse("x y = { { 1, 2, 3 }, { 4 }, { 6, 7, 8} } ;") ; +void ParserTester::case0714() { + parse("char * __attribute__ ( ( aligned ( 8 ) ) ) * x ;"); } -void ParserTester::case0813() -{ - parse("x y = { 1, 2 }, y = { 3, 4, 5 } ;") ; +void ParserTester::case0715() { + parse("__attribute__ ( ( format ( printf , 111 , 222 ) ) ) x ( const char * " + ", ... ) ;"); } -void ParserTester::case0814() -{ - parse("int x[] = { 1, 2 }, y[] = { 3, 4, 5 } ;") ; +void ParserTester::case0716() { + parse(R"( + void x ( void ), + __attribute__ ( ( format ( printf , 111, 222) ) ) y ( const char * , ... ), + z ( void ) ; + )"); } -void ParserTester::case0815() -{ - parse("x y[] = { 1, 2 }, z[] = { 3, 4, 5 } ;") ; +void ParserTester::case0717() { + parse(R"( + __attribute__ ( (noreturn) ) void x ( void ), + __attribute__ ( ( format ( printf , 111, 222) ) ) y ( const char * , ... ), + z ( void ) ; + )"); } -void ParserTester::case0816() -{ - parse("x y = { 1, , 2 } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case0718() { + parse("int x __attribute__ ( ( aligned (16) ) ) = 0 ;"); } -void ParserTester::case0817() -{ - // Trailing comman is OK here. - - parse("x y = { 1, 2, } ;") ; +void ParserTester::case0719() { + parse("x y __attribute__ ( ( aligned (16) ) ) = 0 ;"); } -void ParserTester::case0818() -{ - parse("struct x y = { } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedBraceEnclosedInitializerList)); +void ParserTester::case0720() { + parse("short x [3] __attribute__ ( ( aligned ( __BIGGEST_ALIGNMENT__ ) ));"); } -void ParserTester::case0819() -{ - +void ParserTester::case0721() { + parse("x y [3] __attribute__ ( ( aligned ( __BIGGEST_ALIGNMENT__ ) ));"); } -void ParserTester::case0820() -{ - +void ParserTester::case0722() { + parse("enum __attribute__ ( ( aligned ) ) x { y } ;"); } -void ParserTester::case0821() -{ - +void ParserTester::case0723() { + parse("enum x { y } __attribute__ ( ( aligned ) );"); } -void ParserTester::case0822() -{ - +void ParserTester::case0724() { + parse("enum x { y __attribute__( ( deprecated ) ) } ;"); } -void ParserTester::case0823() -{ - +void ParserTester::case0725() { + parse("enum x { y __attribute__( ( deprecated ) ) = 1} ;"); } -void ParserTester::case0824() -{ - +void ParserTester::case0726() { + parse("enum x { y __attribute__( ( deprecated ) ), z } ;"); } -void ParserTester::case0825() -{ - +void ParserTester::case0727() { + parse("enum x { y __attribute__( ( deprecated ) ) = 1, z } ;"); } -void ParserTester::case0826() -{ - +void ParserTester::case0728() { + parse("struct x { int y : 1 __attribute__ ( ( ) ) ; } ;"); } -void ParserTester::case0827() -{ - +void ParserTester::case0729() { + parse("struct x { int __attribute__(()) y : 2 ; } ;"); } -void ParserTester::case0828() -{ +void ParserTester::case0730() { + // The attribute belongs to the declarator. + parse("int x __attribute__ ( ( ) ) ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, + ExtGNU_AttributeSpecifier, ExtGNU_Attribute})); } -void ParserTester::case0829() -{ +void ParserTester::case0731() { + // The attribute belongs to the declaration. + parse("int __attribute__ ( ( ) ) x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ExtGNU_AttributeSpecifier, + ExtGNU_Attribute, IdentifierDeclarator})); } -void ParserTester::case0830() -{ +void ParserTester::case0732() { + // The attribute belongs to the declaration. + parse("__attribute__ ( ( ) ) int x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + ExtGNU_AttributeSpecifier, ExtGNU_Attribute, + BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0831() -{ - +void ParserTester::case0733() { + parse("const __attribute__ ( ( ) ) int __attribute__ ( ( ) ) x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + ConstQualifier, ExtGNU_AttributeSpecifier, + ExtGNU_Attribute, BuiltinTypeSpecifier, + ExtGNU_AttributeSpecifier, ExtGNU_Attribute, + IdentifierDeclarator})); } -void ParserTester::case0832() -{ - +void ParserTester::case0734() { + parse("struct x { } __attribute__ ( ( aligned ) ) y ;"); } -void ParserTester::case0833() -{ - +void ParserTester::case0735() { + parse("int __attribute__ ( ( ) ) x ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, ExtGNU_AttributeSpecifier, + ExtGNU_Attribute, IdentifierDeclarator})); } -void ParserTester::case0834() -{ - +void ParserTester::case0736() { + parse("x __attribute__ ( ( ) ) y ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, ExtGNU_AttributeSpecifier, + ExtGNU_Attribute, IdentifierDeclarator})); } -void ParserTester::case0835() -{ - -} +void ParserTester::case0737() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0023); -void ParserTester::case0836() -{ + // Similar but without the `__attribute__'. + CROSS_REFERENCE_TEST(ParserTester::case0021); + parse("int __attribute__ ( ( ) ) double ;", + Expectation().AST({TranslationUnit, IncompleteDeclaration, + BuiltinTypeSpecifier, ExtGNU_AttributeSpecifier, + ExtGNU_Attribute, BuiltinTypeSpecifier})); } -void ParserTester::case0837() -{ +void ParserTester::case0738() { + // Not a syntactic error, but a semantic one; covered in: + CROSS_REFERENCE_TEST(BinderTester::case0024); + parse("x __attribute__ ( ( ) ) int ;", + Expectation().AST({TranslationUnit, IncompleteDeclaration, TypedefName, + ExtGNU_AttributeSpecifier, ExtGNU_Attribute, + BuiltinTypeSpecifier})); } -void ParserTester::case0838() -{ +void ParserTester::case0739() { + /* + * Notes: + * - Here, and without a `typedef' for `x', GCC 11.2 diagnoses a warning + * (no type or storage class) while Clang 13.0 diagnoses an error. + */ + parse("x __attribute__ ( ( ) ) ;", + Expectation().AST({TranslationUnit, IncompleteDeclaration, TypedefName, + ExtGNU_AttributeSpecifier, ExtGNU_Attribute})); } -void ParserTester::case0839() -{ - +void ParserTester::case0740() { + parse("x __attribute__ ( ( noinline ) ) f ( ) { return 0 ; }"); } -void ParserTester::case0840() -{ - -} +void ParserTester::case0741() {} -void ParserTester::case0841() -{ +void ParserTester::case0742() {} -} +void ParserTester::case0743() {} -void ParserTester::case0842() -{ +void ParserTester::case0744() {} -} +void ParserTester::case0745() {} -void ParserTester::case0843() -{ +void ParserTester::case0746() {} -} +void ParserTester::case0747() {} -void ParserTester::case0844() -{ +void ParserTester::case0748() {} -} +void ParserTester::case0749() {} -void ParserTester::case0845() -{ +void ParserTester::case0750() {} -} +void ParserTester::case0751() {} -void ParserTester::case0846() -{ +void ParserTester::case0752() {} -} +void ParserTester::case0753() {} -void ParserTester::case0847() -{ +void ParserTester::case0754() {} -} +void ParserTester::case0755() {} -void ParserTester::case0848() -{ +void ParserTester::case0756() {} -} +void ParserTester::case0757() {} -void ParserTester::case0849() -{ +void ParserTester::case0758() {} -} +void ParserTester::case0759() {} -void ParserTester::case0850() -{ - parse("struct x y = { . z = 1 } ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - StructTypeSpecifier, - IdentifierDeclarator, - BraceEnclosedInitializer, - DesignatedInitializer, - FieldDesignator, - ExpressionInitializer, - IntegerConstantExpression })); -} +void ParserTester::case0760() {} -void ParserTester::case0851() -{ - parse("struct x y = { . z = 1, . w = 2 } ;") ; -} +void ParserTester::case0761() {} -void ParserTester::case0852() -{ - parse("struct x y = { . = 1 } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFieldDesignator)); -} +void ParserTester::case0762() {} -void ParserTester::case0853() -{ - parse("x y [ ] = { [ 1 ] = 1 } ;", - Expectation().AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - TypedefName, - ArrayDeclarator, - IdentifierDeclarator, - SubscriptSuffix, - BraceEnclosedInitializer, - DesignatedInitializer, - ArrayDesignator, - IntegerConstantExpression, - ExpressionInitializer, - IntegerConstantExpression })); -} +void ParserTester::case0763() {} -void ParserTester::case0854() -{ - parse("int x [ 1 ] = { [ 1 ] = 1 , [ 2 ] = 2 } ;"); -} +void ParserTester::case0764() {} -void ParserTester::case0855() -{ - parse("x y [ 1 ] = { [ 1 ] = 1 , 2 , [ 3 ] = 3 } ;"); -} +void ParserTester::case0765() {} -void ParserTester::case0856() -{ - parse("x y [ 1 ] = { [ 1 ] = 1 , 2 , [ 3 ] = 3 , z } ;"); -} +void ParserTester::case0766() {} -void ParserTester::case0857() -{ - parse("x y [ 1 ] = { [ 1 ] = 1 , 2 , [ 3 ] = 3 } ;"); -} +void ParserTester::case0767() {} -void ParserTester::case0858() -{ - parse("x y [ ] = { [ 1 ] = z , } ;"); -} +void ParserTester::case0768() {} -void ParserTester::case0859() -{ - parse("x y [ ] = { [ 1 ] } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDesignatedInitializer) - .diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); -} +void ParserTester::case0769() {} -void ParserTester::case0860() -{ - parse("x y [ ] = { [ 1 ] 2 } ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedFOLLOWofDesignatedInitializer)); -} +void ParserTester::case0770() {} -void ParserTester::case0861() -{ - parse("x y [ ] = { [ 1 ] = } ;", - Expectation().setErrorCnt(1)); -} +void ParserTester::case0771() {} -void ParserTester::case0862() -{ - parse("x y [ ] = { [ ] = 1 } ;", - Expectation().setErrorCnt(1)); -} +void ParserTester::case0772() {} -void ParserTester::case0863() -{ - parseExpression("( struct x ) { . y [ 0 ] = 1 }", - Expectation().AST( { CompoundLiteralExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - BraceEnclosedInitializer, - DesignatedInitializer, - FieldDesignator, - ArrayDesignator, - IntegerConstantExpression, - ExpressionInitializer, - IntegerConstantExpression })); -} +void ParserTester::case0773() {} -void ParserTester::case0864() -{ - parseExpression("( struct x ) { . y [ 0 ] . z = 1 }", - Expectation().AST( { CompoundLiteralExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - BraceEnclosedInitializer, - DesignatedInitializer, - FieldDesignator, - ArrayDesignator, - IntegerConstantExpression, - FieldDesignator, - ExpressionInitializer, - IntegerConstantExpression })); -} +void ParserTester::case0774() {} -void ParserTester::case0865() -{ +void ParserTester::case0775() {} -} +void ParserTester::case0776() {} -void ParserTester::case0866() -{ +void ParserTester::case0777() {} -} +void ParserTester::case0778() {} -void ParserTester::case0867() -{ +void ParserTester::case0779() {} +void ParserTester::case0780() { + parse(R"( + asm("nop \n"); + )"); } -void ParserTester::case0868() -{ +void ParserTester::case0781() { parse("int x asm ( \"y\") = 1 ;"); } +void ParserTester::case0782() { + parse("int x asm ( \"y\") __attribute__ (()) = 1 ;"); } -void ParserTester::case0869() -{ - +void ParserTester::case0783() { + parse("int x __attribute__ (()) asm", Expectation().setErrorCnt(2)); } -void ParserTester::case0870() -{ - +void ParserTester::case0784() { + parse("int __attribute__ (()) x asm ( \"y\") = 1 ;"); } -void ParserTester::case0871() -{ - -} +void ParserTester::case0785() { parse("int x ( int y ) asm ( \"z\" );"); } -void ParserTester::case0872() -{ +void ParserTester::case0786() {} -} +void ParserTester::case0787() {} -void ParserTester::case0873() -{ +void ParserTester::case0788() {} -} +void ParserTester::case0789() {} -void ParserTester::case0874() -{ +void ParserTester::case0790() {} -} +void ParserTester::case0791() {} -void ParserTester::case0875() -{ +void ParserTester::case0792() {} -} +void ParserTester::case0793() {} -void ParserTester::case0876() -{ +void ParserTester::case0794() {} -} +void ParserTester::case0795() {} -void ParserTester::case0877() -{ +void ParserTester::case0796() {} -} +void ParserTester::case0797() {} -void ParserTester::case0878() -{ +void ParserTester::case0798() {} -} +void ParserTester::case0799() {} -void ParserTester::case0879() -{ +void ParserTester::case0800() { parse("x y = { z } ;"); } +void ParserTester::case0801() { + parse("int x = { 1 } ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, + BraceEnclosedInitializer, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case0880() -{ - +void ParserTester::case0802() { + parse("struct x y = { 1 } ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + StructTypeSpecifier, IdentifierDeclarator, + BraceEnclosedInitializer, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case0881() -{ +void ParserTester::case0803() { parse("struct x y = { 1, 2 } ;"); } +void ParserTester::case0804() { + parse("x y = { 1, 2 } ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, IdentifierDeclarator, + BraceEnclosedInitializer, ExpressionInitializer, + IntegerConstantExpression, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case0882() -{ - +void ParserTester::case0805() { + parse("x y = { { 1 } } ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, IdentifierDeclarator, + BraceEnclosedInitializer, BraceEnclosedInitializer, + ExpressionInitializer, IntegerConstantExpression})); } -void ParserTester::case0883() -{ +void ParserTester::case0806() { parse("int x[] = { 1, 2 } ;"); } -} +void ParserTester::case0807() { parse("int x[2] = { 1, 2 } ;"); } -void ParserTester::case0884() -{ +void ParserTester::case0808() { parse("int x[][2] = { { 1, 2 } } ;"); } +void ParserTester::case0809() { + parse("int x[][2] = { { 1, 2 }, { 3, 4 } } ;"); } -void ParserTester::case0885() -{ - -} +void ParserTester::case0810() { parse("x y[][2] = { { 1, 2 }, { 3, 4 } } ;"); } -void ParserTester::case0886() -{ +void ParserTester::case0811() { parse("x y = { { 1, 2 }, { 3, 4 } } ;"); } +void ParserTester::case0812() { + parse("x y = { { 1, 2, 3 }, { 4 }, { 6, 7, 8} } ;"); } -void ParserTester::case0887() -{ +void ParserTester::case0813() { parse("x y = { 1, 2 }, y = { 3, 4, 5 } ;"); } +void ParserTester::case0814() { + parse("int x[] = { 1, 2 }, y[] = { 3, 4, 5 } ;"); } -void ParserTester::case0888() -{ - +void ParserTester::case0815() { + parse("x y[] = { 1, 2 }, z[] = { 3, 4, 5 } ;"); } -void ParserTester::case0889() -{ - +void ParserTester::case0816() { + parse("x y = { 1, , 2 } ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case0890() -{ +void ParserTester::case0817() { + // Trailing comman is OK here. + parse("x y = { 1, 2, } ;"); } -void ParserTester::case0891() -{ - +void ParserTester::case0818() { + parse( + "struct x y = { } ;", + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedBraceEnclosedInitializerList)); } -void ParserTester::case0892() -{ +void ParserTester::case0819() {} -} +void ParserTester::case0820() {} -void ParserTester::case0893() -{ +void ParserTester::case0821() {} -} +void ParserTester::case0822() {} -void ParserTester::case0894() -{ +void ParserTester::case0823() {} -} +void ParserTester::case0824() {} -void ParserTester::case0895() -{ +void ParserTester::case0825() {} -} +void ParserTester::case0826() {} -void ParserTester::case0896() -{ +void ParserTester::case0827() {} -} +void ParserTester::case0828() {} -void ParserTester::case0897() -{ +void ParserTester::case0829() {} -} +void ParserTester::case0830() {} -void ParserTester::case0898() -{ +void ParserTester::case0831() {} -} +void ParserTester::case0832() {} -void ParserTester::case0899() -{ +void ParserTester::case0833() {} -} +void ParserTester::case0834() {} -void ParserTester::case0900() -{ - parse("__typeof__ ( int ) x ;"); -} +void ParserTester::case0835() {} -void ParserTester::case0901() -{ - parse("__typeof__ ( int * ) x ;"); -} +void ParserTester::case0836() {} -void ParserTester::case0902() -{ - parse("__typeof__ ( int * ) x [ 1 ] ;"); -} +void ParserTester::case0837() {} -void ParserTester::case0903() -{ - parse("__typeof__ ( __typeof__ ( int * ) [ 1 ] ) x ;"); -} +void ParserTester::case0838() {} -void ParserTester::case0904() -{ - /* - Despite the parsing similarities between `typeof' and `sizeof', - mind the difference between this test case and the following: +void ParserTester::case0839() {} - `sizeof ( x ) y ;' +void ParserTester::case0840() {} - This `sizeof' expression is invalid, since it'd imply parsing - the expression operand as a cast-expression, but that isn't - allowed in such context: only a unary-expression is. - */ +void ParserTester::case0841() {} - CROSS_REFERENCE_TEST(ParserTester::case2115); +void ParserTester::case0842() {} - parse("__typeof__ ( x ) y ;", - Expectation().ambiguity("__typeof__ ( x ) ( x ) y ;") - .AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - ExtGNU_Typeof, - AmbiguousTypeNameOrExpressionAsTypeReference, - ExpressionAsTypeReference, - ParenthesizedExpression, - IdentifierName, - TypeNameAsTypeReference, - TypeName, - TypedefName, - IdentifierDeclarator } )); -} +void ParserTester::case0843() {} -void ParserTester::case0905() -{ - parse("__typeof__ ( x * ) y ;"); -} +void ParserTester::case0844() {} -void ParserTester::case0906() -{ - parse("__typeof__ ( * x ) y ;"); -} +void ParserTester::case0845() {} -void ParserTester::case0907() -{ - parse("__typeof__ ( x [ 0 ] ) y ;"); -} +void ParserTester::case0846() {} -void ParserTester::case0908() -{ - parse("__typeof__ ( x [ 0 ] [ 1 ] ) y ;"); -} +void ParserTester::case0847() {} -void ParserTester::case0909() -{ - parse("__typeof__ ( x [ 0 ] [ 1 ] ( ) ) y ;"); -} +void ParserTester::case0848() {} -void ParserTester::case0910() -{ - parse("int x = ( __typeof__ ( int ) ) 1 ;"); -} +void ParserTester::case0849() {} -void ParserTester::case0911() -{ - parse("void x ( __typeof__ ( int ) y ) ;"); +void ParserTester::case0850() { + parse("struct x y = { . z = 1 } ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + StructTypeSpecifier, IdentifierDeclarator, + BraceEnclosedInitializer, DesignatedInitializer, + FieldDesignator, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case0912() -{ - parse("void x ( ) { __typeof__ ( x * ) y ; }"); -} +void ParserTester::case0851() { parse("struct x y = { . z = 1, . w = 2 } ;"); } -void ParserTester::case0913() -{ - parse("void x ( ) { __typeof__ ( int ) x ; }"); +void ParserTester::case0852() { + parse("struct x y = { . = 1 } ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFieldDesignator)); } -void ParserTester::case0914() -{ - parse("void x ( ) { sizeof ( __typeof__ ( int ) ) ; }"); +void ParserTester::case0853() { + parse("x y [ ] = { [ 1 ] = 1 } ;", + Expectation().AST({TranslationUnit, VariableAndOrFunctionDeclaration, + TypedefName, ArrayDeclarator, IdentifierDeclarator, + SubscriptSuffix, BraceEnclosedInitializer, + DesignatedInitializer, ArrayDesignator, + IntegerConstantExpression, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case0915() -{ - +void ParserTester::case0854() { + parse("int x [ 1 ] = { [ 1 ] = 1 , [ 2 ] = 2 } ;"); } -void ParserTester::case0916() -{ - +void ParserTester::case0855() { + parse("x y [ 1 ] = { [ 1 ] = 1 , 2 , [ 3 ] = 3 } ;"); } -void ParserTester::case0917() -{ - +void ParserTester::case0856() { + parse("x y [ 1 ] = { [ 1 ] = 1 , 2 , [ 3 ] = 3 , z } ;"); } -void ParserTester::case0918() -{ - +void ParserTester::case0857() { + parse("x y [ 1 ] = { [ 1 ] = 1 , 2 , [ 3 ] = 3 } ;"); } -void ParserTester::case0919() -{ +void ParserTester::case0858() { parse("x y [ ] = { [ 1 ] = z , } ;"); } +void ParserTester::case0859() { + parse("x y [ ] = { [ 1 ] } ;", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFOLLOWofDesignatedInitializer) + .diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case0920() -{ - +void ParserTester::case0860() { + parse("x y [ ] = { [ 1 ] 2 } ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFOLLOWofDesignatedInitializer)); } -void ParserTester::case0921() -{ - +void ParserTester::case0861() { + parse("x y [ ] = { [ 1 ] = } ;", Expectation().setErrorCnt(1)); } -void ParserTester::case0922() -{ - +void ParserTester::case0862() { + parse("x y [ ] = { [ ] = 1 } ;", Expectation().setErrorCnt(1)); } -void ParserTester::case0923() -{ - +void ParserTester::case0863() { + parseExpression( + "( struct x ) { . y [ 0 ] = 1 }", + Expectation().AST( + {CompoundLiteralExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, BraceEnclosedInitializer, DesignatedInitializer, + FieldDesignator, ArrayDesignator, IntegerConstantExpression, + ExpressionInitializer, IntegerConstantExpression})); } -void ParserTester::case0924() -{ - +void ParserTester::case0864() { + parseExpression( + "( struct x ) { . y [ 0 ] . z = 1 }", + Expectation().AST( + {CompoundLiteralExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, BraceEnclosedInitializer, DesignatedInitializer, + FieldDesignator, ArrayDesignator, IntegerConstantExpression, + FieldDesignator, ExpressionInitializer, IntegerConstantExpression})); } -void ParserTester::case0925() -{ +void ParserTester::case0865() {} -} - -void ParserTester::case0926() -{ +void ParserTester::case0866() {} -} +void ParserTester::case0867() {} -void ParserTester::case0927() -{ +void ParserTester::case0868() {} -} +void ParserTester::case0869() {} -void ParserTester::case0928() -{ +void ParserTester::case0870() {} -} +void ParserTester::case0871() {} -void ParserTester::case0929() -{ +void ParserTester::case0872() {} -} +void ParserTester::case0873() {} -void ParserTester::case0930() -{ +void ParserTester::case0874() {} -} +void ParserTester::case0875() {} -void ParserTester::case0931() -{ +void ParserTester::case0876() {} -} +void ParserTester::case0877() {} -void ParserTester::case0932() -{ +void ParserTester::case0878() {} -} +void ParserTester::case0879() {} -void ParserTester::case0933() -{ +void ParserTester::case0880() {} -} +void ParserTester::case0881() {} -void ParserTester::case0934() -{ +void ParserTester::case0882() {} -} +void ParserTester::case0883() {} -void ParserTester::case0935() -{ +void ParserTester::case0884() {} -} +void ParserTester::case0885() {} -void ParserTester::case0936() -{ +void ParserTester::case0886() {} -} +void ParserTester::case0887() {} -void ParserTester::case0937() -{ +void ParserTester::case0888() {} -} +void ParserTester::case0889() {} -void ParserTester::case0938() -{ +void ParserTester::case0890() {} -} +void ParserTester::case0891() {} -void ParserTester::case0939() -{ +void ParserTester::case0892() {} -} +void ParserTester::case0893() {} -void ParserTester::case0940() -{ +void ParserTester::case0894() {} -} +void ParserTester::case0895() {} -void ParserTester::case0941() -{ +void ParserTester::case0896() {} -} +void ParserTester::case0897() {} -void ParserTester::case0942() -{ +void ParserTester::case0898() {} -} +void ParserTester::case0899() {} -void ParserTester::case0943() -{ +void ParserTester::case0900() { parse("__typeof__ ( int ) x ;"); } -} +void ParserTester::case0901() { parse("__typeof__ ( int * ) x ;"); } -void ParserTester::case0944() -{ +void ParserTester::case0902() { parse("__typeof__ ( int * ) x [ 1 ] ;"); } +void ParserTester::case0903() { + parse("__typeof__ ( __typeof__ ( int * ) [ 1 ] ) x ;"); } -void ParserTester::case0945() -{ +void ParserTester::case0904() { + /* + Despite the parsing similarities between `typeof' and `sizeof', + mind the difference between this test case and the following: -} - -void ParserTester::case0946() -{ + `sizeof ( x ) y ;' -} + This `sizeof' expression is invalid, since it'd imply parsing + the expression operand as a cast-expression, but that isn't + allowed in such context: only a unary-expression is. + */ -void ParserTester::case0947() -{ + CROSS_REFERENCE_TEST(ParserTester::case2115); + parse("__typeof__ ( x ) y ;", + Expectation() + .ambiguity("__typeof__ ( x ) ( x ) y ;") + .AST({TranslationUnit, VariableAndOrFunctionDeclaration, + ExtGNU_Typeof, AmbiguousTypeNameOrExpressionAsTypeReference, + ExpressionAsTypeReference, ParenthesizedExpression, + IdentifierName, TypeNameAsTypeReference, TypeName, + TypedefName, IdentifierDeclarator})); } -void ParserTester::case0948() -{ +void ParserTester::case0905() { parse("__typeof__ ( x * ) y ;"); } -} +void ParserTester::case0906() { parse("__typeof__ ( * x ) y ;"); } -void ParserTester::case0949() -{ +void ParserTester::case0907() { parse("__typeof__ ( x [ 0 ] ) y ;"); } -} +void ParserTester::case0908() { parse("__typeof__ ( x [ 0 ] [ 1 ] ) y ;"); } -void ParserTester::case0950() -{ - parse("_Alignas ( 16 ) int x ;"); -} +void ParserTester::case0909() { parse("__typeof__ ( x [ 0 ] [ 1 ] ( ) ) y ;"); } -void ParserTester::case0951() -{ - parse("_Alignas ( double ) int x ;"); -} +void ParserTester::case0910() { parse("int x = ( __typeof__ ( int ) ) 1 ;"); } -void ParserTester::case0952() -{ - parse("_Alignas ( double * ) int y ;"); -} +void ParserTester::case0911() { parse("void x ( __typeof__ ( int ) y ) ;"); } -void ParserTester::case0953() -{ - parse("_Alignas ( x ) int y ;", - Expectation().ambiguity("_Alignas ( x ) ( x ) int y ;") - .AST( { TranslationUnit, - VariableAndOrFunctionDeclaration, - AlignmentSpecifier, - AmbiguousTypeNameOrExpressionAsTypeReference, - ExpressionAsTypeReference, - ParenthesizedExpression, - IdentifierName, - TypeNameAsTypeReference, - TypeName, - TypedefName, - BuiltinTypeSpecifier, - IdentifierDeclarator } )); +void ParserTester::case0912() { + parse("void x ( ) { __typeof__ ( x * ) y ; }"); } -void ParserTester::case0954() -{ - parse("_Alignas ( x * ) int y ;"); +void ParserTester::case0913() { + parse("void x ( ) { __typeof__ ( int ) x ; }"); } -void ParserTester::case0955() -{ - parse("_Alignas ( x * ) y z ;"); +void ParserTester::case0914() { + parse("void x ( ) { sizeof ( __typeof__ ( int ) ) ; }"); } -void ParserTester::case0956() -{ - parse("struct x { _Alignas ( 16 ) int y ; } ;"); -} +void ParserTester::case0915() {} -void ParserTester::case0957() -{ +void ParserTester::case0916() {} -} +void ParserTester::case0917() {} -void ParserTester::case0958() -{ +void ParserTester::case0918() {} -} +void ParserTester::case0919() {} -void ParserTester::case0959() -{ +void ParserTester::case0920() {} -} +void ParserTester::case0921() {} -void ParserTester::case0960() -{ +void ParserTester::case0922() {} -} +void ParserTester::case0923() {} -void ParserTester::case0961() -{ +void ParserTester::case0924() {} -} +void ParserTester::case0925() {} -void ParserTester::case0962() -{ +void ParserTester::case0926() {} -} +void ParserTester::case0927() {} -void ParserTester::case0963() -{ +void ParserTester::case0928() {} -} +void ParserTester::case0929() {} -void ParserTester::case0964() -{ +void ParserTester::case0930() {} -} +void ParserTester::case0931() {} -void ParserTester::case0965() -{ +void ParserTester::case0932() {} -} +void ParserTester::case0933() {} -void ParserTester::case0966() -{ +void ParserTester::case0934() {} -} +void ParserTester::case0935() {} -void ParserTester::case0967() -{ +void ParserTester::case0936() {} -} +void ParserTester::case0937() {} -void ParserTester::case0968() -{ +void ParserTester::case0938() {} -} +void ParserTester::case0939() {} -void ParserTester::case0969() -{ +void ParserTester::case0940() {} -} +void ParserTester::case0941() {} -void ParserTester::case0970() -{ +void ParserTester::case0942() {} -} +void ParserTester::case0943() {} -void ParserTester::case0971() -{ +void ParserTester::case0944() {} -} +void ParserTester::case0945() {} -void ParserTester::case0972() -{ +void ParserTester::case0946() {} -} +void ParserTester::case0947() {} -void ParserTester::case0973() -{ +void ParserTester::case0948() {} -} +void ParserTester::case0949() {} -void ParserTester::case0974() -{ +void ParserTester::case0950() { parse("_Alignas ( 16 ) int x ;"); } -} +void ParserTester::case0951() { parse("_Alignas ( double ) int x ;"); } -void ParserTester::case0975() -{ +void ParserTester::case0952() { parse("_Alignas ( double * ) int y ;"); } +void ParserTester::case0953() { + parse("_Alignas ( x ) int y ;", + Expectation() + .ambiguity("_Alignas ( x ) ( x ) int y ;") + .AST({TranslationUnit, VariableAndOrFunctionDeclaration, + AlignmentSpecifier, + AmbiguousTypeNameOrExpressionAsTypeReference, + ExpressionAsTypeReference, ParenthesizedExpression, + IdentifierName, TypeNameAsTypeReference, TypeName, + TypedefName, BuiltinTypeSpecifier, IdentifierDeclarator})); } -void ParserTester::case0976() -{ - -} +void ParserTester::case0954() { parse("_Alignas ( x * ) int y ;"); } -void ParserTester::case0977() -{ +void ParserTester::case0955() { parse("_Alignas ( x * ) y z ;"); } +void ParserTester::case0956() { + parse("struct x { _Alignas ( 16 ) int y ; } ;"); } -void ParserTester::case0978() -{ - -} +void ParserTester::case0957() {} -void ParserTester::case0979() -{ +void ParserTester::case0958() {} -} +void ParserTester::case0959() {} -void ParserTester::case0980() -{ +void ParserTester::case0960() {} -} +void ParserTester::case0961() {} -void ParserTester::case0981() -{ +void ParserTester::case0962() {} -} +void ParserTester::case0963() {} -void ParserTester::case0982() -{ +void ParserTester::case0964() {} -} +void ParserTester::case0965() {} -void ParserTester::case0983() -{ +void ParserTester::case0966() {} -} +void ParserTester::case0967() {} -void ParserTester::case0984() -{ +void ParserTester::case0968() {} -} +void ParserTester::case0969() {} -void ParserTester::case0985() -{ +void ParserTester::case0970() {} -} +void ParserTester::case0971() {} -void ParserTester::case0986() -{ +void ParserTester::case0972() {} -} +void ParserTester::case0973() {} -void ParserTester::case0987() -{ +void ParserTester::case0974() {} -} +void ParserTester::case0975() {} -void ParserTester::case0988() -{ +void ParserTester::case0976() {} -} +void ParserTester::case0977() {} -void ParserTester::case0989() -{ +void ParserTester::case0978() {} -} +void ParserTester::case0979() {} -void ParserTester::case0990() -{ +void ParserTester::case0980() {} -} +void ParserTester::case0981() {} -void ParserTester::case0991() -{ +void ParserTester::case0982() {} -} +void ParserTester::case0983() {} -void ParserTester::case0992() -{ +void ParserTester::case0984() {} -} +void ParserTester::case0985() {} -void ParserTester::case0993() -{ +void ParserTester::case0986() {} -} +void ParserTester::case0987() {} -void ParserTester::case0994() -{ +void ParserTester::case0988() {} -} +void ParserTester::case0989() {} -void ParserTester::case0995() -{ +void ParserTester::case0990() {} -} +void ParserTester::case0991() {} -void ParserTester::case0996() -{ +void ParserTester::case0992() {} -} +void ParserTester::case0993() {} -void ParserTester::case0997() -{ +void ParserTester::case0994() {} -} +void ParserTester::case0995() {} -void ParserTester::case0998() -{ +void ParserTester::case0996() {} -} +void ParserTester::case0997() {} -void ParserTester::case0999() -{ +void ParserTester::case0998() {} -} +void ParserTester::case0999() {} diff --git a/C/tests/ParserTester_1000_1999.cpp b/C/tests/ParserTester_1000_1999.cpp index 6c5d36105..3520d4f21 100644 --- a/C/tests/ParserTester_1000_1999.cpp +++ b/C/tests/ParserTester_1000_1999.cpp @@ -30,685 +30,527 @@ #include #include #include -#include #include +#include using namespace psy; using namespace C; -void ParserTester::case1000() -{ - parseExpression("1", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1000() { + parseExpression("1", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1001() -{ - parseExpression(".1", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1001() { + parseExpression(".1", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1002() -{ - parseExpression("1.", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1002() { + parseExpression("1.", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1003() -{ - parseExpression("1.2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1003() { + parseExpression("1.2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1004() -{ - parseExpression("1.2e3", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1004() { + parseExpression("1.2e3", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1005() -{ - parseExpression("1.2E3", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1005() { + parseExpression("1.2E3", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1006() -{ - parseExpression("1.2e+3", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1006() { + parseExpression("1.2e+3", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1007() -{ - parseExpression("1.2E+3", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1007() { + parseExpression("1.2E+3", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1008() -{ - parseExpression("1.2e-3", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1008() { + parseExpression("1.2e-3", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1009() -{ - parseExpression("1.2E-3", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1009() { + parseExpression("1.2E-3", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1010() -{ - parseExpression("1e2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1010() { + parseExpression("1e2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1011() -{ - parseExpression("1E2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1011() { + parseExpression("1E2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1012() -{ - parseExpression("1e+2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1012() { + parseExpression("1e+2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1013() -{ - parseExpression("1e-2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1013() { + parseExpression("1e-2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1014() -{ - parseExpression("1E+2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1014() { + parseExpression("1E+2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1015() -{ - parseExpression("1E-2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1015() { + parseExpression("1E-2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1016() -{ - parseExpression("1E+2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1016() { + parseExpression("1E+2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1017() -{ - parseExpression("1.e2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1017() { + parseExpression("1.e2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1018() -{ - parseExpression("1.E2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1018() { + parseExpression("1.E2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1019() -{ - parseExpression("0", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1019() { + parseExpression("0", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1020() -{ - parseExpression("0L", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1020() { + parseExpression("0L", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1021() -{ - parseExpression("int", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1021() { + parseExpression( + "int", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1022() -{ - parseExpression("{", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1022() { + parseExpression( + "{", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1023() -{ - parseExpression("0x1.2p3", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1023() { + parseExpression("0x1.2p3", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1024() -{ - parseExpression("0x1.ap2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1024() { + parseExpression("0x1.ap2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1025() -{ - parseExpression("0x1.Ap2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1025() { + parseExpression("0x1.Ap2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1026() -{ - parseExpression("0x1.fp2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1026() { + parseExpression("0x1.fp2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1027() -{ - parseExpression("0x1.Fp2", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1027() { + parseExpression("0x1.Fp2", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1028() -{ - parseExpression("0x1.2p3f", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1028() { + parseExpression("0x1.2p3f", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1029() -{ - parseExpression("0x1.2p3F", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1029() { + parseExpression("0x1.2p3F", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1030() -{ - parseExpression("x", - Expectation().AST( { IdentifierName })); +void ParserTester::case1030() { + parseExpression("x", Expectation().AST({IdentifierName})); } -void ParserTester::case1031() -{ - parseExpression("_x", - Expectation().AST( { IdentifierName })); +void ParserTester::case1031() { + parseExpression("_x", Expectation().AST({IdentifierName})); } -void ParserTester::case1032() -{ - parseExpression("x_y", - Expectation().AST( { IdentifierName })); +void ParserTester::case1032() { + parseExpression("x_y", Expectation().AST({IdentifierName})); } -void ParserTester::case1033() -{ - parseExpression("x1", - Expectation().AST( { IdentifierName })); +void ParserTester::case1033() { + parseExpression("x1", Expectation().AST({IdentifierName})); } -void ParserTester::case1034() -{ - parseExpression("x1_", - Expectation().AST( { IdentifierName })); +void ParserTester::case1034() { + parseExpression("x1_", Expectation().AST({IdentifierName})); } -void ParserTester::case1035() -{ - parseExpression("x1y2", - Expectation().AST( { IdentifierName })); +void ParserTester::case1035() { + parseExpression("x1y2", Expectation().AST({IdentifierName})); } -void ParserTester::case1036() -{ - parseExpression("_x1y2_", - Expectation().AST( { IdentifierName })); +void ParserTester::case1036() { + parseExpression("_x1y2_", Expectation().AST({IdentifierName})); } -void ParserTester::case1037() -{ - parseExpression("X", - Expectation().AST( { IdentifierName })); +void ParserTester::case1037() { + parseExpression("X", Expectation().AST({IdentifierName})); } -void ParserTester::case1038() -{ - parseExpression("_X", - Expectation().AST( { IdentifierName })); +void ParserTester::case1038() { + parseExpression("_X", Expectation().AST({IdentifierName})); } -void ParserTester::case1039() -{ - parseExpression("X1", - Expectation().AST( { IdentifierName })); +void ParserTester::case1039() { + parseExpression("X1", Expectation().AST({IdentifierName})); } -void ParserTester::case1040() -{ - parseExpression("_X1", - Expectation().AST( { IdentifierName })); +void ParserTester::case1040() { + parseExpression("_X1", Expectation().AST({IdentifierName})); } -void ParserTester::case1041() -{ - parseExpression("xYz1", - Expectation().AST( { IdentifierName })); +void ParserTester::case1041() { + parseExpression("xYz1", Expectation().AST({IdentifierName})); } -void ParserTester::case1042() -{ - parseExpression("xYz1_", - Expectation().AST( { IdentifierName })); +void ParserTester::case1042() { + parseExpression("xYz1_", Expectation().AST({IdentifierName})); } -void ParserTester::case1043() -{ - parseExpression("xY_z1", - Expectation().AST( { IdentifierName })); +void ParserTester::case1043() { + parseExpression("xY_z1", Expectation().AST({IdentifierName})); } -void ParserTester::case1044() -{ - parseExpression("1l", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1044() { + parseExpression("1l", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1045() -{ - parseExpression("1ll", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1045() { + parseExpression("1ll", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1046() -{ - parseExpression("1L", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1046() { + parseExpression("1L", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1047() -{ - parseExpression("1LL", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1047() { + parseExpression("1LL", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1048() -{ - parseExpression("1u", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1048() { + parseExpression("1u", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1049() -{ - parseExpression("1U", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1049() { + parseExpression("1U", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1050() -{ - parseExpression("1uL", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1050() { + parseExpression("1uL", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1051() -{ - parseExpression("1ul", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1051() { + parseExpression("1ul", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1052() -{ - parseExpression("0x1u", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1052() { + parseExpression("0x1u", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1053() -{ - parseExpression("0x1Ul", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1053() { + parseExpression("0x1Ul", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1054() -{ - parseExpression("L'x'", - Expectation().AST( { CharacterConstantExpression })); +void ParserTester::case1054() { + parseExpression("L'x'", Expectation().AST({CharacterConstantExpression})); } -void ParserTester::case1055() -{ - parseExpression("u'x'", - Expectation().AST( { CharacterConstantExpression })); +void ParserTester::case1055() { + parseExpression("u'x'", Expectation().AST({CharacterConstantExpression})); } -void ParserTester::case1056() -{ - parseExpression("U'x'", - Expectation().AST( { CharacterConstantExpression })); +void ParserTester::case1056() { + parseExpression("U'x'", Expectation().AST({CharacterConstantExpression})); } -void ParserTester::case1057() -{ - parseExpression("'x'", - Expectation().AST( { CharacterConstantExpression })); +void ParserTester::case1057() { + parseExpression("'x'", Expectation().AST({CharacterConstantExpression})); } -void ParserTester::case1058() -{ - parseExpression("u\"xyz\"", - Expectation().AST( { StringLiteralExpression })); +void ParserTester::case1058() { + parseExpression("u\"xyz\"", Expectation().AST({StringLiteralExpression})); } -void ParserTester::case1059() -{ - parseExpression("\"xyz\"", - Expectation().AST( { StringLiteralExpression })); +void ParserTester::case1059() { + parseExpression("\"xyz\"", Expectation().AST({StringLiteralExpression})); } -void ParserTester::case1060() -{ - parseExpression("\"x\" \"y\"", - Expectation().AST( { StringLiteralExpression, - StringLiteralExpression})); +void ParserTester::case1060() { + parseExpression("\"x\" \"y\"", Expectation().AST({StringLiteralExpression, + StringLiteralExpression})); } -void ParserTester::case1061() -{ - parseExpression("1Lu", - Expectation().AST( { IntegerConstantExpression })); - +void ParserTester::case1061() { + parseExpression("1Lu", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1062() -{ - parseExpression("0x1lU", - Expectation().AST( { IntegerConstantExpression })); +void ParserTester::case1062() { + parseExpression("0x1lU", Expectation().AST({IntegerConstantExpression})); } -void ParserTester::case1063() -{ - parseExpression("0x1lUll", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1063() { + parseExpression( + "0x1lUll", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1064() -{ - parseExpression("1lul", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1064() { + parseExpression( + "1lul", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1065() -{ - parseExpression("1ulu", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1065() { + parseExpression( + "1ulu", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1066() -{ - parseExpression("1ullu", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1066() { + parseExpression( + "1ullu", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1067() -{ - parseExpression("1uu", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1067() { + parseExpression( + "1uu", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1068() -{ - parseExpression("1lll", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1068() { + parseExpression( + "1lll", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1069() -{ - parseExpression(".1f", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1069() { + parseExpression(".1f", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1070() -{ - parseExpression(".1l", - Expectation().AST( { FloatingConstantExpression })); +void ParserTester::case1070() { + parseExpression(".1l", Expectation().AST({FloatingConstantExpression})); } -void ParserTester::case1071() -{ - parseExpression("1i", - Expectation().AST( { ImaginaryIntegerConstantExpression })); +void ParserTester::case1071() { + parseExpression("1i", + Expectation().AST({ImaginaryIntegerConstantExpression})); } -void ParserTester::case1072() -{ - parseExpression(".1i", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1072() { + parseExpression(".1i", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1073() -{ - parseExpression("1.i", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1073() { + parseExpression("1.i", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1074() -{ - parseExpression("1.2i", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1074() { + parseExpression("1.2i", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1075() -{ - parseExpression("1.2e3i", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1075() { + parseExpression("1.2e3i", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1076() -{ - parseExpression("1uli", - Expectation().AST( { ImaginaryIntegerConstantExpression })); +void ParserTester::case1076() { + parseExpression("1uli", + Expectation().AST({ImaginaryIntegerConstantExpression})); } -void ParserTester::case1077() -{ - parseExpression("1j", - Expectation().AST( { ImaginaryIntegerConstantExpression })); +void ParserTester::case1077() { + parseExpression("1j", + Expectation().AST({ImaginaryIntegerConstantExpression})); } -void ParserTester::case1078() -{ - parseExpression(".1j", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1078() { + parseExpression(".1j", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1079() -{ - parseExpression("1.j", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1079() { + parseExpression("1.j", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1080() -{ - parseExpression("1.2j", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1080() { + parseExpression("1.2j", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1081() -{ - parseExpression("1.2e3j", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1081() { + parseExpression("1.2e3j", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1082() -{ - parseExpression("1ulj", - Expectation().AST( { ImaginaryIntegerConstantExpression })); +void ParserTester::case1082() { + parseExpression("1ulj", + Expectation().AST({ImaginaryIntegerConstantExpression})); } -void ParserTester::case1083() -{ - parseExpression("1iu", - Expectation().AST( { ImaginaryIntegerConstantExpression })); +void ParserTester::case1083() { + parseExpression("1iu", + Expectation().AST({ImaginaryIntegerConstantExpression})); } -void ParserTester::case1084() -{ - parseExpression("1ju", - Expectation().AST( { ImaginaryIntegerConstantExpression })); +void ParserTester::case1084() { + parseExpression("1ju", + Expectation().AST({ImaginaryIntegerConstantExpression})); } -void ParserTester::case1085() -{ - parseExpression("1.2if", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1085() { + parseExpression("1.2if", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1086() -{ - parseExpression("1.2jf", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1086() { + parseExpression("1.2jf", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1087() -{ - parseExpression("1.2e3if", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1087() { + parseExpression("1.2e3if", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1088() -{ - parseExpression("1.2e3jf", - Expectation().AST( { ImaginaryFloatingConstantExpression })); +void ParserTester::case1088() { + parseExpression("1.2e3jf", + Expectation().AST({ImaginaryFloatingConstantExpression})); } -void ParserTester::case1089() -{ - parseExpression("1ii", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1089() { + parseExpression( + "1ii", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1090() -{ - parseExpression("1jj", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1090() { + parseExpression( + "1jj", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1091() -{ - parseExpression("1ij", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1091() { + parseExpression( + "1ij", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1092() -{ - parseExpression("1ji", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1092() { + parseExpression( + "1ji", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1093() -{ - parseExpression("1uliul", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1093() { + parseExpression( + "1uliul", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1094() -{ - parseExpression("1uljul", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1094() { + parseExpression( + "1uljul", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1095() -{ - parseExpression(".1fllf", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1095() { + parseExpression( + ".1fllf", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1096() -{ - parseExpression("0.1fllf", - Expectation().diagnostic( - Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1096() { + parseExpression( + "0.1fllf", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } void ParserTester::case1097() {} void ParserTester::case1098() {} void ParserTester::case1099() {} -void ParserTester::case1100() -{ - parseExpression("( 1 )", - Expectation().AST( { ParenthesizedExpression, - IntegerConstantExpression })); +void ParserTester::case1100() { + parseExpression("( 1 )", Expectation().AST({ParenthesizedExpression, + IntegerConstantExpression})); } -void ParserTester::case1101() -{ - parseExpression("( x )", - Expectation().AST( { ParenthesizedExpression, - IdentifierName })); +void ParserTester::case1101() { + parseExpression("( x )", + Expectation().AST({ParenthesizedExpression, IdentifierName})); } -void ParserTester::case1102() -{ - parseExpression("( ( x ) )", - Expectation().AST( { ParenthesizedExpression, - ParenthesizedExpression, - IdentifierName })); +void ParserTester::case1102() { + parseExpression("( ( x ) )", + Expectation().AST({ParenthesizedExpression, + ParenthesizedExpression, IdentifierName})); } -void ParserTester::case1103() -{ - parseExpression("( 'x' )", - Expectation().AST( { ParenthesizedExpression, - CharacterConstantExpression })); +void ParserTester::case1103() { + parseExpression("( 'x' )", Expectation().AST({ParenthesizedExpression, + CharacterConstantExpression})); } -void ParserTester::case1104() -{ - parseExpression("( x", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case1104() { + parseExpression("( x", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case1105() -{ - parseExpression("( ( x )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case1105() { + parseExpression("( ( x )", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case1106() -{ - parseExpression("( int", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case1106() { + parseExpression("( int", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case1107() -{ - parseExpression("( int )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1107() { + parseExpression( + "( int )", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } void ParserTester::case1108() {} @@ -804,17 +646,15 @@ void ParserTester::case1197() {} void ParserTester::case1198() {} void ParserTester::case1199() {} -void ParserTester::case1200() -{ - parseExpression(R"( +void ParserTester::case1200() { + parseExpression(R"( _Generic( x, default: cbrt) )"); } -void ParserTester::case1201() -{ - parseExpression(R"( +void ParserTester::case1201() { + parseExpression(R"( _Generic( x, long double: cbrtl, default: cbrt, @@ -822,56 +662,54 @@ void ParserTester::case1201() )"); } -void ParserTester::case1202() -{ - parseExpression(R"( +void ParserTester::case1202() { + parseExpression(R"( _Generic( x, float: cbrtf) )"); } -void ParserTester::case1203() -{ - parseExpression(R"( +void ParserTester::case1203() { + parseExpression(R"( _Generic( ( x ), long double: cbrtl, default: cbrt) )"); } -void ParserTester::case1204() -{ - parseExpression(R"( +void ParserTester::case1204() { + parseExpression(R"( _Generic( x float: cbrtf) )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case1205() -{ - parseExpression("_Generic( x, float, cbrtf)", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case1205() { + parseExpression("_Generic( x, float, cbrtf)", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case1206() -{ - parseExpression("_Generic( x : cbrtf)", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case1206() { + parseExpression("_Generic( x : cbrtf)", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case1207() -{ - parseExpression("_Generic(float: cbrtf)", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1207() { + parseExpression( + "_Generic(float: cbrtf)", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1208() -{ - parseExpression(R"( +void ParserTester::case1208() { + parseExpression(R"( _Generic( x, int: y, char*: z, @@ -879,30 +717,27 @@ void ParserTester::case1208() )"); } -void ParserTester::case1209() -{ - parseExpression(R"( +void ParserTester::case1209() { + parseExpression(R"( _Generic( x, default: cbrt )", - Expectation().setErrorCnt(1)); + Expectation().setErrorCnt(1)); } -void ParserTester::case1210() -{ - parseExpression(R"( +void ParserTester::case1210() { + parseExpression(R"( _Generic( x, default: )", - Expectation().setErrorCnt(1)); + Expectation().setErrorCnt(1)); } -void ParserTester::case1211() -{ - parseExpression(R"( +void ParserTester::case1211() { + parseExpression(R"( _Generic( ( x ), int : 1,) )", - Expectation().setErrorCnt(1)); + Expectation().setErrorCnt(1)); } void ParserTester::case1212() {} @@ -944,80 +779,67 @@ void ParserTester::case1247() {} void ParserTester::case1248() {} void ParserTester::case1249() {} -void ParserTester::case1250() -{ - parseExpression("( struct x ) { y++ }", - Expectation().AST( { CompoundLiteralExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - PostIncrementExpression, - IdentifierName })); +void ParserTester::case1250() { + parseExpression( + "( struct x ) { y++ }", + Expectation().AST({CompoundLiteralExpression, TypeName, + StructTypeSpecifier, AbstractDeclarator, + BraceEnclosedInitializer, ExpressionInitializer, + PostIncrementExpression, IdentifierName})); } -void ParserTester::case1251() -{ - parseExpression("( int ) { 1 }", - Expectation().AST( { CompoundLiteralExpression, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression })); +void ParserTester::case1251() { + parseExpression( + "( int ) { 1 }", + Expectation().AST({CompoundLiteralExpression, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator, + BraceEnclosedInitializer, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case1252() -{ - parseExpression("( x ) { 1, 2 }", - Expectation().AST( { CompoundLiteralExpression, - TypeName, - TypedefName, - AbstractDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression, - ExpressionInitializer, - IntegerConstantExpression })); +void ParserTester::case1252() { + parseExpression( + "( x ) { 1, 2 }", + Expectation().AST({CompoundLiteralExpression, TypeName, TypedefName, + AbstractDeclarator, BraceEnclosedInitializer, + ExpressionInitializer, IntegerConstantExpression, + ExpressionInitializer, IntegerConstantExpression})); } -void ParserTester::case1253() -{ - parseExpression("( struct x ) {", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1253() { + parseExpression( + "( struct x ) {", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1254() -{ - parseExpression("( struct x ) { 1,", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1254() { + parseExpression( + "( struct x ) { 1,", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1255() -{ - parseExpression("( struct x ) { 1", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case1255() { + parseExpression("( struct x ) { 1", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case1256() -{ - parseExpression("( long ) {", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1256() { + parseExpression( + "( long ) {", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case1257() -{ -} +void ParserTester::case1257() {} -void ParserTester::case1258() -{ -} +void ParserTester::case1258() {} void ParserTester::case1259() {} void ParserTester::case1260() {} @@ -1061,73 +883,58 @@ void ParserTester::case1297() {} void ParserTester::case1298() {} void ParserTester::case1299() {} -void ParserTester::case1300() -{ - parseExpression("++x", - Expectation().AST({ PreIncrementExpression, - IdentifierName })); +void ParserTester::case1300() { + parseExpression("++x", + Expectation().AST({PreIncrementExpression, IdentifierName})); } -void ParserTester::case1301() -{ - parseExpression("--x", - Expectation().AST({ PreDecrementExpression, - IdentifierName }));; +void ParserTester::case1301() { + parseExpression("--x", + Expectation().AST({PreDecrementExpression, IdentifierName})); + ; } -void ParserTester::case1302() -{ - parseExpression("x++", - Expectation().AST({ PostIncrementExpression, - IdentifierName })); +void ParserTester::case1302() { + parseExpression("x++", + Expectation().AST({PostIncrementExpression, IdentifierName})); } -void ParserTester::case1303() -{ - parseExpression("x--", - Expectation().AST({ PostDecrementExpression, - IdentifierName })); +void ParserTester::case1303() { + parseExpression("x--", + Expectation().AST({PostDecrementExpression, IdentifierName})); } -void ParserTester::case1304() -{ - parseExpression("++( x )", - Expectation().AST({ PreIncrementExpression, - ParenthesizedExpression, - IdentifierName })); +void ParserTester::case1304() { + parseExpression("++( x )", + Expectation().AST({PreIncrementExpression, + ParenthesizedExpression, IdentifierName})); } -void ParserTester::case1305() -{ - parseExpression("++( ( x ))", - Expectation().AST({ PreIncrementExpression, - ParenthesizedExpression, - ParenthesizedExpression, - IdentifierName })); +void ParserTester::case1305() { + parseExpression( + "++( ( x ))", + Expectation().AST({PreIncrementExpression, ParenthesizedExpression, + ParenthesizedExpression, IdentifierName})); } -void ParserTester::case1306() -{ - parseExpression("( x )++", - Expectation().AST({ PostIncrementExpression, - ParenthesizedExpression, - IdentifierName })); +void ParserTester::case1306() { + parseExpression("( x )++", + Expectation().AST({PostIncrementExpression, + ParenthesizedExpression, IdentifierName})); } -void ParserTester::case1307() -{ - parseExpression("( ( x ))++", - Expectation().AST({ PostIncrementExpression, - ParenthesizedExpression, - ParenthesizedExpression, - IdentifierName })); +void ParserTester::case1307() { + parseExpression( + "( ( x ))++", + Expectation().AST({PostIncrementExpression, ParenthesizedExpression, + ParenthesizedExpression, IdentifierName})); } -void ParserTester::case1308() -{ - parseExpression("x +", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case1308() { + parseExpression( + "x +", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } void ParserTester::case1309() {} @@ -1172,39 +979,29 @@ void ParserTester::case1347() {} void ParserTester::case1348() {} void ParserTester::case1349() {} -void ParserTester::case1350() -{ - parseExpression("-1", - Expectation().AST( { UnaryMinusExpression, - IntegerConstantExpression })); +void ParserTester::case1350() { + parseExpression("-1", Expectation().AST( + {UnaryMinusExpression, IntegerConstantExpression})); } -void ParserTester::case1351() -{ - parseExpression("+1", - Expectation().AST( { UnaryPlusExpression, - IntegerConstantExpression })); +void ParserTester::case1351() { + parseExpression("+1", Expectation().AST( + {UnaryPlusExpression, IntegerConstantExpression})); } -void ParserTester::case1352() -{ - parseExpression("-1.2", - Expectation().AST( { UnaryMinusExpression, - FloatingConstantExpression })); +void ParserTester::case1352() { + parseExpression("-1.2", Expectation().AST({UnaryMinusExpression, + FloatingConstantExpression})); } -void ParserTester::case1353() -{ - parseExpression("-.1", - Expectation().AST( { UnaryMinusExpression, - FloatingConstantExpression })); +void ParserTester::case1353() { + parseExpression("-.1", Expectation().AST({UnaryMinusExpression, + FloatingConstantExpression})); } -void ParserTester::case1354() -{ - parseExpression("-1.2e3", - Expectation().AST( { UnaryMinusExpression, - FloatingConstantExpression })); +void ParserTester::case1354() { + parseExpression("-1.2e3", Expectation().AST({UnaryMinusExpression, + FloatingConstantExpression})); } void ParserTester::case1355() {} @@ -1253,170 +1050,114 @@ void ParserTester::case1397() {} void ParserTester::case1398() {} void ParserTester::case1399() {} -void ParserTester::case1400() -{ - parseExpression("sizeof x", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - IdentifierName })); -} - -void ParserTester::case1401() -{ - parseExpression("sizeof ( x )", - Expectation().AST( { SizeofExpression, - AmbiguousTypeNameOrExpressionAsTypeReference, - ExpressionAsTypeReference, - ParenthesizedExpression, - IdentifierName, - TypeNameAsTypeReference, - TypeName, - TypedefName }) - .ambiguity("sizeof ( x ) ( x )")); -} - -void ParserTester::case1402() -{ - parseExpression("sizeof ( const x )", - Expectation().AST( { SizeofExpression, - TypeNameAsTypeReference, - TypeName, - ConstQualifier, - TypedefName, - AbstractDeclarator })); -} - -void ParserTester::case1403() -{ - parseExpression("sizeof ( x * )", - Expectation().AST( { SizeofExpression, - TypeNameAsTypeReference, - TypeName, - TypedefName, - PointerDeclarator, - AbstractDeclarator })); -} - -void ParserTester::case1404() -{ - parseExpression("sizeof int", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); -} - -void ParserTester::case1405() -{ - parseExpression("sizeof * x", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - PointerIndirectionExpression, - IdentifierName })); -} - -void ParserTester::case1406() -{ - parseExpression("sizeof x [ 0 ]", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - ElementAccessExpression, - IdentifierName, - IntegerConstantExpression })); -} - -void ParserTester::case1407() -{ - parseExpression("sizeof ( int )", - Expectation().AST( { SizeofExpression, - TypeNameAsTypeReference, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator - })); -} - -void ParserTester::case1408() -{ - parseExpression("sizeof ( int * )", - Expectation().AST( { SizeofExpression, - TypeNameAsTypeReference, - TypeName, - BuiltinTypeSpecifier, - PointerDeclarator, - AbstractDeclarator })); -} - -void ParserTester::case1409() -{ - parseExpression("sizeof x . y", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - DirectMemberAccessExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1410() -{ - parseExpression("sizeof ( x . y )"); -} - -void ParserTester::case1411() -{ - parseExpression("sizeof x [ 0 ]"); -} - -void ParserTester::case1412() -{ - parseExpression("sizeof ( x [ 0 ] )"); -} - -void ParserTester::case1413() -{ - parseExpression("sizeof ( x + 1 )"); -} - -void ParserTester::case1414() -{ - parseExpression("sizeof ( int ) { 1 , 2 } ", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - CompoundLiteralExpression, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression, - ExpressionInitializer, - IntegerConstantExpression })); -} - -void ParserTester::case1415() -{ - parseExpression("sizeof ( x ) { 1 , 2 } ", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - CompoundLiteralExpression, - TypeName, - TypedefName, - AbstractDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression, - ExpressionInitializer, - IntegerConstantExpression })); -} - -void ParserTester::case1416() -{ - parseExpression("sizeof ( _Atomic ( int ) )"); +void ParserTester::case1400() { + parseExpression("sizeof x", Expectation().AST({SizeofExpression, + ExpressionAsTypeReference, + IdentifierName})); +} + +void ParserTester::case1401() { + parseExpression( + "sizeof ( x )", + Expectation() + .AST({SizeofExpression, AmbiguousTypeNameOrExpressionAsTypeReference, + ExpressionAsTypeReference, ParenthesizedExpression, + IdentifierName, TypeNameAsTypeReference, TypeName, TypedefName}) + .ambiguity("sizeof ( x ) ( x )")); +} + +void ParserTester::case1402() { + parseExpression( + "sizeof ( const x )", + Expectation().AST({SizeofExpression, TypeNameAsTypeReference, TypeName, + ConstQualifier, TypedefName, AbstractDeclarator})); +} + +void ParserTester::case1403() { + parseExpression( + "sizeof ( x * )", + Expectation().AST({SizeofExpression, TypeNameAsTypeReference, TypeName, + TypedefName, PointerDeclarator, AbstractDeclarator})); +} + +void ParserTester::case1404() { + parseExpression( + "sizeof int", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +} + +void ParserTester::case1405() { + parseExpression( + "sizeof * x", + Expectation().AST({SizeofExpression, ExpressionAsTypeReference, + PointerIndirectionExpression, IdentifierName})); +} + +void ParserTester::case1406() { + parseExpression( + "sizeof x [ 0 ]", + Expectation().AST({SizeofExpression, ExpressionAsTypeReference, + ElementAccessExpression, IdentifierName, + IntegerConstantExpression})); +} + +void ParserTester::case1407() { + parseExpression( + "sizeof ( int )", + Expectation().AST({SizeofExpression, TypeNameAsTypeReference, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator})); +} + +void ParserTester::case1408() { + parseExpression("sizeof ( int * )", + Expectation().AST({SizeofExpression, TypeNameAsTypeReference, + TypeName, BuiltinTypeSpecifier, + PointerDeclarator, AbstractDeclarator})); +} + +void ParserTester::case1409() { + parseExpression( + "sizeof x . y", + Expectation().AST({SizeofExpression, ExpressionAsTypeReference, + DirectMemberAccessExpression, IdentifierName, + IdentifierName})); +} + +void ParserTester::case1410() { parseExpression("sizeof ( x . y )"); } + +void ParserTester::case1411() { parseExpression("sizeof x [ 0 ]"); } + +void ParserTester::case1412() { parseExpression("sizeof ( x [ 0 ] )"); } + +void ParserTester::case1413() { parseExpression("sizeof ( x + 1 )"); } + +void ParserTester::case1414() { + parseExpression( + "sizeof ( int ) { 1 , 2 } ", + Expectation().AST({SizeofExpression, ExpressionAsTypeReference, + CompoundLiteralExpression, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator, + BraceEnclosedInitializer, ExpressionInitializer, + IntegerConstantExpression, ExpressionInitializer, + IntegerConstantExpression})); } -void ParserTester::case1417() -{ - parseExpression("sizeof ( _Atomic ( x ) )"); +void ParserTester::case1415() { + parseExpression( + "sizeof ( x ) { 1 , 2 } ", + Expectation().AST({SizeofExpression, ExpressionAsTypeReference, + CompoundLiteralExpression, TypeName, TypedefName, + AbstractDeclarator, BraceEnclosedInitializer, + ExpressionInitializer, IntegerConstantExpression, + ExpressionInitializer, IntegerConstantExpression})); } +void ParserTester::case1416() { parseExpression("sizeof ( _Atomic ( int ) )"); } + +void ParserTester::case1417() { parseExpression("sizeof ( _Atomic ( x ) )"); } + void ParserTester::case1418() {} void ParserTester::case1419() {} void ParserTester::case1420() {} @@ -1450,66 +1191,45 @@ void ParserTester::case1447() {} void ParserTester::case1448() {} void ParserTester::case1449() {} -void ParserTester::case1450() -{ - parseExpression("_Alignof ( x )", - Expectation().AST( { AlignofExpression, - AmbiguousTypeNameOrExpressionAsTypeReference, - ExpressionAsTypeReference, - ParenthesizedExpression, - IdentifierName, - TypeNameAsTypeReference, - TypeName, - TypedefName }) - .ambiguity("_Alignof ( x ) ( x )")); +void ParserTester::case1450() { + parseExpression( + "_Alignof ( x )", + Expectation() + .AST({AlignofExpression, AmbiguousTypeNameOrExpressionAsTypeReference, + ExpressionAsTypeReference, ParenthesizedExpression, + IdentifierName, TypeNameAsTypeReference, TypeName, TypedefName}) + .ambiguity("_Alignof ( x ) ( x )")); } -void ParserTester::case1451() -{ - parseExpression("_Alignof ( int )", - Expectation().AST( { AlignofExpression, - TypeNameAsTypeReference, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator })); +void ParserTester::case1451() { + parseExpression( + "_Alignof ( int )", + Expectation().AST({AlignofExpression, TypeNameAsTypeReference, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator})); } -void ParserTester::case1452() -{ - parseExpression("_Alignof ( int * )", - Expectation().AST( { AlignofExpression, - TypeNameAsTypeReference, - TypeName, - BuiltinTypeSpecifier, - PointerDeclarator, - AbstractDeclarator })); +void ParserTester::case1452() { + parseExpression("_Alignof ( int * )", + Expectation().AST({AlignofExpression, TypeNameAsTypeReference, + TypeName, BuiltinTypeSpecifier, + PointerDeclarator, AbstractDeclarator})); } -void ParserTester::case1453() -{ - // See LanguageExtensions. +void ParserTester::case1453() { + // See LanguageExtensions. - parseExpression("_Alignof x", - Expectation().AST( { AlignofExpression, - ExpressionAsTypeReference, - IdentifierName })); + parseExpression("_Alignof x", Expectation().AST({AlignofExpression, + ExpressionAsTypeReference, + IdentifierName})); } -void ParserTester::case1454() -{ -} +void ParserTester::case1454() {} -void ParserTester::case1455() -{ -} +void ParserTester::case1455() {} -void ParserTester::case1456() -{ -} +void ParserTester::case1456() {} -void ParserTester::case1457() -{ -} +void ParserTester::case1457() {} void ParserTester::case1458() {} void ParserTester::case1459() {} @@ -1554,152 +1274,118 @@ void ParserTester::case1497() {} void ParserTester::case1498() {} void ParserTester::case1499() {} -void ParserTester::case1500() -{ - parseExpression("x . y", - Expectation().AST( { DirectMemberAccessExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1501() -{ - parseExpression("x .", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFieldName)); -} - -void ParserTester::case1502() -{ - parseExpression("x . 'y'", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFieldName)); -} - -void ParserTester::case1503() -{ - parseExpression("x ( ) . y", - Expectation().AST( { DirectMemberAccessExpression, - CallExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1504() -{ - parseExpression("x -> y", - Expectation().AST( { IndirectMemberAccessExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1505() -{ - parseExpression("x -> ", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFieldName)); -} - -void ParserTester::case1506() -{ - parseExpression("x -> 'y'", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFieldName)); -} - -void ParserTester::case1507() -{ - parseExpression("x . y . z", - Expectation().AST( { DirectMemberAccessExpression, - DirectMemberAccessExpression, - IdentifierName, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1508() -{ - parseExpression("x . y -> z", - Expectation().AST( { IndirectMemberAccessExpression, - DirectMemberAccessExpression, - IdentifierName, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1509() -{ - parseExpression("x -> y -> z", - Expectation().AST( { IndirectMemberAccessExpression, - IndirectMemberAccessExpression, - IdentifierName, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1510() -{ - parseExpression("( x . y ) -> z", - Expectation().AST( { IndirectMemberAccessExpression, - ParenthesizedExpression, - DirectMemberAccessExpression, - IdentifierName, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1511() -{ - parseExpression("x . y . z . w", - Expectation().AST( { DirectMemberAccessExpression, - DirectMemberAccessExpression, - DirectMemberAccessExpression, - IdentifierName, - IdentifierName, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1512() -{ - parseExpression("x [ 0 ] . y", - Expectation().AST( { DirectMemberAccessExpression, - ElementAccessExpression, - IdentifierName, - IntegerConstantExpression, - IdentifierName })); - -} - -void ParserTester::case1513() -{ - parseExpression("( struct x ) { . y = 1 } . z", - Expectation().AST( { DirectMemberAccessExpression, - CompoundLiteralExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - BraceEnclosedInitializer, - DesignatedInitializer, - FieldDesignator, - ExpressionInitializer, - IntegerConstantExpression, - IdentifierName })); - -} - -void ParserTester::case1514() -{ - parseExpression("( struct x ) { 1 } . z", - Expectation().AST( { DirectMemberAccessExpression, - CompoundLiteralExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - BraceEnclosedInitializer, - ExpressionInitializer, - IntegerConstantExpression, - IdentifierName })); +void ParserTester::case1500() { + parseExpression("x . y", Expectation().AST({DirectMemberAccessExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1501() { + parseExpression("x .", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFieldName)); +} + +void ParserTester::case1502() { + parseExpression("x . 'y'", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFieldName)); +} + +void ParserTester::case1503() { + parseExpression( + "x ( ) . y", + Expectation().AST({DirectMemberAccessExpression, CallExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1504() { + parseExpression("x -> y", + Expectation().AST({IndirectMemberAccessExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1505() { + parseExpression("x -> ", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFieldName)); +} + +void ParserTester::case1506() { + parseExpression("x -> 'y'", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFieldName)); +} + +void ParserTester::case1507() { + parseExpression( + "x . y . z", + Expectation().AST({DirectMemberAccessExpression, + DirectMemberAccessExpression, IdentifierName, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1508() { + parseExpression( + "x . y -> z", + Expectation().AST({IndirectMemberAccessExpression, + DirectMemberAccessExpression, IdentifierName, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1509() { + parseExpression( + "x -> y -> z", + Expectation().AST({IndirectMemberAccessExpression, + IndirectMemberAccessExpression, IdentifierName, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1510() { + parseExpression( + "( x . y ) -> z", + Expectation().AST({IndirectMemberAccessExpression, + ParenthesizedExpression, DirectMemberAccessExpression, + IdentifierName, IdentifierName, IdentifierName})); +} + +void ParserTester::case1511() { + parseExpression( + "x . y . z . w", + Expectation().AST({DirectMemberAccessExpression, + DirectMemberAccessExpression, + DirectMemberAccessExpression, IdentifierName, + IdentifierName, IdentifierName, IdentifierName})); +} + +void ParserTester::case1512() { + parseExpression( + "x [ 0 ] . y", + Expectation().AST({DirectMemberAccessExpression, ElementAccessExpression, + IdentifierName, IntegerConstantExpression, + IdentifierName})); +} + +void ParserTester::case1513() { + parseExpression( + "( struct x ) { . y = 1 } . z", + Expectation().AST( + {DirectMemberAccessExpression, CompoundLiteralExpression, TypeName, + StructTypeSpecifier, AbstractDeclarator, BraceEnclosedInitializer, + DesignatedInitializer, FieldDesignator, ExpressionInitializer, + IntegerConstantExpression, IdentifierName})); +} + +void ParserTester::case1514() { + parseExpression( + "( struct x ) { 1 } . z", + Expectation().AST( + {DirectMemberAccessExpression, CompoundLiteralExpression, TypeName, + StructTypeSpecifier, AbstractDeclarator, BraceEnclosedInitializer, + ExpressionInitializer, IntegerConstantExpression, IdentifierName})); } void ParserTester::case1515() {} @@ -1788,158 +1474,122 @@ void ParserTester::case1597() {} void ParserTester::case1598() {} void ParserTester::case1599() {} -void ParserTester::case1600() -{ - parseExpression("x ( )", - Expectation().AST( { CallExpression, - IdentifierName })); -} - -void ParserTester::case1601() -{ - parseExpression("( x ) ( )", - Expectation().AST( { CallExpression, - ParenthesizedExpression, - IdentifierName })); -} - -void ParserTester::case1602() -{ - parseExpression("x ( 1 )", - Expectation().AST( { CallExpression, - IdentifierName, - IntegerConstantExpression })); -} - -void ParserTester::case1603() -{ - parseExpression("x ( y )", - Expectation().AST( { CallExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1604() -{ - parseExpression("x ( y , 1 )", - Expectation().AST( { CallExpression, - IdentifierName, - IdentifierName, - IntegerConstantExpression })); -} - -void ParserTester::case1605() -{ - parseExpression("( & x ) ( )", - Expectation().AST( { CallExpression, - ParenthesizedExpression, - AddressOfExpression, - IdentifierName })); -} - -void ParserTester::case1606() -{ - parseExpression("( * x ) ( )", - Expectation().AST( { CallExpression, - ParenthesizedExpression, - PointerIndirectionExpression, - IdentifierName })); -} - -void ParserTester::case1607() -{ - parseExpression("( * * x ) ( )", - Expectation().AST( { CallExpression, - ParenthesizedExpression, - PointerIndirectionExpression, - PointerIndirectionExpression, - IdentifierName })); -} - -void ParserTester::case1608() -{ - parseExpression("x ( y ( ), \"z\" )", - Expectation().AST( { CallExpression, - IdentifierName, - CallExpression, - IdentifierName, - StringLiteralExpression })); -} - -void ParserTester::case1609() -{ - parseExpression("x ( y", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); -} - -void ParserTester::case1610() -{ - parseExpression("x (", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); -} - -void ParserTester::case1611() -{ - parseExpression("x ( y , )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); -} - -void ParserTester::case1612() -{ - parseExpression("x ( ( 1 ) )", - Expectation().AST( { CallExpression, - IdentifierName, - ParenthesizedExpression, - IntegerConstantExpression })); -} - -void ParserTester::case1613() -{ - parseExpression("x ( ( ( y ) ) )", - Expectation().AST( { CallExpression, - IdentifierName, - ParenthesizedExpression, - ParenthesizedExpression, - IdentifierName })); -} - -void ParserTester::case1614() -{ - parseExpression("( x ( ) )", - Expectation().AST( { ParenthesizedExpression, - CallExpression, - IdentifierName })); -} - -void ParserTester::case1615() -{ - parseExpression("( ( x ( ) ) )", - Expectation().AST( { ParenthesizedExpression, - ParenthesizedExpression, - CallExpression, - IdentifierName })); -} - -void ParserTester::case1616() -{ - parseExpression("( x ( 1 ) )", - Expectation().AST( { ParenthesizedExpression, - CallExpression, - IdentifierName, - IntegerConstantExpression })); -} - -void ParserTester::case1617() -{ - parseExpression("( x ( 1 , y ) )", - Expectation().AST( { ParenthesizedExpression, - CallExpression, - IdentifierName, - IntegerConstantExpression, - IdentifierName })); +void ParserTester::case1600() { + parseExpression("x ( )", Expectation().AST({CallExpression, IdentifierName})); +} + +void ParserTester::case1601() { + parseExpression("( x ) ( )", + Expectation().AST({CallExpression, ParenthesizedExpression, + IdentifierName})); +} + +void ParserTester::case1602() { + parseExpression("x ( 1 )", Expectation().AST({CallExpression, IdentifierName, + IntegerConstantExpression})); +} + +void ParserTester::case1603() { + parseExpression("x ( y )", Expectation().AST({CallExpression, IdentifierName, + IdentifierName})); +} + +void ParserTester::case1604() { + parseExpression( + "x ( y , 1 )", + Expectation().AST({CallExpression, IdentifierName, IdentifierName, + IntegerConstantExpression})); +} + +void ParserTester::case1605() { + parseExpression("( & x ) ( )", + Expectation().AST({CallExpression, ParenthesizedExpression, + AddressOfExpression, IdentifierName})); +} + +void ParserTester::case1606() { + parseExpression( + "( * x ) ( )", + Expectation().AST({CallExpression, ParenthesizedExpression, + PointerIndirectionExpression, IdentifierName})); +} + +void ParserTester::case1607() { + parseExpression( + "( * * x ) ( )", + Expectation().AST({CallExpression, ParenthesizedExpression, + PointerIndirectionExpression, + PointerIndirectionExpression, IdentifierName})); +} + +void ParserTester::case1608() { + parseExpression( + "x ( y ( ), \"z\" )", + Expectation().AST({CallExpression, IdentifierName, CallExpression, + IdentifierName, StringLiteralExpression})); +} + +void ParserTester::case1609() { + parseExpression("x ( y", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +} + +void ParserTester::case1610() { + parseExpression( + "x (", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +} + +void ParserTester::case1611() { + parseExpression( + "x ( y , )", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +} + +void ParserTester::case1612() { + parseExpression( + "x ( ( 1 ) )", + Expectation().AST({CallExpression, IdentifierName, + ParenthesizedExpression, IntegerConstantExpression})); +} + +void ParserTester::case1613() { + parseExpression("x ( ( ( y ) ) )", + Expectation().AST({CallExpression, IdentifierName, + ParenthesizedExpression, + ParenthesizedExpression, IdentifierName})); +} + +void ParserTester::case1614() { + parseExpression("( x ( ) )", + Expectation().AST({ParenthesizedExpression, CallExpression, + IdentifierName})); +} + +void ParserTester::case1615() { + parseExpression( + "( ( x ( ) ) )", + Expectation().AST({ParenthesizedExpression, ParenthesizedExpression, + CallExpression, IdentifierName})); +} + +void ParserTester::case1616() { + parseExpression( + "( x ( 1 ) )", + Expectation().AST({ParenthesizedExpression, CallExpression, + IdentifierName, IntegerConstantExpression})); +} + +void ParserTester::case1617() { + parseExpression("( x ( 1 , y ) )", + Expectation().AST({ParenthesizedExpression, CallExpression, + IdentifierName, IntegerConstantExpression, + IdentifierName})); } void ParserTester::case1618() {} @@ -1975,48 +1625,38 @@ void ParserTester::case1647() {} void ParserTester::case1648() {} void ParserTester::case1649() {} -void ParserTester::case1650() -{ - parseExpression("* x", - Expectation().AST( { PointerIndirectionExpression, - IdentifierName })); +void ParserTester::case1650() { + parseExpression( + "* x", Expectation().AST({PointerIndirectionExpression, IdentifierName})); } -void ParserTester::case1651() -{ - parseExpression("* ( x )", - Expectation().AST( { PointerIndirectionExpression, - ParenthesizedExpression, - IdentifierName })); +void ParserTester::case1651() { + parseExpression("* ( x )", + Expectation().AST({PointerIndirectionExpression, + ParenthesizedExpression, IdentifierName})); } -void ParserTester::case1652() -{ - parseExpression("& x", - Expectation().AST( { AddressOfExpression, - IdentifierName })); +void ParserTester::case1652() { + parseExpression("& x", + Expectation().AST({AddressOfExpression, IdentifierName})); } -void ParserTester::case1653() -{ - // Syntax OK, semantics invalid. +void ParserTester::case1653() { + // Syntax OK, semantics invalid. - CROSS_REFERENCE_TEST(BinderTester::case0101); + CROSS_REFERENCE_TEST(BinderTester::case0101); - parseExpression("* 1", - Expectation().AST( { PointerIndirectionExpression, - IntegerConstantExpression })); + parseExpression("* 1", Expectation().AST({PointerIndirectionExpression, + IntegerConstantExpression})); } -void ParserTester::case1654() -{ - // Syntax OK, semantics invalid. +void ParserTester::case1654() { + // Syntax OK, semantics invalid. - CROSS_REFERENCE_TEST(BinderTester::case0102); + CROSS_REFERENCE_TEST(BinderTester::case0102); - parseExpression("& 1", - Expectation().AST( { AddressOfExpression, - IntegerConstantExpression })); + parseExpression("& 1", Expectation().AST( + {AddressOfExpression, IntegerConstantExpression})); } void ParserTester::case1655() {} @@ -2065,223 +1705,146 @@ void ParserTester::case1697() {} void ParserTester::case1698() {} void ParserTester::case1699() {} -void ParserTester::case1700() -{ - parseExpression("( int ) x", - Expectation().AST({ CastExpression, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - IdentifierName })); -} - -void ParserTester::case1701() -{ - parseExpression("( int * ) x", - Expectation().AST({ CastExpression, - TypeName, - BuiltinTypeSpecifier, - PointerDeclarator, - AbstractDeclarator, - IdentifierName })); -} - -void ParserTester::case1702() -{ - parseExpression("( int const * ) x", - Expectation().AST({ CastExpression, - TypeName, - BuiltinTypeSpecifier, - ConstQualifier, - PointerDeclarator, - AbstractDeclarator, - IdentifierName })); -} - -void ParserTester::case1703() -{ - parseExpression("( struct x ) y", - Expectation().AST({ CastExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - IdentifierName })); -} - -void ParserTester::case1704() -{ - parseExpression("( unsigned long ) + x", - Expectation().AST({ CastExpression, - TypeName, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - AbstractDeclarator, - UnaryPlusExpression, - IdentifierName })); -} - -void ParserTester::case1705() -{ - parseExpression("( unsigned long ) - x", - Expectation().AST({ CastExpression, - TypeName, - BuiltinTypeSpecifier, - BuiltinTypeSpecifier, - AbstractDeclarator, - UnaryMinusExpression, - IdentifierName })); -} - -void ParserTester::case1706() -{ - parseExpression("( int ) ++ x", - Expectation().AST({ CastExpression, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - PreIncrementExpression, - IdentifierName })); -} - -void ParserTester::case1707() -{ - parseExpression("( int ) x ++", - Expectation().AST({ CastExpression, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - PostIncrementExpression, - IdentifierName })); -} - -void ParserTester::case1708() -{ - parseExpression("( int ) _Generic ( y", - Expectation().setErrorCnt(1)); -} - -void ParserTester::case1709() -{ - parseExpression("( long ) int", - Expectation().setErrorCnt(1)); -} - -void ParserTester::case1710() -{ - parseExpression("( struct x ) -", - Expectation().setErrorCnt(1)); -} - -void ParserTester::case1711() -{ - parseExpression("( int ) -", - Expectation().setErrorCnt(1)); -} - -void ParserTester::case1712() -{ - parseExpression("( int ) x +", - Expectation().setErrorCnt(1)); -} - -void ParserTester::case1713() -{ - parseExpression("( int ) x ( y", - Expectation().setErrorCnt(1)); -} - -void ParserTester::case1714() -{ - parseExpression("( x ) y ( z )", - Expectation().AST({ CastExpression, - TypeName, - TypedefName, - AbstractDeclarator, - CallExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1715() -{ - parseExpression("( x ) ( y ( z ) )", - Expectation().AST({ CastExpression, - TypeName, - TypedefName, - AbstractDeclarator, - ParenthesizedExpression, - CallExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1716() -{ - parseExpression("( int ) - 1", - Expectation().AST( { CastExpression, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - UnaryMinusExpression, - IntegerConstantExpression })); -} - -void ParserTester::case1717() -{ - parseExpression("( x ) - 1", - Expectation().ambiguity() - .AST( { AmbiguousCastOrBinaryExpression, - CastExpression, - TypeName, - TypedefName, - AbstractDeclarator, - UnaryMinusExpression, - IntegerConstantExpression, - SubstractExpression, - ParenthesizedExpression, - IdentifierName, - IntegerConstantExpression })); -} - -void ParserTester::case1718() -{ - parseExpression("( x ) + y", - Expectation().ambiguity() - .AST( { AmbiguousCastOrBinaryExpression, - CastExpression, - TypeName, - TypedefName, - AbstractDeclarator, - UnaryPlusExpression, - IdentifierName, - AddExpression, - ParenthesizedExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1719() -{ - parseExpression("( const x ) - 1", - Expectation().AST( { CastExpression, - TypeName, - ConstQualifier, - TypedefName, - AbstractDeclarator, - UnaryMinusExpression, - IntegerConstantExpression })); -} - -void ParserTester::case1720() -{ - parseExpression("( x * ) - 1", - Expectation().AST( { CastExpression, - TypeName, - TypedefName, - PointerDeclarator, - AbstractDeclarator, - UnaryMinusExpression, - IntegerConstantExpression })); +void ParserTester::case1700() { + parseExpression( + "( int ) x", + Expectation().AST({CastExpression, TypeName, BuiltinTypeSpecifier, + AbstractDeclarator, IdentifierName})); +} + +void ParserTester::case1701() { + parseExpression("( int * ) x", + Expectation().AST({CastExpression, TypeName, + BuiltinTypeSpecifier, PointerDeclarator, + AbstractDeclarator, IdentifierName})); +} + +void ParserTester::case1702() { + parseExpression( + "( int const * ) x", + Expectation().AST({CastExpression, TypeName, BuiltinTypeSpecifier, + ConstQualifier, PointerDeclarator, AbstractDeclarator, + IdentifierName})); +} + +void ParserTester::case1703() { + parseExpression( + "( struct x ) y", + Expectation().AST({CastExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, IdentifierName})); +} + +void ParserTester::case1704() { + parseExpression( + "( unsigned long ) + x", + Expectation().AST({CastExpression, TypeName, BuiltinTypeSpecifier, + BuiltinTypeSpecifier, AbstractDeclarator, + UnaryPlusExpression, IdentifierName})); +} + +void ParserTester::case1705() { + parseExpression( + "( unsigned long ) - x", + Expectation().AST({CastExpression, TypeName, BuiltinTypeSpecifier, + BuiltinTypeSpecifier, AbstractDeclarator, + UnaryMinusExpression, IdentifierName})); +} + +void ParserTester::case1706() { + parseExpression("( int ) ++ x", + Expectation().AST({CastExpression, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator, + PreIncrementExpression, IdentifierName})); +} + +void ParserTester::case1707() { + parseExpression("( int ) x ++", + Expectation().AST({CastExpression, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator, + PostIncrementExpression, IdentifierName})); +} + +void ParserTester::case1708() { + parseExpression("( int ) _Generic ( y", Expectation().setErrorCnt(1)); +} + +void ParserTester::case1709() { + parseExpression("( long ) int", Expectation().setErrorCnt(1)); +} + +void ParserTester::case1710() { + parseExpression("( struct x ) -", Expectation().setErrorCnt(1)); +} + +void ParserTester::case1711() { + parseExpression("( int ) -", Expectation().setErrorCnt(1)); +} + +void ParserTester::case1712() { + parseExpression("( int ) x +", Expectation().setErrorCnt(1)); +} + +void ParserTester::case1713() { + parseExpression("( int ) x ( y", Expectation().setErrorCnt(1)); +} + +void ParserTester::case1714() { + parseExpression("( x ) y ( z )", + Expectation().AST({CastExpression, TypeName, TypedefName, + AbstractDeclarator, CallExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1715() { + parseExpression( + "( x ) ( y ( z ) )", + Expectation().AST({CastExpression, TypeName, TypedefName, + AbstractDeclarator, ParenthesizedExpression, + CallExpression, IdentifierName, IdentifierName})); +} + +void ParserTester::case1716() { + parseExpression( + "( int ) - 1", + Expectation().AST({CastExpression, TypeName, BuiltinTypeSpecifier, + AbstractDeclarator, UnaryMinusExpression, + IntegerConstantExpression})); +} + +void ParserTester::case1717() { + parseExpression("( x ) - 1", + Expectation().ambiguity().AST( + {AmbiguousCastOrBinaryExpression, CastExpression, + TypeName, TypedefName, AbstractDeclarator, + UnaryMinusExpression, IntegerConstantExpression, + SubstractExpression, ParenthesizedExpression, + IdentifierName, IntegerConstantExpression})); +} + +void ParserTester::case1718() { + parseExpression( + "( x ) + y", + Expectation().ambiguity().AST( + {AmbiguousCastOrBinaryExpression, CastExpression, TypeName, + TypedefName, AbstractDeclarator, UnaryPlusExpression, IdentifierName, + AddExpression, ParenthesizedExpression, IdentifierName, + IdentifierName})); +} + +void ParserTester::case1719() { + parseExpression( + "( const x ) - 1", + Expectation().AST({CastExpression, TypeName, ConstQualifier, TypedefName, + AbstractDeclarator, UnaryMinusExpression, + IntegerConstantExpression})); +} + +void ParserTester::case1720() { + parseExpression( + "( x * ) - 1", + Expectation().AST({CastExpression, TypeName, TypedefName, + PointerDeclarator, AbstractDeclarator, + UnaryMinusExpression, IntegerConstantExpression})); } void ParserTester::case1721() {} void ParserTester::case1722() {} @@ -2313,40 +1876,28 @@ void ParserTester::case1747() {} void ParserTester::case1748() {} void ParserTester::case1749() {} -void ParserTester::case1750() -{ - parseExpression("x ? y : z", - Expectation().AST( { ConditionalExpression, - IdentifierName, - IdentifierName, - IdentifierName } )); - +void ParserTester::case1750() { + parseExpression("x ? y : z", + Expectation().AST({ConditionalExpression, IdentifierName, + IdentifierName, IdentifierName})); } -void ParserTester::case1751() -{ - parseExpression("x ? y + z : w", - Expectation().AST( { ConditionalExpression, - IdentifierName, - AddExpression, - IdentifierName, - IdentifierName, - IdentifierName } )); +void ParserTester::case1751() { + parseExpression( + "x ? y + z : w", + Expectation().AST({ConditionalExpression, IdentifierName, AddExpression, + IdentifierName, IdentifierName, IdentifierName})); } -void ParserTester::case1752() -{ - // See ExtGNU_Conditionals in LanguageExtensions. +void ParserTester::case1752() { + // See ExtGNU_Conditionals in LanguageExtensions. - parseExpression("x ?: z", - Expectation().AST( { ConditionalExpression, - IdentifierName, - IdentifierName } )); + parseExpression("x ?: z", + Expectation().AST( + {ConditionalExpression, IdentifierName, IdentifierName})); } -void ParserTester::case1753() -{ -} +void ParserTester::case1753() {} void ParserTester::case1754() {} void ParserTester::case1755() {} @@ -2395,150 +1946,104 @@ void ParserTester::case1797() {} void ParserTester::case1798() {} void ParserTester::case1799() {} -void ParserTester::case1800() -{ - parseExpression("x / y", - Expectation().AST( { DivideExpression, - IdentifierName, - IdentifierName } )); +void ParserTester::case1800() { + parseExpression("x / y", Expectation().AST({DivideExpression, IdentifierName, + IdentifierName})); +} + +void ParserTester::case1801() { + parseExpression( + "x << y", + Expectation().AST({LeftShiftExpression, IdentifierName, IdentifierName})); +} + +void ParserTester::case1802() { + parseExpression("x + y", Expectation().AST({AddExpression, IdentifierName, + IdentifierName})); +} + +void ParserTester::case1803() { + parseExpression( + "x || y", + Expectation().AST({LogicalORExpression, IdentifierName, IdentifierName})); +} + +void ParserTester::case1804() { + // No ambiguity here, this is an expression (not an statement). + + parseExpression("x * y", Expectation().AST({MultiplyExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1805() { + parseExpression("( x * y ) + z", + Expectation().AST({AddExpression, ParenthesizedExpression, + MultiplyExpression, IdentifierName, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1806() { + parseExpression("x * ( y + z)", + Expectation().AST({MultiplyExpression, IdentifierName, + ParenthesizedExpression, AddExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1807() { + parseExpression( + "x + y * z", + Expectation().AST({AddExpression, IdentifierName, MultiplyExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1808() { + parseExpression( + "x * y + z", + Expectation().AST({AddExpression, MultiplyExpression, IdentifierName, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1809() { + parseExpression("x , y", Expectation().AST({SequencingExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1810() { + parseExpression("x , 1, y", + Expectation().AST({SequencingExpression, SequencingExpression, + IdentifierName, IntegerConstantExpression, + IdentifierName})); } -void ParserTester::case1801() -{ - parseExpression("x << y", - Expectation().AST( { LeftShiftExpression, - IdentifierName, - IdentifierName } )); - -} +void ParserTester::case1811() { + parseExpression( + "x * y + z >> w", + Expectation().AST({RightShiftExpression, AddExpression, + MultiplyExpression, IdentifierName, IdentifierName, + IdentifierName, IdentifierName})); +} -void ParserTester::case1802() -{ - parseExpression("x + y", - Expectation().AST( { AddExpression, - IdentifierName, - IdentifierName } )); - -} - -void ParserTester::case1803() -{ - parseExpression("x || y", - Expectation().AST( { LogicalORExpression, - IdentifierName, - IdentifierName } )); -} - -void ParserTester::case1804() -{ - // No ambiguity here, this is an expression (not an statement). - - parseExpression("x * y", - Expectation().AST( { MultiplyExpression, - IdentifierName, - IdentifierName } )); - -} - -void ParserTester::case1805() -{ - parseExpression("( x * y ) + z", - Expectation().AST( { AddExpression, - ParenthesizedExpression, - MultiplyExpression, - IdentifierName, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1806() -{ - parseExpression("x * ( y + z)", - Expectation().AST( { MultiplyExpression, - IdentifierName, - ParenthesizedExpression, - AddExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1807() -{ - parseExpression("x + y * z", - Expectation().AST( { AddExpression, - IdentifierName, - MultiplyExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1808() -{ - parseExpression("x * y + z", - Expectation().AST( { AddExpression, - MultiplyExpression, - IdentifierName, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1809() -{ - parseExpression("x , y", - Expectation().AST( { SequencingExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1810() -{ - parseExpression("x , 1, y", - Expectation().AST( { SequencingExpression, - SequencingExpression, - IdentifierName, - IntegerConstantExpression, - IdentifierName })); -} - -void ParserTester::case1811() -{ - parseExpression("x * y + z >> w", - Expectation().AST( { RightShiftExpression, - AddExpression, - MultiplyExpression, - IdentifierName, - IdentifierName, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1812() -{ - parseExpression("x >> y + z * w", - Expectation().AST( { RightShiftExpression, - IdentifierName, - AddExpression, - IdentifierName, - MultiplyExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1813() -{ - /* - * Can't be parsed as an assignment-expression. - * Should only parse till `x'. - * - * (6.5.16) assignment-expression: - * conditional-expression - * unary-expression assignment-operator assignment-expression - */ - - CROSS_REFERENCE_TEST(ParserTester::case2213); - - parseExpression("x * y = z", - Expectation().unfinishedParse()); +void ParserTester::case1812() { + parseExpression( + "x >> y + z * w", + Expectation().AST({RightShiftExpression, IdentifierName, AddExpression, + IdentifierName, MultiplyExpression, IdentifierName, + IdentifierName})); +} + +void ParserTester::case1813() { + /* + * Can't be parsed as an assignment-expression. + * Should only parse till `x'. + * + * (6.5.16) assignment-expression: + * conditional-expression + * unary-expression assignment-operator assignment-expression + */ + + CROSS_REFERENCE_TEST(ParserTester::case2213); + + parseExpression("x * y = z", Expectation().unfinishedParse()); } void ParserTester::case1814() {} @@ -2578,77 +2083,54 @@ void ParserTester::case1847() {} void ParserTester::case1848() {} void ParserTester::case1849() {} -void ParserTester::case1850() -{ - parseExpression("x = y", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - IdentifierName } )); -} - -void ParserTester::case1851() -{ - parseExpression("x %= y", - Expectation().AST( { ModuloAssignmentExpression, - IdentifierName, - IdentifierName } )); -} - -void ParserTester::case1852() -{ - parseExpression("x = y = 1", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - BasicAssignmentExpression, - IdentifierName, - IntegerConstantExpression } )); - -} - -void ParserTester::case1853() -{ - parseExpression("x = ( y = 1)", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - ParenthesizedExpression, - BasicAssignmentExpression, - IdentifierName, - IntegerConstantExpression } )); -} - -void ParserTester::case1854() -{ - parseExpression("x = 0", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - IntegerConstantExpression } )); -} - -void ParserTester::case1855() -{ - parseExpression("x = ( void * ) 0", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - CastExpression, - TypeName, - BuiltinTypeSpecifier, - PointerDeclarator, - AbstractDeclarator, - IntegerConstantExpression} )); -} - -void ParserTester::case1856() -{ - parseExpression("x = ( ( void * ) 0 )", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - ParenthesizedExpression, - CastExpression, - TypeName, - BuiltinTypeSpecifier, - PointerDeclarator, - AbstractDeclarator, - IntegerConstantExpression} )); +void ParserTester::case1850() { + parseExpression("x = y", Expectation().AST({BasicAssignmentExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1851() { + parseExpression("x %= y", + Expectation().AST({ModuloAssignmentExpression, IdentifierName, + IdentifierName})); +} + +void ParserTester::case1852() { + parseExpression("x = y = 1", + Expectation().AST({BasicAssignmentExpression, IdentifierName, + BasicAssignmentExpression, IdentifierName, + IntegerConstantExpression})); +} + +void ParserTester::case1853() { + parseExpression( + "x = ( y = 1)", + Expectation().AST({BasicAssignmentExpression, IdentifierName, + ParenthesizedExpression, BasicAssignmentExpression, + IdentifierName, IntegerConstantExpression})); +} + +void ParserTester::case1854() { + parseExpression("x = 0", + Expectation().AST({BasicAssignmentExpression, IdentifierName, + IntegerConstantExpression})); +} + +void ParserTester::case1855() { + parseExpression( + "x = ( void * ) 0", + Expectation().AST({BasicAssignmentExpression, IdentifierName, + CastExpression, TypeName, BuiltinTypeSpecifier, + PointerDeclarator, AbstractDeclarator, + IntegerConstantExpression})); +} + +void ParserTester::case1856() { + parseExpression( + "x = ( ( void * ) 0 )", + Expectation().AST({BasicAssignmentExpression, IdentifierName, + ParenthesizedExpression, CastExpression, TypeName, + BuiltinTypeSpecifier, PointerDeclarator, + AbstractDeclarator, IntegerConstantExpression})); } void ParserTester::case1857() {} @@ -2695,32 +2177,28 @@ void ParserTester::case1897() {} void ParserTester::case1898() {} void ParserTester::case1899() {} -void ParserTester::case1900() -{ - // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html +void ParserTester::case1900() { + // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html - parseExpression("({ int x; })"); + parseExpression("({ int x; })"); } -void ParserTester::case1901() -{ - // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html +void ParserTester::case1901() { + // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html - parseExpression("({ int x; x; })"); + parseExpression("({ int x; x; })"); } -void ParserTester::case1902() -{ - // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html +void ParserTester::case1902() { + // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html - parseExpression("({ x y; })"); + parseExpression("({ x y; })"); } -void ParserTester::case1903() -{ - // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html +void ParserTester::case1903() { + // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html - parseExpression("({ x y; y; })"); + parseExpression("({ x y; y; })"); } void ParserTester::case1904() {} @@ -2770,24 +2248,18 @@ void ParserTester::case1947() {} void ParserTester::case1948() {} void ParserTester::case1949() {} -void ParserTester::case1950() -{ - parseExpression("__builtin_va_arg ( x , int )", - Expectation().AST( { VAArgumentExpression, - IdentifierName, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator })); +void ParserTester::case1950() { + parseExpression( + "__builtin_va_arg ( x , int )", + Expectation().AST({VAArgumentExpression, IdentifierName, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator})); } -void ParserTester::case1951() -{ - parseExpression("__builtin_va_arg ( x , y )", - Expectation().AST( { VAArgumentExpression, - IdentifierName, - TypeName, - TypedefName, - AbstractDeclarator })); +void ParserTester::case1951() { + parseExpression( + "__builtin_va_arg ( x , y )", + Expectation().AST({VAArgumentExpression, IdentifierName, TypeName, + TypedefName, AbstractDeclarator})); } void ParserTester::case1952() {} @@ -2799,60 +2271,41 @@ void ParserTester::case1957() {} void ParserTester::case1958() {} void ParserTester::case1959() {} -void ParserTester::case1960() -{ - parseExpression("__builtin_offsetof ( struct x , y )", - Expectation().AST( { OffsetOfExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator })); -} - -void ParserTester::case1961() -{ - parseExpression("__builtin_offsetof ( struct x , y . z )", - Expectation().AST( { OffsetOfExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator, - FieldDesignator })); -} - -void ParserTester::case1962() -{ - parseExpression("__builtin_offsetof ( struct x , y [ 0 ] )", - Expectation().AST( { OffsetOfExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator, - ArrayDesignator, - IntegerConstantExpression })); -} - -void ParserTester::case1963() -{ - parseExpression("__builtin_offsetof ( struct x , y [ 0 ] . z )", - Expectation().AST( { OffsetOfExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator, - ArrayDesignator, - IntegerConstantExpression, - FieldDesignator })); -} - -void ParserTester::case1964() -{ - parseExpression("__builtin_offsetof ( union x , y )", - Expectation().AST( { OffsetOfExpression, - TypeName, - UnionTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator })); +void ParserTester::case1960() { + parseExpression( + "__builtin_offsetof ( struct x , y )", + Expectation().AST({OffsetOfExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, OffsetOfDesignator})); +} + +void ParserTester::case1961() { + parseExpression("__builtin_offsetof ( struct x , y . z )", + Expectation().AST({OffsetOfExpression, TypeName, + StructTypeSpecifier, AbstractDeclarator, + OffsetOfDesignator, FieldDesignator})); +} + +void ParserTester::case1962() { + parseExpression( + "__builtin_offsetof ( struct x , y [ 0 ] )", + Expectation().AST({OffsetOfExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, OffsetOfDesignator, + ArrayDesignator, IntegerConstantExpression})); +} + +void ParserTester::case1963() { + parseExpression("__builtin_offsetof ( struct x , y [ 0 ] . z )", + Expectation().AST( + {OffsetOfExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, OffsetOfDesignator, ArrayDesignator, + IntegerConstantExpression, FieldDesignator})); +} + +void ParserTester::case1964() { + parseExpression( + "__builtin_offsetof ( union x , y )", + Expectation().AST({OffsetOfExpression, TypeName, UnionTypeSpecifier, + AbstractDeclarator, OffsetOfDesignator})); } void ParserTester::case1965() {} @@ -2861,72 +2314,48 @@ void ParserTester::case1967() {} void ParserTester::case1968() {} void ParserTester::case1969() {} -void ParserTester::case1970() -{ - parseExpression("__builtin_choose_expr ( 0 , x , y )", - Expectation().AST( { ExtGNU_ChooseExpression, - IntegerConstantExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1971() -{ - parseExpression("__builtin_choose_expr ( 1 , sizeof ( int ) , sizeof ( double ) )", - Expectation().AST( { ExtGNU_ChooseExpression, - IntegerConstantExpression, - SizeofExpression, - TypeNameAsTypeReference, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - SizeofExpression, - TypeNameAsTypeReference, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator })); -} - -void ParserTester::case1972() -{ - parseExpression(R"( +void ParserTester::case1970() { + parseExpression( + "__builtin_choose_expr ( 0 , x , y )", + Expectation().AST({ExtGNU_ChooseExpression, IntegerConstantExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1971() { + parseExpression( + "__builtin_choose_expr ( 1 , sizeof ( int ) , sizeof ( double ) )", + Expectation().AST({ExtGNU_ChooseExpression, IntegerConstantExpression, + SizeofExpression, TypeNameAsTypeReference, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator, + SizeofExpression, TypeNameAsTypeReference, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator})); +} + +void ParserTester::case1972() { + parseExpression( + R"( __builtin_choose_expr ( 0 , __builtin_choose_expr ( 1 , sizeof ( int ) , sizeof ( double ) ) , __builtin_choose_expr ( 2 , x , y ) ) )", - Expectation().AST( { ExtGNU_ChooseExpression, - IntegerConstantExpression, - ExtGNU_ChooseExpression, - IntegerConstantExpression, - SizeofExpression, - TypeNameAsTypeReference, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - SizeofExpression, - TypeNameAsTypeReference, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - ExtGNU_ChooseExpression, - IntegerConstantExpression, - IdentifierName, - IdentifierName })); -} - -void ParserTester::case1973() -{ - parseExpression("__builtin_choose_expr ( 1 , x + y , z + w )", - Expectation().AST( { ExtGNU_ChooseExpression, - IntegerConstantExpression, - AddExpression, - IdentifierName, - IdentifierName, - AddExpression, - IdentifierName, - IdentifierName })); + Expectation().AST({ExtGNU_ChooseExpression, IntegerConstantExpression, + ExtGNU_ChooseExpression, IntegerConstantExpression, + SizeofExpression, TypeNameAsTypeReference, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator, + SizeofExpression, TypeNameAsTypeReference, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator, + ExtGNU_ChooseExpression, IntegerConstantExpression, + IdentifierName, IdentifierName})); +} + +void ParserTester::case1973() { + parseExpression( + "__builtin_choose_expr ( 1 , x + y , z + w )", + Expectation().AST({ExtGNU_ChooseExpression, IntegerConstantExpression, + AddExpression, IdentifierName, IdentifierName, + AddExpression, IdentifierName, IdentifierName})); } void ParserTester::case1974() {} @@ -2936,137 +2365,103 @@ void ParserTester::case1977() {} void ParserTester::case1978() {} void ParserTester::case1979() {} -void ParserTester::case1980() -{ - parseExpression("__FUNCTION__", - Expectation().AST( { PredefinedName })); +void ParserTester::case1980() { + parseExpression("__FUNCTION__", Expectation().AST({PredefinedName})); +} + +void ParserTester::case1981() { + parseExpression("__PRETTY_FUNCTION__", Expectation().AST({PredefinedName})); +} + +void ParserTester::case1982() { + parseExpression( + "sizeof ( __FUNCTION__ )", + Expectation().AST({SizeofExpression, ExpressionAsTypeReference, + ParenthesizedExpression, PredefinedName})); +} + +void ParserTester::case1983() { + parseExpression( + "sizeof ( __PRETTY_FUNCTION__ )", + Expectation().AST({SizeofExpression, ExpressionAsTypeReference, + ParenthesizedExpression, PredefinedName})); +} + +void ParserTester::case1984() { + parseExpression( + "sizeof __FUNCTION__", + Expectation().AST( + {SizeofExpression, ExpressionAsTypeReference, PredefinedName})); +} + +void ParserTester::case1985() { + parseExpression( + "sizeof __PRETTY_FUNCTION__", + Expectation().AST( + {SizeofExpression, ExpressionAsTypeReference, PredefinedName})); +} + +void ParserTester::case1986() { + parseExpression("( __FUNCTION__ )", + Expectation().AST({ParenthesizedExpression, PredefinedName})); +} + +void ParserTester::case1987() { + parseExpression("( __PRETTY_FUNCTION__ )", + Expectation().AST({ParenthesizedExpression, PredefinedName})); +} + +void ParserTester::case1988() { + parseExpression("x = __FUNCTION__", + Expectation().AST({BasicAssignmentExpression, IdentifierName, + PredefinedName})); } -void ParserTester::case1981() -{ - parseExpression("__PRETTY_FUNCTION__", - Expectation().AST( { PredefinedName })); +void ParserTester::case1989() { + parseExpression("x = __PRETTY_FUNCTION__", + Expectation().AST({BasicAssignmentExpression, IdentifierName, + PredefinedName})); } -void ParserTester::case1982() -{ - parseExpression("sizeof ( __FUNCTION__ )", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - ParenthesizedExpression, - PredefinedName })); +void ParserTester::case1990() { + parseExpression("__real__ x", + Expectation().AST({ExtGNU_RealExpression, IdentifierName})); } -void ParserTester::case1983() -{ - parseExpression("sizeof ( __PRETTY_FUNCTION__ )", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - ParenthesizedExpression, - PredefinedName})); +void ParserTester::case1991() { + parseExpression("__real__ ( x )", + Expectation().AST({ExtGNU_RealExpression, + ParenthesizedExpression, IdentifierName})); } -void ParserTester::case1984() -{ - parseExpression("sizeof __FUNCTION__", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - PredefinedName })); -} - -void ParserTester::case1985() -{ - parseExpression("sizeof __PRETTY_FUNCTION__", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - PredefinedName })); -} - -void ParserTester::case1986() -{ - parseExpression("( __FUNCTION__ )", - Expectation().AST( { ParenthesizedExpression, - PredefinedName })); -} - -void ParserTester::case1987() -{ - parseExpression("( __PRETTY_FUNCTION__ )", - Expectation().AST( { ParenthesizedExpression, - PredefinedName })); -} - -void ParserTester::case1988() -{ - parseExpression("x = __FUNCTION__", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - PredefinedName })); -} - -void ParserTester::case1989() -{ - parseExpression("x = __PRETTY_FUNCTION__", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - PredefinedName })); -} - -void ParserTester::case1990() -{ - parseExpression("__real__ x", - Expectation().AST( { ExtGNU_RealExpression, - IdentifierName })); -} - -void ParserTester::case1991() -{ - parseExpression("__real__ ( x )", - Expectation().AST( { ExtGNU_RealExpression, - ParenthesizedExpression, - IdentifierName })); -} - -void ParserTester::case1992() -{ - parseExpression("__real__ ( __real__ x )", - Expectation().AST( { ExtGNU_RealExpression, - ParenthesizedExpression, - ExtGNU_RealExpression, - IdentifierName })); -} -void ParserTester::case1993() -{ - parseExpression("__imag__ x", - Expectation().AST( { ExtGNU_ImagExpression, - IdentifierName })); +void ParserTester::case1992() { + parseExpression( + "__real__ ( __real__ x )", + Expectation().AST({ExtGNU_RealExpression, ParenthesizedExpression, + ExtGNU_RealExpression, IdentifierName})); } - -void ParserTester::case1994() -{ - parseExpression("__imag__ ( x )", - Expectation().AST( { ExtGNU_ImagExpression, - ParenthesizedExpression, - IdentifierName })); -} - -void ParserTester::case1995() -{ - parseExpression("__imag__ __real__ x", - Expectation().AST( { ExtGNU_ImagExpression, - ExtGNU_RealExpression, - IdentifierName })); -} - -void ParserTester::case1996() -{ - parseExpression("__real__ ( int ) x", - Expectation().AST( { ExtGNU_RealExpression, - CastExpression, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator, - IdentifierName })); +void ParserTester::case1993() { + parseExpression("__imag__ x", + Expectation().AST({ExtGNU_ImagExpression, IdentifierName})); +} + +void ParserTester::case1994() { + parseExpression("__imag__ ( x )", + Expectation().AST({ExtGNU_ImagExpression, + ParenthesizedExpression, IdentifierName})); +} + +void ParserTester::case1995() { + parseExpression("__imag__ __real__ x", + Expectation().AST({ExtGNU_ImagExpression, + ExtGNU_RealExpression, IdentifierName})); +} + +void ParserTester::case1996() { + parseExpression("__real__ ( int ) x", + Expectation().AST({ExtGNU_RealExpression, CastExpression, + TypeName, BuiltinTypeSpecifier, + AbstractDeclarator, IdentifierName})); } void ParserTester::case1997() {} diff --git a/C/tests/ParserTester_2000_2999.cpp b/C/tests/ParserTester_2000_2999.cpp index 18f54dbbf..eec02acb5 100644 --- a/C/tests/ParserTester_2000_2999.cpp +++ b/C/tests/ParserTester_2000_2999.cpp @@ -28,375 +28,196 @@ using namespace psy; using namespace C; -void ParserTester::case2000() -{ - parseStatement("x : 1 ; ", - Expectation().AST( { IdentifierLabelStatement, - ExpressionStatement, - IntegerConstantExpression })); +void ParserTester::case2000() { + parseStatement("x : 1 ; ", Expectation().AST({IdentifierLabelStatement, + ExpressionStatement, + IntegerConstantExpression})); } -void ParserTester::case2001() -{ - parseStatement("x : :", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case2001() { + parseStatement( + "x : :", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case2002() -{ - parseStatement("goto x ;", - Expectation().AST( { GotoStatement })); +void ParserTester::case2002() { + parseStatement("goto x ;", Expectation().AST({GotoStatement})); } -void ParserTester::case2003() -{ - parseStatement("goto ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryIdentifier)); +void ParserTester::case2003() { + parseStatement("goto ;", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedTokenOfCategoryIdentifier)); } -void ParserTester::case2004() -{ - parseStatement("goto 1 ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryIdentifier)); +void ParserTester::case2004() { + parseStatement("goto 1 ;", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedTokenOfCategoryIdentifier)); } -void ParserTester::case2005() -{ - parseStatement("goto x", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case2005() { + parseStatement("goto x", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case2006() -{ +void ParserTester::case2006() {} -} - -void ParserTester::case2007() -{ - -} - -void ParserTester::case2008() -{ - -} - -void ParserTester::case2009() -{ - -} - -void ParserTester::case2010() -{ - -} - -void ParserTester::case2011() -{ - -} - -void ParserTester::case2012() -{ - -} - -void ParserTester::case2013() -{ - -} - -void ParserTester::case2014() -{ - -} - -void ParserTester::case2015() -{ - -} - -void ParserTester::case2016() -{ - -} - -void ParserTester::case2017() -{ - -} - -void ParserTester::case2018() -{ - -} - -void ParserTester::case2019() -{ - -} - -void ParserTester::case2020() -{ - parseStatement("{ }", - Expectation().AST( { CompoundStatement })); -} - -void ParserTester::case2021() -{ - parseStatement("{", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); -} - -void ParserTester::case2022() -{ - parseStatement("{ / }", - Expectation().setErrorCnt(1)); -} +void ParserTester::case2007() {} -void ParserTester::case2023() -{ - parseStatement("{ { } }", - Expectation().AST( { CompoundStatement, - CompoundStatement })); -} - -void ParserTester::case2024() -{ - parseDeclaration("void x ( ) { }", - Expectation().AST( { FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - CompoundStatement })); -} - -void ParserTester::case2025() -{ - -} +void ParserTester::case2008() {} -void ParserTester::case2026() -{ +void ParserTester::case2009() {} -} - -void ParserTester::case2027() -{ - -} +void ParserTester::case2010() {} -void ParserTester::case2028() -{ +void ParserTester::case2011() {} -} +void ParserTester::case2012() {} -void ParserTester::case2029() -{ +void ParserTester::case2013() {} -} +void ParserTester::case2014() {} -void ParserTester::case2030() -{ +void ParserTester::case2015() {} -} - -void ParserTester::case2031() -{ -} - -void ParserTester::case2032() -{ -} - -void ParserTester::case2033() -{ -} - -void ParserTester::case2034() -{ -} - -void ParserTester::case2035() -{ -} +void ParserTester::case2016() {} -void ParserTester::case2036() -{ -} +void ParserTester::case2017() {} -void ParserTester::case2037() -{ -} +void ParserTester::case2018() {} -void ParserTester::case2038() -{ -} +void ParserTester::case2019() {} -void ParserTester::case2039() -{ +void ParserTester::case2020() { + parseStatement("{ }", Expectation().AST({CompoundStatement})); } -void ParserTester::case2040() -{ +void ParserTester::case2021() { + parseStatement("{", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case2041() -{ +void ParserTester::case2022() { + parseStatement("{ / }", Expectation().setErrorCnt(1)); } -void ParserTester::case2042() -{ +void ParserTester::case2023() { + parseStatement("{ { } }", + Expectation().AST({CompoundStatement, CompoundStatement})); } -void ParserTester::case2043() -{ +void ParserTester::case2024() { + parseDeclaration("void x ( ) { }", + Expectation().AST({FunctionDefinition, BuiltinTypeSpecifier, + FunctionDeclarator, IdentifierDeclarator, + ParameterSuffix, CompoundStatement})); } -void ParserTester::case2044() -{ -} +void ParserTester::case2025() {} -void ParserTester::case2045() -{ -} +void ParserTester::case2026() {} -void ParserTester::case2046() -{ -} +void ParserTester::case2027() {} -void ParserTester::case2047() -{ +void ParserTester::case2028() {} -} +void ParserTester::case2029() {} -void ParserTester::case2048() -{ +void ParserTester::case2030() {} -} +void ParserTester::case2031() {} -void ParserTester::case2049() -{ +void ParserTester::case2032() {} -} +void ParserTester::case2033() {} -void ParserTester::case2050() -{ +void ParserTester::case2034() {} -} +void ParserTester::case2035() {} -void ParserTester::case2051() -{ +void ParserTester::case2036() {} -} +void ParserTester::case2037() {} -void ParserTester::case2052() -{ +void ParserTester::case2038() {} -} +void ParserTester::case2039() {} -void ParserTester::case2053() -{ +void ParserTester::case2040() {} -} +void ParserTester::case2041() {} -void ParserTester::case2054() -{ +void ParserTester::case2042() {} -} +void ParserTester::case2043() {} -void ParserTester::case2055() -{ +void ParserTester::case2044() {} -} +void ParserTester::case2045() {} -void ParserTester::case2056() -{ +void ParserTester::case2046() {} -} +void ParserTester::case2047() {} -void ParserTester::case2057() -{ +void ParserTester::case2048() {} -} +void ParserTester::case2049() {} -void ParserTester::case2058() -{ +void ParserTester::case2050() {} -} +void ParserTester::case2051() {} -void ParserTester::case2059() -{ +void ParserTester::case2052() {} -} +void ParserTester::case2053() {} -void ParserTester::case2060() -{ +void ParserTester::case2054() {} -} +void ParserTester::case2055() {} -void ParserTester::case2061() -{ +void ParserTester::case2056() {} -} +void ParserTester::case2057() {} -void ParserTester::case2062() -{ +void ParserTester::case2058() {} -} +void ParserTester::case2059() {} -void ParserTester::case2063() -{ -} +void ParserTester::case2060() {} -void ParserTester::case2064() -{ -} +void ParserTester::case2061() {} -void ParserTester::case2065() -{ +void ParserTester::case2062() {} -} +void ParserTester::case2063() {} -void ParserTester::case2066() -{ +void ParserTester::case2064() {} -} +void ParserTester::case2065() {} -void ParserTester::case2067() -{ +void ParserTester::case2066() {} -} +void ParserTester::case2067() {} -void ParserTester::case2068() -{ -} +void ParserTester::case2068() {} -void ParserTester::case2069() -{ -} +void ParserTester::case2069() {} -void ParserTester::case2070() -{ -} +void ParserTester::case2070() {} -void ParserTester::case2071() -{ -} +void ParserTester::case2071() {} -void ParserTester::case2072() -{ -} +void ParserTester::case2072() {} -void ParserTester::case2073() -{ -} +void ParserTester::case2073() {} void ParserTester::case2074() {} void ParserTester::case2075() {} @@ -425,118 +246,74 @@ void ParserTester::case2097() {} void ParserTester::case2098() {} void ParserTester::case2099() {} -void ParserTester::case2100() -{ - parseStatement("{ x ++ ; }", - Expectation().AST( { CompoundStatement, - ExpressionStatement, - PostIncrementExpression, - IdentifierName })); +void ParserTester::case2100() { + parseStatement("{ x ++ ; }", + Expectation().AST({CompoundStatement, ExpressionStatement, + PostIncrementExpression, IdentifierName})); } -void ParserTester::case2101() -{ - parseStatement("{ ++ x ; }", - Expectation().AST( { CompoundStatement, - ExpressionStatement, - PreIncrementExpression, - IdentifierName })); +void ParserTester::case2101() { + parseStatement("{ ++ x ; }", + Expectation().AST({CompoundStatement, ExpressionStatement, + PreIncrementExpression, IdentifierName})); } -void ParserTester::case2102() -{ - parseStatement("{ x ( 1 ) ; }", - Expectation().AST( { CompoundStatement, - ExpressionStatement, - CallExpression, - IdentifierName, - IntegerConstantExpression })); +void ParserTester::case2102() { + parseStatement( + "{ x ( 1 ) ; }", + Expectation().AST({CompoundStatement, ExpressionStatement, CallExpression, + IdentifierName, IntegerConstantExpression})); } -void ParserTester::case2103() -{ - parseStatement("{ x ( 1 , 2 ) ; }"); -} +void ParserTester::case2103() { parseStatement("{ x ( 1 , 2 ) ; }"); } -void ParserTester::case2104() -{ - parseStatement("{ x ( y , 2 ) ; }"); -} +void ParserTester::case2104() { parseStatement("{ x ( y , 2 ) ; }"); } -void ParserTester::case2105() -{ - parseStatement("{ x ( 1 , 2 ) ; }"); -} +void ParserTester::case2105() { parseStatement("{ x ( 1 , 2 ) ; }"); } -void ParserTester::case2106() -{ - parseStatement("{ ( x ( 1 ) ) ; }", - Expectation().AST( { CompoundStatement, - ExpressionStatement, - ParenthesizedExpression, - CallExpression, - IdentifierName, - IntegerConstantExpression })); +void ParserTester::case2106() { + parseStatement( + "{ ( x ( 1 ) ) ; }", + Expectation().AST({CompoundStatement, ExpressionStatement, + ParenthesizedExpression, CallExpression, + IdentifierName, IntegerConstantExpression})); } -void ParserTester::case2107() -{ - parseStatement("{ ( ( x ( 1 ) ) ) ; }"); -} +void ParserTester::case2107() { parseStatement("{ ( ( x ( 1 ) ) ) ; }"); } -void ParserTester::case2108() -{ - parseStatement("{ ( x ( 1 , 2 ) ) ; }"); -} +void ParserTester::case2108() { parseStatement("{ ( x ( 1 , 2 ) ) ; }"); } -void ParserTester::case2109() -{ - parseStatement("{ 'x' ; }"); -} +void ParserTester::case2109() { parseStatement("{ 'x' ; }"); } -void ParserTester::case2110() -{ - parseStatement("{ \"x\" ; }"); -} +void ParserTester::case2110() { parseStatement("{ \"x\" ; }"); } -void ParserTester::case2111() -{ - parseStatement("{ x ; }"); -} +void ParserTester::case2111() { parseStatement("{ x ; }"); } -void ParserTester::case2112() -{ - parseStatement("{ 1 ; }"); -} +void ParserTester::case2112() { parseStatement("{ 1 ; }"); } -void ParserTester::case2113() -{ - parseStatement("{ 1 ( ; }", - Expectation().setErrorCnt(1)); +void ParserTester::case2113() { + parseStatement("{ 1 ( ; }", Expectation().setErrorCnt(1)); } -void ParserTester::case2114() -{ - parseStatement("{ 'x' ; }"); -} +void ParserTester::case2114() { parseStatement("{ 'x' ; }"); } -void ParserTester::case2115() -{ - /* - Despite the parsing similarities between `typeof' and `sizeof', - mind the difference between this test case and the following: +void ParserTester::case2115() { + /* + Despite the parsing similarities between `typeof' and `sizeof', + mind the difference between this test case and the following: - `typeof ( x ) y ;' + `typeof ( x ) y ;' - This would be a valid declaration-statement, and the `y' doesn't - belong to the parsing of `typeof': it's the declarator. - */ + This would be a valid declaration-statement, and the `y' doesn't + belong to the parsing of `typeof': it's the declarator. + */ - CROSS_REFERENCE_TEST(ParserTester::case0904); + CROSS_REFERENCE_TEST(ParserTester::case0904); - parseStatement("sizeof ( x ) y ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); + parseStatement("sizeof ( x ) y ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } void ParserTester::case2116() {} @@ -624,166 +401,120 @@ void ParserTester::case2197() {} void ParserTester::case2198() {} void ParserTester::case2199() {} -void ParserTester::case2200() -{ - parseStatement("{ _Static_assert ( 1 != 2 , \"x\" ) ; }"); -} - -void ParserTester::case2201() -{ - parseStatement("{ int x ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case2202() -{ - parseStatement("{ int x , y ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case2203() -{ - parseStatement("{ const int x ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - ConstQualifier, - BuiltinTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case2204() -{ - parseStatement("{ int * x ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - PointerDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case2205() -{ - parseStatement("{ struct x ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - StructDeclaration, - StructTypeSpecifier })); -} - -void ParserTester::case2206() -{ - parseStatement("{ union x y ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - UnionTypeSpecifier, - IdentifierDeclarator })); -} - -void ParserTester::case2207() -{ - parseStatement("{ x y ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator })); -} - -void ParserTester::case2208() -{ - parseStatement("{ x y , z ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator, - IdentifierDeclarator })); -} - -void ParserTester::case2209() -{ - parseStatement("{ const x y ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - ConstQualifier, - TypedefName, - IdentifierDeclarator })); -} - -void ParserTester::case2210() -{ - parseStatement("{ const x * const y ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - ConstQualifier, - TypedefName, - PointerDeclarator, - ConstQualifier, - IdentifierDeclarator })); -} - -void ParserTester::case2211() -{ - parseStatement("{ x * y ; }", - Expectation().AST( { CompoundStatement, - AmbiguousMultiplicationOrPointerDeclaration, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - PointerDeclarator, - IdentifierDeclarator, - ExpressionStatement, - MultiplyExpression, - IdentifierName, - IdentifierName }) - .ambiguity("{ x * y ; x * y ; }")); -} - -void ParserTester::case2212() -{ - parseStatement("{ x ( y ) ; }", - Expectation().AST( { CompoundStatement, - AmbiguousCallOrVariableDeclaration, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - ParenthesizedDeclarator, - IdentifierDeclarator, - ExpressionStatement, - CallExpression, - IdentifierName, - IdentifierName }) - .ambiguity("{ x ( y ) ; x ( y ) ; }")); -} - -void ParserTester::case2213() -{ - CROSS_REFERENCE_TEST(ParserTester::case1813); - - parseStatement("{ x * y = 0 ; }", - Expectation().AST( { CompoundStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - PointerDeclarator, - IdentifierDeclarator, - ExpressionInitializer, - IntegerConstantExpression })); +void ParserTester::case2200() { + parseStatement("{ _Static_assert ( 1 != 2 , \"x\" ) ; }"); +} + +void ParserTester::case2201() { + parseStatement( + "{ int x ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator})); +} + +void ParserTester::case2202() { + parseStatement( + "{ int x , y ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, IdentifierDeclarator})); +} + +void ParserTester::case2203() { + parseStatement( + "{ const int x ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, ConstQualifier, + BuiltinTypeSpecifier, IdentifierDeclarator})); +} + +void ParserTester::case2204() { + parseStatement( + "{ int * x ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, BuiltinTypeSpecifier, + PointerDeclarator, IdentifierDeclarator})); +} + +void ParserTester::case2205() { + parseStatement("{ struct x ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + StructDeclaration, StructTypeSpecifier})); +} + +void ParserTester::case2206() { + parseStatement("{ union x y ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, + UnionTypeSpecifier, IdentifierDeclarator})); +} +void ParserTester::case2207() { + parseStatement("{ x y ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, + TypedefName, IdentifierDeclarator})); +} + +void ParserTester::case2208() { + parseStatement( + "{ x y , z ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, TypedefName, + IdentifierDeclarator, IdentifierDeclarator})); +} + +void ParserTester::case2209() { + parseStatement( + "{ const x y ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, ConstQualifier, + TypedefName, IdentifierDeclarator})); +} + +void ParserTester::case2210() { + parseStatement( + "{ const x * const y ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, ConstQualifier, + TypedefName, PointerDeclarator, ConstQualifier, + IdentifierDeclarator})); +} + +void ParserTester::case2211() { + parseStatement( + "{ x * y ; }", + Expectation() + .AST({CompoundStatement, AmbiguousMultiplicationOrPointerDeclaration, + DeclarationStatement, VariableAndOrFunctionDeclaration, + TypedefName, PointerDeclarator, IdentifierDeclarator, + ExpressionStatement, MultiplyExpression, IdentifierName, + IdentifierName}) + .ambiguity("{ x * y ; x * y ; }")); +} + +void ParserTester::case2212() { + parseStatement( + "{ x ( y ) ; }", + Expectation() + .AST({CompoundStatement, AmbiguousCallOrVariableDeclaration, + DeclarationStatement, VariableAndOrFunctionDeclaration, + TypedefName, ParenthesizedDeclarator, IdentifierDeclarator, + ExpressionStatement, CallExpression, IdentifierName, + IdentifierName}) + .ambiguity("{ x ( y ) ; x ( y ) ; }")); +} + +void ParserTester::case2213() { + CROSS_REFERENCE_TEST(ParserTester::case1813); + + parseStatement( + "{ x * y = 0 ; }", + Expectation().AST({CompoundStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, TypedefName, + PointerDeclarator, IdentifierDeclarator, + ExpressionInitializer, IntegerConstantExpression})); } void ParserTester::case2214() {} @@ -873,119 +604,82 @@ void ParserTester::case2297() {} void ParserTester::case2298() {} void ParserTester::case2299() {} -void ParserTester::case2300() -{ - parseStatement("if ( x ) ;"); -} +void ParserTester::case2300() { parseStatement("if ( x ) ;"); } -void ParserTester::case2301() -{ - parseStatement("if ( x ) { } "); -} +void ParserTester::case2301() { parseStatement("if ( x ) { } "); } -void ParserTester::case2302() -{ - parseStatement("if ( x ( ) ) { }"); -} +void ParserTester::case2302() { parseStatement("if ( x ( ) ) { }"); } -void ParserTester::case2303() -{ - parseStatement("if ( x ) y ;"); -} +void ParserTester::case2303() { parseStatement("if ( x ) y ;"); } -void ParserTester::case2304() -{ - parseStatement("if ( x ) { y ; }"); -} +void ParserTester::case2304() { parseStatement("if ( x ) { y ; }"); } -void ParserTester::case2305() -{ - parseStatement("if ( x ++ ) { }"); -} +void ParserTester::case2305() { parseStatement("if ( x ++ ) { }"); } -void ParserTester::case2306() -{ - parseStatement("if ( ++ x ) { }"); -} +void ParserTester::case2306() { parseStatement("if ( ++ x ) { }"); } -void ParserTester::case2307() -{ - parseStatement("if ( 1 ) { } else ;"); -} +void ParserTester::case2307() { parseStatement("if ( 1 ) { } else ;"); } -void ParserTester::case2308() -{ - parseStatement("if ( 1 ) ; else ;"); -} +void ParserTester::case2308() { parseStatement("if ( 1 ) ; else ;"); } -void ParserTester::case2309() -{ - parseStatement("if ( 1 ) ; else { }"); -} +void ParserTester::case2309() { parseStatement("if ( 1 ) ; else { }"); } -void ParserTester::case2310() -{ - parseStatement("if ( 1 ) { } else { }"); -} +void ParserTester::case2310() { parseStatement("if ( 1 ) { } else { }"); } -void ParserTester::case2311() -{ - parseStatement("if ( 1 ) { x ; } else { y ; }"); +void ParserTester::case2311() { + parseStatement("if ( 1 ) { x ; } else { y ; }"); } -void ParserTester::case2312() -{ - parseStatement("if ( 1 ) else { }", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case2312() { + parseStatement( + "if ( 1 ) else { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case2313() -{ - parseStatement("if ( 1 ) 2 else { }", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case2313() { + parseStatement("if ( 1 ) 2 else { }", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case2314() -{ - parseStatement("if else x ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case2314() { + parseStatement("if else x ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case2315() -{ - parseStatement("if ( 1 ) { } else ", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case2315() { + parseStatement( + "if ( 1 ) { } else ", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case2316() -{ - parseStatement("if ( 1 ) { } else (", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case2316() { + parseStatement( + "if ( 1 ) { } else (", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case2317() -{ - parseStatement("if ( 1 ) if ( 2 ) x ;"); -} +void ParserTester::case2317() { parseStatement("if ( 1 ) if ( 2 ) x ;"); } -void ParserTester::case2318() -{ - parseStatement("if ( 1 ) if ( 2 ) x ; else y ;"); +void ParserTester::case2318() { + parseStatement("if ( 1 ) if ( 2 ) x ; else y ;"); } -void ParserTester::case2319() -{ - parseStatement("if ( 1 ) { if ( 2 ) x ; } else y ;"); +void ParserTester::case2319() { + parseStatement("if ( 1 ) { if ( 2 ) x ; } else y ;"); } -void ParserTester::case2320() -{ - parseStatement("if ( 1 ) { if ( 2 ) x ; } else { y ; }"); +void ParserTester::case2320() { + parseStatement("if ( 1 ) { if ( 2 ) x ; } else { y ; }"); } void ParserTester::case2321() {} @@ -1018,19 +712,14 @@ void ParserTester::case2347() {} void ParserTester::case2348() {} void ParserTester::case2349() {} -void ParserTester::case2350() -{ - parseStatement("switch ( 1 ) { }"); -} +void ParserTester::case2350() { parseStatement("switch ( 1 ) { }"); } -void ParserTester::case2351() -{ - parseStatement("switch ( x ) { case 2 : y ( ) ; }"); +void ParserTester::case2351() { + parseStatement("switch ( x ) { case 2 : y ( ) ; }"); } -void ParserTester::case2352() -{ - parseStatement(R"( +void ParserTester::case2352() { + parseStatement(R"( switch ( x ) { case 1 : y ; case 2 : z ( ) ; @@ -1038,14 +727,12 @@ void ParserTester::case2352() )"); } -void ParserTester::case2353() -{ - parseStatement("switch ( x ) case 2 : y ( ) ;"); +void ParserTester::case2353() { + parseStatement("switch ( x ) case 2 : y ( ) ;"); } -void ParserTester::case2354() -{ - parseStatement(R"( +void ParserTester::case2354() { + parseStatement(R"( switch ( x ) { case 1 : y ; default : z ( ) ; @@ -1053,32 +740,31 @@ void ParserTester::case2354() )"); } -void ParserTester::case2355() -{ - parseStatement(R"( +void ParserTester::case2355() { + parseStatement(R"( switch ( x ) { default : y ; } )"); } -void ParserTester::case2356() -{ - parseStatement("case 1 : x ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_UnexpectedCaseLabelOutsideSwitch)); +void ParserTester::case2356() { + parseStatement( + "case 1 : x ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_UnexpectedCaseLabelOutsideSwitch)); } -void ParserTester::case2357() -{ - parseStatement("default : x ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_UnexpectedDefaultLabelOutsideSwitch)); +void ParserTester::case2357() { + parseStatement( + "default : x ;", + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_UnexpectedDefaultLabelOutsideSwitch)); } -void ParserTester::case2358() -{ -} +void ParserTester::case2358() {} void ParserTester::case2359() {} void ParserTester::case2360() {} @@ -1122,93 +808,63 @@ void ParserTester::case2397() {} void ParserTester::case2398() {} void ParserTester::case2399() {} -void ParserTester::case2400() -{ - parseStatement("while ( 1 ) { }"); -} +void ParserTester::case2400() { parseStatement("while ( 1 ) { }"); } -void ParserTester::case2401() -{ - parseStatement("while ( 1 ) ;"); -} +void ParserTester::case2401() { parseStatement("while ( 1 ) ;"); } -void ParserTester::case2402() -{ - parseStatement("while ( * x ++ != '\\0' ) ;"); -} +void ParserTester::case2402() { parseStatement("while ( * x ++ != '\\0' ) ;"); } -void ParserTester::case2403() -{ - parseStatement("while ( 1 ) x = y ;"); -} +void ParserTester::case2403() { parseStatement("while ( 1 ) x = y ;"); } -void ParserTester::case2404() -{ - parseStatement("do { } while ( 1 ) ;"); -} +void ParserTester::case2404() { parseStatement("do { } while ( 1 ) ;"); } -void ParserTester::case2405() -{ - parseStatement("do { } while ( 1 )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case2405() { + parseStatement("do { } while ( 1 )", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case2406() -{ - parseStatement("do { } while ( ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case2406() { + parseStatement( + "do { } while ( ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case2407() -{ - parseStatement("while ( )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +void ParserTester::case2407() { + parseStatement( + "while ( )", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); } -void ParserTester::case2408() -{ - parseStatement("do ; while ( 1 )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); +void ParserTester::case2408() { + parseStatement("do ; while ( 1 )", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case2409() -{ - parseStatement("do x ( ) ; while ( y / z % 0 ) ;"); +void ParserTester::case2409() { + parseStatement("do x ( ) ; while ( y / z % 0 ) ;"); } -void ParserTester::case2410() -{ - parseStatement("do x ; while ( y ) ;"); -} +void ParserTester::case2410() { parseStatement("do x ; while ( y ) ;"); } -void ParserTester::case2411() -{ - parseStatement("do ; while ( 1 ) ;"); -} +void ParserTester::case2411() { parseStatement("do ; while ( 1 ) ;"); } -void ParserTester::case2412() -{ - parseStatement("while ( * x ++ != 0 ) y ;"); -} +void ParserTester::case2412() { parseStatement("while ( * x ++ != 0 ) y ;"); } -void ParserTester::case2413() -{ - parseStatement("while ( x != y ) z ;"); -} +void ParserTester::case2413() { parseStatement("while ( x != y ) z ;"); } -void ParserTester::case2414() -{ - parseStatement("while ( ! x ( ) ) { y ; z ; }"); +void ParserTester::case2414() { + parseStatement("while ( ! x ( ) ) { y ; z ; }"); } -void ParserTester::case2415() -{ - parseStatement("while ( * x ++ != '0' ) ;"); -} +void ParserTester::case2415() { parseStatement("while ( * x ++ != '0' ) ;"); } void ParserTester::case2416() {} void ParserTester::case2417() {} @@ -1245,126 +901,94 @@ void ParserTester::case2447() {} void ParserTester::case2448() {} void ParserTester::case2449() {} -void ParserTester::case2450() -{ - parseStatement("for ( ; ; ) 1 ;", - Expectation().AST( { ForStatement, - ExpressionStatement, - ExpressionStatement, - IntegerConstantExpression })); -} - -void ParserTester::case2451() -{ - parseStatement("for ( ; ) ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); -} - -void ParserTester::case2452() -{ - parseStatement("for ( ; ; ) { }", - Expectation().AST( { ForStatement, - ExpressionStatement, - CompoundStatement })); -} - -void ParserTester::case2453() -{ - parseStatement("for ( ; ; )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); -} - -void ParserTester::case2454() -{ - parseStatement("for ( x ; y ; z ) { }", - Expectation().AST( { ForStatement, - ExpressionStatement, - IdentifierName, - IdentifierName, - IdentifierName, - CompoundStatement })); -} - -void ParserTester::case2455() -{ - parseStatement("for ( int x ; y ; z ) { }", - Expectation().AST( { ForStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - IdentifierName, - IdentifierName, - CompoundStatement })); -} - -void ParserTester::case2456() -{ - parseStatement("for ( x y ; 1 ; 2 ) { }", - Expectation().AST( { ForStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator, - IntegerConstantExpression, - IntegerConstantExpression, - CompoundStatement })); -} - -void ParserTester::case2457() -{ - parseStatement("for ( x y ; 1 ; ) { }", - Expectation().AST( { ForStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator, - IntegerConstantExpression, - CompoundStatement })); -} - -void ParserTester::case2458() -{ - parseStatement("for ( x y ; ; ) { }", - Expectation().AST( { ForStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator, - CompoundStatement })); -} - -void ParserTester::case2459() -{ - parseStatement("for ( 1 ; x != 0 ; ++ y ) { }", - Expectation().AST( { ForStatement, - ExpressionStatement, - IntegerConstantExpression, - NotEqualsExpression, - IdentifierName, - IntegerConstantExpression, - PreIncrementExpression, - IdentifierName, - CompoundStatement })); -} -void ParserTester::case2460() -{ - parseStatement("for ( int x = 1 ; y != 0 ; ++ z ) { }", - Expectation().AST( { ForStatement, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - BuiltinTypeSpecifier, - IdentifierDeclarator, - ExpressionInitializer, - IntegerConstantExpression, - NotEqualsExpression, - IdentifierName, - IntegerConstantExpression, - PreIncrementExpression, - IdentifierName, - CompoundStatement })); +void ParserTester::case2450() { + parseStatement( + "for ( ; ; ) 1 ;", + Expectation().AST({ForStatement, ExpressionStatement, ExpressionStatement, + IntegerConstantExpression})); +} + +void ParserTester::case2451() { + parseStatement( + "for ( ; ) ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +} + +void ParserTester::case2452() { + parseStatement("for ( ; ; ) { }", + Expectation().AST( + {ForStatement, ExpressionStatement, CompoundStatement})); +} + +void ParserTester::case2453() { + parseStatement( + "for ( ; ; )", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofExpression)); +} + +void ParserTester::case2454() { + parseStatement( + "for ( x ; y ; z ) { }", + Expectation().AST({ForStatement, ExpressionStatement, IdentifierName, + IdentifierName, IdentifierName, CompoundStatement})); +} + +void ParserTester::case2455() { + parseStatement( + "for ( int x ; y ; z ) { }", + Expectation().AST({ForStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, BuiltinTypeSpecifier, + IdentifierDeclarator, IdentifierName, IdentifierName, + CompoundStatement})); +} + +void ParserTester::case2456() { + parseStatement( + "for ( x y ; 1 ; 2 ) { }", + Expectation().AST({ForStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, TypedefName, + IdentifierDeclarator, IntegerConstantExpression, + IntegerConstantExpression, CompoundStatement})); +} + +void ParserTester::case2457() { + parseStatement( + "for ( x y ; 1 ; ) { }", + Expectation().AST({ForStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, TypedefName, + IdentifierDeclarator, IntegerConstantExpression, + CompoundStatement})); +} + +void ParserTester::case2458() { + parseStatement( + "for ( x y ; ; ) { }", + Expectation().AST({ForStatement, DeclarationStatement, + VariableAndOrFunctionDeclaration, TypedefName, + IdentifierDeclarator, CompoundStatement})); +} + +void ParserTester::case2459() { + parseStatement( + "for ( 1 ; x != 0 ; ++ y ) { }", + Expectation().AST( + {ForStatement, ExpressionStatement, IntegerConstantExpression, + NotEqualsExpression, IdentifierName, IntegerConstantExpression, + PreIncrementExpression, IdentifierName, CompoundStatement})); +} +void ParserTester::case2460() { + parseStatement( + "for ( int x = 1 ; y != 0 ; ++ z ) { }", + Expectation().AST( + {ForStatement, DeclarationStatement, VariableAndOrFunctionDeclaration, + BuiltinTypeSpecifier, IdentifierDeclarator, ExpressionInitializer, + IntegerConstantExpression, NotEqualsExpression, IdentifierName, + IntegerConstantExpression, PreIncrementExpression, IdentifierName, + CompoundStatement})); } void ParserTester::case2461() {} @@ -1407,51 +1031,38 @@ void ParserTester::case2497() {} void ParserTester::case2498() {} void ParserTester::case2499() {} -void ParserTester::case2500() -{ - parseStatement("break ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_UnexpectedBreakOutsideSwitchOrLoop)); +void ParserTester::case2500() { + parseStatement("break ;", Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_UnexpectedBreakOutsideSwitchOrLoop)); } -void ParserTester::case2501() -{ - parseStatement("continue ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_UnexpectedContinueOutsideLoop)); +void ParserTester::case2501() { + parseStatement( + "continue ;", + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_UnexpectedContinueOutsideLoop)); } -void ParserTester::case2502() -{ - parseStatement("return ;"); -} +void ParserTester::case2502() { parseStatement("return ;"); } -void ParserTester::case2503() -{ - parseStatement("return x ;"); -} +void ParserTester::case2503() { parseStatement("return x ;"); } -void ParserTester::case2504() -{ - parseStatement("return 0 ;"); -} +void ParserTester::case2504() { parseStatement("return 0 ;"); } -void ParserTester::case2505() -{ - parseStatement("return x ( ) ;"); -} +void ParserTester::case2505() { parseStatement("return x ( ) ;"); } -void ParserTester::case2506() -{ - parseStatement(R"( +void ParserTester::case2506() { + parseStatement(R"( for ( ; ; ) break ; )"); } -void ParserTester::case2507() -{ - parseStatement(R"( +void ParserTester::case2507() { + parseStatement(R"( for ( ; ; ) { break ; @@ -1459,25 +1070,22 @@ void ParserTester::case2507() )"); } -void ParserTester::case2508() -{ - parseStatement(R"( +void ParserTester::case2508() { + parseStatement(R"( for ( ; ; ) continue ; )"); } -void ParserTester::case2509() -{ - parseStatement(R"( +void ParserTester::case2509() { + parseStatement(R"( while ( 1 ) break ; )"); } -void ParserTester::case2510() -{ - parseStatement(R"( +void ParserTester::case2510() { + parseStatement(R"( while ( 1 ) { break ; @@ -1485,9 +1093,8 @@ void ParserTester::case2510() )"); } -void ParserTester::case2511() -{ - parseStatement(R"( +void ParserTester::case2511() { + parseStatement(R"( for ( ; ; ) { continue ; @@ -1495,9 +1102,8 @@ void ParserTester::case2511() )"); } -void ParserTester::case2512() -{ - parseStatement(R"( +void ParserTester::case2512() { + parseStatement(R"( switch ( x ) { case 1 : @@ -1506,9 +1112,8 @@ void ParserTester::case2512() )"); } -void ParserTester::case2513() -{ - parseStatement(R"( +void ParserTester::case2513() { + parseStatement(R"( switch ( x ) { case 1 : break ; @@ -1517,9 +1122,8 @@ void ParserTester::case2513() )"); } -void ParserTester::case2514() -{ - parseStatement(R"( +void ParserTester::case2514() { + parseStatement(R"( switch ( x ) { case 1 : @@ -1529,28 +1133,30 @@ void ParserTester::case2514() )"); } -void ParserTester::case2515() -{ - parse("break", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator) - .diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); +void ParserTester::case2515() { + parse("break", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFIRSTofDirectDeclarator) + .diagnostic( + Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); } -void ParserTester::case2516() -{ - parse("continue ;", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedFIRSTofDirectDeclarator) - .diagnostic(Expectation::ErrorOrWarn::Warn, - Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); - +void ParserTester::case2516() { + parse("continue ;", + Expectation() + .diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedFIRSTofDirectDeclarator) + .diagnostic( + Expectation::ErrorOrWarn::Warn, + Parser::DiagnosticsReporter::ID_of_ExpectedTypeSpecifier)); } -void ParserTester::case2517() -{ - parseStatement(R"( +void ParserTester::case2517() { + parseStatement(R"( for ( ; ; ) { switch ( 1 ) { default : @@ -1560,9 +1166,8 @@ void ParserTester::case2517() )"); } -void ParserTester::case2518() -{ - parseStatement(R"( +void ParserTester::case2518() { + parseStatement(R"( for ( ; ; ) { switch ( 1 ) { default : @@ -1572,18 +1177,16 @@ void ParserTester::case2518() )"); } -void ParserTester::case2519() -{ - parseStatement(R"( +void ParserTester::case2519() { + parseStatement(R"( switch ( x ) { break; } )"); } -void ParserTester::case2520() -{ - parseStatement(R"( +void ParserTester::case2520() { + parseStatement(R"( switch ( 0 ) { case 1 : ; default: @@ -1674,69 +1277,64 @@ void ParserTester::case2597() {} void ParserTester::case2598() {} void ParserTester::case2599() {} -void ParserTester::case2600() -{ - parseStatement(R"( +void ParserTester::case2600() { + parseStatement(R"( asm ( "nop" ); )"); } -void ParserTester::case2601() -{ - parseStatement(R"( +void ParserTester::case2601() { + parseStatement(R"( asm ( "nop" "nop" ); )"); } -void ParserTester::case2602() -{ - parseStatement(R"( +void ParserTester::case2602() { + parseStatement(R"( asm ( "nop" ) )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedToken)); + Expectation().diagnostic( + Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter::ID_of_ExpectedToken)); } -void ParserTester::case2603() -{ - parseStatement(R"( +void ParserTester::case2603() { + parseStatement( + R"( asm ( ) )", - Expectation().diagnostic(Expectation::ErrorOrWarn::Error, - Parser::DiagnosticsReporter::ID_of_ExpectedTokenOfCategoryStringLiteral)); + Expectation().diagnostic(Expectation::ErrorOrWarn::Error, + Parser::DiagnosticsReporter:: + ID_of_ExpectedTokenOfCategoryStringLiteral)); } -void ParserTester::case2604() -{ - // From https://www.felixcloutier.com/documents/gcc-asm.html. +void ParserTester::case2604() { + // From https://www.felixcloutier.com/documents/gcc-asm.html. - parseStatement(R"( + parseStatement(R"( asm ( "movq %0, %0" : "+rm" ( foo ) ) ; )"); } -void ParserTester::case2605() -{ - // From https://www.felixcloutier.com/documents/gcc-asm.html. +void ParserTester::case2605() { + // From https://www.felixcloutier.com/documents/gcc-asm.html. - parseStatement(R"( + parseStatement(R"( asm ( "addl %0, %1" : "+r" ( foo ) : "g" ( bar ) ) ; )"); } -void ParserTester::case2606() -{ - // From https://www.felixcloutier.com/documents/gcc-asm.html. +void ParserTester::case2606() { + // From https://www.felixcloutier.com/documents/gcc-asm.html. - parseStatement(R"( + parseStatement(R"( asm ( "lfence " : : : "memory" ) ; )"); } -void ParserTester::case2607() -{ - parseStatement(R"( +void ParserTester::case2607() { + parseStatement(R"( asm ( "movl $123 , %0 \n " "addl %1 , %0" : "=&r" ( foo ) @@ -1744,9 +1342,8 @@ void ParserTester::case2607() )"); } -void ParserTester::case2608() -{ - parseStatement(R"( +void ParserTester::case2608() { + parseStatement(R"( asm goto ( "jmp %l0\n" : : @@ -1755,9 +1352,8 @@ void ParserTester::case2608() )"); } -void ParserTester::case2609() -{ - parseStatement(R"( +void ParserTester::case2609() { + parseStatement(R"( asm goto ( "jmp %l0\n" : : @@ -1766,29 +1362,26 @@ void ParserTester::case2609() )"); } -void ParserTester::case2610() -{ - // From https://www.felixcloutier.com/documents/gcc-asm.html. +void ParserTester::case2610() { + // From https://www.felixcloutier.com/documents/gcc-asm.html. - parseStatement(R"( + parseStatement(R"( asm volatile ( "syscall" : "=a" (ret_val) : : "rcx" , "r11" ) ; )"); } -void ParserTester::case2611() -{ - // From https://www.felixcloutier.com/documents/gcc-asm.html. +void ParserTester::case2611() { + // From https://www.felixcloutier.com/documents/gcc-asm.html. - parseStatement(R"( + parseStatement(R"( asm ( "imulq %[rhs]" : "=a" (*lo) , "=d" (*hi) : [ lhs ] "0" ( left ) , [ rhs ] "rm" ( right )) ; )"); } -void ParserTester::case2612() -{ - parseStatement(R"( +void ParserTester::case2612() { + parseStatement(R"( asm ( "mov %[e], %[d]" : [ d ] "=rm" ( d ) : [ e ] "rm" ( * e ) ); diff --git a/C/tests/ParserTester_3000_3999.cpp b/C/tests/ParserTester_3000_3999.cpp index 907b7308f..2ecaf2842 100644 --- a/C/tests/ParserTester_3000_3999.cpp +++ b/C/tests/ParserTester_3000_3999.cpp @@ -28,417 +28,204 @@ using namespace psy; using namespace C; -void ParserTester::case3000() -{ - parseExpression("va_arg ( x , int )", - Expectation().AST( { VAArgumentExpression, - IdentifierName, - TypeName, - BuiltinTypeSpecifier, - AbstractDeclarator })); - -} - -void ParserTester::case3001() -{ - parseExpression("va_arg ( x , y )", - Expectation().AST( { VAArgumentExpression, - IdentifierName, - TypeName, - TypedefName, - AbstractDeclarator })); -} - -void ParserTester::case3002() -{ - -} - -void ParserTester::case3003() -{ - -} - -void ParserTester::case3004() -{ - -} - -void ParserTester::case3005() -{ - -} - -void ParserTester::case3006() -{ - -} - -void ParserTester::case3007() -{ - -} - -void ParserTester::case3008() -{ - -} - -void ParserTester::case3009() -{ - -} - -void ParserTester::case3010() -{ - parseExpression("offsetof ( struct x , y )", - Expectation().AST( { OffsetOfExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator })); -} - -void ParserTester::case3011() -{ - parseExpression("offsetof ( struct x , y . z )", - Expectation().AST( { OffsetOfExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator, - FieldDesignator })); -} - -void ParserTester::case3012() -{ - parseExpression("offsetof ( struct x , y [ 0 ] )", - Expectation().AST( { OffsetOfExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator, - ArrayDesignator, - IntegerConstantExpression })); -} - -void ParserTester::case3013() -{ - parseExpression("offsetof ( struct x , y [ 0 ] . z )", - Expectation().AST( { OffsetOfExpression, - TypeName, - StructTypeSpecifier, - AbstractDeclarator, - OffsetOfDesignator, - ArrayDesignator, - IntegerConstantExpression, - FieldDesignator })); -} - -void ParserTester::case3014() -{ - +void ParserTester::case3000() { + parseExpression( + "va_arg ( x , int )", + Expectation().AST({VAArgumentExpression, IdentifierName, TypeName, + BuiltinTypeSpecifier, AbstractDeclarator})); } -void ParserTester::case3015() -{ - -} - -void ParserTester::case3016() -{ - -} - -void ParserTester::case3017() -{ - -} - -void ParserTester::case3018() -{ - -} - -void ParserTester::case3019() -{ - -} - -void ParserTester::case3020() -{ - parseExpression("__func__", - Expectation().AST( { PredefinedName })); -} - -void ParserTester::case3021() -{ - parseExpression("(__func__)", - Expectation().AST( { ParenthesizedExpression, - PredefinedName })); -} - -void ParserTester::case3022() -{ - parseExpression("sizeof( __func__ )", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - ParenthesizedExpression, - PredefinedName })); +void ParserTester::case3001() { + parseExpression( + "va_arg ( x , y )", + Expectation().AST({VAArgumentExpression, IdentifierName, TypeName, + TypedefName, AbstractDeclarator})); } -void ParserTester::case3023() -{ - parseExpression("sizeof __func__", - Expectation().AST( { SizeofExpression, - ExpressionAsTypeReference, - PredefinedName })); -} - -void ParserTester::case3024() -{ - parseExpression("x = __func__", - Expectation().AST( { BasicAssignmentExpression, - IdentifierName, - PredefinedName })); -} - -void ParserTester::case3025() -{ - -} - -void ParserTester::case3026() -{ +void ParserTester::case3002() {} -} +void ParserTester::case3003() {} -void ParserTester::case3027() -{ - -} - -void ParserTester::case3028() -{ - -} - -void ParserTester::case3029() -{ - -} - -void ParserTester::case3030() -{ - -} +void ParserTester::case3004() {} -void ParserTester::case3031() -{ +void ParserTester::case3005() {} -} +void ParserTester::case3006() {} -void ParserTester::case3032() -{ +void ParserTester::case3007() {} -} +void ParserTester::case3008() {} -void ParserTester::case3033() -{ +void ParserTester::case3009() {} +void ParserTester::case3010() { + parseExpression( + "offsetof ( struct x , y )", + Expectation().AST({OffsetOfExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, OffsetOfDesignator})); } -void ParserTester::case3034() -{ - +void ParserTester::case3011() { + parseExpression("offsetof ( struct x , y . z )", + Expectation().AST({OffsetOfExpression, TypeName, + StructTypeSpecifier, AbstractDeclarator, + OffsetOfDesignator, FieldDesignator})); } -void ParserTester::case3035() -{ - +void ParserTester::case3012() { + parseExpression( + "offsetof ( struct x , y [ 0 ] )", + Expectation().AST({OffsetOfExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, OffsetOfDesignator, + ArrayDesignator, IntegerConstantExpression})); } -void ParserTester::case3036() -{ - +void ParserTester::case3013() { + parseExpression("offsetof ( struct x , y [ 0 ] . z )", + Expectation().AST( + {OffsetOfExpression, TypeName, StructTypeSpecifier, + AbstractDeclarator, OffsetOfDesignator, ArrayDesignator, + IntegerConstantExpression, FieldDesignator})); } -void ParserTester::case3037() -{ +void ParserTester::case3014() {} -} +void ParserTester::case3015() {} -void ParserTester::case3038() -{ +void ParserTester::case3016() {} -} +void ParserTester::case3017() {} -void ParserTester::case3039() -{ +void ParserTester::case3018() {} -} - -void ParserTester::case3040() -{ +void ParserTester::case3019() {} +void ParserTester::case3020() { + parseExpression("__func__", Expectation().AST({PredefinedName})); } -void ParserTester::case3041() -{ - +void ParserTester::case3021() { + parseExpression("(__func__)", + Expectation().AST({ParenthesizedExpression, PredefinedName})); } -void ParserTester::case3042() -{ - +void ParserTester::case3022() { + parseExpression( + "sizeof( __func__ )", + Expectation().AST({SizeofExpression, ExpressionAsTypeReference, + ParenthesizedExpression, PredefinedName})); } -void ParserTester::case3043() -{ - +void ParserTester::case3023() { + parseExpression( + "sizeof __func__", + Expectation().AST( + {SizeofExpression, ExpressionAsTypeReference, PredefinedName})); } -void ParserTester::case3044() -{ - +void ParserTester::case3024() { + parseExpression("x = __func__", + Expectation().AST({BasicAssignmentExpression, IdentifierName, + PredefinedName})); } -void ParserTester::case3045() -{ +void ParserTester::case3025() {} -} +void ParserTester::case3026() {} -void ParserTester::case3046() -{ +void ParserTester::case3027() {} -} +void ParserTester::case3028() {} -void ParserTester::case3047() -{ +void ParserTester::case3029() {} -} - -void ParserTester::case3048() -{ +void ParserTester::case3030() {} -} +void ParserTester::case3031() {} -void ParserTester::case3049() -{ +void ParserTester::case3032() {} -} +void ParserTester::case3033() {} -void ParserTester::case3050() -{ +void ParserTester::case3034() {} -} +void ParserTester::case3035() {} -void ParserTester::case3051() -{ +void ParserTester::case3036() {} -} +void ParserTester::case3037() {} -void ParserTester::case3052() -{ +void ParserTester::case3038() {} -} +void ParserTester::case3039() {} -void ParserTester::case3053() -{ +void ParserTester::case3040() {} -} +void ParserTester::case3041() {} -void ParserTester::case3054() -{ +void ParserTester::case3042() {} -} +void ParserTester::case3043() {} -void ParserTester::case3055() -{ +void ParserTester::case3044() {} -} +void ParserTester::case3045() {} -void ParserTester::case3056() -{ +void ParserTester::case3046() {} -} +void ParserTester::case3047() {} -void ParserTester::case3057() -{ +void ParserTester::case3048() {} -} +void ParserTester::case3049() {} -void ParserTester::case3058() -{ +void ParserTester::case3050() {} -} +void ParserTester::case3051() {} -void ParserTester::case3059() -{ +void ParserTester::case3052() {} -} +void ParserTester::case3053() {} -void ParserTester::case3060() -{ +void ParserTester::case3054() {} -} +void ParserTester::case3055() {} -void ParserTester::case3061() -{ +void ParserTester::case3056() {} -} +void ParserTester::case3057() {} -void ParserTester::case3062() -{ +void ParserTester::case3058() {} -} +void ParserTester::case3059() {} -void ParserTester::case3063() -{ -} +void ParserTester::case3060() {} -void ParserTester::case3064() -{ -} +void ParserTester::case3061() {} -void ParserTester::case3065() -{ +void ParserTester::case3062() {} -} +void ParserTester::case3063() {} -void ParserTester::case3066() -{ +void ParserTester::case3064() {} -} +void ParserTester::case3065() {} -void ParserTester::case3067() -{ +void ParserTester::case3066() {} -} +void ParserTester::case3067() {} -void ParserTester::case3068() -{ -} +void ParserTester::case3068() {} -void ParserTester::case3069() -{ -} +void ParserTester::case3069() {} -void ParserTester::case3070() -{ -} +void ParserTester::case3070() {} -void ParserTester::case3071() -{ -} +void ParserTester::case3071() {} -void ParserTester::case3072() -{ -} +void ParserTester::case3072() {} -void ParserTester::case3073() -{ -} +void ParserTester::case3073() {} void ParserTester::case3074() {} void ParserTester::case3075() {} @@ -467,41 +254,21 @@ void ParserTester::case3097() {} void ParserTester::case3098() {} void ParserTester::case3099() {} -void ParserTester::case3100() -{ +void ParserTester::case3100() {} -} +void ParserTester::case3101() {} -void ParserTester::case3101() -{ +void ParserTester::case3102() {} -} +void ParserTester::case3103() {} -void ParserTester::case3102() -{ +void ParserTester::case3104() {} -} +void ParserTester::case3105() {} -void ParserTester::case3103() -{ +void ParserTester::case3106() {} -} - -void ParserTester::case3104() -{ -} - -void ParserTester::case3105() -{ -} - -void ParserTester::case3106() -{ -} - -void ParserTester::case3107() -{ -} +void ParserTester::case3107() {} void ParserTester::case3108() {} void ParserTester::case3109() {} @@ -596,37 +363,21 @@ void ParserTester::case3197() {} void ParserTester::case3198() {} void ParserTester::case3199() {} -void ParserTester::case3200() -{ -} +void ParserTester::case3200() {} -void ParserTester::case3201() -{ -} +void ParserTester::case3201() {} -void ParserTester::case3202() -{ -} +void ParserTester::case3202() {} -void ParserTester::case3203() -{ -} +void ParserTester::case3203() {} -void ParserTester::case3204() -{ -} +void ParserTester::case3204() {} -void ParserTester::case3205() -{ -} +void ParserTester::case3205() {} -void ParserTester::case3206() -{ -} +void ParserTester::case3206() {} -void ParserTester::case3207() -{ -} +void ParserTester::case3207() {} void ParserTester::case3208() {} void ParserTester::case3209() {} void ParserTester::case3210() {} @@ -720,37 +471,21 @@ void ParserTester::case3297() {} void ParserTester::case3298() {} void ParserTester::case3299() {} -void ParserTester::case3300() -{ -} +void ParserTester::case3300() {} -void ParserTester::case3301() -{ -} +void ParserTester::case3301() {} -void ParserTester::case3302() -{ -} +void ParserTester::case3302() {} -void ParserTester::case3303() -{ -} +void ParserTester::case3303() {} -void ParserTester::case3304() -{ -} +void ParserTester::case3304() {} -void ParserTester::case3305() -{ -} +void ParserTester::case3305() {} -void ParserTester::case3306() -{ -} +void ParserTester::case3306() {} -void ParserTester::case3307() -{ -} +void ParserTester::case3307() {} void ParserTester::case3308() {} void ParserTester::case3309() {} @@ -845,25 +580,15 @@ void ParserTester::case3397() {} void ParserTester::case3398() {} void ParserTester::case3399() {} -void ParserTester::case3400() -{ -} +void ParserTester::case3400() {} -void ParserTester::case3401() -{ -} +void ParserTester::case3401() {} -void ParserTester::case3402() -{ -} +void ParserTester::case3402() {} -void ParserTester::case3403() -{ -} +void ParserTester::case3403() {} -void ParserTester::case3404() -{ -} +void ParserTester::case3404() {} void ParserTester::case3405() {} void ParserTester::case3406() {} void ParserTester::case3407() {} diff --git a/C/tests/ReparserTester.cpp b/C/tests/ReparserTester.cpp index 4f46d8b27..8f81bb722 100644 --- a/C/tests/ReparserTester.cpp +++ b/C/tests/ReparserTester.cpp @@ -25,42 +25,37 @@ using namespace C; const std::string ReparserTester::Name = "REPARSER"; -void ReparserTester::testReparser() -{ - return run(tests_); -} +void ReparserTester::testReparser() { return run(tests_); } -void ReparserTester::reparse_withSyntaxCorrelation(std::string text, Expectation X) -{ - (static_cast(suite_)->reparse_withSyntaxCorrelation(text, X)); +void ReparserTester::reparse_withSyntaxCorrelation(std::string text, + Expectation X) { + (static_cast(suite_)->reparse_withSyntaxCorrelation( + text, X)); } -void ReparserTester::reparse_withTypeSynonymVerification(std::string text, Expectation X) -{ - (static_cast(suite_)->reparse_withTypeSynonymVerification(text, X)); +void ReparserTester::reparse_withTypeSynonymVerification(std::string text, + Expectation X) { + (static_cast(suite_) + ->reparse_withTypeSynonymVerification(text, X)); } -void ReparserTester::reparse_withGuidelineImposition(std::string text, Expectation X) -{ - (static_cast(suite_)->reparse_withGuidelineImposition(text, X)); +void ReparserTester::reparse_withGuidelineImposition(std::string text, + Expectation X) { + (static_cast(suite_)->reparse_withGuidelineImposition( + text, X)); } -static std::vector body(std::vector&& v) -{ - std::vector w = { TranslationUnit, - FunctionDefinition, - BuiltinTypeSpecifier, - FunctionDeclarator, - IdentifierDeclarator, - ParameterSuffix, - CompoundStatement }; - w.insert(w.end(), v.begin(), v.end()); - return w; +static std::vector body(std::vector &&v) { + std::vector w = {TranslationUnit, FunctionDefinition, + BuiltinTypeSpecifier, FunctionDeclarator, + IdentifierDeclarator, ParameterSuffix, + CompoundStatement}; + w.insert(w.end(), v.begin(), v.end()); + return w; } -void ReparserTester::case0001() -{ - auto s = R"( +void ReparserTester::case0001() { + auto s = R"( int _ ( ) { x z ; @@ -68,22 +63,16 @@ int _ ( ) } )"; - reparse_withSyntaxCorrelation( - s, - Expectation().AST(body({ DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - PointerDeclarator, - IdentifierDeclarator }))); + reparse_withSyntaxCorrelation( + s, Expectation().AST( + body({DeclarationStatement, VariableAndOrFunctionDeclaration, + TypedefName, IdentifierDeclarator, DeclarationStatement, + VariableAndOrFunctionDeclaration, TypedefName, + PointerDeclarator, IdentifierDeclarator}))); } -void ReparserTester::case0002() -{ - auto s = R"( +void ReparserTester::case0002() { + auto s = R"( int _ ( ) { x * y ; @@ -91,22 +80,16 @@ int _ ( ) } )"; - reparse_withSyntaxCorrelation( - s, - Expectation().AST(body({ DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - PointerDeclarator, - IdentifierDeclarator, - DeclarationStatement, - VariableAndOrFunctionDeclaration, - TypedefName, - IdentifierDeclarator }))); + reparse_withSyntaxCorrelation( + s, Expectation().AST( + body({DeclarationStatement, VariableAndOrFunctionDeclaration, + TypedefName, PointerDeclarator, IdentifierDeclarator, + DeclarationStatement, VariableAndOrFunctionDeclaration, + TypedefName, IdentifierDeclarator}))); } -void ReparserTester::case0003() -{ - auto s = R"( +void ReparserTester::case0003() { + auto s = R"( int _ ( ) { x * y ; @@ -114,21 +97,15 @@ int _ ( ) } )"; - reparse_withSyntaxCorrelation( - s, - Expectation().AST(body({ ExpressionStatement, - MultiplyExpression, - IdentifierName, - IdentifierName, - ExpressionStatement, - AddExpression, - IdentifierName, - IdentifierName }))); + reparse_withSyntaxCorrelation( + s, Expectation().AST( + body({ExpressionStatement, MultiplyExpression, IdentifierName, + IdentifierName, ExpressionStatement, AddExpression, + IdentifierName, IdentifierName}))); } -void ReparserTester::case0004() -{ - auto s = R"( +void ReparserTester::case0004() { + auto s = R"( int _ ( ) { x + y ; @@ -136,312 +113,307 @@ int _ ( ) } )"; - reparse_withSyntaxCorrelation( - s, - Expectation().AST(body({ ExpressionStatement, - AddExpression, - IdentifierName, - IdentifierName, - ExpressionStatement, - MultiplyExpression, - IdentifierName, - IdentifierName }))); + reparse_withSyntaxCorrelation( + s, Expectation().AST( + body({ExpressionStatement, AddExpression, IdentifierName, + IdentifierName, ExpressionStatement, MultiplyExpression, + IdentifierName, IdentifierName}))); } -void ReparserTester::case0005(){} -void ReparserTester::case0006(){} -void ReparserTester::case0007(){} -void ReparserTester::case0008(){} -void ReparserTester::case0009(){} -void ReparserTester::case0010(){} -void ReparserTester::case0011(){} -void ReparserTester::case0012(){} -void ReparserTester::case0013(){} -void ReparserTester::case0014(){} -void ReparserTester::case0015(){} -void ReparserTester::case0016(){} -void ReparserTester::case0017(){} -void ReparserTester::case0018(){} -void ReparserTester::case0019(){} -void ReparserTester::case0020(){} -void ReparserTester::case0021(){} -void ReparserTester::case0022(){} -void ReparserTester::case0023(){} -void ReparserTester::case0024(){} -void ReparserTester::case0025(){} -void ReparserTester::case0026(){} -void ReparserTester::case0027(){} -void ReparserTester::case0028(){} -void ReparserTester::case0029(){} -void ReparserTester::case0030(){} -void ReparserTester::case0031(){} -void ReparserTester::case0032(){} -void ReparserTester::case0033(){} -void ReparserTester::case0034(){} -void ReparserTester::case0035(){} -void ReparserTester::case0036(){} -void ReparserTester::case0037(){} -void ReparserTester::case0038(){} -void ReparserTester::case0039(){} -void ReparserTester::case0040(){} -void ReparserTester::case0041(){} -void ReparserTester::case0042(){} -void ReparserTester::case0043(){} -void ReparserTester::case0044(){} -void ReparserTester::case0045(){} -void ReparserTester::case0046(){} -void ReparserTester::case0047(){} -void ReparserTester::case0048(){} -void ReparserTester::case0049(){} -void ReparserTester::case0050(){} -void ReparserTester::case0051(){} -void ReparserTester::case0052(){} -void ReparserTester::case0053(){} -void ReparserTester::case0054(){} -void ReparserTester::case0055(){} -void ReparserTester::case0056(){} -void ReparserTester::case0057(){} -void ReparserTester::case0058(){} -void ReparserTester::case0059(){} -void ReparserTester::case0060(){} -void ReparserTester::case0061(){} -void ReparserTester::case0062(){} -void ReparserTester::case0063(){} -void ReparserTester::case0064(){} -void ReparserTester::case0065(){} -void ReparserTester::case0066(){} -void ReparserTester::case0067(){} -void ReparserTester::case0068(){} -void ReparserTester::case0069(){} -void ReparserTester::case0070(){} -void ReparserTester::case0071(){} -void ReparserTester::case0072(){} -void ReparserTester::case0073(){} -void ReparserTester::case0074(){} -void ReparserTester::case0075(){} -void ReparserTester::case0076(){} -void ReparserTester::case0077(){} -void ReparserTester::case0078(){} -void ReparserTester::case0079(){} -void ReparserTester::case0080(){} -void ReparserTester::case0081(){} -void ReparserTester::case0082(){} -void ReparserTester::case0083(){} -void ReparserTester::case0084(){} -void ReparserTester::case0085(){} -void ReparserTester::case0086(){} -void ReparserTester::case0087(){} -void ReparserTester::case0088(){} -void ReparserTester::case0089(){} -void ReparserTester::case0090(){} -void ReparserTester::case0091(){} -void ReparserTester::case0092(){} -void ReparserTester::case0093(){} -void ReparserTester::case0094(){} -void ReparserTester::case0095(){} -void ReparserTester::case0096(){} -void ReparserTester::case0097(){} -void ReparserTester::case0098(){} -void ReparserTester::case0099(){} +void ReparserTester::case0005() {} +void ReparserTester::case0006() {} +void ReparserTester::case0007() {} +void ReparserTester::case0008() {} +void ReparserTester::case0009() {} +void ReparserTester::case0010() {} +void ReparserTester::case0011() {} +void ReparserTester::case0012() {} +void ReparserTester::case0013() {} +void ReparserTester::case0014() {} +void ReparserTester::case0015() {} +void ReparserTester::case0016() {} +void ReparserTester::case0017() {} +void ReparserTester::case0018() {} +void ReparserTester::case0019() {} +void ReparserTester::case0020() {} +void ReparserTester::case0021() {} +void ReparserTester::case0022() {} +void ReparserTester::case0023() {} +void ReparserTester::case0024() {} +void ReparserTester::case0025() {} +void ReparserTester::case0026() {} +void ReparserTester::case0027() {} +void ReparserTester::case0028() {} +void ReparserTester::case0029() {} +void ReparserTester::case0030() {} +void ReparserTester::case0031() {} +void ReparserTester::case0032() {} +void ReparserTester::case0033() {} +void ReparserTester::case0034() {} +void ReparserTester::case0035() {} +void ReparserTester::case0036() {} +void ReparserTester::case0037() {} +void ReparserTester::case0038() {} +void ReparserTester::case0039() {} +void ReparserTester::case0040() {} +void ReparserTester::case0041() {} +void ReparserTester::case0042() {} +void ReparserTester::case0043() {} +void ReparserTester::case0044() {} +void ReparserTester::case0045() {} +void ReparserTester::case0046() {} +void ReparserTester::case0047() {} +void ReparserTester::case0048() {} +void ReparserTester::case0049() {} +void ReparserTester::case0050() {} +void ReparserTester::case0051() {} +void ReparserTester::case0052() {} +void ReparserTester::case0053() {} +void ReparserTester::case0054() {} +void ReparserTester::case0055() {} +void ReparserTester::case0056() {} +void ReparserTester::case0057() {} +void ReparserTester::case0058() {} +void ReparserTester::case0059() {} +void ReparserTester::case0060() {} +void ReparserTester::case0061() {} +void ReparserTester::case0062() {} +void ReparserTester::case0063() {} +void ReparserTester::case0064() {} +void ReparserTester::case0065() {} +void ReparserTester::case0066() {} +void ReparserTester::case0067() {} +void ReparserTester::case0068() {} +void ReparserTester::case0069() {} +void ReparserTester::case0070() {} +void ReparserTester::case0071() {} +void ReparserTester::case0072() {} +void ReparserTester::case0073() {} +void ReparserTester::case0074() {} +void ReparserTester::case0075() {} +void ReparserTester::case0076() {} +void ReparserTester::case0077() {} +void ReparserTester::case0078() {} +void ReparserTester::case0079() {} +void ReparserTester::case0080() {} +void ReparserTester::case0081() {} +void ReparserTester::case0082() {} +void ReparserTester::case0083() {} +void ReparserTester::case0084() {} +void ReparserTester::case0085() {} +void ReparserTester::case0086() {} +void ReparserTester::case0087() {} +void ReparserTester::case0088() {} +void ReparserTester::case0089() {} +void ReparserTester::case0090() {} +void ReparserTester::case0091() {} +void ReparserTester::case0092() {} +void ReparserTester::case0093() {} +void ReparserTester::case0094() {} +void ReparserTester::case0095() {} +void ReparserTester::case0096() {} +void ReparserTester::case0097() {} +void ReparserTester::case0098() {} +void ReparserTester::case0099() {} -void ReparserTester::case0100(){} -void ReparserTester::case0101(){} -void ReparserTester::case0102(){} -void ReparserTester::case0103(){} -void ReparserTester::case0104(){} -void ReparserTester::case0105(){} -void ReparserTester::case0106(){} -void ReparserTester::case0107(){} -void ReparserTester::case0108(){} -void ReparserTester::case0109(){} -void ReparserTester::case0110(){} -void ReparserTester::case0111(){} -void ReparserTester::case0112(){} -void ReparserTester::case0113(){} -void ReparserTester::case0114(){} -void ReparserTester::case0115(){} -void ReparserTester::case0116(){} -void ReparserTester::case0117(){} -void ReparserTester::case0118(){} -void ReparserTester::case0119(){} -void ReparserTester::case0120(){} -void ReparserTester::case0121(){} -void ReparserTester::case0122(){} -void ReparserTester::case0123(){} -void ReparserTester::case0124(){} -void ReparserTester::case0125(){} -void ReparserTester::case0126(){} -void ReparserTester::case0127(){} -void ReparserTester::case0128(){} -void ReparserTester::case0129(){} -void ReparserTester::case0130(){} -void ReparserTester::case0131(){} -void ReparserTester::case0132(){} -void ReparserTester::case0133(){} -void ReparserTester::case0134(){} -void ReparserTester::case0135(){} -void ReparserTester::case0136(){} -void ReparserTester::case0137(){} -void ReparserTester::case0138(){} -void ReparserTester::case0139(){} -void ReparserTester::case0140(){} -void ReparserTester::case0141(){} -void ReparserTester::case0142(){} -void ReparserTester::case0143(){} -void ReparserTester::case0144(){} -void ReparserTester::case0145(){} -void ReparserTester::case0146(){} -void ReparserTester::case0147(){} -void ReparserTester::case0148(){} -void ReparserTester::case0149(){} -void ReparserTester::case0150(){} -void ReparserTester::case0151(){} -void ReparserTester::case0152(){} -void ReparserTester::case0153(){} -void ReparserTester::case0154(){} -void ReparserTester::case0155(){} -void ReparserTester::case0156(){} -void ReparserTester::case0157(){} -void ReparserTester::case0158(){} -void ReparserTester::case0159(){} -void ReparserTester::case0160(){} -void ReparserTester::case0161(){} -void ReparserTester::case0162(){} -void ReparserTester::case0163(){} -void ReparserTester::case0164(){} -void ReparserTester::case0165(){} -void ReparserTester::case0166(){} -void ReparserTester::case0167(){} -void ReparserTester::case0168(){} -void ReparserTester::case0169(){} -void ReparserTester::case0170(){} -void ReparserTester::case0171(){} -void ReparserTester::case0172(){} -void ReparserTester::case0173(){} -void ReparserTester::case0174(){} -void ReparserTester::case0175(){} -void ReparserTester::case0176(){} -void ReparserTester::case0177(){} -void ReparserTester::case0178(){} -void ReparserTester::case0179(){} -void ReparserTester::case0180(){} -void ReparserTester::case0181(){} -void ReparserTester::case0182(){} -void ReparserTester::case0183(){} -void ReparserTester::case0184(){} -void ReparserTester::case0185(){} -void ReparserTester::case0186(){} -void ReparserTester::case0187(){} -void ReparserTester::case0188(){} -void ReparserTester::case0189(){} -void ReparserTester::case0190(){} -void ReparserTester::case0191(){} -void ReparserTester::case0192(){} -void ReparserTester::case0193(){} -void ReparserTester::case0194(){} -void ReparserTester::case0195(){} -void ReparserTester::case0196(){} -void ReparserTester::case0197(){} -void ReparserTester::case0198(){} -void ReparserTester::case0199(){} +void ReparserTester::case0100() {} +void ReparserTester::case0101() {} +void ReparserTester::case0102() {} +void ReparserTester::case0103() {} +void ReparserTester::case0104() {} +void ReparserTester::case0105() {} +void ReparserTester::case0106() {} +void ReparserTester::case0107() {} +void ReparserTester::case0108() {} +void ReparserTester::case0109() {} +void ReparserTester::case0110() {} +void ReparserTester::case0111() {} +void ReparserTester::case0112() {} +void ReparserTester::case0113() {} +void ReparserTester::case0114() {} +void ReparserTester::case0115() {} +void ReparserTester::case0116() {} +void ReparserTester::case0117() {} +void ReparserTester::case0118() {} +void ReparserTester::case0119() {} +void ReparserTester::case0120() {} +void ReparserTester::case0121() {} +void ReparserTester::case0122() {} +void ReparserTester::case0123() {} +void ReparserTester::case0124() {} +void ReparserTester::case0125() {} +void ReparserTester::case0126() {} +void ReparserTester::case0127() {} +void ReparserTester::case0128() {} +void ReparserTester::case0129() {} +void ReparserTester::case0130() {} +void ReparserTester::case0131() {} +void ReparserTester::case0132() {} +void ReparserTester::case0133() {} +void ReparserTester::case0134() {} +void ReparserTester::case0135() {} +void ReparserTester::case0136() {} +void ReparserTester::case0137() {} +void ReparserTester::case0138() {} +void ReparserTester::case0139() {} +void ReparserTester::case0140() {} +void ReparserTester::case0141() {} +void ReparserTester::case0142() {} +void ReparserTester::case0143() {} +void ReparserTester::case0144() {} +void ReparserTester::case0145() {} +void ReparserTester::case0146() {} +void ReparserTester::case0147() {} +void ReparserTester::case0148() {} +void ReparserTester::case0149() {} +void ReparserTester::case0150() {} +void ReparserTester::case0151() {} +void ReparserTester::case0152() {} +void ReparserTester::case0153() {} +void ReparserTester::case0154() {} +void ReparserTester::case0155() {} +void ReparserTester::case0156() {} +void ReparserTester::case0157() {} +void ReparserTester::case0158() {} +void ReparserTester::case0159() {} +void ReparserTester::case0160() {} +void ReparserTester::case0161() {} +void ReparserTester::case0162() {} +void ReparserTester::case0163() {} +void ReparserTester::case0164() {} +void ReparserTester::case0165() {} +void ReparserTester::case0166() {} +void ReparserTester::case0167() {} +void ReparserTester::case0168() {} +void ReparserTester::case0169() {} +void ReparserTester::case0170() {} +void ReparserTester::case0171() {} +void ReparserTester::case0172() {} +void ReparserTester::case0173() {} +void ReparserTester::case0174() {} +void ReparserTester::case0175() {} +void ReparserTester::case0176() {} +void ReparserTester::case0177() {} +void ReparserTester::case0178() {} +void ReparserTester::case0179() {} +void ReparserTester::case0180() {} +void ReparserTester::case0181() {} +void ReparserTester::case0182() {} +void ReparserTester::case0183() {} +void ReparserTester::case0184() {} +void ReparserTester::case0185() {} +void ReparserTester::case0186() {} +void ReparserTester::case0187() {} +void ReparserTester::case0188() {} +void ReparserTester::case0189() {} +void ReparserTester::case0190() {} +void ReparserTester::case0191() {} +void ReparserTester::case0192() {} +void ReparserTester::case0193() {} +void ReparserTester::case0194() {} +void ReparserTester::case0195() {} +void ReparserTester::case0196() {} +void ReparserTester::case0197() {} +void ReparserTester::case0198() {} +void ReparserTester::case0199() {} -void ReparserTester::case0200(){} -void ReparserTester::case0201(){} -void ReparserTester::case0202(){} -void ReparserTester::case0203(){} -void ReparserTester::case0204(){} -void ReparserTester::case0205(){} -void ReparserTester::case0206(){} -void ReparserTester::case0207(){} -void ReparserTester::case0208(){} -void ReparserTester::case0209(){} -void ReparserTester::case0210(){} -void ReparserTester::case0211(){} -void ReparserTester::case0212(){} -void ReparserTester::case0213(){} -void ReparserTester::case0214(){} -void ReparserTester::case0215(){} -void ReparserTester::case0216(){} -void ReparserTester::case0217(){} -void ReparserTester::case0218(){} -void ReparserTester::case0219(){} -void ReparserTester::case0220(){} -void ReparserTester::case0221(){} -void ReparserTester::case0222(){} -void ReparserTester::case0223(){} -void ReparserTester::case0224(){} -void ReparserTester::case0225(){} -void ReparserTester::case0226(){} -void ReparserTester::case0227(){} -void ReparserTester::case0228(){} -void ReparserTester::case0229(){} -void ReparserTester::case0230(){} -void ReparserTester::case0231(){} -void ReparserTester::case0232(){} -void ReparserTester::case0233(){} -void ReparserTester::case0234(){} -void ReparserTester::case0235(){} -void ReparserTester::case0236(){} -void ReparserTester::case0237(){} -void ReparserTester::case0238(){} -void ReparserTester::case0239(){} -void ReparserTester::case0240(){} -void ReparserTester::case0241(){} -void ReparserTester::case0242(){} -void ReparserTester::case0243(){} -void ReparserTester::case0244(){} -void ReparserTester::case0245(){} -void ReparserTester::case0246(){} -void ReparserTester::case0247(){} -void ReparserTester::case0248(){} -void ReparserTester::case0249(){} -void ReparserTester::case0250(){} -void ReparserTester::case0251(){} -void ReparserTester::case0252(){} -void ReparserTester::case0253(){} -void ReparserTester::case0254(){} -void ReparserTester::case0255(){} -void ReparserTester::case0256(){} -void ReparserTester::case0257(){} -void ReparserTester::case0258(){} -void ReparserTester::case0259(){} -void ReparserTester::case0260(){} -void ReparserTester::case0261(){} -void ReparserTester::case0262(){} -void ReparserTester::case0263(){} -void ReparserTester::case0264(){} -void ReparserTester::case0265(){} -void ReparserTester::case0266(){} -void ReparserTester::case0267(){} -void ReparserTester::case0268(){} -void ReparserTester::case0269(){} -void ReparserTester::case0270(){} -void ReparserTester::case0271(){} -void ReparserTester::case0272(){} -void ReparserTester::case0273(){} -void ReparserTester::case0274(){} -void ReparserTester::case0275(){} -void ReparserTester::case0276(){} -void ReparserTester::case0277(){} -void ReparserTester::case0278(){} -void ReparserTester::case0279(){} -void ReparserTester::case0280(){} -void ReparserTester::case0281(){} -void ReparserTester::case0282(){} -void ReparserTester::case0283(){} -void ReparserTester::case0284(){} -void ReparserTester::case0285(){} -void ReparserTester::case0286(){} -void ReparserTester::case0287(){} -void ReparserTester::case0288(){} -void ReparserTester::case0289(){} -void ReparserTester::case0290(){} -void ReparserTester::case0291(){} -void ReparserTester::case0292(){} -void ReparserTester::case0293(){} -void ReparserTester::case0294(){} -void ReparserTester::case0295(){} -void ReparserTester::case0296(){} -void ReparserTester::case0297(){} -void ReparserTester::case0298(){} -void ReparserTester::case0299(){} +void ReparserTester::case0200() {} +void ReparserTester::case0201() {} +void ReparserTester::case0202() {} +void ReparserTester::case0203() {} +void ReparserTester::case0204() {} +void ReparserTester::case0205() {} +void ReparserTester::case0206() {} +void ReparserTester::case0207() {} +void ReparserTester::case0208() {} +void ReparserTester::case0209() {} +void ReparserTester::case0210() {} +void ReparserTester::case0211() {} +void ReparserTester::case0212() {} +void ReparserTester::case0213() {} +void ReparserTester::case0214() {} +void ReparserTester::case0215() {} +void ReparserTester::case0216() {} +void ReparserTester::case0217() {} +void ReparserTester::case0218() {} +void ReparserTester::case0219() {} +void ReparserTester::case0220() {} +void ReparserTester::case0221() {} +void ReparserTester::case0222() {} +void ReparserTester::case0223() {} +void ReparserTester::case0224() {} +void ReparserTester::case0225() {} +void ReparserTester::case0226() {} +void ReparserTester::case0227() {} +void ReparserTester::case0228() {} +void ReparserTester::case0229() {} +void ReparserTester::case0230() {} +void ReparserTester::case0231() {} +void ReparserTester::case0232() {} +void ReparserTester::case0233() {} +void ReparserTester::case0234() {} +void ReparserTester::case0235() {} +void ReparserTester::case0236() {} +void ReparserTester::case0237() {} +void ReparserTester::case0238() {} +void ReparserTester::case0239() {} +void ReparserTester::case0240() {} +void ReparserTester::case0241() {} +void ReparserTester::case0242() {} +void ReparserTester::case0243() {} +void ReparserTester::case0244() {} +void ReparserTester::case0245() {} +void ReparserTester::case0246() {} +void ReparserTester::case0247() {} +void ReparserTester::case0248() {} +void ReparserTester::case0249() {} +void ReparserTester::case0250() {} +void ReparserTester::case0251() {} +void ReparserTester::case0252() {} +void ReparserTester::case0253() {} +void ReparserTester::case0254() {} +void ReparserTester::case0255() {} +void ReparserTester::case0256() {} +void ReparserTester::case0257() {} +void ReparserTester::case0258() {} +void ReparserTester::case0259() {} +void ReparserTester::case0260() {} +void ReparserTester::case0261() {} +void ReparserTester::case0262() {} +void ReparserTester::case0263() {} +void ReparserTester::case0264() {} +void ReparserTester::case0265() {} +void ReparserTester::case0266() {} +void ReparserTester::case0267() {} +void ReparserTester::case0268() {} +void ReparserTester::case0269() {} +void ReparserTester::case0270() {} +void ReparserTester::case0271() {} +void ReparserTester::case0272() {} +void ReparserTester::case0273() {} +void ReparserTester::case0274() {} +void ReparserTester::case0275() {} +void ReparserTester::case0276() {} +void ReparserTester::case0277() {} +void ReparserTester::case0278() {} +void ReparserTester::case0279() {} +void ReparserTester::case0280() {} +void ReparserTester::case0281() {} +void ReparserTester::case0282() {} +void ReparserTester::case0283() {} +void ReparserTester::case0284() {} +void ReparserTester::case0285() {} +void ReparserTester::case0286() {} +void ReparserTester::case0287() {} +void ReparserTester::case0288() {} +void ReparserTester::case0289() {} +void ReparserTester::case0290() {} +void ReparserTester::case0291() {} +void ReparserTester::case0292() {} +void ReparserTester::case0293() {} +void ReparserTester::case0294() {} +void ReparserTester::case0295() {} +void ReparserTester::case0296() {} +void ReparserTester::case0297() {} +void ReparserTester::case0298() {} +void ReparserTester::case0299() {} diff --git a/C/tests/ReparserTester.h b/C/tests/ReparserTester.h index 82a99f450..2176895f6 100644 --- a/C/tests/ReparserTester.h +++ b/C/tests/ReparserTester.h @@ -25,648 +25,451 @@ #include "TestSuite_Internals.h" #include "tests/Tester.h" -#define TEST_REPARSER(Function) TestFunction { &ReparserTester::Function, #Function } +#define TEST_REPARSER(Function) \ + TestFunction { &ReparserTester::Function, #Function } namespace psy { namespace C { -class ReparserTester final : public Tester -{ +class ReparserTester final : public Tester { public: - ReparserTester(TestSuite* suite) - : Tester(suite) - {} + ReparserTester(TestSuite *suite) : Tester(suite) {} - static const std::string Name; - virtual std::string name() const override { return Name; } + static const std::string Name; + virtual std::string name() const override { return Name; } - void testReparser(); + void testReparser(); - void reparse_withSyntaxCorrelation(std::string text, Expectation X = Expectation()); - void reparse_withTypeSynonymVerification(std::string text, Expectation X = Expectation()); - void reparse_withGuidelineImposition(std::string text, Expectation X = Expectation()); + void reparse_withSyntaxCorrelation(std::string text, + Expectation X = Expectation()); + void reparse_withTypeSynonymVerification(std::string text, + Expectation X = Expectation()); + void reparse_withGuidelineImposition(std::string text, + Expectation X = Expectation()); - using TestFunction = std::pair, const char*>; + using TestFunction = + std::pair, const char *>; - /* - Syntax Correlation - + 0000-0019 -> multiplication x pointer declaration - + 0020-0039 -> call x variable declaration - + 0040-0059 -> cast x binary expression - + 0060-0069 -> type name x expression (as type reference) + /* + Syntax Correlation + + 0000-0019 -> multiplication x pointer declaration + + 0020-0039 -> call x variable declaration + + 0040-0059 -> cast x binary expression + + 0060-0069 -> type name x expression (as type reference) - */ + */ - void case0001(); - void case0002(); - void case0003(); - void case0004(); - void case0005(); - void case0006(); - void case0007(); - void case0008(); - void case0009(); - void case0010(); - void case0011(); - void case0012(); - void case0013(); - void case0014(); - void case0015(); - void case0016(); - void case0017(); - void case0018(); - void case0019(); - void case0020(); - void case0021(); - void case0022(); - void case0023(); - void case0024(); - void case0025(); - void case0026(); - void case0027(); - void case0028(); - void case0029(); - void case0030(); - void case0031(); - void case0032(); - void case0033(); - void case0034(); - void case0035(); - void case0036(); - void case0037(); - void case0038(); - void case0039(); - void case0040(); - void case0041(); - void case0042(); - void case0043(); - void case0044(); - void case0045(); - void case0046(); - void case0047(); - void case0048(); - void case0049(); - void case0050(); - void case0051(); - void case0052(); - void case0053(); - void case0054(); - void case0055(); - void case0056(); - void case0057(); - void case0058(); - void case0059(); - void case0060(); - void case0061(); - void case0062(); - void case0063(); - void case0064(); - void case0065(); - void case0066(); - void case0067(); - void case0068(); - void case0069(); - void case0070(); - void case0071(); - void case0072(); - void case0073(); - void case0074(); - void case0075(); - void case0076(); - void case0077(); - void case0078(); - void case0079(); - void case0080(); - void case0081(); - void case0082(); - void case0083(); - void case0084(); - void case0085(); - void case0086(); - void case0087(); - void case0088(); - void case0089(); - void case0090(); - void case0091(); - void case0092(); - void case0093(); - void case0094(); - void case0095(); - void case0096(); - void case0097(); - void case0098(); - void case0099(); + void case0001(); + void case0002(); + void case0003(); + void case0004(); + void case0005(); + void case0006(); + void case0007(); + void case0008(); + void case0009(); + void case0010(); + void case0011(); + void case0012(); + void case0013(); + void case0014(); + void case0015(); + void case0016(); + void case0017(); + void case0018(); + void case0019(); + void case0020(); + void case0021(); + void case0022(); + void case0023(); + void case0024(); + void case0025(); + void case0026(); + void case0027(); + void case0028(); + void case0029(); + void case0030(); + void case0031(); + void case0032(); + void case0033(); + void case0034(); + void case0035(); + void case0036(); + void case0037(); + void case0038(); + void case0039(); + void case0040(); + void case0041(); + void case0042(); + void case0043(); + void case0044(); + void case0045(); + void case0046(); + void case0047(); + void case0048(); + void case0049(); + void case0050(); + void case0051(); + void case0052(); + void case0053(); + void case0054(); + void case0055(); + void case0056(); + void case0057(); + void case0058(); + void case0059(); + void case0060(); + void case0061(); + void case0062(); + void case0063(); + void case0064(); + void case0065(); + void case0066(); + void case0067(); + void case0068(); + void case0069(); + void case0070(); + void case0071(); + void case0072(); + void case0073(); + void case0074(); + void case0075(); + void case0076(); + void case0077(); + void case0078(); + void case0079(); + void case0080(); + void case0081(); + void case0082(); + void case0083(); + void case0084(); + void case0085(); + void case0086(); + void case0087(); + void case0088(); + void case0089(); + void case0090(); + void case0091(); + void case0092(); + void case0093(); + void case0094(); + void case0095(); + void case0096(); + void case0097(); + void case0098(); + void case0099(); - void case0100(); - void case0101(); - void case0102(); - void case0103(); - void case0104(); - void case0105(); - void case0106(); - void case0107(); - void case0108(); - void case0109(); - void case0110(); - void case0111(); - void case0112(); - void case0113(); - void case0114(); - void case0115(); - void case0116(); - void case0117(); - void case0118(); - void case0119(); - void case0120(); - void case0121(); - void case0122(); - void case0123(); - void case0124(); - void case0125(); - void case0126(); - void case0127(); - void case0128(); - void case0129(); - void case0130(); - void case0131(); - void case0132(); - void case0133(); - void case0134(); - void case0135(); - void case0136(); - void case0137(); - void case0138(); - void case0139(); - void case0140(); - void case0141(); - void case0142(); - void case0143(); - void case0144(); - void case0145(); - void case0146(); - void case0147(); - void case0148(); - void case0149(); - void case0150(); - void case0151(); - void case0152(); - void case0153(); - void case0154(); - void case0155(); - void case0156(); - void case0157(); - void case0158(); - void case0159(); - void case0160(); - void case0161(); - void case0162(); - void case0163(); - void case0164(); - void case0165(); - void case0166(); - void case0167(); - void case0168(); - void case0169(); - void case0170(); - void case0171(); - void case0172(); - void case0173(); - void case0174(); - void case0175(); - void case0176(); - void case0177(); - void case0178(); - void case0179(); - void case0180(); - void case0181(); - void case0182(); - void case0183(); - void case0184(); - void case0185(); - void case0186(); - void case0187(); - void case0188(); - void case0189(); - void case0190(); - void case0191(); - void case0192(); - void case0193(); - void case0194(); - void case0195(); - void case0196(); - void case0197(); - void case0198(); - void case0199(); + void case0100(); + void case0101(); + void case0102(); + void case0103(); + void case0104(); + void case0105(); + void case0106(); + void case0107(); + void case0108(); + void case0109(); + void case0110(); + void case0111(); + void case0112(); + void case0113(); + void case0114(); + void case0115(); + void case0116(); + void case0117(); + void case0118(); + void case0119(); + void case0120(); + void case0121(); + void case0122(); + void case0123(); + void case0124(); + void case0125(); + void case0126(); + void case0127(); + void case0128(); + void case0129(); + void case0130(); + void case0131(); + void case0132(); + void case0133(); + void case0134(); + void case0135(); + void case0136(); + void case0137(); + void case0138(); + void case0139(); + void case0140(); + void case0141(); + void case0142(); + void case0143(); + void case0144(); + void case0145(); + void case0146(); + void case0147(); + void case0148(); + void case0149(); + void case0150(); + void case0151(); + void case0152(); + void case0153(); + void case0154(); + void case0155(); + void case0156(); + void case0157(); + void case0158(); + void case0159(); + void case0160(); + void case0161(); + void case0162(); + void case0163(); + void case0164(); + void case0165(); + void case0166(); + void case0167(); + void case0168(); + void case0169(); + void case0170(); + void case0171(); + void case0172(); + void case0173(); + void case0174(); + void case0175(); + void case0176(); + void case0177(); + void case0178(); + void case0179(); + void case0180(); + void case0181(); + void case0182(); + void case0183(); + void case0184(); + void case0185(); + void case0186(); + void case0187(); + void case0188(); + void case0189(); + void case0190(); + void case0191(); + void case0192(); + void case0193(); + void case0194(); + void case0195(); + void case0196(); + void case0197(); + void case0198(); + void case0199(); - void case0200(); - void case0201(); - void case0202(); - void case0203(); - void case0204(); - void case0205(); - void case0206(); - void case0207(); - void case0208(); - void case0209(); - void case0210(); - void case0211(); - void case0212(); - void case0213(); - void case0214(); - void case0215(); - void case0216(); - void case0217(); - void case0218(); - void case0219(); - void case0220(); - void case0221(); - void case0222(); - void case0223(); - void case0224(); - void case0225(); - void case0226(); - void case0227(); - void case0228(); - void case0229(); - void case0230(); - void case0231(); - void case0232(); - void case0233(); - void case0234(); - void case0235(); - void case0236(); - void case0237(); - void case0238(); - void case0239(); - void case0240(); - void case0241(); - void case0242(); - void case0243(); - void case0244(); - void case0245(); - void case0246(); - void case0247(); - void case0248(); - void case0249(); - void case0250(); - void case0251(); - void case0252(); - void case0253(); - void case0254(); - void case0255(); - void case0256(); - void case0257(); - void case0258(); - void case0259(); - void case0260(); - void case0261(); - void case0262(); - void case0263(); - void case0264(); - void case0265(); - void case0266(); - void case0267(); - void case0268(); - void case0269(); - void case0270(); - void case0271(); - void case0272(); - void case0273(); - void case0274(); - void case0275(); - void case0276(); - void case0277(); - void case0278(); - void case0279(); - void case0280(); - void case0281(); - void case0282(); - void case0283(); - void case0284(); - void case0285(); - void case0286(); - void case0287(); - void case0288(); - void case0289(); - void case0290(); - void case0291(); - void case0292(); - void case0293(); - void case0294(); - void case0295(); - void case0296(); - void case0297(); - void case0298(); - void case0299(); + void case0200(); + void case0201(); + void case0202(); + void case0203(); + void case0204(); + void case0205(); + void case0206(); + void case0207(); + void case0208(); + void case0209(); + void case0210(); + void case0211(); + void case0212(); + void case0213(); + void case0214(); + void case0215(); + void case0216(); + void case0217(); + void case0218(); + void case0219(); + void case0220(); + void case0221(); + void case0222(); + void case0223(); + void case0224(); + void case0225(); + void case0226(); + void case0227(); + void case0228(); + void case0229(); + void case0230(); + void case0231(); + void case0232(); + void case0233(); + void case0234(); + void case0235(); + void case0236(); + void case0237(); + void case0238(); + void case0239(); + void case0240(); + void case0241(); + void case0242(); + void case0243(); + void case0244(); + void case0245(); + void case0246(); + void case0247(); + void case0248(); + void case0249(); + void case0250(); + void case0251(); + void case0252(); + void case0253(); + void case0254(); + void case0255(); + void case0256(); + void case0257(); + void case0258(); + void case0259(); + void case0260(); + void case0261(); + void case0262(); + void case0263(); + void case0264(); + void case0265(); + void case0266(); + void case0267(); + void case0268(); + void case0269(); + void case0270(); + void case0271(); + void case0272(); + void case0273(); + void case0274(); + void case0275(); + void case0276(); + void case0277(); + void case0278(); + void case0279(); + void case0280(); + void case0281(); + void case0282(); + void case0283(); + void case0284(); + void case0285(); + void case0286(); + void case0287(); + void case0288(); + void case0289(); + void case0290(); + void case0291(); + void case0292(); + void case0293(); + void case0294(); + void case0295(); + void case0296(); + void case0297(); + void case0298(); + void case0299(); - std::vector tests_ - { - TEST_REPARSER(case0001), - TEST_REPARSER(case0002), - TEST_REPARSER(case0003), - TEST_REPARSER(case0004), - TEST_REPARSER(case0005), - TEST_REPARSER(case0006), - TEST_REPARSER(case0007), - TEST_REPARSER(case0008), - TEST_REPARSER(case0009), - TEST_REPARSER(case0010), - TEST_REPARSER(case0011), - TEST_REPARSER(case0012), - TEST_REPARSER(case0013), - TEST_REPARSER(case0014), - TEST_REPARSER(case0015), - TEST_REPARSER(case0016), - TEST_REPARSER(case0017), - TEST_REPARSER(case0018), - TEST_REPARSER(case0019), - TEST_REPARSER(case0020), - TEST_REPARSER(case0021), - TEST_REPARSER(case0022), - TEST_REPARSER(case0023), - TEST_REPARSER(case0024), - TEST_REPARSER(case0025), - TEST_REPARSER(case0026), - TEST_REPARSER(case0027), - TEST_REPARSER(case0028), - TEST_REPARSER(case0029), - TEST_REPARSER(case0030), - TEST_REPARSER(case0031), - TEST_REPARSER(case0032), - TEST_REPARSER(case0033), - TEST_REPARSER(case0034), - TEST_REPARSER(case0035), - TEST_REPARSER(case0036), - TEST_REPARSER(case0037), - TEST_REPARSER(case0038), - TEST_REPARSER(case0039), - TEST_REPARSER(case0040), - TEST_REPARSER(case0041), - TEST_REPARSER(case0042), - TEST_REPARSER(case0043), - TEST_REPARSER(case0044), - TEST_REPARSER(case0045), - TEST_REPARSER(case0046), - TEST_REPARSER(case0047), - TEST_REPARSER(case0048), - TEST_REPARSER(case0049), - TEST_REPARSER(case0050), - TEST_REPARSER(case0051), - TEST_REPARSER(case0052), - TEST_REPARSER(case0053), - TEST_REPARSER(case0054), - TEST_REPARSER(case0055), - TEST_REPARSER(case0056), - TEST_REPARSER(case0057), - TEST_REPARSER(case0058), - TEST_REPARSER(case0059), - TEST_REPARSER(case0060), - TEST_REPARSER(case0061), - TEST_REPARSER(case0062), - TEST_REPARSER(case0063), - TEST_REPARSER(case0064), - TEST_REPARSER(case0065), - TEST_REPARSER(case0066), - TEST_REPARSER(case0067), - TEST_REPARSER(case0068), - TEST_REPARSER(case0069), - TEST_REPARSER(case0070), - TEST_REPARSER(case0071), - TEST_REPARSER(case0072), - TEST_REPARSER(case0073), - TEST_REPARSER(case0074), - TEST_REPARSER(case0075), - TEST_REPARSER(case0076), - TEST_REPARSER(case0077), - TEST_REPARSER(case0078), - TEST_REPARSER(case0079), - TEST_REPARSER(case0080), - TEST_REPARSER(case0081), - TEST_REPARSER(case0082), - TEST_REPARSER(case0083), - TEST_REPARSER(case0084), - TEST_REPARSER(case0085), - TEST_REPARSER(case0086), - TEST_REPARSER(case0087), - TEST_REPARSER(case0088), - TEST_REPARSER(case0089), - TEST_REPARSER(case0090), - TEST_REPARSER(case0091), - TEST_REPARSER(case0092), - TEST_REPARSER(case0093), - TEST_REPARSER(case0094), - TEST_REPARSER(case0095), - TEST_REPARSER(case0096), - TEST_REPARSER(case0097), - TEST_REPARSER(case0098), - TEST_REPARSER(case0099), + std::vector tests_{ + TEST_REPARSER(case0001), TEST_REPARSER(case0002), TEST_REPARSER(case0003), + TEST_REPARSER(case0004), TEST_REPARSER(case0005), TEST_REPARSER(case0006), + TEST_REPARSER(case0007), TEST_REPARSER(case0008), TEST_REPARSER(case0009), + TEST_REPARSER(case0010), TEST_REPARSER(case0011), TEST_REPARSER(case0012), + TEST_REPARSER(case0013), TEST_REPARSER(case0014), TEST_REPARSER(case0015), + TEST_REPARSER(case0016), TEST_REPARSER(case0017), TEST_REPARSER(case0018), + TEST_REPARSER(case0019), TEST_REPARSER(case0020), TEST_REPARSER(case0021), + TEST_REPARSER(case0022), TEST_REPARSER(case0023), TEST_REPARSER(case0024), + TEST_REPARSER(case0025), TEST_REPARSER(case0026), TEST_REPARSER(case0027), + TEST_REPARSER(case0028), TEST_REPARSER(case0029), TEST_REPARSER(case0030), + TEST_REPARSER(case0031), TEST_REPARSER(case0032), TEST_REPARSER(case0033), + TEST_REPARSER(case0034), TEST_REPARSER(case0035), TEST_REPARSER(case0036), + TEST_REPARSER(case0037), TEST_REPARSER(case0038), TEST_REPARSER(case0039), + TEST_REPARSER(case0040), TEST_REPARSER(case0041), TEST_REPARSER(case0042), + TEST_REPARSER(case0043), TEST_REPARSER(case0044), TEST_REPARSER(case0045), + TEST_REPARSER(case0046), TEST_REPARSER(case0047), TEST_REPARSER(case0048), + TEST_REPARSER(case0049), TEST_REPARSER(case0050), TEST_REPARSER(case0051), + TEST_REPARSER(case0052), TEST_REPARSER(case0053), TEST_REPARSER(case0054), + TEST_REPARSER(case0055), TEST_REPARSER(case0056), TEST_REPARSER(case0057), + TEST_REPARSER(case0058), TEST_REPARSER(case0059), TEST_REPARSER(case0060), + TEST_REPARSER(case0061), TEST_REPARSER(case0062), TEST_REPARSER(case0063), + TEST_REPARSER(case0064), TEST_REPARSER(case0065), TEST_REPARSER(case0066), + TEST_REPARSER(case0067), TEST_REPARSER(case0068), TEST_REPARSER(case0069), + TEST_REPARSER(case0070), TEST_REPARSER(case0071), TEST_REPARSER(case0072), + TEST_REPARSER(case0073), TEST_REPARSER(case0074), TEST_REPARSER(case0075), + TEST_REPARSER(case0076), TEST_REPARSER(case0077), TEST_REPARSER(case0078), + TEST_REPARSER(case0079), TEST_REPARSER(case0080), TEST_REPARSER(case0081), + TEST_REPARSER(case0082), TEST_REPARSER(case0083), TEST_REPARSER(case0084), + TEST_REPARSER(case0085), TEST_REPARSER(case0086), TEST_REPARSER(case0087), + TEST_REPARSER(case0088), TEST_REPARSER(case0089), TEST_REPARSER(case0090), + TEST_REPARSER(case0091), TEST_REPARSER(case0092), TEST_REPARSER(case0093), + TEST_REPARSER(case0094), TEST_REPARSER(case0095), TEST_REPARSER(case0096), + TEST_REPARSER(case0097), TEST_REPARSER(case0098), TEST_REPARSER(case0099), - TEST_REPARSER(case0100), - TEST_REPARSER(case0101), - TEST_REPARSER(case0102), - TEST_REPARSER(case0103), - TEST_REPARSER(case0104), - TEST_REPARSER(case0105), - TEST_REPARSER(case0106), - TEST_REPARSER(case0107), - TEST_REPARSER(case0108), - TEST_REPARSER(case0109), - TEST_REPARSER(case0110), - TEST_REPARSER(case0111), - TEST_REPARSER(case0112), - TEST_REPARSER(case0113), - TEST_REPARSER(case0114), - TEST_REPARSER(case0115), - TEST_REPARSER(case0116), - TEST_REPARSER(case0117), - TEST_REPARSER(case0118), - TEST_REPARSER(case0119), - TEST_REPARSER(case0120), - TEST_REPARSER(case0121), - TEST_REPARSER(case0122), - TEST_REPARSER(case0123), - TEST_REPARSER(case0124), - TEST_REPARSER(case0125), - TEST_REPARSER(case0126), - TEST_REPARSER(case0127), - TEST_REPARSER(case0128), - TEST_REPARSER(case0129), - TEST_REPARSER(case0130), - TEST_REPARSER(case0131), - TEST_REPARSER(case0132), - TEST_REPARSER(case0133), - TEST_REPARSER(case0134), - TEST_REPARSER(case0135), - TEST_REPARSER(case0136), - TEST_REPARSER(case0137), - TEST_REPARSER(case0138), - TEST_REPARSER(case0139), - TEST_REPARSER(case0140), - TEST_REPARSER(case0141), - TEST_REPARSER(case0142), - TEST_REPARSER(case0143), - TEST_REPARSER(case0144), - TEST_REPARSER(case0145), - TEST_REPARSER(case0146), - TEST_REPARSER(case0147), - TEST_REPARSER(case0148), - TEST_REPARSER(case0149), - TEST_REPARSER(case0150), - TEST_REPARSER(case0151), - TEST_REPARSER(case0152), - TEST_REPARSER(case0153), - TEST_REPARSER(case0154), - TEST_REPARSER(case0155), - TEST_REPARSER(case0156), - TEST_REPARSER(case0157), - TEST_REPARSER(case0158), - TEST_REPARSER(case0159), - TEST_REPARSER(case0160), - TEST_REPARSER(case0161), - TEST_REPARSER(case0162), - TEST_REPARSER(case0163), - TEST_REPARSER(case0164), - TEST_REPARSER(case0165), - TEST_REPARSER(case0166), - TEST_REPARSER(case0167), - TEST_REPARSER(case0168), - TEST_REPARSER(case0169), - TEST_REPARSER(case0170), - TEST_REPARSER(case0171), - TEST_REPARSER(case0172), - TEST_REPARSER(case0173), - TEST_REPARSER(case0174), - TEST_REPARSER(case0175), - TEST_REPARSER(case0176), - TEST_REPARSER(case0177), - TEST_REPARSER(case0178), - TEST_REPARSER(case0179), - TEST_REPARSER(case0180), - TEST_REPARSER(case0181), - TEST_REPARSER(case0182), - TEST_REPARSER(case0183), - TEST_REPARSER(case0184), - TEST_REPARSER(case0185), - TEST_REPARSER(case0186), - TEST_REPARSER(case0187), - TEST_REPARSER(case0188), - TEST_REPARSER(case0189), - TEST_REPARSER(case0190), - TEST_REPARSER(case0191), - TEST_REPARSER(case0192), - TEST_REPARSER(case0193), - TEST_REPARSER(case0194), - TEST_REPARSER(case0195), - TEST_REPARSER(case0196), - TEST_REPARSER(case0197), - TEST_REPARSER(case0198), - TEST_REPARSER(case0199), + TEST_REPARSER(case0100), TEST_REPARSER(case0101), TEST_REPARSER(case0102), + TEST_REPARSER(case0103), TEST_REPARSER(case0104), TEST_REPARSER(case0105), + TEST_REPARSER(case0106), TEST_REPARSER(case0107), TEST_REPARSER(case0108), + TEST_REPARSER(case0109), TEST_REPARSER(case0110), TEST_REPARSER(case0111), + TEST_REPARSER(case0112), TEST_REPARSER(case0113), TEST_REPARSER(case0114), + TEST_REPARSER(case0115), TEST_REPARSER(case0116), TEST_REPARSER(case0117), + TEST_REPARSER(case0118), TEST_REPARSER(case0119), TEST_REPARSER(case0120), + TEST_REPARSER(case0121), TEST_REPARSER(case0122), TEST_REPARSER(case0123), + TEST_REPARSER(case0124), TEST_REPARSER(case0125), TEST_REPARSER(case0126), + TEST_REPARSER(case0127), TEST_REPARSER(case0128), TEST_REPARSER(case0129), + TEST_REPARSER(case0130), TEST_REPARSER(case0131), TEST_REPARSER(case0132), + TEST_REPARSER(case0133), TEST_REPARSER(case0134), TEST_REPARSER(case0135), + TEST_REPARSER(case0136), TEST_REPARSER(case0137), TEST_REPARSER(case0138), + TEST_REPARSER(case0139), TEST_REPARSER(case0140), TEST_REPARSER(case0141), + TEST_REPARSER(case0142), TEST_REPARSER(case0143), TEST_REPARSER(case0144), + TEST_REPARSER(case0145), TEST_REPARSER(case0146), TEST_REPARSER(case0147), + TEST_REPARSER(case0148), TEST_REPARSER(case0149), TEST_REPARSER(case0150), + TEST_REPARSER(case0151), TEST_REPARSER(case0152), TEST_REPARSER(case0153), + TEST_REPARSER(case0154), TEST_REPARSER(case0155), TEST_REPARSER(case0156), + TEST_REPARSER(case0157), TEST_REPARSER(case0158), TEST_REPARSER(case0159), + TEST_REPARSER(case0160), TEST_REPARSER(case0161), TEST_REPARSER(case0162), + TEST_REPARSER(case0163), TEST_REPARSER(case0164), TEST_REPARSER(case0165), + TEST_REPARSER(case0166), TEST_REPARSER(case0167), TEST_REPARSER(case0168), + TEST_REPARSER(case0169), TEST_REPARSER(case0170), TEST_REPARSER(case0171), + TEST_REPARSER(case0172), TEST_REPARSER(case0173), TEST_REPARSER(case0174), + TEST_REPARSER(case0175), TEST_REPARSER(case0176), TEST_REPARSER(case0177), + TEST_REPARSER(case0178), TEST_REPARSER(case0179), TEST_REPARSER(case0180), + TEST_REPARSER(case0181), TEST_REPARSER(case0182), TEST_REPARSER(case0183), + TEST_REPARSER(case0184), TEST_REPARSER(case0185), TEST_REPARSER(case0186), + TEST_REPARSER(case0187), TEST_REPARSER(case0188), TEST_REPARSER(case0189), + TEST_REPARSER(case0190), TEST_REPARSER(case0191), TEST_REPARSER(case0192), + TEST_REPARSER(case0193), TEST_REPARSER(case0194), TEST_REPARSER(case0195), + TEST_REPARSER(case0196), TEST_REPARSER(case0197), TEST_REPARSER(case0198), + TEST_REPARSER(case0199), - TEST_REPARSER(case0200), - TEST_REPARSER(case0201), - TEST_REPARSER(case0202), - TEST_REPARSER(case0203), - TEST_REPARSER(case0204), - TEST_REPARSER(case0205), - TEST_REPARSER(case0206), - TEST_REPARSER(case0207), - TEST_REPARSER(case0208), - TEST_REPARSER(case0209), - TEST_REPARSER(case0210), - TEST_REPARSER(case0211), - TEST_REPARSER(case0212), - TEST_REPARSER(case0213), - TEST_REPARSER(case0214), - TEST_REPARSER(case0215), - TEST_REPARSER(case0216), - TEST_REPARSER(case0217), - TEST_REPARSER(case0218), - TEST_REPARSER(case0219), - TEST_REPARSER(case0220), - TEST_REPARSER(case0221), - TEST_REPARSER(case0222), - TEST_REPARSER(case0223), - TEST_REPARSER(case0224), - TEST_REPARSER(case0225), - TEST_REPARSER(case0226), - TEST_REPARSER(case0227), - TEST_REPARSER(case0228), - TEST_REPARSER(case0229), - TEST_REPARSER(case0230), - TEST_REPARSER(case0231), - TEST_REPARSER(case0232), - TEST_REPARSER(case0233), - TEST_REPARSER(case0234), - TEST_REPARSER(case0235), - TEST_REPARSER(case0236), - TEST_REPARSER(case0237), - TEST_REPARSER(case0238), - TEST_REPARSER(case0239), - TEST_REPARSER(case0240), - TEST_REPARSER(case0241), - TEST_REPARSER(case0242), - TEST_REPARSER(case0243), - TEST_REPARSER(case0244), - TEST_REPARSER(case0245), - TEST_REPARSER(case0246), - TEST_REPARSER(case0247), - TEST_REPARSER(case0248), - TEST_REPARSER(case0249), - TEST_REPARSER(case0250), - TEST_REPARSER(case0251), - TEST_REPARSER(case0252), - TEST_REPARSER(case0253), - TEST_REPARSER(case0254), - TEST_REPARSER(case0255), - TEST_REPARSER(case0256), - TEST_REPARSER(case0257), - TEST_REPARSER(case0258), - TEST_REPARSER(case0259), - TEST_REPARSER(case0260), - TEST_REPARSER(case0261), - TEST_REPARSER(case0262), - TEST_REPARSER(case0263), - TEST_REPARSER(case0264), - TEST_REPARSER(case0265), - TEST_REPARSER(case0266), - TEST_REPARSER(case0267), - TEST_REPARSER(case0268), - TEST_REPARSER(case0269), - TEST_REPARSER(case0270), - TEST_REPARSER(case0271), - TEST_REPARSER(case0272), - TEST_REPARSER(case0273), - TEST_REPARSER(case0274), - TEST_REPARSER(case0275), - TEST_REPARSER(case0276), - TEST_REPARSER(case0277), - TEST_REPARSER(case0278), - TEST_REPARSER(case0279), - TEST_REPARSER(case0280), - TEST_REPARSER(case0281), - TEST_REPARSER(case0282), - TEST_REPARSER(case0283), - TEST_REPARSER(case0284), - TEST_REPARSER(case0285), - TEST_REPARSER(case0286), - TEST_REPARSER(case0287), - TEST_REPARSER(case0288), - TEST_REPARSER(case0289), - TEST_REPARSER(case0290), - TEST_REPARSER(case0291), - TEST_REPARSER(case0292), - TEST_REPARSER(case0293), - TEST_REPARSER(case0294), - TEST_REPARSER(case0295), - TEST_REPARSER(case0296), - TEST_REPARSER(case0297), - TEST_REPARSER(case0298), - TEST_REPARSER(case0299), + TEST_REPARSER(case0200), TEST_REPARSER(case0201), TEST_REPARSER(case0202), + TEST_REPARSER(case0203), TEST_REPARSER(case0204), TEST_REPARSER(case0205), + TEST_REPARSER(case0206), TEST_REPARSER(case0207), TEST_REPARSER(case0208), + TEST_REPARSER(case0209), TEST_REPARSER(case0210), TEST_REPARSER(case0211), + TEST_REPARSER(case0212), TEST_REPARSER(case0213), TEST_REPARSER(case0214), + TEST_REPARSER(case0215), TEST_REPARSER(case0216), TEST_REPARSER(case0217), + TEST_REPARSER(case0218), TEST_REPARSER(case0219), TEST_REPARSER(case0220), + TEST_REPARSER(case0221), TEST_REPARSER(case0222), TEST_REPARSER(case0223), + TEST_REPARSER(case0224), TEST_REPARSER(case0225), TEST_REPARSER(case0226), + TEST_REPARSER(case0227), TEST_REPARSER(case0228), TEST_REPARSER(case0229), + TEST_REPARSER(case0230), TEST_REPARSER(case0231), TEST_REPARSER(case0232), + TEST_REPARSER(case0233), TEST_REPARSER(case0234), TEST_REPARSER(case0235), + TEST_REPARSER(case0236), TEST_REPARSER(case0237), TEST_REPARSER(case0238), + TEST_REPARSER(case0239), TEST_REPARSER(case0240), TEST_REPARSER(case0241), + TEST_REPARSER(case0242), TEST_REPARSER(case0243), TEST_REPARSER(case0244), + TEST_REPARSER(case0245), TEST_REPARSER(case0246), TEST_REPARSER(case0247), + TEST_REPARSER(case0248), TEST_REPARSER(case0249), TEST_REPARSER(case0250), + TEST_REPARSER(case0251), TEST_REPARSER(case0252), TEST_REPARSER(case0253), + TEST_REPARSER(case0254), TEST_REPARSER(case0255), TEST_REPARSER(case0256), + TEST_REPARSER(case0257), TEST_REPARSER(case0258), TEST_REPARSER(case0259), + TEST_REPARSER(case0260), TEST_REPARSER(case0261), TEST_REPARSER(case0262), + TEST_REPARSER(case0263), TEST_REPARSER(case0264), TEST_REPARSER(case0265), + TEST_REPARSER(case0266), TEST_REPARSER(case0267), TEST_REPARSER(case0268), + TEST_REPARSER(case0269), TEST_REPARSER(case0270), TEST_REPARSER(case0271), + TEST_REPARSER(case0272), TEST_REPARSER(case0273), TEST_REPARSER(case0274), + TEST_REPARSER(case0275), TEST_REPARSER(case0276), TEST_REPARSER(case0277), + TEST_REPARSER(case0278), TEST_REPARSER(case0279), TEST_REPARSER(case0280), + TEST_REPARSER(case0281), TEST_REPARSER(case0282), TEST_REPARSER(case0283), + TEST_REPARSER(case0284), TEST_REPARSER(case0285), TEST_REPARSER(case0286), + TEST_REPARSER(case0287), TEST_REPARSER(case0288), TEST_REPARSER(case0289), + TEST_REPARSER(case0290), TEST_REPARSER(case0291), TEST_REPARSER(case0292), + TEST_REPARSER(case0293), TEST_REPARSER(case0294), TEST_REPARSER(case0295), + TEST_REPARSER(case0296), TEST_REPARSER(case0297), TEST_REPARSER(case0298), + TEST_REPARSER(case0299), - }; + }; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/tests/SemanticModelTester.cpp b/C/tests/SemanticModelTester.cpp index 63f7d9201..b396a5d9b 100644 --- a/C/tests/SemanticModelTester.cpp +++ b/C/tests/SemanticModelTester.cpp @@ -29,439 +29,419 @@ using namespace C; const std::string SemanticModelTester::Name = "SEMANTIC MODEL"; - -APITestSuite* SemanticModelTester::suite() -{ - return static_cast(suite_); +APITestSuite *SemanticModelTester::suite() { + return static_cast(suite_); } -void SemanticModelTester::setUp() -{ -} +void SemanticModelTester::setUp() {} -void SemanticModelTester::tearDown() -{ - compilation_.reset(nullptr); - tree_.reset(nullptr); +void SemanticModelTester::tearDown() { + compilation_.reset(nullptr); + tree_.reset(nullptr); } template -std::tuple -SemanticModelTester::declAndSemaModel(const std::string& s) -{ - tree_ = SyntaxTree::parseText(SourceText(s), - TextPreprocessingState::Preprocessed, - TextCompleteness::Fragment, - ParseOptions(), - ""); - - auto TU = tree_->translationUnitRoot(); - PSY_EXPECT_TRUE(TU); - PSY_EXPECT_TRUE(TU->declarations()); - - auto anyDecl = TU->declarations()->value; - PSY_EXPECT_TRUE(anyDecl); - PSY_EXPECT_TRUE(anyDecl->asDeclaration()); - - auto decl = dynamic_cast(anyDecl); - PSY_EXPECT_TRUE(decl); - - compilation_ = Compilation::create(tree_->filePath()); - compilation_->addSyntaxTrees({ tree_.get() }); - auto semaModel = compilation_->semanticModel(tree_.get()); - PSY_EXPECT_TRUE(semaModel); - - return std::make_tuple(decl, semaModel); -} - -void SemanticModelTester::testSemanticModel() -{ - return run(tests_); -} - -void SemanticModelTester::case0001() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("int x ;"); - - auto decltor = varAndOrFunDecl->declarators()->value; - auto identDecltor = decltor->asIdentifierDeclarator(); - - const Symbol* sym = semaModel->declaredSymbol(identDecltor); - PSY_EXPECT_TRUE(sym); - PSY_EXPECT_EQ_ENU(sym->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym->asValue()->valueKind(), ValueKind::Variable, ValueKind); - const VariableSymbol* varsym = sym->asValue()->asVariable(); - PSY_EXPECT_EQ_STR(varsym->name()->text(), "x"); - PSY_EXPECT_EQ_ENU(varsym->type()->typeKind(), TypeKind::Named, TypeKind); -} +std::tuple +SemanticModelTester::declAndSemaModel(const std::string &s) { + tree_ = SyntaxTree::parseText( + SourceText(s), TextPreprocessingState::Preprocessed, + TextCompleteness::Fragment, ParseOptions(), ""); -void SemanticModelTester::case0002() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("int ( x ) ;"); + auto TU = tree_->translationUnitRoot(); + PSY_EXPECT_TRUE(TU); + PSY_EXPECT_TRUE(TU->declarations()); + + auto anyDecl = TU->declarations()->value; + PSY_EXPECT_TRUE(anyDecl); + PSY_EXPECT_TRUE(anyDecl->asDeclaration()); - auto decltor = varAndOrFunDecl->declarators()->value; - auto parenDecltor = decltor->asParenthesizedDeclarator(); + auto decl = dynamic_cast(anyDecl); + PSY_EXPECT_TRUE(decl); + + compilation_ = Compilation::create(tree_->filePath()); + compilation_->addSyntaxTrees({tree_.get()}); + auto semaModel = compilation_->semanticModel(tree_.get()); + PSY_EXPECT_TRUE(semaModel); + + return std::make_tuple(decl, semaModel); +} + +void SemanticModelTester::testSemanticModel() { + return run(tests_); +} + +void SemanticModelTester::case0001() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel("int x ;"); + + auto decltor = varAndOrFunDecl->declarators()->value; + auto identDecltor = decltor->asIdentifierDeclarator(); + + const Symbol *sym = semaModel->declaredSymbol(identDecltor); + PSY_EXPECT_TRUE(sym); + PSY_EXPECT_EQ_ENU(sym->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym->asValue()->valueKind(), ValueKind::Variable, + ValueKind); + const VariableSymbol *varsym = sym->asValue()->asVariable(); + PSY_EXPECT_EQ_STR(varsym->name()->text(), "x"); + PSY_EXPECT_EQ_ENU(varsym->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0002() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel("int ( x ) ;"); + + auto decltor = varAndOrFunDecl->declarators()->value; + auto parenDecltor = decltor->asParenthesizedDeclarator(); + + const Symbol *sym = semaModel->declaredSymbol(parenDecltor); + PSY_EXPECT_TRUE(sym); + PSY_EXPECT_EQ_ENU(sym->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym->asValue()->valueKind(), ValueKind::Variable, + ValueKind); + const VariableSymbol *varsym = sym->asValue()->asVariable(); + PSY_EXPECT_EQ_STR(varsym->name()->text(), "x"); + PSY_EXPECT_EQ_ENU(varsym->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0003() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel("int x ;"); + + auto syms = semaModel->declaredSymbols(varAndOrFunDecl); + PSY_EXPECT_EQ_INT(syms.size(), 1); + + const Symbol *sym0 = syms[0]; + PSY_EXPECT_TRUE(sym0); + PSY_EXPECT_EQ_ENU(sym0->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym0->asValue()->valueKind(), ValueKind::Variable, + ValueKind); + const VariableSymbol *varSym1 = sym0->asValue()->asVariable(); + PSY_EXPECT_EQ_STR(varSym1->name()->text(), "x"); + PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0004() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel("x y , z ;"); + + auto syms = semaModel->declaredSymbols(varAndOrFunDecl); + PSY_EXPECT_EQ_INT(syms.size(), 2); + + const Symbol *sym1 = syms[0]; + PSY_EXPECT_TRUE(sym1); + PSY_EXPECT_EQ_ENU(sym1->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym1->asValue()->valueKind(), ValueKind::Variable, + ValueKind); + const VariableSymbol *varSym1 = sym1->asValue()->asVariable(); + PSY_EXPECT_EQ_STR(varSym1->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); + + const Symbol *sym2 = syms[1]; + PSY_EXPECT_TRUE(sym2); + PSY_EXPECT_EQ_ENU(sym2->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym2->asValue()->valueKind(), ValueKind::Variable, + ValueKind); + const VariableSymbol *varSym2 = sym2->asValue()->asVariable(); + PSY_EXPECT_EQ_STR(varSym2->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(varSym2->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0090() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel( + "int x , y ( ) ;"); + + auto syms = semaModel->declaredSymbols(varAndOrFunDecl); + PSY_EXPECT_EQ_INT(syms.size(), 2); + + const Symbol *sym0 = syms[0]; + PSY_EXPECT_TRUE(sym0); + PSY_EXPECT_EQ_ENU(sym0->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym0->asValue()->valueKind(), ValueKind::Variable, + ValueKind); + const VariableSymbol *varSym1 = sym0->asValue()->asVariable(); + PSY_EXPECT_EQ_STR(varSym1->name()->text(), "x"); + PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); + + const Symbol *sym1 = syms[1]; + PSY_EXPECT_TRUE(sym1); + PSY_EXPECT_EQ_ENU(sym1->kind(), SymbolKind::Function, SymbolKind); + const FunctionSymbol *funcSym2 = sym1->asFunction(); + PSY_EXPECT_TRUE(funcSym2); + PSY_EXPECT_EQ_STR(funcSym2->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(funcSym2->type()->typeKind(), TypeKind::Function, TypeKind); +} + +void SemanticModelTester::case0091() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel( + "int x , y ( int z ) ;"); + + auto syms = semaModel->declaredSymbols(varAndOrFunDecl); + PSY_EXPECT_EQ_INT(syms.size(), 2); + + const Symbol *sym1 = syms[0]; + PSY_EXPECT_TRUE(sym1); + PSY_EXPECT_EQ_ENU(sym1->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym1->asValue()->valueKind(), ValueKind::Variable, + ValueKind); + const VariableSymbol *varSym1 = sym1->asValue()->asVariable(); + PSY_EXPECT_EQ_STR(varSym1->name()->text(), "x"); + PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); + + const Symbol *sym2 = syms[1]; + PSY_EXPECT_TRUE(sym2); + PSY_EXPECT_EQ_ENU(sym2->kind(), SymbolKind::Function, SymbolKind); + const FunctionSymbol *funcSym2 = sym2->asFunction(); + PSY_EXPECT_TRUE(funcSym2); + PSY_EXPECT_EQ_STR(funcSym2->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(funcSym2->type()->typeKind(), TypeKind::Function, TypeKind); +} + +void SemanticModelTester::case0092() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel("x y , z ( ) ;"); + + auto syms = semaModel->declaredSymbols(varAndOrFunDecl); + PSY_EXPECT_EQ_INT(syms.size(), 2); + + const Symbol *sym0 = syms[0]; + PSY_EXPECT_TRUE(sym0); + PSY_EXPECT_EQ_ENU(sym0->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym0->asValue()->valueKind(), ValueKind::Variable, + ValueKind); + const VariableSymbol *varSym1 = sym0->asValue()->asVariable(); + PSY_EXPECT_EQ_STR(varSym1->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); + + const Symbol *sym1 = syms[1]; + PSY_EXPECT_TRUE(sym1); + PSY_EXPECT_EQ_ENU(sym1->kind(), SymbolKind::Function, SymbolKind); + const FunctionSymbol *funcSym2 = sym1->asFunction(); + PSY_EXPECT_TRUE(funcSym2); + PSY_EXPECT_EQ_STR(funcSym2->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(funcSym2->type()->typeKind(), TypeKind::Function, TypeKind); +} + +void SemanticModelTester::case0093() {} +void SemanticModelTester::case0094() {} +void SemanticModelTester::case0095() {} +void SemanticModelTester::case0096() {} +void SemanticModelTester::case0097() {} +void SemanticModelTester::case0098() {} +void SemanticModelTester::case0099() {} + +void SemanticModelTester::case0005() {} +void SemanticModelTester::case0006() {} +void SemanticModelTester::case0007() {} +void SemanticModelTester::case0008() {} +void SemanticModelTester::case0009() {} +void SemanticModelTester::case0010() {} + +void SemanticModelTester::case0101() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel("void x ( ) ;"); + + auto syms = semaModel->declaredSymbols(varAndOrFunDecl); + PSY_EXPECT_EQ_INT(syms.size(), 1); + + const Symbol *sym0 = syms[0]; + PSY_EXPECT_TRUE(sym0); + PSY_EXPECT_EQ_ENU(sym0->kind(), SymbolKind::Function, SymbolKind); + const FunctionSymbol *funcSym = sym0->asFunction(); + PSY_EXPECT_TRUE(funcSym); + PSY_EXPECT_EQ_STR(funcSym->name()->text(), "x"); + PSY_EXPECT_EQ_ENU(funcSym->type()->typeKind(), TypeKind::Function, TypeKind); + + auto decltor = varAndOrFunDecl->declarators()->value; + auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); + + const Symbol *sym = semaModel->declaredSymbol(arrOrFunDecltor); + PSY_EXPECT_TRUE(sym); + PSY_EXPECT_TRUE(sym->kind() == SymbolKind::Function); + PSY_EXPECT_EQ_PTR(sym, funcSym); +} + +void SemanticModelTester::case0102() {} + +void SemanticModelTester::case0103() {} + +void SemanticModelTester::case0104() {} +void SemanticModelTester::case0105() {} +void SemanticModelTester::case0106() {} +void SemanticModelTester::case0107() {} +void SemanticModelTester::case0108() {} +void SemanticModelTester::case0109() {} +void SemanticModelTester::case0110() {} + +void SemanticModelTester::case0150() { + auto [funcDef, semaModel] = + declAndSemaModel("void x ( ) { }"); + + const FunctionSymbol *funcSym = semaModel->declaredSymbol(funcDef); + PSY_EXPECT_TRUE(funcSym); + PSY_EXPECT_EQ_STR(funcSym->name()->text(), "x"); + PSY_EXPECT_EQ_ENU(funcSym->type()->typeKind(), TypeKind::Function, TypeKind); + + auto decltor = funcDef->declarator(); + auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); + + const Symbol *sym = semaModel->declaredSymbol(arrOrFunDecltor); + PSY_EXPECT_TRUE(sym); + PSY_EXPECT_TRUE(sym->kind() == SymbolKind::Function); + PSY_EXPECT_EQ_PTR(sym, funcSym); +} + +void SemanticModelTester::case0151() {} + +void SemanticModelTester::case0152() {} +void SemanticModelTester::case0153() {} +void SemanticModelTester::case0154() {} +void SemanticModelTester::case0155() {} +void SemanticModelTester::case0156() {} +void SemanticModelTester::case0157() {} +void SemanticModelTester::case0158() {} +void SemanticModelTester::case0159() {} + +void SemanticModelTester::case0201() { + auto [funcDef, semaModel] = + declAndSemaModel("void x ( int y ) { }"); + + auto decltor = funcDef->declarator(); + auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); + auto parmDecls = arrOrFunDecltor->suffix()->asParameterSuffix()->parameters(); + auto parmDecl0 = parmDecls->value; + auto identDecltor = parmDecl0->declarator()->asIdentifierDeclarator(); + + const Symbol *sym = semaModel->declaredSymbol(identDecltor); + PSY_EXPECT_TRUE(sym); + PSY_EXPECT_EQ_ENU(sym->kind(), SymbolKind::Value, SymbolKind); + PSY_EXPECT_EQ_ENU(sym->asValue()->valueKind(), ValueKind::Parameter, + ValueKind); + const ParameterSymbol *parmSym = sym->asValue()->asParameter(); + PSY_EXPECT_TRUE(parmSym); + PSY_EXPECT_EQ_STR(parmSym->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(parmSym->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0202() { + auto [funcDef, semaModel] = + declAndSemaModel("void x ( int y ) { }"); + + auto decltor = funcDef->declarator(); + auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); + auto parmDecls = arrOrFunDecltor->suffix()->asParameterSuffix()->parameters(); + + const ParameterSymbol *parmSym = semaModel->declaredSymbol(parmDecls->value); + PSY_EXPECT_TRUE(parmSym); + PSY_EXPECT_EQ_STR(parmSym->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(parmSym->type()->typeKind(), TypeKind::Named, TypeKind); +} - const Symbol* sym = semaModel->declaredSymbol(parenDecltor); - PSY_EXPECT_TRUE(sym); - PSY_EXPECT_EQ_ENU(sym->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym->asValue()->valueKind(), ValueKind::Variable, ValueKind); - const VariableSymbol* varsym = sym->asValue()->asVariable(); - PSY_EXPECT_EQ_STR(varsym->name()->text(), "x"); - PSY_EXPECT_EQ_ENU(varsym->type()->typeKind(), TypeKind::Named, TypeKind); +void SemanticModelTester::case0203() { + auto [funcDef, semaModel] = + declAndSemaModel("void x ( y z ) { }"); + + auto decltor = funcDef->declarator(); + auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); + auto parmDecls = arrOrFunDecltor->suffix()->asParameterSuffix()->parameters(); + + const ParameterSymbol *parmSym = semaModel->declaredSymbol(parmDecls->value); + PSY_EXPECT_TRUE(parmSym); + PSY_EXPECT_EQ_STR(parmSym->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(parmSym->type()->typeKind(), TypeKind::Named, TypeKind); } -void SemanticModelTester::case0003() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("int x ;"); +void SemanticModelTester::case0204() { + auto [funcDef, semaModel] = + declAndSemaModel("void x ( y z , int w ) { }"); - auto syms = semaModel->declaredSymbols(varAndOrFunDecl); - PSY_EXPECT_EQ_INT(syms.size(), 1); - - const Symbol* sym0 = syms[0]; - PSY_EXPECT_TRUE(sym0); - PSY_EXPECT_EQ_ENU(sym0->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym0->asValue()->valueKind(), ValueKind::Variable, ValueKind); - const VariableSymbol* varSym1 = sym0->asValue()->asVariable(); - PSY_EXPECT_EQ_STR(varSym1->name()->text(), "x"); - PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); -} + auto decltor = funcDef->declarator(); + auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); + auto parmDecls = arrOrFunDecltor->suffix()->asParameterSuffix()->parameters(); -void SemanticModelTester::case0004() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("x y , z ;"); - - auto syms = semaModel->declaredSymbols(varAndOrFunDecl); - PSY_EXPECT_EQ_INT(syms.size(), 2); - - const Symbol* sym1 = syms[0]; - PSY_EXPECT_TRUE(sym1); - PSY_EXPECT_EQ_ENU(sym1->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym1->asValue()->valueKind(), ValueKind::Variable, ValueKind); - const VariableSymbol* varSym1 = sym1->asValue()->asVariable(); - PSY_EXPECT_EQ_STR(varSym1->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); - - const Symbol* sym2 = syms[1]; - PSY_EXPECT_TRUE(sym2); - PSY_EXPECT_EQ_ENU(sym2->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym2->asValue()->valueKind(), ValueKind::Variable, ValueKind); - const VariableSymbol* varSym2 = sym2->asValue()->asVariable(); - PSY_EXPECT_EQ_STR(varSym2->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(varSym2->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0090() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("int x , y ( ) ;"); - - auto syms = semaModel->declaredSymbols(varAndOrFunDecl); - PSY_EXPECT_EQ_INT(syms.size(), 2); - - const Symbol* sym0 = syms[0]; - PSY_EXPECT_TRUE(sym0); - PSY_EXPECT_EQ_ENU(sym0->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym0->asValue()->valueKind(), ValueKind::Variable, ValueKind); - const VariableSymbol* varSym1 = sym0->asValue()->asVariable(); - PSY_EXPECT_EQ_STR(varSym1->name()->text(), "x"); - PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); - - const Symbol* sym1 = syms[1]; - PSY_EXPECT_TRUE(sym1); - PSY_EXPECT_EQ_ENU(sym1->kind(), SymbolKind::Function, SymbolKind); - const FunctionSymbol* funcSym2 = sym1->asFunction(); - PSY_EXPECT_TRUE(funcSym2); - PSY_EXPECT_EQ_STR(funcSym2->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(funcSym2->type()->typeKind(), TypeKind::Function, TypeKind); -} - -void SemanticModelTester::case0091() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("int x , y ( int z ) ;"); - - auto syms = semaModel->declaredSymbols(varAndOrFunDecl); - PSY_EXPECT_EQ_INT(syms.size(), 2); - - const Symbol* sym1 = syms[0]; - PSY_EXPECT_TRUE(sym1); - PSY_EXPECT_EQ_ENU(sym1->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym1->asValue()->valueKind(), ValueKind::Variable, ValueKind); - const VariableSymbol* varSym1 = sym1->asValue()->asVariable(); - PSY_EXPECT_EQ_STR(varSym1->name()->text(), "x"); - PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); - - const Symbol* sym2 = syms[1]; - PSY_EXPECT_TRUE(sym2); - PSY_EXPECT_EQ_ENU(sym2->kind(), SymbolKind::Function, SymbolKind); - const FunctionSymbol* funcSym2 = sym2->asFunction(); - PSY_EXPECT_TRUE(funcSym2); - PSY_EXPECT_EQ_STR(funcSym2->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(funcSym2->type()->typeKind(), TypeKind::Function, TypeKind); -} - -void SemanticModelTester::case0092() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("x y , z ( ) ;"); - - auto syms = semaModel->declaredSymbols(varAndOrFunDecl); - PSY_EXPECT_EQ_INT(syms.size(), 2); - - const Symbol* sym0 = syms[0]; - PSY_EXPECT_TRUE(sym0); - PSY_EXPECT_EQ_ENU(sym0->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym0->asValue()->valueKind(), ValueKind::Variable, ValueKind); - const VariableSymbol* varSym1 = sym0->asValue()->asVariable(); - PSY_EXPECT_EQ_STR(varSym1->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(varSym1->type()->typeKind(), TypeKind::Named, TypeKind); - - const Symbol* sym1 = syms[1]; - PSY_EXPECT_TRUE(sym1); - PSY_EXPECT_EQ_ENU(sym1->kind(), SymbolKind::Function, SymbolKind); - const FunctionSymbol* funcSym2 = sym1->asFunction(); - PSY_EXPECT_TRUE(funcSym2); - PSY_EXPECT_EQ_STR(funcSym2->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(funcSym2->type()->typeKind(), TypeKind::Function, TypeKind); -} - -void SemanticModelTester::case0093(){} -void SemanticModelTester::case0094(){} -void SemanticModelTester::case0095(){} -void SemanticModelTester::case0096(){} -void SemanticModelTester::case0097(){} -void SemanticModelTester::case0098(){} -void SemanticModelTester::case0099(){} - -void SemanticModelTester::case0005(){} -void SemanticModelTester::case0006(){} -void SemanticModelTester::case0007(){} -void SemanticModelTester::case0008(){} -void SemanticModelTester::case0009(){} -void SemanticModelTester::case0010(){} - -void SemanticModelTester::case0101() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("void x ( ) ;"); + const ParameterSymbol *parmSym0 = semaModel->declaredSymbol(parmDecls->value); + PSY_EXPECT_TRUE(parmSym0); + PSY_EXPECT_EQ_STR(parmSym0->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(parmSym0->type()->typeKind(), TypeKind::Named, TypeKind); + + const ParameterSymbol *parmSym1 = + semaModel->declaredSymbol(parmDecls->next->value); + PSY_EXPECT_TRUE(parmSym1); + PSY_EXPECT_EQ_STR(parmSym1->name()->text(), "w"); + PSY_EXPECT_EQ_ENU(parmSym1->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0205() {} +void SemanticModelTester::case0206() {} +void SemanticModelTester::case0207() {} +void SemanticModelTester::case0208() {} +void SemanticModelTester::case0209() {} +void SemanticModelTester::case0210() {} +void SemanticModelTester::case0211() {} +void SemanticModelTester::case0212() {} +void SemanticModelTester::case0213() {} +void SemanticModelTester::case0214() {} +void SemanticModelTester::case0215() {} +void SemanticModelTester::case0216() {} +void SemanticModelTester::case0217() {} +void SemanticModelTester::case0218() {} +void SemanticModelTester::case0219() {} +void SemanticModelTester::case0220() {} + +void SemanticModelTester::case0300() { + auto [tyDecl, semaModel] = declAndSemaModel( + "struct x { int _ ; } ;"); + + const NamedTypeSymbol *namedTySym = semaModel->declaredSymbol(tyDecl); + PSY_EXPECT_TRUE(namedTySym); + PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "struct x"); +} + +void SemanticModelTester::case0301() { + auto [tyDecl, semaModel] = + declAndSemaModel("union x { int _ ; } ;"); + + const NamedTypeSymbol *namedTySym = semaModel->declaredSymbol(tyDecl); + PSY_EXPECT_TRUE(namedTySym); + PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "union x"); +} - auto syms = semaModel->declaredSymbols(varAndOrFunDecl); - PSY_EXPECT_EQ_INT(syms.size(), 1); +void SemanticModelTester::case0302() { + auto [varAndOrFunDecl, semaModel] = + declAndSemaModel( + "struct x { int _ ; } y ;"); - const Symbol* sym0 = syms[0]; - PSY_EXPECT_TRUE(sym0); - PSY_EXPECT_EQ_ENU(sym0->kind(), SymbolKind::Function, SymbolKind); - const FunctionSymbol* funcSym = sym0->asFunction(); - PSY_EXPECT_TRUE(funcSym); - PSY_EXPECT_EQ_STR(funcSym->name()->text(), "x"); - PSY_EXPECT_EQ_ENU(funcSym->type()->typeKind(), TypeKind::Function, TypeKind); + auto syms = semaModel->declaredSymbols(varAndOrFunDecl); + PSY_EXPECT_EQ_INT(syms.size(), 1); - auto decltor = varAndOrFunDecl->declarators()->value; - auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); + auto spec = varAndOrFunDecl->specifiers()->value->asSpecifier(); + auto tyDecl = spec->asTypeDeclarationAsSpecifier()->typeDeclaration(); - const Symbol* sym = semaModel->declaredSymbol(arrOrFunDecltor); - PSY_EXPECT_TRUE(sym); - PSY_EXPECT_TRUE(sym->kind() == SymbolKind::Function); - PSY_EXPECT_EQ_PTR(sym, funcSym); + const NamedTypeSymbol *namedTySym = semaModel->declaredSymbol(tyDecl); + PSY_EXPECT_TRUE(namedTySym); + PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "struct x"); } -void SemanticModelTester::case0102() -{ -} - -void SemanticModelTester::case0103() -{ - -} - -void SemanticModelTester::case0104(){} -void SemanticModelTester::case0105(){} -void SemanticModelTester::case0106(){} -void SemanticModelTester::case0107(){} -void SemanticModelTester::case0108(){} -void SemanticModelTester::case0109(){} -void SemanticModelTester::case0110(){} - -void SemanticModelTester::case0150() -{ - auto [funcDef, semaModel] = - declAndSemaModel("void x ( ) { }"); - - const FunctionSymbol* funcSym = semaModel->declaredSymbol(funcDef); - PSY_EXPECT_TRUE(funcSym); - PSY_EXPECT_EQ_STR(funcSym->name()->text(), "x"); - PSY_EXPECT_EQ_ENU(funcSym->type()->typeKind(), TypeKind::Function, TypeKind); - - auto decltor = funcDef->declarator(); - auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); - - const Symbol* sym = semaModel->declaredSymbol(arrOrFunDecltor); - PSY_EXPECT_TRUE(sym); - PSY_EXPECT_TRUE(sym->kind() == SymbolKind::Function); - PSY_EXPECT_EQ_PTR(sym, funcSym); -} - -void SemanticModelTester::case0151() -{ -} - -void SemanticModelTester::case0152(){} -void SemanticModelTester::case0153(){} -void SemanticModelTester::case0154(){} -void SemanticModelTester::case0155(){} -void SemanticModelTester::case0156(){} -void SemanticModelTester::case0157(){} -void SemanticModelTester::case0158(){} -void SemanticModelTester::case0159(){} - - -void SemanticModelTester::case0201() -{ - auto [funcDef, semaModel] = - declAndSemaModel("void x ( int y ) { }"); - - auto decltor = funcDef->declarator(); - auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); - auto parmDecls = arrOrFunDecltor->suffix()->asParameterSuffix()->parameters(); - auto parmDecl0 = parmDecls->value; - auto identDecltor = parmDecl0->declarator()->asIdentifierDeclarator(); - - const Symbol* sym = semaModel->declaredSymbol(identDecltor); - PSY_EXPECT_TRUE(sym); - PSY_EXPECT_EQ_ENU(sym->kind(), SymbolKind::Value, SymbolKind); - PSY_EXPECT_EQ_ENU(sym->asValue()->valueKind(), ValueKind::Parameter, ValueKind); - const ParameterSymbol* parmSym = sym->asValue()->asParameter(); - PSY_EXPECT_TRUE(parmSym); - PSY_EXPECT_EQ_STR(parmSym->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(parmSym->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0202() -{ - auto [funcDef, semaModel] = - declAndSemaModel("void x ( int y ) { }"); - - auto decltor = funcDef->declarator(); - auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); - auto parmDecls = arrOrFunDecltor->suffix()->asParameterSuffix()->parameters(); - - const ParameterSymbol* parmSym = semaModel->declaredSymbol(parmDecls->value); - PSY_EXPECT_TRUE(parmSym); - PSY_EXPECT_EQ_STR(parmSym->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(parmSym->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0203() -{ - auto [funcDef, semaModel] = - declAndSemaModel("void x ( y z ) { }"); - - auto decltor = funcDef->declarator(); - auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); - auto parmDecls = arrOrFunDecltor->suffix()->asParameterSuffix()->parameters(); - - const ParameterSymbol* parmSym = semaModel->declaredSymbol(parmDecls->value); - PSY_EXPECT_TRUE(parmSym); - PSY_EXPECT_EQ_STR(parmSym->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(parmSym->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0204() -{ - auto [funcDef, semaModel] = - declAndSemaModel("void x ( y z , int w ) { }"); - - auto decltor = funcDef->declarator(); - auto arrOrFunDecltor = decltor->asArrayOrFunctionDeclarator(); - auto parmDecls = arrOrFunDecltor->suffix()->asParameterSuffix()->parameters(); - - const ParameterSymbol* parmSym0 = semaModel->declaredSymbol(parmDecls->value); - PSY_EXPECT_TRUE(parmSym0); - PSY_EXPECT_EQ_STR(parmSym0->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(parmSym0->type()->typeKind(), TypeKind::Named, TypeKind); - - const ParameterSymbol* parmSym1 = semaModel->declaredSymbol(parmDecls->next->value); - PSY_EXPECT_TRUE(parmSym1); - PSY_EXPECT_EQ_STR(parmSym1->name()->text(), "w"); - PSY_EXPECT_EQ_ENU(parmSym1->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0205(){} -void SemanticModelTester::case0206(){} -void SemanticModelTester::case0207(){} -void SemanticModelTester::case0208(){} -void SemanticModelTester::case0209(){} -void SemanticModelTester::case0210(){} -void SemanticModelTester::case0211(){} -void SemanticModelTester::case0212(){} -void SemanticModelTester::case0213(){} -void SemanticModelTester::case0214(){} -void SemanticModelTester::case0215(){} -void SemanticModelTester::case0216(){} -void SemanticModelTester::case0217(){} -void SemanticModelTester::case0218(){} -void SemanticModelTester::case0219(){} -void SemanticModelTester::case0220(){} - -void SemanticModelTester::case0300() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("struct x { int _ ; } ;"); - - const NamedTypeSymbol* namedTySym = semaModel->declaredSymbol(tyDecl); - PSY_EXPECT_TRUE(namedTySym); - PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "struct x"); -} - -void SemanticModelTester::case0301() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("union x { int _ ; } ;"); - - const NamedTypeSymbol* namedTySym = semaModel->declaredSymbol(tyDecl); - PSY_EXPECT_TRUE(namedTySym); - PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "union x"); -} - -void SemanticModelTester::case0302() -{ - auto [varAndOrFunDecl, semaModel] = - declAndSemaModel("struct x { int _ ; } y ;"); - - auto syms = semaModel->declaredSymbols(varAndOrFunDecl); - PSY_EXPECT_EQ_INT(syms.size(), 1); - - auto spec = varAndOrFunDecl->specifiers()->value->asSpecifier(); - auto tyDecl = spec->asTypeDeclarationAsSpecifier()->typeDeclaration(); - - const NamedTypeSymbol* namedTySym = semaModel->declaredSymbol(tyDecl); - PSY_EXPECT_TRUE(namedTySym); - PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "struct x"); -} - -void SemanticModelTester::case0303() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("struct x { struct y { int _ ; } z ; } ;"); +void SemanticModelTester::case0303() { + auto [tyDecl, semaModel] = declAndSemaModel( + "struct x { struct y { int _ ; } z ; } ;"); - auto tySpec = tyDecl->typeSpecifier(); - auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); - auto nestedTyDecl = fldDecl0->specifiers()->value->asTypeDeclarationAsSpecifier()->typeDeclaration(); + auto tySpec = tyDecl->typeSpecifier(); + auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); + auto nestedTyDecl = fldDecl0->specifiers() + ->value->asTypeDeclarationAsSpecifier() + ->typeDeclaration(); - const NamedTypeSymbol* namedTySym = semaModel->declaredSymbol(nestedTyDecl); - PSY_EXPECT_TRUE(namedTySym); - PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "struct y"); + const NamedTypeSymbol *namedTySym = semaModel->declaredSymbol(nestedTyDecl); + PSY_EXPECT_TRUE(namedTySym); + PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "struct y"); } -void SemanticModelTester::case0304() -{ - auto [tyDecl, semaModel] = - declAndSemaModel(R"( +void SemanticModelTester::case0304() { + auto [tyDecl, semaModel] = + declAndSemaModel(R"( struct x { struct y @@ -471,474 +451,468 @@ struct x } ; )"); - auto tySpec = tyDecl->typeSpecifier(); - auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); - auto nestedTyDecl = fldDecl0->specifiers()->value->asTypeDeclarationAsSpecifier()->typeDeclaration(); - - auto nestedTySpec = nestedTyDecl->typeSpecifier(); - auto nestedFldDecl0 = nestedTySpec->declarations()->value->asFieldDeclaration(); - auto nestedNestedTyDecl = nestedFldDecl0->specifiers()->value->asTypeDeclarationAsSpecifier()->typeDeclaration(); - - const NamedTypeSymbol* namedTySym = semaModel->declaredSymbol(nestedNestedTyDecl); - PSY_EXPECT_TRUE(namedTySym); - PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "struct z"); - -} - -void SemanticModelTester::case0305(){} -void SemanticModelTester::case0306(){} -void SemanticModelTester::case0307(){} -void SemanticModelTester::case0308(){} -void SemanticModelTester::case0309(){} -void SemanticModelTester::case0310(){} -void SemanticModelTester::case0311(){} -void SemanticModelTester::case0312(){} -void SemanticModelTester::case0313(){} -void SemanticModelTester::case0314(){} -void SemanticModelTester::case0315(){} -void SemanticModelTester::case0316(){} -void SemanticModelTester::case0317(){} -void SemanticModelTester::case0318(){} -void SemanticModelTester::case0319(){} -void SemanticModelTester::case0320(){} -void SemanticModelTester::case0321(){} -void SemanticModelTester::case0322(){} -void SemanticModelTester::case0323(){} -void SemanticModelTester::case0324(){} -void SemanticModelTester::case0325(){} -void SemanticModelTester::case0326(){} -void SemanticModelTester::case0327(){} -void SemanticModelTester::case0328(){} -void SemanticModelTester::case0329(){} -void SemanticModelTester::case0330(){} -void SemanticModelTester::case0331(){} -void SemanticModelTester::case0332(){} -void SemanticModelTester::case0333(){} -void SemanticModelTester::case0334(){} -void SemanticModelTester::case0335(){} -void SemanticModelTester::case0336(){} -void SemanticModelTester::case0337(){} -void SemanticModelTester::case0338(){} -void SemanticModelTester::case0339(){} -void SemanticModelTester::case0340(){} -void SemanticModelTester::case0341(){} -void SemanticModelTester::case0342(){} -void SemanticModelTester::case0343(){} -void SemanticModelTester::case0344(){} -void SemanticModelTester::case0345(){} -void SemanticModelTester::case0346(){} -void SemanticModelTester::case0347(){} -void SemanticModelTester::case0348(){} -void SemanticModelTester::case0349(){} - -void SemanticModelTester::case0350() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("struct x { int y ; } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); - std::vector fldSyms0 = semaModel->declaredSymbols(fldDecl0); - PSY_EXPECT_EQ_INT(fldSyms0.size(), 1); - - const FieldSymbol* fldSym0_0 = fldSyms0[0]; - PSY_EXPECT_TRUE(fldSym0_0); - PSY_EXPECT_EQ_STR(fldSym0_0->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(fldSym0_0->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0351() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("struct x { int y , z ; } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); - std::vector fldSyms0 = semaModel->declaredSymbols(fldDecl0); - PSY_EXPECT_EQ_INT(fldSyms0.size(), 2); - - const FieldSymbol* fldSym0_0 = fldSyms0[0]; - PSY_EXPECT_TRUE(fldSym0_0); - PSY_EXPECT_EQ_STR(fldSym0_0->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(fldSym0_0->type()->typeKind(), TypeKind::Named, TypeKind); - - const FieldSymbol* fldSym0_1 = fldSyms0[1]; - PSY_EXPECT_TRUE(fldSym0_1); - PSY_EXPECT_EQ_STR(fldSym0_1->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(fldSym0_1->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0352() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("struct x { int y ; double * z ; } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); - std::vector fldSyms0 = semaModel->declaredSymbols(fldDecl0); - PSY_EXPECT_EQ_INT(fldSyms0.size(), 1); - - const FieldSymbol* fldSym0_0 = fldSyms0[0]; - PSY_EXPECT_TRUE(fldSym0_0); - PSY_EXPECT_EQ_STR(fldSym0_0->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(fldSym0_0->type()->typeKind(), TypeKind::Named, TypeKind); - - auto fldDecl1 = tySpec->declarations()->next->value->asFieldDeclaration(); - std::vector fldSyms1 = semaModel->declaredSymbols(fldDecl1); - PSY_EXPECT_EQ_INT(fldSyms1.size(), 1); - - const FieldSymbol* fldSym1_0 = fldSyms1[0]; - PSY_EXPECT_TRUE(fldSym1_0); - PSY_EXPECT_EQ_STR(fldSym1_0->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(fldSym1_0->type()->typeKind(), TypeKind::Pointer, TypeKind); -} - -void SemanticModelTester::case0353() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("struct x { int y , z ; double * z, w ; } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); - std::vector fldSyms0 = semaModel->declaredSymbols(fldDecl0); - PSY_EXPECT_EQ_INT(fldSyms0.size(), 2); - - const FieldSymbol* fldSym0_0 = fldSyms0[0]; - PSY_EXPECT_TRUE(fldSym0_0); - PSY_EXPECT_EQ_STR(fldSym0_0->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(fldSym0_0->type()->typeKind(), TypeKind::Named, TypeKind); - - const FieldSymbol* fldSym0_1 = fldSyms0[1]; - PSY_EXPECT_TRUE(fldSym0_1); - PSY_EXPECT_EQ_STR(fldSym0_1->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(fldSym0_1->type()->typeKind(), TypeKind::Named, TypeKind); - - auto fldDecl1 = tySpec->declarations()->next->value->asFieldDeclaration(); - std::vector fldSyms1 = semaModel->declaredSymbols(fldDecl1); - PSY_EXPECT_EQ_INT(fldSyms1.size(), 2); - - const FieldSymbol* fldSym1_0 = fldSyms1[0]; - PSY_EXPECT_TRUE(fldSym1_0); - PSY_EXPECT_EQ_STR(fldSym1_0->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(fldSym1_0->type()->typeKind(), TypeKind::Pointer, TypeKind); - - const FieldSymbol* fldSym1_1 = fldSyms1[1]; - PSY_EXPECT_TRUE(fldSym1_1); - PSY_EXPECT_EQ_STR(fldSym1_1->name()->text(), "w"); - PSY_EXPECT_EQ_ENU(fldSym1_1->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0354(){} -void SemanticModelTester::case0355(){} -void SemanticModelTester::case0356(){} -void SemanticModelTester::case0357(){} -void SemanticModelTester::case0358(){} -void SemanticModelTester::case0359(){} -void SemanticModelTester::case0360(){} -void SemanticModelTester::case0361(){} -void SemanticModelTester::case0362(){} -void SemanticModelTester::case0363(){} -void SemanticModelTester::case0364(){} -void SemanticModelTester::case0365(){} -void SemanticModelTester::case0366(){} -void SemanticModelTester::case0367(){} -void SemanticModelTester::case0368(){} -void SemanticModelTester::case0369(){} -void SemanticModelTester::case0370(){} -void SemanticModelTester::case0371(){} -void SemanticModelTester::case0372(){} -void SemanticModelTester::case0373(){} -void SemanticModelTester::case0374(){} -void SemanticModelTester::case0375(){} -void SemanticModelTester::case0376(){} -void SemanticModelTester::case0377(){} -void SemanticModelTester::case0378(){} -void SemanticModelTester::case0379(){} -void SemanticModelTester::case0380(){} -void SemanticModelTester::case0381(){} -void SemanticModelTester::case0382(){} -void SemanticModelTester::case0383(){} -void SemanticModelTester::case0384(){} -void SemanticModelTester::case0385(){} -void SemanticModelTester::case0386(){} -void SemanticModelTester::case0387(){} -void SemanticModelTester::case0388(){} -void SemanticModelTester::case0389(){} -void SemanticModelTester::case0390(){} -void SemanticModelTester::case0391(){} -void SemanticModelTester::case0392(){} -void SemanticModelTester::case0393(){} -void SemanticModelTester::case0394(){} -void SemanticModelTester::case0395(){} -void SemanticModelTester::case0396(){} -void SemanticModelTester::case0397(){} -void SemanticModelTester::case0398(){} -void SemanticModelTester::case0399(){} - -void SemanticModelTester::case0400() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("enum x { y } ;"); - - const NamedTypeSymbol* namedTySym = semaModel->declaredSymbol(tyDecl); - PSY_EXPECT_TRUE(namedTySym); - PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "enum x"); -} - -void SemanticModelTester::case0401() -{ -} - -void SemanticModelTester::case0402() -{ -} - -void SemanticModelTester::case0403() -{ -} - -void SemanticModelTester::case0404(){} -void SemanticModelTester::case0405(){} -void SemanticModelTester::case0406(){} -void SemanticModelTester::case0407(){} -void SemanticModelTester::case0408(){} -void SemanticModelTester::case0409(){} -void SemanticModelTester::case0410(){} -void SemanticModelTester::case0411(){} -void SemanticModelTester::case0412(){} -void SemanticModelTester::case0413(){} -void SemanticModelTester::case0414(){} -void SemanticModelTester::case0415(){} -void SemanticModelTester::case0416(){} -void SemanticModelTester::case0417(){} -void SemanticModelTester::case0418(){} -void SemanticModelTester::case0419(){} -void SemanticModelTester::case0420(){} -void SemanticModelTester::case0421(){} -void SemanticModelTester::case0422(){} -void SemanticModelTester::case0423(){} -void SemanticModelTester::case0424(){} -void SemanticModelTester::case0425(){} -void SemanticModelTester::case0426(){} -void SemanticModelTester::case0427(){} -void SemanticModelTester::case0428(){} -void SemanticModelTester::case0429(){} -void SemanticModelTester::case0430(){} -void SemanticModelTester::case0431(){} -void SemanticModelTester::case0432(){} -void SemanticModelTester::case0433(){} -void SemanticModelTester::case0434(){} -void SemanticModelTester::case0435(){} -void SemanticModelTester::case0436(){} -void SemanticModelTester::case0437(){} -void SemanticModelTester::case0438(){} -void SemanticModelTester::case0439(){} -void SemanticModelTester::case0440(){} -void SemanticModelTester::case0441(){} -void SemanticModelTester::case0442(){} -void SemanticModelTester::case0443(){} -void SemanticModelTester::case0444(){} -void SemanticModelTester::case0445(){} -void SemanticModelTester::case0446(){} -void SemanticModelTester::case0447(){} -void SemanticModelTester::case0448(){} -void SemanticModelTester::case0449(){} - -void SemanticModelTester::case0450() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("enum x { y } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym = semaModel->declaredSymbol(enumtrDecl0); - PSY_EXPECT_TRUE(enumtrSym); - PSY_EXPECT_EQ_STR(enumtrSym->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(enumtrSym->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0451() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("enum x { y = 0 } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym = semaModel->declaredSymbol(enumtrDecl0); - PSY_EXPECT_TRUE(enumtrSym); - PSY_EXPECT_EQ_STR(enumtrSym->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(enumtrSym->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0452() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("enum x { y , z } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym0 = semaModel->declaredSymbol(enumtrDecl0); - PSY_EXPECT_TRUE(enumtrSym0); - PSY_EXPECT_EQ_STR(enumtrSym0->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(enumtrSym0->type()->typeKind(), TypeKind::Named, TypeKind); - - auto enumtrDecl1 = tySpec->declarations()->next->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym1 = semaModel->declaredSymbol(enumtrDecl1); - PSY_EXPECT_TRUE(enumtrSym1); - PSY_EXPECT_EQ_STR(enumtrSym1->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(enumtrSym1->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0453() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("enum x { y = 0 , z } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym0 = semaModel->declaredSymbol(enumtrDecl0); - PSY_EXPECT_TRUE(enumtrSym0); - PSY_EXPECT_EQ_STR(enumtrSym0->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(enumtrSym0->type()->typeKind(), TypeKind::Named, TypeKind); - - auto enumtrDecl1 = tySpec->declarations()->next->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym1 = semaModel->declaredSymbol(enumtrDecl1); - PSY_EXPECT_TRUE(enumtrSym1); - PSY_EXPECT_EQ_STR(enumtrSym1->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(enumtrSym1->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0454() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("enum x { y = 0 , z = 1 } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym0 = semaModel->declaredSymbol(enumtrDecl0); - PSY_EXPECT_TRUE(enumtrSym0); - PSY_EXPECT_EQ_STR(enumtrSym0->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(enumtrSym0->type()->typeKind(), TypeKind::Named, TypeKind); - - auto enumtrDecl1 = tySpec->declarations()->next->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym1 = semaModel->declaredSymbol(enumtrDecl1); - PSY_EXPECT_TRUE(enumtrSym1); - PSY_EXPECT_EQ_STR(enumtrSym1->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(enumtrSym1->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0455() -{ - auto [tyDecl, semaModel] = - declAndSemaModel("enum x { y , z = 1 } ;"); - - auto tySpec = tyDecl->typeSpecifier(); - - auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym0 = semaModel->declaredSymbol(enumtrDecl0); - PSY_EXPECT_TRUE(enumtrSym0); - PSY_EXPECT_EQ_STR(enumtrSym0->name()->text(), "y"); - PSY_EXPECT_EQ_ENU(enumtrSym0->type()->typeKind(), TypeKind::Named, TypeKind); - - auto enumtrDecl1 = tySpec->declarations()->next->value->asEnumeratorDeclaration(); - - const EnumeratorSymbol* enumtrSym1 = semaModel->declaredSymbol(enumtrDecl1); - PSY_EXPECT_TRUE(enumtrSym1); - PSY_EXPECT_EQ_STR(enumtrSym1->name()->text(), "z"); - PSY_EXPECT_EQ_ENU(enumtrSym1->type()->typeKind(), TypeKind::Named, TypeKind); -} - -void SemanticModelTester::case0456(){} -void SemanticModelTester::case0457(){} -void SemanticModelTester::case0458(){} -void SemanticModelTester::case0459(){} -void SemanticModelTester::case0460(){} -void SemanticModelTester::case0461(){} -void SemanticModelTester::case0462(){} -void SemanticModelTester::case0463(){} -void SemanticModelTester::case0464(){} -void SemanticModelTester::case0465(){} -void SemanticModelTester::case0466(){} -void SemanticModelTester::case0467(){} -void SemanticModelTester::case0468(){} -void SemanticModelTester::case0469(){} -void SemanticModelTester::case0470(){} -void SemanticModelTester::case0471(){} -void SemanticModelTester::case0472(){} -void SemanticModelTester::case0473(){} -void SemanticModelTester::case0474(){} -void SemanticModelTester::case0475(){} -void SemanticModelTester::case0476(){} -void SemanticModelTester::case0477(){} -void SemanticModelTester::case0478(){} -void SemanticModelTester::case0479(){} -void SemanticModelTester::case0480(){} -void SemanticModelTester::case0481(){} -void SemanticModelTester::case0482(){} -void SemanticModelTester::case0483(){} -void SemanticModelTester::case0484(){} -void SemanticModelTester::case0485(){} -void SemanticModelTester::case0486(){} -void SemanticModelTester::case0487(){} -void SemanticModelTester::case0488(){} -void SemanticModelTester::case0489(){} -void SemanticModelTester::case0490(){} -void SemanticModelTester::case0491(){} -void SemanticModelTester::case0492(){} -void SemanticModelTester::case0493(){} -void SemanticModelTester::case0494(){} -void SemanticModelTester::case0495(){} -void SemanticModelTester::case0496(){} -void SemanticModelTester::case0497(){} -void SemanticModelTester::case0498(){} -void SemanticModelTester::case0499(){} - -void SemanticModelTester::case0500() -{ - auto s = "int x ; "; - - tree_ = SyntaxTree::parseText(SourceText(s), - TextPreprocessingState::Preprocessed, - TextCompleteness::Fragment, - ParseOptions(), - ""); - - auto TU = tree_->translationUnitRoot(); - PSY_EXPECT_TRUE(TU); - - compilation_ = Compilation::create(tree_->filePath()); - compilation_->addSyntaxTrees({ tree_.get() }); - auto semaModel = compilation_->semanticModel(tree_.get()); - PSY_EXPECT_TRUE(semaModel); - - const LibrarySymbol* libSym = semaModel->declaredSymbol(TU); - PSY_EXPECT_TRUE(libSym); - -} -void SemanticModelTester::case0501(){} -void SemanticModelTester::case0502(){} -void SemanticModelTester::case0503(){} -void SemanticModelTester::case0504(){} -void SemanticModelTester::case0505(){} -void SemanticModelTester::case0506(){} -void SemanticModelTester::case0507(){} -void SemanticModelTester::case0508(){} -void SemanticModelTester::case0509(){} + auto tySpec = tyDecl->typeSpecifier(); + auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); + auto nestedTyDecl = fldDecl0->specifiers() + ->value->asTypeDeclarationAsSpecifier() + ->typeDeclaration(); + + auto nestedTySpec = nestedTyDecl->typeSpecifier(); + auto nestedFldDecl0 = + nestedTySpec->declarations()->value->asFieldDeclaration(); + auto nestedNestedTyDecl = nestedFldDecl0->specifiers() + ->value->asTypeDeclarationAsSpecifier() + ->typeDeclaration(); + + const NamedTypeSymbol *namedTySym = + semaModel->declaredSymbol(nestedNestedTyDecl); + PSY_EXPECT_TRUE(namedTySym); + PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "struct z"); +} + +void SemanticModelTester::case0305() {} +void SemanticModelTester::case0306() {} +void SemanticModelTester::case0307() {} +void SemanticModelTester::case0308() {} +void SemanticModelTester::case0309() {} +void SemanticModelTester::case0310() {} +void SemanticModelTester::case0311() {} +void SemanticModelTester::case0312() {} +void SemanticModelTester::case0313() {} +void SemanticModelTester::case0314() {} +void SemanticModelTester::case0315() {} +void SemanticModelTester::case0316() {} +void SemanticModelTester::case0317() {} +void SemanticModelTester::case0318() {} +void SemanticModelTester::case0319() {} +void SemanticModelTester::case0320() {} +void SemanticModelTester::case0321() {} +void SemanticModelTester::case0322() {} +void SemanticModelTester::case0323() {} +void SemanticModelTester::case0324() {} +void SemanticModelTester::case0325() {} +void SemanticModelTester::case0326() {} +void SemanticModelTester::case0327() {} +void SemanticModelTester::case0328() {} +void SemanticModelTester::case0329() {} +void SemanticModelTester::case0330() {} +void SemanticModelTester::case0331() {} +void SemanticModelTester::case0332() {} +void SemanticModelTester::case0333() {} +void SemanticModelTester::case0334() {} +void SemanticModelTester::case0335() {} +void SemanticModelTester::case0336() {} +void SemanticModelTester::case0337() {} +void SemanticModelTester::case0338() {} +void SemanticModelTester::case0339() {} +void SemanticModelTester::case0340() {} +void SemanticModelTester::case0341() {} +void SemanticModelTester::case0342() {} +void SemanticModelTester::case0343() {} +void SemanticModelTester::case0344() {} +void SemanticModelTester::case0345() {} +void SemanticModelTester::case0346() {} +void SemanticModelTester::case0347() {} +void SemanticModelTester::case0348() {} +void SemanticModelTester::case0349() {} + +void SemanticModelTester::case0350() { + auto [tyDecl, semaModel] = declAndSemaModel( + "struct x { int y ; } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); + std::vector fldSyms0 = + semaModel->declaredSymbols(fldDecl0); + PSY_EXPECT_EQ_INT(fldSyms0.size(), 1); + + const FieldSymbol *fldSym0_0 = fldSyms0[0]; + PSY_EXPECT_TRUE(fldSym0_0); + PSY_EXPECT_EQ_STR(fldSym0_0->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(fldSym0_0->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0351() { + auto [tyDecl, semaModel] = declAndSemaModel( + "struct x { int y , z ; } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); + std::vector fldSyms0 = + semaModel->declaredSymbols(fldDecl0); + PSY_EXPECT_EQ_INT(fldSyms0.size(), 2); + + const FieldSymbol *fldSym0_0 = fldSyms0[0]; + PSY_EXPECT_TRUE(fldSym0_0); + PSY_EXPECT_EQ_STR(fldSym0_0->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(fldSym0_0->type()->typeKind(), TypeKind::Named, TypeKind); + + const FieldSymbol *fldSym0_1 = fldSyms0[1]; + PSY_EXPECT_TRUE(fldSym0_1); + PSY_EXPECT_EQ_STR(fldSym0_1->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(fldSym0_1->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0352() { + auto [tyDecl, semaModel] = declAndSemaModel( + "struct x { int y ; double * z ; } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); + std::vector fldSyms0 = + semaModel->declaredSymbols(fldDecl0); + PSY_EXPECT_EQ_INT(fldSyms0.size(), 1); + + const FieldSymbol *fldSym0_0 = fldSyms0[0]; + PSY_EXPECT_TRUE(fldSym0_0); + PSY_EXPECT_EQ_STR(fldSym0_0->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(fldSym0_0->type()->typeKind(), TypeKind::Named, TypeKind); + + auto fldDecl1 = tySpec->declarations()->next->value->asFieldDeclaration(); + std::vector fldSyms1 = + semaModel->declaredSymbols(fldDecl1); + PSY_EXPECT_EQ_INT(fldSyms1.size(), 1); + + const FieldSymbol *fldSym1_0 = fldSyms1[0]; + PSY_EXPECT_TRUE(fldSym1_0); + PSY_EXPECT_EQ_STR(fldSym1_0->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(fldSym1_0->type()->typeKind(), TypeKind::Pointer, TypeKind); +} + +void SemanticModelTester::case0353() { + auto [tyDecl, semaModel] = declAndSemaModel( + "struct x { int y , z ; double * z, w ; } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto fldDecl0 = tySpec->declarations()->value->asFieldDeclaration(); + std::vector fldSyms0 = + semaModel->declaredSymbols(fldDecl0); + PSY_EXPECT_EQ_INT(fldSyms0.size(), 2); + + const FieldSymbol *fldSym0_0 = fldSyms0[0]; + PSY_EXPECT_TRUE(fldSym0_0); + PSY_EXPECT_EQ_STR(fldSym0_0->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(fldSym0_0->type()->typeKind(), TypeKind::Named, TypeKind); + + const FieldSymbol *fldSym0_1 = fldSyms0[1]; + PSY_EXPECT_TRUE(fldSym0_1); + PSY_EXPECT_EQ_STR(fldSym0_1->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(fldSym0_1->type()->typeKind(), TypeKind::Named, TypeKind); + + auto fldDecl1 = tySpec->declarations()->next->value->asFieldDeclaration(); + std::vector fldSyms1 = + semaModel->declaredSymbols(fldDecl1); + PSY_EXPECT_EQ_INT(fldSyms1.size(), 2); + + const FieldSymbol *fldSym1_0 = fldSyms1[0]; + PSY_EXPECT_TRUE(fldSym1_0); + PSY_EXPECT_EQ_STR(fldSym1_0->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(fldSym1_0->type()->typeKind(), TypeKind::Pointer, TypeKind); + + const FieldSymbol *fldSym1_1 = fldSyms1[1]; + PSY_EXPECT_TRUE(fldSym1_1); + PSY_EXPECT_EQ_STR(fldSym1_1->name()->text(), "w"); + PSY_EXPECT_EQ_ENU(fldSym1_1->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0354() {} +void SemanticModelTester::case0355() {} +void SemanticModelTester::case0356() {} +void SemanticModelTester::case0357() {} +void SemanticModelTester::case0358() {} +void SemanticModelTester::case0359() {} +void SemanticModelTester::case0360() {} +void SemanticModelTester::case0361() {} +void SemanticModelTester::case0362() {} +void SemanticModelTester::case0363() {} +void SemanticModelTester::case0364() {} +void SemanticModelTester::case0365() {} +void SemanticModelTester::case0366() {} +void SemanticModelTester::case0367() {} +void SemanticModelTester::case0368() {} +void SemanticModelTester::case0369() {} +void SemanticModelTester::case0370() {} +void SemanticModelTester::case0371() {} +void SemanticModelTester::case0372() {} +void SemanticModelTester::case0373() {} +void SemanticModelTester::case0374() {} +void SemanticModelTester::case0375() {} +void SemanticModelTester::case0376() {} +void SemanticModelTester::case0377() {} +void SemanticModelTester::case0378() {} +void SemanticModelTester::case0379() {} +void SemanticModelTester::case0380() {} +void SemanticModelTester::case0381() {} +void SemanticModelTester::case0382() {} +void SemanticModelTester::case0383() {} +void SemanticModelTester::case0384() {} +void SemanticModelTester::case0385() {} +void SemanticModelTester::case0386() {} +void SemanticModelTester::case0387() {} +void SemanticModelTester::case0388() {} +void SemanticModelTester::case0389() {} +void SemanticModelTester::case0390() {} +void SemanticModelTester::case0391() {} +void SemanticModelTester::case0392() {} +void SemanticModelTester::case0393() {} +void SemanticModelTester::case0394() {} +void SemanticModelTester::case0395() {} +void SemanticModelTester::case0396() {} +void SemanticModelTester::case0397() {} +void SemanticModelTester::case0398() {} +void SemanticModelTester::case0399() {} + +void SemanticModelTester::case0400() { + auto [tyDecl, semaModel] = + declAndSemaModel("enum x { y } ;"); + + const NamedTypeSymbol *namedTySym = semaModel->declaredSymbol(tyDecl); + PSY_EXPECT_TRUE(namedTySym); + PSY_EXPECT_EQ_STR(namedTySym->name()->text(), "enum x"); +} + +void SemanticModelTester::case0401() {} + +void SemanticModelTester::case0402() {} + +void SemanticModelTester::case0403() {} + +void SemanticModelTester::case0404() {} +void SemanticModelTester::case0405() {} +void SemanticModelTester::case0406() {} +void SemanticModelTester::case0407() {} +void SemanticModelTester::case0408() {} +void SemanticModelTester::case0409() {} +void SemanticModelTester::case0410() {} +void SemanticModelTester::case0411() {} +void SemanticModelTester::case0412() {} +void SemanticModelTester::case0413() {} +void SemanticModelTester::case0414() {} +void SemanticModelTester::case0415() {} +void SemanticModelTester::case0416() {} +void SemanticModelTester::case0417() {} +void SemanticModelTester::case0418() {} +void SemanticModelTester::case0419() {} +void SemanticModelTester::case0420() {} +void SemanticModelTester::case0421() {} +void SemanticModelTester::case0422() {} +void SemanticModelTester::case0423() {} +void SemanticModelTester::case0424() {} +void SemanticModelTester::case0425() {} +void SemanticModelTester::case0426() {} +void SemanticModelTester::case0427() {} +void SemanticModelTester::case0428() {} +void SemanticModelTester::case0429() {} +void SemanticModelTester::case0430() {} +void SemanticModelTester::case0431() {} +void SemanticModelTester::case0432() {} +void SemanticModelTester::case0433() {} +void SemanticModelTester::case0434() {} +void SemanticModelTester::case0435() {} +void SemanticModelTester::case0436() {} +void SemanticModelTester::case0437() {} +void SemanticModelTester::case0438() {} +void SemanticModelTester::case0439() {} +void SemanticModelTester::case0440() {} +void SemanticModelTester::case0441() {} +void SemanticModelTester::case0442() {} +void SemanticModelTester::case0443() {} +void SemanticModelTester::case0444() {} +void SemanticModelTester::case0445() {} +void SemanticModelTester::case0446() {} +void SemanticModelTester::case0447() {} +void SemanticModelTester::case0448() {} +void SemanticModelTester::case0449() {} + +void SemanticModelTester::case0450() { + auto [tyDecl, semaModel] = + declAndSemaModel("enum x { y } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym = semaModel->declaredSymbol(enumtrDecl0); + PSY_EXPECT_TRUE(enumtrSym); + PSY_EXPECT_EQ_STR(enumtrSym->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(enumtrSym->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0451() { + auto [tyDecl, semaModel] = + declAndSemaModel("enum x { y = 0 } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym = semaModel->declaredSymbol(enumtrDecl0); + PSY_EXPECT_TRUE(enumtrSym); + PSY_EXPECT_EQ_STR(enumtrSym->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(enumtrSym->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0452() { + auto [tyDecl, semaModel] = + declAndSemaModel("enum x { y , z } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym0 = semaModel->declaredSymbol(enumtrDecl0); + PSY_EXPECT_TRUE(enumtrSym0); + PSY_EXPECT_EQ_STR(enumtrSym0->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(enumtrSym0->type()->typeKind(), TypeKind::Named, TypeKind); + + auto enumtrDecl1 = + tySpec->declarations()->next->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym1 = semaModel->declaredSymbol(enumtrDecl1); + PSY_EXPECT_TRUE(enumtrSym1); + PSY_EXPECT_EQ_STR(enumtrSym1->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(enumtrSym1->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0453() { + auto [tyDecl, semaModel] = + declAndSemaModel("enum x { y = 0 , z } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym0 = semaModel->declaredSymbol(enumtrDecl0); + PSY_EXPECT_TRUE(enumtrSym0); + PSY_EXPECT_EQ_STR(enumtrSym0->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(enumtrSym0->type()->typeKind(), TypeKind::Named, TypeKind); + + auto enumtrDecl1 = + tySpec->declarations()->next->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym1 = semaModel->declaredSymbol(enumtrDecl1); + PSY_EXPECT_TRUE(enumtrSym1); + PSY_EXPECT_EQ_STR(enumtrSym1->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(enumtrSym1->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0454() { + auto [tyDecl, semaModel] = + declAndSemaModel("enum x { y = 0 , z = 1 } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym0 = semaModel->declaredSymbol(enumtrDecl0); + PSY_EXPECT_TRUE(enumtrSym0); + PSY_EXPECT_EQ_STR(enumtrSym0->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(enumtrSym0->type()->typeKind(), TypeKind::Named, TypeKind); + + auto enumtrDecl1 = + tySpec->declarations()->next->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym1 = semaModel->declaredSymbol(enumtrDecl1); + PSY_EXPECT_TRUE(enumtrSym1); + PSY_EXPECT_EQ_STR(enumtrSym1->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(enumtrSym1->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0455() { + auto [tyDecl, semaModel] = + declAndSemaModel("enum x { y , z = 1 } ;"); + + auto tySpec = tyDecl->typeSpecifier(); + + auto enumtrDecl0 = tySpec->declarations()->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym0 = semaModel->declaredSymbol(enumtrDecl0); + PSY_EXPECT_TRUE(enumtrSym0); + PSY_EXPECT_EQ_STR(enumtrSym0->name()->text(), "y"); + PSY_EXPECT_EQ_ENU(enumtrSym0->type()->typeKind(), TypeKind::Named, TypeKind); + + auto enumtrDecl1 = + tySpec->declarations()->next->value->asEnumeratorDeclaration(); + + const EnumeratorSymbol *enumtrSym1 = semaModel->declaredSymbol(enumtrDecl1); + PSY_EXPECT_TRUE(enumtrSym1); + PSY_EXPECT_EQ_STR(enumtrSym1->name()->text(), "z"); + PSY_EXPECT_EQ_ENU(enumtrSym1->type()->typeKind(), TypeKind::Named, TypeKind); +} + +void SemanticModelTester::case0456() {} +void SemanticModelTester::case0457() {} +void SemanticModelTester::case0458() {} +void SemanticModelTester::case0459() {} +void SemanticModelTester::case0460() {} +void SemanticModelTester::case0461() {} +void SemanticModelTester::case0462() {} +void SemanticModelTester::case0463() {} +void SemanticModelTester::case0464() {} +void SemanticModelTester::case0465() {} +void SemanticModelTester::case0466() {} +void SemanticModelTester::case0467() {} +void SemanticModelTester::case0468() {} +void SemanticModelTester::case0469() {} +void SemanticModelTester::case0470() {} +void SemanticModelTester::case0471() {} +void SemanticModelTester::case0472() {} +void SemanticModelTester::case0473() {} +void SemanticModelTester::case0474() {} +void SemanticModelTester::case0475() {} +void SemanticModelTester::case0476() {} +void SemanticModelTester::case0477() {} +void SemanticModelTester::case0478() {} +void SemanticModelTester::case0479() {} +void SemanticModelTester::case0480() {} +void SemanticModelTester::case0481() {} +void SemanticModelTester::case0482() {} +void SemanticModelTester::case0483() {} +void SemanticModelTester::case0484() {} +void SemanticModelTester::case0485() {} +void SemanticModelTester::case0486() {} +void SemanticModelTester::case0487() {} +void SemanticModelTester::case0488() {} +void SemanticModelTester::case0489() {} +void SemanticModelTester::case0490() {} +void SemanticModelTester::case0491() {} +void SemanticModelTester::case0492() {} +void SemanticModelTester::case0493() {} +void SemanticModelTester::case0494() {} +void SemanticModelTester::case0495() {} +void SemanticModelTester::case0496() {} +void SemanticModelTester::case0497() {} +void SemanticModelTester::case0498() {} +void SemanticModelTester::case0499() {} + +void SemanticModelTester::case0500() { + auto s = "int x ; "; + + tree_ = SyntaxTree::parseText( + SourceText(s), TextPreprocessingState::Preprocessed, + TextCompleteness::Fragment, ParseOptions(), ""); + + auto TU = tree_->translationUnitRoot(); + PSY_EXPECT_TRUE(TU); + + compilation_ = Compilation::create(tree_->filePath()); + compilation_->addSyntaxTrees({tree_.get()}); + auto semaModel = compilation_->semanticModel(tree_.get()); + PSY_EXPECT_TRUE(semaModel); + + const LibrarySymbol *libSym = semaModel->declaredSymbol(TU); + PSY_EXPECT_TRUE(libSym); +} +void SemanticModelTester::case0501() {} +void SemanticModelTester::case0502() {} +void SemanticModelTester::case0503() {} +void SemanticModelTester::case0504() {} +void SemanticModelTester::case0505() {} +void SemanticModelTester::case0506() {} +void SemanticModelTester::case0507() {} +void SemanticModelTester::case0508() {} +void SemanticModelTester::case0509() {} diff --git a/C/tests/SemanticModelTester.h b/C/tests/SemanticModelTester.h index df22350ab..5a20dd0b4 100644 --- a/C/tests/SemanticModelTester.h +++ b/C/tests/SemanticModelTester.h @@ -26,612 +26,613 @@ #include "tests/Tester.h" #include "C/SyntaxTree.h" -#include "C/syntax/SyntaxNodes.h" #include "C/compilation/SemanticModel.h" +#include "C/syntax/SyntaxNodes.h" -#define TEST_SEMANTIC_MODEL(Function) TestFunction { &SemanticModelTester::Function, #Function } +#define TEST_SEMANTIC_MODEL(Function) \ + TestFunction { &SemanticModelTester::Function, #Function } namespace psy { namespace C { class APITestSuite; -class SemanticModelTester final : public Tester -{ +class SemanticModelTester final : public Tester { public: - SemanticModelTester(TestSuite* suite) : Tester(suite) {} + SemanticModelTester(TestSuite *suite) : Tester(suite) {} - APITestSuite* suite(); + APITestSuite *suite(); - static const std::string Name; - virtual std::string name() const override { return Name; } - virtual void setUp() override; - virtual void tearDown() override; + static const std::string Name; + virtual std::string name() const override { return Name; } + virtual void setUp() override; + virtual void tearDown() override; - std::unique_ptr tree_; - std::unique_ptr compilation_; + std::unique_ptr tree_; + std::unique_ptr compilation_; - template - std::tuple declAndSemaModel(const std::string& s); + template + std::tuple + declAndSemaModel(const std::string &s); - void testSemanticModel(); + void testSemanticModel(); - using TestFunction = std::pair, const char*>; + using TestFunction = + std::pair, const char *>; - /* - + 0000-0089 -> variable - + 0090-0099 -> variable and function (declaration) - + 0100-0149 -> function (declaration) - + 0150-0199 -> function (definition) - + 0200-0299 -> parameter - + 0300-0349 -> struct/union - + 0350-0399 -> field - + 0400-0449 -> enum - + 0450-0499 -> enumerator - + 0500-0509 -> library - */ + /* + + 0000-0089 -> variable + + 0090-0099 -> variable and function (declaration) + + 0100-0149 -> function (declaration) + + 0150-0199 -> function (definition) + + 0200-0299 -> parameter + + 0300-0349 -> struct/union + + 0350-0399 -> field + + 0400-0449 -> enum + + 0450-0499 -> enumerator + + 0500-0509 -> library + */ - void case0001(); - void case0002(); - void case0003(); - void case0004(); - void case0005(); - void case0006(); - void case0007(); - void case0008(); - void case0009(); - void case0010(); - //... - void case0090(); - void case0091(); - void case0092(); - void case0093(); - void case0094(); - void case0095(); - void case0096(); - void case0097(); - void case0098(); - void case0099(); + void case0001(); + void case0002(); + void case0003(); + void case0004(); + void case0005(); + void case0006(); + void case0007(); + void case0008(); + void case0009(); + void case0010(); + //... + void case0090(); + void case0091(); + void case0092(); + void case0093(); + void case0094(); + void case0095(); + void case0096(); + void case0097(); + void case0098(); + void case0099(); - void case0101(); - void case0102(); - void case0103(); - void case0104(); - void case0105(); - void case0106(); - void case0107(); - void case0108(); - void case0109(); - void case0110(); - //... - void case0150(); - void case0151(); - void case0152(); - void case0153(); - void case0154(); - void case0155(); - void case0156(); - void case0157(); - void case0158(); - void case0159(); + void case0101(); + void case0102(); + void case0103(); + void case0104(); + void case0105(); + void case0106(); + void case0107(); + void case0108(); + void case0109(); + void case0110(); + //... + void case0150(); + void case0151(); + void case0152(); + void case0153(); + void case0154(); + void case0155(); + void case0156(); + void case0157(); + void case0158(); + void case0159(); - void case0201(); - void case0202(); - void case0203(); - void case0204(); - void case0205(); - void case0206(); - void case0207(); - void case0208(); - void case0209(); - void case0210(); - void case0211(); - void case0212(); - void case0213(); - void case0214(); - void case0215(); - void case0216(); - void case0217(); - void case0218(); - void case0219(); - void case0220(); + void case0201(); + void case0202(); + void case0203(); + void case0204(); + void case0205(); + void case0206(); + void case0207(); + void case0208(); + void case0209(); + void case0210(); + void case0211(); + void case0212(); + void case0213(); + void case0214(); + void case0215(); + void case0216(); + void case0217(); + void case0218(); + void case0219(); + void case0220(); - void case0300(); - void case0301(); - void case0302(); - void case0303(); - void case0304(); - void case0305(); - void case0306(); - void case0307(); - void case0308(); - void case0309(); - void case0310(); - void case0311(); - void case0312(); - void case0313(); - void case0314(); - void case0315(); - void case0316(); - void case0317(); - void case0318(); - void case0319(); - void case0320(); - void case0321(); - void case0322(); - void case0323(); - void case0324(); - void case0325(); - void case0326(); - void case0327(); - void case0328(); - void case0329(); - void case0330(); - void case0331(); - void case0332(); - void case0333(); - void case0334(); - void case0335(); - void case0336(); - void case0337(); - void case0338(); - void case0339(); - void case0340(); - void case0341(); - void case0342(); - void case0343(); - void case0344(); - void case0345(); - void case0346(); - void case0347(); - void case0348(); - void case0349(); - void case0350(); - void case0351(); - void case0352(); - void case0353(); - void case0354(); - void case0355(); - void case0356(); - void case0357(); - void case0358(); - void case0359(); - void case0360(); - void case0361(); - void case0362(); - void case0363(); - void case0364(); - void case0365(); - void case0366(); - void case0367(); - void case0368(); - void case0369(); - void case0370(); - void case0371(); - void case0372(); - void case0373(); - void case0374(); - void case0375(); - void case0376(); - void case0377(); - void case0378(); - void case0379(); - void case0380(); - void case0381(); - void case0382(); - void case0383(); - void case0384(); - void case0385(); - void case0386(); - void case0387(); - void case0388(); - void case0389(); - void case0390(); - void case0391(); - void case0392(); - void case0393(); - void case0394(); - void case0395(); - void case0396(); - void case0397(); - void case0398(); - void case0399(); + void case0300(); + void case0301(); + void case0302(); + void case0303(); + void case0304(); + void case0305(); + void case0306(); + void case0307(); + void case0308(); + void case0309(); + void case0310(); + void case0311(); + void case0312(); + void case0313(); + void case0314(); + void case0315(); + void case0316(); + void case0317(); + void case0318(); + void case0319(); + void case0320(); + void case0321(); + void case0322(); + void case0323(); + void case0324(); + void case0325(); + void case0326(); + void case0327(); + void case0328(); + void case0329(); + void case0330(); + void case0331(); + void case0332(); + void case0333(); + void case0334(); + void case0335(); + void case0336(); + void case0337(); + void case0338(); + void case0339(); + void case0340(); + void case0341(); + void case0342(); + void case0343(); + void case0344(); + void case0345(); + void case0346(); + void case0347(); + void case0348(); + void case0349(); + void case0350(); + void case0351(); + void case0352(); + void case0353(); + void case0354(); + void case0355(); + void case0356(); + void case0357(); + void case0358(); + void case0359(); + void case0360(); + void case0361(); + void case0362(); + void case0363(); + void case0364(); + void case0365(); + void case0366(); + void case0367(); + void case0368(); + void case0369(); + void case0370(); + void case0371(); + void case0372(); + void case0373(); + void case0374(); + void case0375(); + void case0376(); + void case0377(); + void case0378(); + void case0379(); + void case0380(); + void case0381(); + void case0382(); + void case0383(); + void case0384(); + void case0385(); + void case0386(); + void case0387(); + void case0388(); + void case0389(); + void case0390(); + void case0391(); + void case0392(); + void case0393(); + void case0394(); + void case0395(); + void case0396(); + void case0397(); + void case0398(); + void case0399(); - void case0400(); - void case0401(); - void case0402(); - void case0403(); - void case0404(); - void case0405(); - void case0406(); - void case0407(); - void case0408(); - void case0409(); - void case0410(); - void case0411(); - void case0412(); - void case0413(); - void case0414(); - void case0415(); - void case0416(); - void case0417(); - void case0418(); - void case0419(); - void case0420(); - void case0421(); - void case0422(); - void case0423(); - void case0424(); - void case0425(); - void case0426(); - void case0427(); - void case0428(); - void case0429(); - void case0430(); - void case0431(); - void case0432(); - void case0433(); - void case0434(); - void case0435(); - void case0436(); - void case0437(); - void case0438(); - void case0439(); - void case0440(); - void case0441(); - void case0442(); - void case0443(); - void case0444(); - void case0445(); - void case0446(); - void case0447(); - void case0448(); - void case0449(); - void case0450(); - void case0451(); - void case0452(); - void case0453(); - void case0454(); - void case0455(); - void case0456(); - void case0457(); - void case0458(); - void case0459(); - void case0460(); - void case0461(); - void case0462(); - void case0463(); - void case0464(); - void case0465(); - void case0466(); - void case0467(); - void case0468(); - void case0469(); - void case0470(); - void case0471(); - void case0472(); - void case0473(); - void case0474(); - void case0475(); - void case0476(); - void case0477(); - void case0478(); - void case0479(); - void case0480(); - void case0481(); - void case0482(); - void case0483(); - void case0484(); - void case0485(); - void case0486(); - void case0487(); - void case0488(); - void case0489(); - void case0490(); - void case0491(); - void case0492(); - void case0493(); - void case0494(); - void case0495(); - void case0496(); - void case0497(); - void case0498(); - void case0499(); + void case0400(); + void case0401(); + void case0402(); + void case0403(); + void case0404(); + void case0405(); + void case0406(); + void case0407(); + void case0408(); + void case0409(); + void case0410(); + void case0411(); + void case0412(); + void case0413(); + void case0414(); + void case0415(); + void case0416(); + void case0417(); + void case0418(); + void case0419(); + void case0420(); + void case0421(); + void case0422(); + void case0423(); + void case0424(); + void case0425(); + void case0426(); + void case0427(); + void case0428(); + void case0429(); + void case0430(); + void case0431(); + void case0432(); + void case0433(); + void case0434(); + void case0435(); + void case0436(); + void case0437(); + void case0438(); + void case0439(); + void case0440(); + void case0441(); + void case0442(); + void case0443(); + void case0444(); + void case0445(); + void case0446(); + void case0447(); + void case0448(); + void case0449(); + void case0450(); + void case0451(); + void case0452(); + void case0453(); + void case0454(); + void case0455(); + void case0456(); + void case0457(); + void case0458(); + void case0459(); + void case0460(); + void case0461(); + void case0462(); + void case0463(); + void case0464(); + void case0465(); + void case0466(); + void case0467(); + void case0468(); + void case0469(); + void case0470(); + void case0471(); + void case0472(); + void case0473(); + void case0474(); + void case0475(); + void case0476(); + void case0477(); + void case0478(); + void case0479(); + void case0480(); + void case0481(); + void case0482(); + void case0483(); + void case0484(); + void case0485(); + void case0486(); + void case0487(); + void case0488(); + void case0489(); + void case0490(); + void case0491(); + void case0492(); + void case0493(); + void case0494(); + void case0495(); + void case0496(); + void case0497(); + void case0498(); + void case0499(); - void case0500(); - void case0501(); - void case0502(); - void case0503(); - void case0504(); - void case0505(); - void case0506(); - void case0507(); - void case0508(); - void case0509(); + void case0500(); + void case0501(); + void case0502(); + void case0503(); + void case0504(); + void case0505(); + void case0506(); + void case0507(); + void case0508(); + void case0509(); - std::vector tests_ - { - TEST_SEMANTIC_MODEL(case0001), - TEST_SEMANTIC_MODEL(case0002), - TEST_SEMANTIC_MODEL(case0003), - TEST_SEMANTIC_MODEL(case0004), - TEST_SEMANTIC_MODEL(case0005), - TEST_SEMANTIC_MODEL(case0006), - TEST_SEMANTIC_MODEL(case0007), - TEST_SEMANTIC_MODEL(case0008), - TEST_SEMANTIC_MODEL(case0009), - TEST_SEMANTIC_MODEL(case0010), - //... - TEST_SEMANTIC_MODEL(case0090), - TEST_SEMANTIC_MODEL(case0091), - TEST_SEMANTIC_MODEL(case0092), - TEST_SEMANTIC_MODEL(case0093), - TEST_SEMANTIC_MODEL(case0094), - TEST_SEMANTIC_MODEL(case0095), - TEST_SEMANTIC_MODEL(case0096), - TEST_SEMANTIC_MODEL(case0097), - TEST_SEMANTIC_MODEL(case0098), - TEST_SEMANTIC_MODEL(case0099), + std::vector tests_{ + TEST_SEMANTIC_MODEL(case0001), + TEST_SEMANTIC_MODEL(case0002), + TEST_SEMANTIC_MODEL(case0003), + TEST_SEMANTIC_MODEL(case0004), + TEST_SEMANTIC_MODEL(case0005), + TEST_SEMANTIC_MODEL(case0006), + TEST_SEMANTIC_MODEL(case0007), + TEST_SEMANTIC_MODEL(case0008), + TEST_SEMANTIC_MODEL(case0009), + TEST_SEMANTIC_MODEL(case0010), + //... + TEST_SEMANTIC_MODEL(case0090), + TEST_SEMANTIC_MODEL(case0091), + TEST_SEMANTIC_MODEL(case0092), + TEST_SEMANTIC_MODEL(case0093), + TEST_SEMANTIC_MODEL(case0094), + TEST_SEMANTIC_MODEL(case0095), + TEST_SEMANTIC_MODEL(case0096), + TEST_SEMANTIC_MODEL(case0097), + TEST_SEMANTIC_MODEL(case0098), + TEST_SEMANTIC_MODEL(case0099), - TEST_SEMANTIC_MODEL(case0101), - TEST_SEMANTIC_MODEL(case0102), - TEST_SEMANTIC_MODEL(case0103), - TEST_SEMANTIC_MODEL(case0104), - TEST_SEMANTIC_MODEL(case0105), - TEST_SEMANTIC_MODEL(case0106), - TEST_SEMANTIC_MODEL(case0107), - TEST_SEMANTIC_MODEL(case0108), - TEST_SEMANTIC_MODEL(case0109), - TEST_SEMANTIC_MODEL(case0110), - //... - TEST_SEMANTIC_MODEL(case0150), - TEST_SEMANTIC_MODEL(case0151), - TEST_SEMANTIC_MODEL(case0152), - TEST_SEMANTIC_MODEL(case0153), - TEST_SEMANTIC_MODEL(case0154), - TEST_SEMANTIC_MODEL(case0155), - TEST_SEMANTIC_MODEL(case0156), - TEST_SEMANTIC_MODEL(case0157), - TEST_SEMANTIC_MODEL(case0158), - TEST_SEMANTIC_MODEL(case0159), + TEST_SEMANTIC_MODEL(case0101), + TEST_SEMANTIC_MODEL(case0102), + TEST_SEMANTIC_MODEL(case0103), + TEST_SEMANTIC_MODEL(case0104), + TEST_SEMANTIC_MODEL(case0105), + TEST_SEMANTIC_MODEL(case0106), + TEST_SEMANTIC_MODEL(case0107), + TEST_SEMANTIC_MODEL(case0108), + TEST_SEMANTIC_MODEL(case0109), + TEST_SEMANTIC_MODEL(case0110), + //... + TEST_SEMANTIC_MODEL(case0150), + TEST_SEMANTIC_MODEL(case0151), + TEST_SEMANTIC_MODEL(case0152), + TEST_SEMANTIC_MODEL(case0153), + TEST_SEMANTIC_MODEL(case0154), + TEST_SEMANTIC_MODEL(case0155), + TEST_SEMANTIC_MODEL(case0156), + TEST_SEMANTIC_MODEL(case0157), + TEST_SEMANTIC_MODEL(case0158), + TEST_SEMANTIC_MODEL(case0159), - TEST_SEMANTIC_MODEL(case0201), - TEST_SEMANTIC_MODEL(case0202), - TEST_SEMANTIC_MODEL(case0203), - TEST_SEMANTIC_MODEL(case0204), - TEST_SEMANTIC_MODEL(case0205), - TEST_SEMANTIC_MODEL(case0206), - TEST_SEMANTIC_MODEL(case0207), - TEST_SEMANTIC_MODEL(case0208), - TEST_SEMANTIC_MODEL(case0209), - TEST_SEMANTIC_MODEL(case0210), - TEST_SEMANTIC_MODEL(case0211), - TEST_SEMANTIC_MODEL(case0212), - TEST_SEMANTIC_MODEL(case0213), - TEST_SEMANTIC_MODEL(case0214), - TEST_SEMANTIC_MODEL(case0215), - TEST_SEMANTIC_MODEL(case0216), - TEST_SEMANTIC_MODEL(case0217), - TEST_SEMANTIC_MODEL(case0218), - TEST_SEMANTIC_MODEL(case0219), - TEST_SEMANTIC_MODEL(case0220), + TEST_SEMANTIC_MODEL(case0201), + TEST_SEMANTIC_MODEL(case0202), + TEST_SEMANTIC_MODEL(case0203), + TEST_SEMANTIC_MODEL(case0204), + TEST_SEMANTIC_MODEL(case0205), + TEST_SEMANTIC_MODEL(case0206), + TEST_SEMANTIC_MODEL(case0207), + TEST_SEMANTIC_MODEL(case0208), + TEST_SEMANTIC_MODEL(case0209), + TEST_SEMANTIC_MODEL(case0210), + TEST_SEMANTIC_MODEL(case0211), + TEST_SEMANTIC_MODEL(case0212), + TEST_SEMANTIC_MODEL(case0213), + TEST_SEMANTIC_MODEL(case0214), + TEST_SEMANTIC_MODEL(case0215), + TEST_SEMANTIC_MODEL(case0216), + TEST_SEMANTIC_MODEL(case0217), + TEST_SEMANTIC_MODEL(case0218), + TEST_SEMANTIC_MODEL(case0219), + TEST_SEMANTIC_MODEL(case0220), - TEST_SEMANTIC_MODEL(case0300), - TEST_SEMANTIC_MODEL(case0301), - TEST_SEMANTIC_MODEL(case0302), - TEST_SEMANTIC_MODEL(case0303), - TEST_SEMANTIC_MODEL(case0304), - TEST_SEMANTIC_MODEL(case0305), - TEST_SEMANTIC_MODEL(case0306), - TEST_SEMANTIC_MODEL(case0307), - TEST_SEMANTIC_MODEL(case0308), - TEST_SEMANTIC_MODEL(case0309), - TEST_SEMANTIC_MODEL(case0310), - TEST_SEMANTIC_MODEL(case0311), - TEST_SEMANTIC_MODEL(case0312), - TEST_SEMANTIC_MODEL(case0313), - TEST_SEMANTIC_MODEL(case0314), - TEST_SEMANTIC_MODEL(case0315), - TEST_SEMANTIC_MODEL(case0316), - TEST_SEMANTIC_MODEL(case0317), - TEST_SEMANTIC_MODEL(case0318), - TEST_SEMANTIC_MODEL(case0319), - TEST_SEMANTIC_MODEL(case0320), - TEST_SEMANTIC_MODEL(case0321), - TEST_SEMANTIC_MODEL(case0322), - TEST_SEMANTIC_MODEL(case0323), - TEST_SEMANTIC_MODEL(case0324), - TEST_SEMANTIC_MODEL(case0325), - TEST_SEMANTIC_MODEL(case0326), - TEST_SEMANTIC_MODEL(case0327), - TEST_SEMANTIC_MODEL(case0328), - TEST_SEMANTIC_MODEL(case0329), - TEST_SEMANTIC_MODEL(case0330), - TEST_SEMANTIC_MODEL(case0331), - TEST_SEMANTIC_MODEL(case0332), - TEST_SEMANTIC_MODEL(case0333), - TEST_SEMANTIC_MODEL(case0334), - TEST_SEMANTIC_MODEL(case0335), - TEST_SEMANTIC_MODEL(case0336), - TEST_SEMANTIC_MODEL(case0337), - TEST_SEMANTIC_MODEL(case0338), - TEST_SEMANTIC_MODEL(case0339), - TEST_SEMANTIC_MODEL(case0340), - TEST_SEMANTIC_MODEL(case0341), - TEST_SEMANTIC_MODEL(case0342), - TEST_SEMANTIC_MODEL(case0343), - TEST_SEMANTIC_MODEL(case0344), - TEST_SEMANTIC_MODEL(case0345), - TEST_SEMANTIC_MODEL(case0346), - TEST_SEMANTIC_MODEL(case0347), - TEST_SEMANTIC_MODEL(case0348), - TEST_SEMANTIC_MODEL(case0349), - TEST_SEMANTIC_MODEL(case0350), - TEST_SEMANTIC_MODEL(case0351), - TEST_SEMANTIC_MODEL(case0352), - TEST_SEMANTIC_MODEL(case0353), - TEST_SEMANTIC_MODEL(case0354), - TEST_SEMANTIC_MODEL(case0355), - TEST_SEMANTIC_MODEL(case0356), - TEST_SEMANTIC_MODEL(case0357), - TEST_SEMANTIC_MODEL(case0358), - TEST_SEMANTIC_MODEL(case0359), - TEST_SEMANTIC_MODEL(case0360), - TEST_SEMANTIC_MODEL(case0361), - TEST_SEMANTIC_MODEL(case0362), - TEST_SEMANTIC_MODEL(case0363), - TEST_SEMANTIC_MODEL(case0364), - TEST_SEMANTIC_MODEL(case0365), - TEST_SEMANTIC_MODEL(case0366), - TEST_SEMANTIC_MODEL(case0367), - TEST_SEMANTIC_MODEL(case0368), - TEST_SEMANTIC_MODEL(case0369), - TEST_SEMANTIC_MODEL(case0370), - TEST_SEMANTIC_MODEL(case0371), - TEST_SEMANTIC_MODEL(case0372), - TEST_SEMANTIC_MODEL(case0373), - TEST_SEMANTIC_MODEL(case0374), - TEST_SEMANTIC_MODEL(case0375), - TEST_SEMANTIC_MODEL(case0376), - TEST_SEMANTIC_MODEL(case0377), - TEST_SEMANTIC_MODEL(case0378), - TEST_SEMANTIC_MODEL(case0379), - TEST_SEMANTIC_MODEL(case0380), - TEST_SEMANTIC_MODEL(case0381), - TEST_SEMANTIC_MODEL(case0382), - TEST_SEMANTIC_MODEL(case0383), - TEST_SEMANTIC_MODEL(case0384), - TEST_SEMANTIC_MODEL(case0385), - TEST_SEMANTIC_MODEL(case0386), - TEST_SEMANTIC_MODEL(case0387), - TEST_SEMANTIC_MODEL(case0388), - TEST_SEMANTIC_MODEL(case0389), - TEST_SEMANTIC_MODEL(case0390), - TEST_SEMANTIC_MODEL(case0391), - TEST_SEMANTIC_MODEL(case0392), - TEST_SEMANTIC_MODEL(case0393), - TEST_SEMANTIC_MODEL(case0394), - TEST_SEMANTIC_MODEL(case0395), - TEST_SEMANTIC_MODEL(case0396), - TEST_SEMANTIC_MODEL(case0397), - TEST_SEMANTIC_MODEL(case0398), - TEST_SEMANTIC_MODEL(case0399), + TEST_SEMANTIC_MODEL(case0300), + TEST_SEMANTIC_MODEL(case0301), + TEST_SEMANTIC_MODEL(case0302), + TEST_SEMANTIC_MODEL(case0303), + TEST_SEMANTIC_MODEL(case0304), + TEST_SEMANTIC_MODEL(case0305), + TEST_SEMANTIC_MODEL(case0306), + TEST_SEMANTIC_MODEL(case0307), + TEST_SEMANTIC_MODEL(case0308), + TEST_SEMANTIC_MODEL(case0309), + TEST_SEMANTIC_MODEL(case0310), + TEST_SEMANTIC_MODEL(case0311), + TEST_SEMANTIC_MODEL(case0312), + TEST_SEMANTIC_MODEL(case0313), + TEST_SEMANTIC_MODEL(case0314), + TEST_SEMANTIC_MODEL(case0315), + TEST_SEMANTIC_MODEL(case0316), + TEST_SEMANTIC_MODEL(case0317), + TEST_SEMANTIC_MODEL(case0318), + TEST_SEMANTIC_MODEL(case0319), + TEST_SEMANTIC_MODEL(case0320), + TEST_SEMANTIC_MODEL(case0321), + TEST_SEMANTIC_MODEL(case0322), + TEST_SEMANTIC_MODEL(case0323), + TEST_SEMANTIC_MODEL(case0324), + TEST_SEMANTIC_MODEL(case0325), + TEST_SEMANTIC_MODEL(case0326), + TEST_SEMANTIC_MODEL(case0327), + TEST_SEMANTIC_MODEL(case0328), + TEST_SEMANTIC_MODEL(case0329), + TEST_SEMANTIC_MODEL(case0330), + TEST_SEMANTIC_MODEL(case0331), + TEST_SEMANTIC_MODEL(case0332), + TEST_SEMANTIC_MODEL(case0333), + TEST_SEMANTIC_MODEL(case0334), + TEST_SEMANTIC_MODEL(case0335), + TEST_SEMANTIC_MODEL(case0336), + TEST_SEMANTIC_MODEL(case0337), + TEST_SEMANTIC_MODEL(case0338), + TEST_SEMANTIC_MODEL(case0339), + TEST_SEMANTIC_MODEL(case0340), + TEST_SEMANTIC_MODEL(case0341), + TEST_SEMANTIC_MODEL(case0342), + TEST_SEMANTIC_MODEL(case0343), + TEST_SEMANTIC_MODEL(case0344), + TEST_SEMANTIC_MODEL(case0345), + TEST_SEMANTIC_MODEL(case0346), + TEST_SEMANTIC_MODEL(case0347), + TEST_SEMANTIC_MODEL(case0348), + TEST_SEMANTIC_MODEL(case0349), + TEST_SEMANTIC_MODEL(case0350), + TEST_SEMANTIC_MODEL(case0351), + TEST_SEMANTIC_MODEL(case0352), + TEST_SEMANTIC_MODEL(case0353), + TEST_SEMANTIC_MODEL(case0354), + TEST_SEMANTIC_MODEL(case0355), + TEST_SEMANTIC_MODEL(case0356), + TEST_SEMANTIC_MODEL(case0357), + TEST_SEMANTIC_MODEL(case0358), + TEST_SEMANTIC_MODEL(case0359), + TEST_SEMANTIC_MODEL(case0360), + TEST_SEMANTIC_MODEL(case0361), + TEST_SEMANTIC_MODEL(case0362), + TEST_SEMANTIC_MODEL(case0363), + TEST_SEMANTIC_MODEL(case0364), + TEST_SEMANTIC_MODEL(case0365), + TEST_SEMANTIC_MODEL(case0366), + TEST_SEMANTIC_MODEL(case0367), + TEST_SEMANTIC_MODEL(case0368), + TEST_SEMANTIC_MODEL(case0369), + TEST_SEMANTIC_MODEL(case0370), + TEST_SEMANTIC_MODEL(case0371), + TEST_SEMANTIC_MODEL(case0372), + TEST_SEMANTIC_MODEL(case0373), + TEST_SEMANTIC_MODEL(case0374), + TEST_SEMANTIC_MODEL(case0375), + TEST_SEMANTIC_MODEL(case0376), + TEST_SEMANTIC_MODEL(case0377), + TEST_SEMANTIC_MODEL(case0378), + TEST_SEMANTIC_MODEL(case0379), + TEST_SEMANTIC_MODEL(case0380), + TEST_SEMANTIC_MODEL(case0381), + TEST_SEMANTIC_MODEL(case0382), + TEST_SEMANTIC_MODEL(case0383), + TEST_SEMANTIC_MODEL(case0384), + TEST_SEMANTIC_MODEL(case0385), + TEST_SEMANTIC_MODEL(case0386), + TEST_SEMANTIC_MODEL(case0387), + TEST_SEMANTIC_MODEL(case0388), + TEST_SEMANTIC_MODEL(case0389), + TEST_SEMANTIC_MODEL(case0390), + TEST_SEMANTIC_MODEL(case0391), + TEST_SEMANTIC_MODEL(case0392), + TEST_SEMANTIC_MODEL(case0393), + TEST_SEMANTIC_MODEL(case0394), + TEST_SEMANTIC_MODEL(case0395), + TEST_SEMANTIC_MODEL(case0396), + TEST_SEMANTIC_MODEL(case0397), + TEST_SEMANTIC_MODEL(case0398), + TEST_SEMANTIC_MODEL(case0399), - TEST_SEMANTIC_MODEL(case0400), - TEST_SEMANTIC_MODEL(case0401), - TEST_SEMANTIC_MODEL(case0402), - TEST_SEMANTIC_MODEL(case0403), - TEST_SEMANTIC_MODEL(case0404), - TEST_SEMANTIC_MODEL(case0405), - TEST_SEMANTIC_MODEL(case0406), - TEST_SEMANTIC_MODEL(case0407), - TEST_SEMANTIC_MODEL(case0408), - TEST_SEMANTIC_MODEL(case0409), - TEST_SEMANTIC_MODEL(case0410), - TEST_SEMANTIC_MODEL(case0411), - TEST_SEMANTIC_MODEL(case0412), - TEST_SEMANTIC_MODEL(case0413), - TEST_SEMANTIC_MODEL(case0414), - TEST_SEMANTIC_MODEL(case0415), - TEST_SEMANTIC_MODEL(case0416), - TEST_SEMANTIC_MODEL(case0417), - TEST_SEMANTIC_MODEL(case0418), - TEST_SEMANTIC_MODEL(case0419), - TEST_SEMANTIC_MODEL(case0420), - TEST_SEMANTIC_MODEL(case0421), - TEST_SEMANTIC_MODEL(case0422), - TEST_SEMANTIC_MODEL(case0423), - TEST_SEMANTIC_MODEL(case0424), - TEST_SEMANTIC_MODEL(case0425), - TEST_SEMANTIC_MODEL(case0426), - TEST_SEMANTIC_MODEL(case0427), - TEST_SEMANTIC_MODEL(case0428), - TEST_SEMANTIC_MODEL(case0429), - TEST_SEMANTIC_MODEL(case0430), - TEST_SEMANTIC_MODEL(case0431), - TEST_SEMANTIC_MODEL(case0432), - TEST_SEMANTIC_MODEL(case0433), - TEST_SEMANTIC_MODEL(case0434), - TEST_SEMANTIC_MODEL(case0435), - TEST_SEMANTIC_MODEL(case0436), - TEST_SEMANTIC_MODEL(case0437), - TEST_SEMANTIC_MODEL(case0438), - TEST_SEMANTIC_MODEL(case0439), - TEST_SEMANTIC_MODEL(case0440), - TEST_SEMANTIC_MODEL(case0441), - TEST_SEMANTIC_MODEL(case0442), - TEST_SEMANTIC_MODEL(case0443), - TEST_SEMANTIC_MODEL(case0444), - TEST_SEMANTIC_MODEL(case0445), - TEST_SEMANTIC_MODEL(case0446), - TEST_SEMANTIC_MODEL(case0447), - TEST_SEMANTIC_MODEL(case0448), - TEST_SEMANTIC_MODEL(case0449), - TEST_SEMANTIC_MODEL(case0450), - TEST_SEMANTIC_MODEL(case0451), - TEST_SEMANTIC_MODEL(case0452), - TEST_SEMANTIC_MODEL(case0453), - TEST_SEMANTIC_MODEL(case0454), - TEST_SEMANTIC_MODEL(case0455), - TEST_SEMANTIC_MODEL(case0456), - TEST_SEMANTIC_MODEL(case0457), - TEST_SEMANTIC_MODEL(case0458), - TEST_SEMANTIC_MODEL(case0459), - TEST_SEMANTIC_MODEL(case0460), - TEST_SEMANTIC_MODEL(case0461), - TEST_SEMANTIC_MODEL(case0462), - TEST_SEMANTIC_MODEL(case0463), - TEST_SEMANTIC_MODEL(case0464), - TEST_SEMANTIC_MODEL(case0465), - TEST_SEMANTIC_MODEL(case0466), - TEST_SEMANTIC_MODEL(case0467), - TEST_SEMANTIC_MODEL(case0468), - TEST_SEMANTIC_MODEL(case0469), - TEST_SEMANTIC_MODEL(case0470), - TEST_SEMANTIC_MODEL(case0471), - TEST_SEMANTIC_MODEL(case0472), - TEST_SEMANTIC_MODEL(case0473), - TEST_SEMANTIC_MODEL(case0474), - TEST_SEMANTIC_MODEL(case0475), - TEST_SEMANTIC_MODEL(case0476), - TEST_SEMANTIC_MODEL(case0477), - TEST_SEMANTIC_MODEL(case0478), - TEST_SEMANTIC_MODEL(case0479), - TEST_SEMANTIC_MODEL(case0480), - TEST_SEMANTIC_MODEL(case0481), - TEST_SEMANTIC_MODEL(case0482), - TEST_SEMANTIC_MODEL(case0483), - TEST_SEMANTIC_MODEL(case0484), - TEST_SEMANTIC_MODEL(case0485), - TEST_SEMANTIC_MODEL(case0486), - TEST_SEMANTIC_MODEL(case0487), - TEST_SEMANTIC_MODEL(case0488), - TEST_SEMANTIC_MODEL(case0489), - TEST_SEMANTIC_MODEL(case0490), - TEST_SEMANTIC_MODEL(case0491), - TEST_SEMANTIC_MODEL(case0492), - TEST_SEMANTIC_MODEL(case0493), - TEST_SEMANTIC_MODEL(case0494), - TEST_SEMANTIC_MODEL(case0495), - TEST_SEMANTIC_MODEL(case0496), - TEST_SEMANTIC_MODEL(case0497), - TEST_SEMANTIC_MODEL(case0498), - TEST_SEMANTIC_MODEL(case0499), + TEST_SEMANTIC_MODEL(case0400), + TEST_SEMANTIC_MODEL(case0401), + TEST_SEMANTIC_MODEL(case0402), + TEST_SEMANTIC_MODEL(case0403), + TEST_SEMANTIC_MODEL(case0404), + TEST_SEMANTIC_MODEL(case0405), + TEST_SEMANTIC_MODEL(case0406), + TEST_SEMANTIC_MODEL(case0407), + TEST_SEMANTIC_MODEL(case0408), + TEST_SEMANTIC_MODEL(case0409), + TEST_SEMANTIC_MODEL(case0410), + TEST_SEMANTIC_MODEL(case0411), + TEST_SEMANTIC_MODEL(case0412), + TEST_SEMANTIC_MODEL(case0413), + TEST_SEMANTIC_MODEL(case0414), + TEST_SEMANTIC_MODEL(case0415), + TEST_SEMANTIC_MODEL(case0416), + TEST_SEMANTIC_MODEL(case0417), + TEST_SEMANTIC_MODEL(case0418), + TEST_SEMANTIC_MODEL(case0419), + TEST_SEMANTIC_MODEL(case0420), + TEST_SEMANTIC_MODEL(case0421), + TEST_SEMANTIC_MODEL(case0422), + TEST_SEMANTIC_MODEL(case0423), + TEST_SEMANTIC_MODEL(case0424), + TEST_SEMANTIC_MODEL(case0425), + TEST_SEMANTIC_MODEL(case0426), + TEST_SEMANTIC_MODEL(case0427), + TEST_SEMANTIC_MODEL(case0428), + TEST_SEMANTIC_MODEL(case0429), + TEST_SEMANTIC_MODEL(case0430), + TEST_SEMANTIC_MODEL(case0431), + TEST_SEMANTIC_MODEL(case0432), + TEST_SEMANTIC_MODEL(case0433), + TEST_SEMANTIC_MODEL(case0434), + TEST_SEMANTIC_MODEL(case0435), + TEST_SEMANTIC_MODEL(case0436), + TEST_SEMANTIC_MODEL(case0437), + TEST_SEMANTIC_MODEL(case0438), + TEST_SEMANTIC_MODEL(case0439), + TEST_SEMANTIC_MODEL(case0440), + TEST_SEMANTIC_MODEL(case0441), + TEST_SEMANTIC_MODEL(case0442), + TEST_SEMANTIC_MODEL(case0443), + TEST_SEMANTIC_MODEL(case0444), + TEST_SEMANTIC_MODEL(case0445), + TEST_SEMANTIC_MODEL(case0446), + TEST_SEMANTIC_MODEL(case0447), + TEST_SEMANTIC_MODEL(case0448), + TEST_SEMANTIC_MODEL(case0449), + TEST_SEMANTIC_MODEL(case0450), + TEST_SEMANTIC_MODEL(case0451), + TEST_SEMANTIC_MODEL(case0452), + TEST_SEMANTIC_MODEL(case0453), + TEST_SEMANTIC_MODEL(case0454), + TEST_SEMANTIC_MODEL(case0455), + TEST_SEMANTIC_MODEL(case0456), + TEST_SEMANTIC_MODEL(case0457), + TEST_SEMANTIC_MODEL(case0458), + TEST_SEMANTIC_MODEL(case0459), + TEST_SEMANTIC_MODEL(case0460), + TEST_SEMANTIC_MODEL(case0461), + TEST_SEMANTIC_MODEL(case0462), + TEST_SEMANTIC_MODEL(case0463), + TEST_SEMANTIC_MODEL(case0464), + TEST_SEMANTIC_MODEL(case0465), + TEST_SEMANTIC_MODEL(case0466), + TEST_SEMANTIC_MODEL(case0467), + TEST_SEMANTIC_MODEL(case0468), + TEST_SEMANTIC_MODEL(case0469), + TEST_SEMANTIC_MODEL(case0470), + TEST_SEMANTIC_MODEL(case0471), + TEST_SEMANTIC_MODEL(case0472), + TEST_SEMANTIC_MODEL(case0473), + TEST_SEMANTIC_MODEL(case0474), + TEST_SEMANTIC_MODEL(case0475), + TEST_SEMANTIC_MODEL(case0476), + TEST_SEMANTIC_MODEL(case0477), + TEST_SEMANTIC_MODEL(case0478), + TEST_SEMANTIC_MODEL(case0479), + TEST_SEMANTIC_MODEL(case0480), + TEST_SEMANTIC_MODEL(case0481), + TEST_SEMANTIC_MODEL(case0482), + TEST_SEMANTIC_MODEL(case0483), + TEST_SEMANTIC_MODEL(case0484), + TEST_SEMANTIC_MODEL(case0485), + TEST_SEMANTIC_MODEL(case0486), + TEST_SEMANTIC_MODEL(case0487), + TEST_SEMANTIC_MODEL(case0488), + TEST_SEMANTIC_MODEL(case0489), + TEST_SEMANTIC_MODEL(case0490), + TEST_SEMANTIC_MODEL(case0491), + TEST_SEMANTIC_MODEL(case0492), + TEST_SEMANTIC_MODEL(case0493), + TEST_SEMANTIC_MODEL(case0494), + TEST_SEMANTIC_MODEL(case0495), + TEST_SEMANTIC_MODEL(case0496), + TEST_SEMANTIC_MODEL(case0497), + TEST_SEMANTIC_MODEL(case0498), + TEST_SEMANTIC_MODEL(case0499), - TEST_SEMANTIC_MODEL(case0500), - TEST_SEMANTIC_MODEL(case0501), - TEST_SEMANTIC_MODEL(case0502), - TEST_SEMANTIC_MODEL(case0503), - TEST_SEMANTIC_MODEL(case0504), - TEST_SEMANTIC_MODEL(case0505), - TEST_SEMANTIC_MODEL(case0506), - TEST_SEMANTIC_MODEL(case0507), - TEST_SEMANTIC_MODEL(case0508), - TEST_SEMANTIC_MODEL(case0509), - }; + TEST_SEMANTIC_MODEL(case0500), + TEST_SEMANTIC_MODEL(case0501), + TEST_SEMANTIC_MODEL(case0502), + TEST_SEMANTIC_MODEL(case0503), + TEST_SEMANTIC_MODEL(case0504), + TEST_SEMANTIC_MODEL(case0505), + TEST_SEMANTIC_MODEL(case0506), + TEST_SEMANTIC_MODEL(case0507), + TEST_SEMANTIC_MODEL(case0508), + TEST_SEMANTIC_MODEL(case0509), + }; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/tests/TestExpectation.cpp b/C/tests/TestExpectation.cpp index b04ab2ad6..afdcdb717 100644 --- a/C/tests/TestExpectation.cpp +++ b/C/tests/TestExpectation.cpp @@ -21,184 +21,149 @@ #include "TestExpectation.h" using namespace psy; -using namespace C; +using namespace C; -TypeSpecSummary::TypeSpecSummary(DeclSummary& declSummary) - : declSummary_(declSummary) - , nestedRetTySpec_(nullptr) - , namedTyK_(NamedTypeKind::UNSPECIFIED) - , specTyBuiltinK_(BuiltinTypeKind::UNSPECIFIED) - , specTyCVR_(CVR::None) -{} +TypeSpecSummary::TypeSpecSummary(DeclSummary &declSummary) + : declSummary_(declSummary), nestedRetTySpec_(nullptr), + namedTyK_(NamedTypeKind::UNSPECIFIED), + specTyBuiltinK_(BuiltinTypeKind::UNSPECIFIED), specTyCVR_(CVR::None) {} -TypeSpecSummary::~TypeSpecSummary() -{} +TypeSpecSummary::~TypeSpecSummary() {} -DeclSummary& TypeSpecSummary::basis(std::string name, - NamedTypeKind namedTyK, - BuiltinTypeKind builtinTypeKind, - CVR cvr) -{ - specTyName_ = std::move(name); - namedTyK_ = namedTyK; - specTyBuiltinK_ = builtinTypeKind; - specTyCVR_ = cvr; - return declSummary_; +DeclSummary &TypeSpecSummary::basis(std::string name, NamedTypeKind namedTyK, + BuiltinTypeKind builtinTypeKind, CVR cvr) { + specTyName_ = std::move(name); + namedTyK_ = namedTyK; + specTyBuiltinK_ = builtinTypeKind; + specTyCVR_ = cvr; + return declSummary_; } -DeclSummary& TypeSpecSummary::deriv(TypeKind tyKind, CVR cvr, Decay decay) -{ - derivTyKs_.push_back(tyKind); - derivTyCVRs_.push_back(cvr); - derivPtrTyDecay_.push_back(decay); - return declSummary_; +DeclSummary &TypeSpecSummary::deriv(TypeKind tyKind, CVR cvr, Decay decay) { + derivTyKs_.push_back(tyKind); + derivTyCVRs_.push_back(cvr); + derivPtrTyDecay_.push_back(decay); + return declSummary_; } -TypeSpecSummary& TypeSpecSummary::Parameter() -{ - parmsTySpecs_.emplace_back(declSummary_); - return parmsTySpecs_.back(); +TypeSpecSummary &TypeSpecSummary::Parameter() { + parmsTySpecs_.emplace_back(declSummary_); + return parmsTySpecs_.back(); } -TypeSpecSummary& TypeSpecSummary::_AtParam_() -{ - return parmsTySpecs_.back(); -} +TypeSpecSummary &TypeSpecSummary::_AtParam_() { return parmsTySpecs_.back(); } -DeclSummary& TypeSpecSummary::NestAsReturn() -{ - nestedRetTySpec_.reset(new TypeSpecSummary(*this)); +DeclSummary &TypeSpecSummary::NestAsReturn() { + nestedRetTySpec_.reset(new TypeSpecSummary(*this)); - specTyName_.clear(); - namedTyK_ = NamedTypeKind::UNSPECIFIED; - specTyBuiltinK_ = BuiltinTypeKind::UNSPECIFIED; - specTyCVR_ = CVR::None; - derivTyKs_.clear(); - derivTyCVRs_.clear(); - derivPtrTyDecay_.clear(); - parmsTySpecs_.clear(); + specTyName_.clear(); + namedTyK_ = NamedTypeKind::UNSPECIFIED; + specTyBuiltinK_ = BuiltinTypeKind::UNSPECIFIED; + specTyCVR_ = CVR::None; + derivTyKs_.clear(); + derivTyCVRs_.clear(); + derivPtrTyDecay_.clear(); + parmsTySpecs_.clear(); - return declSummary_; + return declSummary_; } DeclSummary::DeclSummary() - : valK_(ValueKind::UNSPECIFIED) - , tyK_(TypeKind::UNSPECIFIED) - , scopeK_(ScopeKind::UNSPECIFIED) - , TySpec(*this) -{} + : valK_(ValueKind::UNSPECIFIED), tyK_(TypeKind::UNSPECIFIED), + scopeK_(ScopeKind::UNSPECIFIED), TySpec(*this) {} -DeclSummary& DeclSummary::Value(std::string name, ValueKind valK, ScopeKind scopeK) -{ - name_ = std::move(name); - symK_ = SymbolKind::Value; - valK_ = valK; - scopeK_ = scopeK; - return *this; +DeclSummary &DeclSummary::Value(std::string name, ValueKind valK, + ScopeKind scopeK) { + name_ = std::move(name); + symK_ = SymbolKind::Value; + valK_ = valK; + scopeK_ = scopeK; + return *this; } -DeclSummary& DeclSummary::Type(std::string name, NamedTypeKind namedTyDeclK) -{ - name_ = std::move(name); - symK_ = SymbolKind::Type; - namedTyDeclK_ = namedTyDeclK; - return *this; +DeclSummary &DeclSummary::Type(std::string name, NamedTypeKind namedTyDeclK) { + name_ = std::move(name); + symK_ = SymbolKind::Type; + namedTyDeclK_ = namedTyDeclK; + return *this; } -DeclSummary& DeclSummary::Function(std::string funcName, ScopeKind scopeK) -{ - name_ = std::move(funcName); - symK_ = SymbolKind::Function; - scopeK_ = scopeK; - return *this; +DeclSummary &DeclSummary::Function(std::string funcName, ScopeKind scopeK) { + name_ = std::move(funcName); + symK_ = SymbolKind::Function; + scopeK_ = scopeK; + return *this; } -DeclSummary& DeclSummary::withScopeKind(ScopeKind scopeK) -{ - scopeK_ = scopeK; - return *this; +DeclSummary &DeclSummary::withScopeKind(ScopeKind scopeK) { + scopeK_ = scopeK; + return *this; } -DeclSummary& DeclSummary::withNameSpaceKind(NameSpaceKind nsK) -{ - nsK_ = nsK; - return *this; +DeclSummary &DeclSummary::withNameSpaceKind(NameSpaceKind nsK) { + nsK_ = nsK; + return *this; } -DeclSummary& DeclSummary::withNameKind(SymbolNameKind nameK) -{ - nameK_ = nameK; - return *this; +DeclSummary &DeclSummary::withNameKind(SymbolNameKind nameK) { + nameK_ = nameK; + return *this; } -DeclSummary& DeclSummary::withTagChoice(TagSymbolName::TagChoice tagChoice) -{ - tagChoice_ = tagChoice; - return *this; +DeclSummary &DeclSummary::withTagChoice(TagSymbolName::TagChoice tagChoice) { + tagChoice_ = tagChoice; + return *this; } Expectation::Expectation() - : numE_(0) - , numW_(0) - , continueTestDespiteOfErrors_(false) - , containsAmbiguity_(false) - , unfinishedParse_(false) -{} + : numE_(0), numW_(0), continueTestDespiteOfErrors_(false), + containsAmbiguity_(false), unfinishedParse_(false) {} -Expectation &Expectation::ContinueTestDespiteOfErrors() -{ - continueTestDespiteOfErrors_ = true; - return *this; +Expectation &Expectation::ContinueTestDespiteOfErrors() { + continueTestDespiteOfErrors_ = true; + return *this; } -Expectation &Expectation::unfinishedParse() -{ - unfinishedParse_ = true; - return *this; +Expectation &Expectation::unfinishedParse() { + unfinishedParse_ = true; + return *this; } -Expectation& Expectation::setErrorCnt(int numE) -{ - numE_ = numE; - return *this; +Expectation &Expectation::setErrorCnt(int numE) { + numE_ = numE; + return *this; } -Expectation& Expectation::setWarnCnt(int numW) -{ - numW_ = numW; - return *this; +Expectation &Expectation::setWarnCnt(int numW) { + numW_ = numW; + return *this; } -Expectation& Expectation::ambiguity(std::string s) -{ - containsAmbiguity_ = true; - ambiguityText_ = std::move(s); - return *this; +Expectation &Expectation::ambiguity(std::string s) { + containsAmbiguity_ = true; + ambiguityText_ = std::move(s); + return *this; } -Expectation& Expectation::binding(DeclSummary b) -{ - bindings_.push_back(b); - return *this; +Expectation &Expectation::binding(DeclSummary b) { + bindings_.push_back(b); + return *this; } -Expectation& Expectation::AST(std::vector&& v) -{ - syntaxKinds_ = std::move(v); - return *this; +Expectation &Expectation::AST(std::vector &&v) { + syntaxKinds_ = std::move(v); + return *this; } -Expectation& Expectation::diagnostic(ErrorOrWarn v, std::string descriptorId) -{ - if (v == ErrorOrWarn::Error) { - ++numE_; - if (!descriptorId.empty()) - descriptorsE_.push_back(descriptorId); - } - else { - ++numW_; - if (!descriptorId.empty()) - descriptorsW_.push_back(descriptorId); - } - return *this; +Expectation &Expectation::diagnostic(ErrorOrWarn v, std::string descriptorId) { + if (v == ErrorOrWarn::Error) { + ++numE_; + if (!descriptorId.empty()) + descriptorsE_.push_back(descriptorId); + } else { + ++numW_; + if (!descriptorId.empty()) + descriptorsW_.push_back(descriptorId); + } + return *this; } diff --git a/C/tests/TestExpectation.h b/C/tests/TestExpectation.h index 03dca2cfa..b47e92b5d 100644 --- a/C/tests/TestExpectation.h +++ b/C/tests/TestExpectation.h @@ -21,16 +21,16 @@ #ifndef PSYCHE_C_TEST_EXPECTATION_H__ #define PSYCHE_C_TEST_EXPECTATION_H__ -#include "compilation/Compilation.h" #include "binder/NameSpaceKind.h" #include "binder/Scope.h" +#include "compilation/Compilation.h" +#include "symbols/SymbolKind.h" #include "symbols/SymbolNameKind.h" #include "symbols/SymbolName_Tag.h" -#include "symbols/SymbolKind.h" -#include "symbols/ValueKind.h" #include "symbols/TypeKind.h" #include "symbols/TypeKind_Builtin.h" #include "symbols/TypeKind_Named.h" +#include "symbols/ValueKind.h" #include "tests/TestSuite.h" #include @@ -43,120 +43,101 @@ namespace psy { namespace C { -enum class CVR -{ - Const, - Volatile, - Restrict, - ConstAndVolatile, - None -}; +enum class CVR { Const, Volatile, Restrict, ConstAndVolatile, None }; -enum class Decay -{ - None, - FromArrayToPointer, - FromFunctionToFunctionPointer -}; +enum class Decay { None, FromArrayToPointer, FromFunctionToFunctionPointer }; struct DeclSummary; -struct TypeSpecSummary -{ - TypeSpecSummary(DeclSummary& declSummary); - TypeSpecSummary(TypeSpecSummary&& tySpec) = default; - TypeSpecSummary(const TypeSpecSummary& tySpec) = default; - ~TypeSpecSummary(); - - DeclSummary& declSummary_; - - DeclSummary& basis(std::string name, - NamedTypeKind namedTyK, - BuiltinTypeKind builtinTypeKind = BuiltinTypeKind::UNSPECIFIED, - CVR cvr = CVR::None); - DeclSummary& deriv(TypeKind tyKind, CVR cvr = CVR::None, Decay decay = Decay::None); - - TypeSpecSummary& Parameter(); - TypeSpecSummary& _AtParam_(); - - DeclSummary& NestAsReturn(); - - std::shared_ptr nestedRetTySpec_; - std::string specTyName_; - NamedTypeKind namedTyK_; - BuiltinTypeKind specTyBuiltinK_; - CVR specTyCVR_; - std::vector derivTyKs_; - std::vector derivTyCVRs_; - std::vector derivPtrTyDecay_; - std::vector parmsTySpecs_; +struct TypeSpecSummary { + TypeSpecSummary(DeclSummary &declSummary); + TypeSpecSummary(TypeSpecSummary &&tySpec) = default; + TypeSpecSummary(const TypeSpecSummary &tySpec) = default; + ~TypeSpecSummary(); + + DeclSummary &declSummary_; + + DeclSummary & + basis(std::string name, NamedTypeKind namedTyK, + BuiltinTypeKind builtinTypeKind = BuiltinTypeKind::UNSPECIFIED, + CVR cvr = CVR::None); + DeclSummary &deriv(TypeKind tyKind, CVR cvr = CVR::None, + Decay decay = Decay::None); + + TypeSpecSummary &Parameter(); + TypeSpecSummary &_AtParam_(); + + DeclSummary &NestAsReturn(); + + std::shared_ptr nestedRetTySpec_; + std::string specTyName_; + NamedTypeKind namedTyK_; + BuiltinTypeKind specTyBuiltinK_; + CVR specTyCVR_; + std::vector derivTyKs_; + std::vector derivTyCVRs_; + std::vector derivPtrTyDecay_; + std::vector parmsTySpecs_; }; -struct DeclSummary -{ - DeclSummary(); - - DeclSummary& Value(std::string name, - ValueKind valK, - ScopeKind scopeK = ScopeKind::UNSPECIFIED); - DeclSummary& Function(std::string funcName, - ScopeKind scopeK = ScopeKind::UNSPECIFIED); - DeclSummary& Type(std::string name, NamedTypeKind namedTyDeclTyK); - - DeclSummary& withScopeKind(ScopeKind scopeK); - DeclSummary& withNameSpaceKind(NameSpaceKind nsK); - DeclSummary& withNameKind(SymbolNameKind nameK); - DeclSummary& withTagChoice(TagSymbolName::TagChoice tagChoice); - - std::string name_; - SymbolKind symK_; - ValueKind valK_; - TypeKind tyK_; - NamedTypeKind namedTyDeclK_; - ScopeKind scopeK_; - NameSpaceKind nsK_; - SymbolNameKind nameK_; - TagSymbolName::TagChoice tagChoice_; - - TypeSpecSummary TySpec; +struct DeclSummary { + DeclSummary(); + + DeclSummary &Value(std::string name, ValueKind valK, + ScopeKind scopeK = ScopeKind::UNSPECIFIED); + DeclSummary &Function(std::string funcName, + ScopeKind scopeK = ScopeKind::UNSPECIFIED); + DeclSummary &Type(std::string name, NamedTypeKind namedTyDeclTyK); + + DeclSummary &withScopeKind(ScopeKind scopeK); + DeclSummary &withNameSpaceKind(NameSpaceKind nsK); + DeclSummary &withNameKind(SymbolNameKind nameK); + DeclSummary &withTagChoice(TagSymbolName::TagChoice tagChoice); + + std::string name_; + SymbolKind symK_; + ValueKind valK_; + TypeKind tyK_; + NamedTypeKind namedTyDeclK_; + ScopeKind scopeK_; + NameSpaceKind nsK_; + SymbolNameKind nameK_; + TagSymbolName::TagChoice tagChoice_; + + TypeSpecSummary TySpec; }; -struct Expectation -{ - Expectation(); +struct Expectation { + Expectation(); - enum class ErrorOrWarn - { - Error, - Warn - }; + enum class ErrorOrWarn { Error, Warn }; - int numE_; - int numW_; - std::vector descriptorsE_; - std::vector descriptorsW_; - Expectation& setErrorCnt(int numE); - Expectation& setWarnCnt(int numW); - Expectation& diagnostic(ErrorOrWarn v, std::string descriptorId = ""); + int numE_; + int numW_; + std::vector descriptorsE_; + std::vector descriptorsW_; + Expectation &setErrorCnt(int numE); + Expectation &setWarnCnt(int numW); + Expectation &diagnostic(ErrorOrWarn v, std::string descriptorId = ""); - bool continueTestDespiteOfErrors_; - Expectation& ContinueTestDespiteOfErrors(); + bool continueTestDespiteOfErrors_; + Expectation &ContinueTestDespiteOfErrors(); - bool containsAmbiguity_; - std::string ambiguityText_; - Expectation& ambiguity(std::string s = ""); + bool containsAmbiguity_; + std::string ambiguityText_; + Expectation &ambiguity(std::string s = ""); - bool unfinishedParse_; - Expectation& unfinishedParse(); + bool unfinishedParse_; + Expectation &unfinishedParse(); - std::vector syntaxKinds_; - Expectation& AST(std::vector&& v); + std::vector syntaxKinds_; + Expectation &AST(std::vector &&v); - std::vector bindings_; - Expectation& binding(DeclSummary b); + std::vector bindings_; + Expectation &binding(DeclSummary b); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/tests/TestSuite_API.cpp b/C/tests/TestSuite_API.cpp index 977132af2..f870d83a3 100644 --- a/C/tests/TestSuite_API.cpp +++ b/C/tests/TestSuite_API.cpp @@ -25,31 +25,26 @@ using namespace psy; using namespace C; -APITestSuite::~APITestSuite() -{} +APITestSuite::~APITestSuite() {} -std::tuple APITestSuite::testAll() -{ - auto SM = std::make_unique(this); - SM->testSemanticModel(); +std::tuple APITestSuite::testAll() { + auto SM = std::make_unique(this); + SM->testSemanticModel(); - auto res = std::make_tuple(SM->totalPassed(), - SM->totalFailed()); + auto res = std::make_tuple(SM->totalPassed(), SM->totalFailed()); - testers_.emplace_back(SM.release()); + testers_.emplace_back(SM.release()); - return res; + return res; } -std::string APITestSuite::description() const -{ - return "C API test suite"; -} +std::string APITestSuite::description() const { return "C API test suite"; } -void APITestSuite::printSummary() const -{ - for (auto const& tester : testers_) { - std::cout << " " << tester->name() << " passed: " << tester->totalPassed() << std::endl - << " " << std::string(tester->name().length(), ' ') << " failed: " << tester->totalFailed() << std::endl; - } +void APITestSuite::printSummary() const { + for (auto const &tester : testers_) { + std::cout << " " << tester->name() + << " passed: " << tester->totalPassed() << std::endl + << " " << std::string(tester->name().length(), ' ') + << " failed: " << tester->totalFailed() << std::endl; + } } diff --git a/C/tests/TestSuite_API.h b/C/tests/TestSuite_API.h index 94ed6fec7..1d284a9cc 100644 --- a/C/tests/TestSuite_API.h +++ b/C/tests/TestSuite_API.h @@ -27,9 +27,9 @@ #include "tests/Tester.h" #include "C/SyntaxTree.h" -#include "C/syntax/SyntaxNodes.h" #include "C/compilation/Compilation.h" #include "C/compilation/SemanticModel.h" +#include "C/syntax/SyntaxNodes.h" #include #include @@ -38,22 +38,21 @@ namespace psy { namespace C { -class APITestSuite : public TestSuite -{ - friend class SemanticModelTester; +class APITestSuite : public TestSuite { + friend class SemanticModelTester; public: - virtual ~APITestSuite(); + virtual ~APITestSuite(); - virtual std::tuple testAll() override; - virtual std::string description() const override; - virtual void printSummary() const override; + virtual std::tuple testAll() override; + virtual std::string description() const override; + virtual void printSummary() const override; private: - std::vector> testers_; + std::vector> testers_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/tests/TestSuite_Internals.cpp b/C/tests/TestSuite_Internals.cpp index a079195d0..154b2f7e3 100644 --- a/C/tests/TestSuite_Internals.cpp +++ b/C/tests/TestSuite_Internals.cpp @@ -23,8 +23,8 @@ #include "compilation/Assembly.h" #include "compilation/Compilation.h" #include "compilation/SemanticModel.h" -#include "symbols/Symbol.h" #include "parser/Unparser.h" +#include "symbols/Symbol.h" #include "symbols/Symbol_ALL.h" #include "syntax/SyntaxLexeme_ALL.h" #include "syntax/SyntaxNamePrinter.h" @@ -37,678 +37,647 @@ #include #include #include -#include -#include #include +#include +#include -//#define DUMP_AST +// #define DUMP_AST #define DEBUG_DIAGNOSTICS -//#define DEBUG_BINDING_SEARCH +// #define DEBUG_BINDING_SEARCH using namespace psy; using namespace C; -InternalsTestSuite::InternalsTestSuite() -{} +InternalsTestSuite::InternalsTestSuite() {} -InternalsTestSuite::~InternalsTestSuite() -{} +InternalsTestSuite::~InternalsTestSuite() {} -std::tuple InternalsTestSuite::testAll() -{ - auto P = std::make_unique(this); - P->testParser(); +std::tuple InternalsTestSuite::testAll() { + auto P = std::make_unique(this); + P->testParser(); - auto B = std::make_unique(this); - B->testReparser(); + auto B = std::make_unique(this); + B->testReparser(); - auto C = std::make_unique(this); - C->testBinder(); + auto C = std::make_unique(this); + C->testBinder(); - auto res = std::make_tuple(P->totalPassed() - + B->totalPassed() - + C->totalPassed(), - P->totalFailed() - + B->totalFailed() - + C->totalFailed()); + auto res = + std::make_tuple(P->totalPassed() + B->totalPassed() + C->totalPassed(), + P->totalFailed() + B->totalFailed() + C->totalFailed()); - testers_.emplace_back(P.release()); - testers_.emplace_back(B.release()); - testers_.emplace_back(C.release()); + testers_.emplace_back(P.release()); + testers_.emplace_back(B.release()); + testers_.emplace_back(C.release()); - return res; + return res; } -std::string InternalsTestSuite::description() const -{ - return "C internals test suite"; +std::string InternalsTestSuite::description() const { + return "C internals test suite"; } -void InternalsTestSuite::printSummary() const -{ - for (auto const& tester : testers_) { - std::cout << " " << tester->name() << " passed: " << tester->totalPassed() << std::endl - << " " << std::string(tester->name().length(), ' ') << " failed: " << tester->totalFailed() << std::endl; - } +void InternalsTestSuite::printSummary() const { + for (auto const &tester : testers_) { + std::cout << " " << tester->name() + << " passed: " << tester->totalPassed() << std::endl + << " " << std::string(tester->name().length(), ' ') + << " failed: " << tester->totalFailed() << std::endl; + } } -bool InternalsTestSuite::checkErrorAndWarn(Expectation X) -{ - int E_cnt = 0; - int W_cnt = 0; - std::unordered_set E_IDs; - std::unordered_set W_IDs; - for (const auto& diagnostic : tree_->diagnostics()) { - if (diagnostic.severity() == DiagnosticSeverity::Error) { - ++E_cnt; - E_IDs.insert(diagnostic.descriptor().id()); - } - else if (diagnostic.severity() == DiagnosticSeverity::Warning) { - ++W_cnt; - W_IDs.insert(diagnostic.descriptor().id()); - } +bool InternalsTestSuite::checkErrorAndWarn(Expectation X) { + int E_cnt = 0; + int W_cnt = 0; + std::unordered_set E_IDs; + std::unordered_set W_IDs; + for (const auto &diagnostic : tree_->diagnostics()) { + if (diagnostic.severity() == DiagnosticSeverity::Error) { + ++E_cnt; + E_IDs.insert(diagnostic.descriptor().id()); + } else if (diagnostic.severity() == DiagnosticSeverity::Warning) { + ++W_cnt; + W_IDs.insert(diagnostic.descriptor().id()); } + } #ifdef DEBUG_DIAGNOSTICS - if (!tree_->diagnostics().empty()) { - for (auto& diagnostic : tree_->diagnostics()) { - diagnostic.outputIndent_ = 2; - std::cout << std::endl << diagnostic << std::endl; - } - std::cout << "\t"; + if (!tree_->diagnostics().empty()) { + for (auto &diagnostic : tree_->diagnostics()) { + diagnostic.outputIndent_ = 2; + std::cout << std::endl << diagnostic << std::endl; } + std::cout << "\t"; + } #endif - if (X.numW_ != W_cnt || X.numE_ != E_cnt) { + if (X.numW_ != W_cnt || X.numE_ != E_cnt) { #ifdef DEBUG_DIAGNOSTICS - std::cout << "\n\t" << std::string(25, '%') << "\n\t"; + std::cout << "\n\t" << std::string(25, '%') << "\n\t"; #endif - std::cout << "mismatch in "; - if (X.numW_ != W_cnt) - std::cout << "WARNING"; - else - std::cout << "ERROR"; - std::cout << " count"; + std::cout << "mismatch in "; + if (X.numW_ != W_cnt) + std::cout << "WARNING"; + else + std::cout << "ERROR"; + std::cout << " count"; #ifdef DEBUG_DIAGNOSTICS - std::cout << "\n\t" << std::string(25, '%'); + std::cout << "\n\t" << std::string(25, '%'); #endif - } + } - PSY_EXPECT_EQ_INT(W_cnt, X.numW_); - PSY_EXPECT_EQ_INT(E_cnt, X.numE_); + PSY_EXPECT_EQ_INT(W_cnt, X.numW_); + PSY_EXPECT_EQ_INT(E_cnt, X.numE_); - for (const auto& id : X.descriptorsW_) { - if (!W_IDs.count(id)) { - std::string msg = "WARNING " + id + " not found, got:"; - for (const auto& idP : W_IDs) - msg += "\n\t\t- " + idP; - PSY__internals__FAIL(msg); - } + for (const auto &id : X.descriptorsW_) { + if (!W_IDs.count(id)) { + std::string msg = "WARNING " + id + " not found, got:"; + for (const auto &idP : W_IDs) + msg += "\n\t\t- " + idP; + PSY__internals__FAIL(msg); } - - for (const auto& id : X.descriptorsE_) { - if (!E_IDs.count(id)) { - std::string msg = "ERROR " + id + " not found, got:"; - for (const auto& idP : E_IDs) - msg += "\n\t\t- " + idP; - PSY__internals__FAIL(msg); - } + } + + for (const auto &id : X.descriptorsE_) { + if (!E_IDs.count(id)) { + std::string msg = "ERROR " + id + " not found, got:"; + for (const auto &idP : E_IDs) + msg += "\n\t\t- " + idP; + PSY__internals__FAIL(msg); } + } - if (X.numE_ && !X.continueTestDespiteOfErrors_) - return false; + if (X.numE_ && !X.continueTestDespiteOfErrors_) + return false; - return true; + return true; } -void InternalsTestSuite::parseDeclaration(std::string source, Expectation X) -{ - parse(source, X, SyntaxTree::SyntaxCategory::Declarations); +void InternalsTestSuite::parseDeclaration(std::string source, Expectation X) { + parse(source, X, SyntaxTree::SyntaxCategory::Declarations); } -void InternalsTestSuite::parseExpression(std::string source, Expectation X) -{ - parse(source, X, SyntaxTree::SyntaxCategory::Expressions); +void InternalsTestSuite::parseExpression(std::string source, Expectation X) { + parse(source, X, SyntaxTree::SyntaxCategory::Expressions); } -void InternalsTestSuite::parseStatement(std::string source, Expectation X) -{ - parse(source, X, SyntaxTree::SyntaxCategory::Statements); +void InternalsTestSuite::parseStatement(std::string source, Expectation X) { + parse(source, X, SyntaxTree::SyntaxCategory::Statements); } -void InternalsTestSuite::parse(std::string source, - Expectation X, - SyntaxTree::SyntaxCategory syntaxCat) -{ - auto text = source; +void InternalsTestSuite::parse(std::string source, Expectation X, + SyntaxTree::SyntaxCategory syntaxCat) { + auto text = source; #ifdef DEBUG_DIAGNOSTICS - if (X.numW_ > 0 || X.numE_ > 0) { - std::cout << std::endl; - if (X.numW_ > 0) - std::cout << "\t\t[expect (parser) WARNING]\n"; - if (X.numE_ > 0) - std::cout << "\t\t[expect (parser) ERROR]\n"; - } + if (X.numW_ > 0 || X.numE_ > 0) { + std::cout << std::endl; + if (X.numW_ > 0) + std::cout << "\t\t[expect (parser) WARNING]\n"; + if (X.numE_ > 0) + std::cout << "\t\t[expect (parser) ERROR]\n"; + } #endif - ParseOptions parseOpts; - if (X.containsAmbiguity_) - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::None); + ParseOptions parseOpts; + if (X.containsAmbiguity_) + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities::None); - tree_ = SyntaxTree::parseText(text, - TextPreprocessingState::Unknown, - TextCompleteness::Fragment, - parseOpts, - "", - syntaxCat); + tree_ = SyntaxTree::parseText(text, TextPreprocessingState::Unknown, + TextCompleteness::Fragment, parseOpts, "", + syntaxCat); - if (X.numE_ == 0 && X.numW_ == 0 && tree_->parseExitedEarly()) { - PSY_EXPECT_TRUE(X.unfinishedParse_); - return; - } + if (X.numE_ == 0 && X.numW_ == 0 && tree_->parseExitedEarly()) { + PSY_EXPECT_TRUE(X.unfinishedParse_); + return; + } - if (!checkErrorAndWarn(X)) - return; + if (!checkErrorAndWarn(X)) + return; - std::ostringstream ossTree; - SyntaxNamePrinter printer(tree_.get()); - printer.print(tree_->root(), - SyntaxNamePrinter::Style::Plain, - ossTree); + std::ostringstream ossTree; + SyntaxNamePrinter printer(tree_.get()); + printer.print(tree_->root(), SyntaxNamePrinter::Style::Plain, ossTree); #ifdef DUMP_AST - std::cout << "\n\n" - << "========================== AST ==================================\n" - << source << "\n" - << "-----------------------------------------------------------------" - << ossTree.str() - << "=================================================================\n"; + std::cout + << "\n\n" + << "========================== AST ==================================\n" + << source << "\n" + << "-----------------------------------------------------------------" + << ossTree.str() + << "=================================================================\n"; #endif - std::ostringstream ossText; - Unparser unparser(tree_.get()); - unparser.unparse(tree_->root(), ossText); - - std::string textP = ossText.str(); - textP.erase(std::remove_if(textP.begin(), textP.end(), ::isspace), textP.end()); - text.erase(std::remove_if(text.begin(), text.end(), ::isspace), text.end()); - - if (X.containsAmbiguity_) { - if (X.ambiguityText_.empty()) - PSY_EXPECT_EQ_STR(textP, text + text); - else { - X.ambiguityText_.erase( - std::remove_if(X.ambiguityText_.begin(), - X.ambiguityText_.end(), ::isspace), - X.ambiguityText_.end()); - PSY_EXPECT_EQ_STR(textP, X.ambiguityText_); - } + std::ostringstream ossText; + Unparser unparser(tree_.get()); + unparser.unparse(tree_->root(), ossText); + + std::string textP = ossText.str(); + textP.erase(std::remove_if(textP.begin(), textP.end(), ::isspace), + textP.end()); + text.erase(std::remove_if(text.begin(), text.end(), ::isspace), text.end()); + + if (X.containsAmbiguity_) { + if (X.ambiguityText_.empty()) + PSY_EXPECT_EQ_STR(textP, text + text); + else { + X.ambiguityText_.erase(std::remove_if(X.ambiguityText_.begin(), + X.ambiguityText_.end(), ::isspace), + X.ambiguityText_.end()); + PSY_EXPECT_EQ_STR(textP, X.ambiguityText_); } - else - PSY_EXPECT_EQ_STR(textP, text); + } else + PSY_EXPECT_EQ_STR(textP, text); - if (X.syntaxKinds_.empty()) - return; + if (X.syntaxKinds_.empty()) + return; - std::string names; - for (auto k : X.syntaxKinds_) - names += to_string(k); + std::string names; + for (auto k : X.syntaxKinds_) + names += to_string(k); - std::string namesP = ossTree.str(); - namesP.erase(std::remove_if(namesP.begin(), namesP.end(), ::isspace), namesP.end()); - PSY_EXPECT_EQ_STR(namesP, names); + std::string namesP = ossTree.str(); + namesP.erase(std::remove_if(namesP.begin(), namesP.end(), ::isspace), + namesP.end()); + PSY_EXPECT_EQ_STR(namesP, names); } -void InternalsTestSuite::reparse(std::string source, - Expectation X, - Reparser::DisambiguationStrategy strategy) -{ - auto text = source; - - PSY_EXPECT_TRUE(strategy != Reparser::DisambiguationStrategy::UNSPECIFIED); - - ParseOptions parseOpts; - TextCompleteness textCompleness; - switch (strategy) { - case Reparser::DisambiguationStrategy::SyntaxCorrelation: - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmically); - textCompleness = TextCompleteness::Fragment; - break; - - case Reparser::DisambiguationStrategy::TypeSynonymsVerification: - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmically); - textCompleness = TextCompleteness::Full; - break; - - case Reparser::DisambiguationStrategy::GuidelineImposition: - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::DisambiguateHeuristically); - textCompleness = TextCompleteness::Unknown; - break; - - default: - PSY__internals__FAIL("unknown strategy"); - } +void InternalsTestSuite::reparse(std::string source, Expectation X, + Reparser::DisambiguationStrategy strategy) { + auto text = source; + + PSY_EXPECT_TRUE(strategy != Reparser::DisambiguationStrategy::UNSPECIFIED); + + ParseOptions parseOpts; + TextCompleteness textCompleness; + switch (strategy) { + case Reparser::DisambiguationStrategy::SyntaxCorrelation: + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmically); + textCompleness = TextCompleteness::Fragment; + break; - tree_ = SyntaxTree::parseText(text, - TextPreprocessingState::Unknown, - textCompleness, - parseOpts, - ""); + case Reparser::DisambiguationStrategy::TypeSynonymsVerification: + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmically); + textCompleness = TextCompleteness::Full; + break; - if (!checkErrorAndWarn(X)) - return; + case Reparser::DisambiguationStrategy::GuidelineImposition: + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities::DisambiguateHeuristically); + textCompleness = TextCompleteness::Unknown; + break; - std::ostringstream ossTree; - SyntaxNamePrinter printer(tree_.get()); - printer.print(tree_->root(), - SyntaxNamePrinter::Style::Plain, - ossTree); + default: + PSY__internals__FAIL("unknown strategy"); + } + + tree_ = SyntaxTree::parseText(text, TextPreprocessingState::Unknown, + textCompleness, parseOpts, ""); + + if (!checkErrorAndWarn(X)) + return; + + std::ostringstream ossTree; + SyntaxNamePrinter printer(tree_.get()); + printer.print(tree_->root(), SyntaxNamePrinter::Style::Plain, ossTree); #ifdef DUMP_AST - std::cout << "\n\n" - << "========================== AST ==================================\n" - << source << "\n" - << "-----------------------------------------------------------------" - << ossTree.str() - << "=================================================================\n"; + std::cout + << "\n\n" + << "========================== AST ==================================\n" + << source << "\n" + << "-----------------------------------------------------------------" + << ossTree.str() + << "=================================================================\n"; #endif - std::ostringstream ossText; - Unparser unparser(tree_.get()); - unparser.unparse(tree_->root(), ossText); - - std::string textP = ossText.str(); - textP.erase(std::remove_if(textP.begin(), textP.end(), ::isspace), textP.end()); - text.erase(std::remove_if(text.begin(), text.end(), ::isspace), text.end()); - - if (X.containsAmbiguity_) { - if (X.ambiguityText_.empty()) - PSY_EXPECT_EQ_STR(textP, text + text); - else { - X.ambiguityText_.erase( - std::remove_if(X.ambiguityText_.begin(), - X.ambiguityText_.end(), ::isspace), - X.ambiguityText_.end()); - PSY_EXPECT_EQ_STR(textP, X.ambiguityText_); - } + std::ostringstream ossText; + Unparser unparser(tree_.get()); + unparser.unparse(tree_->root(), ossText); + + std::string textP = ossText.str(); + textP.erase(std::remove_if(textP.begin(), textP.end(), ::isspace), + textP.end()); + text.erase(std::remove_if(text.begin(), text.end(), ::isspace), text.end()); + + if (X.containsAmbiguity_) { + if (X.ambiguityText_.empty()) + PSY_EXPECT_EQ_STR(textP, text + text); + else { + X.ambiguityText_.erase(std::remove_if(X.ambiguityText_.begin(), + X.ambiguityText_.end(), ::isspace), + X.ambiguityText_.end()); + PSY_EXPECT_EQ_STR(textP, X.ambiguityText_); } - else - PSY_EXPECT_EQ_STR(textP, text); + } else + PSY_EXPECT_EQ_STR(textP, text); - if (X.syntaxKinds_.empty()) - return; + if (X.syntaxKinds_.empty()) + return; - std::string names; - for (auto k : X.syntaxKinds_) - names += to_string(k); + std::string names; + for (auto k : X.syntaxKinds_) + names += to_string(k); - std::string namesP = ossTree.str(); - namesP.erase(std::remove_if(namesP.begin(), namesP.end(), ::isspace), namesP.end()); - PSY_EXPECT_EQ_STR(namesP, names); + std::string namesP = ossTree.str(); + namesP.erase(std::remove_if(namesP.begin(), namesP.end(), ::isspace), + namesP.end()); + PSY_EXPECT_EQ_STR(namesP, names); } -void InternalsTestSuite::reparse_withSyntaxCorrelation(std::string text, Expectation X) -{ - reparse(text, X, Reparser::DisambiguationStrategy::SyntaxCorrelation); +void InternalsTestSuite::reparse_withSyntaxCorrelation(std::string text, + Expectation X) { + reparse(text, X, Reparser::DisambiguationStrategy::SyntaxCorrelation); } -void InternalsTestSuite::reparse_withTypeSynonymVerification(std::string text, Expectation X) -{ - reparse(text, X, Reparser::DisambiguationStrategy::TypeSynonymsVerification); +void InternalsTestSuite::reparse_withTypeSynonymVerification(std::string text, + Expectation X) { + reparse(text, X, Reparser::DisambiguationStrategy::TypeSynonymsVerification); } -void InternalsTestSuite::reparse_withGuidelineImposition(std::string text, Expectation X) -{ - reparse(text, X, Reparser::DisambiguationStrategy::GuidelineImposition); +void InternalsTestSuite::reparse_withGuidelineImposition(std::string text, + Expectation X) { + reparse(text, X, Reparser::DisambiguationStrategy::GuidelineImposition); } namespace { -bool REJECT_CANDIDATE(const Symbol* sym, std::string msg) -{ +bool REJECT_CANDIDATE(const Symbol *sym, std::string msg) { #ifdef DEBUG_BINDING_SEARCH - std::cout << "\n\t\tREJECT " << to_string(*sym) << " DUE TO " << msg; + std::cout << "\n\t\tREJECT " << to_string(*sym) << " DUE TO " << msg; #endif - return false; + return false; } -void DETAIL_MISMATCH(std::string msg) -{ +void DETAIL_MISMATCH(std::string msg) { #ifdef DEBUG_BINDING_SEARCH - std::cout << "\n\t\t\tmismatch detail: " << msg; + std::cout << "\n\t\t\tmismatch detail: " << msg; #endif } -bool CVRMatches(const TypeSymbol* tySym, CVR cvr) -{ - switch (cvr) { - case CVR::Const: - if (!tySym->isConstQualified()) { - DETAIL_MISMATCH("missing const"); - return false; - } - break; - - case CVR::Volatile: - if (!tySym->isVolatileQualified()) { - DETAIL_MISMATCH("missing volatile"); - return false; - } - break; - - case CVR::ConstAndVolatile: - if (!(tySym->isConstQualified()) - || !(tySym->isVolatileQualified())) { - DETAIL_MISMATCH("missing const volatile"); - return false; - } - break; - - case CVR::Restrict: - if (!tySym->isRestrictQualified()) { - DETAIL_MISMATCH("missing restrict"); - return false; - } - break; - - case CVR::None: - if (tySym->isConstQualified()) { - DETAIL_MISMATCH("spurious const"); - return false; - } - if (tySym->isVolatileQualified()) { - DETAIL_MISMATCH("spurious volatile"); - return false; - } - if (tySym->isRestrictQualified()) { - DETAIL_MISMATCH("spurious restrict"); - return false; - } - break; +bool CVRMatches(const TypeSymbol *tySym, CVR cvr) { + switch (cvr) { + case CVR::Const: + if (!tySym->isConstQualified()) { + DETAIL_MISMATCH("missing const"); + return false; } + break; - return true; -} + case CVR::Volatile: + if (!tySym->isVolatileQualified()) { + DETAIL_MISMATCH("missing volatile"); + return false; + } + break; -bool namedTypeMatches(const NamedTypeSymbol* namedTySym, const TypeSpecSummary& tySpec) -{ - if (namedTySym->name() == nullptr) { - DETAIL_MISMATCH("null type name"); - return false; + case CVR::ConstAndVolatile: + if (!(tySym->isConstQualified()) || !(tySym->isVolatileQualified())) { + DETAIL_MISMATCH("missing const volatile"); + return false; } + break; - if (namedTySym->name()->text() != tySpec.specTyName_) { - DETAIL_MISMATCH("type name"); - return false; + case CVR::Restrict: + if (!tySym->isRestrictQualified()) { + DETAIL_MISMATCH("missing restrict"); + return false; } + break; - if (namedTySym->namedTypeKind() != tySpec.namedTyK_) { - DETAIL_MISMATCH("type kind"); - return false; + case CVR::None: + if (tySym->isConstQualified()) { + DETAIL_MISMATCH("spurious const"); + return false; + } + if (tySym->isVolatileQualified()) { + DETAIL_MISMATCH("spurious volatile"); + return false; } + if (tySym->isRestrictQualified()) { + DETAIL_MISMATCH("spurious restrict"); + return false; + } + break; + } - if (tySpec.specTyBuiltinK_ != BuiltinTypeKind::UNSPECIFIED) { - if (namedTySym->namedTypeKind() != NamedTypeKind::Builtin) { - DETAIL_MISMATCH("not a builtin"); - return false; - } + return true; +} - if (namedTySym->builtinTypeKind() != tySpec.specTyBuiltinK_) { - DETAIL_MISMATCH("builtin kind"); - return false; - } +bool namedTypeMatches(const NamedTypeSymbol *namedTySym, + const TypeSpecSummary &tySpec) { + if (namedTySym->name() == nullptr) { + DETAIL_MISMATCH("null type name"); + return false; + } + + if (namedTySym->name()->text() != tySpec.specTyName_) { + DETAIL_MISMATCH("type name"); + return false; + } + + if (namedTySym->namedTypeKind() != tySpec.namedTyK_) { + DETAIL_MISMATCH("type kind"); + return false; + } + + if (tySpec.specTyBuiltinK_ != BuiltinTypeKind::UNSPECIFIED) { + if (namedTySym->namedTypeKind() != NamedTypeKind::Builtin) { + DETAIL_MISMATCH("not a builtin"); + return false; } - if (!CVRMatches(namedTySym, tySpec.specTyCVR_)) { - DETAIL_MISMATCH("CVR"); - return false; + if (namedTySym->builtinTypeKind() != tySpec.specTyBuiltinK_) { + DETAIL_MISMATCH("builtin kind"); + return false; } + } - return true; + if (!CVRMatches(namedTySym, tySpec.specTyCVR_)) { + DETAIL_MISMATCH("CVR"); + return false; + } + + return true; } -bool typeMatches(const TypeSymbol* tySym, const TypeSpecSummary& tySpec) -{ - for (auto i = tySpec.derivTyKs_.size(); i > 0; --i) { - auto derivTyK = tySpec.derivTyKs_[i - 1]; - if (derivTyK != tySym->typeKind()) { - DETAIL_MISMATCH("derived type kind"); - return false; +bool typeMatches(const TypeSymbol *tySym, const TypeSpecSummary &tySpec) { + for (auto i = tySpec.derivTyKs_.size(); i > 0; --i) { + auto derivTyK = tySpec.derivTyKs_[i - 1]; + if (derivTyK != tySym->typeKind()) { + DETAIL_MISMATCH("derived type kind"); + return false; + } + + auto derivTyCVR = tySpec.derivTyCVRs_[i - 1]; + if (!CVRMatches(tySym, derivTyCVR)) { + DETAIL_MISMATCH("derived type CVR"); + return false; + } + + auto derivPtrTyDecay = tySpec.derivPtrTyDecay_[i - 1]; + + switch (tySym->typeKind()) { + case TypeKind::Array: + if (derivPtrTyDecay != Decay::None) { + DETAIL_MISMATCH("can't happen for array"); + return false; + } + tySym = tySym->asArrayType()->elementType(); + break; + + case TypeKind::Pointer: + switch (derivPtrTyDecay) { + case Decay::None: + if (tySym->asPointerType()->arisesFromFunctionDecay() || + tySym->asPointerType()->arisesFromArrayDecay()) { + DETAIL_MISMATCH("pointer type is decayed from array/function"); + return false; } + break; - auto derivTyCVR = tySpec.derivTyCVRs_[i - 1]; - if (!CVRMatches(tySym, derivTyCVR)) { - DETAIL_MISMATCH("derived type CVR"); - return false; + case Decay::FromFunctionToFunctionPointer: + if (!tySym->asPointerType()->arisesFromFunctionDecay()) { + DETAIL_MISMATCH("pointer type isn't (function) decayed"); + return false; } + break; - auto derivPtrTyDecay = tySpec.derivPtrTyDecay_[i - 1]; - - switch (tySym->typeKind()) { - case TypeKind::Array: - if (derivPtrTyDecay != Decay::None) { - DETAIL_MISMATCH("can't happen for array"); - return false; - } - tySym = tySym->asArrayType()->elementType(); - break; - - case TypeKind::Pointer: - switch (derivPtrTyDecay) { - case Decay::None: - if (tySym->asPointerType()->arisesFromFunctionDecay() - || tySym->asPointerType()->arisesFromArrayDecay()) { - DETAIL_MISMATCH("pointer type is decayed from array/function"); - return false; - } - break; - - case Decay::FromFunctionToFunctionPointer: - if (!tySym->asPointerType()->arisesFromFunctionDecay()) { - DETAIL_MISMATCH("pointer type isn't (function) decayed"); - return false; - } - break; - - case Decay::FromArrayToPointer: - if (!tySym->asPointerType()->arisesFromArrayDecay()) { - DETAIL_MISMATCH("pointer type isn't (array) decayed"); - return false; - } - break; - } - tySym = tySym->asPointerType()->referencedType(); - break; - - case TypeKind::Function: { - if (derivPtrTyDecay != Decay::None) { - DETAIL_MISMATCH("can't happen for function"); - return false; - } - - auto funcTySym = tySym->asFunctionType(); - auto parms = funcTySym->parameterTypes(); - if (parms.size() != tySpec.parmsTySpecs_.size()) { - DETAIL_MISMATCH("number of parameters"); - return false; - } - - for (auto i = 0U; i < parms.size(); ++i) { - const TypeSymbol* parmTySym = parms[i]; - if (!typeMatches(parmTySym, tySpec.parmsTySpecs_[i])) { - DETAIL_MISMATCH("parameter type mismatch"); - return false; - } - } - - tySym = funcTySym->returnType(); - if (!tySpec.nestedRetTySpec_) - break; - - if (!typeMatches(tySym, *tySpec.nestedRetTySpec_.get())) { - DETAIL_MISMATCH("nested return type mismatch"); - return false; - } - return true; - } - - default: - PSY__internals__FAIL("unexpected"); - return false; + case Decay::FromArrayToPointer: + if (!tySym->asPointerType()->arisesFromArrayDecay()) { + DETAIL_MISMATCH("pointer type isn't (array) decayed"); + return false; } - } + break; + } + tySym = tySym->asPointerType()->referencedType(); + break; + + case TypeKind::Function: { + if (derivPtrTyDecay != Decay::None) { + DETAIL_MISMATCH("can't happen for function"); + return false; + } - const NamedTypeSymbol* namedTySym = tySym->asNamedType(); - if (!namedTySym) { - DETAIL_MISMATCH("not a named type"); + auto funcTySym = tySym->asFunctionType(); + auto parms = funcTySym->parameterTypes(); + if (parms.size() != tySpec.parmsTySpecs_.size()) { + DETAIL_MISMATCH("number of parameters"); return false; + } + + for (auto i = 0U; i < parms.size(); ++i) { + const TypeSymbol *parmTySym = parms[i]; + if (!typeMatches(parmTySym, tySpec.parmsTySpecs_[i])) { + DETAIL_MISMATCH("parameter type mismatch"); + return false; + } + } + + tySym = funcTySym->returnType(); + if (!tySpec.nestedRetTySpec_) + break; + + if (!typeMatches(tySym, *tySpec.nestedRetTySpec_.get())) { + DETAIL_MISMATCH("nested return type mismatch"); + return false; + } + return true; } - return namedTypeMatches(namedTySym, tySpec); + default: + PSY__internals__FAIL("unexpected"); + return false; + } + } + + const NamedTypeSymbol *namedTySym = tySym->asNamedType(); + if (!namedTySym) { + DETAIL_MISMATCH("not a named type"); + return false; + } + + return namedTypeMatches(namedTySym, tySpec); } -bool functionMatchesBinding(const FunctionSymbol* funcSym, const DeclSummary& decl) -{ - if (!funcSym->name()) - return REJECT_CANDIDATE(funcSym, "empty name"); +bool functionMatchesBinding(const FunctionSymbol *funcSym, + const DeclSummary &decl) { + if (!funcSym->name()) + return REJECT_CANDIDATE(funcSym, "empty name"); - if (funcSym->name()->text() != decl.name_) - return REJECT_CANDIDATE(funcSym, "name mismatch"); + if (funcSym->name()->text() != decl.name_) + return REJECT_CANDIDATE(funcSym, "name mismatch"); - if (funcSym->type() == nullptr) - return REJECT_CANDIDATE(funcSym, "null type"); + if (funcSym->type() == nullptr) + return REJECT_CANDIDATE(funcSym, "null type"); - if (funcSym->type()->typeKind() != TypeKind::Function) - return REJECT_CANDIDATE(funcSym, "not a function type"); + if (funcSym->type()->typeKind() != TypeKind::Function) + return REJECT_CANDIDATE(funcSym, "not a function type"); - if (!typeMatches(funcSym->type(), decl.TySpec)) - return REJECT_CANDIDATE(funcSym, "type mismatch"); + if (!typeMatches(funcSym->type(), decl.TySpec)) + return REJECT_CANDIDATE(funcSym, "type mismatch"); - return true; + return true; } -bool valueMatchesBinding(const ValueSymbol* valSym, const DeclSummary& decl) -{ - if (valSym->valueKind() != decl.valK_) - return REJECT_CANDIDATE(valSym, "value kind mismatch"); +bool valueMatchesBinding(const ValueSymbol *valSym, const DeclSummary &decl) { + if (valSym->valueKind() != decl.valK_) + return REJECT_CANDIDATE(valSym, "value kind mismatch"); - if (!valSym->name()) - return REJECT_CANDIDATE(valSym, "empty name"); + if (!valSym->name()) + return REJECT_CANDIDATE(valSym, "empty name"); - if (valSym->name()->text() != decl.name_) - return REJECT_CANDIDATE(valSym, "name mismatch"); + if (valSym->name()->text() != decl.name_) + return REJECT_CANDIDATE(valSym, "name mismatch"); - if (valSym->type() == nullptr) - return REJECT_CANDIDATE(valSym, "null type"); + if (valSym->type() == nullptr) + return REJECT_CANDIDATE(valSym, "null type"); - if (!typeMatches(valSym->type(), decl.TySpec)) - return REJECT_CANDIDATE(valSym, "type mismatch"); + if (!typeMatches(valSym->type(), decl.TySpec)) + return REJECT_CANDIDATE(valSym, "type mismatch"); - return true; + return true; } -bool typeMatchesBinding(const TypeSymbol* tySym, const DeclSummary& decl) -{ - const NamedTypeSymbol* namedTySym = tySym->asNamedType(); - if (!namedTySym) - return REJECT_CANDIDATE(tySym, "not a declarable type"); +bool typeMatchesBinding(const TypeSymbol *tySym, const DeclSummary &decl) { + const NamedTypeSymbol *namedTySym = tySym->asNamedType(); + if (!namedTySym) + return REJECT_CANDIDATE(tySym, "not a declarable type"); - if (namedTySym->namedTypeKind() != decl.namedTyDeclK_) - return REJECT_CANDIDATE(tySym, "named type kind mismatch"); + if (namedTySym->namedTypeKind() != decl.namedTyDeclK_) + return REJECT_CANDIDATE(tySym, "named type kind mismatch"); - if (!namedTySym->name()) - return REJECT_CANDIDATE(tySym, "empty type name"); + if (!namedTySym->name()) + return REJECT_CANDIDATE(tySym, "empty type name"); - if (namedTySym->name()->kind() != decl.nameK_) - return REJECT_CANDIDATE(tySym, "name kind mismatch"); + if (namedTySym->name()->kind() != decl.nameK_) + return REJECT_CANDIDATE(tySym, "name kind mismatch"); - if (namedTySym->name()->kind() == SymbolNameKind::Tag) { - if (namedTySym->name()->asTagSymbolName()->tagChoice() != decl.tagChoice_) - return REJECT_CANDIDATE(tySym, "tag choice mismatch"); - } + if (namedTySym->name()->kind() == SymbolNameKind::Tag) { + if (namedTySym->name()->asTagSymbolName()->tagChoice() != decl.tagChoice_) + return REJECT_CANDIDATE(tySym, "tag choice mismatch"); + } - if (namedTySym->name()->text() != decl.name_) - return REJECT_CANDIDATE(tySym, "type name mismatch"); + if (namedTySym->name()->text() != decl.name_) + return REJECT_CANDIDATE(tySym, "type name mismatch"); - return true; + return true; } -bool symbolMatchesBinding(const std::unique_ptr& sym, const DeclSummary& summary) -{ - const Symbol* candSym = sym.get(); +bool symbolMatchesBinding(const std::unique_ptr &sym, + const DeclSummary &summary) { + const Symbol *candSym = sym.get(); - if (candSym->kind() != summary.symK_) - return REJECT_CANDIDATE(candSym, "symbol kind mismatch"); + if (candSym->kind() != summary.symK_) + return REJECT_CANDIDATE(candSym, "symbol kind mismatch"); - if (summary.scopeK_ != ScopeKind::UNSPECIFIED) { - if (candSym->scope()->kind() != summary.scopeK_) - return REJECT_CANDIDATE(candSym, "scope kind mismatch"); - } + if (summary.scopeK_ != ScopeKind::UNSPECIFIED) { + if (candSym->scope()->kind() != summary.scopeK_) + return REJECT_CANDIDATE(candSym, "scope kind mismatch"); + } -// if (summary.nsK_ != NameSpaceKind::UNSPECIFIED) { -// if (candSym->nameSpace()->kind() != summary.nsK_) -// return REJECT_CANDIDATE(candSym, "name space kind mismatch"); -// } + // if (summary.nsK_ != NameSpaceKind::UNSPECIFIED) { + // if (candSym->nameSpace()->kind() != summary.nsK_) + // return REJECT_CANDIDATE(candSym, "name space kind mismatch"); + // } - switch (summary.symK_) - { - case SymbolKind::Value: - return valueMatchesBinding(candSym->asValue(), summary); + switch (summary.symK_) { + case SymbolKind::Value: + return valueMatchesBinding(candSym->asValue(), summary); - case SymbolKind::Type: { - return typeMatchesBinding(candSym->asType(), summary); - } + case SymbolKind::Type: { + return typeMatchesBinding(candSym->asType(), summary); + } - case SymbolKind::Function: - return functionMatchesBinding(candSym->asFunction(), summary); - - default: - PSY__internals__FAIL("unknkown symbol kind"); - return false; - } + case SymbolKind::Function: + return functionMatchesBinding(candSym->asFunction(), summary); + default: + PSY__internals__FAIL("unknkown symbol kind"); return false; + } + + return false; }; -} // anonymous +} // namespace -void InternalsTestSuite::bind(std::string text, Expectation X) -{ - parse(text); - auto compilation = Compilation::create(tree_->filePath()); - compilation->addSyntaxTrees({ tree_.get() }); - compilation->semanticModel(tree_.get()); +void InternalsTestSuite::bind(std::string text, Expectation X) { + parse(text); + auto compilation = Compilation::create(tree_->filePath()); + compilation->addSyntaxTrees({tree_.get()}); + compilation->semanticModel(tree_.get()); - if (!checkErrorAndWarn(X)) - return; + if (!checkErrorAndWarn(X)) + return; - auto sym = compilation->assembly()->findSymDEF( - [] (const auto& sym) { - return sym->kind() == SymbolKind::Library; - }); - if (sym == nullptr) - PSY__internals__FAIL("link unit not found"); + auto sym = compilation->assembly()->findSymDEF( + [](const auto &sym) { return sym->kind() == SymbolKind::Library; }); + if (sym == nullptr) + PSY__internals__FAIL("link unit not found"); - for (const auto& binding : X.bindings_) { + for (const auto &binding : X.bindings_) { #ifdef DEBUG_BINDING_SEARCH - std::cout << "\n\t\t..."; + std::cout << "\n\t\t..."; #endif - using namespace std::placeholders; + using namespace std::placeholders; - auto pred = std::bind(symbolMatchesBinding, _1, binding); - auto sym = compilation->assembly()->findSymDEF(pred); + auto pred = std::bind(symbolMatchesBinding, _1, binding); + auto sym = compilation->assembly()->findSymDEF(pred); - if (sym == nullptr) { - auto s = "no symbol matches the expectation: " - + binding.name_ + " " + to_string(binding.symK_); - PSY__internals__FAIL(s); - } + if (sym == nullptr) { + auto s = "no symbol matches the expectation: " + binding.name_ + " " + + to_string(binding.symK_); + PSY__internals__FAIL(s); + } #ifdef DEBUG_BINDING_SEARCH - std::cout << "\n\t\tmatch! "; + std::cout << "\n\t\tmatch! "; #endif - - } + } } diff --git a/C/tests/TestSuite_Internals.h b/C/tests/TestSuite_Internals.h index 91c5b0ca4..fcc2ecf6e 100644 --- a/C/tests/TestSuite_Internals.h +++ b/C/tests/TestSuite_Internals.h @@ -32,51 +32,57 @@ #include #include -#define CROSS_REFERENCE_TEST(CASE) { auto x = &CASE; (void)x; } \ +#define CROSS_REFERENCE_TEST(CASE) \ + { \ + auto x = &CASE; \ + (void)x; \ + } namespace psy { namespace C { -class InternalsTestSuite : public TestSuite -{ - friend class ParserTester; - friend class ReparserTester; - friend class BinderTester; +class InternalsTestSuite : public TestSuite { + friend class ParserTester; + friend class ReparserTester; + friend class BinderTester; public: - virtual ~InternalsTestSuite(); - InternalsTestSuite(); + virtual ~InternalsTestSuite(); + InternalsTestSuite(); - virtual std::tuple testAll() override; - virtual std::string description() const override; - virtual void printSummary() const override; + virtual std::tuple testAll() override; + virtual std::string description() const override; + virtual void printSummary() const override; private: - bool checkErrorAndWarn(Expectation X); - - void parseDeclaration(std::string text, Expectation X = Expectation()); - void parseExpression(std::string text, Expectation X = Expectation()); - void parseStatement(std::string text, Expectation X = Expectation()); - void parse(std::string text, - Expectation X = Expectation(), - SyntaxTree::SyntaxCategory synCat = SyntaxTree::SyntaxCategory::UNSPECIFIED); - - void reparse_withSyntaxCorrelation(std::string text, Expectation X = Expectation()); - void reparse_withTypeSynonymVerification(std::string text, Expectation X = Expectation()); - void reparse_withGuidelineImposition(std::string text, Expectation X = Expectation()); - void reparse(std::string text, - Expectation X = Expectation(), - Reparser::DisambiguationStrategy strategy = Reparser::DisambiguationStrategy::UNSPECIFIED); - - void bind(std::string text, Expectation X = Expectation()); - - std::unique_ptr tree_; - std::unique_ptr compilation_; - std::vector> testers_; + bool checkErrorAndWarn(Expectation X); + + void parseDeclaration(std::string text, Expectation X = Expectation()); + void parseExpression(std::string text, Expectation X = Expectation()); + void parseStatement(std::string text, Expectation X = Expectation()); + void parse(std::string text, Expectation X = Expectation(), + SyntaxTree::SyntaxCategory synCat = + SyntaxTree::SyntaxCategory::UNSPECIFIED); + + void reparse_withSyntaxCorrelation(std::string text, + Expectation X = Expectation()); + void reparse_withTypeSynonymVerification(std::string text, + Expectation X = Expectation()); + void reparse_withGuidelineImposition(std::string text, + Expectation X = Expectation()); + void reparse(std::string text, Expectation X = Expectation(), + Reparser::DisambiguationStrategy strategy = + Reparser::DisambiguationStrategy::UNSPECIFIED); + + void bind(std::string text, Expectation X = Expectation()); + + std::unique_ptr tree_; + std::unique_ptr compilation_; + std::vector> testers_; }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/C/typing/Shape.h b/C/typing/Shape.h index fbb047479..2db06ebd6 100644 --- a/C/typing/Shape.h +++ b/C/typing/Shape.h @@ -27,13 +27,12 @@ namespace psy { namespace C { -class PSY_C_NON_API Shape -{ +class PSY_C_NON_API Shape { public: - virtual ~Shape(); + virtual ~Shape(); }; -} // C -} // psy +} // namespace C +} // namespace psy #endif diff --git a/TestSuiteRunner.cpp b/TestSuiteRunner.cpp index 7e517c3bd..dda3a2f14 100644 --- a/TestSuiteRunner.cpp +++ b/TestSuiteRunner.cpp @@ -24,17 +24,13 @@ using namespace psy; -int main() -{ - try - { - TestSuite::runTests(); - } - catch (...) - { - std::cerr << "Unhandled exception during tests!" << std::endl; - return 1; - } +int main() { + try { + TestSuite::runTests(); + } catch (...) { + std::cerr << "Unhandled exception during tests!" << std::endl; + return 1; + } - return 0; + return 0; } diff --git a/cnippet/CompilerFrontend.cpp b/cnippet/CompilerFrontend.cpp index 81853ff1d..39b319d74 100644 --- a/cnippet/CompilerFrontend.cpp +++ b/cnippet/CompilerFrontend.cpp @@ -24,8 +24,6 @@ using namespace cnip; -CompilerFrontend::~CompilerFrontend() -{} +CompilerFrontend::~CompilerFrontend() {} -CompilerFrontend::CompilerFrontend() -{} +CompilerFrontend::CompilerFrontend() {} diff --git a/cnippet/CompilerFrontend.h b/cnippet/CompilerFrontend.h index 9413cbdfb..2a9c0a502 100644 --- a/cnippet/CompilerFrontend.h +++ b/cnippet/CompilerFrontend.h @@ -34,17 +34,16 @@ namespace cnip { /*! * \brief The CompilerFrontend class. */ -class CompilerFrontend -{ +class CompilerFrontend { public: - virtual ~CompilerFrontend(); + virtual ~CompilerFrontend(); - virtual int run(const std::string& srcText, const psy::FileInfo& fi) = 0; + virtual int run(const std::string &srcText, const psy::FileInfo &fi) = 0; protected: - CompilerFrontend(); + CompilerFrontend(); }; -} // cnip +} // namespace cnip #endif diff --git a/cnippet/CompilerFrontend_C.cpp b/cnippet/CompilerFrontend_C.cpp index 6ff6a49b5..71dde5e9f 100644 --- a/cnippet/CompilerFrontend_C.cpp +++ b/cnippet/CompilerFrontend_C.cpp @@ -33,14 +33,12 @@ using namespace cnip; using namespace psy; using namespace C; -namespace DEBUG -{ +namespace DEBUG { bool globalDebugEnabled = false; } -namespace -{ -const char * const kInclude = "#include"; +namespace { +const char *const kInclude = "#include"; } constexpr int CCompilerFrontend::ERROR_PreprocessorInvocationFailure; @@ -48,159 +46,151 @@ constexpr int CCompilerFrontend::ERROR_PreprocessedFileWritingFailure; constexpr int CCompilerFrontend::ERROR_UnsuccessfulParsing; constexpr int CCompilerFrontend::ERROR_InvalidSyntaxTree; -CCompilerFrontend::CCompilerFrontend(const cxxopts::ParseResult& parsedCmdLine) - : CompilerFrontend() - , config_(new ConfigurationForC(parsedCmdLine)) -{} +CCompilerFrontend::CCompilerFrontend(const cxxopts::ParseResult &parsedCmdLine) + : CompilerFrontend(), config_(new ConfigurationForC(parsedCmdLine)) {} -CCompilerFrontend::~CCompilerFrontend() -{} +CCompilerFrontend::~CCompilerFrontend() {} -int CCompilerFrontend::run(const std::string& srcText, const FileInfo& fi) -{ - if (srcText.empty()) - return 0; +int CCompilerFrontend::run(const std::string &srcText, const FileInfo &fi) { + if (srcText.empty()) + return 0; + + return config_->inferMissingTypes ? extendWithStdLibHeaders(srcText, fi) + : preprocess(srcText, fi); +} - return config_->inferMissingTypes ? extendWithStdLibHeaders(srcText, fi) - : preprocess(srcText, fi); +int CCompilerFrontend::extendWithStdLibHeaders(const std::string &srcText, + const psy::FileInfo &fi) { + if (!Plugin::isLoaded()) + return 1; + + std::istringstream iss(srcText); + std::string line; + std::string existingHeaders; + while (std::getline(iss, line)) { + line.erase(0, line.find_first_not_of(' ')); + if (line.find(kInclude) == 0) + existingHeaders += line + '\n'; + } + + SourceInspector *inspector = Plugin::createInspector(); + auto stdLibHeaders = inspector->detectRequiredHeaders(srcText); + if (stdLibHeaders.empty()) + return preprocess(srcText, fi); + + std::string srcText_P; + srcText_P += "\n/* CNIPPET: Start of #include section */\n"; + for (const auto &name : stdLibHeaders) { + auto line = std::string(kInclude) + " <" + name + ">\n"; + srcText_P += line; + existingHeaders += line; + } + srcText_P += "\n/* End of #include section */\n\n"; + srcText_P += srcText; + + return preprocess(srcText_P, fi); } -int CCompilerFrontend::extendWithStdLibHeaders(const std::string& srcText, - const psy::FileInfo& fi) -{ - if (!Plugin::isLoaded()) - return 1; - - std::istringstream iss(srcText); - std::string line; - std::string existingHeaders; - while (std::getline(iss, line)) { - line.erase(0, line.find_first_not_of(' ')); - if (line.find(kInclude) == 0) - existingHeaders += line + '\n'; +int CCompilerFrontend::preprocess(const std::string &srcText, + const psy::FileInfo &fi) { + GnuCompilerFacade cc(config_->hostCompiler, to_string(config_->langStd), + config_->macrosToDefine, config_->macrosToUndef); + + std::string srcText_P; + int exit; + if (config_->expandIncludes) { + std::tie(exit, srcText_P) = cc.preprocess(srcText); + if (exit != 0) { + std::cerr << kCnip << "preprocessor invocation failed" << std::endl; + return ERROR_PreprocessorInvocationFailure; } - SourceInspector* inspector = Plugin::createInspector(); - auto stdLibHeaders = inspector->detectRequiredHeaders(srcText); - if (stdLibHeaders.empty()) - return preprocess(srcText, fi); - - std::string srcText_P; - srcText_P += "\n/* CNIPPET: Start of #include section */\n"; - for (const auto& name : stdLibHeaders) { - auto line = std::string(kInclude) + " <" + name + ">\n"; - srcText_P += line; - existingHeaders += line; + exit = writeFile(fi.fullFileBaseName() + ".i", srcText_P); + if (exit != 0) { + std::cerr << kCnip << "preprocessed file write failure" << std::endl; + return ERROR_PreprocessedFileWritingFailure; } - srcText_P += "\n/* End of #include section */\n\n"; - srcText_P += srcText; + } else { + std::tie(exit, srcText_P) = cc.preprocess_IgnoreIncludes(srcText); + } - return preprocess(srcText_P, fi); + return constructSyntaxTree(srcText_P, fi); } -int CCompilerFrontend::preprocess(const std::string& srcText, - const psy::FileInfo& fi) -{ - GnuCompilerFacade cc(config_->hostCompiler, - to_string(config_->langStd), - config_->macrosToDefine, - config_->macrosToUndef); - - std::string srcText_P; - int exit; - if (config_->expandIncludes) { - std::tie(exit, srcText_P) = cc.preprocess(srcText); - if (exit != 0) { - std::cerr << kCnip << "preprocessor invocation failed" << std::endl; - return ERROR_PreprocessorInvocationFailure; - } - - exit = writeFile(fi.fullFileBaseName() + ".i", srcText_P); - if (exit != 0) { - std::cerr << kCnip << "preprocessed file write failure" << std::endl; - return ERROR_PreprocessedFileWritingFailure; - } - } +int CCompilerFrontend::constructSyntaxTree(const std::string &srcText, + const psy::FileInfo &fi) { + ParseOptions parseOpts; + + // TODO: Move to driver/config. + if (!config_->ParseOptions_TreatmentOfAmbiguities.empty()) { + if (config_->ParseOptions_TreatmentOfAmbiguities == "None") + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities::None); + else if (config_->ParseOptions_TreatmentOfAmbiguities == "Diagnose") + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities::Diagnose); + else if (config_->ParseOptions_TreatmentOfAmbiguities == + "DisambiguateAlgorithmically") + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmically); + else if (config_->ParseOptions_TreatmentOfAmbiguities == + "DisambiguateAlgorithmicallyOrHeuristically") + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities:: + DisambiguateAlgorithmicallyOrHeuristically); + else if (config_->ParseOptions_TreatmentOfAmbiguities == + "DisambiguateHeuristically") + parseOpts.setTreatmentOfAmbiguities( + ParseOptions::TreatmentOfAmbiguities::DisambiguateHeuristically); else { - std::tie(exit, srcText_P) = cc.preprocess_IgnoreIncludes(srcText); + std::cerr << "unrecognized --C-ParseOptions-TreatmentOfAmbiguities" + << std::endl; + return 1; } - - return constructSyntaxTree(srcText_P, fi); + } + + auto tree = SyntaxTree::parseText( + srcText, TextPreprocessingState::Preprocessed, TextCompleteness::Fragment, + parseOpts, fi.fileName()); + + if (!tree) { + std::cerr << "unsuccessful parsing" << std::endl; + return ERROR_UnsuccessfulParsing; + } + + TranslationUnitSyntax *TU = tree->translationUnitRoot(); + if (!TU) { + std::cerr << "invalid syntax tree" << std::endl; + return ERROR_InvalidSyntaxTree; + } + + if (!tree->diagnostics().empty()) { + auto c = tree->diagnostics(); + std::copy(c.begin(), c.end(), std::ostream_iterator(std::cerr)); + std::cerr << std::endl; + } + + if (config_->dumpAst) { + std::ostringstream ossTree; + SyntaxNamePrinter printer(tree.get()); + printer.print(TU, SyntaxNamePrinter::Style::Decorated, ossTree); + std::cout << ossTree.str() << std::endl; + } + + return config_->WIP_ ? computeSemanticModel(std::move(tree)) : 0; } -int CCompilerFrontend::constructSyntaxTree(const std::string& srcText, - const psy::FileInfo& fi) -{ - ParseOptions parseOpts; - - // TODO: Move to driver/config. - if (!config_->ParseOptions_TreatmentOfAmbiguities.empty()) { - if (config_->ParseOptions_TreatmentOfAmbiguities == "None") - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::None); - else if (config_->ParseOptions_TreatmentOfAmbiguities == "Diagnose") - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::Diagnose); - else if (config_->ParseOptions_TreatmentOfAmbiguities == "DisambiguateAlgorithmically") - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmically); - else if (config_->ParseOptions_TreatmentOfAmbiguities == "DisambiguateAlgorithmicallyOrHeuristically") - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::DisambiguateAlgorithmicallyOrHeuristically); - else if (config_->ParseOptions_TreatmentOfAmbiguities == "DisambiguateHeuristically") - parseOpts.setTreatmentOfAmbiguities(ParseOptions::TreatmentOfAmbiguities::DisambiguateHeuristically); - else { - std::cerr << "unrecognized --C-ParseOptions-TreatmentOfAmbiguities" << std::endl; - return 1; - } - } - - auto tree = SyntaxTree::parseText(srcText, - TextPreprocessingState::Preprocessed, - TextCompleteness::Fragment, - parseOpts, - fi.fileName()); +int CCompilerFrontend::computeSemanticModel(std::unique_ptr tree) { + auto compilation = Compilation::create(tree->filePath()); + compilation->addSyntaxTrees({tree.get()}); + /*auto semaModel = */ compilation->semanticModel(tree.get()); - if (!tree) { - std::cerr << "unsuccessful parsing" << std::endl; - return ERROR_UnsuccessfulParsing; - } - - TranslationUnitSyntax* TU = tree->translationUnitRoot(); - if (!TU) { - std::cerr << "invalid syntax tree" << std::endl; - return ERROR_InvalidSyntaxTree; - } + // show only not yet shown + if (!tree->diagnostics().empty()) { + auto c = tree->diagnostics(); + std::copy(c.begin(), c.end(), std::ostream_iterator(std::cerr)); + std::cerr << std::endl; + } - if (!tree->diagnostics().empty()) { - auto c = tree->diagnostics(); - std::copy(c.begin(), c.end(), - std::ostream_iterator(std::cerr)); - std::cerr << std::endl; - } - - if (config_->dumpAst) { - std::ostringstream ossTree; - SyntaxNamePrinter printer(tree.get()); - printer.print(TU, - SyntaxNamePrinter::Style::Decorated, - ossTree); - std::cout << ossTree.str() << std::endl; - } - - return config_->WIP_ ? computeSemanticModel(std::move(tree)) - : 0; -} - -int CCompilerFrontend::computeSemanticModel(std::unique_ptr tree) -{ - auto compilation = Compilation::create(tree->filePath()); - compilation->addSyntaxTrees({ tree.get() }); - /*auto semaModel = */compilation->semanticModel(tree.get()); - - // show only not yet shown - if (!tree->diagnostics().empty()) { - auto c = tree->diagnostics(); - std::copy(c.begin(), c.end(), - std::ostream_iterator(std::cerr)); - std::cerr << std::endl; - } - - return 0; + return 0; } diff --git a/cnippet/CompilerFrontend_C.h b/cnippet/CompilerFrontend_C.h index 7dfbf7243..208585a3f 100644 --- a/cnippet/CompilerFrontend_C.h +++ b/cnippet/CompilerFrontend_C.h @@ -28,37 +28,36 @@ #include "C/SyntaxTree.h" -#include #include +#include namespace cnip { /*! * \brief The CCompilerFrontend class. */ -class CCompilerFrontend : public CompilerFrontend -{ +class CCompilerFrontend : public CompilerFrontend { public: - CCompilerFrontend(const cxxopts::ParseResult& parsedCmdLine); - virtual ~CCompilerFrontend(); + CCompilerFrontend(const cxxopts::ParseResult &parsedCmdLine); + virtual ~CCompilerFrontend(); - int run(const std::string& srcText, const psy::FileInfo& fi) override; + int run(const std::string &srcText, const psy::FileInfo &fi) override; private: - - int extendWithStdLibHeaders(const std::string& srcText, const psy::FileInfo& fi); - int preprocess(const std::string& srcText, const psy::FileInfo& fi); - int constructSyntaxTree(const std::string& srcText, const psy::FileInfo& fi); - int computeSemanticModel(std::unique_ptr tree); - - static constexpr int ERROR_PreprocessorInvocationFailure = 100; - static constexpr int ERROR_PreprocessedFileWritingFailure = 101; - static constexpr int ERROR_UnsuccessfulParsing = 102; - static constexpr int ERROR_InvalidSyntaxTree = 103; - - std::unique_ptr config_; + int extendWithStdLibHeaders(const std::string &srcText, + const psy::FileInfo &fi); + int preprocess(const std::string &srcText, const psy::FileInfo &fi); + int constructSyntaxTree(const std::string &srcText, const psy::FileInfo &fi); + int computeSemanticModel(std::unique_ptr tree); + + static constexpr int ERROR_PreprocessorInvocationFailure = 100; + static constexpr int ERROR_PreprocessedFileWritingFailure = 101; + static constexpr int ERROR_UnsuccessfulParsing = 102; + static constexpr int ERROR_InvalidSyntaxTree = 103; + + std::unique_ptr config_; }; -} // cnip +} // namespace cnip #endif diff --git a/cnippet/Configuration.cpp b/cnippet/Configuration.cpp index db18c9103..6e6b972de 100644 --- a/cnippet/Configuration.cpp +++ b/cnippet/Configuration.cpp @@ -22,10 +22,8 @@ using namespace cnip; -Configuration::~Configuration() -{} +Configuration::~Configuration() {} -Configuration::Configuration(const cxxopts::ParseResult& parsedCmdLine) - : dumpAst(parsedCmdLine.count("dump-AST")) - , WIP_(parsedCmdLine.count("WIP")) -{} +Configuration::Configuration(const cxxopts::ParseResult &parsedCmdLine) + : dumpAst(parsedCmdLine.count("dump-AST")), + WIP_(parsedCmdLine.count("WIP")) {} diff --git a/cnippet/Configuration.h b/cnippet/Configuration.h index 0dd75d890..18202db37 100644 --- a/cnippet/Configuration.h +++ b/cnippet/Configuration.h @@ -28,19 +28,18 @@ namespace cnip { /*! * \brief The Configuration class. */ -class Configuration -{ +class Configuration { public: - virtual ~Configuration(); + virtual ~Configuration(); - // TODO: API - bool dumpAst; - bool WIP_; + // TODO: API + bool dumpAst; + bool WIP_; protected: - Configuration(const cxxopts::ParseResult& parsedCmdLine); + Configuration(const cxxopts::ParseResult &parsedCmdLine); }; -} // cnip +} // namespace cnip #endif diff --git a/cnippet/Configuration_C.cpp b/cnippet/Configuration_C.cpp index e49187432..4678038bc 100644 --- a/cnippet/Configuration_C.cpp +++ b/cnippet/Configuration_C.cpp @@ -21,93 +21,85 @@ #include "Configuration_C.h" namespace { -const char* const kCStd = "c-std"; -const char* const kHostCCompiler = "host-cc"; -const char* const kExpandCPPIncludeDirectives = "cpp-includes"; -const char* const kDefineCPPMacro = "cpp-D"; -const char* const KUndefineCPPMacro = "cpp-U"; -const char* const kAddDirToCPPSearchPath = "cpp-I"; -} +const char *const kCStd = "c-std"; +const char *const kHostCCompiler = "host-cc"; +const char *const kExpandCPPIncludeDirectives = "cpp-includes"; +const char *const kDefineCPPMacro = "cpp-D"; +const char *const KUndefineCPPMacro = "cpp-U"; +const char *const kAddDirToCPPSearchPath = "cpp-I"; +} // namespace using namespace cnip; -void ConfigurationForC::extend(cxxopts::Options& cmdLineOpts) -{ - cmdLineOpts.add_options() - // https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options - (kCStd, - "Specify the C standard.", - cxxopts::value()->default_value("c11"), - "") - - (kHostCCompiler, - "Specify a host C compiler.", - cxxopts::value()->default_value("gcc"), - "") - - // https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html - (kExpandCPPIncludeDirectives, - "Expand `#include' directives of the C preprocessor.", - cxxopts::value()->default_value("false")) - - // https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html - (kAddDirToCPPSearchPath, - "Add a directory to the `#include' search path of the C preprocessor.", - cxxopts::value>(), - "path") - - // https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html - (kDefineCPPMacro, - "Predefine a C preprocessor macro.", - cxxopts::value>(), - "") - (KUndefineCPPMacro, - "Undefine a C preprocessor macro.", - cxxopts::value>(), - "") - - /* Ambiguity */ - ("C-ParseOptions-TreatmentOfAmbiguities", - "Treatment of ambiguities.", - cxxopts::value() - ->default_value("DisambiguateAlgorithmicallyOrHeuristically"), - "") - - /* Type inference */ - ("C-infer", "Infer the definition of missing types.") - ("o,output", "Specify output file", - cxxopts::value()->default_value("a.cstr")) - ; +void ConfigurationForC::extend(cxxopts::Options &cmdLineOpts) { + cmdLineOpts.add_options() + // https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options + (kCStd, "Specify the C standard.", + cxxopts::value()->default_value("c11"), + "") + + (kHostCCompiler, "Specify a host C compiler.", + cxxopts::value()->default_value("gcc"), "") + + // https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html + (kExpandCPPIncludeDirectives, + "Expand `#include' directives of the C preprocessor.", + cxxopts::value()->default_value("false")) + + // https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html + (kAddDirToCPPSearchPath, + "Add a directory to the `#include' search path of the C preprocessor.", + cxxopts::value>(), "path") + + // https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html + (kDefineCPPMacro, "Predefine a C preprocessor macro.", + cxxopts::value>(), "")( + KUndefineCPPMacro, "Undefine a C preprocessor macro.", + cxxopts::value>(), "") + + /* Ambiguity */ + ("C-ParseOptions-TreatmentOfAmbiguities", "Treatment of ambiguities.", + cxxopts::value()->default_value( + "DisambiguateAlgorithmicallyOrHeuristically"), + "") + + /* Type inference */ + ("C-infer", "Infer the definition of missing types.")( + "o,output", "Specify output file", + cxxopts::value()->default_value("a.cstr")); } -ConfigurationForC::ConfigurationForC(const cxxopts::ParseResult& parsedCmdLine) - : Configuration(parsedCmdLine) -{ - auto cc_std = parsedCmdLine[kCStd].as(); - std::for_each(cc_std.begin(), - cc_std.end(), - [] (char& c) { c = ::tolower(c); }); - if (cc_std == "c89" || cc_std == "c90") - langStd = LanguageDialect::Std::C89_90; - else if (cc_std == "c99") - langStd = LanguageDialect::Std::C99; - else if (cc_std == "c17" || cc_std == "c18") - langStd = LanguageDialect::Std::C17_18; - else - langStd = LanguageDialect::Std::C11; - - hostCompiler = parsedCmdLine[kHostCCompiler].as(); - - expandIncludes = parsedCmdLine[kExpandCPPIncludeDirectives].as(); - if (parsedCmdLine.count(kDefineCPPMacro)) - macrosToDefine = parsedCmdLine[kDefineCPPMacro].as>(); - if (parsedCmdLine.count(KUndefineCPPMacro)) - macrosToUndef = parsedCmdLine[KUndefineCPPMacro].as>(); - - if (parsedCmdLine.count(kAddDirToCPPSearchPath)) - headerSearchPaths = parsedCmdLine[kAddDirToCPPSearchPath].as>(); - - ParseOptions_TreatmentOfAmbiguities = parsedCmdLine["C-ParseOptions-TreatmentOfAmbiguities"].as(); - - inferMissingTypes = parsedCmdLine.count("infer"); +ConfigurationForC::ConfigurationForC(const cxxopts::ParseResult &parsedCmdLine) + : Configuration(parsedCmdLine) { + auto cc_std = parsedCmdLine[kCStd].as(); + std::for_each(cc_std.begin(), cc_std.end(), + [](char &c) { c = ::tolower(c); }); + if (cc_std == "c89" || cc_std == "c90") + langStd = LanguageDialect::Std::C89_90; + else if (cc_std == "c99") + langStd = LanguageDialect::Std::C99; + else if (cc_std == "c17" || cc_std == "c18") + langStd = LanguageDialect::Std::C17_18; + else + langStd = LanguageDialect::Std::C11; + + hostCompiler = parsedCmdLine[kHostCCompiler].as(); + + expandIncludes = parsedCmdLine[kExpandCPPIncludeDirectives].as(); + if (parsedCmdLine.count(kDefineCPPMacro)) + macrosToDefine = + parsedCmdLine[kDefineCPPMacro].as>(); + if (parsedCmdLine.count(KUndefineCPPMacro)) + macrosToUndef = + parsedCmdLine[KUndefineCPPMacro].as>(); + + if (parsedCmdLine.count(kAddDirToCPPSearchPath)) + headerSearchPaths = + parsedCmdLine[kAddDirToCPPSearchPath].as>(); + + ParseOptions_TreatmentOfAmbiguities = + parsedCmdLine["C-ParseOptions-TreatmentOfAmbiguities"].as(); + + inferMissingTypes = parsedCmdLine.count("infer"); } diff --git a/cnippet/Configuration_C.h b/cnippet/Configuration_C.h index f8526e1f1..c5afe6d38 100644 --- a/cnippet/Configuration_C.h +++ b/cnippet/Configuration_C.h @@ -36,28 +36,27 @@ namespace cnip { /*! * \brief The ConfigurationForC class. */ -class ConfigurationForC : public Configuration -{ +class ConfigurationForC : public Configuration { public: - ConfigurationForC(const cxxopts::ParseResult& parsedCmdLine); + ConfigurationForC(const cxxopts::ParseResult &parsedCmdLine); - static void extend(cxxopts::Options& cmdLineOpts); + static void extend(cxxopts::Options &cmdLineOpts); - // TODO: API - LanguageDialect::Std langStd; + // TODO: API + LanguageDialect::Std langStd; - std::string hostCompiler; - std::vector macrosToDefine; - std::vector macrosToUndef; - std::vector headerSearchPaths; + std::string hostCompiler; + std::vector macrosToDefine; + std::vector macrosToUndef; + std::vector headerSearchPaths; - std::string ParseOptions_TreatmentOfAmbiguities; + std::string ParseOptions_TreatmentOfAmbiguities; - // TODO: Bit fields. - bool expandIncludes; - bool inferMissingTypes; + // TODO: Bit fields. + bool expandIncludes; + bool inferMissingTypes; }; -} // cnip +} // namespace cnip #endif diff --git a/cnippet/Driver.cpp b/cnippet/Driver.cpp index b8d4897ca..847458768 100644 --- a/cnippet/Driver.cpp +++ b/cnippet/Driver.cpp @@ -29,15 +29,17 @@ #include "Plugin.h" #include +#include #include #include #include -#include using namespace psy; using namespace cnip; -namespace DEBUG { extern bool globalDebugEnabled; } +namespace DEBUG { +extern bool globalDebugEnabled; +} constexpr int Driver::SUCCESS; constexpr int Driver::ERROR_NoInputFile; @@ -45,99 +47,84 @@ constexpr int Driver::ERROR_UnrecognizedCmdLineOption; constexpr int Driver::ERROR_CannotLoadPluging; constexpr int Driver::ERROR_LanguageNotRecognized; -Driver::Driver() -{} - -Driver::~Driver() -{} - -int Driver::execute(int argc, char* argv[]) -{ - cxxopts::Options cmdLineOpts(argv[0], "cnippet"); - cmdLineOpts - .positional_help("file") - .add_options() - ("file", - "The input file(s) path(s).", - cxxopts::value>()) - ("l,lang", - "Specify the language.", - cxxopts::value()->default_value("C"), - "") - ("z,dump-AST", - "Dump the program's AST to the console.") - ("d,debug", - "Enable debugging.", - cxxopts::value(DEBUG::globalDebugEnabled)) - ("p,plugin", - "Load plugin with the given name.", - cxxopts::value()) - ("w,WIP", - "Enable Work-In-Progress features.") - ("h,help", - "Print instructions.") - ; - - ConfigurationForC::extend(cmdLineOpts); - - std::unique_ptr FE; - std::vector filesPaths; - try { - cmdLineOpts.parse_positional(std::vector{"file"}); - auto parsedCmdLine = cmdLineOpts.parse(argc, argv); - - if (parsedCmdLine.count("help")) { - std::cout << cmdLineOpts.help({"", "Group"}) << std::endl; - return SUCCESS; - } - - if (parsedCmdLine.count("plugin")) { - auto pluginName = parsedCmdLine["plugin"].as(); - Plugin::load(pluginName); - if (!Plugin::isLoaded()) { - std::cerr << kCnip << "cannot load plugin " << pluginName << std::endl; - return ERROR_CannotLoadPluging; - } - } - - if (parsedCmdLine.count("file")) - filesPaths = parsedCmdLine["file"].as>(); - else { - std::cerr << kCnip << "no input file(s)" << std::endl; - return ERROR_NoInputFile; - } - - auto lang = parsedCmdLine["lang"].as(); - if (lang != "C") { - std::cerr << kCnip << "language " << lang << " not recognized" << std::endl; - return ERROR_LanguageNotRecognized; - } - - FE.reset(new CCompilerFrontend(parsedCmdLine)); +Driver::Driver() {} + +Driver::~Driver() {} + +int Driver::execute(int argc, char *argv[]) { + cxxopts::Options cmdLineOpts(argv[0], "cnippet"); + cmdLineOpts.positional_help("file").add_options()( + "file", "The input file(s) path(s).", + cxxopts::value>())( + "l,lang", "Specify the language.", + cxxopts::value()->default_value("C"), + "")("z,dump-AST", "Dump the program's AST to the console.")( + "d,debug", "Enable debugging.", + cxxopts::value(DEBUG::globalDebugEnabled))( + "p,plugin", "Load plugin with the given name.", + cxxopts::value())( + "w,WIP", "Enable Work-In-Progress features.")("h,help", + "Print instructions."); + + ConfigurationForC::extend(cmdLineOpts); + + std::unique_ptr FE; + std::vector filesPaths; + try { + cmdLineOpts.parse_positional(std::vector{"file"}); + auto parsedCmdLine = cmdLineOpts.parse(argc, argv); + + if (parsedCmdLine.count("help")) { + std::cout << cmdLineOpts.help({"", "Group"}) << std::endl; + return SUCCESS; } - catch (...) { - std::cerr << kCnip << "unrecognized command-line option" << std::endl; - return ERROR_UnrecognizedCmdLineOption; + + if (parsedCmdLine.count("plugin")) { + auto pluginName = parsedCmdLine["plugin"].as(); + Plugin::load(pluginName); + if (!Plugin::isLoaded()) { + std::cerr << kCnip << "cannot load plugin " << pluginName << std::endl; + return ERROR_CannotLoadPluging; + } } - for (auto filePath : filesPaths) { - auto [exit, srcText] = readFile(filePath); - if (exit != 0) - return ERROR_FileNotFound; + if (parsedCmdLine.count("file")) + filesPaths = parsedCmdLine["file"].as>(); + else { + std::cerr << kCnip << "no input file(s)" << std::endl; + return ERROR_NoInputFile; + } - FileInfo fi(filePath); + auto lang = parsedCmdLine["lang"].as(); + if (lang != "C") { + std::cerr << kCnip << "language " << lang << " not recognized" + << std::endl; + return ERROR_LanguageNotRecognized; + } + + FE.reset(new CCompilerFrontend(parsedCmdLine)); + } catch (...) { + std::cerr << kCnip << "unrecognized command-line option" << std::endl; + return ERROR_UnrecognizedCmdLineOption; + } + + for (auto filePath : filesPaths) { + auto [exit, srcText] = readFile(filePath); + if (exit != 0) + return ERROR_FileNotFound; - try { - exit = FE->run(srcText, fi); - } - catch (...) { - Plugin::unload(); - return Driver::ERROR; - } + FileInfo fi(filePath); - if (exit != 0) - return exit; + try { + exit = FE->run(srcText, fi); + } catch (...) { + Plugin::unload(); + return Driver::ERROR; } - return SUCCESS; + if (exit != 0) + return exit; + } + + return SUCCESS; } diff --git a/cnippet/Driver.h b/cnippet/Driver.h index 0d674c63a..69a93fdec 100644 --- a/cnippet/Driver.h +++ b/cnippet/Driver.h @@ -21,35 +21,34 @@ #ifndef CNIPPET_DRIVER_H__ #define CNIPPET_DRIVER_H__ -const char* const kCnip = "cnip: "; +const char *const kCnip = "cnip: "; namespace cnip { /*! * \brief The Driver class. */ -class Driver final -{ +class Driver final { public: - Driver(); - ~Driver(); + Driver(); + ~Driver(); - int execute(int argc, char* argv[]); + int execute(int argc, char *argv[]); private: - friend class FrontEnd; - friend class CCompilerFrontEnd; + friend class FrontEnd; + friend class CCompilerFrontEnd; - static constexpr int SUCCESS = 0; + static constexpr int SUCCESS = 0; - static constexpr int ERROR = 1; - static constexpr int ERROR_UnrecognizedCmdLineOption = 2; - static constexpr int ERROR_NoInputFile = 3; - static constexpr int ERROR_FileNotFound = 4; - static constexpr int ERROR_CannotLoadPluging = 5; - static constexpr int ERROR_LanguageNotRecognized = 6; + static constexpr int ERROR = 1; + static constexpr int ERROR_UnrecognizedCmdLineOption = 2; + static constexpr int ERROR_NoInputFile = 3; + static constexpr int ERROR_FileNotFound = 4; + static constexpr int ERROR_CannotLoadPluging = 5; + static constexpr int ERROR_LanguageNotRecognized = 6; }; -} // cnip +} // namespace cnip #endif diff --git a/cnippet/Main.cpp b/cnippet/Main.cpp index 3134018a4..3997e1552 100644 --- a/cnippet/Main.cpp +++ b/cnippet/Main.cpp @@ -24,16 +24,12 @@ using namespace cnip; -int main(int argc, char* argv[]) -{ - try - { - Driver driver; - return driver.execute(argc, argv); - } - catch (...) - { - std::cerr << "unhandled exception" << std::endl; - return 1; - } +int main(int argc, char *argv[]) { + try { + Driver driver; + return driver.execute(argc, argv); + } catch (...) { + std::cerr << "unhandled exception" << std::endl; + return 1; + } } diff --git a/cnippet/Plugin.cpp b/cnippet/Plugin.cpp index e5e0a2147..e6c5132b3 100644 --- a/cnippet/Plugin.cpp +++ b/cnippet/Plugin.cpp @@ -23,106 +23,95 @@ #include "plugin-api/DeclarationInterceptor.h" #include "plugin-api/SourceInspector.h" -#include #include +#include #include using namespace cnip; using namespace psy; using namespace C; -void* Plugin::handle_ { nullptr }; -DeclarationInterceptor* Plugin::interceptor_ { nullptr }; -SourceInspector* Plugin::inspector_ { nullptr }; -VisitorObserver* Plugin::observer_ { nullptr }; +void *Plugin::handle_{nullptr}; +DeclarationInterceptor *Plugin::interceptor_{nullptr}; +SourceInspector *Plugin::inspector_{nullptr}; +VisitorObserver *Plugin::observer_{nullptr}; namespace { -std::string appendSuffix(std::string s) -{ - return s + - #if __APPLE__ - ".dylib"; - #else - ".so"; - #endif +std::string appendSuffix(std::string s) { + return s + +#if __APPLE__ + ".dylib"; +#else + ".so"; +#endif } -} // anonymous +} // namespace -void Plugin::load(const std::string& name) -{ - const std::string file = appendSuffix(name); - handle_ = dlopen(file.c_str(), RTLD_LOCAL | RTLD_LAZY); +void Plugin::load(const std::string &name) { + const std::string file = appendSuffix(name); + handle_ = dlopen(file.c_str(), RTLD_LOCAL | RTLD_LAZY); } -bool Plugin::isLoaded() -{ - return handle_; -} +bool Plugin::isLoaded() { return handle_; } -void Plugin::unload() -{ - if (!handle_) - return; +void Plugin::unload() { + if (!handle_) + return; - destroy(interceptor_, "deleteInterceptor"); - destroy(inspector_, "deleteInspector"); - destroy(observer_, "deleteObserver"); + destroy(interceptor_, "deleteInterceptor"); + destroy(inspector_, "deleteInspector"); + destroy(observer_, "deleteObserver"); } -DeclarationInterceptor* Plugin::createInterceptor() -{ - interceptor_ = create("newInterceptor"); - return interceptor_; +DeclarationInterceptor *Plugin::createInterceptor() { + interceptor_ = create("newInterceptor"); + return interceptor_; } -SourceInspector* Plugin::createInspector() -{ - inspector_ = create("newInspector"); - return inspector_; +SourceInspector *Plugin::createInspector() { + inspector_ = create("newInspector"); + return inspector_; } -VisitorObserver* Plugin::createObserver() -{ - observer_ = create("newObserver"); - return observer_; +VisitorObserver *Plugin::createObserver() { + observer_ = create("newObserver"); + return observer_; } -template -RetT* Plugin::create(const char* name) -{ - if (!handle_) - return nullptr; +template RetT *Plugin::create(const char *name) { + if (!handle_) + return nullptr; - using FuncT = RetT* (*) (); + using FuncT = RetT *(*)(); - dlerror(); - FuncT func = (FuncT)dlsym(handle_, name); - if (dlerror()) - return nullptr; + dlerror(); + FuncT func = (FuncT)dlsym(handle_, name); + if (dlerror()) + return nullptr; - return (*func)(); + return (*func)(); } -template -void Plugin::destroy(ParamT* p, const char* name) -{ - using FuncT = void (*) (ParamT*); - - if (p) { - dlerror(); - FuncT func = (FuncT)dlsym(handle_, name); - if (!dlerror()) - (*func)(p); - } +template void Plugin::destroy(ParamT *p, const char *name) { + using FuncT = void (*)(ParamT *); + + if (p) { + dlerror(); + FuncT func = (FuncT)dlsym(handle_, name); + if (!dlerror()) + (*func)(p); + } } // Explicit instantiations -template DeclarationInterceptor* Plugin::create(const char*); -template SourceInspector* Plugin::create(const char*); -template VisitorObserver* Plugin::create(const char*); - -template void Plugin::destroy(DeclarationInterceptor*, const char*); -template void Plugin::destroy(SourceInspector*, const char*); -template void Plugin::destroy(VisitorObserver*, const char*); +template DeclarationInterceptor * +Plugin::create(const char *); +template SourceInspector *Plugin::create(const char *); +template VisitorObserver *Plugin::create(const char *); + +template void Plugin::destroy(DeclarationInterceptor *, + const char *); +template void Plugin::destroy(SourceInspector *, const char *); +template void Plugin::destroy(VisitorObserver *, const char *); diff --git a/cnippet/Plugin.h b/cnippet/Plugin.h index 4a349a605..ffb915b0e 100644 --- a/cnippet/Plugin.h +++ b/cnippet/Plugin.h @@ -31,8 +31,8 @@ class DeclarationInterceptor; class SourceInspector; class VisitorObserver; -} // C -} // psy +} // namespace C +} // namespace psy namespace cnip { @@ -41,32 +41,29 @@ namespace cnip { * * To be extended... */ -class Plugin final -{ +class Plugin final { public: - static void load(const std::string& name); - static bool isLoaded(); - static void unload(); + static void load(const std::string &name); + static bool isLoaded(); + static void unload(); - static psy::C::DeclarationInterceptor* createInterceptor(); - static psy::C::SourceInspector* createInspector(); - static psy::C::VisitorObserver* createObserver(); + static psy::C::DeclarationInterceptor *createInterceptor(); + static psy::C::SourceInspector *createInspector(); + static psy::C::VisitorObserver *createObserver(); private: - Plugin() = delete; + Plugin() = delete; - template - static RetT* create(const char* name); + template static RetT *create(const char *name); - template - static void destroy(ParamT*, const char* name); + template static void destroy(ParamT *, const char *name); - static void* handle_; - static psy::C::DeclarationInterceptor* interceptor_; - static psy::C::SourceInspector* inspector_; - static psy::C::VisitorObserver* observer_; + static void *handle_; + static psy::C::DeclarationInterceptor *interceptor_; + static psy::C::SourceInspector *inspector_; + static psy::C::VisitorObserver *observer_; }; -} // cnip +} // namespace cnip #endif diff --git a/command/cxxopts/include/cxxopts.hpp b/command/cxxopts/include/cxxopts.hpp index 6d230f062..0452eadc9 100644 --- a/command/cxxopts/include/cxxopts.hpp +++ b/command/cxxopts/include/cxxopts.hpp @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef CXXOPTS_HPP_INCLUDED #define CXXOPTS_HPP_INCLUDED -#include #include +#include #include #include #include @@ -52,1644 +52,1069 @@ THE SOFTWARE. #define CXXOPTS__VERSION_MINOR 2 #define CXXOPTS__VERSION_PATCH 0 -namespace cxxopts -{ - static constexpr struct { - uint8_t major, minor, patch; - } version = { - CXXOPTS__VERSION_MAJOR, - CXXOPTS__VERSION_MINOR, - CXXOPTS__VERSION_PATCH - }; -} +namespace cxxopts { +static constexpr struct { + uint8_t major, minor, patch; +} version = {CXXOPTS__VERSION_MAJOR, CXXOPTS__VERSION_MINOR, + CXXOPTS__VERSION_PATCH}; +} // namespace cxxopts -//when we ask cxxopts to use Unicode, help strings are processed using ICU, -//which results in the correct lengths being computed for strings when they -//are formatted for the help output -//it is necessary to make sure that can be found by the -//compiler, and that icu-uc is linked in to the binary. +// when we ask cxxopts to use Unicode, help strings are processed using ICU, +// which results in the correct lengths being computed for strings when they +// are formatted for the help output +// it is necessary to make sure that can be found by the +// compiler, and that icu-uc is linked in to the binary. #ifdef CXXOPTS_USE_UNICODE #include -namespace cxxopts -{ - typedef icu::UnicodeString String; +namespace cxxopts { +typedef icu::UnicodeString String; - inline - String - toLocalString(std::string s) - { - return icu::UnicodeString::fromUTF8(std::move(s)); - } +inline String toLocalString(std::string s) { + return icu::UnicodeString::fromUTF8(std::move(s)); +} - class UnicodeStringIterator : public - std::iterator - { - public: +class UnicodeStringIterator + : public std::iterator { +public: + UnicodeStringIterator(const icu::UnicodeString *string, int32_t pos) + : s(string), i(pos) {} - UnicodeStringIterator(const icu::UnicodeString* string, int32_t pos) - : s(string) - , i(pos) - { - } + value_type operator*() const { return s->char32At(i); } - value_type - operator*() const - { - return s->char32At(i); - } + bool operator==(const UnicodeStringIterator &rhs) const { + return s == rhs.s && i == rhs.i; + } - bool - operator==(const UnicodeStringIterator& rhs) const - { - return s == rhs.s && i == rhs.i; - } + bool operator!=(const UnicodeStringIterator &rhs) const { + return !(*this == rhs); + } - bool - operator!=(const UnicodeStringIterator& rhs) const - { - return !(*this == rhs); - } + UnicodeStringIterator &operator++() { + ++i; + return *this; + } - UnicodeStringIterator& - operator++() - { - ++i; - return *this; - } + UnicodeStringIterator operator+(int32_t v) { + return UnicodeStringIterator(s, i + v); + } - UnicodeStringIterator - operator+(int32_t v) - { - return UnicodeStringIterator(s, i + v); - } +private: + const icu::UnicodeString *s; + int32_t i; +}; - private: - const icu::UnicodeString* s; - int32_t i; - }; +inline String &stringAppend(String &s, String a) { + return s.append(std::move(a)); +} - inline - String& - stringAppend(String&s, String a) - { - return s.append(std::move(a)); +inline String &stringAppend(String &s, int n, UChar32 c) { + for (int i = 0; i != n; ++i) { + s.append(c); } - inline - String& - stringAppend(String& s, int n, UChar32 c) - { - for (int i = 0; i != n; ++i) - { - s.append(c); - } + return s; +} - return s; +template +String &stringAppend(String &s, Iterator begin, Iterator end) { + while (begin != end) { + s.append(*begin); + ++begin; } - template - String& - stringAppend(String& s, Iterator begin, Iterator end) - { - while (begin != end) - { - s.append(*begin); - ++begin; - } + return s; +} - return s; - } +inline size_t stringLength(const String &s) { return s.length(); } - inline - size_t - stringLength(const String& s) - { - return s.length(); - } +inline std::string toUTF8String(const String &s) { + std::string result; + s.toUTF8String(result); - inline - std::string - toUTF8String(const String& s) - { - std::string result; - s.toUTF8String(result); + return result; +} - return result; - } +inline bool empty(const String &s) { return s.isEmpty(); } +} // namespace cxxopts - inline - bool - empty(const String& s) - { - return s.isEmpty(); - } +namespace std { +inline cxxopts::UnicodeStringIterator begin(const icu::UnicodeString &s) { + return cxxopts::UnicodeStringIterator(&s, 0); } -namespace std -{ - inline - cxxopts::UnicodeStringIterator - begin(const icu::UnicodeString& s) - { - return cxxopts::UnicodeStringIterator(&s, 0); - } - - inline - cxxopts::UnicodeStringIterator - end(const icu::UnicodeString& s) - { - return cxxopts::UnicodeStringIterator(&s, s.length()); - } +inline cxxopts::UnicodeStringIterator end(const icu::UnicodeString &s) { + return cxxopts::UnicodeStringIterator(&s, s.length()); } +} // namespace std -//ifdef CXXOPTS_USE_UNICODE +// ifdef CXXOPTS_USE_UNICODE #else -namespace cxxopts -{ - typedef std::string String; +namespace cxxopts { +typedef std::string String; - template - T - toLocalString(T&& t) - { - return std::forward(t); - } +template T toLocalString(T &&t) { return std::forward(t); } - inline - size_t - stringLength(const String& s) - { - return s.length(); - } - - inline - String& - stringAppend(String&s, String a) - { - return s.append(std::move(a)); - } +inline size_t stringLength(const String &s) { return s.length(); } - inline - String& - stringAppend(String& s, size_t n, char c) - { - return s.append(n, c); - } +inline String &stringAppend(String &s, String a) { + return s.append(std::move(a)); +} - template - String& - stringAppend(String& s, Iterator begin, Iterator end) - { - return s.append(begin, end); - } +inline String &stringAppend(String &s, size_t n, char c) { + return s.append(n, c); +} - template - std::string - toUTF8String(T&& t) - { - return std::forward(t); - } +template +String &stringAppend(String &s, Iterator begin, Iterator end) { + return s.append(begin, end); +} - inline - bool - empty(const std::string& s) - { - return s.empty(); - } +template std::string toUTF8String(T &&t) { + return std::forward(t); } -//ifdef CXXOPTS_USE_UNICODE +inline bool empty(const std::string &s) { return s.empty(); } +} // namespace cxxopts + +// ifdef CXXOPTS_USE_UNICODE #endif -namespace cxxopts -{ - namespace - { +namespace cxxopts { +namespace { #ifdef _WIN32 - const std::string LQUOTE("\'"); - const std::string RQUOTE("\'"); +const std::string LQUOTE("\'"); +const std::string RQUOTE("\'"); #else - const std::string LQUOTE("‘"); - const std::string RQUOTE("’"); +const std::string LQUOTE("‘"); +const std::string RQUOTE("’"); #endif - } +} // namespace - class Value : public std::enable_shared_from_this - { - public: +class Value : public std::enable_shared_from_this { +public: + virtual ~Value() = default; - virtual ~Value() = default; + virtual std::shared_ptr clone() const = 0; + + virtual void parse(const std::string &text) const = 0; - virtual - std::shared_ptr - clone() const = 0; - - virtual void - parse(const std::string& text) const = 0; - - virtual void - parse() const = 0; - - virtual bool - has_default() const = 0; - - virtual bool - is_container() const = 0; + virtual void parse() const = 0; + + virtual bool has_default() const = 0; + + virtual bool is_container() const = 0; + + virtual bool has_implicit() const = 0; + + virtual std::string get_default_value() const = 0; + + virtual std::string get_implicit_value() const = 0; + + virtual std::shared_ptr default_value(const std::string &value) = 0; + + virtual std::shared_ptr implicit_value(const std::string &value) = 0; + + virtual std::shared_ptr no_implicit_value() = 0; + + virtual bool is_boolean() const = 0; +}; + +class OptionException : public std::exception { +public: + OptionException(const std::string &message) : m_message(message) {} + + virtual const char *what() const noexcept { return m_message.c_str(); } + +private: + std::string m_message; +}; + +class OptionSpecException : public OptionException { +public: + OptionSpecException(const std::string &message) : OptionException(message) {} +}; + +class OptionParseException : public OptionException { +public: + OptionParseException(const std::string &message) : OptionException(message) {} +}; + +class option_exists_error : public OptionSpecException { +public: + option_exists_error(const std::string &option) + : OptionSpecException("Option " + LQUOTE + option + RQUOTE + + " already exists") {} +}; + +class invalid_option_format_error : public OptionSpecException { +public: + invalid_option_format_error(const std::string &format) + : OptionSpecException("Invalid option format " + LQUOTE + format + + RQUOTE) {} +}; + +class option_syntax_exception : public OptionParseException { +public: + option_syntax_exception(const std::string &text) + : OptionParseException("Argument " + LQUOTE + text + RQUOTE + + " starts with a - but has incorrect syntax") {} +}; + +class option_not_exists_exception : public OptionParseException { +public: + option_not_exists_exception(const std::string &option) + : OptionParseException("Option " + LQUOTE + option + RQUOTE + + " does not exist") {} +}; + +class missing_argument_exception : public OptionParseException { +public: + missing_argument_exception(const std::string &option) + : OptionParseException("Option " + LQUOTE + option + RQUOTE + + " is missing an argument") {} +}; + +class option_requires_argument_exception : public OptionParseException { +public: + option_requires_argument_exception(const std::string &option) + : OptionParseException("Option " + LQUOTE + option + RQUOTE + + " requires an argument") {} +}; + +class option_not_has_argument_exception : public OptionParseException { +public: + option_not_has_argument_exception(const std::string &option, + const std::string &arg) + : OptionParseException("Option " + LQUOTE + option + RQUOTE + + " does not take an argument, but argument " + + LQUOTE + arg + RQUOTE + " given") {} +}; + +class option_not_present_exception : public OptionParseException { +public: + option_not_present_exception(const std::string &option) + : OptionParseException("Option " + LQUOTE + option + RQUOTE + + " not present") {} +}; + +class argument_incorrect_type : public OptionParseException { +public: + argument_incorrect_type(const std::string &arg) + : OptionParseException("Argument " + LQUOTE + arg + RQUOTE + + " failed to parse") {} +}; + +class option_required_exception : public OptionParseException { +public: + option_required_exception(const std::string &option) + : OptionParseException("Option " + LQUOTE + option + RQUOTE + + " is required but not present") {} +}; + +namespace values { +namespace { +std::basic_regex integer_pattern("(-)?(0x)?([0-9a-zA-Z]+)|((0x)?0)"); +std::basic_regex truthy_pattern("(t|T)(rue)?|1"); +std::basic_regex falsy_pattern("(f|F)(alse)?|0"); +} // namespace + +namespace detail { +template struct SignedCheck; + +template struct SignedCheck { + template + void operator()(bool negative, U u, const std::string &text) { + if (negative) { + if (u > static_cast((std::numeric_limits::min)())) { + throw argument_incorrect_type(text); + } + } else { + if (u > static_cast((std::numeric_limits::max)())) { + throw argument_incorrect_type(text); + } + } + } +}; - virtual bool - has_implicit() const = 0; +template struct SignedCheck { + template void operator()(bool, U, const std::string &) {} +}; - virtual std::string - get_default_value() const = 0; +template +void check_signed_range(bool negative, U value, const std::string &text) { + SignedCheck::is_signed>()(negative, value, text); +} +} // namespace detail + +template +R checked_negate(T &&t, const std::string &, std::true_type) { + // if we got to here, then `t` is a positive number that fits into + // `R`. So to avoid MSVC C4146, we first cast it to `R`. + // See https://github.com/jarro2783/cxxopts/issues/62 for more details. + return -static_cast(t - 1) - 1; +} - virtual std::string - get_implicit_value() const = 0; +template +T checked_negate(T &&, const std::string &text, std::false_type) { + throw argument_incorrect_type(text); +} - virtual std::shared_ptr - default_value(const std::string& value) = 0; +template void integer_parser(const std::string &text, T &value) { + std::smatch match; + std::regex_match(text, match, integer_pattern); - virtual std::shared_ptr - implicit_value(const std::string& value) = 0; + if (match.length() == 0) { + throw argument_incorrect_type(text); + } - virtual std::shared_ptr - no_implicit_value() = 0; + if (match.length(4) > 0) { + value = 0; + return; + } - virtual bool - is_boolean() const = 0; - }; + using US = typename std::make_unsigned::type; - class OptionException : public std::exception - { - public: - OptionException(const std::string& message) - : m_message(message) - { - } + constexpr bool is_signed = std::numeric_limits::is_signed; + const bool negative = match.length(1) > 0; + const uint8_t base = match.length(2) > 0 ? 16 : 10; - virtual const char* - what() const noexcept - { - return m_message.c_str(); - } + auto value_match = match[3]; - private: - std::string m_message; - }; + US result = 0; - class OptionSpecException : public OptionException - { - public: + for (auto iter = value_match.first; iter != value_match.second; ++iter) { + US digit = 0; - OptionSpecException(const std::string& message) - : OptionException(message) - { - } - }; - - class OptionParseException : public OptionException - { - public: - OptionParseException(const std::string& message) - : OptionException(message) - { - } - }; - - class option_exists_error : public OptionSpecException - { - public: - option_exists_error(const std::string& option) - : OptionSpecException("Option " + LQUOTE + option + RQUOTE + " already exists") - { - } - }; - - class invalid_option_format_error : public OptionSpecException - { - public: - invalid_option_format_error(const std::string& format) - : OptionSpecException("Invalid option format " + LQUOTE + format + RQUOTE) - { - } - }; - - class option_syntax_exception : public OptionParseException { - public: - option_syntax_exception(const std::string& text) - : OptionParseException("Argument " + LQUOTE + text + RQUOTE + - " starts with a - but has incorrect syntax") - { - } - }; - - class option_not_exists_exception : public OptionParseException - { - public: - option_not_exists_exception(const std::string& option) - : OptionParseException("Option " + LQUOTE + option + RQUOTE + " does not exist") - { - } - }; - - class missing_argument_exception : public OptionParseException - { - public: - missing_argument_exception(const std::string& option) - : OptionParseException( - "Option " + LQUOTE + option + RQUOTE + " is missing an argument" - ) - { - } - }; - - class option_requires_argument_exception : public OptionParseException - { - public: - option_requires_argument_exception(const std::string& option) - : OptionParseException( - "Option " + LQUOTE + option + RQUOTE + " requires an argument" - ) - { - } - }; - - class option_not_has_argument_exception : public OptionParseException - { - public: - option_not_has_argument_exception - ( - const std::string& option, - const std::string& arg - ) - : OptionParseException( - "Option " + LQUOTE + option + RQUOTE + - " does not take an argument, but argument " + - LQUOTE + arg + RQUOTE + " given" - ) - { - } - }; - - class option_not_present_exception : public OptionParseException - { - public: - option_not_present_exception(const std::string& option) - : OptionParseException("Option " + LQUOTE + option + RQUOTE + " not present") - { - } - }; - - class argument_incorrect_type : public OptionParseException - { - public: - argument_incorrect_type - ( - const std::string& arg - ) - : OptionParseException( - "Argument " + LQUOTE + arg + RQUOTE + " failed to parse" - ) - { - } - }; - - class option_required_exception : public OptionParseException - { - public: - option_required_exception(const std::string& option) - : OptionParseException( - "Option " + LQUOTE + option + RQUOTE + " is required but not present" - ) - { - } - }; - - namespace values - { - namespace - { - std::basic_regex integer_pattern - ("(-)?(0x)?([0-9a-zA-Z]+)|((0x)?0)"); - std::basic_regex truthy_pattern - ("(t|T)(rue)?|1"); - std::basic_regex falsy_pattern - ("(f|F)(alse)?|0"); - } - - namespace detail - { - template - struct SignedCheck; - - template - struct SignedCheck - { - template - void - operator()(bool negative, U u, const std::string& text) - { - if (negative) - { - if (u > static_cast((std::numeric_limits::min)())) - { - throw argument_incorrect_type(text); - } - } - else - { - if (u > static_cast((std::numeric_limits::max)())) - { - throw argument_incorrect_type(text); - } - } - } - }; - - template - struct SignedCheck - { - template - void - operator()(bool, U, const std::string&) {} - }; - - template - void - check_signed_range(bool negative, U value, const std::string& text) - { - SignedCheck::is_signed>()(negative, value, text); - } - } - - template - R - checked_negate(T&& t, const std::string&, std::true_type) - { - // if we got to here, then `t` is a positive number that fits into - // `R`. So to avoid MSVC C4146, we first cast it to `R`. - // See https://github.com/jarro2783/cxxopts/issues/62 for more details. - return -static_cast(t-1)-1; + if (*iter >= '0' && *iter <= '9') { + digit = static_cast(*iter - '0'); + } else if (base == 16 && *iter >= 'a' && *iter <= 'f') { + digit = static_cast(*iter - 'a' + 10); + } else if (base == 16 && *iter >= 'A' && *iter <= 'F') { + digit = static_cast(*iter - 'A' + 10); + } else { + throw argument_incorrect_type(text); } - template - T - checked_negate(T&&, const std::string& text, std::false_type) - { + US next = result * base + digit; + if (result > next) { throw argument_incorrect_type(text); } - template - void - integer_parser(const std::string& text, T& value) - { - std::smatch match; - std::regex_match(text, match, integer_pattern); - - if (match.length() == 0) - { - throw argument_incorrect_type(text); - } - - if (match.length(4) > 0) - { - value = 0; - return; - } + result = next; + } - using US = typename std::make_unsigned::type; + detail::check_signed_range(negative, result, text); - constexpr bool is_signed = std::numeric_limits::is_signed; - const bool negative = match.length(1) > 0; - const uint8_t base = match.length(2) > 0 ? 16 : 10; + if (negative) { + value = checked_negate(result, text, + std::integral_constant()); + } else { + value = static_cast(result); + } +} - auto value_match = match[3]; +template +void stringstream_parser(const std::string &text, T &value) { + std::stringstream in(text); + in >> value; + if (!in) { + throw argument_incorrect_type(text); + } +} - US result = 0; +inline void parse_value(const std::string &text, uint8_t &value) { + integer_parser(text, value); +} - for (auto iter = value_match.first; iter != value_match.second; ++iter) - { - US digit = 0; +inline void parse_value(const std::string &text, int8_t &value) { + integer_parser(text, value); +} - if (*iter >= '0' && *iter <= '9') - { - digit = static_cast(*iter - '0'); - } - else if (base == 16 && *iter >= 'a' && *iter <= 'f') - { - digit = static_cast(*iter - 'a' + 10); - } - else if (base == 16 && *iter >= 'A' && *iter <= 'F') - { - digit = static_cast(*iter - 'A' + 10); - } - else - { - throw argument_incorrect_type(text); - } +inline void parse_value(const std::string &text, uint16_t &value) { + integer_parser(text, value); +} - US next = result * base + digit; - if (result > next) - { - throw argument_incorrect_type(text); - } +inline void parse_value(const std::string &text, int16_t &value) { + integer_parser(text, value); +} - result = next; - } +inline void parse_value(const std::string &text, uint32_t &value) { + integer_parser(text, value); +} - detail::check_signed_range(negative, result, text); +inline void parse_value(const std::string &text, int32_t &value) { + integer_parser(text, value); +} - if (negative) - { - value = checked_negate(result, - text, - std::integral_constant()); - } - else - { - value = static_cast(result); - } - } +inline void parse_value(const std::string &text, uint64_t &value) { + integer_parser(text, value); +} - template - void stringstream_parser(const std::string& text, T& value) - { - std::stringstream in(text); - in >> value; - if (!in) { - throw argument_incorrect_type(text); - } - } +inline void parse_value(const std::string &text, int64_t &value) { + integer_parser(text, value); +} - inline - void - parse_value(const std::string& text, uint8_t& value) - { - integer_parser(text, value); - } +inline void parse_value(const std::string &text, bool &value) { + std::smatch result; + std::regex_match(text, result, truthy_pattern); - inline - void - parse_value(const std::string& text, int8_t& value) - { - integer_parser(text, value); - } + if (!result.empty()) { + value = true; + return; + } - inline - void - parse_value(const std::string& text, uint16_t& value) - { - integer_parser(text, value); - } + std::regex_match(text, result, falsy_pattern); + if (!result.empty()) { + value = false; + return; + } - inline - void - parse_value(const std::string& text, int16_t& value) - { - integer_parser(text, value); - } + throw argument_incorrect_type(text); +} - inline - void - parse_value(const std::string& text, uint32_t& value) - { - integer_parser(text, value); - } +inline void parse_value(const std::string &text, std::string &value) { + value = text; +} - inline - void - parse_value(const std::string& text, int32_t& value) - { - integer_parser(text, value); - } +// The fallback parser. It uses the stringstream parser to parse all types +// that have not been overloaded explicitly. It has to be placed in the +// source code before all other more specialized templates. +template void parse_value(const std::string &text, T &value) { + stringstream_parser(text, value); +} - inline - void - parse_value(const std::string& text, uint64_t& value) - { - integer_parser(text, value); - } +template +void parse_value(const std::string &text, std::vector &value) { + std::stringstream in(text); + std::string token; + while (in.eof() == false && + std::getline(in, token, CXXOPTS_VECTOR_DELIMITER)) { + T v; + parse_value(token, v); + value.emplace_back(std::move(v)); + } +} - inline - void - parse_value(const std::string& text, int64_t& value) - { - integer_parser(text, value); - } +#ifdef CXXOPTS_HAS_OPTIONAL +template +void parse_value(const std::string &text, std::optional &value) { + T result; + parse_value(text, result); + value = std::move(result); +} +#endif - inline - void - parse_value(const std::string& text, bool& value) - { - std::smatch result; - std::regex_match(text, result, truthy_pattern); - - if (!result.empty()) - { - value = true; - return; - } +template struct type_is_container { + static constexpr bool value = false; +}; - std::regex_match(text, result, falsy_pattern); - if (!result.empty()) - { - value = false; - return; - } +template struct type_is_container> { + static constexpr bool value = true; +}; - throw argument_incorrect_type(text); - } +template class abstract_value : public Value { + using Self = abstract_value; - inline - void - parse_value(const std::string& text, std::string& value) - { - value = text; - } +public: + abstract_value() : m_result(std::make_shared()), m_store(m_result.get()) {} - // The fallback parser. It uses the stringstream parser to parse all types - // that have not been overloaded explicitly. It has to be placed in the - // source code before all other more specialized templates. - template - void - parse_value(const std::string& text, T& value) { - stringstream_parser(text, value); - } + abstract_value(T *t) : m_store(t) {} - template - void - parse_value(const std::string& text, std::vector& value) - { - std::stringstream in(text); - std::string token; - while(in.eof() == false && std::getline(in, token, CXXOPTS_VECTOR_DELIMITER)) { - T v; - parse_value(token, v); - value.emplace_back(std::move(v)); - } - } + virtual ~abstract_value() = default; -#ifdef CXXOPTS_HAS_OPTIONAL - template - void - parse_value(const std::string& text, std::optional& value) - { - T result; - parse_value(text, result); - value = std::move(result); + abstract_value(const abstract_value &rhs) { + if (rhs.m_result) { + m_result = std::make_shared(); + m_store = m_result.get(); + } else { + m_store = rhs.m_store; } -#endif - template - struct type_is_container - { - static constexpr bool value = false; - }; - - template - struct type_is_container> - { - static constexpr bool value = true; - }; - - template - class abstract_value : public Value - { - using Self = abstract_value; - - public: - abstract_value() - : m_result(std::make_shared()) - , m_store(m_result.get()) - { - } + m_default = rhs.m_default; + m_implicit = rhs.m_implicit; + m_default_value = rhs.m_default_value; + m_implicit_value = rhs.m_implicit_value; + } - abstract_value(T* t) - : m_store(t) - { - } + void parse(const std::string &text) const { parse_value(text, *m_store); } - virtual ~abstract_value() = default; + bool is_container() const { return type_is_container::value; } - abstract_value(const abstract_value& rhs) - { - if (rhs.m_result) - { - m_result = std::make_shared(); - m_store = m_result.get(); - } - else - { - m_store = rhs.m_store; - } + void parse() const { parse_value(m_default_value, *m_store); } - m_default = rhs.m_default; - m_implicit = rhs.m_implicit; - m_default_value = rhs.m_default_value; - m_implicit_value = rhs.m_implicit_value; - } - - void - parse(const std::string& text) const - { - parse_value(text, *m_store); - } + bool has_default() const { return m_default; } - bool - is_container() const - { - return type_is_container::value; - } + bool has_implicit() const { return m_implicit; } - void - parse() const - { - parse_value(m_default_value, *m_store); - } + std::shared_ptr default_value(const std::string &value) { + m_default = true; + m_default_value = value; + return shared_from_this(); + } - bool - has_default() const - { - return m_default; - } + std::shared_ptr implicit_value(const std::string &value) { + m_implicit = true; + m_implicit_value = value; + return shared_from_this(); + } - bool - has_implicit() const - { - return m_implicit; - } + std::shared_ptr no_implicit_value() { + m_implicit = false; + return shared_from_this(); + } - std::shared_ptr - default_value(const std::string& value) - { - m_default = true; - m_default_value = value; - return shared_from_this(); - } + std::string get_default_value() const { return m_default_value; } - std::shared_ptr - implicit_value(const std::string& value) - { - m_implicit = true; - m_implicit_value = value; - return shared_from_this(); - } + std::string get_implicit_value() const { return m_implicit_value; } - std::shared_ptr - no_implicit_value() - { - m_implicit = false; - return shared_from_this(); - } + bool is_boolean() const { return std::is_same::value; } - std::string - get_default_value() const - { - return m_default_value; - } + const T &get() const { + if (m_store == nullptr) { + return *m_result; + } else { + return *m_store; + } + } - std::string - get_implicit_value() const - { - return m_implicit_value; - } +protected: + std::shared_ptr m_result; + T *m_store; - bool - is_boolean() const - { - return std::is_same::value; - } + bool m_default = false; + bool m_implicit = false; - const T& - get() const - { - if (m_store == nullptr) - { - return *m_result; - } - else - { - return *m_store; - } - } + std::string m_default_value; + std::string m_implicit_value; +}; - protected: - std::shared_ptr m_result; - T* m_store; +template class standard_value : public abstract_value { +public: + using abstract_value::abstract_value; - bool m_default = false; - bool m_implicit = false; + std::shared_ptr clone() const { + return std::make_shared>(*this); + } +}; - std::string m_default_value; - std::string m_implicit_value; - }; +template <> class standard_value : public abstract_value { +public: + ~standard_value() = default; - template - class standard_value : public abstract_value - { - public: - using abstract_value::abstract_value; + standard_value() { set_default_and_implicit(); } - std::shared_ptr - clone() const - { - return std::make_shared>(*this); - } - }; + standard_value(bool *b) : abstract_value(b) { set_default_and_implicit(); } - template <> - class standard_value : public abstract_value - { - public: - ~standard_value() = default; + std::shared_ptr clone() const { + return std::make_shared>(*this); + } - standard_value() - { - set_default_and_implicit(); - } +private: + void set_default_and_implicit() { + m_default = true; + m_default_value = "false"; + m_implicit = true; + m_implicit_value = "true"; + } +}; +} // namespace values - standard_value(bool* b) - : abstract_value(b) - { - set_default_and_implicit(); - } +template std::shared_ptr value() { + return std::make_shared>(); +} - std::shared_ptr - clone() const - { - return std::make_shared>(*this); - } +template std::shared_ptr value(T &t) { + return std::make_shared>(&t); +} - private: +class OptionAdder; - void - set_default_and_implicit() - { - m_default = true; - m_default_value = "false"; - m_implicit = true; - m_implicit_value = "true"; - } - }; +class OptionDetails { +public: + OptionDetails(const std::string &short_, const std::string &long_, + const String &desc, std::shared_ptr val) + : m_short(short_), m_long(long_), m_desc(desc), m_value(val), m_count(0) { } - template - std::shared_ptr - value() - { - return std::make_shared>(); + OptionDetails(const OptionDetails &rhs) + : m_desc(rhs.m_desc), m_count(rhs.m_count) { + m_value = rhs.m_value->clone(); } - template - std::shared_ptr - value(T& t) - { - return std::make_shared>(&t); + OptionDetails(OptionDetails &&rhs) = default; + + const String &description() const { return m_desc; } + + const Value &value() const { return *m_value; } + + std::shared_ptr make_storage() const { return m_value->clone(); } + + const std::string &short_name() const { return m_short; } + + const std::string &long_name() const { return m_long; } + +private: + std::string m_short; + std::string m_long; + String m_desc; + std::shared_ptr m_value; + int m_count; +}; + +struct HelpOptionDetails { + std::string s; + std::string l; + String desc; + bool has_default; + std::string default_value; + bool has_implicit; + std::string implicit_value; + std::string arg_help; + bool is_container; + bool is_boolean; +}; + +struct HelpGroupDetails { + std::string name; + std::string description; + std::vector options; +}; + +class OptionValue { +public: + void parse(std::shared_ptr details, + const std::string &text) { + ensure_value(details); + ++m_count; + m_value->parse(text); } - class OptionAdder; - - class OptionDetails - { - public: - OptionDetails - ( - const std::string& short_, - const std::string& long_, - const String& desc, - std::shared_ptr val - ) - : m_short(short_) - , m_long(long_) - , m_desc(desc) - , m_value(val) - , m_count(0) - { - } - - OptionDetails(const OptionDetails& rhs) - : m_desc(rhs.m_desc) - , m_count(rhs.m_count) - { - m_value = rhs.m_value->clone(); - } + void parse_default(std::shared_ptr details) { + ensure_value(details); + m_default = true; + m_value->parse(); + } - OptionDetails(OptionDetails&& rhs) = default; + size_t count() const noexcept { return m_count; } - const String& - description() const - { - return m_desc; - } + // TODO: maybe default options should count towards the number of arguments + bool has_default() const noexcept { return m_default; } - const Value& value() const { - return *m_value; + template const T &as() const { + if (m_value == nullptr) { + throw std::domain_error("No value"); } - std::shared_ptr - make_storage() const - { - return m_value->clone(); - } +#ifdef CXXOPTS_NO_RTTI + return static_cast &>(*m_value).get(); +#else + return dynamic_cast &>(*m_value).get(); +#endif + } - const std::string& - short_name() const - { - return m_short; +private: + void ensure_value(std::shared_ptr details) { + if (m_value == nullptr) { + m_value = details->make_storage(); } + } - const std::string& - long_name() const - { - return m_long; - } + std::shared_ptr m_value; + size_t m_count = 0; + bool m_default = false; +}; - private: - std::string m_short; - std::string m_long; - String m_desc; - std::shared_ptr m_value; - int m_count; - }; - - struct HelpOptionDetails - { - std::string s; - std::string l; - String desc; - bool has_default; - std::string default_value; - bool has_implicit; - std::string implicit_value; - std::string arg_help; - bool is_container; - bool is_boolean; - }; - - struct HelpGroupDetails - { - std::string name; - std::string description; - std::vector options; - }; - - class OptionValue - { - public: - void - parse - ( - std::shared_ptr details, - const std::string& text - ) - { - ensure_value(details); - ++m_count; - m_value->parse(text); - } +class KeyValue { +public: + KeyValue(std::string key_, std::string value_) + : m_key(std::move(key_)), m_value(std::move(value_)) {} - void - parse_default(std::shared_ptr details) - { - ensure_value(details); - m_default = true; - m_value->parse(); - } + const std::string &key() const { return m_key; } - size_t - count() const noexcept - { - return m_count; - } + const std::string &value() const { return m_value; } - // TODO: maybe default options should count towards the number of arguments - bool - has_default() const noexcept - { - return m_default; - } + template T as() const { + T result; + values::parse_value(m_value, result); + return result; + } - template - const T& - as() const - { - if (m_value == nullptr) { - throw std::domain_error("No value"); - } +private: + std::string m_key; + std::string m_value; +}; -#ifdef CXXOPTS_NO_RTTI - return static_cast&>(*m_value).get(); -#else - return dynamic_cast&>(*m_value).get(); -#endif - } +class ParseResult { +public: + ParseResult( + const std::shared_ptr< + std::unordered_map>>, + std::vector, bool allow_unrecognised, int &, char **&); - private: - void - ensure_value(std::shared_ptr details) - { - if (m_value == nullptr) - { - m_value = details->make_storage(); - } + size_t count(const std::string &o) const { + auto iter = m_options->find(o); + if (iter == m_options->end()) { + return 0; } - std::shared_ptr m_value; - size_t m_count = 0; - bool m_default = false; - }; - - class KeyValue - { - public: - KeyValue(std::string key_, std::string value_) - : m_key(std::move(key_)) - , m_value(std::move(value_)) - { - } + auto riter = m_results.find(iter->second); - const - std::string& - key() const - { - return m_key; - } + return riter->second.count(); + } - const - std::string& - value() const - { - return m_value; - } + const OptionValue &operator[](const std::string &option) const { + auto iter = m_options->find(option); - template - T - as() const - { - T result; - values::parse_value(m_value, result); - return result; + if (iter == m_options->end()) { + throw option_not_present_exception(option); } - private: - std::string m_key; - std::string m_value; - }; + auto riter = m_results.find(iter->second); - class ParseResult - { - public: + return riter->second; + } - ParseResult( - const std::shared_ptr< - std::unordered_map> - >, - std::vector, - bool allow_unrecognised, - int&, char**&); - - size_t - count(const std::string& o) const - { - auto iter = m_options->find(o); - if (iter == m_options->end()) - { - return 0; - } + const std::vector &arguments() const { return m_sequential; } - auto riter = m_results.find(iter->second); +private: + void parse(int &argc, char **&argv); - return riter->second.count(); - } + void add_to_option(const std::string &option, const std::string &arg); - const OptionValue& - operator[](const std::string& option) const - { - auto iter = m_options->find(option); + bool consume_positional(std::string a); - if (iter == m_options->end()) - { - throw option_not_present_exception(option); - } + void parse_option(std::shared_ptr value, + const std::string &name, const std::string &arg = ""); - auto riter = m_results.find(iter->second); + void parse_default(std::shared_ptr details); - return riter->second; - } + void checked_parse_arg(int argc, char *argv[], int ¤t, + std::shared_ptr value, + const std::string &name); - const std::vector& - arguments() const - { - return m_sequential; - } + const std::shared_ptr< + std::unordered_map>> + m_options; + std::vector m_positional; + std::vector::iterator m_next_positional; + std::unordered_set m_positional_set; + std::unordered_map, OptionValue> m_results; - private: + bool m_allow_unrecognised; - void - parse(int& argc, char**& argv); + std::vector m_sequential; +}; - void - add_to_option(const std::string& option, const std::string& arg); +class Options { + typedef std::unordered_map> + OptionMap; - bool - consume_positional(std::string a); +public: + Options(std::string program, std::string help_string = "") + : m_program(std::move(program)), + m_help_string(toLocalString(std::move(help_string))), + m_custom_help("[OPTION...]"), + m_positional_help("positional parameters"), m_show_positional(false), + m_allow_unrecognised(false), m_options(std::make_shared()), + m_next_positional(m_positional.end()) {} + + Options &positional_help(std::string help_text) { + m_positional_help = std::move(help_text); + return *this; + } - void - parse_option - ( - std::shared_ptr value, - const std::string& name, - const std::string& arg = "" - ); + Options &custom_help(std::string help_text) { + m_custom_help = std::move(help_text); + return *this; + } - void - parse_default(std::shared_ptr details); + Options &show_positional_help() { + m_show_positional = true; + return *this; + } - void - checked_parse_arg - ( - int argc, - char* argv[], - int& current, - std::shared_ptr value, - const std::string& name - ); + Options &allow_unrecognised_options() { + m_allow_unrecognised = true; + return *this; + } - const std::shared_ptr< - std::unordered_map> - > m_options; - std::vector m_positional; - std::vector::iterator m_next_positional; - std::unordered_set m_positional_set; - std::unordered_map, OptionValue> m_results; + ParseResult parse(int &argc, char **&argv); - bool m_allow_unrecognised; + OptionAdder add_options(std::string group = ""); - std::vector m_sequential; - }; + void add_option(const std::string &group, const std::string &s, + const std::string &l, std::string desc, + std::shared_ptr value, std::string arg_help); - class Options - { - typedef std::unordered_map> - OptionMap; - public: - - Options(std::string program, std::string help_string = "") - : m_program(std::move(program)) - , m_help_string(toLocalString(std::move(help_string))) - , m_custom_help("[OPTION...]") - , m_positional_help("positional parameters") - , m_show_positional(false) - , m_allow_unrecognised(false) - , m_options(std::make_shared()) - , m_next_positional(m_positional.end()) - { - } + // parse positional arguments into the given option + void parse_positional(std::string option); - Options& - positional_help(std::string help_text) - { - m_positional_help = std::move(help_text); - return *this; - } + void parse_positional(std::vector options); - Options& - custom_help(std::string help_text) - { - m_custom_help = std::move(help_text); - return *this; - } + void parse_positional(std::initializer_list options); - Options& - show_positional_help() - { - m_show_positional = true; - return *this; - } + template + void parse_positional(Iterator begin, Iterator end) { + parse_positional(std::vector{begin, end}); + } - Options& - allow_unrecognised_options() - { - m_allow_unrecognised = true; - return *this; - } + std::string help(const std::vector &groups = {}) const; - ParseResult - parse(int& argc, char**& argv); - - OptionAdder - add_options(std::string group = ""); - - void - add_option - ( - const std::string& group, - const std::string& s, - const std::string& l, - std::string desc, - std::shared_ptr value, - std::string arg_help - ); - - //parse positional arguments into the given option - void - parse_positional(std::string option); - - void - parse_positional(std::vector options); - - void - parse_positional(std::initializer_list options); - - template - void - parse_positional(Iterator begin, Iterator end) { - parse_positional(std::vector{begin, end}); - } + const std::vector groups() const; - std::string - help(const std::vector& groups = {}) const; + const HelpGroupDetails &group_help(const std::string &group) const; - const std::vector - groups() const; +private: + void add_one_option(const std::string &option, + std::shared_ptr details); - const HelpGroupDetails& - group_help(const std::string& group) const; + String help_one_group(const std::string &group) const; - private: + void generate_group_help(String &result, + const std::vector &groups) const; - void - add_one_option - ( - const std::string& option, - std::shared_ptr details - ); + void generate_all_groups_help(String &result) const; - String - help_one_group(const std::string& group) const; + std::string m_program; + String m_help_string; + std::string m_custom_help; + std::string m_positional_help; + bool m_show_positional; + bool m_allow_unrecognised; - void - generate_group_help - ( - String& result, - const std::vector& groups - ) const; + std::shared_ptr m_options; + std::vector m_positional; + std::vector::iterator m_next_positional; + std::unordered_set m_positional_set; - void - generate_all_groups_help(String& result) const; + // mapping from groups to help options + std::map m_help; +}; - std::string m_program; - String m_help_string; - std::string m_custom_help; - std::string m_positional_help; - bool m_show_positional; - bool m_allow_unrecognised; +class OptionAdder { +public: + OptionAdder(Options &options, std::string group) + : m_options(options), m_group(std::move(group)) {} - std::shared_ptr m_options; - std::vector m_positional; - std::vector::iterator m_next_positional; - std::unordered_set m_positional_set; + OptionAdder & + operator()(const std::string &opts, const std::string &desc, + std::shared_ptr value = ::cxxopts::value(), + std::string arg_help = ""); - //mapping from groups to help options - std::map m_help; - }; +private: + Options &m_options; + std::string m_group; +}; - class OptionAdder - { - public: +namespace { +constexpr int OPTION_LONGEST = 30; +constexpr int OPTION_DESC_GAP = 2; - OptionAdder(Options& options, std::string group) - : m_options(options), m_group(std::move(group)) - { - } +std::basic_regex + option_matcher("--([[:alnum:]][-_[:alnum:]]+)(=(.*))?|-([[:alnum:]]+)"); - OptionAdder& - operator() - ( - const std::string& opts, - const std::string& desc, - std::shared_ptr value - = ::cxxopts::value(), - std::string arg_help = "" - ); - - private: - Options& m_options; - std::string m_group; - }; - - namespace - { - constexpr int OPTION_LONGEST = 30; - constexpr int OPTION_DESC_GAP = 2; - - std::basic_regex option_matcher - ("--([[:alnum:]][-_[:alnum:]]+)(=(.*))?|-([[:alnum:]]+)"); - - std::basic_regex option_specifier - ("(([[:alnum:]]),)?[ ]*([[:alnum:]][-_[:alnum:]]*)?"); - - String - format_option - ( - const HelpOptionDetails& o - ) - { - auto& s = o.s; - auto& l = o.l; - - String result = " "; - - if (s.size() > 0) - { - result += "-" + toLocalString(s) + ","; - } - else - { - result += " "; - } +std::basic_regex + option_specifier("(([[:alnum:]]),)?[ ]*([[:alnum:]][-_[:alnum:]]*)?"); - if (l.size() > 0) - { - result += " --" + toLocalString(l); - } +String format_option(const HelpOptionDetails &o) { + auto &s = o.s; + auto &l = o.l; - auto arg = o.arg_help.size() > 0 ? toLocalString(o.arg_help) : "arg"; + String result = " "; - if (!o.is_boolean) - { - if (o.has_implicit) - { - result += " [=" + arg + "(=" + toLocalString(o.implicit_value) + ")]"; - } - else - { - result += " " + arg; - } - } + if (s.size() > 0) { + result += "-" + toLocalString(s) + ","; + } else { + result += " "; + } - return result; - } + if (l.size() > 0) { + result += " --" + toLocalString(l); + } - String - format_description - ( - const HelpOptionDetails& o, - size_t start, - size_t width - ) - { - auto desc = o.desc; - - if (o.has_default && (!o.is_boolean || o.default_value != "false")) - { - desc += toLocalString(" (default: " + o.default_value + ")"); - } + auto arg = o.arg_help.size() > 0 ? toLocalString(o.arg_help) : "arg"; - String result; + if (!o.is_boolean) { + if (o.has_implicit) { + result += " [=" + arg + "(=" + toLocalString(o.implicit_value) + ")]"; + } else { + result += " " + arg; + } + } - auto current = std::begin(desc); - auto startLine = current; - auto lastSpace = current; + return result; +} - auto size = size_t{}; +String format_description(const HelpOptionDetails &o, size_t start, + size_t width) { + auto desc = o.desc; - while (current != std::end(desc)) - { - if (*current == ' ') - { - lastSpace = current; - } + if (o.has_default && (!o.is_boolean || o.default_value != "false")) { + desc += toLocalString(" (default: " + o.default_value + ")"); + } - if (*current == '\n') - { - startLine = current + 1; - lastSpace = startLine; - } - else if (size > width) - { - if (lastSpace == startLine) - { - stringAppend(result, startLine, current + 1); - stringAppend(result, "\n"); - stringAppend(result, start, ' '); - startLine = current + 1; - lastSpace = startLine; - } - else - { - stringAppend(result, startLine, lastSpace); - stringAppend(result, "\n"); - stringAppend(result, start, ' '); - startLine = lastSpace + 1; - lastSpace = startLine; - } - size = 0; - } - else - { - ++size; - } + String result; - ++current; + auto current = std::begin(desc); + auto startLine = current; + auto lastSpace = current; + + auto size = size_t{}; + + while (current != std::end(desc)) { + if (*current == ' ') { + lastSpace = current; + } + + if (*current == '\n') { + startLine = current + 1; + lastSpace = startLine; + } else if (size > width) { + if (lastSpace == startLine) { + stringAppend(result, startLine, current + 1); + stringAppend(result, "\n"); + stringAppend(result, start, ' '); + startLine = current + 1; + lastSpace = startLine; + } else { + stringAppend(result, startLine, lastSpace); + stringAppend(result, "\n"); + stringAppend(result, start, ' '); + startLine = lastSpace + 1; + lastSpace = startLine; } - - //append whatever is left - stringAppend(result, startLine, current); - - return result; + size = 0; + } else { + ++size; } + + ++current; } -inline -ParseResult::ParseResult -( - const std::shared_ptr< - std::unordered_map> - > options, - std::vector positional, - bool allow_unrecognised, - int& argc, char**& argv -) -: m_options(options) -, m_positional(std::move(positional)) -, m_next_positional(m_positional.begin()) -, m_allow_unrecognised(allow_unrecognised) -{ + // append whatever is left + stringAppend(result, startLine, current); + + return result; +} +} // namespace + +inline ParseResult::ParseResult( + const std::shared_ptr< + std::unordered_map>> + options, + std::vector positional, bool allow_unrecognised, int &argc, + char **&argv) + : m_options(options), m_positional(std::move(positional)), + m_next_positional(m_positional.begin()), + m_allow_unrecognised(allow_unrecognised) { parse(argc, argv); } -inline -OptionAdder -Options::add_options(std::string group) -{ +inline OptionAdder Options::add_options(std::string group) { return OptionAdder(*this, std::move(group)); } -inline -OptionAdder& -OptionAdder::operator() -( - const std::string& opts, - const std::string& desc, - std::shared_ptr value, - std::string arg_help -) -{ - std::match_results result; +inline OptionAdder &OptionAdder::operator()(const std::string &opts, + const std::string &desc, + std::shared_ptr value, + std::string arg_help) { + std::match_results result; std::regex_match(opts.c_str(), result, option_specifier); - if (result.empty()) - { + if (result.empty()) { throw invalid_option_format_error(opts); } - const auto& short_match = result[2]; - const auto& long_match = result[3]; + const auto &short_match = result[2]; + const auto &long_match = result[3]; - if (!short_match.length() && !long_match.length()) - { + if (!short_match.length() && !long_match.length()) { throw invalid_option_format_error(opts); - } else if (long_match.length() == 1 && short_match.length()) - { + } else if (long_match.length() == 1 && short_match.length()) { throw invalid_option_format_error(opts); } - auto option_names = [] - ( - const std::sub_match& short_, - const std::sub_match& long_ - ) - { - if (long_.length() == 1) - { + auto option_names = [](const std::sub_match &short_, + const std::sub_match &long_) { + if (long_.length() == 1) { return std::make_tuple(long_.str(), short_.str()); - } - else - { + } else { return std::make_tuple(short_.str(), long_.str()); } }(short_match, long_match); - m_options.add_option - ( - m_group, - std::get<0>(option_names), - std::get<1>(option_names), - desc, - value, - std::move(arg_help) - ); + m_options.add_option(m_group, std::get<0>(option_names), + std::get<1>(option_names), desc, value, + std::move(arg_help)); return *this; } -inline -void -ParseResult::parse_default(std::shared_ptr details) -{ +inline void ParseResult::parse_default(std::shared_ptr details) { m_results[details].parse_default(details); } -inline -void -ParseResult::parse_option -( - std::shared_ptr value, - const std::string& /*name*/, - const std::string& arg -) -{ - auto& result = m_results[value]; +inline void ParseResult::parse_option(std::shared_ptr value, + const std::string & /*name*/, + const std::string &arg) { + auto &result = m_results[value]; result.parse(value, arg); m_sequential.emplace_back(value->long_name(), arg); } -inline -void -ParseResult::checked_parse_arg -( - int argc, - char* argv[], - int& current, - std::shared_ptr value, - const std::string& name -) -{ - if (current + 1 >= argc) - { - if (value->value().has_implicit()) - { +inline void ParseResult::checked_parse_arg(int argc, char *argv[], int ¤t, + std::shared_ptr value, + const std::string &name) { + if (current + 1 >= argc) { + if (value->value().has_implicit()) { parse_option(value, name, value->value().get_implicit_value()); - } - else - { + } else { throw missing_argument_exception(name); } - } - else - { - if (value->value().has_implicit()) - { + } else { + if (value->value().has_implicit()) { parse_option(value, name, value->value().get_implicit_value()); - } - else - { + } else { parse_option(value, name, argv[current + 1]); ++current; } } } -inline -void -ParseResult::add_to_option(const std::string& option, const std::string& arg) -{ +inline void ParseResult::add_to_option(const std::string &option, + const std::string &arg) { auto iter = m_options->find(option); - if (iter == m_options->end()) - { + if (iter == m_options->end()) { throw option_not_exists_exception(option); } parse_option(iter->second, option, arg); } -inline -bool -ParseResult::consume_positional(std::string a) -{ - while (m_next_positional != m_positional.end()) - { +inline bool ParseResult::consume_positional(std::string a) { + while (m_next_positional != m_positional.end()) { auto iter = m_options->find(*m_next_positional); - if (iter != m_options->end()) - { - auto& result = m_results[iter->second]; - if (!iter->second->value().is_container()) - { - if (result.count() == 0) - { + if (iter != m_options->end()) { + auto &result = m_results[iter->second]; + if (!iter->second->value().is_container()) { + if (result.count() == 0) { add_to_option(*m_next_positional, a); ++m_next_positional; return true; - } - else - { + } else { ++m_next_positional; continue; } - } - else - { + } else { add_to_option(*m_next_positional, a); return true; } - } - else - { + } else { throw option_not_exists_exception(*m_next_positional); } } @@ -1697,63 +1122,46 @@ ParseResult::consume_positional(std::string a) return false; } -inline -void -Options::parse_positional(std::string option) -{ +inline void Options::parse_positional(std::string option) { parse_positional(std::vector{std::move(option)}); } -inline -void -Options::parse_positional(std::vector options) -{ +inline void Options::parse_positional(std::vector options) { m_positional = std::move(options); m_next_positional = m_positional.begin(); m_positional_set.insert(m_positional.begin(), m_positional.end()); } -inline -void -Options::parse_positional(std::initializer_list options) -{ +inline void +Options::parse_positional(std::initializer_list options) { parse_positional(std::vector(std::move(options))); } -inline -ParseResult -Options::parse(int& argc, char**& argv) -{ +inline ParseResult Options::parse(int &argc, char **&argv) { ParseResult result(m_options, m_positional, m_allow_unrecognised, argc, argv); return result; } -inline -void -ParseResult::parse(int& argc, char**& argv) -{ +inline void ParseResult::parse(int &argc, char **&argv) { int current = 1; int nextKeep = 1; bool consume_remaining = false; - while (current != argc) - { - if (strcmp(argv[current], "--") == 0) - { + while (current != argc) { + if (strcmp(argv[current], "--") == 0) { consume_remaining = true; ++current; break; } - std::match_results result; + std::match_results result; std::regex_match(argv[current], result, option_matcher); - if (result.empty()) - { - //not a flag + if (result.empty()) { + // not a flag // but if it starts with a `-`, then it's an error if (argv[current][0] == '-' && argv[current][1] != '\0') { @@ -1762,128 +1170,99 @@ ParseResult::parse(int& argc, char**& argv) } } - //if true is returned here then it was consumed, otherwise it is - //ignored - if (consume_positional(argv[current])) - { - } - else - { + // if true is returned here then it was consumed, otherwise it is + // ignored + if (consume_positional(argv[current])) { + } else { argv[nextKeep] = argv[current]; ++nextKeep; } - //if we return from here then it was parsed successfully, so continue - } - else - { - //short or long option? - if (result[4].length() != 0) - { - const std::string& s = result[4]; - - for (std::size_t i = 0; i != s.size(); ++i) - { + // if we return from here then it was parsed successfully, so continue + } else { + // short or long option? + if (result[4].length() != 0) { + const std::string &s = result[4]; + + for (std::size_t i = 0; i != s.size(); ++i) { std::string name(1, s[i]); auto iter = m_options->find(name); - if (iter == m_options->end()) - { - if (m_allow_unrecognised) - { + if (iter == m_options->end()) { + if (m_allow_unrecognised) { continue; - } - else - { - //error + } else { + // error throw option_not_exists_exception(name); } } auto value = iter->second; - if (i + 1 == s.size()) - { - //it must be the last argument + if (i + 1 == s.size()) { + // it must be the last argument checked_parse_arg(argc, argv, current, value, name); - } - else if (value->value().has_implicit()) - { + } else if (value->value().has_implicit()) { parse_option(value, name, value->value().get_implicit_value()); - } - else - { - //error + } else { + // error throw option_requires_argument_exception(name); } } - } - else if (result[1].length() != 0) - { - const std::string& name = result[1]; + } else if (result[1].length() != 0) { + const std::string &name = result[1]; auto iter = m_options->find(name); - if (iter == m_options->end()) - { - if (m_allow_unrecognised) - { + if (iter == m_options->end()) { + if (m_allow_unrecognised) { // keep unrecognised options in argument list, skip to next argument argv[nextKeep] = argv[current]; ++nextKeep; ++current; continue; - } - else - { - //error + } else { + // error throw option_not_exists_exception(name); } } auto opt = iter->second; - //equals provided for long option? - if (result[2].length() != 0) - { - //parse the option given + // equals provided for long option? + if (result[2].length() != 0) { + // parse the option given parse_option(opt, name, result[3]); - } - else - { - //parse the next argument + } else { + // parse the next argument checked_parse_arg(argc, argv, current, opt, name); } } - } ++current; } - for (auto& opt : *m_options) - { - auto& detail = opt.second; - auto& value = detail->value(); + for (auto &opt : *m_options) { + auto &detail = opt.second; + auto &value = detail->value(); - auto& store = m_results[detail]; + auto &store = m_results[detail]; - if(value.has_default() && !store.count() && !store.has_default()){ + if (value.has_default() && !store.count() && !store.has_default()) { parse_default(detail); } } - if (consume_remaining) - { - while (current < argc) - { + if (consume_remaining) { + while (current < argc) { if (!consume_positional(argv[current])) { break; } ++current; } - //adjust argv for any that couldn't be swallowed + // adjust argv for any that couldn't be swallowed while (current != argc) { argv[nextKeep] = argv[current]; ++nextKeep; @@ -1892,70 +1271,46 @@ ParseResult::parse(int& argc, char**& argv) } argc = nextKeep; - } -inline -void -Options::add_option -( - const std::string& group, - const std::string& s, - const std::string& l, - std::string desc, - std::shared_ptr value, - std::string arg_help -) -{ +inline void Options::add_option(const std::string &group, const std::string &s, + const std::string &l, std::string desc, + std::shared_ptr value, + std::string arg_help) { auto stringDesc = toLocalString(std::move(desc)); auto option = std::make_shared(s, l, stringDesc, value); - if (s.size() > 0) - { + if (s.size() > 0) { add_one_option(s, option); } - if (l.size() > 0) - { + if (l.size() > 0) { add_one_option(l, option); } - //add the help details - auto& options = m_help[group]; + // add the help details + auto &options = m_help[group]; - options.options.emplace_back(HelpOptionDetails{s, l, stringDesc, - value->has_default(), value->get_default_value(), - value->has_implicit(), value->get_implicit_value(), - std::move(arg_help), - value->is_container(), - value->is_boolean()}); + options.options.emplace_back(HelpOptionDetails{ + s, l, stringDesc, value->has_default(), value->get_default_value(), + value->has_implicit(), value->get_implicit_value(), std::move(arg_help), + value->is_container(), value->is_boolean()}); } -inline -void -Options::add_one_option -( - const std::string& option, - std::shared_ptr details -) -{ +inline void Options::add_one_option(const std::string &option, + std::shared_ptr details) { auto in = m_options->emplace(option, details); - if (!in.second) - { + if (!in.second) { throw option_exists_error(option); } } -inline -String -Options::help_one_group(const std::string& g) const -{ +inline String Options::help_one_group(const std::string &g) const { typedef std::vector> OptionHelp; auto group = m_help.find(g); - if (group == m_help.end()) - { + if (group == m_help.end()) { return ""; } @@ -1965,16 +1320,13 @@ Options::help_one_group(const std::string& g) const String result; - if (!g.empty()) - { + if (!g.empty()) { result += toLocalString(" " + g + " options:\n"); } - for (const auto& o : group->second.options) - { + for (const auto &o : group->second.options) { if (m_positional_set.find(o.l) != m_positional_set.end() && - !m_show_positional) - { + !m_show_positional) { continue; } @@ -1985,31 +1337,25 @@ Options::help_one_group(const std::string& g) const longest = (std::min)(longest, static_cast(OPTION_LONGEST)); - //widest allowed description + // widest allowed description auto allowed = size_t{76} - longest - OPTION_DESC_GAP; auto fiter = format.begin(); - for (const auto& o : group->second.options) - { + for (const auto &o : group->second.options) { if (m_positional_set.find(o.l) != m_positional_set.end() && - !m_show_positional) - { + !m_show_positional) { continue; } auto d = format_description(o, longest + OPTION_DESC_GAP, allowed); result += fiter->first; - if (stringLength(fiter->first) > longest) - { + if (stringLength(fiter->first) > longest) { result += '\n'; result += toLocalString(std::string(longest + OPTION_DESC_GAP, ' ')); - } - else - { - result += toLocalString(std::string(longest + OPTION_DESC_GAP - - stringLength(fiter->first), - ' ')); + } else { + result += toLocalString(std::string( + longest + OPTION_DESC_GAP - stringLength(fiter->first), ' ')); } result += d; result += '\n'; @@ -2020,50 +1366,35 @@ Options::help_one_group(const std::string& g) const return result; } -inline -void -Options::generate_group_help -( - String& result, - const std::vector& print_groups -) const -{ - for (size_t i = 0; i != print_groups.size(); ++i) - { - const String& group_help_text = help_one_group(print_groups[i]); - if (empty(group_help_text)) - { +inline void Options::generate_group_help( + String &result, const std::vector &print_groups) const { + for (size_t i = 0; i != print_groups.size(); ++i) { + const String &group_help_text = help_one_group(print_groups[i]); + if (empty(group_help_text)) { continue; } result += group_help_text; - if (i < print_groups.size() - 1) - { + if (i < print_groups.size() - 1) { result += '\n'; } } } -inline -void -Options::generate_all_groups_help(String& result) const -{ +inline void Options::generate_all_groups_help(String &result) const { std::vector all_groups; all_groups.reserve(m_help.size()); - for (auto& group : m_help) - { + for (auto &group : m_help) { all_groups.push_back(group.first); } generate_group_help(result, all_groups); } -inline -std::string -Options::help(const std::vector& help_groups) const -{ - String result = m_help_string + "\nUsage:\n " + - toLocalString(m_program) + " " + toLocalString(m_custom_help); +inline std::string +Options::help(const std::vector &help_groups) const { + String result = m_help_string + "\nUsage:\n " + toLocalString(m_program) + + " " + toLocalString(m_custom_help); if (m_positional.size() > 0 && m_positional_help.size() > 0) { result += " " + toLocalString(m_positional_help); @@ -2071,44 +1402,32 @@ Options::help(const std::vector& help_groups) const result += "\n\n"; - if (help_groups.size() == 0) - { + if (help_groups.size() == 0) { generate_all_groups_help(result); - } - else - { + } else { generate_group_help(result, help_groups); } return toUTF8String(result); } -inline -const std::vector -Options::groups() const -{ +inline const std::vector Options::groups() const { std::vector g; std::transform( - m_help.begin(), - m_help.end(), - std::back_inserter(g), - [] (const std::map::value_type& pair) - { - return pair.first; - } - ); + m_help.begin(), m_help.end(), std::back_inserter(g), + [](const std::map::value_type &pair) { + return pair.first; + }); return g; } -inline -const HelpGroupDetails& -Options::group_help(const std::string& group) const -{ +inline const HelpGroupDetails & +Options::group_help(const std::string &group) const { return m_help.at(group); } -} +} // namespace cxxopts -#endif //CXXOPTS_HPP_INCLUDED +#endif // CXXOPTS_HPP_INCLUDED diff --git a/command/cxxopts/src/example.cpp b/command/cxxopts/src/example.cpp index d3bbb0ad4..17d2df142 100644 --- a/command/cxxopts/src/example.cpp +++ b/command/cxxopts/src/example.cpp @@ -26,116 +26,96 @@ THE SOFTWARE. #include "cxxopts.hpp" -cxxopts::ParseResult -parse(int argc, char* argv[]) -{ - try - { +cxxopts::ParseResult parse(int argc, char *argv[]) { + try { cxxopts::Options options(argv[0], " - example command line options"); - options - .positional_help("[optional args]") - .show_positional_help(); + options.positional_help("[optional args]").show_positional_help(); bool apple = false; - options - .allow_unrecognised_options() - .add_options() - ("a,apple", "an apple", cxxopts::value(apple)) - ("b,bob", "Bob") - ("t,true", "True", cxxopts::value()->default_value("true")) - ("f, file", "File", cxxopts::value>(), "FILE") - ("i,input", "Input", cxxopts::value()) - ("o,output", "Output file", cxxopts::value() - ->default_value("a.out")->implicit_value("b.def"), "BIN") - ("positional", - "Positional arguments: these are the arguments that are entered " - "without an option", cxxopts::value>()) - ("long-description", - "thisisareallylongwordthattakesupthewholelineandcannotbebrokenataspace") - ("help", "Print help") - ("int", "An integer", cxxopts::value(), "N") - ("float", "A floating point number", cxxopts::value()) - ("vector", "A list of doubles", cxxopts::value>()) - ("option_that_is_too_long_for_the_help", "A very long option") - #ifdef CXXOPTS_USE_UNICODE - ("unicode", u8"A help option with non-ascii: à. Here the size of the" - " string should be correct") - #endif - ; - - options.add_options("Group") - ("c,compile", "compile") - ("d,drop", "drop", cxxopts::value>()); + options.allow_unrecognised_options().add_options()( + "a,apple", "an apple", cxxopts::value(apple))("b,bob", "Bob")( + "t,true", "True", cxxopts::value()->default_value("true"))( + "f, file", "File", cxxopts::value>(), + "FILE")("i,input", "Input", cxxopts::value())( + "o,output", "Output file", + cxxopts::value()->default_value("a.out")->implicit_value( + "b.def"), + "BIN")("positional", + "Positional arguments: these are the arguments that are entered " + "without an option", + cxxopts::value>())( + "long-description", "thisisareallylongwordthattakesupthewholelineandcan" + "notbebrokenataspace")("help", "Print help")( + "int", "An integer", cxxopts::value(), + "N")("float", "A floating point number", cxxopts::value())( + "vector", "A list of doubles", cxxopts::value>())( + "option_that_is_too_long_for_the_help", "A very long option") +#ifdef CXXOPTS_USE_UNICODE + ("unicode", u8"A help option with non-ascii: à. Here the size of the" + " string should be correct") +#endif + ; + + options.add_options("Group")("c,compile", "compile")( + "d,drop", "drop", cxxopts::value>()); options.parse_positional({"input", "output", "positional"}); auto result = options.parse(argc, argv); - if (result.count("help")) - { + if (result.count("help")) { std::cout << options.help({"", "Group"}) << std::endl; exit(0); } - if (apple) - { - std::cout << "Saw option ‘a’ " << result.count("a") << " times " << - std::endl; + if (apple) { + std::cout << "Saw option ‘a’ " << result.count("a") << " times " + << std::endl; } - if (result.count("b")) - { + if (result.count("b")) { std::cout << "Saw option ‘b’" << std::endl; } - if (result.count("f")) - { - auto& ff = result["f"].as>(); + if (result.count("f")) { + auto &ff = result["f"].as>(); std::cout << "Files" << std::endl; - for (const auto& f : ff) - { + for (const auto &f : ff) { std::cout << f << std::endl; } } - if (result.count("input")) - { - std::cout << "Input = " << result["input"].as() - << std::endl; + if (result.count("input")) { + std::cout << "Input = " << result["input"].as() << std::endl; } - if (result.count("output")) - { + if (result.count("output")) { std::cout << "Output = " << result["output"].as() - << std::endl; + << std::endl; } - if (result.count("positional")) - { + if (result.count("positional")) { std::cout << "Positional = {"; - auto& v = result["positional"].as>(); - for (const auto& s : v) { + auto &v = result["positional"].as>(); + for (const auto &s : v) { std::cout << s << ", "; } std::cout << "}" << std::endl; } - if (result.count("int")) - { + if (result.count("int")) { std::cout << "int = " << result["int"].as() << std::endl; } - if (result.count("float")) - { + if (result.count("float")) { std::cout << "float = " << result["float"].as() << std::endl; } - if (result.count("vector")) - { + if (result.count("vector")) { std::cout << "vector = "; const auto values = result["vector"].as>(); - for (const auto& v : values) { + for (const auto &v : values) { std::cout << v << ", "; } std::cout << std::endl; @@ -145,15 +125,13 @@ parse(int argc, char* argv[]) return result; - } catch (const cxxopts::OptionException& e) - { + } catch (const cxxopts::OptionException &e) { std::cout << "error parsing options: " << e.what() << std::endl; exit(1); } } -int main(int argc, char* argv[]) -{ +int main(int argc, char *argv[]) { auto result = parse(argc, argv); auto arguments = result.arguments(); std::cout << "Saw " << arguments.size() << " arguments" << std::endl; diff --git a/command/cxxopts/test/catch.hpp b/command/cxxopts/test/catch.hpp index ef9a46326..ff3b2b7fe 100644 --- a/command/cxxopts/test/catch.hpp +++ b/command/cxxopts/test/catch.hpp @@ -2,8 +2,8 @@ * Catch v1.5.0 * Generated: 2016-04-25 18:56:14.308559 * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. + * This file has been merged from multiple headers. Please don't edit it + * directly Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -14,44 +14,44 @@ #define TWOBLUECUBES_CATCH_HPP_INCLUDED #ifdef __clang__ -# pragma clang system_header +#pragma clang system_header #elif defined __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif // #included from: internal/catch_suppress_warnings.h #ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic ignored "-Wglobal-constructors" -# pragma clang diagnostic ignored "-Wvariadic-macros" -# pragma clang diagnostic ignored "-Wc99-extensions" -# pragma clang diagnostic ignored "-Wunused-variable" -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wc++98-compat" -# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif +#ifdef __ICC // icpc defines the __clang__ macro +#pragma warning(push) +#pragma warning(disable : 161 1682) +#else // __ICC +#pragma clang diagnostic ignored "-Wglobal-constructors" +#pragma clang diagnostic ignored "-Wvariadic-macros" +#pragma clang diagnostic ignored "-Wc99-extensions" +#pragma clang diagnostic ignored "-Wunused-variable" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#pragma clang diagnostic ignored "-Wc++98-compat" +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#pragma clang diagnostic ignored "-Wswitch-enum" +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#endif #elif defined __GNUC__ -# pragma GCC diagnostic ignored "-Wvariadic-macros" -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpadded" +#pragma GCC diagnostic ignored "-Wvariadic-macros" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpadded" #endif #if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL +#define CATCH_IMPL #endif #ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif +#ifndef CLARA_CONFIG_MAIN +#define CLARA_CONFIG_MAIN_NOT_DEFINED +#define CLARA_CONFIG_MAIN +#endif #endif // #included from: internal/catch_notimplemented_exception.h @@ -60,35 +60,39 @@ // #included from: catch_common.h #define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2(name, line) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE(name, line) \ + INTERNAL_CATCH_UNIQUE_NAME_LINE2(name, line) #ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#define INTERNAL_CATCH_UNIQUE_NAME(name) \ + INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __COUNTER__) #else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#define INTERNAL_CATCH_UNIQUE_NAME(name) \ + INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __LINE__) #endif -#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr -#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr ) +#define INTERNAL_CATCH_STRINGIFY2(expr) #expr +#define INTERNAL_CATCH_STRINGIFY(expr) INTERNAL_CATCH_STRINGIFY2(expr) +#include #include #include -#include // #included from: catch_compiler_capabilities.h #define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED -// Detect a number of compiler features - mostly C++11/14 conformance - by compiler -// The following features are defined: +// Detect a number of compiler features - mostly C++11/14 conformance - by +// compiler The following features are defined: // // CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported? // CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported? -// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods -// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported? -// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported +// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for +// compiler generated methods CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is +// supported? CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported // CATCH_CONFIG_CPP11_LONG_LONG : is long long supported? // CATCH_CONFIG_CPP11_OVERRIDE : is override supported? -// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr) +// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use +// auto_ptr) // CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported? @@ -107,22 +111,23 @@ // All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11 #if defined(__cplusplus) && __cplusplus >= 201103L -# define CATCH_CPP11_OR_GREATER +#define CATCH_CPP11_OR_GREATER #endif #ifdef __clang__ -# if __has_feature(cxx_nullptr) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif +#if __has_feature(cxx_nullptr) +#define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR +#endif -# if __has_feature(cxx_noexcept) -# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# endif +#if __has_feature(cxx_noexcept) +#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT +#endif -# if defined(CATCH_CPP11_OR_GREATER) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) -# endif +#if defined(CATCH_CPP11_OR_GREATER) +#define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma("clang diagnostic ignored \"-Wparentheses\"") +#endif #endif // __clang__ @@ -148,13 +153,15 @@ // GCC #ifdef __GNUC__ -# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif +#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) +#define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR +#endif -# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_CPP11_OR_GREATER) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" ) -# endif +#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && \ + defined(CATCH_CPP11_OR_GREATER) +#define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma("GCC diagnostic ignored \"-Wparentheses\"") +#endif // - otherwise more recent versions define __cplusplus >= 201103L // and will get picked up below @@ -166,11 +173,11 @@ #ifdef _MSC_VER #if (_MSC_VER >= 1600) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR +#define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR +#define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR #endif -#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) +#if (_MSC_VER >= 1900) // (VC++ 13 (VS2015)) #define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT #define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS #endif @@ -180,19 +187,20 @@ //////////////////////////////////////////////////////////////////////////////// // Use variadic macros if the compiler supports them -#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \ - ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \ - ( defined __GNUC__ && __GNUC__ >= 3 ) || \ - ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) +#if (defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \ + (defined __WAVE__ && __WAVE_HAS_VARIADICS) || \ + (defined __GNUC__ && __GNUC__ >= 3) || \ + (!defined __cplusplus && __STDC_VERSION__ >= 199901L || \ + __cplusplus >= 201103L) #define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS #endif // Use __COUNTER__ if the compiler supports it -#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \ - ( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \ - ( defined __clang__ && __clang_major__ >= 3 ) +#if (defined _MSC_VER && _MSC_VER >= 1300) || \ + (defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3) || \ + (defined __clang__ && __clang_major__ >= 3) #define CATCH_INTERNAL_CONFIG_COUNTER @@ -204,248 +212,269 @@ // catch all support for C++11 #if defined(CATCH_CPP11_OR_GREATER) -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif +#if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) +#define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR +#endif -# ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# endif +#ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT +#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT +#endif -# ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -# define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -# endif +#ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS +#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS +#endif -# ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM -# define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM -# endif +#ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM +#define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM +#endif -# ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE -# define CATCH_INTERNAL_CONFIG_CPP11_TUPLE -# endif +#ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE +#define CATCH_INTERNAL_CONFIG_CPP11_TUPLE +#endif -# ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS -# define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS -# endif +#ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS +#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS +#endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) -# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG -# endif +#if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) +#define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG +#endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) -# define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE -# endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) -# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -# endif +#if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) +#define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE +#endif +#if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) +#define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR +#endif #endif // __cplusplus >= 201103L -// Now set the actual defines based on the above + anything the user has configured -#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_NULLPTR +// Now set the actual defines based on the above + anything the user has +// configured +#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && \ + !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && \ + !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11) +#define CATCH_CONFIG_CPP11_NULLPTR #endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_NOEXCEPT +#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && \ + !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && \ + !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11) +#define CATCH_CONFIG_CPP11_NOEXCEPT #endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_GENERATED_METHODS +#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && \ + !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && \ + !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && \ + !defined(CATCH_CONFIG_NO_CPP11) +#define CATCH_CONFIG_CPP11_GENERATED_METHODS #endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_IS_ENUM +#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && \ + !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && \ + !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11) +#define CATCH_CONFIG_CPP11_IS_ENUM #endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_TUPLE +#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && \ + !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && \ + !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11) +#define CATCH_CONFIG_CPP11_TUPLE #endif -#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS) -# define CATCH_CONFIG_VARIADIC_MACROS +#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && \ + !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && \ + !defined(CATCH_CONFIG_VARIADIC_MACROS) +#define CATCH_CONFIG_VARIADIC_MACROS #endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_LONG_LONG +#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && \ + !defined(CATCH_CONFIG_NO_LONG_LONG) && \ + !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11) +#define CATCH_CONFIG_CPP11_LONG_LONG #endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_OVERRIDE +#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && \ + !defined(CATCH_CONFIG_NO_OVERRIDE) && \ + !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11) +#define CATCH_CONFIG_CPP11_OVERRIDE #endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_UNIQUE_PTR +#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && \ + !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && \ + !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11) +#define CATCH_CONFIG_CPP11_UNIQUE_PTR #endif -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER +#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && \ + !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) +#define CATCH_CONFIG_COUNTER #endif #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +#define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS #endif // noexcept support: #if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) -# define CATCH_NOEXCEPT noexcept -# define CATCH_NOEXCEPT_IS(x) noexcept(x) +#define CATCH_NOEXCEPT noexcept +#define CATCH_NOEXCEPT_IS(x) noexcept(x) #else -# define CATCH_NOEXCEPT throw() -# define CATCH_NOEXCEPT_IS(x) +#define CATCH_NOEXCEPT throw() +#define CATCH_NOEXCEPT_IS(x) #endif // nullptr support #ifdef CATCH_CONFIG_CPP11_NULLPTR -# define CATCH_NULL nullptr +#define CATCH_NULL nullptr #else -# define CATCH_NULL NULL +#define CATCH_NULL NULL #endif // override support #ifdef CATCH_CONFIG_CPP11_OVERRIDE -# define CATCH_OVERRIDE override +#define CATCH_OVERRIDE override #else -# define CATCH_OVERRIDE +#define CATCH_OVERRIDE #endif // unique_ptr support #ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR -# define CATCH_AUTO_PTR( T ) std::unique_ptr +#define CATCH_AUTO_PTR(T) std::unique_ptr #else -# define CATCH_AUTO_PTR( T ) std::auto_ptr +#define CATCH_AUTO_PTR(T) std::auto_ptr #endif namespace Catch { - struct IConfig; +struct IConfig; - struct CaseSensitive { enum Choice { - Yes, - No - }; }; +struct CaseSensitive { + enum Choice { Yes, No }; +}; - class NonCopyable { +class NonCopyable { #ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; + NonCopyable(NonCopyable const &) = delete; + NonCopyable(NonCopyable &&) = delete; + NonCopyable &operator=(NonCopyable const &) = delete; + NonCopyable &operator=(NonCopyable &&) = delete; #else - NonCopyable( NonCopyable const& info ); - NonCopyable& operator = ( NonCopyable const& ); + NonCopyable(NonCopyable const &info); + NonCopyable &operator=(NonCopyable const &); +#endif + +protected: + NonCopyable() {} + virtual ~NonCopyable(); +}; + +class SafeBool { +public: + typedef void (SafeBool::*type)() const; + + static type makeSafe(bool value) { return value ? &SafeBool::trueValue : 0; } + +private: + void trueValue() const {} +}; + +template inline void deleteAll(ContainerT &container) { + typename ContainerT::const_iterator it = container.begin(); + typename ContainerT::const_iterator itEnd = container.end(); + for (; it != itEnd; ++it) + delete *it; +} +template +inline void deleteAllValues(AssociativeContainerT &container) { + typename AssociativeContainerT::const_iterator it = container.begin(); + typename AssociativeContainerT::const_iterator itEnd = container.end(); + for (; it != itEnd; ++it) + delete it->second; +} + +bool startsWith(std::string const &s, std::string const &prefix); +bool endsWith(std::string const &s, std::string const &suffix); +bool contains(std::string const &s, std::string const &infix); +void toLowerInPlace(std::string &s); +std::string toLower(std::string const &s); +std::string trim(std::string const &str); +bool replaceInPlace(std::string &str, std::string const &replaceThis, + std::string const &withThis); + +struct pluralise { + pluralise(std::size_t count, std::string const &label); + + friend std::ostream &operator<<(std::ostream &os, + pluralise const &pluraliser); + + std::size_t m_count; + std::string m_label; +}; + +struct SourceLineInfo { + + SourceLineInfo(); + SourceLineInfo(char const *_file, std::size_t _line); + SourceLineInfo(SourceLineInfo const &other); +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS + SourceLineInfo(SourceLineInfo &&) = default; + SourceLineInfo &operator=(SourceLineInfo const &) = default; + SourceLineInfo &operator=(SourceLineInfo &&) = default; #endif + bool empty() const; + bool operator==(SourceLineInfo const &other) const; + bool operator<(SourceLineInfo const &other) const; - protected: - NonCopyable() {} - virtual ~NonCopyable(); - }; + std::string file; + std::size_t line; +}; - class SafeBool { - public: - typedef void (SafeBool::*type)() const; +std::ostream &operator<<(std::ostream &os, SourceLineInfo const &info); - static type makeSafe( bool value ) { - return value ? &SafeBool::trueValue : 0; - } - private: - void trueValue() const {} - }; - - template - inline void deleteAll( ContainerT& container ) { - typename ContainerT::const_iterator it = container.begin(); - typename ContainerT::const_iterator itEnd = container.end(); - for(; it != itEnd; ++it ) - delete *it; - } - template - inline void deleteAllValues( AssociativeContainerT& container ) { - typename AssociativeContainerT::const_iterator it = container.begin(); - typename AssociativeContainerT::const_iterator itEnd = container.end(); - for(; it != itEnd; ++it ) - delete it->second; - } - - bool startsWith( std::string const& s, std::string const& prefix ); - bool endsWith( std::string const& s, std::string const& suffix ); - bool contains( std::string const& s, std::string const& infix ); - void toLowerInPlace( std::string& s ); - std::string toLower( std::string const& s ); - std::string trim( std::string const& str ); - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); - - struct pluralise { - pluralise( std::size_t count, std::string const& label ); - - friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); - - std::size_t m_count; - std::string m_label; - }; - - struct SourceLineInfo { - - SourceLineInfo(); - SourceLineInfo( char const* _file, std::size_t _line ); - SourceLineInfo( SourceLineInfo const& other ); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - SourceLineInfo( SourceLineInfo && ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo& operator = ( SourceLineInfo && ) = default; -# endif - bool empty() const; - bool operator == ( SourceLineInfo const& other ) const; - bool operator < ( SourceLineInfo const& other ) const; - - std::string file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // This is just here to avoid compiler warnings with macro constants and boolean literals - inline bool isTrue( bool value ){ return value; } - inline bool alwaysTrue() { return true; } - inline bool alwaysFalse() { return false; } - - void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); - - void seedRng( IConfig const& config ); - unsigned int rngSeed(); - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() { - return std::string(); - } - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } +// This is just here to avoid compiler warnings with macro constants and boolean +// literals +inline bool isTrue(bool value) { return value; } +inline bool alwaysTrue() { return true; } +inline bool alwaysFalse() { return false; } + +void throwLogicError(std::string const &message, + SourceLineInfo const &locationInfo); + +void seedRng(IConfig const &config); +unsigned int rngSeed(); + +// Use this in variadic streaming macros to allow +// >> +StreamEndStop +// as well as +// >> stuff +StreamEndStop +struct StreamEndStop { + std::string operator+() { return std::string(); } +}; +template T const &operator+(T const &value, StreamEndStop) { + return value; } +} // namespace Catch -#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) -#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO ); +#define CATCH_INTERNAL_LINEINFO \ + ::Catch::SourceLineInfo(__FILE__, static_cast(__LINE__)) +#define CATCH_INTERNAL_ERROR(msg) \ + ::Catch::throwLogicError(msg, CATCH_INTERNAL_LINEINFO); #include namespace Catch { - class NotImplementedException : public std::exception - { - public: - NotImplementedException( SourceLineInfo const& lineInfo ); - NotImplementedException( NotImplementedException const& ) {} +class NotImplementedException : public std::exception { +public: + NotImplementedException(SourceLineInfo const &lineInfo); + NotImplementedException(NotImplementedException const &) {} - virtual ~NotImplementedException() CATCH_NOEXCEPT {} + virtual ~NotImplementedException() CATCH_NOEXCEPT {} - virtual const char* what() const CATCH_NOEXCEPT; + virtual const char *what() const CATCH_NOEXCEPT; - private: - std::string m_what; - SourceLineInfo m_lineInfo; - }; +private: + std::string m_what; + SourceLineInfo m_lineInfo; +}; } // end namespace Catch /////////////////////////////////////////////////////////////////////////////// -#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO ) +#define CATCH_NOT_IMPLEMENTED \ + throw Catch::NotImplementedException(CATCH_INTERNAL_LINEINFO) // #included from: internal/catch_context.h #define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED @@ -457,20 +486,21 @@ namespace Catch { namespace Catch { - struct IGeneratorInfo { - virtual ~IGeneratorInfo(); - virtual bool moveNext() = 0; - virtual std::size_t getCurrentIndex() const = 0; - }; +struct IGeneratorInfo { + virtual ~IGeneratorInfo(); + virtual bool moveNext() = 0; + virtual std::size_t getCurrentIndex() const = 0; +}; - struct IGeneratorsForTest { - virtual ~IGeneratorsForTest(); +struct IGeneratorsForTest { + virtual ~IGeneratorsForTest(); - virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0; - virtual bool moveNext() = 0; - }; + virtual IGeneratorInfo &getGeneratorInfo(std::string const &fileInfo, + std::size_t size) = 0; + virtual bool moveNext() = 0; +}; - IGeneratorsForTest* createGeneratorsForTest(); +IGeneratorsForTest *createGeneratorsForTest(); } // end namespace Catch @@ -484,72 +514,70 @@ namespace Catch { namespace Catch { - // An intrusive reference counting smart pointer. - // T must implement addRef() and release() methods - // typically implementing the IShared interface - template - class Ptr { - public: - Ptr() : m_p( CATCH_NULL ){} - Ptr( T* p ) : m_p( p ){ - if( m_p ) - m_p->addRef(); - } - Ptr( Ptr const& other ) : m_p( other.m_p ){ - if( m_p ) - m_p->addRef(); - } - ~Ptr(){ - if( m_p ) - m_p->release(); - } - void reset() { - if( m_p ) - m_p->release(); - m_p = CATCH_NULL; - } - Ptr& operator = ( T* p ){ - Ptr temp( p ); - swap( temp ); - return *this; - } - Ptr& operator = ( Ptr const& other ){ - Ptr temp( other ); - swap( temp ); - return *this; - } - void swap( Ptr& other ) { std::swap( m_p, other.m_p ); } - T* get() const{ return m_p; } - T& operator*() const { return *m_p; } - T* operator->() const { return m_p; } - bool operator !() const { return m_p == CATCH_NULL; } - operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); } - - private: - T* m_p; - }; - - struct IShared : NonCopyable { - virtual ~IShared(); - virtual void addRef() const = 0; - virtual void release() const = 0; - }; - - template - struct SharedImpl : T { - - SharedImpl() : m_rc( 0 ){} - - virtual void addRef() const { - ++m_rc; - } - virtual void release() const { - if( --m_rc == 0 ) - delete this; - } +// An intrusive reference counting smart pointer. +// T must implement addRef() and release() methods +// typically implementing the IShared interface +template class Ptr { +public: + Ptr() : m_p(CATCH_NULL) {} + Ptr(T *p) : m_p(p) { + if (m_p) + m_p->addRef(); + } + Ptr(Ptr const &other) : m_p(other.m_p) { + if (m_p) + m_p->addRef(); + } + ~Ptr() { + if (m_p) + m_p->release(); + } + void reset() { + if (m_p) + m_p->release(); + m_p = CATCH_NULL; + } + Ptr &operator=(T *p) { + Ptr temp(p); + swap(temp); + return *this; + } + Ptr &operator=(Ptr const &other) { + Ptr temp(other); + swap(temp); + return *this; + } + void swap(Ptr &other) { std::swap(m_p, other.m_p); } + T *get() const { return m_p; } + T &operator*() const { return *m_p; } + T *operator->() const { return m_p; } + bool operator!() const { return m_p == CATCH_NULL; } + operator SafeBool::type() const { + return SafeBool::makeSafe(m_p != CATCH_NULL); + } + +private: + T *m_p; +}; + +struct IShared : NonCopyable { + virtual ~IShared(); + virtual void addRef() const = 0; + virtual void release() const = 0; +}; + +template struct SharedImpl : T { - mutable unsigned int m_rc; - }; + SharedImpl() : m_rc(0) {} + + virtual void addRef() const { ++m_rc; } + virtual void release() const { + if (--m_rc == 0) + delete this; + } + + mutable unsigned int m_rc; +}; } // end namespace Catch @@ -558,43 +586,42 @@ namespace Catch { #endif #include -#include #include +#include namespace Catch { - class TestCase; - class Stream; - struct IResultCapture; - struct IRunner; - struct IGeneratorsForTest; - struct IConfig; - - struct IContext - { - virtual ~IContext(); - - virtual IResultCapture* getResultCapture() = 0; - virtual IRunner* getRunner() = 0; - virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0; - virtual bool advanceGeneratorsForCurrentTest() = 0; - virtual Ptr getConfig() const = 0; - }; +class TestCase; +class Stream; +struct IResultCapture; +struct IRunner; +struct IGeneratorsForTest; +struct IConfig; + +struct IContext { + virtual ~IContext(); + + virtual IResultCapture *getResultCapture() = 0; + virtual IRunner *getRunner() = 0; + virtual size_t getGeneratorIndex(std::string const &fileInfo, + size_t totalSize) = 0; + virtual bool advanceGeneratorsForCurrentTest() = 0; + virtual Ptr getConfig() const = 0; +}; - struct IMutableContext : IContext - { - virtual ~IMutableContext(); - virtual void setResultCapture( IResultCapture* resultCapture ) = 0; - virtual void setRunner( IRunner* runner ) = 0; - virtual void setConfig( Ptr const& config ) = 0; - }; +struct IMutableContext : IContext { + virtual ~IMutableContext(); + virtual void setResultCapture(IResultCapture *resultCapture) = 0; + virtual void setRunner(IRunner *runner) = 0; + virtual void setConfig(Ptr const &config) = 0; +}; - IContext& getCurrentContext(); - IMutableContext& getCurrentMutableContext(); - void cleanUpContext(); - Stream createStream( std::string const& streamName ); +IContext &getCurrentContext(); +IMutableContext &getCurrentMutableContext(); +void cleanUpContext(); +Stream createStream(std::string const &streamName); -} +} // namespace Catch // #included from: internal/catch_test_registry.hpp #define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED @@ -606,157 +633,176 @@ namespace Catch { namespace Catch { - class TestSpec; +class TestSpec; - struct ITestCase : IShared { - virtual void invoke () const = 0; - protected: - virtual ~ITestCase(); - }; +struct ITestCase : IShared { + virtual void invoke() const = 0; - class TestCase; - struct IConfig; +protected: + virtual ~ITestCase(); +}; - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; +class TestCase; +struct IConfig; - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); +struct ITestCaseRegistry { + virtual ~ITestCaseRegistry(); + virtual std::vector const &getAllTests() const = 0; + virtual std::vector const & + getAllTestsSorted(IConfig const &config) const = 0; +}; -} +bool matchTest(TestCase const &testCase, TestSpec const &testSpec, + IConfig const &config); +std::vector filterTests(std::vector const &testCases, + TestSpec const &testSpec, + IConfig const &config); +std::vector const &getAllTestCasesSorted(IConfig const &config); + +} // namespace Catch namespace Catch { -template -class MethodTestCase : public SharedImpl { +template class MethodTestCase : public SharedImpl { public: - MethodTestCase( void (C::*method)() ) : m_method( method ) {} + MethodTestCase(void (C::*method)()) : m_method(method) {} - virtual void invoke() const { - C obj; - (obj.*m_method)(); - } + virtual void invoke() const { + C obj; + (obj.*m_method)(); + } private: - virtual ~MethodTestCase() {} + virtual ~MethodTestCase() {} - void (C::*m_method)(); + void (C::*m_method)(); }; -typedef void(*TestFunction)(); +typedef void (*TestFunction)(); struct NameAndDesc { - NameAndDesc( const char* _name = "", const char* _description= "" ) - : name( _name ), description( _description ) - {} + NameAndDesc(const char *_name = "", const char *_description = "") + : name(_name), description(_description) {} - const char* name; - const char* description; + const char *name; + const char *description; }; -void registerTestCase - ( ITestCase* testCase, - char const* className, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ); +void registerTestCase(ITestCase *testCase, char const *className, + NameAndDesc const &nameAndDesc, + SourceLineInfo const &lineInfo); struct AutoReg { - AutoReg - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ); + AutoReg(TestFunction function, SourceLineInfo const &lineInfo, + NameAndDesc const &nameAndDesc); - template - AutoReg - ( void (C::*method)(), - char const* className, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ) { + template + AutoReg(void (C::*method)(), char const *className, + NameAndDesc const &nameAndDesc, SourceLineInfo const &lineInfo) { - registerTestCase - ( new MethodTestCase( method ), - className, - nameAndDesc, - lineInfo ); - } + registerTestCase(new MethodTestCase(method), className, nameAndDesc, + lineInfo); + } - ~AutoReg(); + ~AutoReg(); private: - AutoReg( AutoReg const& ); - void operator= ( AutoReg const& ); + AutoReg(AutoReg const &); + void operator=(AutoReg const &); }; -void registerTestCaseFunction - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ); +void registerTestCaseFunction(TestFunction function, + SourceLineInfo const &lineInfo, + NameAndDesc const &nameAndDesc); } // end namespace Catch #ifdef CATCH_CONFIG_VARIADIC_MACROS - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ - static void TestName(); \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\ - static void TestName() - #define INTERNAL_CATCH_TESTCASE( ... ) \ - INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ - namespace{ \ - struct TestName : ClassName{ \ - void test(); \ - }; \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \ - } \ - void TestName::test() - #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ - INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ - Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); + /////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TESTCASE2(TestName, ...) \ + static void TestName(); \ + namespace { \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ + &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(__VA_ARGS__)); \ + } \ + static void TestName() +#define INTERNAL_CATCH_TESTCASE(...) \ + INTERNAL_CATCH_TESTCASE2( \ + INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____), __VA_ARGS__) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_METHOD_AS_TEST_CASE(QualifiedMethod, ...) \ + namespace { \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ + &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc(__VA_ARGS__), \ + CATCH_INTERNAL_LINEINFO); \ + } + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TEST_CASE_METHOD2(TestName, ClassName, ...) \ + namespace { \ + struct TestName : ClassName { \ + void test(); \ + }; \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ + &TestName::test, #ClassName, Catch::NameAndDesc(__VA_ARGS__), \ + CATCH_INTERNAL_LINEINFO); \ + } \ + void TestName::test() +#define INTERNAL_CATCH_TEST_CASE_METHOD(ClassName, ...) \ + INTERNAL_CATCH_TEST_CASE_METHOD2( \ + INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____), ClassName, \ + __VA_ARGS__) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_REGISTER_TESTCASE(Function, ...) \ + Catch::AutoReg(Function, CATCH_INTERNAL_LINEINFO, \ + Catch::NameAndDesc(__VA_ARGS__)); #else - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \ - static void TestName(); \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\ - static void TestName() - #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \ - INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\ - namespace{ \ - struct TestCaseName : ClassName{ \ - void test(); \ - }; \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \ - } \ - void TestCaseName::test() - #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\ - INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \ - Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); + /////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TESTCASE2(TestName, Name, Desc) \ + static void TestName(); \ + namespace { \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ + &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(Name, Desc)); \ + } \ + static void TestName() +#define INTERNAL_CATCH_TESTCASE(Name, Desc) \ + INTERNAL_CATCH_TESTCASE2( \ + INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____), Name, Desc) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_METHOD_AS_TEST_CASE(QualifiedMethod, Name, Desc) \ + namespace { \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ + &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc(Name, Desc), \ + CATCH_INTERNAL_LINEINFO); \ + } + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TEST_CASE_METHOD2(TestCaseName, ClassName, TestName, \ + Desc) \ + namespace { \ + struct TestCaseName : ClassName { \ + void test(); \ + }; \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ + &TestCaseName::test, #ClassName, Catch::NameAndDesc(TestName, Desc), \ + CATCH_INTERNAL_LINEINFO); \ + } \ + void TestCaseName::test() +#define INTERNAL_CATCH_TEST_CASE_METHOD(ClassName, TestName, Desc) \ + INTERNAL_CATCH_TEST_CASE_METHOD2( \ + INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____), ClassName, \ + TestName, Desc) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_REGISTER_TESTCASE(Function, Name, Desc) \ + Catch::AutoReg(Function, CATCH_INTERNAL_LINEINFO, \ + Catch::NameAndDesc(Name, Desc)); #endif // #included from: internal/catch_capture.hpp @@ -770,50 +816,60 @@ void registerTestCaseFunction namespace Catch { - // ResultWas::OfType enum - struct ResultWas { enum OfType { - Unknown = -1, - Ok = 0, - Info = 1, - Warning = 2, +// ResultWas::OfType enum +struct ResultWas { + enum OfType { + Unknown = -1, + Ok = 0, + Info = 1, + Warning = 2, - FailureBit = 0x10, + FailureBit = 0x10, - ExpressionFailed = FailureBit | 1, - ExplicitFailure = FailureBit | 2, + ExpressionFailed = FailureBit | 1, + ExplicitFailure = FailureBit | 2, - Exception = 0x100 | FailureBit, + Exception = 0x100 | FailureBit, - ThrewException = Exception | 1, - DidntThrowException = Exception | 2, + ThrewException = Exception | 1, + DidntThrowException = Exception | 2, - FatalErrorCondition = 0x200 | FailureBit + FatalErrorCondition = 0x200 | FailureBit - }; }; + }; +}; - inline bool isOk( ResultWas::OfType resultType ) { - return ( resultType & ResultWas::FailureBit ) == 0; - } - inline bool isJustInfo( int flags ) { - return flags == ResultWas::Info; - } +inline bool isOk(ResultWas::OfType resultType) { + return (resultType & ResultWas::FailureBit) == 0; +} +inline bool isJustInfo(int flags) { return flags == ResultWas::Info; } - // ResultDisposition::Flags enum - struct ResultDisposition { enum Flags { - Normal = 0x01, +// ResultDisposition::Flags enum +struct ResultDisposition { + enum Flags { + Normal = 0x01, - ContinueOnFailure = 0x02, // Failures fail test, but execution continues - FalseTest = 0x04, // Prefix expression with ! - SuppressFail = 0x08 // Failures are reported but do not fail the test - }; }; + ContinueOnFailure = 0x02, // Failures fail test, but execution continues + FalseTest = 0x04, // Prefix expression with ! + SuppressFail = 0x08 // Failures are reported but do not fail the test + }; +}; - inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { - return static_cast( static_cast( lhs ) | static_cast( rhs ) ); - } +inline ResultDisposition::Flags operator|(ResultDisposition::Flags lhs, + ResultDisposition::Flags rhs) { + return static_cast(static_cast(lhs) | + static_cast(rhs)); +} - inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } - inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } - inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } +inline bool shouldContinueOnFailure(int flags) { + return (flags & ResultDisposition::ContinueOnFailure) != 0; +} +inline bool isFalseTest(int flags) { + return (flags & ResultDisposition::FalseTest) != 0; +} +inline bool shouldSuppressFailure(int flags) { + return (flags & ResultDisposition::SuppressFail) != 0; +} } // end namespace Catch @@ -824,371 +880,381 @@ namespace Catch { namespace Catch { - struct AssertionInfo - { - AssertionInfo() {} - AssertionInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - std::string const& _capturedExpression, - ResultDisposition::Flags _resultDisposition ); - - std::string macroName; - SourceLineInfo lineInfo; - std::string capturedExpression; - ResultDisposition::Flags resultDisposition; - }; - - struct AssertionResultData - { - AssertionResultData() : resultType( ResultWas::Unknown ) {} - - std::string reconstructedExpression; - std::string message; - ResultWas::OfType resultType; - }; - - class AssertionResult { - public: - AssertionResult(); - AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); - ~AssertionResult(); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - AssertionResult( AssertionResult const& ) = default; - AssertionResult( AssertionResult && ) = default; - AssertionResult& operator = ( AssertionResult const& ) = default; - AssertionResult& operator = ( AssertionResult && ) = default; -# endif - - bool isOk() const; - bool succeeded() const; - ResultWas::OfType getResultType() const; - bool hasExpression() const; - bool hasMessage() const; - std::string getExpression() const; - std::string getExpressionInMacro() const; - bool hasExpandedExpression() const; - std::string getExpandedExpression() const; - std::string getMessage() const; - SourceLineInfo getSourceInfo() const; - std::string getTestMacroName() const; - - protected: - AssertionInfo m_info; - AssertionResultData m_resultData; - }; - -} // end namespace Catch - -// #included from: catch_matchers.hpp -#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED - -namespace Catch { -namespace Matchers { - namespace Impl { - - namespace Generic { - template class AllOf; - template class AnyOf; - template class Not; - } +struct AssertionInfo { + AssertionInfo() {} + AssertionInfo(std::string const &_macroName, SourceLineInfo const &_lineInfo, + std::string const &_capturedExpression, + ResultDisposition::Flags _resultDisposition); - template - struct Matcher : SharedImpl - { - typedef ExpressionT ExpressionType; + std::string macroName; + SourceLineInfo lineInfo; + std::string capturedExpression; + ResultDisposition::Flags resultDisposition; +}; - virtual ~Matcher() {} - virtual Ptr clone() const = 0; - virtual bool match( ExpressionT const& expr ) const = 0; - virtual std::string toString() const = 0; +struct AssertionResultData { + AssertionResultData() : resultType(ResultWas::Unknown) {} - Generic::AllOf operator && ( Matcher const& other ) const; - Generic::AnyOf operator || ( Matcher const& other ) const; - Generic::Not operator ! () const; - }; + std::string reconstructedExpression; + std::string message; + ResultWas::OfType resultType; +}; - template - struct MatcherImpl : Matcher { +class AssertionResult { +public: + AssertionResult(); + AssertionResult(AssertionInfo const &info, AssertionResultData const &data); + ~AssertionResult(); +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS + AssertionResult(AssertionResult const &) = default; + AssertionResult(AssertionResult &&) = default; + AssertionResult &operator=(AssertionResult const &) = default; + AssertionResult &operator=(AssertionResult &&) = default; +#endif - virtual Ptr > clone() const { - return Ptr >( new DerivedT( static_cast( *this ) ) ); - } - }; + bool isOk() const; + bool succeeded() const; + ResultWas::OfType getResultType() const; + bool hasExpression() const; + bool hasMessage() const; + std::string getExpression() const; + std::string getExpressionInMacro() const; + bool hasExpandedExpression() const; + std::string getExpandedExpression() const; + std::string getMessage() const; + SourceLineInfo getSourceInfo() const; + std::string getTestMacroName() const; + +protected: + AssertionInfo m_info; + AssertionResultData m_resultData; +}; - namespace Generic { - template - class Not : public MatcherImpl, ExpressionT> { - public: - explicit Not( Matcher const& matcher ) : m_matcher(matcher.clone()) {} - Not( Not const& other ) : m_matcher( other.m_matcher ) {} +} // end namespace Catch - virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE { - return !m_matcher->match( expr ); - } +// #included from: catch_matchers.hpp +#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED - virtual std::string toString() const CATCH_OVERRIDE { - return "not " + m_matcher->toString(); - } - private: - Ptr< Matcher > m_matcher; - }; +namespace Catch { +namespace Matchers { +namespace Impl { + +namespace Generic { +template class AllOf; +template class AnyOf; +template class Not; +} // namespace Generic + +template struct Matcher : SharedImpl { + typedef ExpressionT ExpressionType; + + virtual ~Matcher() {} + virtual Ptr clone() const = 0; + virtual bool match(ExpressionT const &expr) const = 0; + virtual std::string toString() const = 0; + + Generic::AllOf + operator&&(Matcher const &other) const; + Generic::AnyOf + operator||(Matcher const &other) const; + Generic::Not operator!() const; +}; - template - class AllOf : public MatcherImpl, ExpressionT> { - public: +template +struct MatcherImpl : Matcher { - AllOf() {} - AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {} + virtual Ptr> clone() const { + return Ptr>( + new DerivedT(static_cast(*this))); + } +}; - AllOf& add( Matcher const& matcher ) { - m_matchers.push_back( matcher.clone() ); - return *this; - } - virtual bool match( ExpressionT const& expr ) const - { - for( std::size_t i = 0; i < m_matchers.size(); ++i ) - if( !m_matchers[i]->match( expr ) ) - return false; - return true; - } - virtual std::string toString() const { - std::ostringstream oss; - oss << "( "; - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if( i != 0 ) - oss << " and "; - oss << m_matchers[i]->toString(); - } - oss << " )"; - return oss.str(); - } +namespace Generic { +template +class Not : public MatcherImpl, ExpressionT> { +public: + explicit Not(Matcher const &matcher) + : m_matcher(matcher.clone()) {} + Not(Not const &other) : m_matcher(other.m_matcher) {} - AllOf operator && ( Matcher const& other ) const { - AllOf allOfExpr( *this ); - allOfExpr.add( other ); - return allOfExpr; - } + virtual bool match(ExpressionT const &expr) const CATCH_OVERRIDE { + return !m_matcher->match(expr); + } - private: - std::vector > > m_matchers; - }; + virtual std::string toString() const CATCH_OVERRIDE { + return "not " + m_matcher->toString(); + } - template - class AnyOf : public MatcherImpl, ExpressionT> { - public: +private: + Ptr> m_matcher; +}; - AnyOf() {} - AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {} +template +class AllOf : public MatcherImpl, ExpressionT> { +public: + AllOf() {} + AllOf(AllOf const &other) : m_matchers(other.m_matchers) {} + + AllOf &add(Matcher const &matcher) { + m_matchers.push_back(matcher.clone()); + return *this; + } + virtual bool match(ExpressionT const &expr) const { + for (std::size_t i = 0; i < m_matchers.size(); ++i) + if (!m_matchers[i]->match(expr)) + return false; + return true; + } + virtual std::string toString() const { + std::ostringstream oss; + oss << "( "; + for (std::size_t i = 0; i < m_matchers.size(); ++i) { + if (i != 0) + oss << " and "; + oss << m_matchers[i]->toString(); + } + oss << " )"; + return oss.str(); + } - AnyOf& add( Matcher const& matcher ) { - m_matchers.push_back( matcher.clone() ); - return *this; - } - virtual bool match( ExpressionT const& expr ) const - { - for( std::size_t i = 0; i < m_matchers.size(); ++i ) - if( m_matchers[i]->match( expr ) ) - return true; - return false; - } - virtual std::string toString() const { - std::ostringstream oss; - oss << "( "; - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if( i != 0 ) - oss << " or "; - oss << m_matchers[i]->toString(); - } - oss << " )"; - return oss.str(); - } + AllOf operator&&(Matcher const &other) const { + AllOf allOfExpr(*this); + allOfExpr.add(other); + return allOfExpr; + } - AnyOf operator || ( Matcher const& other ) const { - AnyOf anyOfExpr( *this ); - anyOfExpr.add( other ); - return anyOfExpr; - } +private: + std::vector>> m_matchers; +}; - private: - std::vector > > m_matchers; - }; +template +class AnyOf : public MatcherImpl, ExpressionT> { +public: + AnyOf() {} + AnyOf(AnyOf const &other) : m_matchers(other.m_matchers) {} + + AnyOf &add(Matcher const &matcher) { + m_matchers.push_back(matcher.clone()); + return *this; + } + virtual bool match(ExpressionT const &expr) const { + for (std::size_t i = 0; i < m_matchers.size(); ++i) + if (m_matchers[i]->match(expr)) + return true; + return false; + } + virtual std::string toString() const { + std::ostringstream oss; + oss << "( "; + for (std::size_t i = 0; i < m_matchers.size(); ++i) { + if (i != 0) + oss << " or "; + oss << m_matchers[i]->toString(); + } + oss << " )"; + return oss.str(); + } - } // namespace Generic + AnyOf operator||(Matcher const &other) const { + AnyOf anyOfExpr(*this); + anyOfExpr.add(other); + return anyOfExpr; + } - template - Generic::AllOf Matcher::operator && ( Matcher const& other ) const { - Generic::AllOf allOfExpr; - allOfExpr.add( *this ); - allOfExpr.add( other ); - return allOfExpr; - } +private: + std::vector>> m_matchers; +}; - template - Generic::AnyOf Matcher::operator || ( Matcher const& other ) const { - Generic::AnyOf anyOfExpr; - anyOfExpr.add( *this ); - anyOfExpr.add( other ); - return anyOfExpr; - } +} // namespace Generic - template - Generic::Not Matcher::operator ! () const { - return Generic::Not( *this ); - } +template +Generic::AllOf +Matcher::operator&&(Matcher const &other) const { + Generic::AllOf allOfExpr; + allOfExpr.add(*this); + allOfExpr.add(other); + return allOfExpr; +} - namespace StdString { +template +Generic::AnyOf +Matcher::operator||(Matcher const &other) const { + Generic::AnyOf anyOfExpr; + anyOfExpr.add(*this); + anyOfExpr.add(other); + return anyOfExpr; +} - inline std::string makeString( std::string const& str ) { return str; } - inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); } +template +Generic::Not Matcher::operator!() const { + return Generic::Not(*this); +} - struct CasedString - { - CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ) - : m_caseSensitivity( caseSensitivity ), - m_str( adjustString( str ) ) - {} - std::string adjustString( std::string const& str ) const { - return m_caseSensitivity == CaseSensitive::No - ? toLower( str ) - : str; +namespace StdString { - } - std::string toStringSuffix() const - { - return m_caseSensitivity == CaseSensitive::No - ? " (case insensitive)" - : ""; - } - CaseSensitive::Choice m_caseSensitivity; - std::string m_str; - }; +inline std::string makeString(std::string const &str) { return str; } +inline std::string makeString(const char *str) { + return str ? std::string(str) : std::string(); +} - struct Equals : MatcherImpl { - Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) - : m_data( str, caseSensitivity ) - {} - Equals( Equals const& other ) : m_data( other.m_data ){} +struct CasedString { + CasedString(std::string const &str, CaseSensitive::Choice caseSensitivity) + : m_caseSensitivity(caseSensitivity), m_str(adjustString(str)) {} + std::string adjustString(std::string const &str) const { + return m_caseSensitivity == CaseSensitive::No ? toLower(str) : str; + } + std::string toStringSuffix() const { + return m_caseSensitivity == CaseSensitive::No ? " (case insensitive)" : ""; + } + CaseSensitive::Choice m_caseSensitivity; + std::string m_str; +}; - virtual ~Equals(); +struct Equals : MatcherImpl { + Equals(std::string const &str, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) + : m_data(str, caseSensitivity) {} + Equals(Equals const &other) : m_data(other.m_data) {} - virtual bool match( std::string const& expr ) const { - return m_data.m_str == m_data.adjustString( expr );; - } - virtual std::string toString() const { - return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); - } + virtual ~Equals(); - CasedString m_data; - }; + virtual bool match(std::string const &expr) const { + return m_data.m_str == m_data.adjustString(expr); + ; + } + virtual std::string toString() const { + return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); + } - struct Contains : MatcherImpl { - Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) - : m_data( substr, caseSensitivity ){} - Contains( Contains const& other ) : m_data( other.m_data ){} + CasedString m_data; +}; - virtual ~Contains(); +struct Contains : MatcherImpl { + Contains(std::string const &substr, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) + : m_data(substr, caseSensitivity) {} + Contains(Contains const &other) : m_data(other.m_data) {} - virtual bool match( std::string const& expr ) const { - return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos; - } - virtual std::string toString() const { - return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); - } + virtual ~Contains(); - CasedString m_data; - }; + virtual bool match(std::string const &expr) const { + return m_data.adjustString(expr).find(m_data.m_str) != std::string::npos; + } + virtual std::string toString() const { + return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); + } - struct StartsWith : MatcherImpl { - StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) - : m_data( substr, caseSensitivity ){} + CasedString m_data; +}; - StartsWith( StartsWith const& other ) : m_data( other.m_data ){} +struct StartsWith : MatcherImpl { + StartsWith(std::string const &substr, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) + : m_data(substr, caseSensitivity) {} - virtual ~StartsWith(); + StartsWith(StartsWith const &other) : m_data(other.m_data) {} - virtual bool match( std::string const& expr ) const { - return startsWith( m_data.adjustString( expr ), m_data.m_str ); - } - virtual std::string toString() const { - return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); - } + virtual ~StartsWith(); - CasedString m_data; - }; + virtual bool match(std::string const &expr) const { + return startsWith(m_data.adjustString(expr), m_data.m_str); + } + virtual std::string toString() const { + return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); + } - struct EndsWith : MatcherImpl { - EndsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) - : m_data( substr, caseSensitivity ){} - EndsWith( EndsWith const& other ) : m_data( other.m_data ){} + CasedString m_data; +}; - virtual ~EndsWith(); +struct EndsWith : MatcherImpl { + EndsWith(std::string const &substr, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) + : m_data(substr, caseSensitivity) {} + EndsWith(EndsWith const &other) : m_data(other.m_data) {} - virtual bool match( std::string const& expr ) const { - return endsWith( m_data.adjustString( expr ), m_data.m_str ); - } - virtual std::string toString() const { - return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); - } + virtual ~EndsWith(); - CasedString m_data; - }; - } // namespace StdString - } // namespace Impl + virtual bool match(std::string const &expr) const { + return endsWith(m_data.adjustString(expr), m_data.m_str); + } + virtual std::string toString() const { + return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); + } - // The following functions create the actual matcher objects. - // This allows the types to be inferred - template - inline Impl::Generic::Not Not( Impl::Matcher const& m ) { - return Impl::Generic::Not( m ); - } + CasedString m_data; +}; +} // namespace StdString +} // namespace Impl + +// The following functions create the actual matcher objects. +// This allows the types to be inferred +template +inline Impl::Generic::Not +Not(Impl::Matcher const &m) { + return Impl::Generic::Not(m); +} - template - inline Impl::Generic::AllOf AllOf( Impl::Matcher const& m1, - Impl::Matcher const& m2 ) { - return Impl::Generic::AllOf().add( m1 ).add( m2 ); - } - template - inline Impl::Generic::AllOf AllOf( Impl::Matcher const& m1, - Impl::Matcher const& m2, - Impl::Matcher const& m3 ) { - return Impl::Generic::AllOf().add( m1 ).add( m2 ).add( m3 ); - } - template - inline Impl::Generic::AnyOf AnyOf( Impl::Matcher const& m1, - Impl::Matcher const& m2 ) { - return Impl::Generic::AnyOf().add( m1 ).add( m2 ); - } - template - inline Impl::Generic::AnyOf AnyOf( Impl::Matcher const& m1, - Impl::Matcher const& m2, - Impl::Matcher const& m3 ) { - return Impl::Generic::AnyOf().add( m1 ).add( m2 ).add( m3 ); - } +template +inline Impl::Generic::AllOf +AllOf(Impl::Matcher const &m1, + Impl::Matcher const &m2) { + return Impl::Generic::AllOf().add(m1).add(m2); +} +template +inline Impl::Generic::AllOf +AllOf(Impl::Matcher const &m1, + Impl::Matcher const &m2, + Impl::Matcher const &m3) { + return Impl::Generic::AllOf().add(m1).add(m2).add(m3); +} +template +inline Impl::Generic::AnyOf +AnyOf(Impl::Matcher const &m1, + Impl::Matcher const &m2) { + return Impl::Generic::AnyOf().add(m1).add(m2); +} +template +inline Impl::Generic::AnyOf +AnyOf(Impl::Matcher const &m1, + Impl::Matcher const &m2, + Impl::Matcher const &m3) { + return Impl::Generic::AnyOf().add(m1).add(m2).add(m3); +} - inline Impl::StdString::Equals Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) { - return Impl::StdString::Equals( str, caseSensitivity ); - } - inline Impl::StdString::Equals Equals( const char* str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) { - return Impl::StdString::Equals( Impl::StdString::makeString( str ), caseSensitivity ); - } - inline Impl::StdString::Contains Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) { - return Impl::StdString::Contains( substr, caseSensitivity ); - } - inline Impl::StdString::Contains Contains( const char* substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) { - return Impl::StdString::Contains( Impl::StdString::makeString( substr ), caseSensitivity ); - } - inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) { - return Impl::StdString::StartsWith( substr ); - } - inline Impl::StdString::StartsWith StartsWith( const char* substr ) { - return Impl::StdString::StartsWith( Impl::StdString::makeString( substr ) ); - } - inline Impl::StdString::EndsWith EndsWith( std::string const& substr ) { - return Impl::StdString::EndsWith( substr ); - } - inline Impl::StdString::EndsWith EndsWith( const char* substr ) { - return Impl::StdString::EndsWith( Impl::StdString::makeString( substr ) ); - } +inline Impl::StdString::Equals +Equals(std::string const &str, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) { + return Impl::StdString::Equals(str, caseSensitivity); +} +inline Impl::StdString::Equals +Equals(const char *str, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) { + return Impl::StdString::Equals(Impl::StdString::makeString(str), + caseSensitivity); +} +inline Impl::StdString::Contains +Contains(std::string const &substr, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) { + return Impl::StdString::Contains(substr, caseSensitivity); +} +inline Impl::StdString::Contains +Contains(const char *substr, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) { + return Impl::StdString::Contains(Impl::StdString::makeString(substr), + caseSensitivity); +} +inline Impl::StdString::StartsWith StartsWith(std::string const &substr) { + return Impl::StdString::StartsWith(substr); +} +inline Impl::StdString::StartsWith StartsWith(const char *substr) { + return Impl::StdString::StartsWith(Impl::StdString::makeString(substr)); +} +inline Impl::StdString::EndsWith EndsWith(std::string const &substr) { + return Impl::StdString::EndsWith(substr); +} +inline Impl::StdString::EndsWith EndsWith(const char *substr) { + return Impl::StdString::EndsWith(Impl::StdString::makeString(substr)); +} } // namespace Matchers @@ -1198,80 +1264,81 @@ using namespace Matchers; namespace Catch { - struct TestFailureException{}; +struct TestFailureException {}; - template class ExpressionLhs; +template class ExpressionLhs; - struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; +struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; - struct CopyableStream { - CopyableStream() {} - CopyableStream( CopyableStream const& other ) { - oss << other.oss.str(); - } - CopyableStream& operator=( CopyableStream const& other ) { - oss.str(""); - oss << other.oss.str(); - return *this; - } - std::ostringstream oss; - }; - - class ResultBuilder { - public: - ResultBuilder( char const* macroName, - SourceLineInfo const& lineInfo, - char const* capturedExpression, - ResultDisposition::Flags resultDisposition, - char const* secondArg = "" ); - - template - ExpressionLhs operator <= ( T const& operand ); - ExpressionLhs operator <= ( bool value ); - - template - ResultBuilder& operator << ( T const& value ) { - m_stream.oss << value; - return *this; - } +struct CopyableStream { + CopyableStream() {} + CopyableStream(CopyableStream const &other) { oss << other.oss.str(); } + CopyableStream &operator=(CopyableStream const &other) { + oss.str(""); + oss << other.oss.str(); + return *this; + } + std::ostringstream oss; +}; + +class ResultBuilder { +public: + ResultBuilder(char const *macroName, SourceLineInfo const &lineInfo, + char const *capturedExpression, + ResultDisposition::Flags resultDisposition, + char const *secondArg = ""); + + template ExpressionLhs operator<=(T const &operand); + ExpressionLhs operator<=(bool value); + + template ResultBuilder &operator<<(T const &value) { + m_stream.oss << value; + return *this; + } + + template + STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison & + operator&&(RhsT const &); + template + STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison & + operator||(RhsT const &); + + ResultBuilder &setResultType(ResultWas::OfType result); + ResultBuilder &setResultType(bool result); + ResultBuilder &setLhs(std::string const &lhs); + ResultBuilder &setRhs(std::string const &rhs); + ResultBuilder &setOp(std::string const &op); + + void endExpression(); + + std::string reconstructExpression() const; + AssertionResult build() const; + + void useActiveException( + ResultDisposition::Flags resultDisposition = ResultDisposition::Normal); + void captureResult(ResultWas::OfType resultType); + void captureExpression(); + void captureExpectedException(std::string const &expectedMessage); + void + captureExpectedException(Matchers::Impl::Matcher const &matcher); + void handleResult(AssertionResult const &result); + void react(); + bool shouldDebugBreak() const; + bool allowThrows() const; - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& ); - - ResultBuilder& setResultType( ResultWas::OfType result ); - ResultBuilder& setResultType( bool result ); - ResultBuilder& setLhs( std::string const& lhs ); - ResultBuilder& setRhs( std::string const& rhs ); - ResultBuilder& setOp( std::string const& op ); - - void endExpression(); - - std::string reconstructExpression() const; - AssertionResult build() const; - - void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal ); - void captureResult( ResultWas::OfType resultType ); - void captureExpression(); - void captureExpectedException( std::string const& expectedMessage ); - void captureExpectedException( Matchers::Impl::Matcher const& matcher ); - void handleResult( AssertionResult const& result ); - void react(); - bool shouldDebugBreak() const; - bool allowThrows() const; - - private: - AssertionInfo m_assertionInfo; - AssertionResultData m_data; - struct ExprComponents { - ExprComponents() : testFalse( false ) {} - bool testFalse; - std::string lhs, rhs, op; - } m_exprComponents; - CopyableStream m_stream; - - bool m_shouldDebugBreak; - bool m_shouldThrow; - }; +private: + AssertionInfo m_assertionInfo; + AssertionResultData m_data; + struct ExprComponents { + ExprComponents() : testFalse(false) {} + bool testFalse; + std::string lhs, rhs, op; + } m_exprComponents; + CopyableStream m_stream; + + bool m_shouldDebugBreak; + bool m_shouldThrow; +}; } // namespace Catch @@ -1284,7 +1351,7 @@ namespace Catch { #ifdef _MSC_VER #pragma warning(push) -#pragma warning(disable:4389) // '==' : signed/unsigned mismatch +#pragma warning(disable : 4389) // '==' : signed/unsigned mismatch #endif #include @@ -1292,193 +1359,204 @@ namespace Catch { namespace Catch { namespace Internal { - enum Operator { - IsEqualTo, - IsNotEqualTo, - IsLessThan, - IsGreaterThan, - IsLessThanOrEqualTo, - IsGreaterThanOrEqualTo - }; - - template struct OperatorTraits { static const char* getName(){ return "*error*"; } }; - template<> struct OperatorTraits { static const char* getName(){ return "=="; } }; - template<> struct OperatorTraits { static const char* getName(){ return "!="; } }; - template<> struct OperatorTraits { static const char* getName(){ return "<"; } }; - template<> struct OperatorTraits { static const char* getName(){ return ">"; } }; - template<> struct OperatorTraits { static const char* getName(){ return "<="; } }; - template<> struct OperatorTraits{ static const char* getName(){ return ">="; } }; - - template - inline T& opCast(T const& t) { return const_cast(t); } +enum Operator { + IsEqualTo, + IsNotEqualTo, + IsLessThan, + IsGreaterThan, + IsLessThanOrEqualTo, + IsGreaterThanOrEqualTo +}; + +template struct OperatorTraits { + static const char *getName() { return "*error*"; } +}; +template <> struct OperatorTraits { + static const char *getName() { return "=="; } +}; +template <> struct OperatorTraits { + static const char *getName() { return "!="; } +}; +template <> struct OperatorTraits { + static const char *getName() { return "<"; } +}; +template <> struct OperatorTraits { + static const char *getName() { return ">"; } +}; +template <> struct OperatorTraits { + static const char *getName() { return "<="; } +}; +template <> struct OperatorTraits { + static const char *getName() { return ">="; } +}; + +template inline T &opCast(T const &t) { + return const_cast(t); +} // nullptr_t support based on pull request #154 from Konstantin Baumann #ifdef CATCH_CONFIG_CPP11_NULLPTR - inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; } +inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; } #endif // CATCH_CONFIG_CPP11_NULLPTR - // So the compare overloads can be operator agnostic we convey the operator as a template - // enum, which is used to specialise an Evaluator for doing the comparison. - template - class Evaluator{}; - - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs) { - return bool( opCast( lhs ) == opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) != opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) < opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) > opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) >= opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) <= opCast( rhs ) ); - } - }; - - template - bool applyEvaluator( T1 const& lhs, T2 const& rhs ) { - return Evaluator::evaluate( lhs, rhs ); - } - - // This level of indirection allows us to specialise for integer types - // to avoid signed/ unsigned warnings +// So the compare overloads can be operator agnostic we convey the operator as a +// template enum, which is used to specialise an Evaluator for doing the +// comparison. +template class Evaluator {}; - // "base" overload - template - bool compare( T1 const& lhs, T2 const& rhs ) { - return Evaluator::evaluate( lhs, rhs ); - } +template struct Evaluator { + static bool evaluate(T1 const &lhs, T2 const &rhs) { + return bool(opCast(lhs) == opCast(rhs)); + } +}; +template struct Evaluator { + static bool evaluate(T1 const &lhs, T2 const &rhs) { + return bool(opCast(lhs) != opCast(rhs)); + } +}; +template struct Evaluator { + static bool evaluate(T1 const &lhs, T2 const &rhs) { + return bool(opCast(lhs) < opCast(rhs)); + } +}; +template struct Evaluator { + static bool evaluate(T1 const &lhs, T2 const &rhs) { + return bool(opCast(lhs) > opCast(rhs)); + } +}; +template +struct Evaluator { + static bool evaluate(T1 const &lhs, T2 const &rhs) { + return bool(opCast(lhs) >= opCast(rhs)); + } +}; +template +struct Evaluator { + static bool evaluate(T1 const &lhs, T2 const &rhs) { + return bool(opCast(lhs) <= opCast(rhs)); + } +}; - // unsigned X to int - template bool compare( unsigned int lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned long lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned char lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } +template +bool applyEvaluator(T1 const &lhs, T2 const &rhs) { + return Evaluator::evaluate(lhs, rhs); +} - // unsigned X to long - template bool compare( unsigned int lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned long lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned char lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } +// This level of indirection allows us to specialise for integer types +// to avoid signed/ unsigned warnings - // int to unsigned X - template bool compare( int lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( int lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( int lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } +// "base" overload +template +bool compare(T1 const &lhs, T2 const &rhs) { + return Evaluator::evaluate(lhs, rhs); +} - // long to unsigned X - template bool compare( long lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } +// unsigned X to int +template bool compare(unsigned int lhs, int rhs) { + return applyEvaluator(lhs, static_cast(rhs)); +} +template bool compare(unsigned long lhs, int rhs) { + return applyEvaluator(lhs, static_cast(rhs)); +} +template bool compare(unsigned char lhs, int rhs) { + return applyEvaluator(lhs, static_cast(rhs)); +} - // pointer to long (when comparing against NULL) - template bool compare( long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } +// unsigned X to long +template bool compare(unsigned int lhs, long rhs) { + return applyEvaluator(lhs, static_cast(rhs)); +} +template bool compare(unsigned long lhs, long rhs) { + return applyEvaluator(lhs, static_cast(rhs)); +} +template bool compare(unsigned char lhs, long rhs) { + return applyEvaluator(lhs, static_cast(rhs)); +} - // pointer to int (when comparing against NULL) - template bool compare( int lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, int rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } +// int to unsigned X +template bool compare(int lhs, unsigned int rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(int lhs, unsigned long rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(int lhs, unsigned char rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} + +// long to unsigned X +template bool compare(long lhs, unsigned int rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(long lhs, unsigned long rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(long lhs, unsigned char rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} + +// pointer to long (when comparing against NULL) +template bool compare(long lhs, T *rhs) { + return Evaluator::evaluate(reinterpret_cast(lhs), rhs); +} +template bool compare(T *lhs, long rhs) { + return Evaluator::evaluate(lhs, reinterpret_cast(rhs)); +} + +// pointer to int (when comparing against NULL) +template bool compare(int lhs, T *rhs) { + return Evaluator::evaluate(reinterpret_cast(lhs), rhs); +} +template bool compare(T *lhs, int rhs) { + return Evaluator::evaluate(lhs, reinterpret_cast(rhs)); +} #ifdef CATCH_CONFIG_CPP11_LONG_LONG - // long long to unsigned X - template bool compare( long long lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned long long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } +// long long to unsigned X +template bool compare(long long lhs, unsigned int rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(long long lhs, unsigned long rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(long long lhs, unsigned long long rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(long long lhs, unsigned char rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} - // unsigned long long to X - template bool compare( unsigned long long lhs, int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, long long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } +// unsigned long long to X +template bool compare(unsigned long long lhs, int rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(unsigned long long lhs, long rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(unsigned long long lhs, long long rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} +template bool compare(unsigned long long lhs, char rhs) { + return applyEvaluator(static_cast(lhs), rhs); +} - // pointer to long long (when comparing against NULL) - template bool compare( long long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, long long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } +// pointer to long long (when comparing against NULL) +template bool compare(long long lhs, T *rhs) { + return Evaluator::evaluate(reinterpret_cast(lhs), rhs); +} +template bool compare(T *lhs, long long rhs) { + return Evaluator::evaluate(lhs, reinterpret_cast(rhs)); +} #endif // CATCH_CONFIG_CPP11_LONG_LONG #ifdef CATCH_CONFIG_CPP11_NULLPTR - // pointer to nullptr_t (when comparing against nullptr) - template bool compare( std::nullptr_t, T* rhs ) { - return Evaluator::evaluate( nullptr, rhs ); - } - template bool compare( T* lhs, std::nullptr_t ) { - return Evaluator::evaluate( lhs, nullptr ); - } +// pointer to nullptr_t (when comparing against nullptr) +template bool compare(std::nullptr_t, T *rhs) { + return Evaluator::evaluate(nullptr, rhs); +} +template bool compare(T *lhs, std::nullptr_t) { + return Evaluator::evaluate(lhs, nullptr); +} #endif // CATCH_CONFIG_CPP11_NULLPTR } // end of namespace Internal @@ -1491,11 +1569,11 @@ namespace Internal { // #included from: catch_tostring.h #define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED -#include +#include #include #include +#include #include -#include #ifdef __OBJC__ // #included from: catch_objc_arc.hpp @@ -1509,33 +1587,31 @@ namespace Internal { #define CATCH_ARC_ENABLED 0 #endif -void arcSafeRelease( NSObject* obj ); -id performOptionalSelector( id obj, SEL sel ); +void arcSafeRelease(NSObject *obj); +id performOptionalSelector(id obj, SEL sel); #if !CATCH_ARC_ENABLED -inline void arcSafeRelease( NSObject* obj ) { - [obj release]; -} -inline id performOptionalSelector( id obj, SEL sel ) { - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; - return nil; +inline void arcSafeRelease(NSObject *obj) { [obj release]; } +inline id performOptionalSelector(id obj, SEL sel) { + if ([obj respondsToSelector:sel]) + return [obj performSelector:sel]; + return nil; } #define CATCH_UNSAFE_UNRETAINED #define CATCH_ARC_STRONG #else -inline void arcSafeRelease( NSObject* ){} -inline id performOptionalSelector( id obj, SEL sel ) { +inline void arcSafeRelease(NSObject *) {} +inline id performOptionalSelector(id obj, SEL sel) { #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-performSelector-leaks" #endif - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; + if ([obj respondsToSelector:sel]) + return [obj performSelector:sel]; #ifdef __clang__ #pragma clang diagnostic pop #endif - return nil; + return nil; } #define CATCH_UNSAFE_UNRETAINED __unsafe_unretained #define CATCH_ARC_STRONG __strong @@ -1554,207 +1630,183 @@ inline id performOptionalSelector( id obj, SEL sel ) { namespace Catch { // Why we're here. -template -std::string toString( T const& value ); +template std::string toString(T const &value); // Built in overloads -std::string toString( std::string const& value ); -std::string toString( std::wstring const& value ); -std::string toString( const char* const value ); -std::string toString( char* const value ); -std::string toString( const wchar_t* const value ); -std::string toString( wchar_t* const value ); -std::string toString( int value ); -std::string toString( unsigned long value ); -std::string toString( unsigned int value ); -std::string toString( const double value ); -std::string toString( const float value ); -std::string toString( bool value ); -std::string toString( char value ); -std::string toString( signed char value ); -std::string toString( unsigned char value ); +std::string toString(std::string const &value); +std::string toString(std::wstring const &value); +std::string toString(const char *const value); +std::string toString(char *const value); +std::string toString(const wchar_t *const value); +std::string toString(wchar_t *const value); +std::string toString(int value); +std::string toString(unsigned long value); +std::string toString(unsigned int value); +std::string toString(const double value); +std::string toString(const float value); +std::string toString(bool value); +std::string toString(char value); +std::string toString(signed char value); +std::string toString(unsigned char value); #ifdef CATCH_CONFIG_CPP11_LONG_LONG -std::string toString( long long value ); -std::string toString( unsigned long long value ); +std::string toString(long long value); +std::string toString(unsigned long long value); #endif #ifdef CATCH_CONFIG_CPP11_NULLPTR -std::string toString( std::nullptr_t ); +std::string toString(std::nullptr_t); #endif #ifdef __OBJC__ - std::string toString( NSString const * const& nsstring ); - std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ); - std::string toString( NSObject* const& nsObject ); +std::string toString(NSString const *const &nsstring); +std::string toString(NSString *CATCH_ARC_STRONG const &nsstring); +std::string toString(NSObject *const &nsObject); #endif namespace Detail { - extern const std::string unprintableString; +extern const std::string unprintableString; - struct BorgType { - template BorgType( T const& ); - }; +struct BorgType { + template BorgType(T const &); +}; - struct TrueType { char sizer[1]; }; - struct FalseType { char sizer[2]; }; +struct TrueType { + char sizer[1]; +}; +struct FalseType { + char sizer[2]; +}; - TrueType& testStreamable( std::ostream& ); - FalseType testStreamable( FalseType ); +TrueType &testStreamable(std::ostream &); +FalseType testStreamable(FalseType); - FalseType operator<<( std::ostream const&, BorgType const& ); +FalseType operator<<(std::ostream const &, BorgType const &); - template - struct IsStreamInsertable { - static std::ostream &s; - static T const&t; - enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; - }; +template struct IsStreamInsertable { + static std::ostream &s; + static T const &t; + enum { value = sizeof(testStreamable(s << t)) == sizeof(TrueType) }; +}; #if defined(CATCH_CONFIG_CPP11_IS_ENUM) - template::value - > - struct EnumStringMaker - { - static std::string convert( T const& ) { return unprintableString; } - }; +template ::value> +struct EnumStringMaker { + static std::string convert(T const &) { return unprintableString; } +}; - template - struct EnumStringMaker - { - static std::string convert( T const& v ) - { - return ::Catch::toString( - static_cast::type>(v) - ); - } - }; +template struct EnumStringMaker { + static std::string convert(T const &v) { + return ::Catch::toString( + static_cast::type>(v)); + } +}; #endif - template - struct StringMakerBase { +template struct StringMakerBase { #if defined(CATCH_CONFIG_CPP11_IS_ENUM) - template - static std::string convert( T const& v ) - { - return EnumStringMaker::convert( v ); - } + template static std::string convert(T const &v) { + return EnumStringMaker::convert(v); + } #else - template - static std::string convert( T const& ) { return unprintableString; } -#endif - }; - - template<> - struct StringMakerBase { - template - static std::string convert( T const& _value ) { - std::ostringstream oss; - oss << _value; - return oss.str(); - } - }; + template static std::string convert(T const &) { + return unprintableString; + } +#endif +}; + +template <> struct StringMakerBase { + template static std::string convert(T const &_value) { + std::ostringstream oss; + oss << _value; + return oss.str(); + } +}; - std::string rawMemoryToString( const void *object, std::size_t size ); +std::string rawMemoryToString(const void *object, std::size_t size); - template - inline std::string rawMemoryToString( const T& object ) { - return rawMemoryToString( &object, sizeof(object) ); - } +template inline std::string rawMemoryToString(const T &object) { + return rawMemoryToString(&object, sizeof(object)); +} } // end namespace Detail -template -struct StringMaker : - Detail::StringMakerBase::value> {}; +template +struct StringMaker + : Detail::StringMakerBase::value> {}; -template -struct StringMaker { - template - static std::string convert( U* p ) { - if( !p ) - return "NULL"; - else - return Detail::rawMemoryToString( p ); - } +template struct StringMaker { + template static std::string convert(U *p) { + if (!p) + return "NULL"; + else + return Detail::rawMemoryToString(p); + } }; -template -struct StringMaker { - static std::string convert( R C::* p ) { - if( !p ) - return "NULL"; - else - return Detail::rawMemoryToString( p ); - } +template struct StringMaker { + static std::string convert(R C::*p) { + if (!p) + return "NULL"; + else + return Detail::rawMemoryToString(p); + } }; namespace Detail { - template - std::string rangeToString( InputIterator first, InputIterator last ); +template +std::string rangeToString(InputIterator first, InputIterator last); } -//template -//struct StringMaker > { -// static std::string convert( std::vector const& v ) { -// return Detail::rangeToString( v.begin(), v.end() ); -// } -//}; +// template +// struct StringMaker > { +// static std::string convert( std::vector const& v ) { +// return Detail::rangeToString( v.begin(), v.end() ); +// } +// }; -template -std::string toString( std::vector const& v ) { - return Detail::rangeToString( v.begin(), v.end() ); +template +std::string toString(std::vector const &v) { + return Detail::rangeToString(v.begin(), v.end()); } #ifdef CATCH_CONFIG_CPP11_TUPLE // toString for tuples namespace TupleDetail { - template< - typename Tuple, - std::size_t N = 0, - bool = (N < std::tuple_size::value) - > - struct ElementPrinter { - static void print( const Tuple& tuple, std::ostream& os ) - { - os << ( N ? ", " : " " ) - << Catch::toString(std::get(tuple)); - ElementPrinter::print(tuple,os); - } - }; +template ::value)> +struct ElementPrinter { + static void print(const Tuple &tuple, std::ostream &os) { + os << (N ? ", " : " ") << Catch::toString(std::get(tuple)); + ElementPrinter::print(tuple, os); + } +}; - template< - typename Tuple, - std::size_t N - > - struct ElementPrinter { - static void print( const Tuple&, std::ostream& ) {} - }; +template +struct ElementPrinter { + static void print(const Tuple &, std::ostream &) {} +}; -} +} // namespace TupleDetail -template -struct StringMaker> { +template struct StringMaker> { - static std::string convert( const std::tuple& tuple ) - { - std::ostringstream os; - os << '{'; - TupleDetail::ElementPrinter>::print( tuple, os ); - os << " }"; - return os.str(); - } + static std::string convert(const std::tuple &tuple) { + std::ostringstream os; + os << '{'; + TupleDetail::ElementPrinter>::print(tuple, os); + os << " }"; + return os.str(); + } }; #endif // CATCH_CONFIG_CPP11_TUPLE namespace Detail { - template - std::string makeString( T const& value ) { - return StringMaker::convert( value ); - } +template std::string makeString(T const &value) { + return StringMaker::convert(value); +} } // end namespace Detail /// \brief converts any type to a string @@ -1764,129 +1816,129 @@ namespace Detail { /// that and writes {?}. /// Overload (not specialise) this template for custom typs that you don't want /// to provide an ostream overload for. -template -std::string toString( T const& value ) { - return StringMaker::convert( value ); -} - - namespace Detail { - template - std::string rangeToString( InputIterator first, InputIterator last ) { - std::ostringstream oss; - oss << "{ "; - if( first != last ) { - oss << Catch::toString( *first ); - for( ++first ; first != last ; ++first ) - oss << ", " << Catch::toString( *first ); - } - oss << " }"; - return oss.str(); - } +template std::string toString(T const &value) { + return StringMaker::convert(value); } +namespace Detail { +template +std::string rangeToString(InputIterator first, InputIterator last) { + std::ostringstream oss; + oss << "{ "; + if (first != last) { + oss << Catch::toString(*first); + for (++first; first != last; ++first) + oss << ", " << Catch::toString(*first); + } + oss << " }"; + return oss.str(); +} +} // namespace Detail + } // end namespace Catch namespace Catch { // Wraps the LHS of an expression and captures the operator and RHS (if any) - // wrapping them all in a ResultBuilder object -template -class ExpressionLhs { - ExpressionLhs& operator = ( ExpressionLhs const& ); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - ExpressionLhs& operator = ( ExpressionLhs && ) = delete; -# endif +template class ExpressionLhs { + ExpressionLhs &operator=(ExpressionLhs const &); +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS + ExpressionLhs &operator=(ExpressionLhs &&) = delete; +#endif public: - ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {} -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - ExpressionLhs( ExpressionLhs const& ) = default; - ExpressionLhs( ExpressionLhs && ) = default; -# endif - - template - ResultBuilder& operator == ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ResultBuilder& operator != ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ResultBuilder& operator < ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ResultBuilder& operator > ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ResultBuilder& operator <= ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ResultBuilder& operator >= ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - ResultBuilder& operator == ( bool rhs ) { - return captureExpression( rhs ); - } - - ResultBuilder& operator != ( bool rhs ) { - return captureExpression( rhs ); - } - - void endExpression() { - bool value = m_lhs ? true : false; - m_rb - .setLhs( Catch::toString( value ) ) - .setResultType( value ) - .endExpression(); - } + ExpressionLhs(ResultBuilder &rb, T lhs) : m_rb(rb), m_lhs(lhs) {} +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS + ExpressionLhs(ExpressionLhs const &) = default; + ExpressionLhs(ExpressionLhs &&) = default; +#endif - // Only simple binary expressions are allowed on the LHS. - // If more complex compositions are required then place the sub expression in parentheses - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& ); + template ResultBuilder &operator==(RhsT const &rhs) { + return captureExpression(rhs); + } + + template ResultBuilder &operator!=(RhsT const &rhs) { + return captureExpression(rhs); + } + + template ResultBuilder &operator<(RhsT const &rhs) { + return captureExpression(rhs); + } + + template ResultBuilder &operator>(RhsT const &rhs) { + return captureExpression(rhs); + } + + template ResultBuilder &operator<=(RhsT const &rhs) { + return captureExpression(rhs); + } + + template ResultBuilder &operator>=(RhsT const &rhs) { + return captureExpression(rhs); + } + + ResultBuilder &operator==(bool rhs) { + return captureExpression(rhs); + } + + ResultBuilder &operator!=(bool rhs) { + return captureExpression(rhs); + } + + void endExpression() { + bool value = m_lhs ? true : false; + m_rb.setLhs(Catch::toString(value)).setResultType(value).endExpression(); + } + + // Only simple binary expressions are allowed on the LHS. + // If more complex compositions are required then place the sub expression in + // parentheses + template + STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison & + operator+(RhsT const &); + template + STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison & + operator-(RhsT const &); + template + STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison & + operator/(RhsT const &); + template + STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison & + operator*(RhsT const &); + template + STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison & + operator&&(RhsT const &); + template + STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison & + operator||(RhsT const &); private: - template - ResultBuilder& captureExpression( RhsT const& rhs ) { - return m_rb - .setResultType( Internal::compare( m_lhs, rhs ) ) - .setLhs( Catch::toString( m_lhs ) ) - .setRhs( Catch::toString( rhs ) ) - .setOp( Internal::OperatorTraits::getName() ); - } + template + ResultBuilder &captureExpression(RhsT const &rhs) { + return m_rb.setResultType(Internal::compare(m_lhs, rhs)) + .setLhs(Catch::toString(m_lhs)) + .setRhs(Catch::toString(rhs)) + .setOp(Internal::OperatorTraits::getName()); + } private: - ResultBuilder& m_rb; - T m_lhs; + ResultBuilder &m_rb; + T m_lhs; }; } // end namespace Catch - namespace Catch { - template - inline ExpressionLhs ResultBuilder::operator <= ( T const& operand ) { - return ExpressionLhs( *this, operand ); - } +template +inline ExpressionLhs ResultBuilder::operator<=(T const &operand) { + return ExpressionLhs(*this, operand); +} - inline ExpressionLhs ResultBuilder::operator <= ( bool value ) { - return ExpressionLhs( *this, value ); - } +inline ExpressionLhs ResultBuilder::operator<=(bool value) { + return ExpressionLhs(*this, value); +} } // namespace Catch @@ -1897,52 +1949,49 @@ namespace Catch { namespace Catch { - struct MessageInfo { - MessageInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ); +struct MessageInfo { + MessageInfo(std::string const &_macroName, SourceLineInfo const &_lineInfo, + ResultWas::OfType _type); - std::string macroName; - SourceLineInfo lineInfo; - ResultWas::OfType type; - std::string message; - unsigned int sequence; + std::string macroName; + SourceLineInfo lineInfo; + ResultWas::OfType type; + std::string message; + unsigned int sequence; - bool operator == ( MessageInfo const& other ) const { - return sequence == other.sequence; - } - bool operator < ( MessageInfo const& other ) const { - return sequence < other.sequence; - } - private: - static unsigned int globalCount; - }; - - struct MessageBuilder { - MessageBuilder( std::string const& macroName, - SourceLineInfo const& lineInfo, - ResultWas::OfType type ) - : m_info( macroName, lineInfo, type ) - {} - - template - MessageBuilder& operator << ( T const& value ) { - m_stream << value; - return *this; - } + bool operator==(MessageInfo const &other) const { + return sequence == other.sequence; + } + bool operator<(MessageInfo const &other) const { + return sequence < other.sequence; + } + +private: + static unsigned int globalCount; +}; + +struct MessageBuilder { + MessageBuilder(std::string const ¯oName, SourceLineInfo const &lineInfo, + ResultWas::OfType type) + : m_info(macroName, lineInfo, type) {} - MessageInfo m_info; - std::ostringstream m_stream; - }; + template MessageBuilder &operator<<(T const &value) { + m_stream << value; + return *this; + } + + MessageInfo m_info; + std::ostringstream m_stream; +}; - class ScopedMessage { - public: - ScopedMessage( MessageBuilder const& builder ); - ScopedMessage( ScopedMessage const& other ); - ~ScopedMessage(); +class ScopedMessage { +public: + ScopedMessage(MessageBuilder const &builder); + ScopedMessage(ScopedMessage const &other); + ~ScopedMessage(); - MessageInfo m_info; - }; + MessageInfo m_info; +}; } // end namespace Catch @@ -1953,35 +2002,35 @@ namespace Catch { namespace Catch { - class TestCase; - class AssertionResult; - struct AssertionInfo; - struct SectionInfo; - struct SectionEndInfo; - struct MessageInfo; - class ScopedMessageBuilder; - struct Counts; +class TestCase; +class AssertionResult; +struct AssertionInfo; +struct SectionInfo; +struct SectionEndInfo; +struct MessageInfo; +class ScopedMessageBuilder; +struct Counts; - struct IResultCapture { +struct IResultCapture { - virtual ~IResultCapture(); + virtual ~IResultCapture(); - virtual void assertionEnded( AssertionResult const& result ) = 0; - virtual bool sectionStarted( SectionInfo const& sectionInfo, - Counts& assertions ) = 0; - virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; - virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; - virtual void pushScopedMessage( MessageInfo const& message ) = 0; - virtual void popScopedMessage( MessageInfo const& message ) = 0; + virtual void assertionEnded(AssertionResult const &result) = 0; + virtual bool sectionStarted(SectionInfo const §ionInfo, + Counts &assertions) = 0; + virtual void sectionEnded(SectionEndInfo const &endInfo) = 0; + virtual void sectionEndedEarly(SectionEndInfo const &endInfo) = 0; + virtual void pushScopedMessage(MessageInfo const &message) = 0; + virtual void popScopedMessage(MessageInfo const &message) = 0; - virtual std::string getCurrentTestName() const = 0; - virtual const AssertionResult* getLastResult() const = 0; + virtual std::string getCurrentTestName() const = 0; + virtual const AssertionResult *getLastResult() const = 0; - virtual void handleFatalErrorCondition( std::string const& message ) = 0; - }; + virtual void handleFatalErrorCondition(std::string const &message) = 0; +}; - IResultCapture& getResultCapture(); -} +IResultCapture &getResultCapture(); +} // namespace Catch // #included from: catch_debugger.h #define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED @@ -1991,41 +2040,53 @@ namespace Catch { #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) #define CATCH_PLATFORM_MAC -#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #define CATCH_PLATFORM_IPHONE -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || \ + defined(_MSC_VER) #define CATCH_PLATFORM_WINDOWS #endif #include -namespace Catch{ +namespace Catch { - bool isDebuggerActive(); - void writeToDebugConsole( std::string const& text ); -} +bool isDebuggerActive(); +void writeToDebugConsole(std::string const &text); +} // namespace Catch #ifdef CATCH_PLATFORM_MAC - // The following code snippet based on: - // http://cocoawithlove.com/2008/03/break-into-debugger.html - #ifdef DEBUG - #if defined(__ppc64__) || defined(__ppc__) - #define CATCH_BREAK_INTO_DEBUGGER() \ - if( Catch::isDebuggerActive() ) { \ - __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ - : : : "memory","r0","r3","r4" ); \ - } - #else - #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );} - #endif - #endif +// The following code snippet based on: +// http://cocoawithlove.com/2008/03/break-into-debugger.html +#ifdef DEBUG +#if defined(__ppc64__) || defined(__ppc__) +#define CATCH_BREAK_INTO_DEBUGGER() \ + if (Catch::isDebuggerActive()) { \ + __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ + : \ + : \ + : "memory", "r0", "r3", "r4"); \ + } +#else +#define CATCH_BREAK_INTO_DEBUGGER() \ + if (Catch::isDebuggerActive()) { \ + __asm__("int $3\n" : :); \ + } +#endif +#endif #elif defined(_MSC_VER) - #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); } +#define CATCH_BREAK_INTO_DEBUGGER() \ + if (Catch::isDebuggerActive()) { \ + __debugbreak(); \ + } #elif defined(__MINGW32__) - extern "C" __declspec(dllimport) void __stdcall DebugBreak(); - #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); } +extern "C" __declspec(dllimport) void __stdcall DebugBreak(); +#define CATCH_BREAK_INTO_DEBUGGER() \ + if (Catch::isDebuggerActive()) { \ + DebugBreak(); \ + } #endif #ifndef CATCH_BREAK_INTO_DEBUGGER @@ -2036,138 +2097,150 @@ namespace Catch{ #define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED namespace Catch { - class TestCase; +class TestCase; - struct IRunner { - virtual ~IRunner(); - virtual bool aborting() const = 0; - }; -} +struct IRunner { + virtual ~IRunner(); + virtual bool aborting() const = 0; +}; +} // namespace Catch /////////////////////////////////////////////////////////////////////////////// // In the event of a failure works out if the debugger needs to be invoked // and/or an exception thrown and takes appropriate action. // This needs to be done as a macro so the debugger will stop in the user // source code rather than in Catch library code -#define INTERNAL_CATCH_REACT( resultBuilder ) \ - if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \ - resultBuilder.react(); +#define INTERNAL_CATCH_REACT(resultBuilder) \ + if (resultBuilder.shouldDebugBreak()) \ + CATCH_BREAK_INTO_DEBUGGER(); \ + resultBuilder.react(); /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - try { \ - CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - ( __catchResult <= expr ).endExpression(); \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( Catch::ResultDisposition::Normal ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::isTrue( false && static_cast(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look +#define INTERNAL_CATCH_TEST(expr, resultDisposition, macroName) \ + do { \ + Catch::ResultBuilder __catchResult(macroName, CATCH_INTERNAL_LINEINFO, \ + #expr, resultDisposition); \ + try { \ + CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS(__catchResult <= expr) \ + .endExpression(); \ + } catch (...) { \ + __catchResult.useActiveException(Catch::ResultDisposition::Normal); \ + } \ + INTERNAL_CATCH_REACT(__catchResult) \ + } while (Catch::isTrue( \ + false && \ + static_cast(expr))) // expr here is never evaluated at runtime but + // it forces the compiler to give it a look /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ - INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ - if( Catch::getResultCapture().getLastResult()->succeeded() ) +#define INTERNAL_CATCH_IF(expr, resultDisposition, macroName) \ + INTERNAL_CATCH_TEST(expr, resultDisposition, macroName); \ + if (Catch::getResultCapture().getLastResult()->succeeded()) /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \ - INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ - if( !Catch::getResultCapture().getLastResult()->succeeded() ) +#define INTERNAL_CATCH_ELSE(expr, resultDisposition, macroName) \ + INTERNAL_CATCH_TEST(expr, resultDisposition, macroName); \ + if (!Catch::getResultCapture().getLastResult()->succeeded()) /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - try { \ - expr; \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( resultDisposition ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) +#define INTERNAL_CATCH_NO_THROW(expr, resultDisposition, macroName) \ + do { \ + Catch::ResultBuilder __catchResult(macroName, CATCH_INTERNAL_LINEINFO, \ + #expr, resultDisposition); \ + try { \ + expr; \ + __catchResult.captureResult(Catch::ResultWas::Ok); \ + } catch (...) { \ + __catchResult.useActiveException(resultDisposition); \ + } \ + INTERNAL_CATCH_REACT(__catchResult) \ + } while (Catch::alwaysFalse()) /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \ - if( __catchResult.allowThrows() ) \ - try { \ - expr; \ - __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ - } \ - catch( ... ) { \ - __catchResult.captureExpectedException( matcher ); \ - } \ - else \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) +#define INTERNAL_CATCH_THROWS(expr, resultDisposition, matcher, macroName) \ + do { \ + Catch::ResultBuilder __catchResult(macroName, CATCH_INTERNAL_LINEINFO, \ + #expr, resultDisposition, #matcher); \ + if (__catchResult.allowThrows()) \ + try { \ + expr; \ + __catchResult.captureResult(Catch::ResultWas::DidntThrowException); \ + } catch (...) { \ + __catchResult.captureExpectedException(matcher); \ + } \ + else \ + __catchResult.captureResult(Catch::ResultWas::Ok); \ + INTERNAL_CATCH_REACT(__catchResult) \ + } while (Catch::alwaysFalse()) /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - if( __catchResult.allowThrows() ) \ - try { \ - expr; \ - __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ - } \ - catch( exceptionType ) { \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( resultDisposition ); \ - } \ - else \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) +#define INTERNAL_CATCH_THROWS_AS(expr, exceptionType, resultDisposition, \ + macroName) \ + do { \ + Catch::ResultBuilder __catchResult(macroName, CATCH_INTERNAL_LINEINFO, \ + #expr, resultDisposition); \ + if (__catchResult.allowThrows()) \ + try { \ + expr; \ + __catchResult.captureResult(Catch::ResultWas::DidntThrowException); \ + } catch (exceptionType) { \ + __catchResult.captureResult(Catch::ResultWas::Ok); \ + } catch (...) { \ + __catchResult.useActiveException(resultDisposition); \ + } \ + else \ + __catchResult.captureResult(Catch::ResultWas::Ok); \ + INTERNAL_CATCH_REACT(__catchResult) \ + } while (Catch::alwaysFalse()) /////////////////////////////////////////////////////////////////////////////// #ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ - __catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \ - __catchResult.captureResult( messageType ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) +#define INTERNAL_CATCH_MSG(messageType, resultDisposition, macroName, ...) \ + do { \ + Catch::ResultBuilder __catchResult(macroName, CATCH_INTERNAL_LINEINFO, "", \ + resultDisposition); \ + __catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \ + __catchResult.captureResult(messageType); \ + INTERNAL_CATCH_REACT(__catchResult) \ + } while (Catch::alwaysFalse()) #else - #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ - __catchResult << log + ::Catch::StreamEndStop(); \ - __catchResult.captureResult( messageType ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) +#define INTERNAL_CATCH_MSG(messageType, resultDisposition, macroName, log) \ + do { \ + Catch::ResultBuilder __catchResult(macroName, CATCH_INTERNAL_LINEINFO, "", \ + resultDisposition); \ + __catchResult << log + ::Catch::StreamEndStop(); \ + __catchResult.captureResult(messageType); \ + INTERNAL_CATCH_REACT(__catchResult) \ + } while (Catch::alwaysFalse()) #endif /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_INFO( log, macroName ) \ - Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log; +#define INTERNAL_CATCH_INFO(log, macroName) \ + Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME(scopedMessage) = \ + Catch::MessageBuilder(macroName, CATCH_INTERNAL_LINEINFO, \ + Catch::ResultWas::Info) \ + << log; /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \ - try { \ - std::string matcherAsString = (matcher).toString(); \ - __catchResult \ - .setLhs( Catch::toString( arg ) ) \ - .setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \ - .setOp( "matches" ) \ - .setResultType( (matcher).match( arg ) ); \ - __catchResult.captureExpression(); \ - } catch( ... ) { \ - __catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) +#define INTERNAL_CHECK_THAT(arg, matcher, resultDisposition, macroName) \ + do { \ + Catch::ResultBuilder __catchResult(macroName, CATCH_INTERNAL_LINEINFO, \ + #arg ", " #matcher, resultDisposition); \ + try { \ + std::string matcherAsString = (matcher).toString(); \ + __catchResult.setLhs(Catch::toString(arg)) \ + .setRhs(matcherAsString == Catch::Detail::unprintableString \ + ? #matcher \ + : matcherAsString) \ + .setOp("matches") \ + .setResultType((matcher).match(arg)); \ + __catchResult.captureExpression(); \ + } catch (...) { \ + __catchResult.useActiveException( \ + resultDisposition | Catch::ResultDisposition::ContinueOnFailure); \ + } \ + INTERNAL_CATCH_REACT(__catchResult) \ + } while (Catch::alwaysFalse()) // #included from: internal/catch_section.h #define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED @@ -2182,91 +2255,84 @@ namespace Catch { namespace Catch { - struct Counts { - Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {} - - Counts operator - ( Counts const& other ) const { - Counts diff; - diff.passed = passed - other.passed; - diff.failed = failed - other.failed; - diff.failedButOk = failedButOk - other.failedButOk; - return diff; - } - Counts& operator += ( Counts const& other ) { - passed += other.passed; - failed += other.failed; - failedButOk += other.failedButOk; - return *this; - } - - std::size_t total() const { - return passed + failed + failedButOk; - } - bool allPassed() const { - return failed == 0 && failedButOk == 0; - } - bool allOk() const { - return failed == 0; - } - - std::size_t passed; - std::size_t failed; - std::size_t failedButOk; - }; - - struct Totals { - - Totals operator - ( Totals const& other ) const { - Totals diff; - diff.assertions = assertions - other.assertions; - diff.testCases = testCases - other.testCases; - return diff; - } - - Totals delta( Totals const& prevTotals ) const { - Totals diff = *this - prevTotals; - if( diff.assertions.failed > 0 ) - ++diff.testCases.failed; - else if( diff.assertions.failedButOk > 0 ) - ++diff.testCases.failedButOk; - else - ++diff.testCases.passed; - return diff; - } - - Totals& operator += ( Totals const& other ) { - assertions += other.assertions; - testCases += other.testCases; - return *this; - } +struct Counts { + Counts() : passed(0), failed(0), failedButOk(0) {} + + Counts operator-(Counts const &other) const { + Counts diff; + diff.passed = passed - other.passed; + diff.failed = failed - other.failed; + diff.failedButOk = failedButOk - other.failedButOk; + return diff; + } + Counts &operator+=(Counts const &other) { + passed += other.passed; + failed += other.failed; + failedButOk += other.failedButOk; + return *this; + } + + std::size_t total() const { return passed + failed + failedButOk; } + bool allPassed() const { return failed == 0 && failedButOk == 0; } + bool allOk() const { return failed == 0; } + + std::size_t passed; + std::size_t failed; + std::size_t failedButOk; +}; - Counts assertions; - Counts testCases; - }; -} +struct Totals { + + Totals operator-(Totals const &other) const { + Totals diff; + diff.assertions = assertions - other.assertions; + diff.testCases = testCases - other.testCases; + return diff; + } + + Totals delta(Totals const &prevTotals) const { + Totals diff = *this - prevTotals; + if (diff.assertions.failed > 0) + ++diff.testCases.failed; + else if (diff.assertions.failedButOk > 0) + ++diff.testCases.failedButOk; + else + ++diff.testCases.passed; + return diff; + } + + Totals &operator+=(Totals const &other) { + assertions += other.assertions; + testCases += other.testCases; + return *this; + } + + Counts assertions; + Counts testCases; +}; +} // namespace Catch namespace Catch { - struct SectionInfo { - SectionInfo - ( SourceLineInfo const& _lineInfo, - std::string const& _name, - std::string const& _description = std::string() ); +struct SectionInfo { + SectionInfo(SourceLineInfo const &_lineInfo, std::string const &_name, + std::string const &_description = std::string()); - std::string name; - std::string description; - SourceLineInfo lineInfo; - }; + std::string name; + std::string description; + SourceLineInfo lineInfo; +}; - struct SectionEndInfo { - SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds ) - : sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds ) - {} +struct SectionEndInfo { + SectionEndInfo(SectionInfo const &_sectionInfo, Counts const &_prevAssertions, + double _durationInSeconds) + : sectionInfo(_sectionInfo), prevAssertions(_prevAssertions), + durationInSeconds(_durationInSeconds) {} - SectionInfo sectionInfo; - Counts prevAssertions; - double durationInSeconds; - }; + SectionInfo sectionInfo; + Counts prevAssertions; + double durationInSeconds; +}; } // end namespace Catch @@ -2281,17 +2347,17 @@ typedef unsigned long long uint64_t; namespace Catch { - class Timer { - public: - Timer() : m_ticks( 0 ) {} - void start(); - unsigned int getElapsedMicroseconds() const; - unsigned int getElapsedMilliseconds() const; - double getElapsedSeconds() const; +class Timer { +public: + Timer() : m_ticks(0) {} + void start(); + unsigned int getElapsedMicroseconds() const; + unsigned int getElapsedMilliseconds() const; + double getElapsedSeconds() const; - private: - uint64_t m_ticks; - }; +private: + uint64_t m_ticks; +}; } // namespace Catch @@ -2299,201 +2365,189 @@ namespace Catch { namespace Catch { - class Section : NonCopyable { - public: - Section( SectionInfo const& info ); - ~Section(); +class Section : NonCopyable { +public: + Section(SectionInfo const &info); + ~Section(); - // This indicates whether the section should be executed or not - operator bool() const; + // This indicates whether the section should be executed or not + operator bool() const; - private: - SectionInfo m_info; +private: + SectionInfo m_info; - std::string m_name; - Counts m_assertions; - bool m_sectionIncluded; - Timer m_timer; - }; + std::string m_name; + Counts m_assertions; + bool m_sectionIncluded; + Timer m_timer; +}; } // end namespace Catch #ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_SECTION( ... ) \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) +#define INTERNAL_CATCH_SECTION(...) \ + if (Catch::Section const &INTERNAL_CATCH_UNIQUE_NAME( \ + catch_internal_Section) = \ + Catch::SectionInfo(CATCH_INTERNAL_LINEINFO, __VA_ARGS__)) #else - #define INTERNAL_CATCH_SECTION( name, desc ) \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, name, desc ) ) +#define INTERNAL_CATCH_SECTION(name, desc) \ + if (Catch::Section const &INTERNAL_CATCH_UNIQUE_NAME( \ + catch_internal_Section) = \ + Catch::SectionInfo(CATCH_INTERNAL_LINEINFO, name, desc)) #endif // #included from: internal/catch_generators.hpp #define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED #include -#include -#include #include +#include +#include namespace Catch { -template -struct IGenerator { - virtual ~IGenerator() {} - virtual T getValue( std::size_t index ) const = 0; - virtual std::size_t size () const = 0; +template struct IGenerator { + virtual ~IGenerator() {} + virtual T getValue(std::size_t index) const = 0; + virtual std::size_t size() const = 0; }; -template -class BetweenGenerator : public IGenerator { +template class BetweenGenerator : public IGenerator { public: - BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){} + BetweenGenerator(T from, T to) : m_from(from), m_to(to) {} - virtual T getValue( std::size_t index ) const { - return m_from+static_cast( index ); - } + virtual T getValue(std::size_t index) const { + return m_from + static_cast(index); + } - virtual std::size_t size() const { - return static_cast( 1+m_to-m_from ); - } + virtual std::size_t size() const { + return static_cast(1 + m_to - m_from); + } private: - - T m_from; - T m_to; + T m_from; + T m_to; }; -template -class ValuesGenerator : public IGenerator { +template class ValuesGenerator : public IGenerator { public: - ValuesGenerator(){} + ValuesGenerator() {} - void add( T value ) { - m_values.push_back( value ); - } + void add(T value) { m_values.push_back(value); } - virtual T getValue( std::size_t index ) const { - return m_values[index]; - } + virtual T getValue(std::size_t index) const { return m_values[index]; } - virtual std::size_t size() const { - return m_values.size(); - } + virtual std::size_t size() const { return m_values.size(); } private: - std::vector m_values; + std::vector m_values; }; -template -class CompositeGenerator { +template class CompositeGenerator { public: - CompositeGenerator() : m_totalSize( 0 ) {} - - // *** Move semantics, similar to auto_ptr *** - CompositeGenerator( CompositeGenerator& other ) - : m_fileInfo( other.m_fileInfo ), - m_totalSize( 0 ) - { - move( other ); - } - - CompositeGenerator& setFileInfo( const char* fileInfo ) { - m_fileInfo = fileInfo; - return *this; - } - - ~CompositeGenerator() { - deleteAll( m_composed ); - } - - operator T () const { - size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize ); - - typename std::vector*>::const_iterator it = m_composed.begin(); - typename std::vector*>::const_iterator itEnd = m_composed.end(); - for( size_t index = 0; it != itEnd; ++it ) - { - const IGenerator* generator = *it; - if( overallIndex >= index && overallIndex < index + generator->size() ) - { - return generator->getValue( overallIndex-index ); - } - index += generator->size(); - } - CATCH_INTERNAL_ERROR( "Indexed past end of generated range" ); - return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so - } - - void add( const IGenerator* generator ) { - m_totalSize += generator->size(); - m_composed.push_back( generator ); - } - - CompositeGenerator& then( CompositeGenerator& other ) { - move( other ); - return *this; - } - - CompositeGenerator& then( T value ) { - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( value ); - add( valuesGen ); - return *this; - } + CompositeGenerator() : m_totalSize(0) {} + + // *** Move semantics, similar to auto_ptr *** + CompositeGenerator(CompositeGenerator &other) + : m_fileInfo(other.m_fileInfo), m_totalSize(0) { + move(other); + } + + CompositeGenerator &setFileInfo(const char *fileInfo) { + m_fileInfo = fileInfo; + return *this; + } + + ~CompositeGenerator() { deleteAll(m_composed); } + + operator T() const { + size_t overallIndex = + getCurrentContext().getGeneratorIndex(m_fileInfo, m_totalSize); + + typename std::vector *>::const_iterator it = + m_composed.begin(); + typename std::vector *>::const_iterator itEnd = + m_composed.end(); + for (size_t index = 0; it != itEnd; ++it) { + const IGenerator *generator = *it; + if (overallIndex >= index && overallIndex < index + generator->size()) { + return generator->getValue(overallIndex - index); + } + index += generator->size(); + } + CATCH_INTERNAL_ERROR("Indexed past end of generated range"); + return T(); // Suppress spurious "not all control paths return a value" + // warning in Visual Studio - if you know how to fix this please + // do so + } + + void add(const IGenerator *generator) { + m_totalSize += generator->size(); + m_composed.push_back(generator); + } + + CompositeGenerator &then(CompositeGenerator &other) { + move(other); + return *this; + } + + CompositeGenerator &then(T value) { + ValuesGenerator *valuesGen = new ValuesGenerator(); + valuesGen->add(value); + add(valuesGen); + return *this; + } private: - - void move( CompositeGenerator& other ) { - std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) ); - m_totalSize += other.m_totalSize; - other.m_composed.clear(); - } - - std::vector*> m_composed; - std::string m_fileInfo; - size_t m_totalSize; + void move(CompositeGenerator &other) { + std::copy(other.m_composed.begin(), other.m_composed.end(), + std::back_inserter(m_composed)); + m_totalSize += other.m_totalSize; + other.m_composed.clear(); + } + + std::vector *> m_composed; + std::string m_fileInfo; + size_t m_totalSize; }; -namespace Generators -{ - template - CompositeGenerator between( T from, T to ) { - CompositeGenerator generators; - generators.add( new BetweenGenerator( from, to ) ); - return generators; - } +namespace Generators { +template CompositeGenerator between(T from, T to) { + CompositeGenerator generators; + generators.add(new BetweenGenerator(from, to)); + return generators; +} - template - CompositeGenerator values( T val1, T val2 ) { - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - generators.add( valuesGen ); - return generators; - } +template CompositeGenerator values(T val1, T val2) { + CompositeGenerator generators; + ValuesGenerator *valuesGen = new ValuesGenerator(); + valuesGen->add(val1); + valuesGen->add(val2); + generators.add(valuesGen); + return generators; +} - template - CompositeGenerator values( T val1, T val2, T val3 ){ - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - valuesGen->add( val3 ); - generators.add( valuesGen ); - return generators; - } +template CompositeGenerator values(T val1, T val2, T val3) { + CompositeGenerator generators; + ValuesGenerator *valuesGen = new ValuesGenerator(); + valuesGen->add(val1); + valuesGen->add(val2); + valuesGen->add(val3); + generators.add(valuesGen); + return generators; +} - template - CompositeGenerator values( T val1, T val2, T val3, T val4 ) { - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - valuesGen->add( val3 ); - valuesGen->add( val4 ); - generators.add( valuesGen ); - return generators; - } +template +CompositeGenerator values(T val1, T val2, T val3, T val4) { + CompositeGenerator generators; + ValuesGenerator *valuesGen = new ValuesGenerator(); + valuesGen->add(val1); + valuesGen->add(val2); + valuesGen->add(val3); + valuesGen->add(val4); + generators.add(valuesGen); + return generators; +} } // end namespace Generators @@ -2501,10 +2555,11 @@ using namespace Generators; } // end namespace Catch -#define INTERNAL_CATCH_LINESTR2( line ) #line -#define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line ) +#define INTERNAL_CATCH_LINESTR2(line) #line +#define INTERNAL_CATCH_LINESTR(line) INTERNAL_CATCH_LINESTR2(line) -#define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" ) +#define INTERNAL_CATCH_GENERATE(expr) \ + expr.setFileInfo(__FILE__ "(" INTERNAL_CATCH_LINESTR(__LINE__) ")") // #included from: internal/catch_interfaces_exception.h #define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED @@ -2519,173 +2574,177 @@ using namespace Generators; namespace Catch { - class TestCase; - struct ITestCaseRegistry; - struct IExceptionTranslatorRegistry; - struct IExceptionTranslator; - struct IReporterRegistry; - struct IReporterFactory; +class TestCase; +struct ITestCaseRegistry; +struct IExceptionTranslatorRegistry; +struct IExceptionTranslator; +struct IReporterRegistry; +struct IReporterFactory; - struct IRegistryHub { - virtual ~IRegistryHub(); +struct IRegistryHub { + virtual ~IRegistryHub(); - virtual IReporterRegistry const& getReporterRegistry() const = 0; - virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; - }; + virtual IReporterRegistry const &getReporterRegistry() const = 0; + virtual ITestCaseRegistry const &getTestCaseRegistry() const = 0; + virtual IExceptionTranslatorRegistry &getExceptionTranslatorRegistry() = 0; +}; - struct IMutableRegistryHub { - virtual ~IMutableRegistryHub(); - virtual void registerReporter( std::string const& name, Ptr const& factory ) = 0; - virtual void registerListener( Ptr const& factory ) = 0; - virtual void registerTest( TestCase const& testInfo ) = 0; - virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; - }; +struct IMutableRegistryHub { + virtual ~IMutableRegistryHub(); + virtual void registerReporter(std::string const &name, + Ptr const &factory) = 0; + virtual void registerListener(Ptr const &factory) = 0; + virtual void registerTest(TestCase const &testInfo) = 0; + virtual void registerTranslator(const IExceptionTranslator *translator) = 0; +}; - IRegistryHub& getRegistryHub(); - IMutableRegistryHub& getMutableRegistryHub(); - void cleanUp(); - std::string translateActiveException(); +IRegistryHub &getRegistryHub(); +IMutableRegistryHub &getMutableRegistryHub(); +void cleanUp(); +std::string translateActiveException(); -} +} // namespace Catch namespace Catch { - typedef std::string(*exceptionTranslateFunction)(); - - struct IExceptionTranslator; - typedef std::vector ExceptionTranslators; - - struct IExceptionTranslator { - virtual ~IExceptionTranslator(); - virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; - }; - - struct IExceptionTranslatorRegistry { - virtual ~IExceptionTranslatorRegistry(); - - virtual std::string translateActiveException() const = 0; - }; - - class ExceptionTranslatorRegistrar { - template - class ExceptionTranslator : public IExceptionTranslator { - public: - - ExceptionTranslator( std::string(*translateFunction)( T& ) ) - : m_translateFunction( translateFunction ) - {} - - virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const CATCH_OVERRIDE { - try { - if( it == itEnd ) - throw; - else - return (*it)->translate( it+1, itEnd ); - } - catch( T& ex ) { - return m_translateFunction( ex ); - } - } - - protected: - std::string(*m_translateFunction)( T& ); - }; +typedef std::string (*exceptionTranslateFunction)(); - public: - template - ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { - getMutableRegistryHub().registerTranslator - ( new ExceptionTranslator( translateFunction ) ); - } - }; -} +struct IExceptionTranslator; +typedef std::vector ExceptionTranslators; -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ - static std::string translatorName( signature ); \ - namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\ - static std::string translatorName( signature ) +struct IExceptionTranslator { + virtual ~IExceptionTranslator(); + virtual std::string + translate(ExceptionTranslators::const_iterator it, + ExceptionTranslators::const_iterator itEnd) const = 0; +}; -#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) +struct IExceptionTranslatorRegistry { + virtual ~IExceptionTranslatorRegistry(); -// #included from: internal/catch_approx.hpp -#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED + virtual std::string translateActiveException() const = 0; +}; -#include -#include +class ExceptionTranslatorRegistrar { + template + class ExceptionTranslator : public IExceptionTranslator { + public: + ExceptionTranslator(std::string (*translateFunction)(T &)) + : m_translateFunction(translateFunction) {} + + virtual std::string + translate(ExceptionTranslators::const_iterator it, + ExceptionTranslators::const_iterator itEnd) const CATCH_OVERRIDE { + try { + if (it == itEnd) + throw; + else + return (*it)->translate(it + 1, itEnd); + } catch (T &ex) { + return m_translateFunction(ex); + } + } -namespace Catch { -namespace Detail { + protected: + std::string (*m_translateFunction)(T &); + }; - class Approx { - public: - explicit Approx ( double value ) - : m_epsilon( std::numeric_limits::epsilon()*100 ), - m_scale( 1.0 ), - m_value( value ) - {} - - Approx( Approx const& other ) - : m_epsilon( other.m_epsilon ), - m_scale( other.m_scale ), - m_value( other.m_value ) - {} - - static Approx custom() { - return Approx( 0 ); - } - - Approx operator()( double value ) { - Approx approx( value ); - approx.epsilon( m_epsilon ); - approx.scale( m_scale ); - return approx; - } - - friend bool operator == ( double lhs, Approx const& rhs ) { - // Thanks to Richard Harris for his help refining this formula - return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) ); - } - - friend bool operator == ( Approx const& lhs, double rhs ) { - return operator==( rhs, lhs ); - } +public: + template + ExceptionTranslatorRegistrar(std::string (*translateFunction)(T &)) { + getMutableRegistryHub().registerTranslator( + new ExceptionTranslator(translateFunction)); + } +}; +} // namespace Catch - friend bool operator != ( double lhs, Approx const& rhs ) { - return !operator==( lhs, rhs ); - } +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2(translatorName, signature) \ + static std::string translatorName(signature); \ + namespace { \ + Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( \ + catch_internal_ExceptionRegistrar)(&translatorName); \ + } \ + static std::string translatorName(signature) + +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION(signature) \ + INTERNAL_CATCH_TRANSLATE_EXCEPTION2( \ + INTERNAL_CATCH_UNIQUE_NAME(catch_internal_ExceptionTranslator), \ + signature) - friend bool operator != ( Approx const& lhs, double rhs ) { - return !operator==( rhs, lhs ); - } +// #included from: internal/catch_approx.hpp +#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED - Approx& epsilon( double newEpsilon ) { - m_epsilon = newEpsilon; - return *this; - } +#include +#include - Approx& scale( double newScale ) { - m_scale = newScale; - return *this; - } +namespace Catch { +namespace Detail { - std::string toString() const { - std::ostringstream oss; - oss << "Approx( " << Catch::toString( m_value ) << " )"; - return oss.str(); - } +class Approx { +public: + explicit Approx(double value) + : m_epsilon(std::numeric_limits::epsilon() * 100), m_scale(1.0), + m_value(value) {} + + Approx(Approx const &other) + : m_epsilon(other.m_epsilon), m_scale(other.m_scale), + m_value(other.m_value) {} + + static Approx custom() { return Approx(0); } + + Approx operator()(double value) { + Approx approx(value); + approx.epsilon(m_epsilon); + approx.scale(m_scale); + return approx; + } + + friend bool operator==(double lhs, Approx const &rhs) { + // Thanks to Richard Harris for his help refining this formula + return fabs(lhs - rhs.m_value) < + rhs.m_epsilon * + (rhs.m_scale + (std::max)(fabs(lhs), fabs(rhs.m_value))); + } + + friend bool operator==(Approx const &lhs, double rhs) { + return operator==(rhs, lhs); + } + + friend bool operator!=(double lhs, Approx const &rhs) { + return !operator==(lhs, rhs); + } + + friend bool operator!=(Approx const &lhs, double rhs) { + return !operator==(rhs, lhs); + } + + Approx &epsilon(double newEpsilon) { + m_epsilon = newEpsilon; + return *this; + } + + Approx &scale(double newScale) { + m_scale = newScale; + return *this; + } + + std::string toString() const { + std::ostringstream oss; + oss << "Approx( " << Catch::toString(m_value) << " )"; + return oss.str(); + } - private: - double m_epsilon; - double m_scale; - double m_value; - }; -} +private: + double m_epsilon; + double m_scale; + double m_value; +}; +} // namespace Detail -template<> -inline std::string toString( Detail::Approx const& value ) { - return value.toString(); +template <> +inline std::string toString(Detail::Approx const &value) { + return value.toString(); } } // end namespace Catch @@ -2700,94 +2759,93 @@ inline std::string toString( Detail::Approx const& value ) { namespace Catch { - struct TagAlias { - TagAlias( std::string _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {} +struct TagAlias { + TagAlias(std::string _tag, SourceLineInfo _lineInfo) + : tag(_tag), lineInfo(_lineInfo) {} - std::string tag; - SourceLineInfo lineInfo; - }; + std::string tag; + SourceLineInfo lineInfo; +}; - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; +struct RegistrarForTagAliases { + RegistrarForTagAliases(char const *alias, char const *tag, + SourceLineInfo const &lineInfo); +}; } // end namespace Catch -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } +#define CATCH_REGISTER_TAG_ALIAS(alias, spec) \ + namespace { \ + Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( \ + AutoRegisterTagAlias)(alias, spec, CATCH_INTERNAL_LINEINFO); \ + } // #included from: catch_option.hpp #define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED namespace Catch { - // An optional type - template - class Option { - public: - Option() : nullableValue( CATCH_NULL ) {} - Option( T const& _value ) - : nullableValue( new( storage ) T( _value ) ) - {} - Option( Option const& _other ) - : nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL ) - {} - - ~Option() { - reset(); - } - - Option& operator= ( Option const& _other ) { - if( &_other != this ) { - reset(); - if( _other ) - nullableValue = new( storage ) T( *_other ); - } - return *this; - } - Option& operator = ( T const& _value ) { - reset(); - nullableValue = new( storage ) T( _value ); - return *this; - } - - void reset() { - if( nullableValue ) - nullableValue->~T(); - nullableValue = CATCH_NULL; - } - - T& operator*() { return *nullableValue; } - T const& operator*() const { return *nullableValue; } - T* operator->() { return nullableValue; } - const T* operator->() const { return nullableValue; } - - T valueOr( T const& defaultValue ) const { - return nullableValue ? *nullableValue : defaultValue; - } - - bool some() const { return nullableValue != CATCH_NULL; } - bool none() const { return nullableValue == CATCH_NULL; } - - bool operator !() const { return nullableValue == CATCH_NULL; } - operator SafeBool::type() const { - return SafeBool::makeSafe( some() ); - } +// An optional type +template class Option { +public: + Option() : nullableValue(CATCH_NULL) {} + Option(T const &_value) : nullableValue(new(storage) T(_value)) {} + Option(Option const &_other) + : nullableValue(_other ? new(storage) T(*_other) : CATCH_NULL) {} + + ~Option() { reset(); } + + Option &operator=(Option const &_other) { + if (&_other != this) { + reset(); + if (_other) + nullableValue = new (storage) T(*_other); + } + return *this; + } + Option &operator=(T const &_value) { + reset(); + nullableValue = new (storage) T(_value); + return *this; + } + + void reset() { + if (nullableValue) + nullableValue->~T(); + nullableValue = CATCH_NULL; + } + + T &operator*() { return *nullableValue; } + T const &operator*() const { return *nullableValue; } + T *operator->() { return nullableValue; } + const T *operator->() const { return nullableValue; } + + T valueOr(T const &defaultValue) const { + return nullableValue ? *nullableValue : defaultValue; + } + + bool some() const { return nullableValue != CATCH_NULL; } + bool none() const { return nullableValue == CATCH_NULL; } + + bool operator!() const { return nullableValue == CATCH_NULL; } + operator SafeBool::type() const { return SafeBool::makeSafe(some()); } - private: - T* nullableValue; - char storage[sizeof(T)]; - }; +private: + T *nullableValue; + char storage[sizeof(T)]; +}; } // end namespace Catch namespace Catch { - struct ITagAliasRegistry { - virtual ~ITagAliasRegistry(); - virtual Option find( std::string const& alias ) const = 0; - virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; +struct ITagAliasRegistry { + virtual ~ITagAliasRegistry(); + virtual Option find(std::string const &alias) const = 0; + virtual std::string + expandAliases(std::string const &unexpandedTestSpec) const = 0; - static ITagAliasRegistry const& get(); - }; + static ITagAliasRegistry const &get(); +}; } // end namespace Catch @@ -2796,8 +2854,8 @@ namespace Catch { // #included from: internal/catch_test_case_info.h #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED -#include #include +#include #ifdef __clang__ #pragma clang diagnostic push @@ -2806,75 +2864,71 @@ namespace Catch { namespace Catch { - struct ITestCase; - - struct TestCaseInfo { - enum SpecialProperties{ - None = 0, - IsHidden = 1 << 1, - ShouldFail = 1 << 2, - MayFail = 1 << 3, - Throws = 1 << 4 - }; - - TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - SourceLineInfo const& _lineInfo ); - - TestCaseInfo( TestCaseInfo const& other ); +struct ITestCase; - friend void setTags( TestCaseInfo& testCaseInfo, std::set const& tags ); - - bool isHidden() const; - bool throws() const; - bool okToFail() const; - bool expectedToFail() const; - - std::string name; - std::string className; - std::string description; - std::set tags; - std::set lcaseTags; - std::string tagsAsString; - SourceLineInfo lineInfo; - SpecialProperties properties; - }; +struct TestCaseInfo { + enum SpecialProperties { + None = 0, + IsHidden = 1 << 1, + ShouldFail = 1 << 2, + MayFail = 1 << 3, + Throws = 1 << 4 + }; - class TestCase : public TestCaseInfo { - public: + TestCaseInfo(std::string const &_name, std::string const &_className, + std::string const &_description, + std::set const &_tags, + SourceLineInfo const &_lineInfo); + + TestCaseInfo(TestCaseInfo const &other); + + friend void setTags(TestCaseInfo &testCaseInfo, + std::set const &tags); + + bool isHidden() const; + bool throws() const; + bool okToFail() const; + bool expectedToFail() const; + + std::string name; + std::string className; + std::string description; + std::set tags; + std::set lcaseTags; + std::string tagsAsString; + SourceLineInfo lineInfo; + SpecialProperties properties; +}; - TestCase( ITestCase* testCase, TestCaseInfo const& info ); - TestCase( TestCase const& other ); +class TestCase : public TestCaseInfo { +public: + TestCase(ITestCase *testCase, TestCaseInfo const &info); + TestCase(TestCase const &other); - TestCase withName( std::string const& _newName ) const; + TestCase withName(std::string const &_newName) const; - void invoke() const; + void invoke() const; - TestCaseInfo const& getTestCaseInfo() const; + TestCaseInfo const &getTestCaseInfo() const; - void swap( TestCase& other ); - bool operator == ( TestCase const& other ) const; - bool operator < ( TestCase const& other ) const; - TestCase& operator = ( TestCase const& other ); + void swap(TestCase &other); + bool operator==(TestCase const &other) const; + bool operator<(TestCase const &other) const; + TestCase &operator=(TestCase const &other); - private: - Ptr test; - }; +private: + Ptr test; +}; - TestCase makeTestCase( ITestCase* testCase, - std::string const& className, - std::string const& name, - std::string const& description, - SourceLineInfo const& lineInfo ); -} +TestCase makeTestCase(ITestCase *testCase, std::string const &className, + std::string const &name, std::string const &description, + SourceLineInfo const &lineInfo); +} // namespace Catch #ifdef __clang__ #pragma clang diagnostic pop #endif - #ifdef __OBJC__ // #included from: internal/catch_objc.hpp #define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED @@ -2894,178 +2948,184 @@ namespace Catch { @optional --(void) setUp; --(void) tearDown; +- (void)setUp; +- (void)tearDown; @end namespace Catch { - class OcMethod : public SharedImpl { +class OcMethod : public SharedImpl { - public: - OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} +public: + OcMethod(Class cls, SEL sel) : m_cls(cls), m_sel(sel) {} - virtual void invoke() const { - id obj = [[m_cls alloc] init]; + virtual void invoke() const { + id obj = [[m_cls alloc] init]; - performOptionalSelector( obj, @selector(setUp) ); - performOptionalSelector( obj, m_sel ); - performOptionalSelector( obj, @selector(tearDown) ); + performOptionalSelector(obj, @selector(setUp)); + performOptionalSelector(obj, m_sel); + performOptionalSelector(obj, @selector(tearDown)); - arcSafeRelease( obj ); - } - private: - virtual ~OcMethod() {} - - Class m_cls; - SEL m_sel; - }; - - namespace Detail{ - - inline std::string getAnnotation( Class cls, - std::string const& annotationName, - std::string const& testCaseName ) { - NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; - SEL sel = NSSelectorFromString( selStr ); - arcSafeRelease( selStr ); - id value = performOptionalSelector( cls, sel ); - if( value ) - return [(NSString*)value UTF8String]; - return ""; - } - } + arcSafeRelease(obj); + } - inline size_t registerTestMethods() { - size_t noTestMethods = 0; - int noClasses = objc_getClassList( CATCH_NULL, 0 ); - - Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); - objc_getClassList( classes, noClasses ); - - for( int c = 0; c < noClasses; c++ ) { - Class cls = classes[c]; - { - u_int count; - Method* methods = class_copyMethodList( cls, &count ); - for( u_int m = 0; m < count ; m++ ) { - SEL selector = method_getName(methods[m]); - std::string methodName = sel_getName(selector); - if( startsWith( methodName, "Catch_TestCase_" ) ) { - std::string testCaseName = methodName.substr( 15 ); - std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); - std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); - const char* className = class_getName( cls ); - - getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) ); - noTestMethods++; - } - } - free(methods); - } - } - return noTestMethods; - } +private: + virtual ~OcMethod() {} + + Class m_cls; + SEL m_sel; +}; - namespace Matchers { - namespace Impl { - namespace NSStringMatchers { +namespace Detail { + +inline std::string getAnnotation(Class cls, std::string const &annotationName, + std::string const &testCaseName) { + NSString *selStr = + [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), + testCaseName.c_str()]; + SEL sel = NSSelectorFromString(selStr); + arcSafeRelease(selStr); + id value = performOptionalSelector(cls, sel); + if (value) + return [(NSString *)value UTF8String]; + return ""; +} +} // namespace Detail + +inline size_t registerTestMethods() { + size_t noTestMethods = 0; + int noClasses = objc_getClassList(CATCH_NULL, 0); - template - struct StringHolder : MatcherImpl{ - StringHolder( NSString* substr ) : m_substr( [substr copy] ){} - StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} - StringHolder() { - arcSafeRelease( m_substr ); - } + Class *classes = + (CATCH_UNSAFE_UNRETAINED Class *)malloc(sizeof(Class) * noClasses); + objc_getClassList(classes, noClasses); + + for (int c = 0; c < noClasses; c++) { + Class cls = classes[c]; + { + u_int count; + Method *methods = class_copyMethodList(cls, &count); + for (u_int m = 0; m < count; m++) { + SEL selector = method_getName(methods[m]); + std::string methodName = sel_getName(selector); + if (startsWith(methodName, "Catch_TestCase_")) { + std::string testCaseName = methodName.substr(15); + std::string name = Detail::getAnnotation(cls, "Name", testCaseName); + std::string desc = + Detail::getAnnotation(cls, "Description", testCaseName); + const char *className = class_getName(cls); + + getMutableRegistryHub().registerTest( + makeTestCase(new OcMethod(cls, selector), className, name.c_str(), + desc.c_str(), SourceLineInfo())); + noTestMethods++; + } + } + free(methods); + } + } + return noTestMethods; +} - NSString* m_substr; - }; +namespace Matchers { +namespace Impl { +namespace NSStringMatchers { - struct Equals : StringHolder { - Equals( NSString* substr ) : StringHolder( substr ){} +template +struct StringHolder : MatcherImpl { + StringHolder(NSString *substr) : m_substr([substr copy]) {} + StringHolder(StringHolder const &other) : m_substr([other.m_substr copy]) {} + StringHolder() { arcSafeRelease(m_substr); } - virtual bool match( ExpressionType const& str ) const { - return (str != nil || m_substr == nil ) && - [str isEqualToString:m_substr]; - } + NSString *m_substr; +}; - virtual std::string toString() const { - return "equals string: " + Catch::toString( m_substr ); - } - }; +struct Equals : StringHolder { + Equals(NSString *substr) : StringHolder(substr) {} - struct Contains : StringHolder { - Contains( NSString* substr ) : StringHolder( substr ){} + virtual bool match(ExpressionType const &str) const { + return (str != nil || m_substr == nil) && [str isEqualToString:m_substr]; + } - virtual bool match( ExpressionType const& str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location != NSNotFound; - } + virtual std::string toString() const { + return "equals string: " + Catch::toString(m_substr); + } +}; - virtual std::string toString() const { - return "contains string: " + Catch::toString( m_substr ); - } - }; +struct Contains : StringHolder { + Contains(NSString *substr) : StringHolder(substr) {} - struct StartsWith : StringHolder { - StartsWith( NSString* substr ) : StringHolder( substr ){} + virtual bool match(ExpressionType const &str) const { + return (str != nil || m_substr == nil) && + [str rangeOfString:m_substr].location != NSNotFound; + } - virtual bool match( ExpressionType const& str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location == 0; - } + virtual std::string toString() const { + return "contains string: " + Catch::toString(m_substr); + } +}; - virtual std::string toString() const { - return "starts with: " + Catch::toString( m_substr ); - } - }; - struct EndsWith : StringHolder { - EndsWith( NSString* substr ) : StringHolder( substr ){} +struct StartsWith : StringHolder { + StartsWith(NSString *substr) : StringHolder(substr) {} - virtual bool match( ExpressionType const& str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location == [str length] - [m_substr length]; - } + virtual bool match(ExpressionType const &str) const { + return (str != nil || m_substr == nil) && + [str rangeOfString:m_substr].location == 0; + } - virtual std::string toString() const { - return "ends with: " + Catch::toString( m_substr ); - } - }; + virtual std::string toString() const { + return "starts with: " + Catch::toString(m_substr); + } +}; +struct EndsWith : StringHolder { + EndsWith(NSString *substr) : StringHolder(substr) {} + + virtual bool match(ExpressionType const &str) const { + return (str != nil || m_substr == nil) && + [str rangeOfString:m_substr].location == + [str length] - [m_substr length]; + } + + virtual std::string toString() const { + return "ends with: " + Catch::toString(m_substr); + } +}; - } // namespace NSStringMatchers - } // namespace Impl +} // namespace NSStringMatchers +} // namespace Impl - inline Impl::NSStringMatchers::Equals - Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } +inline Impl::NSStringMatchers::Equals Equals(NSString *substr) { + return Impl::NSStringMatchers::Equals(substr); +} - inline Impl::NSStringMatchers::Contains - Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } +inline Impl::NSStringMatchers::Contains Contains(NSString *substr) { + return Impl::NSStringMatchers::Contains(substr); +} - inline Impl::NSStringMatchers::StartsWith - StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } +inline Impl::NSStringMatchers::StartsWith StartsWith(NSString *substr) { + return Impl::NSStringMatchers::StartsWith(substr); +} - inline Impl::NSStringMatchers::EndsWith - EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } +inline Impl::NSStringMatchers::EndsWith EndsWith(NSString *substr) { + return Impl::NSStringMatchers::EndsWith(substr); +} - } // namespace Matchers +} // namespace Matchers - using namespace Matchers; +using namespace Matchers; } // namespace Catch /////////////////////////////////////////////////////////////////////////////// -#define OC_TEST_CASE( name, desc )\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \ -{\ -return @ name; \ -}\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \ -{ \ -return @ desc; \ -} \ --(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test ) +#define OC_TEST_CASE(name, desc) \ + +(NSString *)INTERNAL_CATCH_UNIQUE_NAME(Catch_Name_test) { \ + return @name; \ + } \ + +(NSString *)INTERNAL_CATCH_UNIQUE_NAME(Catch_Description_test) { \ + return @desc; \ + } \ + -(void)INTERNAL_CATCH_UNIQUE_NAME(Catch_TestCase_test) #endif @@ -3109,137 +3169,142 @@ return @ desc; \ // #included from: catch_wildcard_pattern.hpp #define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED -namespace Catch -{ - class WildcardPattern { - enum WildcardPosition { - NoWildcard = 0, - WildcardAtStart = 1, - WildcardAtEnd = 2, - WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd - }; - - public: - - WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity ) - : m_caseSensitivity( caseSensitivity ), - m_wildcard( NoWildcard ), - m_pattern( adjustCase( pattern ) ) - { - if( startsWith( m_pattern, "*" ) ) { - m_pattern = m_pattern.substr( 1 ); - m_wildcard = WildcardAtStart; - } - if( endsWith( m_pattern, "*" ) ) { - m_pattern = m_pattern.substr( 0, m_pattern.size()-1 ); - m_wildcard = static_cast( m_wildcard | WildcardAtEnd ); - } - } - virtual ~WildcardPattern(); - virtual bool matches( std::string const& str ) const { - switch( m_wildcard ) { - case NoWildcard: - return m_pattern == adjustCase( str ); - case WildcardAtStart: - return endsWith( adjustCase( str ), m_pattern ); - case WildcardAtEnd: - return startsWith( adjustCase( str ), m_pattern ); - case WildcardAtBothEnds: - return contains( adjustCase( str ), m_pattern ); - } +namespace Catch { +class WildcardPattern { + enum WildcardPosition { + NoWildcard = 0, + WildcardAtStart = 1, + WildcardAtEnd = 2, + WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd + }; + +public: + WildcardPattern(std::string const &pattern, + CaseSensitive::Choice caseSensitivity) + : m_caseSensitivity(caseSensitivity), m_wildcard(NoWildcard), + m_pattern(adjustCase(pattern)) { + if (startsWith(m_pattern, "*")) { + m_pattern = m_pattern.substr(1); + m_wildcard = WildcardAtStart; + } + if (endsWith(m_pattern, "*")) { + m_pattern = m_pattern.substr(0, m_pattern.size() - 1); + m_wildcard = static_cast(m_wildcard | WildcardAtEnd); + } + } + virtual ~WildcardPattern(); + virtual bool matches(std::string const &str) const { + switch (m_wildcard) { + case NoWildcard: + return m_pattern == adjustCase(str); + case WildcardAtStart: + return endsWith(adjustCase(str), m_pattern); + case WildcardAtEnd: + return startsWith(adjustCase(str), m_pattern); + case WildcardAtBothEnds: + return contains(adjustCase(str), m_pattern); + } #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunreachable-code" #endif - throw std::logic_error( "Unknown enum" ); + throw std::logic_error("Unknown enum"); #ifdef __clang__ #pragma clang diagnostic pop #endif - } - private: - std::string adjustCase( std::string const& str ) const { - return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str; - } - CaseSensitive::Choice m_caseSensitivity; - WildcardPosition m_wildcard; - std::string m_pattern; - }; -} + } + +private: + std::string adjustCase(std::string const &str) const { + return m_caseSensitivity == CaseSensitive::No ? toLower(str) : str; + } + CaseSensitive::Choice m_caseSensitivity; + WildcardPosition m_wildcard; + std::string m_pattern; +}; +} // namespace Catch #include #include namespace Catch { - class TestSpec { - struct Pattern : SharedImpl<> { - virtual ~Pattern(); - virtual bool matches( TestCaseInfo const& testCase ) const = 0; - }; - class NamePattern : public Pattern { - public: - NamePattern( std::string const& name ) - : m_wildcardPattern( toLower( name ), CaseSensitive::No ) - {} - virtual ~NamePattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - return m_wildcardPattern.matches( toLower( testCase.name ) ); - } - private: - WildcardPattern m_wildcardPattern; - }; - - class TagPattern : public Pattern { - public: - TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} - virtual ~TagPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - return testCase.lcaseTags.find( m_tag ) != testCase.lcaseTags.end(); - } - private: - std::string m_tag; - }; - - class ExcludedPattern : public Pattern { - public: - ExcludedPattern( Ptr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} - virtual ~ExcludedPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } - private: - Ptr m_underlyingPattern; - }; - - struct Filter { - std::vector > m_patterns; - - bool matches( TestCaseInfo const& testCase ) const { - // All patterns in a filter must match for the filter to be a match - for( std::vector >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) - if( !(*it)->matches( testCase ) ) - return false; - return true; - } - }; +class TestSpec { + struct Pattern : SharedImpl<> { + virtual ~Pattern(); + virtual bool matches(TestCaseInfo const &testCase) const = 0; + }; + class NamePattern : public Pattern { + public: + NamePattern(std::string const &name) + : m_wildcardPattern(toLower(name), CaseSensitive::No) {} + virtual ~NamePattern(); + virtual bool matches(TestCaseInfo const &testCase) const { + return m_wildcardPattern.matches(toLower(testCase.name)); + } - public: - bool hasFilters() const { - return !m_filters.empty(); - } - bool matches( TestCaseInfo const& testCase ) const { - // A TestSpec matches if any filter matches - for( std::vector::const_iterator it = m_filters.begin(), itEnd = m_filters.end(); it != itEnd; ++it ) - if( it->matches( testCase ) ) - return true; - return false; - } + private: + WildcardPattern m_wildcardPattern; + }; + + class TagPattern : public Pattern { + public: + TagPattern(std::string const &tag) : m_tag(toLower(tag)) {} + virtual ~TagPattern(); + virtual bool matches(TestCaseInfo const &testCase) const { + return testCase.lcaseTags.find(m_tag) != testCase.lcaseTags.end(); + } - private: - std::vector m_filters; + private: + std::string m_tag; + }; - friend class TestSpecParser; - }; -} + class ExcludedPattern : public Pattern { + public: + ExcludedPattern(Ptr const &underlyingPattern) + : m_underlyingPattern(underlyingPattern) {} + virtual ~ExcludedPattern(); + virtual bool matches(TestCaseInfo const &testCase) const { + return !m_underlyingPattern->matches(testCase); + } + + private: + Ptr m_underlyingPattern; + }; + + struct Filter { + std::vector> m_patterns; + + bool matches(TestCaseInfo const &testCase) const { + // All patterns in a filter must match for the filter to be a match + for (std::vector>::const_iterator it = m_patterns.begin(), + itEnd = m_patterns.end(); + it != itEnd; ++it) + if (!(*it)->matches(testCase)) + return false; + return true; + } + }; + +public: + bool hasFilters() const { return !m_filters.empty(); } + bool matches(TestCaseInfo const &testCase) const { + // A TestSpec matches if any filter matches + for (std::vector::const_iterator it = m_filters.begin(), + itEnd = m_filters.end(); + it != itEnd; ++it) + if (it->matches(testCase)) + return true; + return false; + } + +private: + std::vector m_filters; + + friend class TestSpecParser; +}; +} // namespace Catch #ifdef __clang__ #pragma clang diagnostic pop @@ -3247,94 +3312,102 @@ namespace Catch { namespace Catch { - class TestSpecParser { - enum Mode{ None, Name, QuotedName, Tag }; - Mode m_mode; - bool m_exclusion; - std::size_t m_start, m_pos; - std::string m_arg; - TestSpec::Filter m_currentFilter; - TestSpec m_testSpec; - ITagAliasRegistry const* m_tagAliases; - - public: - TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {} - - TestSpecParser& parse( std::string const& arg ) { - m_mode = None; - m_exclusion = false; - m_start = std::string::npos; - m_arg = m_tagAliases->expandAliases( arg ); - for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) - visitChar( m_arg[m_pos] ); - if( m_mode == Name ) - addPattern(); - return *this; - } - TestSpec testSpec() { - addFilter(); - return m_testSpec; - } - private: - void visitChar( char c ) { - if( m_mode == None ) { - switch( c ) { - case ' ': return; - case '~': m_exclusion = true; return; - case '[': return startNewMode( Tag, ++m_pos ); - case '"': return startNewMode( QuotedName, ++m_pos ); - default: startNewMode( Name, m_pos ); break; - } - } - if( m_mode == Name ) { - if( c == ',' ) { - addPattern(); - addFilter(); - } - else if( c == '[' ) { - if( subString() == "exclude:" ) - m_exclusion = true; - else - addPattern(); - startNewMode( Tag, ++m_pos ); - } - } - else if( m_mode == QuotedName && c == '"' ) - addPattern(); - else if( m_mode == Tag && c == ']' ) - addPattern(); - } - void startNewMode( Mode mode, std::size_t start ) { - m_mode = mode; - m_start = start; - } - std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); } - template - void addPattern() { - std::string token = subString(); - if( startsWith( token, "exclude:" ) ) { - m_exclusion = true; - token = token.substr( 8 ); - } - if( !token.empty() ) { - Ptr pattern = new T( token ); - if( m_exclusion ) - pattern = new TestSpec::ExcludedPattern( pattern ); - m_currentFilter.m_patterns.push_back( pattern ); - } - m_exclusion = false; - m_mode = None; - } - void addFilter() { - if( !m_currentFilter.m_patterns.empty() ) { - m_testSpec.m_filters.push_back( m_currentFilter ); - m_currentFilter = TestSpec::Filter(); - } - } - }; - inline TestSpec parseTestSpec( std::string const& arg ) { - return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); +class TestSpecParser { + enum Mode { None, Name, QuotedName, Tag }; + Mode m_mode; + bool m_exclusion; + std::size_t m_start, m_pos; + std::string m_arg; + TestSpec::Filter m_currentFilter; + TestSpec m_testSpec; + ITagAliasRegistry const *m_tagAliases; + +public: + TestSpecParser(ITagAliasRegistry const &tagAliases) + : m_tagAliases(&tagAliases) {} + + TestSpecParser &parse(std::string const &arg) { + m_mode = None; + m_exclusion = false; + m_start = std::string::npos; + m_arg = m_tagAliases->expandAliases(arg); + for (m_pos = 0; m_pos < m_arg.size(); ++m_pos) + visitChar(m_arg[m_pos]); + if (m_mode == Name) + addPattern(); + return *this; + } + TestSpec testSpec() { + addFilter(); + return m_testSpec; + } + +private: + void visitChar(char c) { + if (m_mode == None) { + switch (c) { + case ' ': + return; + case '~': + m_exclusion = true; + return; + case '[': + return startNewMode(Tag, ++m_pos); + case '"': + return startNewMode(QuotedName, ++m_pos); + default: + startNewMode(Name, m_pos); + break; + } } + if (m_mode == Name) { + if (c == ',') { + addPattern(); + addFilter(); + } else if (c == '[') { + if (subString() == "exclude:") + m_exclusion = true; + else + addPattern(); + startNewMode(Tag, ++m_pos); + } + } else if (m_mode == QuotedName && c == '"') + addPattern(); + else if (m_mode == Tag && c == ']') + addPattern(); + } + void startNewMode(Mode mode, std::size_t start) { + m_mode = mode; + m_start = start; + } + std::string subString() const { + return m_arg.substr(m_start, m_pos - m_start); + } + template void addPattern() { + std::string token = subString(); + if (startsWith(token, "exclude:")) { + m_exclusion = true; + token = token.substr(8); + } + if (!token.empty()) { + Ptr pattern = new T(token); + if (m_exclusion) + pattern = new TestSpec::ExcludedPattern(pattern); + m_currentFilter.m_patterns.push_back(pattern); + } + m_exclusion = false; + m_mode = None; + } + void addFilter() { + if (!m_currentFilter.m_patterns.empty()) { + m_testSpec.m_filters.push_back(m_currentFilter); + m_currentFilter = TestSpec::Filter(); + } + } +}; +inline TestSpec parseTestSpec(std::string const &arg) { + return TestSpecParser(ITagAliasRegistry::get()).parse(arg).testSpec(); +} } // namespace Catch @@ -3351,54 +3424,49 @@ namespace Catch { namespace Catch { - struct Verbosity { enum Level { - NoOutput = 0, - Quiet, - Normal - }; }; - - struct WarnAbout { enum What { - Nothing = 0x00, - NoAssertions = 0x01 - }; }; - - struct ShowDurations { enum OrNot { - DefaultForReporter, - Always, - Never - }; }; - struct RunTests { enum InWhatOrder { - InDeclarationOrder, - InLexicographicalOrder, - InRandomOrder - }; }; - struct UseColour { enum YesOrNo { - Auto, - Yes, - No - }; }; - - class TestSpec; - - struct IConfig : IShared { - - virtual ~IConfig(); - - virtual bool allowThrows() const = 0; - virtual std::ostream& stream() const = 0; - virtual std::string name() const = 0; - virtual bool includeSuccessfulResults() const = 0; - virtual bool shouldDebugBreak() const = 0; - virtual bool warnAboutMissingAssertions() const = 0; - virtual int abortAfter() const = 0; - virtual bool showInvisibles() const = 0; - virtual ShowDurations::OrNot showDurations() const = 0; - virtual TestSpec const& testSpec() const = 0; - virtual RunTests::InWhatOrder runOrder() const = 0; - virtual unsigned int rngSeed() const = 0; - virtual UseColour::YesOrNo useColour() const = 0; - }; -} +struct Verbosity { + enum Level { NoOutput = 0, Quiet, Normal }; +}; + +struct WarnAbout { + enum What { Nothing = 0x00, NoAssertions = 0x01 }; +}; + +struct ShowDurations { + enum OrNot { DefaultForReporter, Always, Never }; +}; +struct RunTests { + enum InWhatOrder { + InDeclarationOrder, + InLexicographicalOrder, + InRandomOrder + }; +}; +struct UseColour { + enum YesOrNo { Auto, Yes, No }; +}; + +class TestSpec; + +struct IConfig : IShared { + + virtual ~IConfig(); + + virtual bool allowThrows() const = 0; + virtual std::ostream &stream() const = 0; + virtual std::string name() const = 0; + virtual bool includeSuccessfulResults() const = 0; + virtual bool shouldDebugBreak() const = 0; + virtual bool warnAboutMissingAssertions() const = 0; + virtual int abortAfter() const = 0; + virtual bool showInvisibles() const = 0; + virtual ShowDurations::OrNot showDurations() const = 0; + virtual TestSpec const &testSpec() const = 0; + virtual RunTests::InWhatOrder runOrder() const = 0; + virtual unsigned int rngSeed() const = 0; + virtual UseColour::YesOrNo useColour() const = 0; +}; +} // namespace Catch // #included from: catch_stream.h #define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED @@ -3410,62 +3478,66 @@ namespace Catch { namespace Catch { - class StreamBufBase : public std::streambuf { - public: - virtual ~StreamBufBase() CATCH_NOEXCEPT; - }; -} +class StreamBufBase : public std::streambuf { +public: + virtual ~StreamBufBase() CATCH_NOEXCEPT; +}; +} // namespace Catch -#include -#include #include +#include +#include namespace Catch { - std::ostream& cout(); - std::ostream& cerr(); - - struct IStream { - virtual ~IStream() CATCH_NOEXCEPT; - virtual std::ostream& stream() const = 0; - }; - - class FileStream : public IStream { - mutable std::ofstream m_ofs; - public: - FileStream( std::string const& filename ); - virtual ~FileStream() CATCH_NOEXCEPT; - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; - - class CoutStream : public IStream { - mutable std::ostream m_os; - public: - CoutStream(); - virtual ~CoutStream() CATCH_NOEXCEPT; - - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; - - class DebugOutStream : public IStream { - std::auto_ptr m_streamBuf; - mutable std::ostream m_os; - public: - DebugOutStream(); - virtual ~DebugOutStream() CATCH_NOEXCEPT; - - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; -} +std::ostream &cout(); +std::ostream &cerr(); + +struct IStream { + virtual ~IStream() CATCH_NOEXCEPT; + virtual std::ostream &stream() const = 0; +}; + +class FileStream : public IStream { + mutable std::ofstream m_ofs; + +public: + FileStream(std::string const &filename); + virtual ~FileStream() CATCH_NOEXCEPT; + +public: // IStream + virtual std::ostream &stream() const CATCH_OVERRIDE; +}; + +class CoutStream : public IStream { + mutable std::ostream m_os; + +public: + CoutStream(); + virtual ~CoutStream() CATCH_NOEXCEPT; + +public: // IStream + virtual std::ostream &stream() const CATCH_OVERRIDE; +}; + +class DebugOutStream : public IStream { + std::auto_ptr m_streamBuf; + mutable std::ostream m_os; +public: + DebugOutStream(); + virtual ~DebugOutStream() CATCH_NOEXCEPT; + +public: // IStream + virtual std::ostream &stream() const CATCH_OVERRIDE; +}; +} // namespace Catch + +#include +#include #include -#include #include -#include -#include +#include #ifndef CATCH_CONFIG_CONSOLE_WIDTH #define CATCH_CONFIG_CONSOLE_WIDTH 80 @@ -3473,141 +3545,133 @@ namespace Catch { namespace Catch { - struct ConfigData { - - ConfigData() - : listTests( false ), - listTags( false ), - listReporters( false ), - listTestNamesOnly( false ), - showSuccessfulTests( false ), - shouldDebugBreak( false ), - noThrow( false ), - showHelp( false ), - showInvisibles( false ), - filenamesAsTags( false ), - abortAfter( -1 ), - rngSeed( 0 ), - verbosity( Verbosity::Normal ), - warnings( WarnAbout::Nothing ), - showDurations( ShowDurations::DefaultForReporter ), - runOrder( RunTests::InDeclarationOrder ), - useColour( UseColour::Auto ) - {} - - bool listTests; - bool listTags; - bool listReporters; - bool listTestNamesOnly; - - bool showSuccessfulTests; - bool shouldDebugBreak; - bool noThrow; - bool showHelp; - bool showInvisibles; - bool filenamesAsTags; - - int abortAfter; - unsigned int rngSeed; - - Verbosity::Level verbosity; - WarnAbout::What warnings; - ShowDurations::OrNot showDurations; - RunTests::InWhatOrder runOrder; - UseColour::YesOrNo useColour; - - std::string outputFilename; - std::string name; - std::string processName; - - std::vector reporterNames; - std::vector testsOrTags; - }; - - class Config : public SharedImpl { - private: - Config( Config const& other ); - Config& operator = ( Config const& other ); - virtual void dummy(); - public: - - Config() - {} - - Config( ConfigData const& data ) - : m_data( data ), - m_stream( openStream() ) - { - if( !data.testsOrTags.empty() ) { - TestSpecParser parser( ITagAliasRegistry::get() ); - for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) - parser.parse( data.testsOrTags[i] ); - m_testSpec = parser.testSpec(); - } - } +struct ConfigData { + + ConfigData() + : listTests(false), listTags(false), listReporters(false), + listTestNamesOnly(false), showSuccessfulTests(false), + shouldDebugBreak(false), noThrow(false), showHelp(false), + showInvisibles(false), filenamesAsTags(false), abortAfter(-1), + rngSeed(0), verbosity(Verbosity::Normal), warnings(WarnAbout::Nothing), + showDurations(ShowDurations::DefaultForReporter), + runOrder(RunTests::InDeclarationOrder), useColour(UseColour::Auto) {} + + bool listTests; + bool listTags; + bool listReporters; + bool listTestNamesOnly; + + bool showSuccessfulTests; + bool shouldDebugBreak; + bool noThrow; + bool showHelp; + bool showInvisibles; + bool filenamesAsTags; + + int abortAfter; + unsigned int rngSeed; + + Verbosity::Level verbosity; + WarnAbout::What warnings; + ShowDurations::OrNot showDurations; + RunTests::InWhatOrder runOrder; + UseColour::YesOrNo useColour; + + std::string outputFilename; + std::string name; + std::string processName; + + std::vector reporterNames; + std::vector testsOrTags; +}; - virtual ~Config() { - } +class Config : public SharedImpl { +private: + Config(Config const &other); + Config &operator=(Config const &other); + virtual void dummy(); - std::string const& getFilename() const { - return m_data.outputFilename ; - } +public: + Config() {} + + Config(ConfigData const &data) : m_data(data), m_stream(openStream()) { + if (!data.testsOrTags.empty()) { + TestSpecParser parser(ITagAliasRegistry::get()); + for (std::size_t i = 0; i < data.testsOrTags.size(); ++i) + parser.parse(data.testsOrTags[i]); + m_testSpec = parser.testSpec(); + } + } - bool listTests() const { return m_data.listTests; } - bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } - bool listTags() const { return m_data.listTags; } - bool listReporters() const { return m_data.listReporters; } + virtual ~Config() {} - std::string getProcessName() const { return m_data.processName; } + std::string const &getFilename() const { return m_data.outputFilename; } - bool shouldDebugBreak() const { return m_data.shouldDebugBreak; } + bool listTests() const { return m_data.listTests; } + bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } + bool listTags() const { return m_data.listTags; } + bool listReporters() const { return m_data.listReporters; } - std::vector getReporterNames() const { return m_data.reporterNames; } + std::string getProcessName() const { return m_data.processName; } - int abortAfter() const { return m_data.abortAfter; } + bool shouldDebugBreak() const { return m_data.shouldDebugBreak; } - TestSpec const& testSpec() const { return m_testSpec; } + std::vector getReporterNames() const { + return m_data.reporterNames; + } - bool showHelp() const { return m_data.showHelp; } - bool showInvisibles() const { return m_data.showInvisibles; } + int abortAfter() const { return m_data.abortAfter; } - // IConfig interface - virtual bool allowThrows() const { return !m_data.noThrow; } - virtual std::ostream& stream() const { return m_stream->stream(); } - virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } - virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; } - virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; } - virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; } - virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; } - virtual unsigned int rngSeed() const { return m_data.rngSeed; } - virtual UseColour::YesOrNo useColour() const { return m_data.useColour; } + TestSpec const &testSpec() const { return m_testSpec; } - private: + bool showHelp() const { return m_data.showHelp; } + bool showInvisibles() const { return m_data.showInvisibles; } - IStream const* openStream() { - if( m_data.outputFilename.empty() ) - return new CoutStream(); - else if( m_data.outputFilename[0] == '%' ) { - if( m_data.outputFilename == "%debug" ) - return new DebugOutStream(); - else - throw std::domain_error( "Unrecognised stream: " + m_data.outputFilename ); - } - else - return new FileStream( m_data.outputFilename ); - } - ConfigData m_data; + // IConfig interface + virtual bool allowThrows() const { return !m_data.noThrow; } + virtual std::ostream &stream() const { return m_stream->stream(); } + virtual std::string name() const { + return m_data.name.empty() ? m_data.processName : m_data.name; + } + virtual bool includeSuccessfulResults() const { + return m_data.showSuccessfulTests; + } + virtual bool warnAboutMissingAssertions() const { + return m_data.warnings & WarnAbout::NoAssertions; + } + virtual ShowDurations::OrNot showDurations() const { + return m_data.showDurations; + } + virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; } + virtual unsigned int rngSeed() const { return m_data.rngSeed; } + virtual UseColour::YesOrNo useColour() const { return m_data.useColour; } - std::auto_ptr m_stream; - TestSpec m_testSpec; - }; +private: + IStream const *openStream() { + if (m_data.outputFilename.empty()) + return new CoutStream(); + else if (m_data.outputFilename[0] == '%') { + if (m_data.outputFilename == "%debug") + return new DebugOutStream(); + else + throw std::domain_error("Unrecognised stream: " + + m_data.outputFilename); + } else + return new FileStream(m_data.outputFilename); + } + ConfigData m_data; + + std::auto_ptr m_stream; + TestSpec m_testSpec; +}; } // end namespace Catch // #included from: catch_clara.h #define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED -// Use Catch's value for console width (store Clara's off to the side, if present) +// Use Catch's value for console width (store Clara's off to the side, if +// present) #ifdef CLARA_CONFIG_CONSOLE_WIDTH #define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH #undef CLARA_CONFIG_CONSOLE_WIDTH @@ -3621,7 +3685,8 @@ namespace Catch { // Version 0.0.2.3 // Only use header guard if we are not using an outer namespace -#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE) +#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || \ + defined(STITCH_CLARA_OPEN_NAMESPACE) #ifndef STITCH_CLARA_OPEN_NAMESPACE #define TWOBLUECUBES_CLARA_H_INCLUDED @@ -3636,15 +3701,16 @@ namespace Catch { // ----------- #included from tbc_text_format.h ----------- // Only use header guard if we are not using an outer namespace -#if !defined(TBC_TEXT_FORMAT_H_INCLUDED) || defined(STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE) +#if !defined(TBC_TEXT_FORMAT_H_INCLUDED) || \ + defined(STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE) #ifndef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE #define TBC_TEXT_FORMAT_H_INCLUDED #endif +#include +#include #include #include -#include -#include // Use optional outer namespace #ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE @@ -3654,121 +3720,132 @@ namespace STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE { namespace Tbc { #ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH - const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; +const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; #else - const unsigned int consoleWidth = 80; -#endif - - struct TextAttributes { - TextAttributes() - : initialIndent( std::string::npos ), - indent( 0 ), - width( consoleWidth-1 ), - tabChar( '\t' ) - {} - - TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; } - TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; } - TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; } - TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; } - - std::size_t initialIndent; // indent of first line, or npos - std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos - std::size_t width; // maximum width of text, including indent. Longer text will wrap - char tabChar; // If this char is seen the indent is changed to current pos - }; - - class Text { - public: - Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() ) - : attr( _attr ) - { - std::string wrappableChars = " [({.,/|\\-"; - std::size_t indent = _attr.initialIndent != std::string::npos - ? _attr.initialIndent - : _attr.indent; - std::string remainder = _str; - - while( !remainder.empty() ) { - if( lines.size() >= 1000 ) { - lines.push_back( "... message truncated due to excessive size" ); - return; - } - std::size_t tabPos = std::string::npos; - std::size_t width = (std::min)( remainder.size(), _attr.width - indent ); - std::size_t pos = remainder.find_first_of( '\n' ); - if( pos <= width ) { - width = pos; - } - pos = remainder.find_last_of( _attr.tabChar, width ); - if( pos != std::string::npos ) { - tabPos = pos; - if( remainder[width] == '\n' ) - width--; - remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 ); - } - - if( width == remainder.size() ) { - spliceLine( indent, remainder, width ); - } - else if( remainder[width] == '\n' ) { - spliceLine( indent, remainder, width ); - if( width <= 1 || remainder.size() != 1 ) - remainder = remainder.substr( 1 ); - indent = _attr.indent; - } - else { - pos = remainder.find_last_of( wrappableChars, width ); - if( pos != std::string::npos && pos > 0 ) { - spliceLine( indent, remainder, pos ); - if( remainder[0] == ' ' ) - remainder = remainder.substr( 1 ); - } - else { - spliceLine( indent, remainder, width-1 ); - lines.back() += "-"; - } - if( lines.size() == 1 ) - indent = _attr.indent; - if( tabPos != std::string::npos ) - indent += tabPos; - } - } - } +const unsigned int consoleWidth = 80; +#endif - void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) { - lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) ); - _remainder = _remainder.substr( _pos ); - } +struct TextAttributes { + TextAttributes() + : initialIndent(std::string::npos), indent(0), width(consoleWidth - 1), + tabChar('\t') {} + + TextAttributes &setInitialIndent(std::size_t _value) { + initialIndent = _value; + return *this; + } + TextAttributes &setIndent(std::size_t _value) { + indent = _value; + return *this; + } + TextAttributes &setWidth(std::size_t _value) { + width = _value; + return *this; + } + TextAttributes &setTabChar(char _value) { + tabChar = _value; + return *this; + } + + std::size_t initialIndent; // indent of first line, or npos + std::size_t + indent; // indent of subsequent lines, or all if initialIndent is npos + std::size_t + width; // maximum width of text, including indent. Longer text will wrap + char tabChar; // If this char is seen the indent is changed to current pos +}; - typedef std::vector::const_iterator const_iterator; - - const_iterator begin() const { return lines.begin(); } - const_iterator end() const { return lines.end(); } - std::string const& last() const { return lines.back(); } - std::size_t size() const { return lines.size(); } - std::string const& operator[]( std::size_t _index ) const { return lines[_index]; } - std::string toString() const { - std::ostringstream oss; - oss << *this; - return oss.str(); - } +class Text { +public: + Text(std::string const &_str, TextAttributes const &_attr = TextAttributes()) + : attr(_attr) { + std::string wrappableChars = " [({.,/|\\-"; + std::size_t indent = _attr.initialIndent != std::string::npos + ? _attr.initialIndent + : _attr.indent; + std::string remainder = _str; + + while (!remainder.empty()) { + if (lines.size() >= 1000) { + lines.push_back("... message truncated due to excessive size"); + return; + } + std::size_t tabPos = std::string::npos; + std::size_t width = (std::min)(remainder.size(), _attr.width - indent); + std::size_t pos = remainder.find_first_of('\n'); + if (pos <= width) { + width = pos; + } + pos = remainder.find_last_of(_attr.tabChar, width); + if (pos != std::string::npos) { + tabPos = pos; + if (remainder[width] == '\n') + width--; + remainder = remainder.substr(0, tabPos) + remainder.substr(tabPos + 1); + } - inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { - for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); - it != itEnd; ++it ) { - if( it != _text.begin() ) - _stream << "\n"; - _stream << *it; - } - return _stream; - } + if (width == remainder.size()) { + spliceLine(indent, remainder, width); + } else if (remainder[width] == '\n') { + spliceLine(indent, remainder, width); + if (width <= 1 || remainder.size() != 1) + remainder = remainder.substr(1); + indent = _attr.indent; + } else { + pos = remainder.find_last_of(wrappableChars, width); + if (pos != std::string::npos && pos > 0) { + spliceLine(indent, remainder, pos); + if (remainder[0] == ' ') + remainder = remainder.substr(1); + } else { + spliceLine(indent, remainder, width - 1); + lines.back() += "-"; + } + if (lines.size() == 1) + indent = _attr.indent; + if (tabPos != std::string::npos) + indent += tabPos; + } + } + } + + void spliceLine(std::size_t _indent, std::string &_remainder, + std::size_t _pos) { + lines.push_back(std::string(_indent, ' ') + _remainder.substr(0, _pos)); + _remainder = _remainder.substr(_pos); + } + + typedef std::vector::const_iterator const_iterator; + + const_iterator begin() const { return lines.begin(); } + const_iterator end() const { return lines.end(); } + std::string const &last() const { return lines.back(); } + std::size_t size() const { return lines.size(); } + std::string const &operator[](std::size_t _index) const { + return lines[_index]; + } + std::string toString() const { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + + inline friend std::ostream &operator<<(std::ostream &_stream, + Text const &_text) { + for (Text::const_iterator it = _text.begin(), itEnd = _text.end(); + it != itEnd; ++it) { + if (it != _text.begin()) + _stream << "\n"; + _stream << *it; + } + return _stream; + } - private: - std::string str; - TextAttributes attr; - std::vector lines; - }; +private: + std::string str; + TextAttributes attr; + std::vector lines; +}; } // end namespace Tbc @@ -3788,14 +3865,15 @@ namespace Tbc { #ifndef TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED #define TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED -// Detect a number of compiler features - mostly C++11/14 conformance - by compiler -// The following features are defined: +// Detect a number of compiler features - mostly C++11/14 conformance - by +// compiler The following features are defined: // // CLARA_CONFIG_CPP11_NULLPTR : is nullptr supported? // CLARA_CONFIG_CPP11_NOEXCEPT : is noexcept supported? -// CLARA_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods -// CLARA_CONFIG_CPP11_OVERRIDE : is override supported? -// CLARA_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr) +// CLARA_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for +// compiler generated methods CLARA_CONFIG_CPP11_OVERRIDE : is override +// supported? CLARA_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise +// use auto_ptr) // CLARA_CONFIG_CPP11_OR_GREATER : Is C++11 supported? @@ -3842,7 +3920,7 @@ namespace Tbc { #define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR #endif -#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) +#if (_MSC_VER >= 1900) // (VC++ 13 (VS2015)) #define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT #define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS #endif @@ -3878,30 +3956,42 @@ namespace Tbc { #endif // __cplusplus >= 201103L -// Now set the actual defines based on the above + anything the user has configured -#if defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NO_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_NO_CPP11) +// Now set the actual defines based on the above + anything the user has +// configured +#if defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) && \ + !defined(CLARA_CONFIG_CPP11_NO_NULLPTR) && \ + !defined(CLARA_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_NO_CPP11) #define CLARA_CONFIG_CPP11_NULLPTR #endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_NO_CPP11) +#if defined(CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT) && \ + !defined(CLARA_CONFIG_CPP11_NO_NOEXCEPT) && \ + !defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_NO_CPP11) #define CLARA_CONFIG_CPP11_NOEXCEPT #endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_NO_CPP11) +#if defined(CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && \ + !defined(CLARA_CONFIG_CPP11_NO_GENERATED_METHODS) && \ + !defined(CLARA_CONFIG_CPP11_GENERATED_METHODS) && \ + !defined(CLARA_CONFIG_NO_CPP11) #define CLARA_CONFIG_CPP11_GENERATED_METHODS #endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_OVERRIDE) && !defined(CLARA_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_CPP11) +#if defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) && \ + !defined(CLARA_CONFIG_NO_OVERRIDE) && \ + !defined(CLARA_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_CPP11) #define CLARA_CONFIG_CPP11_OVERRIDE #endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_UNIQUE_PTR) && !defined(CLARA_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_CPP11) +#if defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && \ + !defined(CLARA_CONFIG_NO_UNIQUE_PTR) && \ + !defined(CLARA_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_CPP11) #define CLARA_CONFIG_CPP11_UNIQUE_PTR #endif // noexcept support: #if defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_NOEXCEPT) #define CLARA_NOEXCEPT noexcept -# define CLARA_NOEXCEPT_IS(x) noexcept(x) +#define CLARA_NOEXCEPT_IS(x) noexcept(x) #else #define CLARA_NOEXCEPT throw() -# define CLARA_NOEXCEPT_IS(x) +#define CLARA_NOEXCEPT_IS(x) #endif // nullptr support @@ -3920,9 +4010,9 @@ namespace Tbc { // unique_ptr support #ifdef CLARA_CONFIG_CPP11_UNIQUE_PTR -# define CLARA_AUTO_PTR( T ) std::unique_ptr +#define CLARA_AUTO_PTR(T) std::unique_ptr #else -# define CLARA_AUTO_PTR( T ) std::auto_ptr +#define CLARA_AUTO_PTR(T) std::auto_ptr #endif #endif // TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED @@ -3931,8 +4021,8 @@ namespace Tbc { // ........... back in clara.h #include -#include #include +#include #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) #define CLARA_PLATFORM_WINDOWS @@ -3945,683 +4035,724 @@ STITCH_CLARA_OPEN_NAMESPACE namespace Clara { - struct UnpositionalTag {}; +struct UnpositionalTag {}; - extern UnpositionalTag _; +extern UnpositionalTag _; #ifdef CLARA_CONFIG_MAIN - UnpositionalTag _; +UnpositionalTag _; #endif - namespace Detail { +namespace Detail { #ifdef CLARA_CONSOLE_WIDTH - const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH; +const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH; #else - const unsigned int consoleWidth = 80; +const unsigned int consoleWidth = 80; #endif - using namespace Tbc; +using namespace Tbc; - inline bool startsWith( std::string const& str, std::string const& prefix ) { - return str.size() >= prefix.size() && str.substr( 0, prefix.size() ) == prefix; - } - - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - - template struct IsBool { static const bool value = false; }; - template<> struct IsBool { static const bool value = true; }; - - template - void convertInto( std::string const& _source, T& _dest ) { - std::stringstream ss; - ss << _source; - ss >> _dest; - if( ss.fail() ) - throw std::runtime_error( "Unable to convert " + _source + " to destination type" ); - } - inline void convertInto( std::string const& _source, std::string& _dest ) { - _dest = _source; - } - inline void convertInto( std::string const& _source, bool& _dest ) { - std::string sourceLC = _source; - std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower ); - if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" ) - _dest = true; - else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" ) - _dest = false; - else - throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" ); - } +inline bool startsWith(std::string const &str, std::string const &prefix) { + return str.size() >= prefix.size() && str.substr(0, prefix.size()) == prefix; +} - template - struct IArgFunction { - virtual ~IArgFunction() {} -#ifdef CLARA_CONFIG_CPP11_GENERATED_METHODS - IArgFunction() = default; - IArgFunction( IArgFunction const& ) = default; -#endif - virtual void set( ConfigT& config, std::string const& value ) const = 0; - virtual bool takesArg() const = 0; - virtual IArgFunction* clone() const = 0; - }; - - template - class BoundArgFunction { - public: - BoundArgFunction() : functionObj( CLARA_NULL ) {} - BoundArgFunction( IArgFunction* _functionObj ) : functionObj( _functionObj ) {} - BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CLARA_NULL ) {} - BoundArgFunction& operator = ( BoundArgFunction const& other ) { - IArgFunction* newFunctionObj = other.functionObj ? other.functionObj->clone() : CLARA_NULL; - delete functionObj; - functionObj = newFunctionObj; - return *this; - } - ~BoundArgFunction() { delete functionObj; } - - void set( ConfigT& config, std::string const& value ) const { - functionObj->set( config, value ); - } - bool takesArg() const { return functionObj->takesArg(); } - - bool isSet() const { - return functionObj != CLARA_NULL; - } - private: - IArgFunction* functionObj; - }; - - template - struct NullBinder : IArgFunction{ - virtual void set( C&, std::string const& ) const {} - virtual bool takesArg() const { return true; } - virtual IArgFunction* clone() const { return new NullBinder( *this ); } - }; - - template - struct BoundDataMember : IArgFunction{ - BoundDataMember( M C::* _member ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - convertInto( stringValue, p.*member ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundDataMember( *this ); } - M C::* member; - }; - template - struct BoundUnaryMethod : IArgFunction{ - BoundUnaryMethod( void (C::*_member)( M ) ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - typename RemoveConstRef::type value; - convertInto( stringValue, value ); - (p.*member)( value ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundUnaryMethod( *this ); } - void (C::*member)( M ); - }; - template - struct BoundNullaryMethod : IArgFunction{ - BoundNullaryMethod( void (C::*_member)() ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - bool value; - convertInto( stringValue, value ); - if( value ) - (p.*member)(); - } - virtual bool takesArg() const { return false; } - virtual IArgFunction* clone() const { return new BoundNullaryMethod( *this ); } - void (C::*member)(); - }; - - template - struct BoundUnaryFunction : IArgFunction{ - BoundUnaryFunction( void (*_function)( C& ) ) : function( _function ) {} - virtual void set( C& obj, std::string const& stringValue ) const { - bool value; - convertInto( stringValue, value ); - if( value ) - function( obj ); - } - virtual bool takesArg() const { return false; } - virtual IArgFunction* clone() const { return new BoundUnaryFunction( *this ); } - void (*function)( C& ); - }; - - template - struct BoundBinaryFunction : IArgFunction{ - BoundBinaryFunction( void (*_function)( C&, T ) ) : function( _function ) {} - virtual void set( C& obj, std::string const& stringValue ) const { - typename RemoveConstRef::type value; - convertInto( stringValue, value ); - function( obj, value ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundBinaryFunction( *this ); } - void (*function)( C&, T ); - }; - - } // namespace Detail - - inline std::vector argsToVector( int argc, char const* const* const argv ) { - std::vector args( static_cast( argc ) ); - for( std::size_t i = 0; i < static_cast( argc ); ++i ) - args[i] = argv[i]; - - return args; - } - - class Parser { - enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional }; - Mode mode; - std::size_t from; - bool inQuotes; - public: - - struct Token { - enum Type { Positional, ShortOpt, LongOpt }; - Token( Type _type, std::string const& _data ) : type( _type ), data( _data ) {} - Type type; - std::string data; - }; - - Parser() : mode( None ), from( 0 ), inQuotes( false ){} +template struct RemoveConstRef { + typedef T type; +}; +template struct RemoveConstRef { + typedef T type; +}; +template struct RemoveConstRef { + typedef T type; +}; +template struct RemoveConstRef { + typedef T type; +}; - void parseIntoTokens( std::vector const& args, std::vector& tokens ) { - const std::string doubleDash = "--"; - for( std::size_t i = 1; i < args.size() && args[i] != doubleDash; ++i ) - parseIntoTokens( args[i], tokens); - } +template struct IsBool { + static const bool value = false; +}; +template <> struct IsBool { + static const bool value = true; +}; - void parseIntoTokens( std::string const& arg, std::vector& tokens ) { - for( std::size_t i = 0; i <= arg.size(); ++i ) { - char c = arg[i]; - if( c == '"' ) - inQuotes = !inQuotes; - mode = handleMode( i, c, arg, tokens ); - } - } - Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - switch( mode ) { - case None: return handleNone( i, c ); - case MaybeShortOpt: return handleMaybeShortOpt( i, c ); - case ShortOpt: - case LongOpt: - case SlashOpt: return handleOpt( i, c, arg, tokens ); - case Positional: return handlePositional( i, c, arg, tokens ); - default: throw std::logic_error( "Unknown mode" ); - } - } +template void convertInto(std::string const &_source, T &_dest) { + std::stringstream ss; + ss << _source; + ss >> _dest; + if (ss.fail()) + throw std::runtime_error("Unable to convert " + _source + + " to destination type"); +} +inline void convertInto(std::string const &_source, std::string &_dest) { + _dest = _source; +} +inline void convertInto(std::string const &_source, bool &_dest) { + std::string sourceLC = _source; + std::transform(sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower); + if (sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || + sourceLC == "yes" || sourceLC == "on") + _dest = true; + else if (sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || + sourceLC == "no" || sourceLC == "off") + _dest = false; + else + throw std::runtime_error( + "Expected a boolean value but did not recognise:\n '" + _source + "'"); +} - Mode handleNone( std::size_t i, char c ) { - if( inQuotes ) { - from = i; - return Positional; - } - switch( c ) { - case '-': return MaybeShortOpt; -#ifdef CLARA_PLATFORM_WINDOWS - case '/': from = i+1; return SlashOpt; +template struct IArgFunction { + virtual ~IArgFunction() {} +#ifdef CLARA_CONFIG_CPP11_GENERATED_METHODS + IArgFunction() = default; + IArgFunction(IArgFunction const &) = default; #endif - default: from = i; return Positional; - } - } - Mode handleMaybeShortOpt( std::size_t i, char c ) { - switch( c ) { - case '-': from = i+1; return LongOpt; - default: from = i; return ShortOpt; - } - } - Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( std::string( " \t:=\0", 5 ).find( c ) == std::string::npos ) - return mode; - - std::string optName = arg.substr( from, i-from ); - if( mode == ShortOpt ) - for( std::size_t j = 0; j < optName.size(); ++j ) - tokens.push_back( Token( Token::ShortOpt, optName.substr( j, 1 ) ) ); - else if( mode == SlashOpt && optName.size() == 1 ) - tokens.push_back( Token( Token::ShortOpt, optName ) ); - else - tokens.push_back( Token( Token::LongOpt, optName ) ); - return None; - } - Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( inQuotes || std::string( " \t\0", 3 ).find( c ) == std::string::npos ) - return mode; - - std::string data = arg.substr( from, i-from ); - tokens.push_back( Token( Token::Positional, data ) ); - return None; - } - }; - - template - struct CommonArgProperties { - CommonArgProperties() {} - CommonArgProperties( Detail::BoundArgFunction const& _boundField ) : boundField( _boundField ) {} - - Detail::BoundArgFunction boundField; - std::string description; - std::string detail; - std::string placeholder; // Only value if boundField takes an arg - - bool takesArg() const { - return !placeholder.empty(); - } - void validate() const { - if( !boundField.isSet() ) - throw std::logic_error( "option not bound" ); - } - }; - struct OptionArgProperties { - std::vector shortNames; - std::string longName; - - bool hasShortName( std::string const& shortName ) const { - return std::find( shortNames.begin(), shortNames.end(), shortName ) != shortNames.end(); - } - bool hasLongName( std::string const& _longName ) const { - return _longName == longName; - } - }; - struct PositionalArgProperties { - PositionalArgProperties() : position( -1 ) {} - int position; // -1 means non-positional (floating) - - bool isFixedPositional() const { - return position != -1; - } - }; - - template - class CommandLine { - - struct Arg : CommonArgProperties, OptionArgProperties, PositionalArgProperties { - Arg() {} - Arg( Detail::BoundArgFunction const& _boundField ) : CommonArgProperties( _boundField ) {} + virtual void set(ConfigT &config, std::string const &value) const = 0; + virtual bool takesArg() const = 0; + virtual IArgFunction *clone() const = 0; +}; - using CommonArgProperties::placeholder; // !TBD +template class BoundArgFunction { +public: + BoundArgFunction() : functionObj(CLARA_NULL) {} + BoundArgFunction(IArgFunction *_functionObj) + : functionObj(_functionObj) {} + BoundArgFunction(BoundArgFunction const &other) + : functionObj(other.functionObj ? other.functionObj->clone() + : CLARA_NULL) {} + BoundArgFunction &operator=(BoundArgFunction const &other) { + IArgFunction *newFunctionObj = + other.functionObj ? other.functionObj->clone() : CLARA_NULL; + delete functionObj; + functionObj = newFunctionObj; + return *this; + } + ~BoundArgFunction() { delete functionObj; } + + void set(ConfigT &config, std::string const &value) const { + functionObj->set(config, value); + } + bool takesArg() const { return functionObj->takesArg(); } + + bool isSet() const { return functionObj != CLARA_NULL; } - std::string dbgName() const { - if( !longName.empty() ) - return "--" + longName; - if( !shortNames.empty() ) - return "-" + shortNames[0]; - return "positional args"; - } - std::string commands() const { - std::ostringstream oss; - bool first = true; - std::vector::const_iterator it = shortNames.begin(), itEnd = shortNames.end(); - for(; it != itEnd; ++it ) { - if( first ) - first = false; - else - oss << ", "; - oss << "-" << *it; - } - if( !longName.empty() ) { - if( !first ) - oss << ", "; - oss << "--" << longName; - } - if( !placeholder.empty() ) - oss << " <" << placeholder << ">"; - return oss.str(); - } - }; +private: + IArgFunction *functionObj; +}; - typedef CLARA_AUTO_PTR( Arg ) ArgAutoPtr; +template struct NullBinder : IArgFunction { + virtual void set(C &, std::string const &) const {} + virtual bool takesArg() const { return true; } + virtual IArgFunction *clone() const { return new NullBinder(*this); } +}; - friend void addOptName( Arg& arg, std::string const& optName ) - { - if( optName.empty() ) - return; - if( Detail::startsWith( optName, "--" ) ) { - if( !arg.longName.empty() ) - throw std::logic_error( "Only one long opt may be specified. '" - + arg.longName - + "' already specified, now attempting to add '" - + optName + "'" ); - arg.longName = optName.substr( 2 ); - } - else if( Detail::startsWith( optName, "-" ) ) - arg.shortNames.push_back( optName.substr( 1 ) ); - else - throw std::logic_error( "option must begin with - or --. Option was: '" + optName + "'" ); - } - friend void setPositionalArg( Arg& arg, int position ) - { - arg.position = position; - } +template struct BoundDataMember : IArgFunction { + BoundDataMember(M C::*_member) : member(_member) {} + virtual void set(C &p, std::string const &stringValue) const { + convertInto(stringValue, p.*member); + } + virtual bool takesArg() const { return !IsBool::value; } + virtual IArgFunction *clone() const { return new BoundDataMember(*this); } + M C::*member; +}; +template struct BoundUnaryMethod : IArgFunction { + BoundUnaryMethod(void (C::*_member)(M)) : member(_member) {} + virtual void set(C &p, std::string const &stringValue) const { + typename RemoveConstRef::type value; + convertInto(stringValue, value); + (p.*member)(value); + } + virtual bool takesArg() const { return !IsBool::value; } + virtual IArgFunction *clone() const { return new BoundUnaryMethod(*this); } + void (C::*member)(M); +}; +template struct BoundNullaryMethod : IArgFunction { + BoundNullaryMethod(void (C::*_member)()) : member(_member) {} + virtual void set(C &p, std::string const &stringValue) const { + bool value; + convertInto(stringValue, value); + if (value) + (p.*member)(); + } + virtual bool takesArg() const { return false; } + virtual IArgFunction *clone() const { + return new BoundNullaryMethod(*this); + } + void (C::*member)(); +}; - class ArgBuilder { - public: - ArgBuilder( Arg* arg ) : m_arg( arg ) {} +template struct BoundUnaryFunction : IArgFunction { + BoundUnaryFunction(void (*_function)(C &)) : function(_function) {} + virtual void set(C &obj, std::string const &stringValue) const { + bool value; + convertInto(stringValue, value); + if (value) + function(obj); + } + virtual bool takesArg() const { return false; } + virtual IArgFunction *clone() const { + return new BoundUnaryFunction(*this); + } + void (*function)(C &); +}; - // Bind a non-boolean data member (requires placeholder string) - template - void bind( M C::* field, std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundDataMember( field ); - m_arg->placeholder = placeholder; - } - // Bind a boolean data member (no placeholder required) - template - void bind( bool C::* field ) { - m_arg->boundField = new Detail::BoundDataMember( field ); - } +template struct BoundBinaryFunction : IArgFunction { + BoundBinaryFunction(void (*_function)(C &, T)) : function(_function) {} + virtual void set(C &obj, std::string const &stringValue) const { + typename RemoveConstRef::type value; + convertInto(stringValue, value); + function(obj, value); + } + virtual bool takesArg() const { return !IsBool::value; } + virtual IArgFunction *clone() const { + return new BoundBinaryFunction(*this); + } + void (*function)(C &, T); +}; - // Bind a method taking a single, non-boolean argument (requires a placeholder string) - template - void bind( void (C::* unaryMethod)( M ), std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundUnaryMethod( unaryMethod ); - m_arg->placeholder = placeholder; - } +} // namespace Detail - // Bind a method taking a single, boolean argument (no placeholder string required) - template - void bind( void (C::* unaryMethod)( bool ) ) { - m_arg->boundField = new Detail::BoundUnaryMethod( unaryMethod ); - } +inline std::vector argsToVector(int argc, + char const *const *const argv) { + std::vector args(static_cast(argc)); + for (std::size_t i = 0; i < static_cast(argc); ++i) + args[i] = argv[i]; - // Bind a method that takes no arguments (will be called if opt is present) - template - void bind( void (C::* nullaryMethod)() ) { - m_arg->boundField = new Detail::BoundNullaryMethod( nullaryMethod ); - } + return args; +} - // Bind a free function taking a single argument - the object to operate on (no placeholder string required) - template - void bind( void (* unaryFunction)( C& ) ) { - m_arg->boundField = new Detail::BoundUnaryFunction( unaryFunction ); - } +class Parser { + enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional }; + Mode mode; + std::size_t from; + bool inQuotes; - // Bind a free function taking a single argument - the object to operate on (requires a placeholder string) - template - void bind( void (* binaryFunction)( C&, T ), std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundBinaryFunction( binaryFunction ); - m_arg->placeholder = placeholder; - } +public: + struct Token { + enum Type { Positional, ShortOpt, LongOpt }; + Token(Type _type, std::string const &_data) : type(_type), data(_data) {} + Type type; + std::string data; + }; - ArgBuilder& describe( std::string const& description ) { - m_arg->description = description; - return *this; - } - ArgBuilder& detail( std::string const& detail ) { - m_arg->detail = detail; - return *this; - } + Parser() : mode(None), from(0), inQuotes(false) {} + + void parseIntoTokens(std::vector const &args, + std::vector &tokens) { + const std::string doubleDash = "--"; + for (std::size_t i = 1; i < args.size() && args[i] != doubleDash; ++i) + parseIntoTokens(args[i], tokens); + } + + void parseIntoTokens(std::string const &arg, std::vector &tokens) { + for (std::size_t i = 0; i <= arg.size(); ++i) { + char c = arg[i]; + if (c == '"') + inQuotes = !inQuotes; + mode = handleMode(i, c, arg, tokens); + } + } + Mode handleMode(std::size_t i, char c, std::string const &arg, + std::vector &tokens) { + switch (mode) { + case None: + return handleNone(i, c); + case MaybeShortOpt: + return handleMaybeShortOpt(i, c); + case ShortOpt: + case LongOpt: + case SlashOpt: + return handleOpt(i, c, arg, tokens); + case Positional: + return handlePositional(i, c, arg, tokens); + default: + throw std::logic_error("Unknown mode"); + } + } + + Mode handleNone(std::size_t i, char c) { + if (inQuotes) { + from = i; + return Positional; + } + switch (c) { + case '-': + return MaybeShortOpt; +#ifdef CLARA_PLATFORM_WINDOWS + case '/': + from = i + 1; + return SlashOpt; +#endif + default: + from = i; + return Positional; + } + } + Mode handleMaybeShortOpt(std::size_t i, char c) { + switch (c) { + case '-': + from = i + 1; + return LongOpt; + default: + from = i; + return ShortOpt; + } + } + Mode handleOpt(std::size_t i, char c, std::string const &arg, + std::vector &tokens) { + if (std::string(" \t:=\0", 5).find(c) == std::string::npos) + return mode; + + std::string optName = arg.substr(from, i - from); + if (mode == ShortOpt) + for (std::size_t j = 0; j < optName.size(); ++j) + tokens.push_back(Token(Token::ShortOpt, optName.substr(j, 1))); + else if (mode == SlashOpt && optName.size() == 1) + tokens.push_back(Token(Token::ShortOpt, optName)); + else + tokens.push_back(Token(Token::LongOpt, optName)); + return None; + } + Mode handlePositional(std::size_t i, char c, std::string const &arg, + std::vector &tokens) { + if (inQuotes || std::string(" \t\0", 3).find(c) == std::string::npos) + return mode; + + std::string data = arg.substr(from, i - from); + tokens.push_back(Token(Token::Positional, data)); + return None; + } +}; - protected: - Arg* m_arg; - }; +template struct CommonArgProperties { + CommonArgProperties() {} + CommonArgProperties(Detail::BoundArgFunction const &_boundField) + : boundField(_boundField) {} + + Detail::BoundArgFunction boundField; + std::string description; + std::string detail; + std::string placeholder; // Only value if boundField takes an arg + + bool takesArg() const { return !placeholder.empty(); } + void validate() const { + if (!boundField.isSet()) + throw std::logic_error("option not bound"); + } +}; +struct OptionArgProperties { + std::vector shortNames; + std::string longName; + + bool hasShortName(std::string const &shortName) const { + return std::find(shortNames.begin(), shortNames.end(), shortName) != + shortNames.end(); + } + bool hasLongName(std::string const &_longName) const { + return _longName == longName; + } +}; +struct PositionalArgProperties { + PositionalArgProperties() : position(-1) {} + int position; // -1 means non-positional (floating) - class OptBuilder : public ArgBuilder { - public: - OptBuilder( Arg* arg ) : ArgBuilder( arg ) {} - OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {} + bool isFixedPositional() const { return position != -1; } +}; - OptBuilder& operator[]( std::string const& optName ) { - addOptName( *ArgBuilder::m_arg, optName ); - return *this; - } - }; - - public: - - CommandLine() - : m_boundProcessName( new Detail::NullBinder() ), - m_highestSpecifiedArgPosition( 0 ), - m_throwOnUnrecognisedTokens( false ) - {} - CommandLine( CommandLine const& other ) - : m_boundProcessName( other.m_boundProcessName ), - m_options ( other.m_options ), - m_positionalArgs( other.m_positionalArgs ), - m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ), - m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens ) - { - if( other.m_floatingArg.get() ) - m_floatingArg.reset( new Arg( *other.m_floatingArg ) ); - } +template class CommandLine { + + struct Arg : CommonArgProperties, + OptionArgProperties, + PositionalArgProperties { + Arg() {} + Arg(Detail::BoundArgFunction const &_boundField) + : CommonArgProperties(_boundField) {} + + using CommonArgProperties::placeholder; // !TBD + + std::string dbgName() const { + if (!longName.empty()) + return "--" + longName; + if (!shortNames.empty()) + return "-" + shortNames[0]; + return "positional args"; + } + std::string commands() const { + std::ostringstream oss; + bool first = true; + std::vector::const_iterator it = shortNames.begin(), + itEnd = shortNames.end(); + for (; it != itEnd; ++it) { + if (first) + first = false; + else + oss << ", "; + oss << "-" << *it; + } + if (!longName.empty()) { + if (!first) + oss << ", "; + oss << "--" << longName; + } + if (!placeholder.empty()) + oss << " <" << placeholder << ">"; + return oss.str(); + } + }; - CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) { - m_throwOnUnrecognisedTokens = shouldThrow; - return *this; - } + typedef CLARA_AUTO_PTR(Arg) ArgAutoPtr; + + friend void addOptName(Arg &arg, std::string const &optName) { + if (optName.empty()) + return; + if (Detail::startsWith(optName, "--")) { + if (!arg.longName.empty()) + throw std::logic_error( + "Only one long opt may be specified. '" + arg.longName + + "' already specified, now attempting to add '" + optName + "'"); + arg.longName = optName.substr(2); + } else if (Detail::startsWith(optName, "-")) + arg.shortNames.push_back(optName.substr(1)); + else + throw std::logic_error("option must begin with - or --. Option was: '" + + optName + "'"); + } + friend void setPositionalArg(Arg &arg, int position) { + arg.position = position; + } - OptBuilder operator[]( std::string const& optName ) { - m_options.push_back( Arg() ); - addOptName( m_options.back(), optName ); - OptBuilder builder( &m_options.back() ); - return builder; - } + class ArgBuilder { + public: + ArgBuilder(Arg *arg) : m_arg(arg) {} - ArgBuilder operator[]( int position ) { - m_positionalArgs.insert( std::make_pair( position, Arg() ) ); - if( position > m_highestSpecifiedArgPosition ) - m_highestSpecifiedArgPosition = position; - setPositionalArg( m_positionalArgs[position], position ); - ArgBuilder builder( &m_positionalArgs[position] ); - return builder; - } + // Bind a non-boolean data member (requires placeholder string) + template + void bind(M C::*field, std::string const &placeholder) { + m_arg->boundField = new Detail::BoundDataMember(field); + m_arg->placeholder = placeholder; + } + // Bind a boolean data member (no placeholder required) + template void bind(bool C::*field) { + m_arg->boundField = new Detail::BoundDataMember(field); + } - // Invoke this with the _ instance - ArgBuilder operator[]( UnpositionalTag ) { - if( m_floatingArg.get() ) - throw std::logic_error( "Only one unpositional argument can be added" ); - m_floatingArg.reset( new Arg() ); - ArgBuilder builder( m_floatingArg.get() ); - return builder; - } + // Bind a method taking a single, non-boolean argument (requires a + // placeholder string) + template + void bind(void (C::*unaryMethod)(M), std::string const &placeholder) { + m_arg->boundField = new Detail::BoundUnaryMethod(unaryMethod); + m_arg->placeholder = placeholder; + } - template - void bindProcessName( M C::* field ) { - m_boundProcessName = new Detail::BoundDataMember( field ); - } - template - void bindProcessName( void (C::*_unaryMethod)( M ) ) { - m_boundProcessName = new Detail::BoundUnaryMethod( _unaryMethod ); - } + // Bind a method taking a single, boolean argument (no placeholder string + // required) + template void bind(void (C::*unaryMethod)(bool)) { + m_arg->boundField = new Detail::BoundUnaryMethod(unaryMethod); + } - void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const { - typename std::vector::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it; - std::size_t maxWidth = 0; - for( it = itBegin; it != itEnd; ++it ) - maxWidth = (std::max)( maxWidth, it->commands().size() ); - - for( it = itBegin; it != itEnd; ++it ) { - Detail::Text usage( it->commands(), Detail::TextAttributes() - .setWidth( maxWidth+indent ) - .setIndent( indent ) ); - Detail::Text desc( it->description, Detail::TextAttributes() - .setWidth( width - maxWidth - 3 ) ); - - for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) { - std::string usageCol = i < usage.size() ? usage[i] : ""; - os << usageCol; - - if( i < desc.size() && !desc[i].empty() ) - os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' ) - << desc[i]; - os << "\n"; - } - } - } - std::string optUsage() const { - std::ostringstream oss; - optUsage( oss ); - return oss.str(); - } + // Bind a method that takes no arguments (will be called if opt is present) + template void bind(void (C::*nullaryMethod)()) { + m_arg->boundField = new Detail::BoundNullaryMethod(nullaryMethod); + } - void argSynopsis( std::ostream& os ) const { - for( int i = 1; i <= m_highestSpecifiedArgPosition; ++i ) { - if( i > 1 ) - os << " "; - typename std::map::const_iterator it = m_positionalArgs.find( i ); - if( it != m_positionalArgs.end() ) - os << "<" << it->second.placeholder << ">"; - else if( m_floatingArg.get() ) - os << "<" << m_floatingArg->placeholder << ">"; - else - throw std::logic_error( "non consecutive positional arguments with no floating args" ); - } - // !TBD No indication of mandatory args - if( m_floatingArg.get() ) { - if( m_highestSpecifiedArgPosition > 1 ) - os << " "; - os << "[<" << m_floatingArg->placeholder << "> ...]"; - } - } - std::string argSynopsis() const { - std::ostringstream oss; - argSynopsis( oss ); - return oss.str(); - } + // Bind a free function taking a single argument - the object to operate on + // (no placeholder string required) + template void bind(void (*unaryFunction)(C &)) { + m_arg->boundField = new Detail::BoundUnaryFunction(unaryFunction); + } - void usage( std::ostream& os, std::string const& procName ) const { - validate(); - os << "usage:\n " << procName << " "; - argSynopsis( os ); - if( !m_options.empty() ) { - os << " [options]\n\nwhere options are: \n"; - optUsage( os, 2 ); - } - os << "\n"; - } - std::string usage( std::string const& procName ) const { - std::ostringstream oss; - usage( oss, procName ); - return oss.str(); - } + // Bind a free function taking a single argument - the object to operate on + // (requires a placeholder string) + template + void bind(void (*binaryFunction)(C &, T), std::string const &placeholder) { + m_arg->boundField = new Detail::BoundBinaryFunction(binaryFunction); + m_arg->placeholder = placeholder; + } - ConfigT parse( std::vector const& args ) const { - ConfigT config; - parseInto( args, config ); - return config; - } + ArgBuilder &describe(std::string const &description) { + m_arg->description = description; + return *this; + } + ArgBuilder &detail(std::string const &detail) { + m_arg->detail = detail; + return *this; + } - std::vector parseInto( std::vector const& args, ConfigT& config ) const { - std::string processName = args[0]; - std::size_t lastSlash = processName.find_last_of( "/\\" ); - if( lastSlash != std::string::npos ) - processName = processName.substr( lastSlash+1 ); - m_boundProcessName.set( config, processName ); - std::vector tokens; - Parser parser; - parser.parseIntoTokens( args, tokens ); - return populate( tokens, config ); - } + protected: + Arg *m_arg; + }; - std::vector populate( std::vector const& tokens, ConfigT& config ) const { - validate(); - std::vector unusedTokens = populateOptions( tokens, config ); - unusedTokens = populateFixedArgs( unusedTokens, config ); - unusedTokens = populateFloatingArgs( unusedTokens, config ); - return unusedTokens; - } + class OptBuilder : public ArgBuilder { + public: + OptBuilder(Arg *arg) : ArgBuilder(arg) {} + OptBuilder(OptBuilder &other) : ArgBuilder(other) {} - std::vector populateOptions( std::vector const& tokens, ConfigT& config ) const { - std::vector unusedTokens; - std::vector errors; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - typename std::vector::const_iterator it = m_options.begin(), itEnd = m_options.end(); - for(; it != itEnd; ++it ) { - Arg const& arg = *it; - - try { - if( ( token.type == Parser::Token::ShortOpt && arg.hasShortName( token.data ) ) || - ( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) { - if( arg.takesArg() ) { - if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional ) - errors.push_back( "Expected argument to option: " + token.data ); - else - arg.boundField.set( config, tokens[++i].data ); - } - else { - arg.boundField.set( config, "true" ); - } - break; - } - } - catch( std::exception& ex ) { - errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" ); - } - } - if( it == itEnd ) { - if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens ) - unusedTokens.push_back( token ); - else if( errors.empty() && m_throwOnUnrecognisedTokens ) - errors.push_back( "unrecognised option: " + token.data ); - } - } - if( !errors.empty() ) { - std::ostringstream oss; - for( std::vector::const_iterator it = errors.begin(), itEnd = errors.end(); - it != itEnd; - ++it ) { - if( it != errors.begin() ) - oss << "\n"; - oss << *it; - } - throw std::runtime_error( oss.str() ); - } - return unusedTokens; - } - std::vector populateFixedArgs( std::vector const& tokens, ConfigT& config ) const { - std::vector unusedTokens; - int position = 1; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - typename std::map::const_iterator it = m_positionalArgs.find( position ); - if( it != m_positionalArgs.end() ) - it->second.boundField.set( config, token.data ); - else - unusedTokens.push_back( token ); - if( token.type == Parser::Token::Positional ) - position++; - } - return unusedTokens; - } - std::vector populateFloatingArgs( std::vector const& tokens, ConfigT& config ) const { - if( !m_floatingArg.get() ) - return tokens; - std::vector unusedTokens; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - if( token.type == Parser::Token::Positional ) - m_floatingArg->boundField.set( config, token.data ); - else - unusedTokens.push_back( token ); - } - return unusedTokens; - } + OptBuilder &operator[](std::string const &optName) { + addOptName(*ArgBuilder::m_arg, optName); + return *this; + } + }; - void validate() const - { - if( m_options.empty() && m_positionalArgs.empty() && !m_floatingArg.get() ) - throw std::logic_error( "No options or arguments specified" ); +public: + CommandLine() + : m_boundProcessName(new Detail::NullBinder()), + m_highestSpecifiedArgPosition(0), m_throwOnUnrecognisedTokens(false) {} + CommandLine(CommandLine const &other) + : m_boundProcessName(other.m_boundProcessName), + m_options(other.m_options), m_positionalArgs(other.m_positionalArgs), + m_highestSpecifiedArgPosition(other.m_highestSpecifiedArgPosition), + m_throwOnUnrecognisedTokens(other.m_throwOnUnrecognisedTokens) { + if (other.m_floatingArg.get()) + m_floatingArg.reset(new Arg(*other.m_floatingArg)); + } + + CommandLine &setThrowOnUnrecognisedTokens(bool shouldThrow = true) { + m_throwOnUnrecognisedTokens = shouldThrow; + return *this; + } + + OptBuilder operator[](std::string const &optName) { + m_options.push_back(Arg()); + addOptName(m_options.back(), optName); + OptBuilder builder(&m_options.back()); + return builder; + } + + ArgBuilder operator[](int position) { + m_positionalArgs.insert(std::make_pair(position, Arg())); + if (position > m_highestSpecifiedArgPosition) + m_highestSpecifiedArgPosition = position; + setPositionalArg(m_positionalArgs[position], position); + ArgBuilder builder(&m_positionalArgs[position]); + return builder; + } + + // Invoke this with the _ instance + ArgBuilder operator[](UnpositionalTag) { + if (m_floatingArg.get()) + throw std::logic_error("Only one unpositional argument can be added"); + m_floatingArg.reset(new Arg()); + ArgBuilder builder(m_floatingArg.get()); + return builder; + } + + template void bindProcessName(M C::*field) { + m_boundProcessName = new Detail::BoundDataMember(field); + } + template + void bindProcessName(void (C::*_unaryMethod)(M)) { + m_boundProcessName = new Detail::BoundUnaryMethod(_unaryMethod); + } + + void optUsage(std::ostream &os, std::size_t indent = 0, + std::size_t width = Detail::consoleWidth) const { + typename std::vector::const_iterator itBegin = m_options.begin(), + itEnd = m_options.end(), it; + std::size_t maxWidth = 0; + for (it = itBegin; it != itEnd; ++it) + maxWidth = (std::max)(maxWidth, it->commands().size()); + + for (it = itBegin; it != itEnd; ++it) { + Detail::Text usage(it->commands(), Detail::TextAttributes() + .setWidth(maxWidth + indent) + .setIndent(indent)); + Detail::Text desc(it->description, Detail::TextAttributes().setWidth( + width - maxWidth - 3)); + + for (std::size_t i = 0; i < (std::max)(usage.size(), desc.size()); ++i) { + std::string usageCol = i < usage.size() ? usage[i] : ""; + os << usageCol; + + if (i < desc.size() && !desc[i].empty()) + os << std::string(indent + 2 + maxWidth - usageCol.size(), ' ') + << desc[i]; + os << "\n"; + } + } + } + std::string optUsage() const { + std::ostringstream oss; + optUsage(oss); + return oss.str(); + } + + void argSynopsis(std::ostream &os) const { + for (int i = 1; i <= m_highestSpecifiedArgPosition; ++i) { + if (i > 1) + os << " "; + typename std::map::const_iterator it = m_positionalArgs.find(i); + if (it != m_positionalArgs.end()) + os << "<" << it->second.placeholder << ">"; + else if (m_floatingArg.get()) + os << "<" << m_floatingArg->placeholder << ">"; + else + throw std::logic_error( + "non consecutive positional arguments with no floating args"); + } + // !TBD No indication of mandatory args + if (m_floatingArg.get()) { + if (m_highestSpecifiedArgPosition > 1) + os << " "; + os << "[<" << m_floatingArg->placeholder << "> ...]"; + } + } + std::string argSynopsis() const { + std::ostringstream oss; + argSynopsis(oss); + return oss.str(); + } + + void usage(std::ostream &os, std::string const &procName) const { + validate(); + os << "usage:\n " << procName << " "; + argSynopsis(os); + if (!m_options.empty()) { + os << " [options]\n\nwhere options are: \n"; + optUsage(os, 2); + } + os << "\n"; + } + std::string usage(std::string const &procName) const { + std::ostringstream oss; + usage(oss, procName); + return oss.str(); + } + + ConfigT parse(std::vector const &args) const { + ConfigT config; + parseInto(args, config); + return config; + } + + std::vector parseInto(std::vector const &args, + ConfigT &config) const { + std::string processName = args[0]; + std::size_t lastSlash = processName.find_last_of("/\\"); + if (lastSlash != std::string::npos) + processName = processName.substr(lastSlash + 1); + m_boundProcessName.set(config, processName); + std::vector tokens; + Parser parser; + parser.parseIntoTokens(args, tokens); + return populate(tokens, config); + } + + std::vector populate(std::vector const &tokens, + ConfigT &config) const { + validate(); + std::vector unusedTokens = populateOptions(tokens, config); + unusedTokens = populateFixedArgs(unusedTokens, config); + unusedTokens = populateFloatingArgs(unusedTokens, config); + return unusedTokens; + } + + std::vector + populateOptions(std::vector const &tokens, + ConfigT &config) const { + std::vector unusedTokens; + std::vector errors; + for (std::size_t i = 0; i < tokens.size(); ++i) { + Parser::Token const &token = tokens[i]; + typename std::vector::const_iterator it = m_options.begin(), + itEnd = m_options.end(); + for (; it != itEnd; ++it) { + Arg const &arg = *it; - for( typename std::vector::const_iterator it = m_options.begin(), - itEnd = m_options.end(); - it != itEnd; ++it ) - it->validate(); + try { + if ((token.type == Parser::Token::ShortOpt && + arg.hasShortName(token.data)) || + (token.type == Parser::Token::LongOpt && + arg.hasLongName(token.data))) { + if (arg.takesArg()) { + if (i == tokens.size() - 1 || + tokens[i + 1].type != Parser::Token::Positional) + errors.push_back("Expected argument to option: " + token.data); + else + arg.boundField.set(config, tokens[++i].data); + } else { + arg.boundField.set(config, "true"); + } + break; + } + } catch (std::exception &ex) { + errors.push_back(std::string(ex.what()) + "\n- while parsing: (" + + arg.commands() + ")"); } + } + if (it == itEnd) { + if (token.type == Parser::Token::Positional || + !m_throwOnUnrecognisedTokens) + unusedTokens.push_back(token); + else if (errors.empty() && m_throwOnUnrecognisedTokens) + errors.push_back("unrecognised option: " + token.data); + } + } + if (!errors.empty()) { + std::ostringstream oss; + for (std::vector::const_iterator it = errors.begin(), + itEnd = errors.end(); + it != itEnd; ++it) { + if (it != errors.begin()) + oss << "\n"; + oss << *it; + } + throw std::runtime_error(oss.str()); + } + return unusedTokens; + } + std::vector + populateFixedArgs(std::vector const &tokens, + ConfigT &config) const { + std::vector unusedTokens; + int position = 1; + for (std::size_t i = 0; i < tokens.size(); ++i) { + Parser::Token const &token = tokens[i]; + typename std::map::const_iterator it = + m_positionalArgs.find(position); + if (it != m_positionalArgs.end()) + it->second.boundField.set(config, token.data); + else + unusedTokens.push_back(token); + if (token.type == Parser::Token::Positional) + position++; + } + return unusedTokens; + } + std::vector + populateFloatingArgs(std::vector const &tokens, + ConfigT &config) const { + if (!m_floatingArg.get()) + return tokens; + std::vector unusedTokens; + for (std::size_t i = 0; i < tokens.size(); ++i) { + Parser::Token const &token = tokens[i]; + if (token.type == Parser::Token::Positional) + m_floatingArg->boundField.set(config, token.data); + else + unusedTokens.push_back(token); + } + return unusedTokens; + } + + void validate() const { + if (m_options.empty() && m_positionalArgs.empty() && !m_floatingArg.get()) + throw std::logic_error("No options or arguments specified"); + + for (typename std::vector::const_iterator it = m_options.begin(), + itEnd = m_options.end(); + it != itEnd; ++it) + it->validate(); + } - private: - Detail::BoundArgFunction m_boundProcessName; - std::vector m_options; - std::map m_positionalArgs; - ArgAutoPtr m_floatingArg; - int m_highestSpecifiedArgPosition; - bool m_throwOnUnrecognisedTokens; - }; +private: + Detail::BoundArgFunction m_boundProcessName; + std::vector m_options; + std::map m_positionalArgs; + ArgAutoPtr m_floatingArg; + int m_highestSpecifiedArgPosition; + bool m_throwOnUnrecognisedTokens; +}; } // end namespace Clara @@ -4642,190 +4773,195 @@ STITCH_CLARA_CLOSE_NAMESPACE namespace Catch { - inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; } - inline void abortAfterX( ConfigData& config, int x ) { - if( x < 1 ) - throw std::runtime_error( "Value after -x or --abortAfter must be greater than zero" ); - config.abortAfter = x; - } - inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); } - inline void addReporterName( ConfigData& config, std::string const& _reporterName ) { config.reporterNames.push_back( _reporterName ); } - - inline void addWarning( ConfigData& config, std::string const& _warning ) { - if( _warning == "NoAssertions" ) - config.warnings = static_cast( config.warnings | WarnAbout::NoAssertions ); - else - throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" ); - } - inline void setOrder( ConfigData& config, std::string const& order ) { - if( startsWith( "declared", order ) ) - config.runOrder = RunTests::InDeclarationOrder; - else if( startsWith( "lexical", order ) ) - config.runOrder = RunTests::InLexicographicalOrder; - else if( startsWith( "random", order ) ) - config.runOrder = RunTests::InRandomOrder; - else - throw std::runtime_error( "Unrecognised ordering: '" + order + "'" ); - } - inline void setRngSeed( ConfigData& config, std::string const& seed ) { - if( seed == "time" ) { - config.rngSeed = static_cast( std::time(0) ); - } - else { - std::stringstream ss; - ss << seed; - ss >> config.rngSeed; - if( ss.fail() ) - throw std::runtime_error( "Argment to --rng-seed should be the word 'time' or a number" ); - } - } - inline void setVerbosity( ConfigData& config, int level ) { - // !TBD: accept strings? - config.verbosity = static_cast( level ); - } - inline void setShowDurations( ConfigData& config, bool _showDurations ) { - config.showDurations = _showDurations - ? ShowDurations::Always - : ShowDurations::Never; - } - inline void setUseColour( ConfigData& config, std::string const& value ) { - std::string mode = toLower( value ); - - if( mode == "yes" ) - config.useColour = UseColour::Yes; - else if( mode == "no" ) - config.useColour = UseColour::No; - else if( mode == "auto" ) - config.useColour = UseColour::Auto; - else - throw std::runtime_error( "colour mode must be one of: auto, yes or no" ); - } - inline void forceColour( ConfigData& config ) { - config.useColour = UseColour::Yes; - } - inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) { - std::ifstream f( _filename.c_str() ); - if( !f.is_open() ) - throw std::domain_error( "Unable to load input file: " + _filename ); +inline void abortAfterFirst(ConfigData &config) { config.abortAfter = 1; } +inline void abortAfterX(ConfigData &config, int x) { + if (x < 1) + throw std::runtime_error( + "Value after -x or --abortAfter must be greater than zero"); + config.abortAfter = x; +} +inline void addTestOrTags(ConfigData &config, std::string const &_testSpec) { + config.testsOrTags.push_back(_testSpec); +} +inline void addReporterName(ConfigData &config, + std::string const &_reporterName) { + config.reporterNames.push_back(_reporterName); +} - std::string line; - while( std::getline( f, line ) ) { - line = trim(line); - if( !line.empty() && !startsWith( line, "#" ) ) - addTestOrTags( config, "\"" + line + "\"," ); - } - } +inline void addWarning(ConfigData &config, std::string const &_warning) { + if (_warning == "NoAssertions") + config.warnings = + static_cast(config.warnings | WarnAbout::NoAssertions); + else + throw std::runtime_error("Unrecognised warning: '" + _warning + "'"); +} +inline void setOrder(ConfigData &config, std::string const &order) { + if (startsWith("declared", order)) + config.runOrder = RunTests::InDeclarationOrder; + else if (startsWith("lexical", order)) + config.runOrder = RunTests::InLexicographicalOrder; + else if (startsWith("random", order)) + config.runOrder = RunTests::InRandomOrder; + else + throw std::runtime_error("Unrecognised ordering: '" + order + "'"); +} +inline void setRngSeed(ConfigData &config, std::string const &seed) { + if (seed == "time") { + config.rngSeed = static_cast(std::time(0)); + } else { + std::stringstream ss; + ss << seed; + ss >> config.rngSeed; + if (ss.fail()) + throw std::runtime_error( + "Argment to --rng-seed should be the word 'time' or a number"); + } +} +inline void setVerbosity(ConfigData &config, int level) { + // !TBD: accept strings? + config.verbosity = static_cast(level); +} +inline void setShowDurations(ConfigData &config, bool _showDurations) { + config.showDurations = + _showDurations ? ShowDurations::Always : ShowDurations::Never; +} +inline void setUseColour(ConfigData &config, std::string const &value) { + std::string mode = toLower(value); + + if (mode == "yes") + config.useColour = UseColour::Yes; + else if (mode == "no") + config.useColour = UseColour::No; + else if (mode == "auto") + config.useColour = UseColour::Auto; + else + throw std::runtime_error("colour mode must be one of: auto, yes or no"); +} +inline void forceColour(ConfigData &config) { + config.useColour = UseColour::Yes; +} +inline void loadTestNamesFromFile(ConfigData &config, + std::string const &_filename) { + std::ifstream f(_filename.c_str()); + if (!f.is_open()) + throw std::domain_error("Unable to load input file: " + _filename); + + std::string line; + while (std::getline(f, line)) { + line = trim(line); + if (!line.empty() && !startsWith(line, "#")) + addTestOrTags(config, "\"" + line + "\","); + } +} - inline Clara::CommandLine makeCommandLineParser() { +inline Clara::CommandLine makeCommandLineParser() { - using namespace Clara; - CommandLine cli; + using namespace Clara; + CommandLine cli; - cli.bindProcessName( &ConfigData::processName ); + cli.bindProcessName(&ConfigData::processName); - cli["-?"]["-h"]["--help"] - .describe( "display usage information" ) - .bind( &ConfigData::showHelp ); + cli["-?"]["-h"]["--help"] + .describe("display usage information") + .bind(&ConfigData::showHelp); - cli["-l"]["--list-tests"] - .describe( "list all/matching test cases" ) - .bind( &ConfigData::listTests ); + cli["-l"]["--list-tests"] + .describe("list all/matching test cases") + .bind(&ConfigData::listTests); - cli["-t"]["--list-tags"] - .describe( "list all/matching tags" ) - .bind( &ConfigData::listTags ); + cli["-t"]["--list-tags"] + .describe("list all/matching tags") + .bind(&ConfigData::listTags); - cli["-s"]["--success"] - .describe( "include successful tests in output" ) - .bind( &ConfigData::showSuccessfulTests ); + cli["-s"]["--success"] + .describe("include successful tests in output") + .bind(&ConfigData::showSuccessfulTests); - cli["-b"]["--break"] - .describe( "break into debugger on failure" ) - .bind( &ConfigData::shouldDebugBreak ); + cli["-b"]["--break"] + .describe("break into debugger on failure") + .bind(&ConfigData::shouldDebugBreak); - cli["-e"]["--nothrow"] - .describe( "skip exception tests" ) - .bind( &ConfigData::noThrow ); + cli["-e"]["--nothrow"] + .describe("skip exception tests") + .bind(&ConfigData::noThrow); - cli["-i"]["--invisibles"] - .describe( "show invisibles (tabs, newlines)" ) - .bind( &ConfigData::showInvisibles ); + cli["-i"]["--invisibles"] + .describe("show invisibles (tabs, newlines)") + .bind(&ConfigData::showInvisibles); - cli["-o"]["--out"] - .describe( "output filename" ) - .bind( &ConfigData::outputFilename, "filename" ); + cli["-o"]["--out"] + .describe("output filename") + .bind(&ConfigData::outputFilename, "filename"); - cli["-r"]["--reporter"] -// .placeholder( "name[:filename]" ) - .describe( "reporter to use (defaults to console)" ) - .bind( &addReporterName, "name" ); + cli["-r"]["--reporter"] + // .placeholder( "name[:filename]" ) + .describe("reporter to use (defaults to console)") + .bind(&addReporterName, "name"); - cli["-n"]["--name"] - .describe( "suite name" ) - .bind( &ConfigData::name, "name" ); + cli["-n"]["--name"].describe("suite name").bind(&ConfigData::name, "name"); - cli["-a"]["--abort"] - .describe( "abort at first failure" ) - .bind( &abortAfterFirst ); + cli["-a"]["--abort"] + .describe("abort at first failure") + .bind(&abortAfterFirst); - cli["-x"]["--abortx"] - .describe( "abort after x failures" ) - .bind( &abortAfterX, "no. failures" ); + cli["-x"]["--abortx"] + .describe("abort after x failures") + .bind(&abortAfterX, "no. failures"); - cli["-w"]["--warn"] - .describe( "enable warnings" ) - .bind( &addWarning, "warning name" ); + cli["-w"]["--warn"] + .describe("enable warnings") + .bind(&addWarning, "warning name"); -// - needs updating if reinstated -// cli.into( &setVerbosity ) -// .describe( "level of verbosity (0=no output)" ) -// .shortOpt( "v") -// .longOpt( "verbosity" ) -// .placeholder( "level" ); + // - needs updating if reinstated + // cli.into( &setVerbosity ) + // .describe( "level of verbosity (0=no output)" ) + // .shortOpt( "v") + // .longOpt( "verbosity" ) + // .placeholder( "level" ); - cli[_] - .describe( "which test or tests to use" ) - .bind( &addTestOrTags, "test name, pattern or tags" ); + cli[_] + .describe("which test or tests to use") + .bind(&addTestOrTags, "test name, pattern or tags"); - cli["-d"]["--durations"] - .describe( "show test durations" ) - .bind( &setShowDurations, "yes|no" ); + cli["-d"]["--durations"] + .describe("show test durations") + .bind(&setShowDurations, "yes|no"); - cli["-f"]["--input-file"] - .describe( "load test names to run from a file" ) - .bind( &loadTestNamesFromFile, "filename" ); + cli["-f"]["--input-file"] + .describe("load test names to run from a file") + .bind(&loadTestNamesFromFile, "filename"); - cli["-#"]["--filenames-as-tags"] - .describe( "adds a tag for the filename" ) - .bind( &ConfigData::filenamesAsTags ); + cli["-#"]["--filenames-as-tags"] + .describe("adds a tag for the filename") + .bind(&ConfigData::filenamesAsTags); - // Less common commands which don't have a short form - cli["--list-test-names-only"] - .describe( "list all/matching test cases names only" ) - .bind( &ConfigData::listTestNamesOnly ); + // Less common commands which don't have a short form + cli["--list-test-names-only"] + .describe("list all/matching test cases names only") + .bind(&ConfigData::listTestNamesOnly); - cli["--list-reporters"] - .describe( "list all reporters" ) - .bind( &ConfigData::listReporters ); + cli["--list-reporters"] + .describe("list all reporters") + .bind(&ConfigData::listReporters); - cli["--order"] - .describe( "test case order (defaults to decl)" ) - .bind( &setOrder, "decl|lex|rand" ); + cli["--order"] + .describe("test case order (defaults to decl)") + .bind(&setOrder, "decl|lex|rand"); - cli["--rng-seed"] - .describe( "set a specific seed for random numbers" ) - .bind( &setRngSeed, "'time'|number" ); + cli["--rng-seed"] + .describe("set a specific seed for random numbers") + .bind(&setRngSeed, "'time'|number"); - cli["--force-colour"] - .describe( "force colourised output (deprecated)" ) - .bind( &forceColour ); + cli["--force-colour"] + .describe("force colourised output (deprecated)") + .bind(&forceColour); - cli["--use-colour"] - .describe( "should output be colourised" ) - .bind( &setUseColour, "yes|no" ); + cli["--use-colour"] + .describe("should output be colourised") + .bind(&setUseColour, "yes|no"); - return cli; - } + return cli; +} } // end namespace Catch @@ -4841,18 +4977,18 @@ namespace Catch { // #included from: ../external/tbc_text_format.h // Only use header guard if we are not using an outer namespace #ifndef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -# ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED -# ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -# define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -# endif -# else -# define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED -# endif +#ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED +#ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED +#define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED +#endif +#else +#define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED +#endif #endif #ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED +#include #include #include -#include // Use optional outer namespace #ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE @@ -4862,121 +4998,132 @@ namespace CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE { namespace Tbc { #ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH - const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; +const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; #else - const unsigned int consoleWidth = 80; -#endif - - struct TextAttributes { - TextAttributes() - : initialIndent( std::string::npos ), - indent( 0 ), - width( consoleWidth-1 ), - tabChar( '\t' ) - {} - - TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; } - TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; } - TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; } - TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; } - - std::size_t initialIndent; // indent of first line, or npos - std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos - std::size_t width; // maximum width of text, including indent. Longer text will wrap - char tabChar; // If this char is seen the indent is changed to current pos - }; - - class Text { - public: - Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() ) - : attr( _attr ) - { - std::string wrappableChars = " [({.,/|\\-"; - std::size_t indent = _attr.initialIndent != std::string::npos - ? _attr.initialIndent - : _attr.indent; - std::string remainder = _str; - - while( !remainder.empty() ) { - if( lines.size() >= 1000 ) { - lines.push_back( "... message truncated due to excessive size" ); - return; - } - std::size_t tabPos = std::string::npos; - std::size_t width = (std::min)( remainder.size(), _attr.width - indent ); - std::size_t pos = remainder.find_first_of( '\n' ); - if( pos <= width ) { - width = pos; - } - pos = remainder.find_last_of( _attr.tabChar, width ); - if( pos != std::string::npos ) { - tabPos = pos; - if( remainder[width] == '\n' ) - width--; - remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 ); - } - - if( width == remainder.size() ) { - spliceLine( indent, remainder, width ); - } - else if( remainder[width] == '\n' ) { - spliceLine( indent, remainder, width ); - if( width <= 1 || remainder.size() != 1 ) - remainder = remainder.substr( 1 ); - indent = _attr.indent; - } - else { - pos = remainder.find_last_of( wrappableChars, width ); - if( pos != std::string::npos && pos > 0 ) { - spliceLine( indent, remainder, pos ); - if( remainder[0] == ' ' ) - remainder = remainder.substr( 1 ); - } - else { - spliceLine( indent, remainder, width-1 ); - lines.back() += "-"; - } - if( lines.size() == 1 ) - indent = _attr.indent; - if( tabPos != std::string::npos ) - indent += tabPos; - } - } - } +const unsigned int consoleWidth = 80; +#endif - void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) { - lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) ); - _remainder = _remainder.substr( _pos ); - } +struct TextAttributes { + TextAttributes() + : initialIndent(std::string::npos), indent(0), width(consoleWidth - 1), + tabChar('\t') {} + + TextAttributes &setInitialIndent(std::size_t _value) { + initialIndent = _value; + return *this; + } + TextAttributes &setIndent(std::size_t _value) { + indent = _value; + return *this; + } + TextAttributes &setWidth(std::size_t _value) { + width = _value; + return *this; + } + TextAttributes &setTabChar(char _value) { + tabChar = _value; + return *this; + } + + std::size_t initialIndent; // indent of first line, or npos + std::size_t + indent; // indent of subsequent lines, or all if initialIndent is npos + std::size_t + width; // maximum width of text, including indent. Longer text will wrap + char tabChar; // If this char is seen the indent is changed to current pos +}; - typedef std::vector::const_iterator const_iterator; - - const_iterator begin() const { return lines.begin(); } - const_iterator end() const { return lines.end(); } - std::string const& last() const { return lines.back(); } - std::size_t size() const { return lines.size(); } - std::string const& operator[]( std::size_t _index ) const { return lines[_index]; } - std::string toString() const { - std::ostringstream oss; - oss << *this; - return oss.str(); - } +class Text { +public: + Text(std::string const &_str, TextAttributes const &_attr = TextAttributes()) + : attr(_attr) { + std::string wrappableChars = " [({.,/|\\-"; + std::size_t indent = _attr.initialIndent != std::string::npos + ? _attr.initialIndent + : _attr.indent; + std::string remainder = _str; + + while (!remainder.empty()) { + if (lines.size() >= 1000) { + lines.push_back("... message truncated due to excessive size"); + return; + } + std::size_t tabPos = std::string::npos; + std::size_t width = (std::min)(remainder.size(), _attr.width - indent); + std::size_t pos = remainder.find_first_of('\n'); + if (pos <= width) { + width = pos; + } + pos = remainder.find_last_of(_attr.tabChar, width); + if (pos != std::string::npos) { + tabPos = pos; + if (remainder[width] == '\n') + width--; + remainder = remainder.substr(0, tabPos) + remainder.substr(tabPos + 1); + } - inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { - for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); - it != itEnd; ++it ) { - if( it != _text.begin() ) - _stream << "\n"; - _stream << *it; - } - return _stream; - } + if (width == remainder.size()) { + spliceLine(indent, remainder, width); + } else if (remainder[width] == '\n') { + spliceLine(indent, remainder, width); + if (width <= 1 || remainder.size() != 1) + remainder = remainder.substr(1); + indent = _attr.indent; + } else { + pos = remainder.find_last_of(wrappableChars, width); + if (pos != std::string::npos && pos > 0) { + spliceLine(indent, remainder, pos); + if (remainder[0] == ' ') + remainder = remainder.substr(1); + } else { + spliceLine(indent, remainder, width - 1); + lines.back() += "-"; + } + if (lines.size() == 1) + indent = _attr.indent; + if (tabPos != std::string::npos) + indent += tabPos; + } + } + } + + void spliceLine(std::size_t _indent, std::string &_remainder, + std::size_t _pos) { + lines.push_back(std::string(_indent, ' ') + _remainder.substr(0, _pos)); + _remainder = _remainder.substr(_pos); + } + + typedef std::vector::const_iterator const_iterator; + + const_iterator begin() const { return lines.begin(); } + const_iterator end() const { return lines.end(); } + std::string const &last() const { return lines.back(); } + std::size_t size() const { return lines.size(); } + std::string const &operator[](std::size_t _index) const { + return lines[_index]; + } + std::string toString() const { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + + inline friend std::ostream &operator<<(std::ostream &_stream, + Text const &_text) { + for (Text::const_iterator it = _text.begin(), itEnd = _text.end(); + it != itEnd; ++it) { + if (it != _text.begin()) + _stream << "\n"; + _stream << *it; + } + return _stream; + } - private: - std::string str; - TextAttributes attr; - std::vector lines; - }; +private: + std::string str; + TextAttributes attr; + std::vector lines; +}; } // end namespace Tbc @@ -4988,1194 +5135,1142 @@ namespace Tbc { #undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE namespace Catch { - using Tbc::Text; - using Tbc::TextAttributes; -} +using Tbc::Text; +using Tbc::TextAttributes; +} // namespace Catch // #included from: catch_console_colour.hpp #define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED namespace Catch { - struct Colour { - enum Code { - None = 0, +struct Colour { + enum Code { + None = 0, - White, - Red, - Green, - Blue, - Cyan, - Yellow, - Grey, + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, - Bright = 0x10, + Bright = 0x10, - BrightRed = Bright | Red, - BrightGreen = Bright | Green, - LightGrey = Bright | Grey, - BrightWhite = Bright | White, + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White, - // By intention - FileName = LightGrey, - Warning = Yellow, - ResultError = BrightRed, - ResultSuccess = BrightGreen, - ResultExpectedFailure = Warning, + // By intention + FileName = LightGrey, + Warning = Yellow, + ResultError = BrightRed, + ResultSuccess = BrightGreen, + ResultExpectedFailure = Warning, - Error = BrightRed, - Success = Green, + Error = BrightRed, + Success = Green, - OriginalExpression = Cyan, - ReconstructedExpression = Yellow, + OriginalExpression = Cyan, + ReconstructedExpression = Yellow, - SecondaryText = LightGrey, - Headers = White - }; + SecondaryText = LightGrey, + Headers = White + }; - // Use constructed object for RAII guard - Colour( Code _colourCode ); - Colour( Colour const& other ); - ~Colour(); + // Use constructed object for RAII guard + Colour(Code _colourCode); + Colour(Colour const &other); + ~Colour(); - // Use static method for one-shot changes - static void use( Code _colourCode ); + // Use static method for one-shot changes + static void use(Code _colourCode); - private: - bool m_moved; - }; +private: + bool m_moved; +}; - inline std::ostream& operator << ( std::ostream& os, Colour const& ) { return os; } +inline std::ostream &operator<<(std::ostream &os, Colour const &) { return os; } } // end namespace Catch // #included from: catch_interfaces_reporter.h #define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED -#include -#include -#include #include - -namespace Catch -{ - struct ReporterConfig { - explicit ReporterConfig( Ptr const& _fullConfig ) - : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} - - ReporterConfig( Ptr const& _fullConfig, std::ostream& _stream ) - : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} - - std::ostream& stream() const { return *m_stream; } - Ptr fullConfig() const { return m_fullConfig; } - - private: - std::ostream* m_stream; - Ptr m_fullConfig; - }; - - struct ReporterPreferences { - ReporterPreferences() - : shouldRedirectStdOut( false ) - {} - - bool shouldRedirectStdOut; - }; - - template - struct LazyStat : Option { - LazyStat() : used( false ) {} - LazyStat& operator=( T const& _value ) { - Option::operator=( _value ); - used = false; - return *this; - } - void reset() { - Option::reset(); - used = false; - } - bool used; - }; - - struct TestRunInfo { - TestRunInfo( std::string const& _name ) : name( _name ) {} - std::string name; - }; - struct GroupInfo { - GroupInfo( std::string const& _name, - std::size_t _groupIndex, - std::size_t _groupsCount ) - : name( _name ), - groupIndex( _groupIndex ), - groupsCounts( _groupsCount ) - {} - - std::string name; - std::size_t groupIndex; - std::size_t groupsCounts; - }; - - struct AssertionStats { - AssertionStats( AssertionResult const& _assertionResult, - std::vector const& _infoMessages, - Totals const& _totals ) - : assertionResult( _assertionResult ), - infoMessages( _infoMessages ), - totals( _totals ) - { - if( assertionResult.hasMessage() ) { - // Copy message into messages list. - // !TBD This should have been done earlier, somewhere - MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); - builder << assertionResult.getMessage(); - builder.m_info.message = builder.m_stream.str(); - - infoMessages.push_back( builder.m_info ); - } - } - virtual ~AssertionStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - AssertionStats( AssertionStats const& ) = default; - AssertionStats( AssertionStats && ) = default; - AssertionStats& operator = ( AssertionStats const& ) = default; - AssertionStats& operator = ( AssertionStats && ) = default; -# endif - - AssertionResult assertionResult; - std::vector infoMessages; - Totals totals; - }; - - struct SectionStats { - SectionStats( SectionInfo const& _sectionInfo, - Counts const& _assertions, - double _durationInSeconds, - bool _missingAssertions ) - : sectionInfo( _sectionInfo ), - assertions( _assertions ), - durationInSeconds( _durationInSeconds ), - missingAssertions( _missingAssertions ) - {} - virtual ~SectionStats(); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - SectionStats( SectionStats const& ) = default; - SectionStats( SectionStats && ) = default; - SectionStats& operator = ( SectionStats const& ) = default; - SectionStats& operator = ( SectionStats && ) = default; -# endif - - SectionInfo sectionInfo; - Counts assertions; - double durationInSeconds; - bool missingAssertions; - }; - - struct TestCaseStats { - TestCaseStats( TestCaseInfo const& _testInfo, - Totals const& _totals, - std::string const& _stdOut, - std::string const& _stdErr, - bool _aborting ) - : testInfo( _testInfo ), - totals( _totals ), - stdOut( _stdOut ), - stdErr( _stdErr ), - aborting( _aborting ) - {} - virtual ~TestCaseStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestCaseStats( TestCaseStats const& ) = default; - TestCaseStats( TestCaseStats && ) = default; - TestCaseStats& operator = ( TestCaseStats const& ) = default; - TestCaseStats& operator = ( TestCaseStats && ) = default; -# endif - - TestCaseInfo testInfo; - Totals totals; - std::string stdOut; - std::string stdErr; - bool aborting; - }; - - struct TestGroupStats { - TestGroupStats( GroupInfo const& _groupInfo, - Totals const& _totals, - bool _aborting ) - : groupInfo( _groupInfo ), - totals( _totals ), - aborting( _aborting ) - {} - TestGroupStats( GroupInfo const& _groupInfo ) - : groupInfo( _groupInfo ), - aborting( false ) - {} - virtual ~TestGroupStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestGroupStats( TestGroupStats const& ) = default; - TestGroupStats( TestGroupStats && ) = default; - TestGroupStats& operator = ( TestGroupStats const& ) = default; - TestGroupStats& operator = ( TestGroupStats && ) = default; -# endif - - GroupInfo groupInfo; - Totals totals; - bool aborting; - }; - - struct TestRunStats { - TestRunStats( TestRunInfo const& _runInfo, - Totals const& _totals, - bool _aborting ) - : runInfo( _runInfo ), - totals( _totals ), - aborting( _aborting ) - {} - virtual ~TestRunStats(); - -# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestRunStats( TestRunStats const& _other ) - : runInfo( _other.runInfo ), - totals( _other.totals ), - aborting( _other.aborting ) - {} -# else - TestRunStats( TestRunStats const& ) = default; - TestRunStats( TestRunStats && ) = default; - TestRunStats& operator = ( TestRunStats const& ) = default; - TestRunStats& operator = ( TestRunStats && ) = default; -# endif - - TestRunInfo runInfo; - Totals totals; - bool aborting; - }; - - struct IStreamingReporter : IShared { - virtual ~IStreamingReporter(); - - // Implementing class must also provide the following static method: - // static std::string getDescription(); - - virtual ReporterPreferences getPreferences() const = 0; - - virtual void noMatchingTestCases( std::string const& spec ) = 0; - - virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; - virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; - virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; - - virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; - - // The return value indicates if the messages buffer should be cleared: - virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; - - virtual void sectionEnded( SectionStats const& sectionStats ) = 0; - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; - virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; - - virtual void skipTest( TestCaseInfo const& testInfo ) = 0; - }; - - struct IReporterFactory : IShared { - virtual ~IReporterFactory(); - virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0; - virtual std::string getDescription() const = 0; - }; - - struct IReporterRegistry { - typedef std::map > FactoryMap; - typedef std::vector > Listeners; - - virtual ~IReporterRegistry(); - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const = 0; - virtual FactoryMap const& getFactories() const = 0; - virtual Listeners const& getListeners() const = 0; - }; - - Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ); - -} - -#include -#include +#include +#include +#include namespace Catch { +struct ReporterConfig { + explicit ReporterConfig(Ptr const &_fullConfig) + : m_stream(&_fullConfig->stream()), m_fullConfig(_fullConfig) {} - inline std::size_t listTests( Config const& config ) { + ReporterConfig(Ptr const &_fullConfig, std::ostream &_stream) + : m_stream(&_stream), m_fullConfig(_fullConfig) {} - TestSpec testSpec = config.testSpec(); - if( config.testSpec().hasFilters() ) - Catch::cout() << "Matching test cases:\n"; - else { - Catch::cout() << "All available test cases:\n"; - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - } + std::ostream &stream() const { return *m_stream; } + Ptr fullConfig() const { return m_fullConfig; } - std::size_t matchedTests = 0; - TextAttributes nameAttr, tagsAttr; - nameAttr.setInitialIndent( 2 ).setIndent( 4 ); - tagsAttr.setIndent( 6 ); - - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - matchedTests++; - TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); - Colour::Code colour = testCaseInfo.isHidden() - ? Colour::SecondaryText - : Colour::None; - Colour colourGuard( colour ); - - Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl; - if( !testCaseInfo.tags.empty() ) - Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl; - } +private: + std::ostream *m_stream; + Ptr m_fullConfig; +}; - if( !config.testSpec().hasFilters() ) - Catch::cout() << pluralise( matchedTests, "test case" ) << "\n" << std::endl; - else - Catch::cout() << pluralise( matchedTests, "matching test case" ) << "\n" << std::endl; - return matchedTests; - } - - inline std::size_t listTestsNamesOnly( Config const& config ) { - TestSpec testSpec = config.testSpec(); - if( !config.testSpec().hasFilters() ) - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - std::size_t matchedTests = 0; - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - matchedTests++; - TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); - Catch::cout() << testCaseInfo.name << std::endl; - } - return matchedTests; - } +struct ReporterPreferences { + ReporterPreferences() : shouldRedirectStdOut(false) {} - struct TagInfo { - TagInfo() : count ( 0 ) {} - void add( std::string const& spelling ) { - ++count; - spellings.insert( spelling ); - } - std::string all() const { - std::string out; - for( std::set::const_iterator it = spellings.begin(), itEnd = spellings.end(); - it != itEnd; - ++it ) - out += "[" + *it + "]"; - return out; - } - std::set spellings; - std::size_t count; - }; - - inline std::size_t listTags( Config const& config ) { - TestSpec testSpec = config.testSpec(); - if( config.testSpec().hasFilters() ) - Catch::cout() << "Tags for matching test cases:\n"; - else { - Catch::cout() << "All available tags:\n"; - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - } + bool shouldRedirectStdOut; +}; - std::map tagCounts; - - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - for( std::set::const_iterator tagIt = it->getTestCaseInfo().tags.begin(), - tagItEnd = it->getTestCaseInfo().tags.end(); - tagIt != tagItEnd; - ++tagIt ) { - std::string tagName = *tagIt; - std::string lcaseTagName = toLower( tagName ); - std::map::iterator countIt = tagCounts.find( lcaseTagName ); - if( countIt == tagCounts.end() ) - countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; - countIt->second.add( tagName ); - } - } +template struct LazyStat : Option { + LazyStat() : used(false) {} + LazyStat &operator=(T const &_value) { + Option::operator=(_value); + used = false; + return *this; + } + void reset() { + Option::reset(); + used = false; + } + bool used; +}; - for( std::map::const_iterator countIt = tagCounts.begin(), - countItEnd = tagCounts.end(); - countIt != countItEnd; - ++countIt ) { - std::ostringstream oss; - oss << " " << std::setw(2) << countIt->second.count << " "; - Text wrapper( countIt->second.all(), TextAttributes() - .setInitialIndent( 0 ) - .setIndent( oss.str().size() ) - .setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) ); - Catch::cout() << oss.str() << wrapper << "\n"; - } - Catch::cout() << pluralise( tagCounts.size(), "tag" ) << "\n" << std::endl; - return tagCounts.size(); - } - - inline std::size_t listReporters( Config const& /*config*/ ) { - Catch::cout() << "Available reporters:\n"; - IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); - IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), itEnd = factories.end(), it; - std::size_t maxNameLen = 0; - for(it = itBegin; it != itEnd; ++it ) - maxNameLen = (std::max)( maxNameLen, it->first.size() ); - - for(it = itBegin; it != itEnd; ++it ) { - Text wrapper( it->second->getDescription(), TextAttributes() - .setInitialIndent( 0 ) - .setIndent( 7+maxNameLen ) - .setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) ); - Catch::cout() << " " - << it->first - << ":" - << std::string( maxNameLen - it->first.size() + 2, ' ' ) - << wrapper << "\n"; - } - Catch::cout() << std::endl; - return factories.size(); - } +struct TestRunInfo { + TestRunInfo(std::string const &_name) : name(_name) {} + std::string name; +}; +struct GroupInfo { + GroupInfo(std::string const &_name, std::size_t _groupIndex, + std::size_t _groupsCount) + : name(_name), groupIndex(_groupIndex), groupsCounts(_groupsCount) {} + + std::string name; + std::size_t groupIndex; + std::size_t groupsCounts; +}; - inline Option list( Config const& config ) { - Option listedCount; - if( config.listTests() ) - listedCount = listedCount.valueOr(0) + listTests( config ); - if( config.listTestNamesOnly() ) - listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); - if( config.listTags() ) - listedCount = listedCount.valueOr(0) + listTags( config ); - if( config.listReporters() ) - listedCount = listedCount.valueOr(0) + listReporters( config ); - return listedCount; - } +struct AssertionStats { + AssertionStats(AssertionResult const &_assertionResult, + std::vector const &_infoMessages, + Totals const &_totals) + : assertionResult(_assertionResult), infoMessages(_infoMessages), + totals(_totals) { + if (assertionResult.hasMessage()) { + // Copy message into messages list. + // !TBD This should have been done earlier, somewhere + MessageBuilder builder(assertionResult.getTestMacroName(), + assertionResult.getSourceInfo(), + assertionResult.getResultType()); + builder << assertionResult.getMessage(); + builder.m_info.message = builder.m_stream.str(); + + infoMessages.push_back(builder.m_info); + } + } + virtual ~AssertionStats(); -} // end namespace Catch +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS + AssertionStats(AssertionStats const &) = default; + AssertionStats(AssertionStats &&) = default; + AssertionStats &operator=(AssertionStats const &) = default; + AssertionStats &operator=(AssertionStats &&) = default; +#endif -// #included from: internal/catch_run_context.hpp -#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED - -// #included from: catch_test_case_tracker.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED + AssertionResult assertionResult; + std::vector infoMessages; + Totals totals; +}; -#include -#include -#include -#include +struct SectionStats { + SectionStats(SectionInfo const &_sectionInfo, Counts const &_assertions, + double _durationInSeconds, bool _missingAssertions) + : sectionInfo(_sectionInfo), assertions(_assertions), + durationInSeconds(_durationInSeconds), + missingAssertions(_missingAssertions) {} + virtual ~SectionStats(); +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS + SectionStats(SectionStats const &) = default; + SectionStats(SectionStats &&) = default; + SectionStats &operator=(SectionStats const &) = default; + SectionStats &operator=(SectionStats &&) = default; +#endif -namespace Catch { -namespace TestCaseTracking { + SectionInfo sectionInfo; + Counts assertions; + double durationInSeconds; + bool missingAssertions; +}; - struct ITracker : SharedImpl<> { - virtual ~ITracker(); +struct TestCaseStats { + TestCaseStats(TestCaseInfo const &_testInfo, Totals const &_totals, + std::string const &_stdOut, std::string const &_stdErr, + bool _aborting) + : testInfo(_testInfo), totals(_totals), stdOut(_stdOut), stdErr(_stdErr), + aborting(_aborting) {} + virtual ~TestCaseStats(); - // static queries - virtual std::string name() const = 0; +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS + TestCaseStats(TestCaseStats const &) = default; + TestCaseStats(TestCaseStats &&) = default; + TestCaseStats &operator=(TestCaseStats const &) = default; + TestCaseStats &operator=(TestCaseStats &&) = default; +#endif - // dynamic queries - virtual bool isComplete() const = 0; // Successfully completed or failed - virtual bool isSuccessfullyCompleted() const = 0; - virtual bool isOpen() const = 0; // Started but not complete - virtual bool hasChildren() const = 0; + TestCaseInfo testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; +}; - virtual ITracker& parent() = 0; +struct TestGroupStats { + TestGroupStats(GroupInfo const &_groupInfo, Totals const &_totals, + bool _aborting) + : groupInfo(_groupInfo), totals(_totals), aborting(_aborting) {} + TestGroupStats(GroupInfo const &_groupInfo) + : groupInfo(_groupInfo), aborting(false) {} + virtual ~TestGroupStats(); - // actions - virtual void close() = 0; // Successfully complete - virtual void fail() = 0; - virtual void markAsNeedingAnotherRun() = 0; +#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS + TestGroupStats(TestGroupStats const &) = default; + TestGroupStats(TestGroupStats &&) = default; + TestGroupStats &operator=(TestGroupStats const &) = default; + TestGroupStats &operator=(TestGroupStats &&) = default; +#endif - virtual void addChild( Ptr const& child ) = 0; - virtual ITracker* findChild( std::string const& name ) = 0; - virtual void openChild() = 0; - }; + GroupInfo groupInfo; + Totals totals; + bool aborting; +}; - class TrackerContext { +struct TestRunStats { + TestRunStats(TestRunInfo const &_runInfo, Totals const &_totals, + bool _aborting) + : runInfo(_runInfo), totals(_totals), aborting(_aborting) {} + virtual ~TestRunStats(); - enum RunState { - NotStarted, - Executing, - CompletedCycle - }; +#ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS + TestRunStats(TestRunStats const &_other) + : runInfo(_other.runInfo), totals(_other.totals), + aborting(_other.aborting) {} +#else + TestRunStats(TestRunStats const &) = default; + TestRunStats(TestRunStats &&) = default; + TestRunStats &operator=(TestRunStats const &) = default; + TestRunStats &operator=(TestRunStats &&) = default; +#endif - Ptr m_rootTracker; - ITracker* m_currentTracker; - RunState m_runState; + TestRunInfo runInfo; + Totals totals; + bool aborting; +}; - public: +struct IStreamingReporter : IShared { + virtual ~IStreamingReporter(); - static TrackerContext& instance() { - static TrackerContext s_instance; - return s_instance; - } + // Implementing class must also provide the following static method: + // static std::string getDescription(); - TrackerContext() - : m_currentTracker( CATCH_NULL ), - m_runState( NotStarted ) - {} + virtual ReporterPreferences getPreferences() const = 0; - ITracker& startRun(); + virtual void noMatchingTestCases(std::string const &spec) = 0; - void endRun() { - m_rootTracker.reset(); - m_currentTracker = CATCH_NULL; - m_runState = NotStarted; - } + virtual void testRunStarting(TestRunInfo const &testRunInfo) = 0; + virtual void testGroupStarting(GroupInfo const &groupInfo) = 0; - void startCycle() { - m_currentTracker = m_rootTracker.get(); - m_runState = Executing; - } - void completeCycle() { - m_runState = CompletedCycle; - } + virtual void testCaseStarting(TestCaseInfo const &testInfo) = 0; + virtual void sectionStarting(SectionInfo const §ionInfo) = 0; - bool completedCycle() const { - return m_runState == CompletedCycle; - } - ITracker& currentTracker() { - return *m_currentTracker; - } - void setCurrentTracker( ITracker* tracker ) { - m_currentTracker = tracker; - } - }; - - class TrackerBase : public ITracker { - protected: - enum CycleState { - NotStarted, - Executing, - ExecutingChildren, - NeedsAnotherRun, - CompletedSuccessfully, - Failed - }; - class TrackerHasName { - std::string m_name; - public: - TrackerHasName( std::string const& name ) : m_name( name ) {} - bool operator ()( Ptr const& tracker ) { - return tracker->name() == m_name; - } - }; - typedef std::vector > Children; - std::string m_name; - TrackerContext& m_ctx; - ITracker* m_parent; - Children m_children; - CycleState m_runState; - public: - TrackerBase( std::string const& name, TrackerContext& ctx, ITracker* parent ) - : m_name( name ), - m_ctx( ctx ), - m_parent( parent ), - m_runState( NotStarted ) - {} - virtual ~TrackerBase(); - - virtual std::string name() const CATCH_OVERRIDE { - return m_name; - } - virtual bool isComplete() const CATCH_OVERRIDE { - return m_runState == CompletedSuccessfully || m_runState == Failed; - } - virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE { - return m_runState == CompletedSuccessfully; - } - virtual bool isOpen() const CATCH_OVERRIDE { - return m_runState != NotStarted && !isComplete(); - } - virtual bool hasChildren() const CATCH_OVERRIDE { - return !m_children.empty(); - } + virtual void assertionStarting(AssertionInfo const &assertionInfo) = 0; - virtual void addChild( Ptr const& child ) CATCH_OVERRIDE { - m_children.push_back( child ); - } + // The return value indicates if the messages buffer should be cleared: + virtual bool assertionEnded(AssertionStats const &assertionStats) = 0; - virtual ITracker* findChild( std::string const& name ) CATCH_OVERRIDE { - Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( name ) ); - return( it != m_children.end() ) - ? it->get() - : CATCH_NULL; - } - virtual ITracker& parent() CATCH_OVERRIDE { - assert( m_parent ); // Should always be non-null except for root - return *m_parent; - } + virtual void sectionEnded(SectionStats const §ionStats) = 0; + virtual void testCaseEnded(TestCaseStats const &testCaseStats) = 0; + virtual void testGroupEnded(TestGroupStats const &testGroupStats) = 0; + virtual void testRunEnded(TestRunStats const &testRunStats) = 0; - virtual void openChild() CATCH_OVERRIDE { - if( m_runState != ExecutingChildren ) { - m_runState = ExecutingChildren; - if( m_parent ) - m_parent->openChild(); - } - } - void open() { - m_runState = Executing; - moveToThis(); - if( m_parent ) - m_parent->openChild(); - } + virtual void skipTest(TestCaseInfo const &testInfo) = 0; +}; - virtual void close() CATCH_OVERRIDE { +struct IReporterFactory : IShared { + virtual ~IReporterFactory(); + virtual IStreamingReporter *create(ReporterConfig const &config) const = 0; + virtual std::string getDescription() const = 0; +}; - // Close any still open children (e.g. generators) - while( &m_ctx.currentTracker() != this ) - m_ctx.currentTracker().close(); +struct IReporterRegistry { + typedef std::map> FactoryMap; + typedef std::vector> Listeners; - switch( m_runState ) { - case NotStarted: - case CompletedSuccessfully: - case Failed: - throw std::logic_error( "Illogical state" ); + virtual ~IReporterRegistry(); + virtual IStreamingReporter * + create(std::string const &name, Ptr const &config) const = 0; + virtual FactoryMap const &getFactories() const = 0; + virtual Listeners const &getListeners() const = 0; +}; - case NeedsAnotherRun: - break;; +Ptr +addReporter(Ptr const &existingReporter, + Ptr const &additionalReporter); - case Executing: - m_runState = CompletedSuccessfully; - break; - case ExecutingChildren: - if( m_children.empty() || m_children.back()->isComplete() ) - m_runState = CompletedSuccessfully; - break; +} // namespace Catch - default: - throw std::logic_error( "Unexpected state" ); - } - moveToParent(); - m_ctx.completeCycle(); - } - virtual void fail() CATCH_OVERRIDE { - m_runState = Failed; - if( m_parent ) - m_parent->markAsNeedingAnotherRun(); - moveToParent(); - m_ctx.completeCycle(); - } - virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE { - m_runState = NeedsAnotherRun; - } - private: - void moveToParent() { - assert( m_parent ); - m_ctx.setCurrentTracker( m_parent ); - } - void moveToThis() { - m_ctx.setCurrentTracker( this ); - } - }; - - class SectionTracker : public TrackerBase { - public: - SectionTracker( std::string const& name, TrackerContext& ctx, ITracker* parent ) - : TrackerBase( name, ctx, parent ) - {} - virtual ~SectionTracker(); - - static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) { - SectionTracker* section = CATCH_NULL; - - ITracker& currentTracker = ctx.currentTracker(); - if( ITracker* childTracker = currentTracker.findChild( name ) ) { - section = dynamic_cast( childTracker ); - assert( section ); - } - else { - section = new SectionTracker( name, ctx, ¤tTracker ); - currentTracker.addChild( section ); - } - if( !ctx.completedCycle() && !section->isComplete() ) { +#include +#include - section->open(); - } - return *section; - } - }; - - class IndexTracker : public TrackerBase { - int m_size; - int m_index; - public: - IndexTracker( std::string const& name, TrackerContext& ctx, ITracker* parent, int size ) - : TrackerBase( name, ctx, parent ), - m_size( size ), - m_index( -1 ) - {} - virtual ~IndexTracker(); - - static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) { - IndexTracker* tracker = CATCH_NULL; - - ITracker& currentTracker = ctx.currentTracker(); - if( ITracker* childTracker = currentTracker.findChild( name ) ) { - tracker = dynamic_cast( childTracker ); - assert( tracker ); - } - else { - tracker = new IndexTracker( name, ctx, ¤tTracker, size ); - currentTracker.addChild( tracker ); - } +namespace Catch { - if( !ctx.completedCycle() && !tracker->isComplete() ) { - if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) - tracker->moveNext(); - tracker->open(); - } +inline std::size_t listTests(Config const &config) { + + TestSpec testSpec = config.testSpec(); + if (config.testSpec().hasFilters()) + Catch::cout() << "Matching test cases:\n"; + else { + Catch::cout() << "All available test cases:\n"; + testSpec = TestSpecParser(ITagAliasRegistry::get()).parse("*").testSpec(); + } + + std::size_t matchedTests = 0; + TextAttributes nameAttr, tagsAttr; + nameAttr.setInitialIndent(2).setIndent(4); + tagsAttr.setIndent(6); + + std::vector matchedTestCases = + filterTests(getAllTestCasesSorted(config), testSpec, config); + for (std::vector::const_iterator it = matchedTestCases.begin(), + itEnd = matchedTestCases.end(); + it != itEnd; ++it) { + matchedTests++; + TestCaseInfo const &testCaseInfo = it->getTestCaseInfo(); + Colour::Code colour = + testCaseInfo.isHidden() ? Colour::SecondaryText : Colour::None; + Colour colourGuard(colour); + + Catch::cout() << Text(testCaseInfo.name, nameAttr) << std::endl; + if (!testCaseInfo.tags.empty()) + Catch::cout() << Text(testCaseInfo.tagsAsString, tagsAttr) << std::endl; + } + + if (!config.testSpec().hasFilters()) + Catch::cout() << pluralise(matchedTests, "test case") << "\n" << std::endl; + else + Catch::cout() << pluralise(matchedTests, "matching test case") << "\n" + << std::endl; + return matchedTests; +} - return *tracker; - } +inline std::size_t listTestsNamesOnly(Config const &config) { + TestSpec testSpec = config.testSpec(); + if (!config.testSpec().hasFilters()) + testSpec = TestSpecParser(ITagAliasRegistry::get()).parse("*").testSpec(); + std::size_t matchedTests = 0; + std::vector matchedTestCases = + filterTests(getAllTestCasesSorted(config), testSpec, config); + for (std::vector::const_iterator it = matchedTestCases.begin(), + itEnd = matchedTestCases.end(); + it != itEnd; ++it) { + matchedTests++; + TestCaseInfo const &testCaseInfo = it->getTestCaseInfo(); + Catch::cout() << testCaseInfo.name << std::endl; + } + return matchedTests; +} - int index() const { return m_index; } +struct TagInfo { + TagInfo() : count(0) {} + void add(std::string const &spelling) { + ++count; + spellings.insert(spelling); + } + std::string all() const { + std::string out; + for (std::set::const_iterator it = spellings.begin(), + itEnd = spellings.end(); + it != itEnd; ++it) + out += "[" + *it + "]"; + return out; + } + std::set spellings; + std::size_t count; +}; - void moveNext() { - m_index++; - m_children.clear(); - } +inline std::size_t listTags(Config const &config) { + TestSpec testSpec = config.testSpec(); + if (config.testSpec().hasFilters()) + Catch::cout() << "Tags for matching test cases:\n"; + else { + Catch::cout() << "All available tags:\n"; + testSpec = TestSpecParser(ITagAliasRegistry::get()).parse("*").testSpec(); + } + + std::map tagCounts; + + std::vector matchedTestCases = + filterTests(getAllTestCasesSorted(config), testSpec, config); + for (std::vector::const_iterator it = matchedTestCases.begin(), + itEnd = matchedTestCases.end(); + it != itEnd; ++it) { + for (std::set::const_iterator + tagIt = it->getTestCaseInfo().tags.begin(), + tagItEnd = it->getTestCaseInfo().tags.end(); + tagIt != tagItEnd; ++tagIt) { + std::string tagName = *tagIt; + std::string lcaseTagName = toLower(tagName); + std::map::iterator countIt = + tagCounts.find(lcaseTagName); + if (countIt == tagCounts.end()) + countIt = + tagCounts.insert(std::make_pair(lcaseTagName, TagInfo())).first; + countIt->second.add(tagName); + } + } + + for (std::map::const_iterator + countIt = tagCounts.begin(), + countItEnd = tagCounts.end(); + countIt != countItEnd; ++countIt) { + std::ostringstream oss; + oss << " " << std::setw(2) << countIt->second.count << " "; + Text wrapper(countIt->second.all(), + TextAttributes() + .setInitialIndent(0) + .setIndent(oss.str().size()) + .setWidth(CATCH_CONFIG_CONSOLE_WIDTH - 10)); + Catch::cout() << oss.str() << wrapper << "\n"; + } + Catch::cout() << pluralise(tagCounts.size(), "tag") << "\n" << std::endl; + return tagCounts.size(); +} - virtual void close() CATCH_OVERRIDE { - TrackerBase::close(); - if( m_runState == CompletedSuccessfully && m_index < m_size-1 ) - m_runState = Executing; - } - }; +inline std::size_t listReporters(Config const & /*config*/) { + Catch::cout() << "Available reporters:\n"; + IReporterRegistry::FactoryMap const &factories = + getRegistryHub().getReporterRegistry().getFactories(); + IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), + itEnd = factories.end(), it; + std::size_t maxNameLen = 0; + for (it = itBegin; it != itEnd; ++it) + maxNameLen = (std::max)(maxNameLen, it->first.size()); + + for (it = itBegin; it != itEnd; ++it) { + Text wrapper(it->second->getDescription(), + TextAttributes() + .setInitialIndent(0) + .setIndent(7 + maxNameLen) + .setWidth(CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen - 8)); + Catch::cout() << " " << it->first << ":" + << std::string(maxNameLen - it->first.size() + 2, ' ') + << wrapper << "\n"; + } + Catch::cout() << std::endl; + return factories.size(); +} - inline ITracker& TrackerContext::startRun() { - m_rootTracker = new SectionTracker( "{root}", *this, CATCH_NULL ); - m_currentTracker = CATCH_NULL; - m_runState = Executing; - return *m_rootTracker; - } +inline Option list(Config const &config) { + Option listedCount; + if (config.listTests()) + listedCount = listedCount.valueOr(0) + listTests(config); + if (config.listTestNamesOnly()) + listedCount = listedCount.valueOr(0) + listTestsNamesOnly(config); + if (config.listTags()) + listedCount = listedCount.valueOr(0) + listTags(config); + if (config.listReporters()) + listedCount = listedCount.valueOr(0) + listReporters(config); + return listedCount; +} -} // namespace TestCaseTracking +} // end namespace Catch -using TestCaseTracking::ITracker; -using TestCaseTracking::TrackerContext; -using TestCaseTracking::SectionTracker; -using TestCaseTracking::IndexTracker; +// #included from: internal/catch_run_context.hpp +#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED -} // namespace Catch +// #included from: catch_test_case_tracker.hpp +#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED -// #included from: catch_fatal_condition.hpp -#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED +#include +#include +#include +#include namespace Catch { +namespace TestCaseTracking { - // Report the error condition then exit the process - inline void fatal( std::string const& message, int exitCode ) { - IContext& context = Catch::getCurrentContext(); - IResultCapture* resultCapture = context.getResultCapture(); - resultCapture->handleFatalErrorCondition( message ); +struct ITracker : SharedImpl<> { + virtual ~ITracker(); - if( Catch::alwaysTrue() ) // avoids "no return" warnings - exit( exitCode ); - } + // static queries + virtual std::string name() const = 0; -} // namespace Catch + // dynamic queries + virtual bool isComplete() const = 0; // Successfully completed or failed + virtual bool isSuccessfullyCompleted() const = 0; + virtual bool isOpen() const = 0; // Started but not complete + virtual bool hasChildren() const = 0; -#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// + virtual ITracker &parent() = 0; -namespace Catch { + // actions + virtual void close() = 0; // Successfully complete + virtual void fail() = 0; + virtual void markAsNeedingAnotherRun() = 0; + + virtual void addChild(Ptr const &child) = 0; + virtual ITracker *findChild(std::string const &name) = 0; + virtual void openChild() = 0; +}; - struct FatalConditionHandler { - void reset() {} - }; +class TrackerContext { -} // namespace Catch + enum RunState { NotStarted, Executing, CompletedCycle }; -#else // Not Windows - assumed to be POSIX compatible ////////////////////////// + Ptr m_rootTracker; + ITracker *m_currentTracker; + RunState m_runState; -#include +public: + static TrackerContext &instance() { + static TrackerContext s_instance; + return s_instance; + } + + TrackerContext() : m_currentTracker(CATCH_NULL), m_runState(NotStarted) {} + + ITracker &startRun(); + + void endRun() { + m_rootTracker.reset(); + m_currentTracker = CATCH_NULL; + m_runState = NotStarted; + } + + void startCycle() { + m_currentTracker = m_rootTracker.get(); + m_runState = Executing; + } + void completeCycle() { m_runState = CompletedCycle; } + + bool completedCycle() const { return m_runState == CompletedCycle; } + ITracker ¤tTracker() { return *m_currentTracker; } + void setCurrentTracker(ITracker *tracker) { m_currentTracker = tracker; } +}; -namespace Catch { +class TrackerBase : public ITracker { +protected: + enum CycleState { + NotStarted, + Executing, + ExecutingChildren, + NeedsAnotherRun, + CompletedSuccessfully, + Failed + }; + class TrackerHasName { + std::string m_name; - struct SignalDefs { int id; const char* name; }; - extern SignalDefs signalDefs[]; - SignalDefs signalDefs[] = { - { SIGINT, "SIGINT - Terminal interrupt signal" }, - { SIGILL, "SIGILL - Illegal instruction signal" }, - { SIGFPE, "SIGFPE - Floating point error signal" }, - { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, - { SIGTERM, "SIGTERM - Termination request signal" }, - { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } - }; - - struct FatalConditionHandler { - - static void handleSignal( int sig ) { - for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) - if( sig == signalDefs[i].id ) - fatal( signalDefs[i].name, -sig ); - fatal( "", -sig ); - } + public: + TrackerHasName(std::string const &name) : m_name(name) {} + bool operator()(Ptr const &tracker) { + return tracker->name() == m_name; + } + }; + typedef std::vector> Children; + std::string m_name; + TrackerContext &m_ctx; + ITracker *m_parent; + Children m_children; + CycleState m_runState; - FatalConditionHandler() : m_isSet( true ) { - for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) - signal( signalDefs[i].id, handleSignal ); - } - ~FatalConditionHandler() { - reset(); - } - void reset() { - if( m_isSet ) { - for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) - signal( signalDefs[i].id, SIG_DFL ); - m_isSet = false; - } - } +public: + TrackerBase(std::string const &name, TrackerContext &ctx, ITracker *parent) + : m_name(name), m_ctx(ctx), m_parent(parent), m_runState(NotStarted) {} + virtual ~TrackerBase(); + + virtual std::string name() const CATCH_OVERRIDE { return m_name; } + virtual bool isComplete() const CATCH_OVERRIDE { + return m_runState == CompletedSuccessfully || m_runState == Failed; + } + virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE { + return m_runState == CompletedSuccessfully; + } + virtual bool isOpen() const CATCH_OVERRIDE { + return m_runState != NotStarted && !isComplete(); + } + virtual bool hasChildren() const CATCH_OVERRIDE { + return !m_children.empty(); + } + + virtual void addChild(Ptr const &child) CATCH_OVERRIDE { + m_children.push_back(child); + } + + virtual ITracker *findChild(std::string const &name) CATCH_OVERRIDE { + Children::const_iterator it = std::find_if( + m_children.begin(), m_children.end(), TrackerHasName(name)); + return (it != m_children.end()) ? it->get() : CATCH_NULL; + } + virtual ITracker &parent() CATCH_OVERRIDE { + assert(m_parent); // Should always be non-null except for root + return *m_parent; + } + + virtual void openChild() CATCH_OVERRIDE { + if (m_runState != ExecutingChildren) { + m_runState = ExecutingChildren; + if (m_parent) + m_parent->openChild(); + } + } + void open() { + m_runState = Executing; + moveToThis(); + if (m_parent) + m_parent->openChild(); + } + + virtual void close() CATCH_OVERRIDE { + + // Close any still open children (e.g. generators) + while (&m_ctx.currentTracker() != this) + m_ctx.currentTracker().close(); + + switch (m_runState) { + case NotStarted: + case CompletedSuccessfully: + case Failed: + throw std::logic_error("Illogical state"); + + case NeedsAnotherRun: + break; + ; + + case Executing: + m_runState = CompletedSuccessfully; + break; + case ExecutingChildren: + if (m_children.empty() || m_children.back()->isComplete()) + m_runState = CompletedSuccessfully; + break; + + default: + throw std::logic_error("Unexpected state"); + } + moveToParent(); + m_ctx.completeCycle(); + } + virtual void fail() CATCH_OVERRIDE { + m_runState = Failed; + if (m_parent) + m_parent->markAsNeedingAnotherRun(); + moveToParent(); + m_ctx.completeCycle(); + } + virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE { + m_runState = NeedsAnotherRun; + } - bool m_isSet; - }; +private: + void moveToParent() { + assert(m_parent); + m_ctx.setCurrentTracker(m_parent); + } + void moveToThis() { m_ctx.setCurrentTracker(this); } +}; -} // namespace Catch +class SectionTracker : public TrackerBase { +public: + SectionTracker(std::string const &name, TrackerContext &ctx, ITracker *parent) + : TrackerBase(name, ctx, parent) {} + virtual ~SectionTracker(); -#endif // not Windows + static SectionTracker &acquire(TrackerContext &ctx, std::string const &name) { + SectionTracker *section = CATCH_NULL; -#include -#include + ITracker ¤tTracker = ctx.currentTracker(); + if (ITracker *childTracker = currentTracker.findChild(name)) { + section = dynamic_cast(childTracker); + assert(section); + } else { + section = new SectionTracker(name, ctx, ¤tTracker); + currentTracker.addChild(section); + } + if (!ctx.completedCycle() && !section->isComplete()) { -namespace Catch { + section->open(); + } + return *section; + } +}; - class StreamRedirect { +class IndexTracker : public TrackerBase { + int m_size; + int m_index; - public: - StreamRedirect( std::ostream& stream, std::string& targetString ) - : m_stream( stream ), - m_prevBuf( stream.rdbuf() ), - m_targetString( targetString ) - { - stream.rdbuf( m_oss.rdbuf() ); - } +public: + IndexTracker(std::string const &name, TrackerContext &ctx, ITracker *parent, + int size) + : TrackerBase(name, ctx, parent), m_size(size), m_index(-1) {} + virtual ~IndexTracker(); + + static IndexTracker &acquire(TrackerContext &ctx, std::string const &name, + int size) { + IndexTracker *tracker = CATCH_NULL; + + ITracker ¤tTracker = ctx.currentTracker(); + if (ITracker *childTracker = currentTracker.findChild(name)) { + tracker = dynamic_cast(childTracker); + assert(tracker); + } else { + tracker = new IndexTracker(name, ctx, ¤tTracker, size); + currentTracker.addChild(tracker); + } + + if (!ctx.completedCycle() && !tracker->isComplete()) { + if (tracker->m_runState != ExecutingChildren && + tracker->m_runState != NeedsAnotherRun) + tracker->moveNext(); + tracker->open(); + } + + return *tracker; + } + + int index() const { return m_index; } + + void moveNext() { + m_index++; + m_children.clear(); + } + + virtual void close() CATCH_OVERRIDE { + TrackerBase::close(); + if (m_runState == CompletedSuccessfully && m_index < m_size - 1) + m_runState = Executing; + } +}; - ~StreamRedirect() { - m_targetString += m_oss.str(); - m_stream.rdbuf( m_prevBuf ); - } +inline ITracker &TrackerContext::startRun() { + m_rootTracker = new SectionTracker("{root}", *this, CATCH_NULL); + m_currentTracker = CATCH_NULL; + m_runState = Executing; + return *m_rootTracker; +} - private: - std::ostream& m_stream; - std::streambuf* m_prevBuf; - std::ostringstream m_oss; - std::string& m_targetString; - }; +} // namespace TestCaseTracking - /////////////////////////////////////////////////////////////////////////// +using TestCaseTracking::IndexTracker; +using TestCaseTracking::ITracker; +using TestCaseTracking::SectionTracker; +using TestCaseTracking::TrackerContext; - class RunContext : public IResultCapture, public IRunner { +} // namespace Catch - RunContext( RunContext const& ); - void operator =( RunContext const& ); +// #included from: catch_fatal_condition.hpp +#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED - public: +namespace Catch { - explicit RunContext( Ptr const& _config, Ptr const& reporter ) - : m_runInfo( _config->name() ), - m_context( getCurrentMutableContext() ), - m_activeTestCase( CATCH_NULL ), - m_config( _config ), - m_reporter( reporter ) - { - m_context.setRunner( this ); - m_context.setConfig( m_config ); - m_context.setResultCapture( this ); - m_reporter->testRunStarting( m_runInfo ); - } +// Report the error condition then exit the process +inline void fatal(std::string const &message, int exitCode) { + IContext &context = Catch::getCurrentContext(); + IResultCapture *resultCapture = context.getResultCapture(); + resultCapture->handleFatalErrorCondition(message); - virtual ~RunContext() { - m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) ); - } + if (Catch::alwaysTrue()) // avoids "no return" warnings + exit(exitCode); +} - void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) { - m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) ); - } - void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) { - m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) ); - } +} // namespace Catch - Totals runTest( TestCase const& testCase ) { - Totals prevTotals = m_totals; +#if defined(CATCH_PLATFORM_WINDOWS) ///////////////////////////////////////// - std::string redirectedCout; - std::string redirectedCerr; +namespace Catch { - TestCaseInfo testInfo = testCase.getTestCaseInfo(); +struct FatalConditionHandler { + void reset() {} +}; - m_reporter->testCaseStarting( testInfo ); +} // namespace Catch - m_activeTestCase = &testCase; +#else // Not Windows - assumed to be POSIX compatible ////////////////////////// - do { - m_trackerContext.startRun(); - do { - m_trackerContext.startCycle(); - m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, testInfo.name ); - runCurrentTest( redirectedCout, redirectedCerr ); - } - while( !m_testCaseTracker->isSuccessfullyCompleted() && !aborting() ); - } - // !TBD: deprecated - this will be replaced by indexed trackers - while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() ); - - Totals deltaTotals = m_totals.delta( prevTotals ); - if( testInfo.expectedToFail() && deltaTotals.testCases.passed > 0 ) { - deltaTotals.assertions.failed++; - deltaTotals.testCases.passed--; - deltaTotals.testCases.failed++; - } - m_totals.testCases += deltaTotals.testCases; - m_reporter->testCaseEnded( TestCaseStats( testInfo, - deltaTotals, - redirectedCout, - redirectedCerr, - aborting() ) ); +#include - m_activeTestCase = CATCH_NULL; - m_testCaseTracker = CATCH_NULL; +namespace Catch { - return deltaTotals; - } +struct SignalDefs { + int id; + const char *name; +}; +extern SignalDefs signalDefs[]; +SignalDefs signalDefs[] = { + {SIGINT, "SIGINT - Terminal interrupt signal"}, + {SIGILL, "SIGILL - Illegal instruction signal"}, + {SIGFPE, "SIGFPE - Floating point error signal"}, + {SIGSEGV, "SIGSEGV - Segmentation violation signal"}, + {SIGTERM, "SIGTERM - Termination request signal"}, + {SIGABRT, "SIGABRT - Abort (abnormal termination) signal"}}; + +struct FatalConditionHandler { + + static void handleSignal(int sig) { + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) + if (sig == signalDefs[i].id) + fatal(signalDefs[i].name, -sig); + fatal("", -sig); + } + + FatalConditionHandler() : m_isSet(true) { + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) + signal(signalDefs[i].id, handleSignal); + } + ~FatalConditionHandler() { reset(); } + void reset() { + if (m_isSet) { + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) + signal(signalDefs[i].id, SIG_DFL); + m_isSet = false; + } + } + + bool m_isSet; +}; - Ptr config() const { - return m_config; - } +} // namespace Catch - private: // IResultCapture +#endif // not Windows - virtual void assertionEnded( AssertionResult const& result ) { - if( result.getResultType() == ResultWas::Ok ) { - m_totals.assertions.passed++; - } - else if( !result.isOk() ) { - m_totals.assertions.failed++; - } +#include +#include - if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) ) - m_messages.clear(); +namespace Catch { - // Reset working state - m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition ); - m_lastResult = result; - } +class StreamRedirect { - virtual bool sectionStarted ( - SectionInfo const& sectionInfo, - Counts& assertions - ) - { - std::ostringstream oss; - oss << sectionInfo.name << "@" << sectionInfo.lineInfo; +public: + StreamRedirect(std::ostream &stream, std::string &targetString) + : m_stream(stream), m_prevBuf(stream.rdbuf()), + m_targetString(targetString) { + stream.rdbuf(m_oss.rdbuf()); + } - ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, oss.str() ); - if( !sectionTracker.isOpen() ) - return false; - m_activeSections.push_back( §ionTracker ); + ~StreamRedirect() { + m_targetString += m_oss.str(); + m_stream.rdbuf(m_prevBuf); + } - m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; +private: + std::ostream &m_stream; + std::streambuf *m_prevBuf; + std::ostringstream m_oss; + std::string &m_targetString; +}; - m_reporter->sectionStarting( sectionInfo ); +/////////////////////////////////////////////////////////////////////////// - assertions = m_totals.assertions; +class RunContext : public IResultCapture, public IRunner { - return true; - } - bool testForMissingAssertions( Counts& assertions ) { - if( assertions.total() != 0 ) - return false; - if( !m_config->warnAboutMissingAssertions() ) - return false; - if( m_trackerContext.currentTracker().hasChildren() ) - return false; - m_totals.assertions.failed++; - assertions.failed++; - return true; - } + RunContext(RunContext const &); + void operator=(RunContext const &); - virtual void sectionEnded( SectionEndInfo const& endInfo ) { - Counts assertions = m_totals.assertions - endInfo.prevAssertions; - bool missingAssertions = testForMissingAssertions( assertions ); +public: + explicit RunContext(Ptr const &_config, + Ptr const &reporter) + : m_runInfo(_config->name()), m_context(getCurrentMutableContext()), + m_activeTestCase(CATCH_NULL), m_config(_config), m_reporter(reporter) { + m_context.setRunner(this); + m_context.setConfig(m_config); + m_context.setResultCapture(this); + m_reporter->testRunStarting(m_runInfo); + } + + virtual ~RunContext() { + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, aborting())); + } + + void testGroupStarting(std::string const &testSpec, std::size_t groupIndex, + std::size_t groupsCount) { + m_reporter->testGroupStarting(GroupInfo(testSpec, groupIndex, groupsCount)); + } + void testGroupEnded(std::string const &testSpec, Totals const &totals, + std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupEnded(TestGroupStats( + GroupInfo(testSpec, groupIndex, groupsCount), totals, aborting())); + } + + Totals runTest(TestCase const &testCase) { + Totals prevTotals = m_totals; + + std::string redirectedCout; + std::string redirectedCerr; + + TestCaseInfo testInfo = testCase.getTestCaseInfo(); + + m_reporter->testCaseStarting(testInfo); + + m_activeTestCase = &testCase; + + do { + m_trackerContext.startRun(); + do { + m_trackerContext.startCycle(); + m_testCaseTracker = + &SectionTracker::acquire(m_trackerContext, testInfo.name); + runCurrentTest(redirectedCout, redirectedCerr); + } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting()); + } + // !TBD: deprecated - this will be replaced by indexed trackers + while (getCurrentContext().advanceGeneratorsForCurrentTest() && + !aborting()); + + Totals deltaTotals = m_totals.delta(prevTotals); + if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) { + deltaTotals.assertions.failed++; + deltaTotals.testCases.passed--; + deltaTotals.testCases.failed++; + } + m_totals.testCases += deltaTotals.testCases; + m_reporter->testCaseEnded(TestCaseStats( + testInfo, deltaTotals, redirectedCout, redirectedCerr, aborting())); + + m_activeTestCase = CATCH_NULL; + m_testCaseTracker = CATCH_NULL; + + return deltaTotals; + } + + Ptr config() const { return m_config; } + +private: // IResultCapture + virtual void assertionEnded(AssertionResult const &result) { + if (result.getResultType() == ResultWas::Ok) { + m_totals.assertions.passed++; + } else if (!result.isOk()) { + m_totals.assertions.failed++; + } + + if (m_reporter->assertionEnded( + AssertionStats(result, m_messages, m_totals))) + m_messages.clear(); + + // Reset working state + m_lastAssertionInfo = + AssertionInfo("", m_lastAssertionInfo.lineInfo, + "{Unknown expression after the reported line}", + m_lastAssertionInfo.resultDisposition); + m_lastResult = result; + } + + virtual bool sectionStarted(SectionInfo const §ionInfo, + Counts &assertions) { + std::ostringstream oss; + oss << sectionInfo.name << "@" << sectionInfo.lineInfo; + + ITracker §ionTracker = + SectionTracker::acquire(m_trackerContext, oss.str()); + if (!sectionTracker.isOpen()) + return false; + m_activeSections.push_back(§ionTracker); + + m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; + + m_reporter->sectionStarting(sectionInfo); + + assertions = m_totals.assertions; + + return true; + } + bool testForMissingAssertions(Counts &assertions) { + if (assertions.total() != 0) + return false; + if (!m_config->warnAboutMissingAssertions()) + return false; + if (m_trackerContext.currentTracker().hasChildren()) + return false; + m_totals.assertions.failed++; + assertions.failed++; + return true; + } + + virtual void sectionEnded(SectionEndInfo const &endInfo) { + Counts assertions = m_totals.assertions - endInfo.prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + + if (!m_activeSections.empty()) { + m_activeSections.back()->close(); + m_activeSections.pop_back(); + } + + m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, + endInfo.durationInSeconds, + missingAssertions)); + m_messages.clear(); + } + + virtual void sectionEndedEarly(SectionEndInfo const &endInfo) { + if (m_unfinishedSections.empty()) + m_activeSections.back()->fail(); + else + m_activeSections.back()->close(); + m_activeSections.pop_back(); - if( !m_activeSections.empty() ) { - m_activeSections.back()->close(); - m_activeSections.pop_back(); - } + m_unfinishedSections.push_back(endInfo); + } - m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) ); - m_messages.clear(); - } + virtual void pushScopedMessage(MessageInfo const &message) { + m_messages.push_back(message); + } - virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) { - if( m_unfinishedSections.empty() ) - m_activeSections.back()->fail(); - else - m_activeSections.back()->close(); - m_activeSections.pop_back(); + virtual void popScopedMessage(MessageInfo const &message) { + m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), + m_messages.end()); + } - m_unfinishedSections.push_back( endInfo ); - } + virtual std::string getCurrentTestName() const { + return m_activeTestCase ? m_activeTestCase->getTestCaseInfo().name : ""; + } - virtual void pushScopedMessage( MessageInfo const& message ) { - m_messages.push_back( message ); - } + virtual const AssertionResult *getLastResult() const { return &m_lastResult; } - virtual void popScopedMessage( MessageInfo const& message ) { - m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() ); - } + virtual void handleFatalErrorCondition(std::string const &message) { + ResultBuilder resultBuilder = makeUnexpectedResultBuilder(); + resultBuilder.setResultType(ResultWas::FatalErrorCondition); + resultBuilder << message; + resultBuilder.captureExpression(); - virtual std::string getCurrentTestName() const { - return m_activeTestCase - ? m_activeTestCase->getTestCaseInfo().name - : ""; - } + handleUnfinishedSections(); - virtual const AssertionResult* getLastResult() const { - return &m_lastResult; - } + // Recreate section for test case (as we will lose the one that was in + // scope) + TestCaseInfo const &testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name, + testCaseInfo.description); - virtual void handleFatalErrorCondition( std::string const& message ) { - ResultBuilder resultBuilder = makeUnexpectedResultBuilder(); - resultBuilder.setResultType( ResultWas::FatalErrorCondition ); - resultBuilder << message; - resultBuilder.captureExpression(); - - handleUnfinishedSections(); - - // Recreate section for test case (as we will lose the one that was in scope) - TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); - SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description ); - - Counts assertions; - assertions.failed = 1; - SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false ); - m_reporter->sectionEnded( testCaseSectionStats ); - - TestCaseInfo testInfo = m_activeTestCase->getTestCaseInfo(); - - Totals deltaTotals; - deltaTotals.testCases.failed = 1; - m_reporter->testCaseEnded( TestCaseStats( testInfo, - deltaTotals, - "", - "", - false ) ); - m_totals.testCases.failed++; - testGroupEnded( "", m_totals, 1, 1 ); - m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, false ) ); - } + Counts assertions; + assertions.failed = 1; + SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false); + m_reporter->sectionEnded(testCaseSectionStats); - public: - // !TBD We need to do this another way! - bool aborting() const { - return m_totals.assertions.failed == static_cast( m_config->abortAfter() ); - } + TestCaseInfo testInfo = m_activeTestCase->getTestCaseInfo(); - private: - - void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) { - TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); - SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description ); - m_reporter->sectionStarting( testCaseSection ); - Counts prevAssertions = m_totals.assertions; - double duration = 0; - try { - m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal ); - - seedRng( *m_config ); - - Timer timer; - timer.start(); - if( m_reporter->getPreferences().shouldRedirectStdOut ) { - StreamRedirect coutRedir( Catch::cout(), redirectedCout ); - StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr ); - invokeActiveTestCase(); - } - else { - invokeActiveTestCase(); - } - duration = timer.getElapsedSeconds(); - } - catch( TestFailureException& ) { - // This just means the test was aborted due to failure - } - catch(...) { - makeUnexpectedResultBuilder().useActiveException(); - } - m_testCaseTracker->close(); - handleUnfinishedSections(); - m_messages.clear(); + Totals deltaTotals; + deltaTotals.testCases.failed = 1; + m_reporter->testCaseEnded( + TestCaseStats(testInfo, deltaTotals, "", "", false)); + m_totals.testCases.failed++; + testGroupEnded("", m_totals, 1, 1); + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false)); + } - Counts assertions = m_totals.assertions - prevAssertions; - bool missingAssertions = testForMissingAssertions( assertions ); +public: + // !TBD We need to do this another way! + bool aborting() const { + return m_totals.assertions.failed == + static_cast(m_config->abortAfter()); + } - if( testCaseInfo.okToFail() ) { - std::swap( assertions.failedButOk, assertions.failed ); - m_totals.assertions.failed -= assertions.failedButOk; - m_totals.assertions.failedButOk += assertions.failedButOk; - } +private: + void runCurrentTest(std::string &redirectedCout, + std::string &redirectedCerr) { + TestCaseInfo const &testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name, + testCaseInfo.description); + m_reporter->sectionStarting(testCaseSection); + Counts prevAssertions = m_totals.assertions; + double duration = 0; + try { + m_lastAssertionInfo = AssertionInfo("TEST_CASE", testCaseInfo.lineInfo, + "", ResultDisposition::Normal); + + seedRng(*m_config); + + Timer timer; + timer.start(); + if (m_reporter->getPreferences().shouldRedirectStdOut) { + StreamRedirect coutRedir(Catch::cout(), redirectedCout); + StreamRedirect cerrRedir(Catch::cerr(), redirectedCerr); + invokeActiveTestCase(); + } else { + invokeActiveTestCase(); + } + duration = timer.getElapsedSeconds(); + } catch (TestFailureException &) { + // This just means the test was aborted due to failure + } catch (...) { + makeUnexpectedResultBuilder().useActiveException(); + } + m_testCaseTracker->close(); + handleUnfinishedSections(); + m_messages.clear(); - SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions ); - m_reporter->sectionEnded( testCaseSectionStats ); - } + Counts assertions = m_totals.assertions - prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); - void invokeActiveTestCase() { - FatalConditionHandler fatalConditionHandler; // Handle signals - m_activeTestCase->invoke(); - fatalConditionHandler.reset(); - } + if (testCaseInfo.okToFail()) { + std::swap(assertions.failedButOk, assertions.failed); + m_totals.assertions.failed -= assertions.failedButOk; + m_totals.assertions.failedButOk += assertions.failedButOk; + } - private: + SectionStats testCaseSectionStats(testCaseSection, assertions, duration, + missingAssertions); + m_reporter->sectionEnded(testCaseSectionStats); + } - ResultBuilder makeUnexpectedResultBuilder() const { - return ResultBuilder( m_lastAssertionInfo.macroName.c_str(), - m_lastAssertionInfo.lineInfo, - m_lastAssertionInfo.capturedExpression.c_str(), - m_lastAssertionInfo.resultDisposition ); - } + void invokeActiveTestCase() { + FatalConditionHandler fatalConditionHandler; // Handle signals + m_activeTestCase->invoke(); + fatalConditionHandler.reset(); + } - void handleUnfinishedSections() { - // If sections ended prematurely due to an exception we stored their - // infos here so we can tear them down outside the unwind process. - for( std::vector::const_reverse_iterator it = m_unfinishedSections.rbegin(), - itEnd = m_unfinishedSections.rend(); - it != itEnd; - ++it ) - sectionEnded( *it ); - m_unfinishedSections.clear(); - } +private: + ResultBuilder makeUnexpectedResultBuilder() const { + return ResultBuilder(m_lastAssertionInfo.macroName.c_str(), + m_lastAssertionInfo.lineInfo, + m_lastAssertionInfo.capturedExpression.c_str(), + m_lastAssertionInfo.resultDisposition); + } + + void handleUnfinishedSections() { + // If sections ended prematurely due to an exception we stored their + // infos here so we can tear them down outside the unwind process. + for (std::vector::const_reverse_iterator + it = m_unfinishedSections.rbegin(), + itEnd = m_unfinishedSections.rend(); + it != itEnd; ++it) + sectionEnded(*it); + m_unfinishedSections.clear(); + } + + TestRunInfo m_runInfo; + IMutableContext &m_context; + TestCase const *m_activeTestCase; + ITracker *m_testCaseTracker; + ITracker *m_currentSectionTracker; + AssertionResult m_lastResult; + + Ptr m_config; + Totals m_totals; + Ptr m_reporter; + std::vector m_messages; + AssertionInfo m_lastAssertionInfo; + std::vector m_unfinishedSections; + std::vector m_activeSections; + TrackerContext m_trackerContext; +}; - TestRunInfo m_runInfo; - IMutableContext& m_context; - TestCase const* m_activeTestCase; - ITracker* m_testCaseTracker; - ITracker* m_currentSectionTracker; - AssertionResult m_lastResult; - - Ptr m_config; - Totals m_totals; - Ptr m_reporter; - std::vector m_messages; - AssertionInfo m_lastAssertionInfo; - std::vector m_unfinishedSections; - std::vector m_activeSections; - TrackerContext m_trackerContext; - }; - - IResultCapture& getResultCapture() { - if( IResultCapture* capture = getCurrentContext().getResultCapture() ) - return *capture; - else - throw std::logic_error( "No result capture instance" ); - } +IResultCapture &getResultCapture() { + if (IResultCapture *capture = getCurrentContext().getResultCapture()) + return *capture; + else + throw std::logic_error("No result capture instance"); +} } // end namespace Catch @@ -6184,228 +6279,228 @@ namespace Catch { namespace Catch { - // Versioning information - struct Version { - Version( unsigned int _majorVersion, - unsigned int _minorVersion, - unsigned int _patchNumber, - std::string const& _branchName, - unsigned int _buildNumber ); +// Versioning information +struct Version { + Version(unsigned int _majorVersion, unsigned int _minorVersion, + unsigned int _patchNumber, std::string const &_branchName, + unsigned int _buildNumber); - unsigned int const majorVersion; - unsigned int const minorVersion; - unsigned int const patchNumber; + unsigned int const majorVersion; + unsigned int const minorVersion; + unsigned int const patchNumber; - // buildNumber is only used if branchName is not null - std::string const branchName; - unsigned int const buildNumber; + // buildNumber is only used if branchName is not null + std::string const branchName; + unsigned int const buildNumber; - friend std::ostream& operator << ( std::ostream& os, Version const& version ); + friend std::ostream &operator<<(std::ostream &os, Version const &version); - private: - void operator=( Version const& ); - }; +private: + void operator=(Version const &); +}; - extern Version libraryVersion; -} +extern Version libraryVersion; +} // namespace Catch #include -#include #include +#include namespace Catch { - Ptr createReporter( std::string const& reporterName, Ptr const& config ) { - Ptr reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() ); - if( !reporter ) { - std::ostringstream oss; - oss << "No reporter registered with name: '" << reporterName << "'"; - throw std::domain_error( oss.str() ); - } - return reporter; - } - - Ptr makeReporter( Ptr const& config ) { - std::vector reporters = config->getReporterNames(); - if( reporters.empty() ) - reporters.push_back( "console" ); - - Ptr reporter; - for( std::vector::const_iterator it = reporters.begin(), itEnd = reporters.end(); - it != itEnd; - ++it ) - reporter = addReporter( reporter, createReporter( *it, config ) ); - return reporter; - } - Ptr addListeners( Ptr const& config, Ptr reporters ) { - IReporterRegistry::Listeners listeners = getRegistryHub().getReporterRegistry().getListeners(); - for( IReporterRegistry::Listeners::const_iterator it = listeners.begin(), itEnd = listeners.end(); - it != itEnd; - ++it ) - reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) ); - return reporters; - } - - Totals runTests( Ptr const& config ) { - - Ptr iconfig = config.get(); +Ptr createReporter(std::string const &reporterName, + Ptr const &config) { + Ptr reporter = + getRegistryHub().getReporterRegistry().create(reporterName, config.get()); + if (!reporter) { + std::ostringstream oss; + oss << "No reporter registered with name: '" << reporterName << "'"; + throw std::domain_error(oss.str()); + } + return reporter; +} - Ptr reporter = makeReporter( config ); - reporter = addListeners( iconfig, reporter ); +Ptr makeReporter(Ptr const &config) { + std::vector reporters = config->getReporterNames(); + if (reporters.empty()) + reporters.push_back("console"); + + Ptr reporter; + for (std::vector::const_iterator it = reporters.begin(), + itEnd = reporters.end(); + it != itEnd; ++it) + reporter = addReporter(reporter, createReporter(*it, config)); + return reporter; +} +Ptr addListeners(Ptr const &config, + Ptr reporters) { + IReporterRegistry::Listeners listeners = + getRegistryHub().getReporterRegistry().getListeners(); + for (IReporterRegistry::Listeners::const_iterator it = listeners.begin(), + itEnd = listeners.end(); + it != itEnd; ++it) + reporters = addReporter(reporters, (*it)->create(ReporterConfig(config))); + return reporters; +} - RunContext context( iconfig, reporter ); +Totals runTests(Ptr const &config) { - Totals totals; + Ptr iconfig = config.get(); - context.testGroupStarting( config->name(), 1, 1 ); + Ptr reporter = makeReporter(config); + reporter = addListeners(iconfig, reporter); - TestSpec testSpec = config->testSpec(); - if( !testSpec.hasFilters() ) - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests + RunContext context(iconfig, reporter); - std::vector const& allTestCases = getAllTestCasesSorted( *iconfig ); - for( std::vector::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end(); - it != itEnd; - ++it ) { - if( !context.aborting() && matchTest( *it, testSpec, *iconfig ) ) - totals += context.runTest( *it ); - else - reporter->skipTest( *it ); - } + Totals totals; - context.testGroupEnded( iconfig->name(), totals, 1, 1 ); - return totals; - } + context.testGroupStarting(config->name(), 1, 1); - void applyFilenamesAsTags( IConfig const& config ) { - std::vector const& tests = getAllTestCasesSorted( config ); - for(std::size_t i = 0; i < tests.size(); ++i ) { - TestCase& test = const_cast( tests[i] ); - std::set tags = test.tags; + TestSpec testSpec = config->testSpec(); + if (!testSpec.hasFilters()) + testSpec = TestSpecParser(ITagAliasRegistry::get()) + .parse("~[.]") + .testSpec(); // All not hidden tests - std::string filename = test.lineInfo.file; - std::string::size_type lastSlash = filename.find_last_of( "\\/" ); - if( lastSlash != std::string::npos ) - filename = filename.substr( lastSlash+1 ); + std::vector const &allTestCases = getAllTestCasesSorted(*iconfig); + for (std::vector::const_iterator it = allTestCases.begin(), + itEnd = allTestCases.end(); + it != itEnd; ++it) { + if (!context.aborting() && matchTest(*it, testSpec, *iconfig)) + totals += context.runTest(*it); + else + reporter->skipTest(*it); + } - std::string::size_type lastDot = filename.find_last_of( "." ); - if( lastDot != std::string::npos ) - filename = filename.substr( 0, lastDot ); + context.testGroupEnded(iconfig->name(), totals, 1, 1); + return totals; +} - tags.insert( "#" + filename ); - setTags( test, tags ); - } - } +void applyFilenamesAsTags(IConfig const &config) { + std::vector const &tests = getAllTestCasesSorted(config); + for (std::size_t i = 0; i < tests.size(); ++i) { + TestCase &test = const_cast(tests[i]); + std::set tags = test.tags; - class Session : NonCopyable { - static bool alreadyInstantiated; + std::string filename = test.lineInfo.file; + std::string::size_type lastSlash = filename.find_last_of("\\/"); + if (lastSlash != std::string::npos) + filename = filename.substr(lastSlash + 1); - public: + std::string::size_type lastDot = filename.find_last_of("."); + if (lastDot != std::string::npos) + filename = filename.substr(0, lastDot); - struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; }; + tags.insert("#" + filename); + setTags(test, tags); + } +} - Session() - : m_cli( makeCommandLineParser() ) { - if( alreadyInstantiated ) { - std::string msg = "Only one instance of Catch::Session can ever be used"; - Catch::cerr() << msg << std::endl; - throw std::logic_error( msg ); - } - alreadyInstantiated = true; - } - ~Session() { - Catch::cleanUp(); - } +class Session : NonCopyable { + static bool alreadyInstantiated; - void showHelp( std::string const& processName ) { - Catch::cout() << "\nCatch v" << libraryVersion << "\n"; +public: + struct OnUnusedOptions { + enum DoWhat { Ignore, Fail }; + }; - m_cli.usage( Catch::cout(), processName ); - Catch::cout() << "For more detail usage please see the project docs\n" << std::endl; - } + Session() : m_cli(makeCommandLineParser()) { + if (alreadyInstantiated) { + std::string msg = "Only one instance of Catch::Session can ever be used"; + Catch::cerr() << msg << std::endl; + throw std::logic_error(msg); + } + alreadyInstantiated = true; + } + ~Session() { Catch::cleanUp(); } + + void showHelp(std::string const &processName) { + Catch::cout() << "\nCatch v" << libraryVersion << "\n"; + + m_cli.usage(Catch::cout(), processName); + Catch::cout() << "For more detail usage please see the project docs\n" + << std::endl; + } + + int applyCommandLine( + int argc, char const *const *const argv, + OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail) { + try { + m_cli.setThrowOnUnrecognisedTokens(unusedOptionBehaviour == + OnUnusedOptions::Fail); + m_unusedTokens = + m_cli.parseInto(Clara::argsToVector(argc, argv), m_configData); + if (m_configData.showHelp) + showHelp(m_configData.processName); + m_config.reset(); + } catch (std::exception &ex) { + { + Colour colourGuard(Colour::Red); + Catch::cerr() << "\nError(s) in input:\n" + << Text(ex.what(), TextAttributes().setIndent(2)) + << "\n\n"; + } + m_cli.usage(Catch::cout(), m_configData.processName); + return (std::numeric_limits::max)(); + } + return 0; + } - int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) { - try { - m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail ); - m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData ); - if( m_configData.showHelp ) - showHelp( m_configData.processName ); - m_config.reset(); - } - catch( std::exception& ex ) { - { - Colour colourGuard( Colour::Red ); - Catch::cerr() - << "\nError(s) in input:\n" - << Text( ex.what(), TextAttributes().setIndent(2) ) - << "\n\n"; - } - m_cli.usage( Catch::cout(), m_configData.processName ); - return (std::numeric_limits::max)(); - } - return 0; - } + void useConfigData(ConfigData const &_configData) { + m_configData = _configData; + m_config.reset(); + } - void useConfigData( ConfigData const& _configData ) { - m_configData = _configData; - m_config.reset(); - } + int run(int argc, char const *const *const argv) { - int run( int argc, char const* const* const argv ) { + int returnCode = applyCommandLine(argc, argv); + if (returnCode == 0) + returnCode = run(); + return returnCode; + } - int returnCode = applyCommandLine( argc, argv ); - if( returnCode == 0 ) - returnCode = run(); - return returnCode; - } + int run() { + if (m_configData.showHelp) + return 0; - int run() { - if( m_configData.showHelp ) - return 0; + try { + config(); // Force config to be constructed - try - { - config(); // Force config to be constructed + seedRng(*m_config); - seedRng( *m_config ); + if (m_configData.filenamesAsTags) + applyFilenamesAsTags(*m_config); - if( m_configData.filenamesAsTags ) - applyFilenamesAsTags( *m_config ); + // Handle list request + if (Option listed = list(config())) + return static_cast(*listed); - // Handle list request - if( Option listed = list( config() ) ) - return static_cast( *listed ); + return static_cast(runTests(m_config).assertions.failed); + } catch (std::exception &ex) { + Catch::cerr() << ex.what() << std::endl; + return (std::numeric_limits::max)(); + } + } - return static_cast( runTests( m_config ).assertions.failed ); - } - catch( std::exception& ex ) { - Catch::cerr() << ex.what() << std::endl; - return (std::numeric_limits::max)(); - } - } + Clara::CommandLine const &cli() const { return m_cli; } + std::vector const &unusedTokens() const { + return m_unusedTokens; + } + ConfigData &configData() { return m_configData; } + Config &config() { + if (!m_config) + m_config = new Config(m_configData); + return *m_config; + } - Clara::CommandLine const& cli() const { - return m_cli; - } - std::vector const& unusedTokens() const { - return m_unusedTokens; - } - ConfigData& configData() { - return m_configData; - } - Config& config() { - if( !m_config ) - m_config = new Config( m_configData ); - return *m_config; - } - private: - Clara::CommandLine m_cli; - std::vector m_unusedTokens; - ConfigData m_configData; - Ptr m_config; - }; +private: + Clara::CommandLine m_cli; + std::vector m_unusedTokens; + ConfigData m_configData; + Ptr m_config; +}; - bool Session::alreadyInstantiated = false; +bool Session::alreadyInstantiated = false; } // end namespace Catch @@ -6415,179 +6510,175 @@ namespace Catch { // #included from: catch_test_case_registry_impl.hpp #define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED -#include +#include +#include #include #include -#include -#include +#include namespace Catch { - struct LexSort { - bool operator() (TestCase i,TestCase j) const { return (i sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { - - std::vector sorted = unsortedTestCases; - - switch( config.runOrder() ) { - case RunTests::InLexicographicalOrder: - std::sort( sorted.begin(), sorted.end(), LexSort() ); - break; - case RunTests::InRandomOrder: - { - seedRng( config ); - - RandomNumberGenerator rng; - std::random_shuffle( sorted.begin(), sorted.end(), rng ); - } - break; - case RunTests::InDeclarationOrder: - // already in declaration order - break; - } - return sorted; - } - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) { - return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() ); - } - - void enforceNoDuplicateTestCases( std::vector const& functions ) { - std::set seenFunctions; - for( std::vector::const_iterator it = functions.begin(), itEnd = functions.end(); - it != itEnd; - ++it ) { - std::pair::const_iterator, bool> prev = seenFunctions.insert( *it ); - if( !prev.second ){ - Catch::cerr() - << Colour( Colour::Red ) - << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n" - << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n" - << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl; - exit(1); - } - } - } +struct LexSort { + bool operator()(TestCase i, TestCase j) const { return (i < j); } +}; +struct RandomNumberGenerator { + int operator()(int n) const { return std::rand() % n; } +}; - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { - std::vector filtered; - filtered.reserve( testCases.size() ); - for( std::vector::const_iterator it = testCases.begin(), itEnd = testCases.end(); - it != itEnd; - ++it ) - if( matchTest( *it, testSpec, config ) ) - filtered.push_back( *it ); - return filtered; - } - std::vector const& getAllTestCasesSorted( IConfig const& config ) { - return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); - } - - class TestRegistry : public ITestCaseRegistry { - public: - TestRegistry() - : m_currentSortOrder( RunTests::InDeclarationOrder ), - m_unnamedCount( 0 ) - {} - virtual ~TestRegistry(); - - virtual void registerTest( TestCase const& testCase ) { - std::string name = testCase.getTestCaseInfo().name; - if( name == "" ) { - std::ostringstream oss; - oss << "Anonymous test case " << ++m_unnamedCount; - return registerTest( testCase.withName( oss.str() ) ); - } - m_functions.push_back( testCase ); - } +inline std::vector +sortTests(IConfig const &config, + std::vector const &unsortedTestCases) { + + std::vector sorted = unsortedTestCases; + + switch (config.runOrder()) { + case RunTests::InLexicographicalOrder: + std::sort(sorted.begin(), sorted.end(), LexSort()); + break; + case RunTests::InRandomOrder: { + seedRng(config); + + RandomNumberGenerator rng; + std::random_shuffle(sorted.begin(), sorted.end(), rng); + } break; + case RunTests::InDeclarationOrder: + // already in declaration order + break; + } + return sorted; +} +bool matchTest(TestCase const &testCase, TestSpec const &testSpec, + IConfig const &config) { + return testSpec.matches(testCase) && + (config.allowThrows() || !testCase.throws()); +} - virtual std::vector const& getAllTests() const { - return m_functions; - } - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const { - if( m_sortedFunctions.empty() ) - enforceNoDuplicateTestCases( m_functions ); +void enforceNoDuplicateTestCases(std::vector const &functions) { + std::set seenFunctions; + for (std::vector::const_iterator it = functions.begin(), + itEnd = functions.end(); + it != itEnd; ++it) { + std::pair::const_iterator, bool> prev = + seenFunctions.insert(*it); + if (!prev.second) { + Catch::cerr() << Colour(Colour::Red) << "error: TEST_CASE( \"" << it->name + << "\" ) already defined.\n" + << "\tFirst seen at " + << prev.first->getTestCaseInfo().lineInfo << "\n" + << "\tRedefined at " << it->getTestCaseInfo().lineInfo + << std::endl; + exit(1); + } + } +} - if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) { - m_sortedFunctions = sortTests( config, m_functions ); - m_currentSortOrder = config.runOrder(); - } - return m_sortedFunctions; - } +std::vector filterTests(std::vector const &testCases, + TestSpec const &testSpec, + IConfig const &config) { + std::vector filtered; + filtered.reserve(testCases.size()); + for (std::vector::const_iterator it = testCases.begin(), + itEnd = testCases.end(); + it != itEnd; ++it) + if (matchTest(*it, testSpec, config)) + filtered.push_back(*it); + return filtered; +} +std::vector const &getAllTestCasesSorted(IConfig const &config) { + return getRegistryHub().getTestCaseRegistry().getAllTestsSorted(config); +} - private: - std::vector m_functions; - mutable RunTests::InWhatOrder m_currentSortOrder; - mutable std::vector m_sortedFunctions; - size_t m_unnamedCount; - std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised - }; +class TestRegistry : public ITestCaseRegistry { +public: + TestRegistry() + : m_currentSortOrder(RunTests::InDeclarationOrder), m_unnamedCount(0) {} + virtual ~TestRegistry(); + + virtual void registerTest(TestCase const &testCase) { + std::string name = testCase.getTestCaseInfo().name; + if (name == "") { + std::ostringstream oss; + oss << "Anonymous test case " << ++m_unnamedCount; + return registerTest(testCase.withName(oss.str())); + } + m_functions.push_back(testCase); + } + + virtual std::vector const &getAllTests() const { + return m_functions; + } + virtual std::vector const & + getAllTestsSorted(IConfig const &config) const { + if (m_sortedFunctions.empty()) + enforceNoDuplicateTestCases(m_functions); + + if (m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty()) { + m_sortedFunctions = sortTests(config, m_functions); + m_currentSortOrder = config.runOrder(); + } + return m_sortedFunctions; + } - /////////////////////////////////////////////////////////////////////////// +private: + std::vector m_functions; + mutable RunTests::InWhatOrder m_currentSortOrder; + mutable std::vector m_sortedFunctions; + size_t m_unnamedCount; + std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised +}; - class FreeFunctionTestCase : public SharedImpl { - public: +/////////////////////////////////////////////////////////////////////////// - FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {} +class FreeFunctionTestCase : public SharedImpl { +public: + FreeFunctionTestCase(TestFunction fun) : m_fun(fun) {} - virtual void invoke() const { - m_fun(); - } + virtual void invoke() const { m_fun(); } - private: - virtual ~FreeFunctionTestCase(); +private: + virtual ~FreeFunctionTestCase(); - TestFunction m_fun; - }; + TestFunction m_fun; +}; - inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) { - std::string className = classOrQualifiedMethodName; - if( startsWith( className, "&" ) ) - { - std::size_t lastColons = className.rfind( "::" ); - std::size_t penultimateColons = className.rfind( "::", lastColons-1 ); - if( penultimateColons == std::string::npos ) - penultimateColons = 1; - className = className.substr( penultimateColons, lastColons-penultimateColons ); - } - return className; - } +inline std::string +extractClassName(std::string const &classOrQualifiedMethodName) { + std::string className = classOrQualifiedMethodName; + if (startsWith(className, "&")) { + std::size_t lastColons = className.rfind("::"); + std::size_t penultimateColons = className.rfind("::", lastColons - 1); + if (penultimateColons == std::string::npos) + penultimateColons = 1; + className = + className.substr(penultimateColons, lastColons - penultimateColons); + } + return className; +} - void registerTestCase - ( ITestCase* testCase, - char const* classOrQualifiedMethodName, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ) { +void registerTestCase(ITestCase *testCase, + char const *classOrQualifiedMethodName, + NameAndDesc const &nameAndDesc, + SourceLineInfo const &lineInfo) { - getMutableRegistryHub().registerTest - ( makeTestCase - ( testCase, - extractClassName( classOrQualifiedMethodName ), - nameAndDesc.name, - nameAndDesc.description, - lineInfo ) ); - } - void registerTestCaseFunction - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ) { - registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo ); - } + getMutableRegistryHub().registerTest( + makeTestCase(testCase, extractClassName(classOrQualifiedMethodName), + nameAndDesc.name, nameAndDesc.description, lineInfo)); +} +void registerTestCaseFunction(TestFunction function, + SourceLineInfo const &lineInfo, + NameAndDesc const &nameAndDesc) { + registerTestCase(new FreeFunctionTestCase(function), "", nameAndDesc, + lineInfo); +} - /////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// - AutoReg::AutoReg - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ) { - registerTestCaseFunction( function, lineInfo, nameAndDesc ); - } +AutoReg::AutoReg(TestFunction function, SourceLineInfo const &lineInfo, + NameAndDesc const &nameAndDesc) { + registerTestCaseFunction(function, lineInfo, nameAndDesc); +} - AutoReg::~AutoReg() {} +AutoReg::~AutoReg() {} } // end namespace Catch @@ -6598,38 +6689,40 @@ namespace Catch { namespace Catch { - class ReporterRegistry : public IReporterRegistry { - - public: - - virtual ~ReporterRegistry() CATCH_OVERRIDE {} - - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const CATCH_OVERRIDE { - FactoryMap::const_iterator it = m_factories.find( name ); - if( it == m_factories.end() ) - return CATCH_NULL; - return it->second->create( ReporterConfig( config ) ); - } - - void registerReporter( std::string const& name, Ptr const& factory ) { - m_factories.insert( std::make_pair( name, factory ) ); - } - void registerListener( Ptr const& factory ) { - m_listeners.push_back( factory ); - } +class ReporterRegistry : public IReporterRegistry { - virtual FactoryMap const& getFactories() const CATCH_OVERRIDE { - return m_factories; - } - virtual Listeners const& getListeners() const CATCH_OVERRIDE { - return m_listeners; - } +public: + virtual ~ReporterRegistry() CATCH_OVERRIDE {} + + virtual IStreamingReporter * + create(std::string const &name, + Ptr const &config) const CATCH_OVERRIDE { + FactoryMap::const_iterator it = m_factories.find(name); + if (it == m_factories.end()) + return CATCH_NULL; + return it->second->create(ReporterConfig(config)); + } + + void registerReporter(std::string const &name, + Ptr const &factory) { + m_factories.insert(std::make_pair(name, factory)); + } + void registerListener(Ptr const &factory) { + m_listeners.push_back(factory); + } + + virtual FactoryMap const &getFactories() const CATCH_OVERRIDE { + return m_factories; + } + virtual Listeners const &getListeners() const CATCH_OVERRIDE { + return m_listeners; + } - private: - FactoryMap m_factories; - Listeners m_listeners; - }; -} +private: + FactoryMap m_factories; + Listeners m_listeners; +}; +} // namespace Catch // #included from: catch_exception_translator_registry.hpp #define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED @@ -6640,124 +6733,119 @@ namespace Catch { namespace Catch { - class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { - public: - ~ExceptionTranslatorRegistry() { - deleteAll( m_translators ); - } +class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { +public: + ~ExceptionTranslatorRegistry() { deleteAll(m_translators); } - virtual void registerTranslator( const IExceptionTranslator* translator ) { - m_translators.push_back( translator ); - } + virtual void registerTranslator(const IExceptionTranslator *translator) { + m_translators.push_back(translator); + } - virtual std::string translateActiveException() const { - try { + virtual std::string translateActiveException() const { + try { #ifdef __OBJC__ - // In Objective-C try objective-c exceptions first - @try { - return tryTranslators(); - } - @catch (NSException *exception) { - return Catch::toString( [exception description] ); - } + // In Objective-C try objective-c exceptions first + @try { + return tryTranslators(); + } @catch (NSException *exception) { + return Catch::toString([exception description]); + } #else - return tryTranslators(); + return tryTranslators(); #endif - } - catch( TestFailureException& ) { - throw; - } - catch( std::exception& ex ) { - return ex.what(); - } - catch( std::string& msg ) { - return msg; - } - catch( const char* msg ) { - return msg; - } - catch(...) { - return "Unknown exception"; - } - } - - std::string tryTranslators() const { - if( m_translators.empty() ) - throw; - else - return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() ); - } + } catch (TestFailureException &) { + throw; + } catch (std::exception &ex) { + return ex.what(); + } catch (std::string &msg) { + return msg; + } catch (const char *msg) { + return msg; + } catch (...) { + return "Unknown exception"; + } + } + + std::string tryTranslators() const { + if (m_translators.empty()) + throw; + else + return m_translators[0]->translate(m_translators.begin() + 1, + m_translators.end()); + } - private: - std::vector m_translators; - }; -} +private: + std::vector m_translators; +}; +} // namespace Catch namespace Catch { - namespace { - - class RegistryHub : public IRegistryHub, public IMutableRegistryHub { - - RegistryHub( RegistryHub const& ); - void operator=( RegistryHub const& ); - - public: // IRegistryHub - RegistryHub() { - } - virtual IReporterRegistry const& getReporterRegistry() const CATCH_OVERRIDE { - return m_reporterRegistry; - } - virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_OVERRIDE { - return m_testCaseRegistry; - } - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE { - return m_exceptionTranslatorRegistry; - } +namespace { - public: // IMutableRegistryHub - virtual void registerReporter( std::string const& name, Ptr const& factory ) CATCH_OVERRIDE { - m_reporterRegistry.registerReporter( name, factory ); - } - virtual void registerListener( Ptr const& factory ) CATCH_OVERRIDE { - m_reporterRegistry.registerListener( factory ); - } - virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE { - m_testCaseRegistry.registerTest( testInfo ); - } - virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE { - m_exceptionTranslatorRegistry.registerTranslator( translator ); - } +class RegistryHub : public IRegistryHub, public IMutableRegistryHub { + + RegistryHub(RegistryHub const &); + void operator=(RegistryHub const &); + +public: // IRegistryHub + RegistryHub() {} + virtual IReporterRegistry const &getReporterRegistry() const CATCH_OVERRIDE { + return m_reporterRegistry; + } + virtual ITestCaseRegistry const &getTestCaseRegistry() const CATCH_OVERRIDE { + return m_testCaseRegistry; + } + virtual IExceptionTranslatorRegistry & + getExceptionTranslatorRegistry() CATCH_OVERRIDE { + return m_exceptionTranslatorRegistry; + } + +public: // IMutableRegistryHub + virtual void + registerReporter(std::string const &name, + Ptr const &factory) CATCH_OVERRIDE { + m_reporterRegistry.registerReporter(name, factory); + } + virtual void + registerListener(Ptr const &factory) CATCH_OVERRIDE { + m_reporterRegistry.registerListener(factory); + } + virtual void registerTest(TestCase const &testInfo) CATCH_OVERRIDE { + m_testCaseRegistry.registerTest(testInfo); + } + virtual void + registerTranslator(const IExceptionTranslator *translator) CATCH_OVERRIDE { + m_exceptionTranslatorRegistry.registerTranslator(translator); + } - private: - TestRegistry m_testCaseRegistry; - ReporterRegistry m_reporterRegistry; - ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; - }; - - // Single, global, instance - inline RegistryHub*& getTheRegistryHub() { - static RegistryHub* theRegistryHub = CATCH_NULL; - if( !theRegistryHub ) - theRegistryHub = new RegistryHub(); - return theRegistryHub; - } - } +private: + TestRegistry m_testCaseRegistry; + ReporterRegistry m_reporterRegistry; + ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; +}; - IRegistryHub& getRegistryHub() { - return *getTheRegistryHub(); - } - IMutableRegistryHub& getMutableRegistryHub() { - return *getTheRegistryHub(); - } - void cleanUp() { - delete getTheRegistryHub(); - getTheRegistryHub() = CATCH_NULL; - cleanUpContext(); - } - std::string translateActiveException() { - return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); - } +// Single, global, instance +inline RegistryHub *&getTheRegistryHub() { + static RegistryHub *theRegistryHub = CATCH_NULL; + if (!theRegistryHub) + theRegistryHub = new RegistryHub(); + return theRegistryHub; +} +} // namespace + +IRegistryHub &getRegistryHub() { return *getTheRegistryHub(); } +IMutableRegistryHub &getMutableRegistryHub() { return *getTheRegistryHub(); } +void cleanUp() { + delete getTheRegistryHub(); + getTheRegistryHub() = CATCH_NULL; + cleanUpContext(); +} +std::string translateActiveException() { + return getRegistryHub() + .getExceptionTranslatorRegistry() + .translateActiveException(); +} } // end namespace Catch @@ -6768,17 +6856,17 @@ namespace Catch { namespace Catch { - NotImplementedException::NotImplementedException( SourceLineInfo const& lineInfo ) - : m_lineInfo( lineInfo ) { - std::ostringstream oss; - oss << lineInfo << ": function "; - oss << "not implemented"; - m_what = oss.str(); - } +NotImplementedException::NotImplementedException(SourceLineInfo const &lineInfo) + : m_lineInfo(lineInfo) { + std::ostringstream oss; + oss << lineInfo << ": function "; + oss << "not implemented"; + m_what = oss.str(); +} - const char* NotImplementedException::what() const CATCH_NOEXCEPT { - return m_what.c_str(); - } +const char *NotImplementedException::what() const CATCH_NOEXCEPT { + return m_what.c_str(); +} } // end namespace Catch @@ -6788,219 +6876,196 @@ namespace Catch { // #included from: catch_stream.hpp #define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED -#include #include #include +#include namespace Catch { - template - class StreamBufImpl : public StreamBufBase { - char data[bufferSize]; - WriterF m_writer; - - public: - StreamBufImpl() { - setp( data, data + sizeof(data) ); - } - - ~StreamBufImpl() CATCH_NOEXCEPT { - sync(); - } +template +class StreamBufImpl : public StreamBufBase { + char data[bufferSize]; + WriterF m_writer; - private: - int overflow( int c ) { - sync(); +public: + StreamBufImpl() { setp(data, data + sizeof(data)); } - if( c != EOF ) { - if( pbase() == epptr() ) - m_writer( std::string( 1, static_cast( c ) ) ); - else - sputc( static_cast( c ) ); - } - return 0; - } + ~StreamBufImpl() CATCH_NOEXCEPT { sync(); } - int sync() { - if( pbase() != pptr() ) { - m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); - setp( pbase(), epptr() ); - } - return 0; - } - }; +private: + int overflow(int c) { + sync(); + + if (c != EOF) { + if (pbase() == epptr()) + m_writer(std::string(1, static_cast(c))); + else + sputc(static_cast(c)); + } + return 0; + } + + int sync() { + if (pbase() != pptr()) { + m_writer(std::string( + pbase(), static_cast(pptr() - pbase()))); + setp(pbase(), epptr()); + } + return 0; + } +}; - /////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// - FileStream::FileStream( std::string const& filename ) { - m_ofs.open( filename.c_str() ); - if( m_ofs.fail() ) { - std::ostringstream oss; - oss << "Unable to open file: '" << filename << "'"; - throw std::domain_error( oss.str() ); - } - } +FileStream::FileStream(std::string const &filename) { + m_ofs.open(filename.c_str()); + if (m_ofs.fail()) { + std::ostringstream oss; + oss << "Unable to open file: '" << filename << "'"; + throw std::domain_error(oss.str()); + } +} - std::ostream& FileStream::stream() const { - return m_ofs; - } +std::ostream &FileStream::stream() const { return m_ofs; } - struct OutputDebugWriter { +struct OutputDebugWriter { - void operator()( std::string const&str ) { - writeToDebugConsole( str ); - } - }; + void operator()(std::string const &str) { writeToDebugConsole(str); } +}; - DebugOutStream::DebugOutStream() - : m_streamBuf( new StreamBufImpl() ), - m_os( m_streamBuf.get() ) - {} +DebugOutStream::DebugOutStream() + : m_streamBuf(new StreamBufImpl()), + m_os(m_streamBuf.get()) {} - std::ostream& DebugOutStream::stream() const { - return m_os; - } +std::ostream &DebugOutStream::stream() const { return m_os; } - // Store the streambuf from cout up-front because - // cout may get redirected when running tests - CoutStream::CoutStream() - : m_os( Catch::cout().rdbuf() ) - {} +// Store the streambuf from cout up-front because +// cout may get redirected when running tests +CoutStream::CoutStream() : m_os(Catch::cout().rdbuf()) {} - std::ostream& CoutStream::stream() const { - return m_os; - } +std::ostream &CoutStream::stream() const { return m_os; } -#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions - std::ostream& cout() { - return std::cout; - } - std::ostream& cerr() { - return std::cerr; - } +#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these + // functions +std::ostream &cout() { return std::cout; } +std::ostream &cerr() { return std::cerr; } #endif -} +} // namespace Catch namespace Catch { - class Context : public IMutableContext { - - Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {} - Context( Context const& ); - void operator=( Context const& ); - - public: // IContext - virtual IResultCapture* getResultCapture() { - return m_resultCapture; - } - virtual IRunner* getRunner() { - return m_runner; - } - virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) { - return getGeneratorsForCurrentTest() - .getGeneratorInfo( fileInfo, totalSize ) - .getCurrentIndex(); - } - virtual bool advanceGeneratorsForCurrentTest() { - IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); - return generators && generators->moveNext(); - } - - virtual Ptr getConfig() const { - return m_config; - } - - public: // IMutableContext - virtual void setResultCapture( IResultCapture* resultCapture ) { - m_resultCapture = resultCapture; - } - virtual void setRunner( IRunner* runner ) { - m_runner = runner; - } - virtual void setConfig( Ptr const& config ) { - m_config = config; - } - - friend IMutableContext& getCurrentMutableContext(); +class Context : public IMutableContext { + + Context() + : m_config(CATCH_NULL), m_runner(CATCH_NULL), + m_resultCapture(CATCH_NULL) {} + Context(Context const &); + void operator=(Context const &); + +public: // IContext + virtual IResultCapture *getResultCapture() { return m_resultCapture; } + virtual IRunner *getRunner() { return m_runner; } + virtual size_t getGeneratorIndex(std::string const &fileInfo, + size_t totalSize) { + return getGeneratorsForCurrentTest() + .getGeneratorInfo(fileInfo, totalSize) + .getCurrentIndex(); + } + virtual bool advanceGeneratorsForCurrentTest() { + IGeneratorsForTest *generators = findGeneratorsForCurrentTest(); + return generators && generators->moveNext(); + } + + virtual Ptr getConfig() const { return m_config; } + +public: // IMutableContext + virtual void setResultCapture(IResultCapture *resultCapture) { + m_resultCapture = resultCapture; + } + virtual void setRunner(IRunner *runner) { m_runner = runner; } + virtual void setConfig(Ptr const &config) { + m_config = config; + } + + friend IMutableContext &getCurrentMutableContext(); - private: - IGeneratorsForTest* findGeneratorsForCurrentTest() { - std::string testName = getResultCapture()->getCurrentTestName(); +private: + IGeneratorsForTest *findGeneratorsForCurrentTest() { + std::string testName = getResultCapture()->getCurrentTestName(); - std::map::const_iterator it = - m_generatorsByTestName.find( testName ); - return it != m_generatorsByTestName.end() - ? it->second - : CATCH_NULL; - } + std::map::const_iterator it = + m_generatorsByTestName.find(testName); + return it != m_generatorsByTestName.end() ? it->second : CATCH_NULL; + } - IGeneratorsForTest& getGeneratorsForCurrentTest() { - IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); - if( !generators ) { - std::string testName = getResultCapture()->getCurrentTestName(); - generators = createGeneratorsForTest(); - m_generatorsByTestName.insert( std::make_pair( testName, generators ) ); - } - return *generators; - } + IGeneratorsForTest &getGeneratorsForCurrentTest() { + IGeneratorsForTest *generators = findGeneratorsForCurrentTest(); + if (!generators) { + std::string testName = getResultCapture()->getCurrentTestName(); + generators = createGeneratorsForTest(); + m_generatorsByTestName.insert(std::make_pair(testName, generators)); + } + return *generators; + } - private: - Ptr m_config; - IRunner* m_runner; - IResultCapture* m_resultCapture; - std::map m_generatorsByTestName; - }; +private: + Ptr m_config; + IRunner *m_runner; + IResultCapture *m_resultCapture; + std::map m_generatorsByTestName; +}; - namespace { - Context* currentContext = CATCH_NULL; - } - IMutableContext& getCurrentMutableContext() { - if( !currentContext ) - currentContext = new Context(); - return *currentContext; - } - IContext& getCurrentContext() { - return getCurrentMutableContext(); - } +namespace { +Context *currentContext = CATCH_NULL; +} +IMutableContext &getCurrentMutableContext() { + if (!currentContext) + currentContext = new Context(); + return *currentContext; +} +IContext &getCurrentContext() { return getCurrentMutableContext(); } - void cleanUpContext() { - delete currentContext; - currentContext = CATCH_NULL; - } +void cleanUpContext() { + delete currentContext; + currentContext = CATCH_NULL; } +} // namespace Catch // #included from: catch_console_colour_impl.hpp #define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED namespace Catch { - namespace { +namespace { - struct IColourImpl { - virtual ~IColourImpl() {} - virtual void use( Colour::Code _colourCode ) = 0; - }; +struct IColourImpl { + virtual ~IColourImpl() {} + virtual void use(Colour::Code _colourCode) = 0; +}; - struct NoColourImpl : IColourImpl { - void use( Colour::Code ) {} +struct NoColourImpl : IColourImpl { + void use(Colour::Code) {} - static IColourImpl* instance() { - static NoColourImpl s_instance; - return &s_instance; - } - }; + static IColourImpl *instance() { + static NoColourImpl s_instance; + return &s_instance; + } +}; - } // anon namespace +} // namespace } // namespace Catch -#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI ) -# ifdef CATCH_PLATFORM_WINDOWS -# define CATCH_CONFIG_COLOUR_WINDOWS -# else -# define CATCH_CONFIG_COLOUR_ANSI -# endif +#if !defined(CATCH_CONFIG_COLOUR_NONE) && \ + !defined(CATCH_CONFIG_COLOUR_WINDOWS) && \ + !defined(CATCH_CONFIG_COLOUR_ANSI) +#ifdef CATCH_PLATFORM_WINDOWS +#define CATCH_CONFIG_COLOUR_WINDOWS +#else +#define CATCH_CONFIG_COLOUR_ANSI +#endif #endif -#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// +#if defined( \ + CATCH_CONFIG_COLOUR_WINDOWS) ///////////////////////////////////////// #ifndef NOMINMAX #define NOMINMAX @@ -7015,129 +7080,154 @@ namespace Catch { namespace Catch { namespace { - class Win32ColourImpl : public IColourImpl { - public: - Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) - { - CONSOLE_SCREEN_BUFFER_INFO csbiInfo; - GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); - originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY ); - originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY ); - } +class Win32ColourImpl : public IColourImpl { +public: + Win32ColourImpl() : stdoutHandle(GetStdHandle(STD_OUTPUT_HANDLE)) { + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + GetConsoleScreenBufferInfo(stdoutHandle, &csbiInfo); + originalForegroundAttributes = + csbiInfo.wAttributes & ~(BACKGROUND_GREEN | BACKGROUND_RED | + BACKGROUND_BLUE | BACKGROUND_INTENSITY); + originalBackgroundAttributes = + csbiInfo.wAttributes & ~(FOREGROUND_GREEN | FOREGROUND_RED | + FOREGROUND_BLUE | FOREGROUND_INTENSITY); + } + + virtual void use(Colour::Code _colourCode) { + switch (_colourCode) { + case Colour::None: + return setTextAttribute(originalForegroundAttributes); + case Colour::White: + return setTextAttribute(FOREGROUND_GREEN | FOREGROUND_RED | + FOREGROUND_BLUE); + case Colour::Red: + return setTextAttribute(FOREGROUND_RED); + case Colour::Green: + return setTextAttribute(FOREGROUND_GREEN); + case Colour::Blue: + return setTextAttribute(FOREGROUND_BLUE); + case Colour::Cyan: + return setTextAttribute(FOREGROUND_BLUE | FOREGROUND_GREEN); + case Colour::Yellow: + return setTextAttribute(FOREGROUND_RED | FOREGROUND_GREEN); + case Colour::Grey: + return setTextAttribute(0); + + case Colour::LightGrey: + return setTextAttribute(FOREGROUND_INTENSITY); + case Colour::BrightRed: + return setTextAttribute(FOREGROUND_INTENSITY | FOREGROUND_RED); + case Colour::BrightGreen: + return setTextAttribute(FOREGROUND_INTENSITY | FOREGROUND_GREEN); + case Colour::BrightWhite: + return setTextAttribute(FOREGROUND_INTENSITY | FOREGROUND_GREEN | + FOREGROUND_RED | FOREGROUND_BLUE); + + case Colour::Bright: + throw std::logic_error("not a colour"); + } + } - virtual void use( Colour::Code _colourCode ) { - switch( _colourCode ) { - case Colour::None: return setTextAttribute( originalForegroundAttributes ); - case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); - case Colour::Red: return setTextAttribute( FOREGROUND_RED ); - case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); - case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); - case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); - case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); - case Colour::Grey: return setTextAttribute( 0 ); - - case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); - case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); - case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); - case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); - - case Colour::Bright: throw std::logic_error( "not a colour" ); - } - } +private: + void setTextAttribute(WORD _textAttribute) { + SetConsoleTextAttribute(stdoutHandle, + _textAttribute | originalBackgroundAttributes); + } + HANDLE stdoutHandle; + WORD originalForegroundAttributes; + WORD originalBackgroundAttributes; +}; - private: - void setTextAttribute( WORD _textAttribute ) { - SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes ); - } - HANDLE stdoutHandle; - WORD originalForegroundAttributes; - WORD originalBackgroundAttributes; - }; - - IColourImpl* platformColourInstance() { - static Win32ColourImpl s_instance; - - Ptr config = getCurrentContext().getConfig(); - UseColour::YesOrNo colourMode = config - ? config->useColour() - : UseColour::Auto; - if( colourMode == UseColour::Auto ) - colourMode = !isDebuggerActive() - ? UseColour::Yes - : UseColour::No; - return colourMode == UseColour::Yes - ? &s_instance - : NoColourImpl::instance(); - } - -} // end anon namespace +IColourImpl *platformColourInstance() { + static Win32ColourImpl s_instance; + + Ptr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = + config ? config->useColour() : UseColour::Auto; + if (colourMode == UseColour::Auto) + colourMode = !isDebuggerActive() ? UseColour::Yes : UseColour::No; + return colourMode == UseColour::Yes ? &s_instance : NoColourImpl::instance(); +} + +} // namespace } // end namespace Catch -#elif defined( CATCH_CONFIG_COLOUR_ANSI ) ////////////////////////////////////// +#elif defined(CATCH_CONFIG_COLOUR_ANSI) ////////////////////////////////////// #include namespace Catch { namespace { - // use POSIX/ ANSI console terminal codes - // Thanks to Adam Strzelecki for original contribution - // (http://github.com/nanoant) - // https://github.com/philsquared/Catch/pull/131 - class PosixColourImpl : public IColourImpl { - public: - virtual void use( Colour::Code _colourCode ) { - switch( _colourCode ) { - case Colour::None: - case Colour::White: return setColour( "[0m" ); - case Colour::Red: return setColour( "[0;31m" ); - case Colour::Green: return setColour( "[0;32m" ); - case Colour::Blue: return setColour( "[0:34m" ); - case Colour::Cyan: return setColour( "[0;36m" ); - case Colour::Yellow: return setColour( "[0;33m" ); - case Colour::Grey: return setColour( "[1;30m" ); - - case Colour::LightGrey: return setColour( "[0;37m" ); - case Colour::BrightRed: return setColour( "[1;31m" ); - case Colour::BrightGreen: return setColour( "[1;32m" ); - case Colour::BrightWhite: return setColour( "[1;37m" ); - - case Colour::Bright: throw std::logic_error( "not a colour" ); - } - } - static IColourImpl* instance() { - static PosixColourImpl s_instance; - return &s_instance; - } +// use POSIX/ ANSI console terminal codes +// Thanks to Adam Strzelecki for original contribution +// (http://github.com/nanoant) +// https://github.com/philsquared/Catch/pull/131 +class PosixColourImpl : public IColourImpl { +public: + virtual void use(Colour::Code _colourCode) { + switch (_colourCode) { + case Colour::None: + case Colour::White: + return setColour("[0m"); + case Colour::Red: + return setColour("[0;31m"); + case Colour::Green: + return setColour("[0;32m"); + case Colour::Blue: + return setColour("[0:34m"); + case Colour::Cyan: + return setColour("[0;36m"); + case Colour::Yellow: + return setColour("[0;33m"); + case Colour::Grey: + return setColour("[1;30m"); + + case Colour::LightGrey: + return setColour("[0;37m"); + case Colour::BrightRed: + return setColour("[1;31m"); + case Colour::BrightGreen: + return setColour("[1;32m"); + case Colour::BrightWhite: + return setColour("[1;37m"); + + case Colour::Bright: + throw std::logic_error("not a colour"); + } + } + static IColourImpl *instance() { + static PosixColourImpl s_instance; + return &s_instance; + } - private: - void setColour( const char* _escapeCode ) { - Catch::cout() << '\033' << _escapeCode; - } - }; - - IColourImpl* platformColourInstance() { - Ptr config = getCurrentContext().getConfig(); - UseColour::YesOrNo colourMode = config - ? config->useColour() - : UseColour::Auto; - if( colourMode == UseColour::Auto ) - colourMode = (!isDebuggerActive() && isatty(STDOUT_FILENO) ) - ? UseColour::Yes - : UseColour::No; - return colourMode == UseColour::Yes - ? PosixColourImpl::instance() - : NoColourImpl::instance(); - } - -} // end anon namespace +private: + void setColour(const char *_escapeCode) { + Catch::cout() << '\033' << _escapeCode; + } +}; + +IColourImpl *platformColourInstance() { + Ptr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = + config ? config->useColour() : UseColour::Auto; + if (colourMode == UseColour::Auto) + colourMode = (!isDebuggerActive() && isatty(STDOUT_FILENO)) ? UseColour::Yes + : UseColour::No; + return colourMode == UseColour::Yes ? PosixColourImpl::instance() + : NoColourImpl::instance(); +} + +} // namespace } // end namespace Catch -#else // not Windows or ANSI /////////////////////////////////////////////// +#else // not Windows or ANSI /////////////////////////////////////////////// namespace Catch { - static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); } +static IColourImpl *platformColourInstance() { + return NoColourImpl::instance(); +} } // end namespace Catch @@ -7145,88 +7235,89 @@ namespace Catch { namespace Catch { - Colour::Colour( Code _colourCode ) : m_moved( false ) { use( _colourCode ); } - Colour::Colour( Colour const& _other ) : m_moved( false ) { const_cast( _other ).m_moved = true; } - Colour::~Colour(){ if( !m_moved ) use( None ); } +Colour::Colour(Code _colourCode) : m_moved(false) { use(_colourCode); } +Colour::Colour(Colour const &_other) : m_moved(false) { + const_cast(_other).m_moved = true; +} +Colour::~Colour() { + if (!m_moved) + use(None); +} - void Colour::use( Code _colourCode ) { - static IColourImpl* impl = platformColourInstance(); - impl->use( _colourCode ); - } +void Colour::use(Code _colourCode) { + static IColourImpl *impl = platformColourInstance(); + impl->use(_colourCode); +} } // end namespace Catch // #included from: catch_generators_impl.hpp #define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED -#include -#include #include +#include +#include namespace Catch { - struct GeneratorInfo : IGeneratorInfo { - - GeneratorInfo( std::size_t size ) - : m_size( size ), - m_currentIndex( 0 ) - {} +struct GeneratorInfo : IGeneratorInfo { - bool moveNext() { - if( ++m_currentIndex == m_size ) { - m_currentIndex = 0; - return false; - } - return true; - } - - std::size_t getCurrentIndex() const { - return m_currentIndex; - } + GeneratorInfo(std::size_t size) : m_size(size), m_currentIndex(0) {} - std::size_t m_size; - std::size_t m_currentIndex; - }; + bool moveNext() { + if (++m_currentIndex == m_size) { + m_currentIndex = 0; + return false; + } + return true; + } - /////////////////////////////////////////////////////////////////////////// + std::size_t getCurrentIndex() const { return m_currentIndex; } - class GeneratorsForTest : public IGeneratorsForTest { + std::size_t m_size; + std::size_t m_currentIndex; +}; - public: - ~GeneratorsForTest() { - deleteAll( m_generatorsInOrder ); - } +/////////////////////////////////////////////////////////////////////////// - IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) { - std::map::const_iterator it = m_generatorsByName.find( fileInfo ); - if( it == m_generatorsByName.end() ) { - IGeneratorInfo* info = new GeneratorInfo( size ); - m_generatorsByName.insert( std::make_pair( fileInfo, info ) ); - m_generatorsInOrder.push_back( info ); - return *info; - } - return *it->second; - } +class GeneratorsForTest : public IGeneratorsForTest { - bool moveNext() { - std::vector::const_iterator it = m_generatorsInOrder.begin(); - std::vector::const_iterator itEnd = m_generatorsInOrder.end(); - for(; it != itEnd; ++it ) { - if( (*it)->moveNext() ) - return true; - } - return false; - } +public: + ~GeneratorsForTest() { deleteAll(m_generatorsInOrder); } + + IGeneratorInfo &getGeneratorInfo(std::string const &fileInfo, + std::size_t size) { + std::map::const_iterator it = + m_generatorsByName.find(fileInfo); + if (it == m_generatorsByName.end()) { + IGeneratorInfo *info = new GeneratorInfo(size); + m_generatorsByName.insert(std::make_pair(fileInfo, info)); + m_generatorsInOrder.push_back(info); + return *info; + } + return *it->second; + } + + bool moveNext() { + std::vector::const_iterator it = + m_generatorsInOrder.begin(); + std::vector::const_iterator itEnd = + m_generatorsInOrder.end(); + for (; it != itEnd; ++it) { + if ((*it)->moveNext()) + return true; + } + return false; + } - private: - std::map m_generatorsByName; - std::vector m_generatorsInOrder; - }; +private: + std::map m_generatorsByName; + std::vector m_generatorsInOrder; +}; - IGeneratorsForTest* createGeneratorsForTest() - { - return new GeneratorsForTest(); - } +IGeneratorsForTest *createGeneratorsForTest() { + return new GeneratorsForTest(); +} } // end namespace Catch @@ -7235,78 +7326,74 @@ namespace Catch { namespace Catch { - AssertionInfo::AssertionInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - std::string const& _capturedExpression, - ResultDisposition::Flags _resultDisposition ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - capturedExpression( _capturedExpression ), - resultDisposition( _resultDisposition ) - {} +AssertionInfo::AssertionInfo(std::string const &_macroName, + SourceLineInfo const &_lineInfo, + std::string const &_capturedExpression, + ResultDisposition::Flags _resultDisposition) + : macroName(_macroName), lineInfo(_lineInfo), + capturedExpression(_capturedExpression), + resultDisposition(_resultDisposition) {} - AssertionResult::AssertionResult() {} +AssertionResult::AssertionResult() {} - AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) - : m_info( info ), - m_resultData( data ) - {} +AssertionResult::AssertionResult(AssertionInfo const &info, + AssertionResultData const &data) + : m_info(info), m_resultData(data) {} - AssertionResult::~AssertionResult() {} +AssertionResult::~AssertionResult() {} - // Result was a success - bool AssertionResult::succeeded() const { - return Catch::isOk( m_resultData.resultType ); - } +// Result was a success +bool AssertionResult::succeeded() const { + return Catch::isOk(m_resultData.resultType); +} - // Result was a success, or failure is suppressed - bool AssertionResult::isOk() const { - return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); - } +// Result was a success, or failure is suppressed +bool AssertionResult::isOk() const { + return Catch::isOk(m_resultData.resultType) || + shouldSuppressFailure(m_info.resultDisposition); +} - ResultWas::OfType AssertionResult::getResultType() const { - return m_resultData.resultType; - } +ResultWas::OfType AssertionResult::getResultType() const { + return m_resultData.resultType; +} - bool AssertionResult::hasExpression() const { - return !m_info.capturedExpression.empty(); - } +bool AssertionResult::hasExpression() const { + return !m_info.capturedExpression.empty(); +} - bool AssertionResult::hasMessage() const { - return !m_resultData.message.empty(); - } +bool AssertionResult::hasMessage() const { + return !m_resultData.message.empty(); +} - std::string AssertionResult::getExpression() const { - if( isFalseTest( m_info.resultDisposition ) ) - return "!" + m_info.capturedExpression; - else - return m_info.capturedExpression; - } - std::string AssertionResult::getExpressionInMacro() const { - if( m_info.macroName.empty() ) - return m_info.capturedExpression; - else - return m_info.macroName + "( " + m_info.capturedExpression + " )"; - } +std::string AssertionResult::getExpression() const { + if (isFalseTest(m_info.resultDisposition)) + return "!" + m_info.capturedExpression; + else + return m_info.capturedExpression; +} +std::string AssertionResult::getExpressionInMacro() const { + if (m_info.macroName.empty()) + return m_info.capturedExpression; + else + return m_info.macroName + "( " + m_info.capturedExpression + " )"; +} - bool AssertionResult::hasExpandedExpression() const { - return hasExpression() && getExpandedExpression() != getExpression(); - } +bool AssertionResult::hasExpandedExpression() const { + return hasExpression() && getExpandedExpression() != getExpression(); +} - std::string AssertionResult::getExpandedExpression() const { - return m_resultData.reconstructedExpression; - } +std::string AssertionResult::getExpandedExpression() const { + return m_resultData.reconstructedExpression; +} - std::string AssertionResult::getMessage() const { - return m_resultData.message; - } - SourceLineInfo AssertionResult::getSourceInfo() const { - return m_info.lineInfo; - } +std::string AssertionResult::getMessage() const { return m_resultData.message; } +SourceLineInfo AssertionResult::getSourceInfo() const { + return m_info.lineInfo; +} - std::string AssertionResult::getTestMacroName() const { - return m_info.macroName; - } +std::string AssertionResult::getTestMacroName() const { + return m_info.macroName; +} } // end namespace Catch @@ -7315,185 +7402,163 @@ namespace Catch { namespace Catch { - inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) { - if( startsWith( tag, "." ) || - tag == "hide" || - tag == "!hide" ) - return TestCaseInfo::IsHidden; - else if( tag == "!throws" ) - return TestCaseInfo::Throws; - else if( tag == "!shouldfail" ) - return TestCaseInfo::ShouldFail; - else if( tag == "!mayfail" ) - return TestCaseInfo::MayFail; - else - return TestCaseInfo::None; - } - inline bool isReservedTag( std::string const& tag ) { - return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( tag[0] ); - } - inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { - if( isReservedTag( tag ) ) { - { - Colour colourGuard( Colour::Red ); - Catch::cerr() - << "Tag name [" << tag << "] not allowed.\n" - << "Tag names starting with non alpha-numeric characters are reserved\n"; - } - { - Colour colourGuard( Colour::FileName ); - Catch::cerr() << _lineInfo << std::endl; - } - exit(1); - } - } - - TestCase makeTestCase( ITestCase* _testCase, - std::string const& _className, - std::string const& _name, - std::string const& _descOrTags, - SourceLineInfo const& _lineInfo ) +inline TestCaseInfo::SpecialProperties parseSpecialTag(std::string const &tag) { + if (startsWith(tag, ".") || tag == "hide" || tag == "!hide") + return TestCaseInfo::IsHidden; + else if (tag == "!throws") + return TestCaseInfo::Throws; + else if (tag == "!shouldfail") + return TestCaseInfo::ShouldFail; + else if (tag == "!mayfail") + return TestCaseInfo::MayFail; + else + return TestCaseInfo::None; +} +inline bool isReservedTag(std::string const &tag) { + return parseSpecialTag(tag) == TestCaseInfo::None && tag.size() > 0 && + !isalnum(tag[0]); +} +inline void enforceNotReservedTag(std::string const &tag, + SourceLineInfo const &_lineInfo) { + if (isReservedTag(tag)) { { - bool isHidden( startsWith( _name, "./" ) ); // Legacy support - - // Parse out tags - std::set tags; - std::string desc, tag; - bool inTag = false; - for( std::size_t i = 0; i < _descOrTags.size(); ++i ) { - char c = _descOrTags[i]; - if( !inTag ) { - if( c == '[' ) - inTag = true; - else - desc += c; - } - else { - if( c == ']' ) { - TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag ); - if( prop == TestCaseInfo::IsHidden ) - isHidden = true; - else if( prop == TestCaseInfo::None ) - enforceNotReservedTag( tag, _lineInfo ); - - tags.insert( tag ); - tag.clear(); - inTag = false; - } - else - tag += c; - } - } - if( isHidden ) { - tags.insert( "hide" ); - tags.insert( "." ); - } - - TestCaseInfo info( _name, _className, desc, tags, _lineInfo ); - return TestCase( _testCase, info ); + Colour colourGuard(Colour::Red); + Catch::cerr() << "Tag name [" << tag << "] not allowed.\n" + << "Tag names starting with non alpha-numeric characters " + "are reserved\n"; } - - void setTags( TestCaseInfo& testCaseInfo, std::set const& tags ) - { - testCaseInfo.tags = tags; - testCaseInfo.lcaseTags.clear(); - - std::ostringstream oss; - for( std::set::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) { - oss << "[" << *it << "]"; - std::string lcaseTag = toLower( *it ); - testCaseInfo.properties = static_cast( testCaseInfo.properties | parseSpecialTag( lcaseTag ) ); - testCaseInfo.lcaseTags.insert( lcaseTag ); - } - testCaseInfo.tagsAsString = oss.str(); - } - - TestCaseInfo::TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - SourceLineInfo const& _lineInfo ) - : name( _name ), - className( _className ), - description( _description ), - lineInfo( _lineInfo ), - properties( None ) { - setTags( *this, _tags ); + Colour colourGuard(Colour::FileName); + Catch::cerr() << _lineInfo << std::endl; } + exit(1); + } +} - TestCaseInfo::TestCaseInfo( TestCaseInfo const& other ) - : name( other.name ), - className( other.className ), - description( other.description ), - tags( other.tags ), - lcaseTags( other.lcaseTags ), - tagsAsString( other.tagsAsString ), - lineInfo( other.lineInfo ), - properties( other.properties ) - {} +TestCase makeTestCase(ITestCase *_testCase, std::string const &_className, + std::string const &_name, std::string const &_descOrTags, + SourceLineInfo const &_lineInfo) { + bool isHidden(startsWith(_name, "./")); // Legacy support + + // Parse out tags + std::set tags; + std::string desc, tag; + bool inTag = false; + for (std::size_t i = 0; i < _descOrTags.size(); ++i) { + char c = _descOrTags[i]; + if (!inTag) { + if (c == '[') + inTag = true; + else + desc += c; + } else { + if (c == ']') { + TestCaseInfo::SpecialProperties prop = parseSpecialTag(tag); + if (prop == TestCaseInfo::IsHidden) + isHidden = true; + else if (prop == TestCaseInfo::None) + enforceNotReservedTag(tag, _lineInfo); + + tags.insert(tag); + tag.clear(); + inTag = false; + } else + tag += c; + } + } + if (isHidden) { + tags.insert("hide"); + tags.insert("."); + } + + TestCaseInfo info(_name, _className, desc, tags, _lineInfo); + return TestCase(_testCase, info); +} - bool TestCaseInfo::isHidden() const { - return ( properties & IsHidden ) != 0; - } - bool TestCaseInfo::throws() const { - return ( properties & Throws ) != 0; - } - bool TestCaseInfo::okToFail() const { - return ( properties & (ShouldFail | MayFail ) ) != 0; - } - bool TestCaseInfo::expectedToFail() const { - return ( properties & (ShouldFail ) ) != 0; - } +void setTags(TestCaseInfo &testCaseInfo, std::set const &tags) { + testCaseInfo.tags = tags; + testCaseInfo.lcaseTags.clear(); + + std::ostringstream oss; + for (std::set::const_iterator it = tags.begin(), + itEnd = tags.end(); + it != itEnd; ++it) { + oss << "[" << *it << "]"; + std::string lcaseTag = toLower(*it); + testCaseInfo.properties = static_cast( + testCaseInfo.properties | parseSpecialTag(lcaseTag)); + testCaseInfo.lcaseTags.insert(lcaseTag); + } + testCaseInfo.tagsAsString = oss.str(); +} - TestCase::TestCase( ITestCase* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {} +TestCaseInfo::TestCaseInfo(std::string const &_name, + std::string const &_className, + std::string const &_description, + std::set const &_tags, + SourceLineInfo const &_lineInfo) + : name(_name), className(_className), description(_description), + lineInfo(_lineInfo), properties(None) { + setTags(*this, _tags); +} - TestCase::TestCase( TestCase const& other ) - : TestCaseInfo( other ), - test( other.test ) - {} +TestCaseInfo::TestCaseInfo(TestCaseInfo const &other) + : name(other.name), className(other.className), + description(other.description), tags(other.tags), + lcaseTags(other.lcaseTags), tagsAsString(other.tagsAsString), + lineInfo(other.lineInfo), properties(other.properties) {} - TestCase TestCase::withName( std::string const& _newName ) const { - TestCase other( *this ); - other.name = _newName; - return other; - } +bool TestCaseInfo::isHidden() const { return (properties & IsHidden) != 0; } +bool TestCaseInfo::throws() const { return (properties & Throws) != 0; } +bool TestCaseInfo::okToFail() const { + return (properties & (ShouldFail | MayFail)) != 0; +} +bool TestCaseInfo::expectedToFail() const { + return (properties & (ShouldFail)) != 0; +} - void TestCase::swap( TestCase& other ) { - test.swap( other.test ); - name.swap( other.name ); - className.swap( other.className ); - description.swap( other.description ); - tags.swap( other.tags ); - lcaseTags.swap( other.lcaseTags ); - tagsAsString.swap( other.tagsAsString ); - std::swap( TestCaseInfo::properties, static_cast( other ).properties ); - std::swap( lineInfo, other.lineInfo ); - } +TestCase::TestCase(ITestCase *testCase, TestCaseInfo const &info) + : TestCaseInfo(info), test(testCase) {} - void TestCase::invoke() const { - test->invoke(); - } +TestCase::TestCase(TestCase const &other) + : TestCaseInfo(other), test(other.test) {} - bool TestCase::operator == ( TestCase const& other ) const { - return test.get() == other.test.get() && - name == other.name && - className == other.className; - } +TestCase TestCase::withName(std::string const &_newName) const { + TestCase other(*this); + other.name = _newName; + return other; +} - bool TestCase::operator < ( TestCase const& other ) const { - return name < other.name; - } - TestCase& TestCase::operator = ( TestCase const& other ) { - TestCase temp( other ); - swap( temp ); - return *this; - } +void TestCase::swap(TestCase &other) { + test.swap(other.test); + name.swap(other.name); + className.swap(other.className); + description.swap(other.description); + tags.swap(other.tags); + lcaseTags.swap(other.lcaseTags); + tagsAsString.swap(other.tagsAsString); + std::swap(TestCaseInfo::properties, + static_cast(other).properties); + std::swap(lineInfo, other.lineInfo); +} - TestCaseInfo const& TestCase::getTestCaseInfo() const - { - return *this; - } +void TestCase::invoke() const { test->invoke(); } + +bool TestCase::operator==(TestCase const &other) const { + return test.get() == other.test.get() && name == other.name && + className == other.className; +} + +bool TestCase::operator<(TestCase const &other) const { + return name < other.name; +} +TestCase &TestCase::operator=(TestCase const &other) { + TestCase temp(other); + swap(temp); + return *this; +} + +TestCaseInfo const &TestCase::getTestCaseInfo() const { return *this; } } // end namespace Catch @@ -7502,67 +7567,52 @@ namespace Catch { namespace Catch { - Version::Version - ( unsigned int _majorVersion, - unsigned int _minorVersion, - unsigned int _patchNumber, - std::string const& _branchName, - unsigned int _buildNumber ) - : majorVersion( _majorVersion ), - minorVersion( _minorVersion ), - patchNumber( _patchNumber ), - branchName( _branchName ), - buildNumber( _buildNumber ) - {} - - std::ostream& operator << ( std::ostream& os, Version const& version ) { - os << version.majorVersion << "." - << version.minorVersion << "." - << version.patchNumber; - - if( !version.branchName.empty() ) { - os << "-" << version.branchName - << "." << version.buildNumber; - } - return os; - } +Version::Version(unsigned int _majorVersion, unsigned int _minorVersion, + unsigned int _patchNumber, std::string const &_branchName, + unsigned int _buildNumber) + : majorVersion(_majorVersion), minorVersion(_minorVersion), + patchNumber(_patchNumber), branchName(_branchName), + buildNumber(_buildNumber) {} + +std::ostream &operator<<(std::ostream &os, Version const &version) { + os << version.majorVersion << "." << version.minorVersion << "." + << version.patchNumber; + + if (!version.branchName.empty()) { + os << "-" << version.branchName << "." << version.buildNumber; + } + return os; +} - Version libraryVersion( 1, 5, 0, "", 0 ); +Version libraryVersion(1, 5, 0, "", 0); -} +} // namespace Catch // #included from: catch_message.hpp #define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED namespace Catch { - MessageInfo::MessageInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - type( _type ), - sequence( ++globalCount ) - {} +MessageInfo::MessageInfo(std::string const &_macroName, + SourceLineInfo const &_lineInfo, + ResultWas::OfType _type) + : macroName(_macroName), lineInfo(_lineInfo), type(_type), + sequence(++globalCount) {} - // This may need protecting if threading support is added - unsigned int MessageInfo::globalCount = 0; +// This may need protecting if threading support is added +unsigned int MessageInfo::globalCount = 0; - //////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// - ScopedMessage::ScopedMessage( MessageBuilder const& builder ) - : m_info( builder.m_info ) - { - m_info.message = builder.m_stream.str(); - getResultCapture().pushScopedMessage( m_info ); - } - ScopedMessage::ScopedMessage( ScopedMessage const& other ) - : m_info( other.m_info ) - {} +ScopedMessage::ScopedMessage(MessageBuilder const &builder) + : m_info(builder.m_info) { + m_info.message = builder.m_stream.str(); + getResultCapture().pushScopedMessage(m_info); +} +ScopedMessage::ScopedMessage(ScopedMessage const &other) + : m_info(other.m_info) {} - ScopedMessage::~ScopedMessage() { - getResultCapture().popScopedMessage( m_info ); - } +ScopedMessage::~ScopedMessage() { getResultCapture().popScopedMessage(m_info); } } // end namespace Catch @@ -7572,123 +7622,126 @@ namespace Catch { // #included from: catch_legacy_reporter_adapter.h #define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED -namespace Catch -{ - // Deprecated - struct IReporter : IShared { - virtual ~IReporter(); - - virtual bool shouldRedirectStdout() const = 0; - - virtual void StartTesting() = 0; - virtual void EndTesting( Totals const& totals ) = 0; - virtual void StartGroup( std::string const& groupName ) = 0; - virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0; - virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0; - virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0; - virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0; - virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0; - virtual void NoAssertionsInSection( std::string const& sectionName ) = 0; - virtual void NoAssertionsInTestCase( std::string const& testName ) = 0; - virtual void Aborted() = 0; - virtual void Result( AssertionResult const& result ) = 0; - }; - - class LegacyReporterAdapter : public SharedImpl - { - public: - LegacyReporterAdapter( Ptr const& legacyReporter ); - virtual ~LegacyReporterAdapter(); - - virtual ReporterPreferences getPreferences() const; - virtual void noMatchingTestCases( std::string const& ); - virtual void testRunStarting( TestRunInfo const& ); - virtual void testGroupStarting( GroupInfo const& groupInfo ); - virtual void testCaseStarting( TestCaseInfo const& testInfo ); - virtual void sectionStarting( SectionInfo const& sectionInfo ); - virtual void assertionStarting( AssertionInfo const& ); - virtual bool assertionEnded( AssertionStats const& assertionStats ); - virtual void sectionEnded( SectionStats const& sectionStats ); - virtual void testCaseEnded( TestCaseStats const& testCaseStats ); - virtual void testGroupEnded( TestGroupStats const& testGroupStats ); - virtual void testRunEnded( TestRunStats const& testRunStats ); - virtual void skipTest( TestCaseInfo const& ); - - private: - Ptr m_legacyReporter; - }; -} - -namespace Catch -{ - LegacyReporterAdapter::LegacyReporterAdapter( Ptr const& legacyReporter ) - : m_legacyReporter( legacyReporter ) - {} - LegacyReporterAdapter::~LegacyReporterAdapter() {} - - ReporterPreferences LegacyReporterAdapter::getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout(); - return prefs; - } - - void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {} - void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) { - m_legacyReporter->StartTesting(); - } - void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) { - m_legacyReporter->StartGroup( groupInfo.name ); - } - void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) { - m_legacyReporter->StartTestCase( testInfo ); - } - void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) { - m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description ); - } - void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) { - // Not on legacy interface - } - - bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) { - if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { - for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); - it != itEnd; - ++it ) { - if( it->type == ResultWas::Info ) { - ResultBuilder rb( it->macroName.c_str(), it->lineInfo, "", ResultDisposition::Normal ); - rb << it->message; - rb.setResultType( ResultWas::Info ); - AssertionResult result = rb.build(); - m_legacyReporter->Result( result ); - } - } - } - m_legacyReporter->Result( assertionStats.assertionResult ); - return true; - } - void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) { - if( sectionStats.missingAssertions ) - m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name ); - m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions ); - } - void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) { - m_legacyReporter->EndTestCase - ( testCaseStats.testInfo, - testCaseStats.totals, - testCaseStats.stdOut, - testCaseStats.stdErr ); - } - void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) { - if( testGroupStats.aborting ) - m_legacyReporter->Aborted(); - m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals ); - } - void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) { - m_legacyReporter->EndTesting( testRunStats.totals ); - } - void LegacyReporterAdapter::skipTest( TestCaseInfo const& ) { +namespace Catch { +// Deprecated +struct IReporter : IShared { + virtual ~IReporter(); + + virtual bool shouldRedirectStdout() const = 0; + + virtual void StartTesting() = 0; + virtual void EndTesting(Totals const &totals) = 0; + virtual void StartGroup(std::string const &groupName) = 0; + virtual void EndGroup(std::string const &groupName, Totals const &totals) = 0; + virtual void StartTestCase(TestCaseInfo const &testInfo) = 0; + virtual void EndTestCase(TestCaseInfo const &testInfo, Totals const &totals, + std::string const &stdOut, + std::string const &stdErr) = 0; + virtual void StartSection(std::string const §ionName, + std::string const &description) = 0; + virtual void EndSection(std::string const §ionName, + Counts const &assertions) = 0; + virtual void NoAssertionsInSection(std::string const §ionName) = 0; + virtual void NoAssertionsInTestCase(std::string const &testName) = 0; + virtual void Aborted() = 0; + virtual void Result(AssertionResult const &result) = 0; +}; + +class LegacyReporterAdapter : public SharedImpl { +public: + LegacyReporterAdapter(Ptr const &legacyReporter); + virtual ~LegacyReporterAdapter(); + + virtual ReporterPreferences getPreferences() const; + virtual void noMatchingTestCases(std::string const &); + virtual void testRunStarting(TestRunInfo const &); + virtual void testGroupStarting(GroupInfo const &groupInfo); + virtual void testCaseStarting(TestCaseInfo const &testInfo); + virtual void sectionStarting(SectionInfo const §ionInfo); + virtual void assertionStarting(AssertionInfo const &); + virtual bool assertionEnded(AssertionStats const &assertionStats); + virtual void sectionEnded(SectionStats const §ionStats); + virtual void testCaseEnded(TestCaseStats const &testCaseStats); + virtual void testGroupEnded(TestGroupStats const &testGroupStats); + virtual void testRunEnded(TestRunStats const &testRunStats); + virtual void skipTest(TestCaseInfo const &); + +private: + Ptr m_legacyReporter; +}; +} // namespace Catch + +namespace Catch { +LegacyReporterAdapter::LegacyReporterAdapter( + Ptr const &legacyReporter) + : m_legacyReporter(legacyReporter) {} +LegacyReporterAdapter::~LegacyReporterAdapter() {} + +ReporterPreferences LegacyReporterAdapter::getPreferences() const { + ReporterPreferences prefs; + prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout(); + return prefs; +} + +void LegacyReporterAdapter::noMatchingTestCases(std::string const &) {} +void LegacyReporterAdapter::testRunStarting(TestRunInfo const &) { + m_legacyReporter->StartTesting(); +} +void LegacyReporterAdapter::testGroupStarting(GroupInfo const &groupInfo) { + m_legacyReporter->StartGroup(groupInfo.name); +} +void LegacyReporterAdapter::testCaseStarting(TestCaseInfo const &testInfo) { + m_legacyReporter->StartTestCase(testInfo); +} +void LegacyReporterAdapter::sectionStarting(SectionInfo const §ionInfo) { + m_legacyReporter->StartSection(sectionInfo.name, sectionInfo.description); +} +void LegacyReporterAdapter::assertionStarting(AssertionInfo const &) { + // Not on legacy interface +} + +bool LegacyReporterAdapter::assertionEnded( + AssertionStats const &assertionStats) { + if (assertionStats.assertionResult.getResultType() != ResultWas::Ok) { + for (std::vector::const_iterator + it = assertionStats.infoMessages.begin(), + itEnd = assertionStats.infoMessages.end(); + it != itEnd; ++it) { + if (it->type == ResultWas::Info) { + ResultBuilder rb(it->macroName.c_str(), it->lineInfo, "", + ResultDisposition::Normal); + rb << it->message; + rb.setResultType(ResultWas::Info); + AssertionResult result = rb.build(); + m_legacyReporter->Result(result); + } } + } + m_legacyReporter->Result(assertionStats.assertionResult); + return true; +} +void LegacyReporterAdapter::sectionEnded(SectionStats const §ionStats) { + if (sectionStats.missingAssertions) + m_legacyReporter->NoAssertionsInSection(sectionStats.sectionInfo.name); + m_legacyReporter->EndSection(sectionStats.sectionInfo.name, + sectionStats.assertions); +} +void LegacyReporterAdapter::testCaseEnded(TestCaseStats const &testCaseStats) { + m_legacyReporter->EndTestCase(testCaseStats.testInfo, testCaseStats.totals, + testCaseStats.stdOut, testCaseStats.stdErr); } +void LegacyReporterAdapter::testGroupEnded( + TestGroupStats const &testGroupStats) { + if (testGroupStats.aborting) + m_legacyReporter->Aborted(); + m_legacyReporter->EndGroup(testGroupStats.groupInfo.name, + testGroupStats.totals); +} +void LegacyReporterAdapter::testRunEnded(TestRunStats const &testRunStats) { + m_legacyReporter->EndTesting(testRunStats.totals); +} +void LegacyReporterAdapter::skipTest(TestCaseInfo const &) {} +} // namespace Catch // #included from: catch_timer.hpp @@ -7705,39 +7758,38 @@ namespace Catch namespace Catch { - namespace { +namespace { #ifdef CATCH_PLATFORM_WINDOWS - uint64_t getCurrentTicks() { - static uint64_t hz=0, hzo=0; - if (!hz) { - QueryPerformanceFrequency( reinterpret_cast( &hz ) ); - QueryPerformanceCounter( reinterpret_cast( &hzo ) ); - } - uint64_t t; - QueryPerformanceCounter( reinterpret_cast( &t ) ); - return ((t-hzo)*1000000)/hz; - } +uint64_t getCurrentTicks() { + static uint64_t hz = 0, hzo = 0; + if (!hz) { + QueryPerformanceFrequency(reinterpret_cast(&hz)); + QueryPerformanceCounter(reinterpret_cast(&hzo)); + } + uint64_t t; + QueryPerformanceCounter(reinterpret_cast(&t)); + return ((t - hzo) * 1000000) / hz; +} #else - uint64_t getCurrentTicks() { - timeval t; - gettimeofday(&t,CATCH_NULL); - return static_cast( t.tv_sec ) * 1000000ull + static_cast( t.tv_usec ); - } +uint64_t getCurrentTicks() { + timeval t; + gettimeofday(&t, CATCH_NULL); + return static_cast(t.tv_sec) * 1000000ull + + static_cast(t.tv_usec); +} #endif - } +} // namespace - void Timer::start() { - m_ticks = getCurrentTicks(); - } - unsigned int Timer::getElapsedMicroseconds() const { - return static_cast(getCurrentTicks() - m_ticks); - } - unsigned int Timer::getElapsedMilliseconds() const { - return static_cast(getElapsedMicroseconds()/1000); - } - double Timer::getElapsedSeconds() const { - return getElapsedMicroseconds()/1000000.0; - } +void Timer::start() { m_ticks = getCurrentTicks(); } +unsigned int Timer::getElapsedMicroseconds() const { + return static_cast(getCurrentTicks() - m_ticks); +} +unsigned int Timer::getElapsedMilliseconds() const { + return static_cast(getElapsedMicroseconds() / 1000); +} +double Timer::getElapsedSeconds() const { + return getElapsedMicroseconds() / 1000000.0; +} } // namespace Catch @@ -7749,136 +7801,122 @@ namespace Catch { namespace Catch { - bool startsWith( std::string const& s, std::string const& prefix ) { - return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix; - } - bool endsWith( std::string const& s, std::string const& suffix ) { - return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix; - } - bool contains( std::string const& s, std::string const& infix ) { - return s.find( infix ) != std::string::npos; - } - void toLowerInPlace( std::string& s ) { - std::transform( s.begin(), s.end(), s.begin(), ::tolower ); - } - std::string toLower( std::string const& s ) { - std::string lc = s; - toLowerInPlace( lc ); - return lc; - } - std::string trim( std::string const& str ) { - static char const* whitespaceChars = "\n\r\t "; - std::string::size_type start = str.find_first_not_of( whitespaceChars ); - std::string::size_type end = str.find_last_not_of( whitespaceChars ); +bool startsWith(std::string const &s, std::string const &prefix) { + return s.size() >= prefix.size() && s.substr(0, prefix.size()) == prefix; +} +bool endsWith(std::string const &s, std::string const &suffix) { + return s.size() >= suffix.size() && + s.substr(s.size() - suffix.size(), suffix.size()) == suffix; +} +bool contains(std::string const &s, std::string const &infix) { + return s.find(infix) != std::string::npos; +} +void toLowerInPlace(std::string &s) { + std::transform(s.begin(), s.end(), s.begin(), ::tolower); +} +std::string toLower(std::string const &s) { + std::string lc = s; + toLowerInPlace(lc); + return lc; +} +std::string trim(std::string const &str) { + static char const *whitespaceChars = "\n\r\t "; + std::string::size_type start = str.find_first_not_of(whitespaceChars); + std::string::size_type end = str.find_last_not_of(whitespaceChars); - return start != std::string::npos ? str.substr( start, 1+end-start ) : ""; - } + return start != std::string::npos ? str.substr(start, 1 + end - start) : ""; +} - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { - bool replaced = false; - std::size_t i = str.find( replaceThis ); - while( i != std::string::npos ) { - replaced = true; - str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); - if( i < str.size()-withThis.size() ) - i = str.find( replaceThis, i+withThis.size() ); - else - i = std::string::npos; - } - return replaced; - } +bool replaceInPlace(std::string &str, std::string const &replaceThis, + std::string const &withThis) { + bool replaced = false; + std::size_t i = str.find(replaceThis); + while (i != std::string::npos) { + replaced = true; + str = str.substr(0, i) + withThis + str.substr(i + replaceThis.size()); + if (i < str.size() - withThis.size()) + i = str.find(replaceThis, i + withThis.size()); + else + i = std::string::npos; + } + return replaced; +} - pluralise::pluralise( std::size_t count, std::string const& label ) - : m_count( count ), - m_label( label ) - {} +pluralise::pluralise(std::size_t count, std::string const &label) + : m_count(count), m_label(label) {} - std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { - os << pluraliser.m_count << " " << pluraliser.m_label; - if( pluraliser.m_count != 1 ) - os << "s"; - return os; - } +std::ostream &operator<<(std::ostream &os, pluralise const &pluraliser) { + os << pluraliser.m_count << " " << pluraliser.m_label; + if (pluraliser.m_count != 1) + os << "s"; + return os; +} - SourceLineInfo::SourceLineInfo() : line( 0 ){} - SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) - : file( _file ), - line( _line ) - {} - SourceLineInfo::SourceLineInfo( SourceLineInfo const& other ) - : file( other.file ), - line( other.line ) - {} - bool SourceLineInfo::empty() const { - return file.empty(); - } - bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const { - return line == other.line && file == other.file; - } - bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const { - return line < other.line || ( line == other.line && file < other.file ); - } +SourceLineInfo::SourceLineInfo() : line(0) {} +SourceLineInfo::SourceLineInfo(char const *_file, std::size_t _line) + : file(_file), line(_line) {} +SourceLineInfo::SourceLineInfo(SourceLineInfo const &other) + : file(other.file), line(other.line) {} +bool SourceLineInfo::empty() const { return file.empty(); } +bool SourceLineInfo::operator==(SourceLineInfo const &other) const { + return line == other.line && file == other.file; +} +bool SourceLineInfo::operator<(SourceLineInfo const &other) const { + return line < other.line || (line == other.line && file < other.file); +} - void seedRng( IConfig const& config ) { - if( config.rngSeed() != 0 ) - std::srand( config.rngSeed() ); - } - unsigned int rngSeed() { - return getCurrentContext().getConfig()->rngSeed(); - } +void seedRng(IConfig const &config) { + if (config.rngSeed() != 0) + std::srand(config.rngSeed()); +} +unsigned int rngSeed() { return getCurrentContext().getConfig()->rngSeed(); } - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { +std::ostream &operator<<(std::ostream &os, SourceLineInfo const &info) { #ifndef __GNUG__ - os << info.file << "(" << info.line << ")"; + os << info.file << "(" << info.line << ")"; #else - os << info.file << ":" << info.line; + os << info.file << ":" << info.line; #endif - return os; - } + return os; +} - void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) { - std::ostringstream oss; - oss << locationInfo << ": Internal Catch error: '" << message << "'"; - if( alwaysTrue() ) - throw std::logic_error( oss.str() ); - } +void throwLogicError(std::string const &message, + SourceLineInfo const &locationInfo) { + std::ostringstream oss; + oss << locationInfo << ": Internal Catch error: '" << message << "'"; + if (alwaysTrue()) + throw std::logic_error(oss.str()); } +} // namespace Catch // #included from: catch_section.hpp #define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED namespace Catch { - SectionInfo::SectionInfo - ( SourceLineInfo const& _lineInfo, - std::string const& _name, - std::string const& _description ) - : name( _name ), - description( _description ), - lineInfo( _lineInfo ) - {} - - Section::Section( SectionInfo const& info ) - : m_info( info ), - m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) - { - m_timer.start(); - } +SectionInfo::SectionInfo(SourceLineInfo const &_lineInfo, + std::string const &_name, + std::string const &_description) + : name(_name), description(_description), lineInfo(_lineInfo) {} - Section::~Section() { - if( m_sectionIncluded ) { - SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() ); - if( std::uncaught_exception() ) - getResultCapture().sectionEndedEarly( endInfo ); - else - getResultCapture().sectionEnded( endInfo ); - } - } +Section::Section(SectionInfo const &info) + : m_info(info), m_sectionIncluded(getResultCapture().sectionStarted( + m_info, m_assertions)) { + m_timer.start(); +} - // This indicates whether the section should be executed or not - Section::operator bool() const { - return m_sectionIncluded; - } +Section::~Section() { + if (m_sectionIncluded) { + SectionEndInfo endInfo(m_info, m_assertions, m_timer.getElapsedSeconds()); + if (std::uncaught_exception()) + getResultCapture().sectionEndedEarly(endInfo); + else + getResultCapture().sectionEnded(endInfo); + } +} + +// This indicates whether the section should be executed or not +Section::operator bool() const { return m_sectionIncluded; } } // end namespace Catch @@ -7889,86 +7927,86 @@ namespace Catch { #ifdef CATCH_PLATFORM_MAC - #include - #include - #include - #include - #include +#include +#include +#include +#include +#include - namespace Catch{ +namespace Catch { - // The following function is taken directly from the following technical note: - // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html +// The following function is taken directly from the following technical note: +// http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html - // Returns true if the current process is being debugged (either - // running under the debugger or has a debugger attached post facto). - bool isDebuggerActive(){ +// Returns true if the current process is being debugged (either +// running under the debugger or has a debugger attached post facto). +bool isDebuggerActive() { - int mib[4]; - struct kinfo_proc info; - size_t size; + int mib[4]; + struct kinfo_proc info; + size_t size; - // Initialize the flags so that, if sysctl fails for some bizarre - // reason, we get a predictable result. + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. - info.kp_proc.p_flag = 0; + info.kp_proc.p_flag = 0; - // Initialize mib, which tells sysctl the info we want, in this case - // we're looking for information about a specific process ID. + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); - // Call sysctl. + // Call sysctl. - size = sizeof(info); - if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, CATCH_NULL, 0) != 0 ) { - Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; - return false; - } + size = sizeof(info); + if (sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, CATCH_NULL, 0) != + 0) { + Catch::cerr() << "\n** Call to sysctl failed - unable to determine if " + "debugger is active **\n" + << std::endl; + return false; + } - // We're being debugged if the P_TRACED flag is set. + // We're being debugged if the P_TRACED flag is set. - return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); - } - } // namespace Catch + return ((info.kp_proc.p_flag & P_TRACED) != 0); +} +} // namespace Catch #elif defined(_MSC_VER) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - namespace Catch { - bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } - } +extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); +namespace Catch { +bool isDebuggerActive() { return IsDebuggerPresent() != 0; } +} // namespace Catch #elif defined(__MINGW32__) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - namespace Catch { - bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } - } +extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); +namespace Catch { +bool isDebuggerActive() { return IsDebuggerPresent() != 0; } +} // namespace Catch #else - namespace Catch { - inline bool isDebuggerActive() { return false; } - } +namespace Catch { +inline bool isDebuggerActive() { return false; } +} // namespace Catch #endif // Platform #ifdef CATCH_PLATFORM_WINDOWS - extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* ); - namespace Catch { - void writeToDebugConsole( std::string const& text ) { - ::OutputDebugStringA( text.c_str() ); - } - } +extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( + const char *); +namespace Catch { +void writeToDebugConsole(std::string const &text) { + ::OutputDebugStringA(text.c_str()); +} +} // namespace Catch #else - namespace Catch { - void writeToDebugConsole( std::string const& text ) { - // !TBD: Need a version for Mac/ XCode and other IDEs - Catch::cout() << text; - } - } +namespace Catch { +void writeToDebugConsole(std::string const &text) { + // !TBD: Need a version for Mac/ XCode and other IDEs + Catch::cout() << text; +} +} // namespace Catch #endif // Platform // #included from: catch_tostring.hpp @@ -7978,187 +8016,179 @@ namespace Catch { namespace Detail { - const std::string unprintableString = "{?}"; +const std::string unprintableString = "{?}"; - namespace { - const int hexThreshold = 255; - - struct Endianness { - enum Arch { Big, Little }; - - static Arch which() { - union _{ - int asInt; - char asChar[sizeof (int)]; - } u; +namespace { +const int hexThreshold = 255; - u.asInt = 1; - return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little; - } - }; - } +struct Endianness { + enum Arch { Big, Little }; - std::string rawMemoryToString( const void *object, std::size_t size ) - { - // Reverse order for little endian architectures - int i = 0, end = static_cast( size ), inc = 1; - if( Endianness::which() == Endianness::Little ) { - i = end-1; - end = inc = -1; - } + static Arch which() { + union _ { + int asInt; + char asChar[sizeof(int)]; + } u; - unsigned char const *bytes = static_cast(object); - std::ostringstream os; - os << "0x" << std::setfill('0') << std::hex; - for( ; i != end; i += inc ) - os << std::setw(2) << static_cast(bytes[i]); - return os.str(); - } + u.asInt = 1; + return (u.asChar[sizeof(int) - 1] == 1) ? Big : Little; + } +}; +} // namespace + +std::string rawMemoryToString(const void *object, std::size_t size) { + // Reverse order for little endian architectures + int i = 0, end = static_cast(size), inc = 1; + if (Endianness::which() == Endianness::Little) { + i = end - 1; + end = inc = -1; + } + + unsigned char const *bytes = static_cast(object); + std::ostringstream os; + os << "0x" << std::setfill('0') << std::hex; + for (; i != end; i += inc) + os << std::setw(2) << static_cast(bytes[i]); + return os.str(); } - -std::string toString( std::string const& value ) { - std::string s = value; - if( getCurrentContext().getConfig()->showInvisibles() ) { - for(size_t i = 0; i < s.size(); ++i ) { - std::string subs; - switch( s[i] ) { - case '\n': subs = "\\n"; break; - case '\t': subs = "\\t"; break; - default: break; - } - if( !subs.empty() ) { - s = s.substr( 0, i ) + subs + s.substr( i+1 ); - ++i; - } - } +} // namespace Detail + +std::string toString(std::string const &value) { + std::string s = value; + if (getCurrentContext().getConfig()->showInvisibles()) { + for (size_t i = 0; i < s.size(); ++i) { + std::string subs; + switch (s[i]) { + case '\n': + subs = "\\n"; + break; + case '\t': + subs = "\\t"; + break; + default: + break; + } + if (!subs.empty()) { + s = s.substr(0, i) + subs + s.substr(i + 1); + ++i; + } } - return "\"" + s + "\""; + } + return "\"" + s + "\""; } -std::string toString( std::wstring const& value ) { +std::string toString(std::wstring const &value) { - std::string s; - s.reserve( value.size() ); - for(size_t i = 0; i < value.size(); ++i ) - s += value[i] <= 0xff ? static_cast( value[i] ) : '?'; - return Catch::toString( s ); + std::string s; + s.reserve(value.size()); + for (size_t i = 0; i < value.size(); ++i) + s += value[i] <= 0xff ? static_cast(value[i]) : '?'; + return Catch::toString(s); } -std::string toString( const char* const value ) { - return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" ); +std::string toString(const char *const value) { + return value ? Catch::toString(std::string(value)) + : std::string("{null string}"); } -std::string toString( char* const value ) { - return Catch::toString( static_cast( value ) ); +std::string toString(char *const value) { + return Catch::toString(static_cast(value)); } -std::string toString( const wchar_t* const value ) -{ - return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" ); +std::string toString(const wchar_t *const value) { + return value ? Catch::toString(std::wstring(value)) + : std::string("{null string}"); } -std::string toString( wchar_t* const value ) -{ - return Catch::toString( static_cast( value ) ); +std::string toString(wchar_t *const value) { + return Catch::toString(static_cast(value)); } -std::string toString( int value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ")"; - return oss.str(); +std::string toString(int value) { + std::ostringstream oss; + oss << value; + if (value > Detail::hexThreshold) + oss << " (0x" << std::hex << value << ")"; + return oss.str(); } -std::string toString( unsigned long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ")"; - return oss.str(); +std::string toString(unsigned long value) { + std::ostringstream oss; + oss << value; + if (value > Detail::hexThreshold) + oss << " (0x" << std::hex << value << ")"; + return oss.str(); } -std::string toString( unsigned int value ) { - return Catch::toString( static_cast( value ) ); +std::string toString(unsigned int value) { + return Catch::toString(static_cast(value)); } -template -std::string fpToString( T value, int precision ) { - std::ostringstream oss; - oss << std::setprecision( precision ) - << std::fixed - << value; - std::string d = oss.str(); - std::size_t i = d.find_last_not_of( '0' ); - if( i != std::string::npos && i != d.size()-1 ) { - if( d[i] == '.' ) - i++; - d = d.substr( 0, i+1 ); - } - return d; +template std::string fpToString(T value, int precision) { + std::ostringstream oss; + oss << std::setprecision(precision) << std::fixed << value; + std::string d = oss.str(); + std::size_t i = d.find_last_not_of('0'); + if (i != std::string::npos && i != d.size() - 1) { + if (d[i] == '.') + i++; + d = d.substr(0, i + 1); + } + return d; } -std::string toString( const double value ) { - return fpToString( value, 10 ); -} -std::string toString( const float value ) { - return fpToString( value, 5 ) + "f"; -} +std::string toString(const double value) { return fpToString(value, 10); } +std::string toString(const float value) { return fpToString(value, 5) + "f"; } -std::string toString( bool value ) { - return value ? "true" : "false"; -} +std::string toString(bool value) { return value ? "true" : "false"; } -std::string toString( char value ) { - return value < ' ' - ? toString( static_cast( value ) ) - : Detail::makeString( value ); +std::string toString(char value) { + return value < ' ' ? toString(static_cast(value)) + : Detail::makeString(value); } -std::string toString( signed char value ) { - return toString( static_cast( value ) ); +std::string toString(signed char value) { + return toString(static_cast(value)); } -std::string toString( unsigned char value ) { - return toString( static_cast( value ) ); +std::string toString(unsigned char value) { + return toString(static_cast(value)); } #ifdef CATCH_CONFIG_CPP11_LONG_LONG -std::string toString( long long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ")"; - return oss.str(); +std::string toString(long long value) { + std::ostringstream oss; + oss << value; + if (value > Detail::hexThreshold) + oss << " (0x" << std::hex << value << ")"; + return oss.str(); } -std::string toString( unsigned long long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ")"; - return oss.str(); +std::string toString(unsigned long long value) { + std::ostringstream oss; + oss << value; + if (value > Detail::hexThreshold) + oss << " (0x" << std::hex << value << ")"; + return oss.str(); } #endif #ifdef CATCH_CONFIG_CPP11_NULLPTR -std::string toString( std::nullptr_t ) { - return "nullptr"; -} +std::string toString(std::nullptr_t) { return "nullptr"; } #endif #ifdef __OBJC__ - std::string toString( NSString const * const& nsstring ) { - if( !nsstring ) - return "nil"; - return "@" + toString([nsstring UTF8String]); - } - std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) { - if( !nsstring ) - return "nil"; - return "@" + toString([nsstring UTF8String]); - } - std::string toString( NSObject* const& nsObject ) { - return toString( [nsObject description] ); - } +std::string toString(NSString const *const &nsstring) { + if (!nsstring) + return "nil"; + return "@" + toString([nsstring UTF8String]); +} +std::string toString(NSString *CATCH_ARC_STRONG const &nsstring) { + if (!nsstring) + return "nil"; + return "@" + toString([nsstring UTF8String]); +} +std::string toString(NSObject *const &nsObject) { + return toString([nsObject description]); +} #endif } // end namespace Catch @@ -8168,143 +8198,156 @@ std::string toString( std::nullptr_t ) { namespace Catch { - std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) { - return secondArg.empty() || secondArg == "\"\"" - ? capturedExpression - : capturedExpression + ", " + secondArg; - } - ResultBuilder::ResultBuilder( char const* macroName, - SourceLineInfo const& lineInfo, - char const* capturedExpression, - ResultDisposition::Flags resultDisposition, - char const* secondArg ) - : m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ), - m_shouldDebugBreak( false ), - m_shouldThrow( false ) - {} - - ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) { - m_data.resultType = result; - return *this; - } - ResultBuilder& ResultBuilder::setResultType( bool result ) { - m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed; - return *this; - } - ResultBuilder& ResultBuilder::setLhs( std::string const& lhs ) { - m_exprComponents.lhs = lhs; - return *this; - } - ResultBuilder& ResultBuilder::setRhs( std::string const& rhs ) { - m_exprComponents.rhs = rhs; - return *this; - } - ResultBuilder& ResultBuilder::setOp( std::string const& op ) { - m_exprComponents.op = op; - return *this; - } - - void ResultBuilder::endExpression() { - m_exprComponents.testFalse = isFalseTest( m_assertionInfo.resultDisposition ); - captureExpression(); - } - - void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) { - m_assertionInfo.resultDisposition = resultDisposition; - m_stream.oss << Catch::translateActiveException(); - captureResult( ResultWas::ThrewException ); - } - - void ResultBuilder::captureResult( ResultWas::OfType resultType ) { - setResultType( resultType ); - captureExpression(); - } - void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) { - if( expectedMessage.empty() ) - captureExpectedException( Matchers::Impl::Generic::AllOf() ); - else - captureExpectedException( Matchers::Equals( expectedMessage ) ); - } +std::string +capturedExpressionWithSecondArgument(std::string const &capturedExpression, + std::string const &secondArg) { + return secondArg.empty() || secondArg == "\"\"" + ? capturedExpression + : capturedExpression + ", " + secondArg; +} +ResultBuilder::ResultBuilder(char const *macroName, + SourceLineInfo const &lineInfo, + char const *capturedExpression, + ResultDisposition::Flags resultDisposition, + char const *secondArg) + : m_assertionInfo( + macroName, lineInfo, + capturedExpressionWithSecondArgument(capturedExpression, secondArg), + resultDisposition), + m_shouldDebugBreak(false), m_shouldThrow(false) {} + +ResultBuilder &ResultBuilder::setResultType(ResultWas::OfType result) { + m_data.resultType = result; + return *this; +} +ResultBuilder &ResultBuilder::setResultType(bool result) { + m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed; + return *this; +} +ResultBuilder &ResultBuilder::setLhs(std::string const &lhs) { + m_exprComponents.lhs = lhs; + return *this; +} +ResultBuilder &ResultBuilder::setRhs(std::string const &rhs) { + m_exprComponents.rhs = rhs; + return *this; +} +ResultBuilder &ResultBuilder::setOp(std::string const &op) { + m_exprComponents.op = op; + return *this; +} - void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher const& matcher ) { +void ResultBuilder::endExpression() { + m_exprComponents.testFalse = isFalseTest(m_assertionInfo.resultDisposition); + captureExpression(); +} - assert( m_exprComponents.testFalse == false ); - AssertionResultData data = m_data; - data.resultType = ResultWas::Ok; - data.reconstructedExpression = m_assertionInfo.capturedExpression; +void ResultBuilder::useActiveException( + ResultDisposition::Flags resultDisposition) { + m_assertionInfo.resultDisposition = resultDisposition; + m_stream.oss << Catch::translateActiveException(); + captureResult(ResultWas::ThrewException); +} - std::string actualMessage = Catch::translateActiveException(); - if( !matcher.match( actualMessage ) ) { - data.resultType = ResultWas::ExpressionFailed; - data.reconstructedExpression = actualMessage; - } - AssertionResult result( m_assertionInfo, data ); - handleResult( result ); - } +void ResultBuilder::captureResult(ResultWas::OfType resultType) { + setResultType(resultType); + captureExpression(); +} +void ResultBuilder::captureExpectedException( + std::string const &expectedMessage) { + if (expectedMessage.empty()) + captureExpectedException(Matchers::Impl::Generic::AllOf()); + else + captureExpectedException(Matchers::Equals(expectedMessage)); +} - void ResultBuilder::captureExpression() { - AssertionResult result = build(); - handleResult( result ); - } - void ResultBuilder::handleResult( AssertionResult const& result ) - { - getResultCapture().assertionEnded( result ); +void ResultBuilder::captureExpectedException( + Matchers::Impl::Matcher const &matcher) { + + assert(m_exprComponents.testFalse == false); + AssertionResultData data = m_data; + data.resultType = ResultWas::Ok; + data.reconstructedExpression = m_assertionInfo.capturedExpression; + + std::string actualMessage = Catch::translateActiveException(); + if (!matcher.match(actualMessage)) { + data.resultType = ResultWas::ExpressionFailed; + data.reconstructedExpression = actualMessage; + } + AssertionResult result(m_assertionInfo, data); + handleResult(result); +} - if( !result.isOk() ) { - if( getCurrentContext().getConfig()->shouldDebugBreak() ) - m_shouldDebugBreak = true; - if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) ) - m_shouldThrow = true; - } - } - void ResultBuilder::react() { - if( m_shouldThrow ) - throw Catch::TestFailureException(); - } +void ResultBuilder::captureExpression() { + AssertionResult result = build(); + handleResult(result); +} +void ResultBuilder::handleResult(AssertionResult const &result) { + getResultCapture().assertionEnded(result); + + if (!result.isOk()) { + if (getCurrentContext().getConfig()->shouldDebugBreak()) + m_shouldDebugBreak = true; + if (getCurrentContext().getRunner()->aborting() || + (m_assertionInfo.resultDisposition & ResultDisposition::Normal)) + m_shouldThrow = true; + } +} +void ResultBuilder::react() { + if (m_shouldThrow) + throw Catch::TestFailureException(); +} - bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; } - bool ResultBuilder::allowThrows() const { return getCurrentContext().getConfig()->allowThrows(); } +bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; } +bool ResultBuilder::allowThrows() const { + return getCurrentContext().getConfig()->allowThrows(); +} - AssertionResult ResultBuilder::build() const - { - assert( m_data.resultType != ResultWas::Unknown ); +AssertionResult ResultBuilder::build() const { + assert(m_data.resultType != ResultWas::Unknown); - AssertionResultData data = m_data; + AssertionResultData data = m_data; - // Flip bool results if testFalse is set - if( m_exprComponents.testFalse ) { - if( data.resultType == ResultWas::Ok ) - data.resultType = ResultWas::ExpressionFailed; - else if( data.resultType == ResultWas::ExpressionFailed ) - data.resultType = ResultWas::Ok; - } + // Flip bool results if testFalse is set + if (m_exprComponents.testFalse) { + if (data.resultType == ResultWas::Ok) + data.resultType = ResultWas::ExpressionFailed; + else if (data.resultType == ResultWas::ExpressionFailed) + data.resultType = ResultWas::Ok; + } - data.message = m_stream.oss.str(); - data.reconstructedExpression = reconstructExpression(); - if( m_exprComponents.testFalse ) { - if( m_exprComponents.op == "" ) - data.reconstructedExpression = "!" + data.reconstructedExpression; - else - data.reconstructedExpression = "!(" + data.reconstructedExpression + ")"; - } - return AssertionResult( m_assertionInfo, data ); - } - std::string ResultBuilder::reconstructExpression() const { - if( m_exprComponents.op == "" ) - return m_exprComponents.lhs.empty() ? m_assertionInfo.capturedExpression : m_exprComponents.op + m_exprComponents.lhs; - else if( m_exprComponents.op == "matches" ) - return m_exprComponents.lhs + " " + m_exprComponents.rhs; - else if( m_exprComponents.op != "!" ) { - if( m_exprComponents.lhs.size() + m_exprComponents.rhs.size() < 40 && - m_exprComponents.lhs.find("\n") == std::string::npos && - m_exprComponents.rhs.find("\n") == std::string::npos ) - return m_exprComponents.lhs + " " + m_exprComponents.op + " " + m_exprComponents.rhs; - else - return m_exprComponents.lhs + "\n" + m_exprComponents.op + "\n" + m_exprComponents.rhs; - } - else - return "{can't expand - use " + m_assertionInfo.macroName + "_FALSE( " + m_assertionInfo.capturedExpression.substr(1) + " ) instead of " + m_assertionInfo.macroName + "( " + m_assertionInfo.capturedExpression + " ) for better diagnostics}"; - } + data.message = m_stream.oss.str(); + data.reconstructedExpression = reconstructExpression(); + if (m_exprComponents.testFalse) { + if (m_exprComponents.op == "") + data.reconstructedExpression = "!" + data.reconstructedExpression; + else + data.reconstructedExpression = "!(" + data.reconstructedExpression + ")"; + } + return AssertionResult(m_assertionInfo, data); +} +std::string ResultBuilder::reconstructExpression() const { + if (m_exprComponents.op == "") + return m_exprComponents.lhs.empty() + ? m_assertionInfo.capturedExpression + : m_exprComponents.op + m_exprComponents.lhs; + else if (m_exprComponents.op == "matches") + return m_exprComponents.lhs + " " + m_exprComponents.rhs; + else if (m_exprComponents.op != "!") { + if (m_exprComponents.lhs.size() + m_exprComponents.rhs.size() < 40 && + m_exprComponents.lhs.find("\n") == std::string::npos && + m_exprComponents.rhs.find("\n") == std::string::npos) + return m_exprComponents.lhs + " " + m_exprComponents.op + " " + + m_exprComponents.rhs; + else + return m_exprComponents.lhs + "\n" + m_exprComponents.op + "\n" + + m_exprComponents.rhs; + } else + return "{can't expand - use " + m_assertionInfo.macroName + "_FALSE( " + + m_assertionInfo.capturedExpression.substr(1) + " ) instead of " + + m_assertionInfo.macroName + "( " + + m_assertionInfo.capturedExpression + " ) for better diagnostics}"; +} } // end namespace Catch @@ -8318,85 +8361,92 @@ namespace Catch { namespace Catch { - class TagAliasRegistry : public ITagAliasRegistry { - public: - virtual ~TagAliasRegistry(); - virtual Option find( std::string const& alias ) const; - virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const; - void add( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - static TagAliasRegistry& get(); +class TagAliasRegistry : public ITagAliasRegistry { +public: + virtual ~TagAliasRegistry(); + virtual Option find(std::string const &alias) const; + virtual std::string + expandAliases(std::string const &unexpandedTestSpec) const; + void add(char const *alias, char const *tag, SourceLineInfo const &lineInfo); + static TagAliasRegistry &get(); - private: - std::map m_registry; - }; +private: + std::map m_registry; +}; } // end namespace Catch -#include #include +#include namespace Catch { - TagAliasRegistry::~TagAliasRegistry() {} +TagAliasRegistry::~TagAliasRegistry() {} - Option TagAliasRegistry::find( std::string const& alias ) const { - std::map::const_iterator it = m_registry.find( alias ); - if( it != m_registry.end() ) - return it->second; - else - return Option(); - } - - std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const { - std::string expandedTestSpec = unexpandedTestSpec; - for( std::map::const_iterator it = m_registry.begin(), itEnd = m_registry.end(); - it != itEnd; - ++it ) { - std::size_t pos = expandedTestSpec.find( it->first ); - if( pos != std::string::npos ) { - expandedTestSpec = expandedTestSpec.substr( 0, pos ) + - it->second.tag + - expandedTestSpec.substr( pos + it->first.size() ); - } - } - return expandedTestSpec; - } +Option TagAliasRegistry::find(std::string const &alias) const { + std::map::const_iterator it = m_registry.find(alias); + if (it != m_registry.end()) + return it->second; + else + return Option(); +} - void TagAliasRegistry::add( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) { +std::string +TagAliasRegistry::expandAliases(std::string const &unexpandedTestSpec) const { + std::string expandedTestSpec = unexpandedTestSpec; + for (std::map::const_iterator it = m_registry.begin(), + itEnd = m_registry.end(); + it != itEnd; ++it) { + std::size_t pos = expandedTestSpec.find(it->first); + if (pos != std::string::npos) { + expandedTestSpec = expandedTestSpec.substr(0, pos) + it->second.tag + + expandedTestSpec.substr(pos + it->first.size()); + } + } + return expandedTestSpec; +} - if( !startsWith( alias, "[@" ) || !endsWith( alias, "]" ) ) { - std::ostringstream oss; - oss << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" << lineInfo; - throw std::domain_error( oss.str().c_str() ); - } - if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) { - std::ostringstream oss; - oss << "error: tag alias, \"" << alias << "\" already registered.\n" - << "\tFirst seen at " << find(alias)->lineInfo << "\n" - << "\tRedefined at " << lineInfo; - throw std::domain_error( oss.str().c_str() ); - } - } +void TagAliasRegistry::add(char const *alias, char const *tag, + SourceLineInfo const &lineInfo) { - TagAliasRegistry& TagAliasRegistry::get() { - static TagAliasRegistry instance; - return instance; + if (!startsWith(alias, "[@") || !endsWith(alias, "]")) { + std::ostringstream oss; + oss << "error: tag alias, \"" << alias + << "\" is not of the form [@alias name].\n" + << lineInfo; + throw std::domain_error(oss.str().c_str()); + } + if (!m_registry.insert(std::make_pair(alias, TagAlias(tag, lineInfo))) + .second) { + std::ostringstream oss; + oss << "error: tag alias, \"" << alias << "\" already registered.\n" + << "\tFirst seen at " << find(alias)->lineInfo << "\n" + << "\tRedefined at " << lineInfo; + throw std::domain_error(oss.str().c_str()); + } +} - } +TagAliasRegistry &TagAliasRegistry::get() { + static TagAliasRegistry instance; + return instance; +} - ITagAliasRegistry::~ITagAliasRegistry() {} - ITagAliasRegistry const& ITagAliasRegistry::get() { return TagAliasRegistry::get(); } +ITagAliasRegistry::~ITagAliasRegistry() {} +ITagAliasRegistry const &ITagAliasRegistry::get() { + return TagAliasRegistry::get(); +} - RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) { - try { - TagAliasRegistry::get().add( alias, tag, lineInfo ); - } - catch( std::exception& ex ) { - Colour colourGuard( Colour::Red ); - Catch::cerr() << ex.what() << std::endl; - exit(1); - } - } +RegistrarForTagAliases::RegistrarForTagAliases(char const *alias, + char const *tag, + SourceLineInfo const &lineInfo) { + try { + TagAliasRegistry::get().add(alias, tag, lineInfo); + } catch (std::exception &ex) { + Colour colourGuard(Colour::Red); + Catch::cerr() << ex.what() << std::endl; + exit(1); + } +} } // end namespace Catch @@ -8406,127 +8456,131 @@ namespace Catch { namespace Catch { class MultipleReporters : public SharedImpl { - typedef std::vector > Reporters; - Reporters m_reporters; + typedef std::vector> Reporters; + Reporters m_reporters; public: - void add( Ptr const& reporter ) { - m_reporters.push_back( reporter ); - } + void add(Ptr const &reporter) { + m_reporters.push_back(reporter); + } public: // IStreamingReporter - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporters[0]->getPreferences(); - } - - virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->noMatchingTestCases( spec ); - } - - virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testRunStarting( testRunInfo ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testGroupStarting( groupInfo ); - } - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testCaseStarting( testInfo ); - } - - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->sectionStarting( sectionInfo ); - } - - virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->assertionStarting( assertionInfo ); - } - - // The return value indicates if the messages buffer should be cleared: - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - bool clearBuffer = false; - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - clearBuffer |= (*it)->assertionEnded( assertionStats ); - return clearBuffer; - } - - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->sectionEnded( sectionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testCaseEnded( testCaseStats ); - } - - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testGroupEnded( testGroupStats ); - } - - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testRunEnded( testRunStats ); - } - - virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->skipTest( testInfo ); - } + virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { + return m_reporters[0]->getPreferences(); + } + + virtual void noMatchingTestCases(std::string const &spec) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->noMatchingTestCases(spec); + } + + virtual void testRunStarting(TestRunInfo const &testRunInfo) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->testRunStarting(testRunInfo); + } + + virtual void testGroupStarting(GroupInfo const &groupInfo) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->testGroupStarting(groupInfo); + } + + virtual void testCaseStarting(TestCaseInfo const &testInfo) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->testCaseStarting(testInfo); + } + + virtual void sectionStarting(SectionInfo const §ionInfo) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->sectionStarting(sectionInfo); + } + + virtual void + assertionStarting(AssertionInfo const &assertionInfo) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->assertionStarting(assertionInfo); + } + + // The return value indicates if the messages buffer should be cleared: + virtual bool + assertionEnded(AssertionStats const &assertionStats) CATCH_OVERRIDE { + bool clearBuffer = false; + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + clearBuffer |= (*it)->assertionEnded(assertionStats); + return clearBuffer; + } + + virtual void sectionEnded(SectionStats const §ionStats) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->sectionEnded(sectionStats); + } + + virtual void + testCaseEnded(TestCaseStats const &testCaseStats) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->testCaseEnded(testCaseStats); + } + + virtual void + testGroupEnded(TestGroupStats const &testGroupStats) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->testGroupEnded(testGroupStats); + } + + virtual void testRunEnded(TestRunStats const &testRunStats) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->testRunEnded(testRunStats); + } + + virtual void skipTest(TestCaseInfo const &testInfo) CATCH_OVERRIDE { + for (Reporters::const_iterator it = m_reporters.begin(), + itEnd = m_reporters.end(); + it != itEnd; ++it) + (*it)->skipTest(testInfo); + } }; -Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ) { - Ptr resultingReporter; - - if( existingReporter ) { - MultipleReporters* multi = dynamic_cast( existingReporter.get() ); - if( !multi ) { - multi = new MultipleReporters; - resultingReporter = Ptr( multi ); - if( existingReporter ) - multi->add( existingReporter ); - } - else - resultingReporter = existingReporter; - multi->add( additionalReporter ); - } - else - resultingReporter = additionalReporter; - - return resultingReporter; +Ptr +addReporter(Ptr const &existingReporter, + Ptr const &additionalReporter) { + Ptr resultingReporter; + + if (existingReporter) { + MultipleReporters *multi = + dynamic_cast(existingReporter.get()); + if (!multi) { + multi = new MultipleReporters; + resultingReporter = Ptr(multi); + if (existingReporter) + multi->add(existingReporter); + } else + resultingReporter = existingReporter; + multi->add(additionalReporter); + } else + resultingReporter = additionalReporter; + + return resultingReporter; } } // end namespace Catch @@ -8541,1378 +8595,1369 @@ Ptr addReporter( Ptr const& existingRepo namespace Catch { - struct StreamingReporterBase : SharedImpl { - - StreamingReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - { - m_reporterPrefs.shouldRedirectStdOut = false; - } - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporterPrefs; - } - - virtual ~StreamingReporterBase() CATCH_OVERRIDE; - - virtual void noMatchingTestCases( std::string const& ) CATCH_OVERRIDE {} - - virtual void testRunStarting( TestRunInfo const& _testRunInfo ) CATCH_OVERRIDE { - currentTestRunInfo = _testRunInfo; - } - virtual void testGroupStarting( GroupInfo const& _groupInfo ) CATCH_OVERRIDE { - currentGroupInfo = _groupInfo; - } - - virtual void testCaseStarting( TestCaseInfo const& _testInfo ) CATCH_OVERRIDE { - currentTestCaseInfo = _testInfo; - } - virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE { - m_sectionStack.push_back( _sectionInfo ); - } - - virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) CATCH_OVERRIDE { - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) CATCH_OVERRIDE { - currentTestCaseInfo.reset(); - } - virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) CATCH_OVERRIDE { - currentGroupInfo.reset(); - } - virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) CATCH_OVERRIDE { - currentTestCaseInfo.reset(); - currentGroupInfo.reset(); - currentTestRunInfo.reset(); - } - - virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE { - // Don't do anything with this by default. - // It can optionally be overridden in the derived class. - } - - Ptr m_config; - std::ostream& stream; - - LazyStat currentTestRunInfo; - LazyStat currentGroupInfo; - LazyStat currentTestCaseInfo; - - std::vector m_sectionStack; - ReporterPreferences m_reporterPrefs; - }; - - struct CumulativeReporterBase : SharedImpl { - template - struct Node : SharedImpl<> { - explicit Node( T const& _value ) : value( _value ) {} - virtual ~Node() {} - - typedef std::vector > ChildNodes; - T value; - ChildNodes children; - }; - struct SectionNode : SharedImpl<> { - explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {} - virtual ~SectionNode(); - - bool operator == ( SectionNode const& other ) const { - return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; - } - bool operator == ( Ptr const& other ) const { - return operator==( *other ); - } - - SectionStats stats; - typedef std::vector > ChildSections; - typedef std::vector Assertions; - ChildSections childSections; - Assertions assertions; - std::string stdOut; - std::string stdErr; - }; - - struct BySectionInfo { - BySectionInfo( SectionInfo const& other ) : m_other( other ) {} - BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} - bool operator() ( Ptr const& node ) const { - return node->stats.sectionInfo.lineInfo == m_other.lineInfo; - } - private: - void operator=( BySectionInfo const& ); - SectionInfo const& m_other; - }; - - typedef Node TestCaseNode; - typedef Node TestGroupNode; - typedef Node TestRunNode; - - CumulativeReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - { - m_reporterPrefs.shouldRedirectStdOut = false; - } - ~CumulativeReporterBase(); - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporterPrefs; - } - - virtual void testRunStarting( TestRunInfo const& ) CATCH_OVERRIDE {} - virtual void testGroupStarting( GroupInfo const& ) CATCH_OVERRIDE {} - - virtual void testCaseStarting( TestCaseInfo const& ) CATCH_OVERRIDE {} - - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); - Ptr node; - if( m_sectionStack.empty() ) { - if( !m_rootSection ) - m_rootSection = new SectionNode( incompleteStats ); - node = m_rootSection; - } - else { - SectionNode& parentNode = *m_sectionStack.back(); - SectionNode::ChildSections::const_iterator it = - std::find_if( parentNode.childSections.begin(), - parentNode.childSections.end(), - BySectionInfo( sectionInfo ) ); - if( it == parentNode.childSections.end() ) { - node = new SectionNode( incompleteStats ); - parentNode.childSections.push_back( node ); - } - else - node = *it; - } - m_sectionStack.push_back( node ); - m_deepestSection = node; - } - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} - - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - assert( !m_sectionStack.empty() ); - SectionNode& sectionNode = *m_sectionStack.back(); - sectionNode.assertions.push_back( assertionStats ); - return true; - } - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - assert( !m_sectionStack.empty() ); - SectionNode& node = *m_sectionStack.back(); - node.stats = sectionStats; - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - Ptr node = new TestCaseNode( testCaseStats ); - assert( m_sectionStack.size() == 0 ); - node->children.push_back( m_rootSection ); - m_testCases.push_back( node ); - m_rootSection.reset(); - - assert( m_deepestSection ); - m_deepestSection->stdOut = testCaseStats.stdOut; - m_deepestSection->stdErr = testCaseStats.stdErr; - } - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - Ptr node = new TestGroupNode( testGroupStats ); - node->children.swap( m_testCases ); - m_testGroups.push_back( node ); - } - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - Ptr node = new TestRunNode( testRunStats ); - node->children.swap( m_testGroups ); - m_testRuns.push_back( node ); - testRunEndedCumulative(); - } - virtual void testRunEndedCumulative() = 0; - - virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {} - - Ptr m_config; - std::ostream& stream; - std::vector m_assertions; - std::vector > > m_sections; - std::vector > m_testCases; - std::vector > m_testGroups; - - std::vector > m_testRuns; +struct StreamingReporterBase : SharedImpl { + + StreamingReporterBase(ReporterConfig const &_config) + : m_config(_config.fullConfig()), stream(_config.stream()) { + m_reporterPrefs.shouldRedirectStdOut = false; + } + + virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { + return m_reporterPrefs; + } + + virtual ~StreamingReporterBase() CATCH_OVERRIDE; + + virtual void noMatchingTestCases(std::string const &) CATCH_OVERRIDE {} + + virtual void testRunStarting(TestRunInfo const &_testRunInfo) CATCH_OVERRIDE { + currentTestRunInfo = _testRunInfo; + } + virtual void testGroupStarting(GroupInfo const &_groupInfo) CATCH_OVERRIDE { + currentGroupInfo = _groupInfo; + } + + virtual void testCaseStarting(TestCaseInfo const &_testInfo) CATCH_OVERRIDE { + currentTestCaseInfo = _testInfo; + } + virtual void sectionStarting(SectionInfo const &_sectionInfo) CATCH_OVERRIDE { + m_sectionStack.push_back(_sectionInfo); + } + + virtual void + sectionEnded(SectionStats const & /* _sectionStats */) CATCH_OVERRIDE { + m_sectionStack.pop_back(); + } + virtual void + testCaseEnded(TestCaseStats const & /* _testCaseStats */) CATCH_OVERRIDE { + currentTestCaseInfo.reset(); + } + virtual void + testGroupEnded(TestGroupStats const & /* _testGroupStats */) CATCH_OVERRIDE { + currentGroupInfo.reset(); + } + virtual void + testRunEnded(TestRunStats const & /* _testRunStats */) CATCH_OVERRIDE { + currentTestCaseInfo.reset(); + currentGroupInfo.reset(); + currentTestRunInfo.reset(); + } + + virtual void skipTest(TestCaseInfo const &) CATCH_OVERRIDE { + // Don't do anything with this by default. + // It can optionally be overridden in the derived class. + } + + Ptr m_config; + std::ostream &stream; + + LazyStat currentTestRunInfo; + LazyStat currentGroupInfo; + LazyStat currentTestCaseInfo; + + std::vector m_sectionStack; + ReporterPreferences m_reporterPrefs; +}; - Ptr m_rootSection; - Ptr m_deepestSection; - std::vector > m_sectionStack; - ReporterPreferences m_reporterPrefs; +struct CumulativeReporterBase : SharedImpl { + template struct Node : SharedImpl<> { + explicit Node(T const &_value) : value(_value) {} + virtual ~Node() {} - }; + typedef std::vector> ChildNodes; + T value; + ChildNodes children; + }; + struct SectionNode : SharedImpl<> { + explicit SectionNode(SectionStats const &_stats) : stats(_stats) {} + virtual ~SectionNode(); - template - char const* getLineOfChars() { - static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; - if( !*line ) { - memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); - line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; - } - return line; + bool operator==(SectionNode const &other) const { + return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; + } + bool operator==(Ptr const &other) const { + return operator==(*other); } - struct TestEventListenerBase : StreamingReporterBase { - TestEventListenerBase( ReporterConfig const& _config ) - : StreamingReporterBase( _config ) - {} - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} - virtual bool assertionEnded( AssertionStats const& ) CATCH_OVERRIDE { - return false; - } - }; - -} // end namespace Catch - -// #included from: ../internal/catch_reporter_registrars.hpp -#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED - -namespace Catch { - - template - class LegacyReporterRegistrar { - - class ReporterFactory : public IReporterFactory { - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new LegacyReporterAdapter( new T( config ) ); - } - - virtual std::string getDescription() const { - return T::getDescription(); - } - }; - - public: - - LegacyReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); - } - }; - - template - class ReporterRegistrar { - - class ReporterFactory : public SharedImpl { - - // *** Please Note ***: - // - If you end up here looking at a compiler error because it's trying to register - // your custom reporter class be aware that the native reporter interface has changed - // to IStreamingReporter. The "legacy" interface, IReporter, is still supported via - // an adapter. Just use REGISTER_LEGACY_REPORTER to take advantage of the adapter. - // However please consider updating to the new interface as the old one is now - // deprecated and will probably be removed quite soon! - // Please contact me via github if you have any questions at all about this. - // In fact, ideally, please contact me anyway to let me know you've hit this - as I have - // no idea who is actually using custom reporters at all (possibly no-one!). - // The new interface is designed to minimise exposure to interface changes in the future. - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new T( config ); - } - - virtual std::string getDescription() const { - return T::getDescription(); - } - }; - - public: - - ReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); - } - }; - - template - class ListenerRegistrar { - - class ListenerFactory : public SharedImpl { - - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new T( config ); - } - virtual std::string getDescription() const { - return ""; - } - }; - - public: - - ListenerRegistrar() { - getMutableRegistryHub().registerListener( new ListenerFactory() ); - } - }; -} - -#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \ - namespace{ Catch::LegacyReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } - -#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \ - namespace{ Catch::ReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } - -#define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \ - namespace{ Catch::ListenerRegistrar catch_internal_RegistrarFor##listenerType; } - -// #included from: ../internal/catch_xmlwriter.hpp -#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - class XmlEncode { - public: - enum ForWhat { ForTextNodes, ForAttributes }; - - XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ) - : m_str( str ), - m_forWhat( forWhat ) - {} - - void encodeTo( std::ostream& os ) const { - - // Apostrophe escaping not necessary if we always use " to write attributes - // (see: http://www.w3.org/TR/xml/#syntax) - - for( std::size_t i = 0; i < m_str.size(); ++ i ) { - char c = m_str[i]; - switch( c ) { - case '<': os << "<"; break; - case '&': os << "&"; break; - - case '>': - // See: http://www.w3.org/TR/xml/#syntax - if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' ) - os << ">"; - else - os << c; - break; - - case '\"': - if( m_forWhat == ForAttributes ) - os << """; - else - os << c; - break; - - default: - // Escape control chars - based on contribution by @espenalb in PR #465 - if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) - os << "&#x" << std::uppercase << std::hex << static_cast( c ); - else - os << c; - } - } - } - - friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { - xmlEncode.encodeTo( os ); - return os; - } - - private: - std::string m_str; - ForWhat m_forWhat; - }; - - class XmlWriter { - public: - - class ScopedElement { - public: - ScopedElement( XmlWriter* writer ) - : m_writer( writer ) - {} - - ScopedElement( ScopedElement const& other ) - : m_writer( other.m_writer ){ - other.m_writer = CATCH_NULL; - } - - ~ScopedElement() { - if( m_writer ) - m_writer->endElement(); - } - - ScopedElement& writeText( std::string const& text, bool indent = true ) { - m_writer->writeText( text, indent ); - return *this; - } - - template - ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { - m_writer->writeAttribute( name, attribute ); - return *this; - } - - private: - mutable XmlWriter* m_writer; - }; - - XmlWriter() - : m_tagIsOpen( false ), - m_needsNewline( false ), - m_os( &Catch::cout() ) - {} - - XmlWriter( std::ostream& os ) - : m_tagIsOpen( false ), - m_needsNewline( false ), - m_os( &os ) - {} - - ~XmlWriter() { - while( !m_tags.empty() ) - endElement(); - } - - XmlWriter& startElement( std::string const& name ) { - ensureTagClosed(); - newlineIfNecessary(); - stream() << m_indent << "<" << name; - m_tags.push_back( name ); - m_indent += " "; - m_tagIsOpen = true; - return *this; - } - - ScopedElement scopedElement( std::string const& name ) { - ScopedElement scoped( this ); - startElement( name ); - return scoped; - } - - XmlWriter& endElement() { - newlineIfNecessary(); - m_indent = m_indent.substr( 0, m_indent.size()-2 ); - if( m_tagIsOpen ) { - stream() << "/>\n"; - m_tagIsOpen = false; - } - else { - stream() << m_indent << "\n"; - } - m_tags.pop_back(); - return *this; - } - - XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) { - if( !name.empty() && !attribute.empty() ) - stream() << " " << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << "\""; - return *this; - } - - XmlWriter& writeAttribute( std::string const& name, bool attribute ) { - stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\""; - return *this; - } - - template - XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { - std::ostringstream oss; - oss << attribute; - return writeAttribute( name, oss.str() ); - } - - XmlWriter& writeText( std::string const& text, bool indent = true ) { - if( !text.empty() ){ - bool tagWasOpen = m_tagIsOpen; - ensureTagClosed(); - if( tagWasOpen && indent ) - stream() << m_indent; - stream() << XmlEncode( text ); - m_needsNewline = true; - } - return *this; - } - - XmlWriter& writeComment( std::string const& text ) { - ensureTagClosed(); - stream() << m_indent << ""; - m_needsNewline = true; - return *this; - } - - XmlWriter& writeBlankLine() { - ensureTagClosed(); - stream() << "\n"; - return *this; - } - - void setStream( std::ostream& os ) { - m_os = &os; - } - - private: - XmlWriter( XmlWriter const& ); - void operator=( XmlWriter const& ); - - std::ostream& stream() { - return *m_os; - } + SectionStats stats; + typedef std::vector> ChildSections; + typedef std::vector Assertions; + ChildSections childSections; + Assertions assertions; + std::string stdOut; + std::string stdErr; + }; - void ensureTagClosed() { - if( m_tagIsOpen ) { - stream() << ">\n"; - m_tagIsOpen = false; - } - } + struct BySectionInfo { + BySectionInfo(SectionInfo const &other) : m_other(other) {} + BySectionInfo(BySectionInfo const &other) : m_other(other.m_other) {} + bool operator()(Ptr const &node) const { + return node->stats.sectionInfo.lineInfo == m_other.lineInfo; + } - void newlineIfNecessary() { - if( m_needsNewline ) { - stream() << "\n"; - m_needsNewline = false; - } - } + private: + void operator=(BySectionInfo const &); + SectionInfo const &m_other; + }; - bool m_tagIsOpen; - bool m_needsNewline; - std::vector m_tags; - std::string m_indent; - std::ostream* m_os; - }; + typedef Node TestCaseNode; + typedef Node TestGroupNode; + typedef Node TestRunNode; + + CumulativeReporterBase(ReporterConfig const &_config) + : m_config(_config.fullConfig()), stream(_config.stream()) { + m_reporterPrefs.shouldRedirectStdOut = false; + } + ~CumulativeReporterBase(); + + virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { + return m_reporterPrefs; + } + + virtual void testRunStarting(TestRunInfo const &) CATCH_OVERRIDE {} + virtual void testGroupStarting(GroupInfo const &) CATCH_OVERRIDE {} + + virtual void testCaseStarting(TestCaseInfo const &) CATCH_OVERRIDE {} + + virtual void sectionStarting(SectionInfo const §ionInfo) CATCH_OVERRIDE { + SectionStats incompleteStats(sectionInfo, Counts(), 0, false); + Ptr node; + if (m_sectionStack.empty()) { + if (!m_rootSection) + m_rootSection = new SectionNode(incompleteStats); + node = m_rootSection; + } else { + SectionNode &parentNode = *m_sectionStack.back(); + SectionNode::ChildSections::const_iterator it = std::find_if( + parentNode.childSections.begin(), parentNode.childSections.end(), + BySectionInfo(sectionInfo)); + if (it == parentNode.childSections.end()) { + node = new SectionNode(incompleteStats); + parentNode.childSections.push_back(node); + } else + node = *it; + } + m_sectionStack.push_back(node); + m_deepestSection = node; + } + + virtual void assertionStarting(AssertionInfo const &) CATCH_OVERRIDE {} + + virtual bool + assertionEnded(AssertionStats const &assertionStats) CATCH_OVERRIDE { + assert(!m_sectionStack.empty()); + SectionNode §ionNode = *m_sectionStack.back(); + sectionNode.assertions.push_back(assertionStats); + return true; + } + virtual void sectionEnded(SectionStats const §ionStats) CATCH_OVERRIDE { + assert(!m_sectionStack.empty()); + SectionNode &node = *m_sectionStack.back(); + node.stats = sectionStats; + m_sectionStack.pop_back(); + } + virtual void + testCaseEnded(TestCaseStats const &testCaseStats) CATCH_OVERRIDE { + Ptr node = new TestCaseNode(testCaseStats); + assert(m_sectionStack.size() == 0); + node->children.push_back(m_rootSection); + m_testCases.push_back(node); + m_rootSection.reset(); + + assert(m_deepestSection); + m_deepestSection->stdOut = testCaseStats.stdOut; + m_deepestSection->stdErr = testCaseStats.stdErr; + } + virtual void + testGroupEnded(TestGroupStats const &testGroupStats) CATCH_OVERRIDE { + Ptr node = new TestGroupNode(testGroupStats); + node->children.swap(m_testCases); + m_testGroups.push_back(node); + } + virtual void testRunEnded(TestRunStats const &testRunStats) CATCH_OVERRIDE { + Ptr node = new TestRunNode(testRunStats); + node->children.swap(m_testGroups); + m_testRuns.push_back(node); + testRunEndedCumulative(); + } + virtual void testRunEndedCumulative() = 0; + + virtual void skipTest(TestCaseInfo const &) CATCH_OVERRIDE {} + + Ptr m_config; + std::ostream &stream; + std::vector m_assertions; + std::vector>> m_sections; + std::vector> m_testCases; + std::vector> m_testGroups; + + std::vector> m_testRuns; + + Ptr m_rootSection; + Ptr m_deepestSection; + std::vector> m_sectionStack; + ReporterPreferences m_reporterPrefs; +}; +template char const *getLineOfChars() { + static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; + if (!*line) { + memset(line, C, CATCH_CONFIG_CONSOLE_WIDTH - 1); + line[CATCH_CONFIG_CONSOLE_WIDTH - 1] = 0; + } + return line; } -// #included from: catch_reenable_warnings.h - -#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(pop) -# else -# pragma clang diagnostic pop -# endif -#elif defined __GNUC__ -# pragma GCC diagnostic pop -#endif +struct TestEventListenerBase : StreamingReporterBase { + TestEventListenerBase(ReporterConfig const &_config) + : StreamingReporterBase(_config) {} + virtual void assertionStarting(AssertionInfo const &) CATCH_OVERRIDE {} + virtual bool assertionEnded(AssertionStats const &) CATCH_OVERRIDE { + return false; + } +}; -namespace Catch { - class XmlReporter : public StreamingReporterBase { - public: - XmlReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - m_sectionDepth( 0 ) - { - m_reporterPrefs.shouldRedirectStdOut = true; - } - - virtual ~XmlReporter() CATCH_OVERRIDE; - - static std::string getDescription() { - return "Reports test results as an XML document"; - } - - public: // StreamingReporterBase - - virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE { - StreamingReporterBase::noMatchingTestCases( s ); - } - - virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testRunStarting( testInfo ); - m_xml.setStream( stream ); - m_xml.startElement( "Catch" ); - if( !m_config->name().empty() ) - m_xml.writeAttribute( "name", m_config->name() ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testGroupStarting( groupInfo ); - m_xml.startElement( "Group" ) - .writeAttribute( "name", groupInfo.name ); - } - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseStarting(testInfo); - m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) ); +} // end namespace Catch - if ( m_config->showDurations() == ShowDurations::Always ) - m_testCaseTimer.start(); - } +// #included from: ../internal/catch_reporter_registrars.hpp +#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - StreamingReporterBase::sectionStarting( sectionInfo ); - if( m_sectionDepth++ > 0 ) { - m_xml.startElement( "Section" ) - .writeAttribute( "name", trim( sectionInfo.name ) ) - .writeAttribute( "description", sectionInfo.description ); - } - } +namespace Catch { - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { } - - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - const AssertionResult& assertionResult = assertionStats.assertionResult; - - // Print any info messages in tags. - if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { - for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); - it != itEnd; - ++it ) { - if( it->type == ResultWas::Info ) { - m_xml.scopedElement( "Info" ) - .writeText( it->message ); - } else if ( it->type == ResultWas::Warning ) { - m_xml.scopedElement( "Warning" ) - .writeText( it->message ); - } - } - } +template class LegacyReporterRegistrar { - // Drop out if result was successful but we're not printing them. - if( !m_config->includeSuccessfulResults() && isOk(assertionResult.getResultType()) ) - return true; - - // Print the expression if there is one. - if( assertionResult.hasExpression() ) { - m_xml.startElement( "Expression" ) - .writeAttribute( "success", assertionResult.succeeded() ) - .writeAttribute( "type", assertionResult.getTestMacroName() ) - .writeAttribute( "filename", assertionResult.getSourceInfo().file ) - .writeAttribute( "line", assertionResult.getSourceInfo().line ); - - m_xml.scopedElement( "Original" ) - .writeText( assertionResult.getExpression() ); - m_xml.scopedElement( "Expanded" ) - .writeText( assertionResult.getExpandedExpression() ); - } + class ReporterFactory : public IReporterFactory { + virtual IStreamingReporter *create(ReporterConfig const &config) const { + return new LegacyReporterAdapter(new T(config)); + } - // And... Print a result applicable to each result type. - switch( assertionResult.getResultType() ) { - case ResultWas::ThrewException: - m_xml.scopedElement( "Exception" ) - .writeAttribute( "filename", assertionResult.getSourceInfo().file ) - .writeAttribute( "line", assertionResult.getSourceInfo().line ) - .writeText( assertionResult.getMessage() ); - break; - case ResultWas::FatalErrorCondition: - m_xml.scopedElement( "Fatal Error Condition" ) - .writeAttribute( "filename", assertionResult.getSourceInfo().file ) - .writeAttribute( "line", assertionResult.getSourceInfo().line ) - .writeText( assertionResult.getMessage() ); - break; - case ResultWas::Info: - m_xml.scopedElement( "Info" ) - .writeText( assertionResult.getMessage() ); - break; - case ResultWas::Warning: - // Warning will already have been written - break; - case ResultWas::ExplicitFailure: - m_xml.scopedElement( "Failure" ) - .writeText( assertionResult.getMessage() ); - break; - default: - break; - } + virtual std::string getDescription() const { return T::getDescription(); } + }; - if( assertionResult.hasExpression() ) - m_xml.endElement(); +public: + LegacyReporterRegistrar(std::string const &name) { + getMutableRegistryHub().registerReporter(name, new ReporterFactory()); + } +}; - return true; - } +template class ReporterRegistrar { - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - StreamingReporterBase::sectionEnded( sectionStats ); - if( --m_sectionDepth > 0 ) { - XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); - e.writeAttribute( "successes", sectionStats.assertions.passed ); - e.writeAttribute( "failures", sectionStats.assertions.failed ); - e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk ); + class ReporterFactory : public SharedImpl { - if ( m_config->showDurations() == ShowDurations::Always ) - e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds ); + // *** Please Note ***: + // - If you end up here looking at a compiler error because it's trying to + // register your custom reporter class be aware that the native reporter + // interface has changed to IStreamingReporter. The "legacy" interface, + // IReporter, is still supported via an adapter. Just use + // REGISTER_LEGACY_REPORTER to take advantage of the adapter. However please + // consider updating to the new interface as the old one is now deprecated + // and will probably be removed quite soon! Please contact me via github if + // you have any questions at all about this. In fact, ideally, please + // contact me anyway to let me know you've hit this - as I have no idea who + // is actually using custom reporters at all (possibly no-one!). The new + // interface is designed to minimise exposure to interface changes in the + // future. + virtual IStreamingReporter *create(ReporterConfig const &config) const { + return new T(config); + } - m_xml.endElement(); - } - } + virtual std::string getDescription() const { return T::getDescription(); } + }; - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseEnded( testCaseStats ); - XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); - e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); +public: + ReporterRegistrar(std::string const &name) { + getMutableRegistryHub().registerReporter(name, new ReporterFactory()); + } +}; - if ( m_config->showDurations() == ShowDurations::Always ) - e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); +template class ListenerRegistrar { - m_xml.endElement(); - } + class ListenerFactory : public SharedImpl { - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - StreamingReporterBase::testGroupEnded( testGroupStats ); - // TODO: Check testGroupStats.aborting and act accordingly. - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", testGroupStats.totals.assertions.passed ) - .writeAttribute( "failures", testGroupStats.totals.assertions.failed ) - .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); - m_xml.endElement(); - } + virtual IStreamingReporter *create(ReporterConfig const &config) const { + return new T(config); + } + virtual std::string getDescription() const { return ""; } + }; - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - StreamingReporterBase::testRunEnded( testRunStats ); - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", testRunStats.totals.assertions.passed ) - .writeAttribute( "failures", testRunStats.totals.assertions.failed ) - .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); - m_xml.endElement(); - } +public: + ListenerRegistrar() { + getMutableRegistryHub().registerListener(new ListenerFactory()); + } +}; +} // namespace Catch - private: - Timer m_testCaseTimer; - XmlWriter m_xml; - int m_sectionDepth; - }; +#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER(name, reporterType) \ + namespace { \ + Catch::LegacyReporterRegistrar \ + catch_internal_RegistrarFor##reporterType(name); \ + } - INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter ) +#define INTERNAL_CATCH_REGISTER_REPORTER(name, reporterType) \ + namespace { \ + Catch::ReporterRegistrar \ + catch_internal_RegistrarFor##reporterType(name); \ + } -} // end namespace Catch +#define INTERNAL_CATCH_REGISTER_LISTENER(listenerType) \ + namespace { \ + Catch::ListenerRegistrar \ + catch_internal_RegistrarFor##listenerType; \ + } -// #included from: ../reporters/catch_reporter_junit.hpp -#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED +// #included from: ../internal/catch_xmlwriter.hpp +#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED -#include +#include +#include +#include +#include namespace Catch { - class JunitReporter : public CumulativeReporterBase { - public: - JunitReporter( ReporterConfig const& _config ) - : CumulativeReporterBase( _config ), - xml( _config.stream() ) - { - m_reporterPrefs.shouldRedirectStdOut = true; - } - - virtual ~JunitReporter() CATCH_OVERRIDE; +class XmlEncode { +public: + enum ForWhat { ForTextNodes, ForAttributes }; + + XmlEncode(std::string const &str, ForWhat forWhat = ForTextNodes) + : m_str(str), m_forWhat(forWhat) {} + + void encodeTo(std::ostream &os) const { + + // Apostrophe escaping not necessary if we always use " to write attributes + // (see: http://www.w3.org/TR/xml/#syntax) + + for (std::size_t i = 0; i < m_str.size(); ++i) { + char c = m_str[i]; + switch (c) { + case '<': + os << "<"; + break; + case '&': + os << "&"; + break; + + case '>': + // See: http://www.w3.org/TR/xml/#syntax + if (i > 2 && m_str[i - 1] == ']' && m_str[i - 2] == ']') + os << ">"; + else + os << c; + break; - static std::string getDescription() { - return "Reports test results in an XML format that looks like Ant's junitreport target"; - } + case '\"': + if (m_forWhat == ForAttributes) + os << """; + else + os << c; + break; - virtual void noMatchingTestCases( std::string const& /*spec*/ ) CATCH_OVERRIDE {} + default: + // Escape control chars - based on contribution by @espenalb in PR #465 + if ((c < '\x09') || (c > '\x0D' && c < '\x20') || c == '\x7F') + os << "&#x" << std::uppercase << std::hex << static_cast(c); + else + os << c; + } + } + } - virtual void testRunStarting( TestRunInfo const& runInfo ) CATCH_OVERRIDE { - CumulativeReporterBase::testRunStarting( runInfo ); - xml.startElement( "testsuites" ); - } + friend std::ostream &operator<<(std::ostream &os, + XmlEncode const &xmlEncode) { + xmlEncode.encodeTo(os); + return os; + } - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - suiteTimer.start(); - stdOutForSuite.str(""); - stdErrForSuite.str(""); - unexpectedExceptions = 0; - CumulativeReporterBase::testGroupStarting( groupInfo ); - } +private: + std::string m_str; + ForWhat m_forWhat; +}; - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException ) - unexpectedExceptions++; - return CumulativeReporterBase::assertionEnded( assertionStats ); - } +class XmlWriter { +public: + class ScopedElement { + public: + ScopedElement(XmlWriter *writer) : m_writer(writer) {} - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - stdOutForSuite << testCaseStats.stdOut; - stdErrForSuite << testCaseStats.stdErr; - CumulativeReporterBase::testCaseEnded( testCaseStats ); - } + ScopedElement(ScopedElement const &other) : m_writer(other.m_writer) { + other.m_writer = CATCH_NULL; + } - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - double suiteTime = suiteTimer.getElapsedSeconds(); - CumulativeReporterBase::testGroupEnded( testGroupStats ); - writeGroup( *m_testGroups.back(), suiteTime ); - } + ~ScopedElement() { + if (m_writer) + m_writer->endElement(); + } - virtual void testRunEndedCumulative() CATCH_OVERRIDE { - xml.endElement(); - } + ScopedElement &writeText(std::string const &text, bool indent = true) { + m_writer->writeText(text, indent); + return *this; + } - void writeGroup( TestGroupNode const& groupNode, double suiteTime ) { - XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); - TestGroupStats const& stats = groupNode.value; - xml.writeAttribute( "name", stats.groupInfo.name ); - xml.writeAttribute( "errors", unexpectedExceptions ); - xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); - xml.writeAttribute( "tests", stats.totals.assertions.total() ); - xml.writeAttribute( "hostname", "tbd" ); // !TBD - if( m_config->showDurations() == ShowDurations::Never ) - xml.writeAttribute( "time", "" ); - else - xml.writeAttribute( "time", suiteTime ); - xml.writeAttribute( "timestamp", "tbd" ); // !TBD - - // Write test cases - for( TestGroupNode::ChildNodes::const_iterator - it = groupNode.children.begin(), itEnd = groupNode.children.end(); - it != itEnd; - ++it ) - writeTestCase( **it ); - - xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite.str() ), false ); - xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite.str() ), false ); - } + template + ScopedElement &writeAttribute(std::string const &name, T const &attribute) { + m_writer->writeAttribute(name, attribute); + return *this; + } - void writeTestCase( TestCaseNode const& testCaseNode ) { - TestCaseStats const& stats = testCaseNode.value; + private: + mutable XmlWriter *m_writer; + }; - // All test cases have exactly one section - which represents the - // test case itself. That section may have 0-n nested sections - assert( testCaseNode.children.size() == 1 ); - SectionNode const& rootSection = *testCaseNode.children.front(); + XmlWriter() + : m_tagIsOpen(false), m_needsNewline(false), m_os(&Catch::cout()) {} + + XmlWriter(std::ostream &os) + : m_tagIsOpen(false), m_needsNewline(false), m_os(&os) {} + + ~XmlWriter() { + while (!m_tags.empty()) + endElement(); + } + + XmlWriter &startElement(std::string const &name) { + ensureTagClosed(); + newlineIfNecessary(); + stream() << m_indent << "<" << name; + m_tags.push_back(name); + m_indent += " "; + m_tagIsOpen = true; + return *this; + } + + ScopedElement scopedElement(std::string const &name) { + ScopedElement scoped(this); + startElement(name); + return scoped; + } + + XmlWriter &endElement() { + newlineIfNecessary(); + m_indent = m_indent.substr(0, m_indent.size() - 2); + if (m_tagIsOpen) { + stream() << "/>\n"; + m_tagIsOpen = false; + } else { + stream() << m_indent << "\n"; + } + m_tags.pop_back(); + return *this; + } + + XmlWriter &writeAttribute(std::string const &name, + std::string const &attribute) { + if (!name.empty() && !attribute.empty()) + stream() << " " << name << "=\"" + << XmlEncode(attribute, XmlEncode::ForAttributes) << "\""; + return *this; + } + + XmlWriter &writeAttribute(std::string const &name, bool attribute) { + stream() << " " << name << "=\"" << (attribute ? "true" : "false") << "\""; + return *this; + } + + template + XmlWriter &writeAttribute(std::string const &name, T const &attribute) { + std::ostringstream oss; + oss << attribute; + return writeAttribute(name, oss.str()); + } + + XmlWriter &writeText(std::string const &text, bool indent = true) { + if (!text.empty()) { + bool tagWasOpen = m_tagIsOpen; + ensureTagClosed(); + if (tagWasOpen && indent) + stream() << m_indent; + stream() << XmlEncode(text); + m_needsNewline = true; + } + return *this; + } + + XmlWriter &writeComment(std::string const &text) { + ensureTagClosed(); + stream() << m_indent << ""; + m_needsNewline = true; + return *this; + } + + XmlWriter &writeBlankLine() { + ensureTagClosed(); + stream() << "\n"; + return *this; + } + + void setStream(std::ostream &os) { m_os = &os; } - std::string className = stats.testInfo.className; +private: + XmlWriter(XmlWriter const &); + void operator=(XmlWriter const &); - if( className.empty() ) { - if( rootSection.childSections.empty() ) - className = "global"; - } - writeSection( className, "", rootSection ); - } + std::ostream &stream() { return *m_os; } - void writeSection( std::string const& className, - std::string const& rootName, - SectionNode const& sectionNode ) { - std::string name = trim( sectionNode.stats.sectionInfo.name ); - if( !rootName.empty() ) - name = rootName + "/" + name; - - if( !sectionNode.assertions.empty() || - !sectionNode.stdOut.empty() || - !sectionNode.stdErr.empty() ) { - XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); - if( className.empty() ) { - xml.writeAttribute( "classname", name ); - xml.writeAttribute( "name", "root" ); - } - else { - xml.writeAttribute( "classname", className ); - xml.writeAttribute( "name", name ); - } - xml.writeAttribute( "time", Catch::toString( sectionNode.stats.durationInSeconds ) ); - - writeAssertions( sectionNode ); - - if( !sectionNode.stdOut.empty() ) - xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false ); - if( !sectionNode.stdErr.empty() ) - xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false ); - } - for( SectionNode::ChildSections::const_iterator - it = sectionNode.childSections.begin(), - itEnd = sectionNode.childSections.end(); - it != itEnd; - ++it ) - if( className.empty() ) - writeSection( name, "", **it ); - else - writeSection( className, name, **it ); - } + void ensureTagClosed() { + if (m_tagIsOpen) { + stream() << ">\n"; + m_tagIsOpen = false; + } + } - void writeAssertions( SectionNode const& sectionNode ) { - for( SectionNode::Assertions::const_iterator - it = sectionNode.assertions.begin(), itEnd = sectionNode.assertions.end(); - it != itEnd; - ++it ) - writeAssertion( *it ); - } - void writeAssertion( AssertionStats const& stats ) { - AssertionResult const& result = stats.assertionResult; - if( !result.isOk() ) { - std::string elementName; - switch( result.getResultType() ) { - case ResultWas::ThrewException: - case ResultWas::FatalErrorCondition: - elementName = "error"; - break; - case ResultWas::ExplicitFailure: - elementName = "failure"; - break; - case ResultWas::ExpressionFailed: - elementName = "failure"; - break; - case ResultWas::DidntThrowException: - elementName = "failure"; - break; - - // We should never see these here: - case ResultWas::Info: - case ResultWas::Warning: - case ResultWas::Ok: - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - elementName = "internalError"; - break; - } - - XmlWriter::ScopedElement e = xml.scopedElement( elementName ); - - xml.writeAttribute( "message", result.getExpandedExpression() ); - xml.writeAttribute( "type", result.getTestMacroName() ); - - std::ostringstream oss; - if( !result.getMessage().empty() ) - oss << result.getMessage() << "\n"; - for( std::vector::const_iterator - it = stats.infoMessages.begin(), - itEnd = stats.infoMessages.end(); - it != itEnd; - ++it ) - if( it->type == ResultWas::Info ) - oss << it->message << "\n"; - - oss << "at " << result.getSourceInfo(); - xml.writeText( oss.str(), false ); - } - } + void newlineIfNecessary() { + if (m_needsNewline) { + stream() << "\n"; + m_needsNewline = false; + } + } - XmlWriter xml; - Timer suiteTimer; - std::ostringstream stdOutForSuite; - std::ostringstream stdErrForSuite; - unsigned int unexpectedExceptions; - }; + bool m_tagIsOpen; + bool m_needsNewline; + std::vector m_tags; + std::string m_indent; + std::ostream *m_os; +}; - INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter ) +} // namespace Catch +// #included from: catch_reenable_warnings.h -} // end namespace Catch +#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED -// #included from: ../reporters/catch_reporter_console.hpp -#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED +#ifdef __clang__ +#ifdef __ICC // icpc defines the __clang__ macro +#pragma warning(pop) +#else +#pragma clang diagnostic pop +#endif +#elif defined __GNUC__ +#pragma GCC diagnostic pop +#endif namespace Catch { - - struct ConsoleReporter : StreamingReporterBase { - ConsoleReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - m_headerPrinted( false ) - {} - - virtual ~ConsoleReporter() CATCH_OVERRIDE; - static std::string getDescription() { - return "Reports test results as plain lines of text"; +class XmlReporter : public StreamingReporterBase { +public: + XmlReporter(ReporterConfig const &_config) + : StreamingReporterBase(_config), m_sectionDepth(0) { + m_reporterPrefs.shouldRedirectStdOut = true; + } + + virtual ~XmlReporter() CATCH_OVERRIDE; + + static std::string getDescription() { + return "Reports test results as an XML document"; + } + +public: // StreamingReporterBase + virtual void noMatchingTestCases(std::string const &s) CATCH_OVERRIDE { + StreamingReporterBase::noMatchingTestCases(s); + } + + virtual void testRunStarting(TestRunInfo const &testInfo) CATCH_OVERRIDE { + StreamingReporterBase::testRunStarting(testInfo); + m_xml.setStream(stream); + m_xml.startElement("Catch"); + if (!m_config->name().empty()) + m_xml.writeAttribute("name", m_config->name()); + } + + virtual void testGroupStarting(GroupInfo const &groupInfo) CATCH_OVERRIDE { + StreamingReporterBase::testGroupStarting(groupInfo); + m_xml.startElement("Group").writeAttribute("name", groupInfo.name); + } + + virtual void testCaseStarting(TestCaseInfo const &testInfo) CATCH_OVERRIDE { + StreamingReporterBase::testCaseStarting(testInfo); + m_xml.startElement("TestCase").writeAttribute("name", trim(testInfo.name)); + + if (m_config->showDurations() == ShowDurations::Always) + m_testCaseTimer.start(); + } + + virtual void sectionStarting(SectionInfo const §ionInfo) CATCH_OVERRIDE { + StreamingReporterBase::sectionStarting(sectionInfo); + if (m_sectionDepth++ > 0) { + m_xml.startElement("Section") + .writeAttribute("name", trim(sectionInfo.name)) + .writeAttribute("description", sectionInfo.description); + } + } + + virtual void assertionStarting(AssertionInfo const &) CATCH_OVERRIDE {} + + virtual bool + assertionEnded(AssertionStats const &assertionStats) CATCH_OVERRIDE { + const AssertionResult &assertionResult = assertionStats.assertionResult; + + // Print any info messages in tags. + if (assertionStats.assertionResult.getResultType() != ResultWas::Ok) { + for (std::vector::const_iterator + it = assertionStats.infoMessages.begin(), + itEnd = assertionStats.infoMessages.end(); + it != itEnd; ++it) { + if (it->type == ResultWas::Info) { + m_xml.scopedElement("Info").writeText(it->message); + } else if (it->type == ResultWas::Warning) { + m_xml.scopedElement("Warning").writeText(it->message); } + } + } - virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE { - stream << "No test cases matched '" << spec << "'" << std::endl; - } + // Drop out if result was successful but we're not printing them. + if (!m_config->includeSuccessfulResults() && + isOk(assertionResult.getResultType())) + return true; + + // Print the expression if there is one. + if (assertionResult.hasExpression()) { + m_xml.startElement("Expression") + .writeAttribute("success", assertionResult.succeeded()) + .writeAttribute("type", assertionResult.getTestMacroName()) + .writeAttribute("filename", assertionResult.getSourceInfo().file) + .writeAttribute("line", assertionResult.getSourceInfo().line); + + m_xml.scopedElement("Original") + .writeText(assertionResult.getExpression()); + m_xml.scopedElement("Expanded") + .writeText(assertionResult.getExpandedExpression()); + } + + // And... Print a result applicable to each result type. + switch (assertionResult.getResultType()) { + case ResultWas::ThrewException: + m_xml.scopedElement("Exception") + .writeAttribute("filename", assertionResult.getSourceInfo().file) + .writeAttribute("line", assertionResult.getSourceInfo().line) + .writeText(assertionResult.getMessage()); + break; + case ResultWas::FatalErrorCondition: + m_xml.scopedElement("Fatal Error Condition") + .writeAttribute("filename", assertionResult.getSourceInfo().file) + .writeAttribute("line", assertionResult.getSourceInfo().line) + .writeText(assertionResult.getMessage()); + break; + case ResultWas::Info: + m_xml.scopedElement("Info").writeText(assertionResult.getMessage()); + break; + case ResultWas::Warning: + // Warning will already have been written + break; + case ResultWas::ExplicitFailure: + m_xml.scopedElement("Failure").writeText(assertionResult.getMessage()); + break; + default: + break; + } + + if (assertionResult.hasExpression()) + m_xml.endElement(); + + return true; + } + + virtual void sectionEnded(SectionStats const §ionStats) CATCH_OVERRIDE { + StreamingReporterBase::sectionEnded(sectionStats); + if (--m_sectionDepth > 0) { + XmlWriter::ScopedElement e = m_xml.scopedElement("OverallResults"); + e.writeAttribute("successes", sectionStats.assertions.passed); + e.writeAttribute("failures", sectionStats.assertions.failed); + e.writeAttribute("expectedFailures", sectionStats.assertions.failedButOk); + + if (m_config->showDurations() == ShowDurations::Always) + e.writeAttribute("durationInSeconds", sectionStats.durationInSeconds); + + m_xml.endElement(); + } + } + + virtual void + testCaseEnded(TestCaseStats const &testCaseStats) CATCH_OVERRIDE { + StreamingReporterBase::testCaseEnded(testCaseStats); + XmlWriter::ScopedElement e = m_xml.scopedElement("OverallResult"); + e.writeAttribute("success", testCaseStats.totals.assertions.allOk()); + + if (m_config->showDurations() == ShowDurations::Always) + e.writeAttribute("durationInSeconds", + m_testCaseTimer.getElapsedSeconds()); + + m_xml.endElement(); + } + + virtual void + testGroupEnded(TestGroupStats const &testGroupStats) CATCH_OVERRIDE { + StreamingReporterBase::testGroupEnded(testGroupStats); + // TODO: Check testGroupStats.aborting and act accordingly. + m_xml.scopedElement("OverallResults") + .writeAttribute("successes", testGroupStats.totals.assertions.passed) + .writeAttribute("failures", testGroupStats.totals.assertions.failed) + .writeAttribute("expectedFailures", + testGroupStats.totals.assertions.failedButOk); + m_xml.endElement(); + } + + virtual void testRunEnded(TestRunStats const &testRunStats) CATCH_OVERRIDE { + StreamingReporterBase::testRunEnded(testRunStats); + m_xml.scopedElement("OverallResults") + .writeAttribute("successes", testRunStats.totals.assertions.passed) + .writeAttribute("failures", testRunStats.totals.assertions.failed) + .writeAttribute("expectedFailures", + testRunStats.totals.assertions.failedButOk); + m_xml.endElement(); + } - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { - } +private: + Timer m_testCaseTimer; + XmlWriter m_xml; + int m_sectionDepth; +}; - virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE { - AssertionResult const& result = _assertionStats.assertionResult; +INTERNAL_CATCH_REGISTER_REPORTER("xml", XmlReporter) - bool printInfoMessages = true; +} // end namespace Catch - // Drop out if result was successful and we're not printing those - if( !m_config->includeSuccessfulResults() && result.isOk() ) { - if( result.getResultType() != ResultWas::Warning ) - return false; - printInfoMessages = false; - } +// #included from: ../reporters/catch_reporter_junit.hpp +#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED - lazyPrint(); +#include - AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); - printer.print(); - stream << std::endl; - return true; - } +namespace Catch { - virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE { - m_headerPrinted = false; - StreamingReporterBase::sectionStarting( _sectionInfo ); - } - virtual void sectionEnded( SectionStats const& _sectionStats ) CATCH_OVERRIDE { - if( _sectionStats.missingAssertions ) { - lazyPrint(); - Colour colour( Colour::ResultError ); - if( m_sectionStack.size() > 1 ) - stream << "\nNo assertions in section"; - else - stream << "\nNo assertions in test case"; - stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; - } - if( m_headerPrinted ) { - if( m_config->showDurations() == ShowDurations::Always ) - stream << "Completed in " << _sectionStats.durationInSeconds << "s" << std::endl; - m_headerPrinted = false; - } - else { - if( m_config->showDurations() == ShowDurations::Always ) - stream << _sectionStats.sectionInfo.name << " completed in " << _sectionStats.durationInSeconds << "s" << std::endl; - } - StreamingReporterBase::sectionEnded( _sectionStats ); - } +class JunitReporter : public CumulativeReporterBase { +public: + JunitReporter(ReporterConfig const &_config) + : CumulativeReporterBase(_config), xml(_config.stream()) { + m_reporterPrefs.shouldRedirectStdOut = true; + } + + virtual ~JunitReporter() CATCH_OVERRIDE; + + static std::string getDescription() { + return "Reports test results in an XML format that looks like Ant's " + "junitreport target"; + } + + virtual void + noMatchingTestCases(std::string const & /*spec*/) CATCH_OVERRIDE {} + + virtual void testRunStarting(TestRunInfo const &runInfo) CATCH_OVERRIDE { + CumulativeReporterBase::testRunStarting(runInfo); + xml.startElement("testsuites"); + } + + virtual void testGroupStarting(GroupInfo const &groupInfo) CATCH_OVERRIDE { + suiteTimer.start(); + stdOutForSuite.str(""); + stdErrForSuite.str(""); + unexpectedExceptions = 0; + CumulativeReporterBase::testGroupStarting(groupInfo); + } + + virtual bool + assertionEnded(AssertionStats const &assertionStats) CATCH_OVERRIDE { + if (assertionStats.assertionResult.getResultType() == + ResultWas::ThrewException) + unexpectedExceptions++; + return CumulativeReporterBase::assertionEnded(assertionStats); + } + + virtual void + testCaseEnded(TestCaseStats const &testCaseStats) CATCH_OVERRIDE { + stdOutForSuite << testCaseStats.stdOut; + stdErrForSuite << testCaseStats.stdErr; + CumulativeReporterBase::testCaseEnded(testCaseStats); + } + + virtual void + testGroupEnded(TestGroupStats const &testGroupStats) CATCH_OVERRIDE { + double suiteTime = suiteTimer.getElapsedSeconds(); + CumulativeReporterBase::testGroupEnded(testGroupStats); + writeGroup(*m_testGroups.back(), suiteTime); + } + + virtual void testRunEndedCumulative() CATCH_OVERRIDE { xml.endElement(); } + + void writeGroup(TestGroupNode const &groupNode, double suiteTime) { + XmlWriter::ScopedElement e = xml.scopedElement("testsuite"); + TestGroupStats const &stats = groupNode.value; + xml.writeAttribute("name", stats.groupInfo.name); + xml.writeAttribute("errors", unexpectedExceptions); + xml.writeAttribute("failures", + stats.totals.assertions.failed - unexpectedExceptions); + xml.writeAttribute("tests", stats.totals.assertions.total()); + xml.writeAttribute("hostname", "tbd"); // !TBD + if (m_config->showDurations() == ShowDurations::Never) + xml.writeAttribute("time", ""); + else + xml.writeAttribute("time", suiteTime); + xml.writeAttribute("timestamp", "tbd"); // !TBD + + // Write test cases + for (TestGroupNode::ChildNodes::const_iterator + it = groupNode.children.begin(), + itEnd = groupNode.children.end(); + it != itEnd; ++it) + writeTestCase(**it); + + xml.scopedElement("system-out") + .writeText(trim(stdOutForSuite.str()), false); + xml.scopedElement("system-err") + .writeText(trim(stdErrForSuite.str()), false); + } + + void writeTestCase(TestCaseNode const &testCaseNode) { + TestCaseStats const &stats = testCaseNode.value; + + // All test cases have exactly one section - which represents the + // test case itself. That section may have 0-n nested sections + assert(testCaseNode.children.size() == 1); + SectionNode const &rootSection = *testCaseNode.children.front(); + + std::string className = stats.testInfo.className; + + if (className.empty()) { + if (rootSection.childSections.empty()) + className = "global"; + } + writeSection(className, "", rootSection); + } + + void writeSection(std::string const &className, std::string const &rootName, + SectionNode const §ionNode) { + std::string name = trim(sectionNode.stats.sectionInfo.name); + if (!rootName.empty()) + name = rootName + "/" + name; + + if (!sectionNode.assertions.empty() || !sectionNode.stdOut.empty() || + !sectionNode.stdErr.empty()) { + XmlWriter::ScopedElement e = xml.scopedElement("testcase"); + if (className.empty()) { + xml.writeAttribute("classname", name); + xml.writeAttribute("name", "root"); + } else { + xml.writeAttribute("classname", className); + xml.writeAttribute("name", name); + } + xml.writeAttribute("time", + Catch::toString(sectionNode.stats.durationInSeconds)); + + writeAssertions(sectionNode); + + if (!sectionNode.stdOut.empty()) + xml.scopedElement("system-out") + .writeText(trim(sectionNode.stdOut), false); + if (!sectionNode.stdErr.empty()) + xml.scopedElement("system-err") + .writeText(trim(sectionNode.stdErr), false); + } + for (SectionNode::ChildSections::const_iterator + it = sectionNode.childSections.begin(), + itEnd = sectionNode.childSections.end(); + it != itEnd; ++it) + if (className.empty()) + writeSection(name, "", **it); + else + writeSection(className, name, **it); + } + + void writeAssertions(SectionNode const §ionNode) { + for (SectionNode::Assertions::const_iterator + it = sectionNode.assertions.begin(), + itEnd = sectionNode.assertions.end(); + it != itEnd; ++it) + writeAssertion(*it); + } + void writeAssertion(AssertionStats const &stats) { + AssertionResult const &result = stats.assertionResult; + if (!result.isOk()) { + std::string elementName; + switch (result.getResultType()) { + case ResultWas::ThrewException: + case ResultWas::FatalErrorCondition: + elementName = "error"; + break; + case ResultWas::ExplicitFailure: + elementName = "failure"; + break; + case ResultWas::ExpressionFailed: + elementName = "failure"; + break; + case ResultWas::DidntThrowException: + elementName = "failure"; + break; + + // We should never see these here: + case ResultWas::Info: + case ResultWas::Warning: + case ResultWas::Ok: + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + elementName = "internalError"; + break; + } - virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseEnded( _testCaseStats ); - m_headerPrinted = false; - } - virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) CATCH_OVERRIDE { - if( currentGroupInfo.used ) { - printSummaryDivider(); - stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n"; - printTotals( _testGroupStats.totals ); - stream << "\n" << std::endl; - } - StreamingReporterBase::testGroupEnded( _testGroupStats ); - } - virtual void testRunEnded( TestRunStats const& _testRunStats ) CATCH_OVERRIDE { - printTotalsDivider( _testRunStats.totals ); - printTotals( _testRunStats.totals ); - stream << std::endl; - StreamingReporterBase::testRunEnded( _testRunStats ); - } + XmlWriter::ScopedElement e = xml.scopedElement(elementName); - private: - - class AssertionPrinter { - void operator= ( AssertionPrinter const& ); - public: - AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) - : stream( _stream ), - stats( _stats ), - result( _stats.assertionResult ), - colour( Colour::None ), - message( result.getMessage() ), - messages( _stats.infoMessages ), - printInfoMessages( _printInfoMessages ) - { - switch( result.getResultType() ) { - case ResultWas::Ok: - colour = Colour::Success; - passOrFail = "PASSED"; - //if( result.hasMessage() ) - if( _stats.infoMessages.size() == 1 ) - messageLabel = "with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "with messages"; - break; - case ResultWas::ExpressionFailed: - if( result.isOk() ) { - colour = Colour::Success; - passOrFail = "FAILED - but was ok"; - } - else { - colour = Colour::Error; - passOrFail = "FAILED"; - } - if( _stats.infoMessages.size() == 1 ) - messageLabel = "with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "with messages"; - break; - case ResultWas::ThrewException: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "due to unexpected exception with message"; - break; - case ResultWas::FatalErrorCondition: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "due to a fatal error condition"; - break; - case ResultWas::DidntThrowException: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "because no exception was thrown where one was expected"; - break; - case ResultWas::Info: - messageLabel = "info"; - break; - case ResultWas::Warning: - messageLabel = "warning"; - break; - case ResultWas::ExplicitFailure: - passOrFail = "FAILED"; - colour = Colour::Error; - if( _stats.infoMessages.size() == 1 ) - messageLabel = "explicitly with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "explicitly with messages"; - break; - // These cases are here to prevent compiler warnings - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - passOrFail = "** internal error **"; - colour = Colour::Error; - break; - } - } + xml.writeAttribute("message", result.getExpandedExpression()); + xml.writeAttribute("type", result.getTestMacroName()); - void print() const { - printSourceInfo(); - if( stats.totals.assertions.total() > 0 ) { - if( result.isOk() ) - stream << "\n"; - printResultType(); - printOriginalExpression(); - printReconstructedExpression(); - } - else { - stream << "\n"; - } - printMessage(); - } + std::ostringstream oss; + if (!result.getMessage().empty()) + oss << result.getMessage() << "\n"; + for (std::vector::const_iterator + it = stats.infoMessages.begin(), + itEnd = stats.infoMessages.end(); + it != itEnd; ++it) + if (it->type == ResultWas::Info) + oss << it->message << "\n"; - private: - void printResultType() const { - if( !passOrFail.empty() ) { - Colour colourGuard( colour ); - stream << passOrFail << ":\n"; - } - } - void printOriginalExpression() const { - if( result.hasExpression() ) { - Colour colourGuard( Colour::OriginalExpression ); - stream << " "; - stream << result.getExpressionInMacro(); - stream << "\n"; - } - } - void printReconstructedExpression() const { - if( result.hasExpandedExpression() ) { - stream << "with expansion:\n"; - Colour colourGuard( Colour::ReconstructedExpression ); - stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << "\n"; - } - } - void printMessage() const { - if( !messageLabel.empty() ) - stream << messageLabel << ":" << "\n"; - for( std::vector::const_iterator it = messages.begin(), itEnd = messages.end(); - it != itEnd; - ++it ) { - // If this assertion is a warning ignore any INFO messages - if( printInfoMessages || it->type != ResultWas::Info ) - stream << Text( it->message, TextAttributes().setIndent(2) ) << "\n"; - } - } - void printSourceInfo() const { - Colour colourGuard( Colour::FileName ); - stream << result.getSourceInfo() << ": "; - } + oss << "at " << result.getSourceInfo(); + xml.writeText(oss.str(), false); + } + } - std::ostream& stream; - AssertionStats const& stats; - AssertionResult const& result; - Colour::Code colour; - std::string passOrFail; - std::string messageLabel; - std::string message; - std::vector messages; - bool printInfoMessages; - }; - - void lazyPrint() { - - if( !currentTestRunInfo.used ) - lazyPrintRunInfo(); - if( !currentGroupInfo.used ) - lazyPrintGroupInfo(); - - if( !m_headerPrinted ) { - printTestCaseAndSectionHeader(); - m_headerPrinted = true; - } - } - void lazyPrintRunInfo() { - stream << "\n" << getLineOfChars<'~'>() << "\n"; - Colour colour( Colour::SecondaryText ); - stream << currentTestRunInfo->name - << " is a Catch v" << libraryVersion << " host application.\n" - << "Run with -? for options\n\n"; + XmlWriter xml; + Timer suiteTimer; + std::ostringstream stdOutForSuite; + std::ostringstream stdErrForSuite; + unsigned int unexpectedExceptions; +}; - if( m_config->rngSeed() != 0 ) - stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; +INTERNAL_CATCH_REGISTER_REPORTER("junit", JunitReporter) - currentTestRunInfo.used = true; - } - void lazyPrintGroupInfo() { - if( !currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1 ) { - printClosedHeader( "Group: " + currentGroupInfo->name ); - currentGroupInfo.used = true; - } - } - void printTestCaseAndSectionHeader() { - assert( !m_sectionStack.empty() ); - printOpenHeader( currentTestCaseInfo->name ); - - if( m_sectionStack.size() > 1 ) { - Colour colourGuard( Colour::Headers ); - - std::vector::const_iterator - it = m_sectionStack.begin()+1, // Skip first section (test case) - itEnd = m_sectionStack.end(); - for( ; it != itEnd; ++it ) - printHeaderString( it->name, 2 ); - } +} // end namespace Catch - SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; +// #included from: ../reporters/catch_reporter_console.hpp +#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED - if( !lineInfo.empty() ){ - stream << getLineOfChars<'-'>() << "\n"; - Colour colourGuard( Colour::FileName ); - stream << lineInfo << "\n"; - } - stream << getLineOfChars<'.'>() << "\n" << std::endl; - } +namespace Catch { - void printClosedHeader( std::string const& _name ) { - printOpenHeader( _name ); - stream << getLineOfChars<'.'>() << "\n"; - } - void printOpenHeader( std::string const& _name ) { - stream << getLineOfChars<'-'>() << "\n"; - { - Colour colourGuard( Colour::Headers ); - printHeaderString( _name ); - } - } +struct ConsoleReporter : StreamingReporterBase { + ConsoleReporter(ReporterConfig const &_config) + : StreamingReporterBase(_config), m_headerPrinted(false) {} + + virtual ~ConsoleReporter() CATCH_OVERRIDE; + static std::string getDescription() { + return "Reports test results as plain lines of text"; + } + + virtual void noMatchingTestCases(std::string const &spec) CATCH_OVERRIDE { + stream << "No test cases matched '" << spec << "'" << std::endl; + } + + virtual void assertionStarting(AssertionInfo const &) CATCH_OVERRIDE {} + + virtual bool + assertionEnded(AssertionStats const &_assertionStats) CATCH_OVERRIDE { + AssertionResult const &result = _assertionStats.assertionResult; + + bool printInfoMessages = true; + + // Drop out if result was successful and we're not printing those + if (!m_config->includeSuccessfulResults() && result.isOk()) { + if (result.getResultType() != ResultWas::Warning) + return false; + printInfoMessages = false; + } + + lazyPrint(); + + AssertionPrinter printer(stream, _assertionStats, printInfoMessages); + printer.print(); + stream << std::endl; + return true; + } + + virtual void sectionStarting(SectionInfo const &_sectionInfo) CATCH_OVERRIDE { + m_headerPrinted = false; + StreamingReporterBase::sectionStarting(_sectionInfo); + } + virtual void sectionEnded(SectionStats const &_sectionStats) CATCH_OVERRIDE { + if (_sectionStats.missingAssertions) { + lazyPrint(); + Colour colour(Colour::ResultError); + if (m_sectionStack.size() > 1) + stream << "\nNo assertions in section"; + else + stream << "\nNo assertions in test case"; + stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; + } + if (m_headerPrinted) { + if (m_config->showDurations() == ShowDurations::Always) + stream << "Completed in " << _sectionStats.durationInSeconds << "s" + << std::endl; + m_headerPrinted = false; + } else { + if (m_config->showDurations() == ShowDurations::Always) + stream << _sectionStats.sectionInfo.name << " completed in " + << _sectionStats.durationInSeconds << "s" << std::endl; + } + StreamingReporterBase::sectionEnded(_sectionStats); + } + + virtual void + testCaseEnded(TestCaseStats const &_testCaseStats) CATCH_OVERRIDE { + StreamingReporterBase::testCaseEnded(_testCaseStats); + m_headerPrinted = false; + } + virtual void + testGroupEnded(TestGroupStats const &_testGroupStats) CATCH_OVERRIDE { + if (currentGroupInfo.used) { + printSummaryDivider(); + stream << "Summary for group '" << _testGroupStats.groupInfo.name + << "':\n"; + printTotals(_testGroupStats.totals); + stream << "\n" << std::endl; + } + StreamingReporterBase::testGroupEnded(_testGroupStats); + } + virtual void testRunEnded(TestRunStats const &_testRunStats) CATCH_OVERRIDE { + printTotalsDivider(_testRunStats.totals); + printTotals(_testRunStats.totals); + stream << std::endl; + StreamingReporterBase::testRunEnded(_testRunStats); + } - // if string has a : in first line will set indent to follow it on - // subsequent lines - void printHeaderString( std::string const& _string, std::size_t indent = 0 ) { - std::size_t i = _string.find( ": " ); - if( i != std::string::npos ) - i+=2; - else - i = 0; - stream << Text( _string, TextAttributes() - .setIndent( indent+i) - .setInitialIndent( indent ) ) << "\n"; - } +private: + class AssertionPrinter { + void operator=(AssertionPrinter const &); + + public: + AssertionPrinter(std::ostream &_stream, AssertionStats const &_stats, + bool _printInfoMessages) + : stream(_stream), stats(_stats), result(_stats.assertionResult), + colour(Colour::None), message(result.getMessage()), + messages(_stats.infoMessages), printInfoMessages(_printInfoMessages) { + switch (result.getResultType()) { + case ResultWas::Ok: + colour = Colour::Success; + passOrFail = "PASSED"; + // if( result.hasMessage() ) + if (_stats.infoMessages.size() == 1) + messageLabel = "with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "with messages"; + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) { + colour = Colour::Success; + passOrFail = "FAILED - but was ok"; + } else { + colour = Colour::Error; + passOrFail = "FAILED"; + } + if (_stats.infoMessages.size() == 1) + messageLabel = "with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "with messages"; + break; + case ResultWas::ThrewException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to unexpected exception with message"; + break; + case ResultWas::FatalErrorCondition: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to a fatal error condition"; + break; + case ResultWas::DidntThrowException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "because no exception was thrown where one was expected"; + break; + case ResultWas::Info: + messageLabel = "info"; + break; + case ResultWas::Warning: + messageLabel = "warning"; + break; + case ResultWas::ExplicitFailure: + passOrFail = "FAILED"; + colour = Colour::Error; + if (_stats.infoMessages.size() == 1) + messageLabel = "explicitly with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "explicitly with messages"; + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + passOrFail = "** internal error **"; + colour = Colour::Error; + break; + } + } - struct SummaryColumn { - - SummaryColumn( std::string const& _label, Colour::Code _colour ) - : label( _label ), - colour( _colour ) - {} - SummaryColumn addRow( std::size_t count ) { - std::ostringstream oss; - oss << count; - std::string row = oss.str(); - for( std::vector::iterator it = rows.begin(); it != rows.end(); ++it ) { - while( it->size() < row.size() ) - *it = " " + *it; - while( it->size() > row.size() ) - row = " " + row; - } - rows.push_back( row ); - return *this; - } + void print() const { + printSourceInfo(); + if (stats.totals.assertions.total() > 0) { + if (result.isOk()) + stream << "\n"; + printResultType(); + printOriginalExpression(); + printReconstructedExpression(); + } else { + stream << "\n"; + } + printMessage(); + } - std::string label; - Colour::Code colour; - std::vector rows; + private: + void printResultType() const { + if (!passOrFail.empty()) { + Colour colourGuard(colour); + stream << passOrFail << ":\n"; + } + } + void printOriginalExpression() const { + if (result.hasExpression()) { + Colour colourGuard(Colour::OriginalExpression); + stream << " "; + stream << result.getExpressionInMacro(); + stream << "\n"; + } + } + void printReconstructedExpression() const { + if (result.hasExpandedExpression()) { + stream << "with expansion:\n"; + Colour colourGuard(Colour::ReconstructedExpression); + stream << Text(result.getExpandedExpression(), + TextAttributes().setIndent(2)) + << "\n"; + } + } + void printMessage() const { + if (!messageLabel.empty()) + stream << messageLabel << ":" + << "\n"; + for (std::vector::const_iterator it = messages.begin(), + itEnd = messages.end(); + it != itEnd; ++it) { + // If this assertion is a warning ignore any INFO messages + if (printInfoMessages || it->type != ResultWas::Info) + stream << Text(it->message, TextAttributes().setIndent(2)) << "\n"; + } + } + void printSourceInfo() const { + Colour colourGuard(Colour::FileName); + stream << result.getSourceInfo() << ": "; + } - }; + std::ostream &stream; + AssertionStats const &stats; + AssertionResult const &result; + Colour::Code colour; + std::string passOrFail; + std::string messageLabel; + std::string message; + std::vector messages; + bool printInfoMessages; + }; - void printTotals( Totals const& totals ) { - if( totals.testCases.total() == 0 ) { - stream << Colour( Colour::Warning ) << "No tests ran\n"; - } - else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) { - stream << Colour( Colour::ResultSuccess ) << "All tests passed"; - stream << " (" - << pluralise( totals.assertions.passed, "assertion" ) << " in " - << pluralise( totals.testCases.passed, "test case" ) << ")" - << "\n"; - } - else { - - std::vector columns; - columns.push_back( SummaryColumn( "", Colour::None ) - .addRow( totals.testCases.total() ) - .addRow( totals.assertions.total() ) ); - columns.push_back( SummaryColumn( "passed", Colour::Success ) - .addRow( totals.testCases.passed ) - .addRow( totals.assertions.passed ) ); - columns.push_back( SummaryColumn( "failed", Colour::ResultError ) - .addRow( totals.testCases.failed ) - .addRow( totals.assertions.failed ) ); - columns.push_back( SummaryColumn( "failed as expected", Colour::ResultExpectedFailure ) - .addRow( totals.testCases.failedButOk ) - .addRow( totals.assertions.failedButOk ) ); - - printSummaryRow( "test cases", columns, 0 ); - printSummaryRow( "assertions", columns, 1 ); - } - } - void printSummaryRow( std::string const& label, std::vector const& cols, std::size_t row ) { - for( std::vector::const_iterator it = cols.begin(); it != cols.end(); ++it ) { - std::string value = it->rows[row]; - if( it->label.empty() ) { - stream << label << ": "; - if( value != "0" ) - stream << value; - else - stream << Colour( Colour::Warning ) << "- none -"; - } - else if( value != "0" ) { - stream << Colour( Colour::LightGrey ) << " | "; - stream << Colour( it->colour ) - << value << " " << it->label; - } - } - stream << "\n"; - } + void lazyPrint() { + + if (!currentTestRunInfo.used) + lazyPrintRunInfo(); + if (!currentGroupInfo.used) + lazyPrintGroupInfo(); + + if (!m_headerPrinted) { + printTestCaseAndSectionHeader(); + m_headerPrinted = true; + } + } + void lazyPrintRunInfo() { + stream << "\n" << getLineOfChars<'~'>() << "\n"; + Colour colour(Colour::SecondaryText); + stream << currentTestRunInfo->name << " is a Catch v" << libraryVersion + << " host application.\n" + << "Run with -? for options\n\n"; + + if (m_config->rngSeed() != 0) + stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; + + currentTestRunInfo.used = true; + } + void lazyPrintGroupInfo() { + if (!currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1) { + printClosedHeader("Group: " + currentGroupInfo->name); + currentGroupInfo.used = true; + } + } + void printTestCaseAndSectionHeader() { + assert(!m_sectionStack.empty()); + printOpenHeader(currentTestCaseInfo->name); + + if (m_sectionStack.size() > 1) { + Colour colourGuard(Colour::Headers); + + std::vector::const_iterator + it = m_sectionStack.begin() + 1, // Skip first section (test case) + itEnd = m_sectionStack.end(); + for (; it != itEnd; ++it) + printHeaderString(it->name, 2); + } + + SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; + + if (!lineInfo.empty()) { + stream << getLineOfChars<'-'>() << "\n"; + Colour colourGuard(Colour::FileName); + stream << lineInfo << "\n"; + } + stream << getLineOfChars<'.'>() << "\n" << std::endl; + } + + void printClosedHeader(std::string const &_name) { + printOpenHeader(_name); + stream << getLineOfChars<'.'>() << "\n"; + } + void printOpenHeader(std::string const &_name) { + stream << getLineOfChars<'-'>() << "\n"; + { + Colour colourGuard(Colour::Headers); + printHeaderString(_name); + } + } - static std::size_t makeRatio( std::size_t number, std::size_t total ) { - std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0; - return ( ratio == 0 && number > 0 ) ? 1 : ratio; - } - static std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) { - if( i > j && i > k ) - return i; - else if( j > k ) - return j; - else - return k; - } + // if string has a : in first line will set indent to follow it on + // subsequent lines + void printHeaderString(std::string const &_string, std::size_t indent = 0) { + std::size_t i = _string.find(": "); + if (i != std::string::npos) + i += 2; + else + i = 0; + stream + << Text(_string, + TextAttributes().setIndent(indent + i).setInitialIndent(indent)) + << "\n"; + } + + struct SummaryColumn { + + SummaryColumn(std::string const &_label, Colour::Code _colour) + : label(_label), colour(_colour) {} + SummaryColumn addRow(std::size_t count) { + std::ostringstream oss; + oss << count; + std::string row = oss.str(); + for (std::vector::iterator it = rows.begin(); + it != rows.end(); ++it) { + while (it->size() < row.size()) + *it = " " + *it; + while (it->size() > row.size()) + row = " " + row; + } + rows.push_back(row); + return *this; + } - void printTotalsDivider( Totals const& totals ) { - if( totals.testCases.total() > 0 ) { - std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() ); - std::size_t failedButOkRatio = makeRatio( totals.testCases.failedButOk, totals.testCases.total() ); - std::size_t passedRatio = makeRatio( totals.testCases.passed, totals.testCases.total() ); - while( failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH-1 ) - findMax( failedRatio, failedButOkRatio, passedRatio )++; - while( failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH-1 ) - findMax( failedRatio, failedButOkRatio, passedRatio )--; - - stream << Colour( Colour::Error ) << std::string( failedRatio, '=' ); - stream << Colour( Colour::ResultExpectedFailure ) << std::string( failedButOkRatio, '=' ); - if( totals.testCases.allPassed() ) - stream << Colour( Colour::ResultSuccess ) << std::string( passedRatio, '=' ); - else - stream << Colour( Colour::Success ) << std::string( passedRatio, '=' ); - } - else { - stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' ); - } - stream << "\n"; - } - void printSummaryDivider() { - stream << getLineOfChars<'-'>() << "\n"; - } + std::string label; + Colour::Code colour; + std::vector rows; + }; - private: - bool m_headerPrinted; - }; + void printTotals(Totals const &totals) { + if (totals.testCases.total() == 0) { + stream << Colour(Colour::Warning) << "No tests ran\n"; + } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) { + stream << Colour(Colour::ResultSuccess) << "All tests passed"; + stream << " (" << pluralise(totals.assertions.passed, "assertion") + << " in " << pluralise(totals.testCases.passed, "test case") << ")" + << "\n"; + } else { + + std::vector columns; + columns.push_back(SummaryColumn("", Colour::None) + .addRow(totals.testCases.total()) + .addRow(totals.assertions.total())); + columns.push_back(SummaryColumn("passed", Colour::Success) + .addRow(totals.testCases.passed) + .addRow(totals.assertions.passed)); + columns.push_back(SummaryColumn("failed", Colour::ResultError) + .addRow(totals.testCases.failed) + .addRow(totals.assertions.failed)); + columns.push_back( + SummaryColumn("failed as expected", Colour::ResultExpectedFailure) + .addRow(totals.testCases.failedButOk) + .addRow(totals.assertions.failedButOk)); + + printSummaryRow("test cases", columns, 0); + printSummaryRow("assertions", columns, 1); + } + } + void printSummaryRow(std::string const &label, + std::vector const &cols, + std::size_t row) { + for (std::vector::const_iterator it = cols.begin(); + it != cols.end(); ++it) { + std::string value = it->rows[row]; + if (it->label.empty()) { + stream << label << ": "; + if (value != "0") + stream << value; + else + stream << Colour(Colour::Warning) << "- none -"; + } else if (value != "0") { + stream << Colour(Colour::LightGrey) << " | "; + stream << Colour(it->colour) << value << " " << it->label; + } + } + stream << "\n"; + } + + static std::size_t makeRatio(std::size_t number, std::size_t total) { + std::size_t ratio = + total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0; + return (ratio == 0 && number > 0) ? 1 : ratio; + } + static std::size_t &findMax(std::size_t &i, std::size_t &j, std::size_t &k) { + if (i > j && i > k) + return i; + else if (j > k) + return j; + else + return k; + } + + void printTotalsDivider(Totals const &totals) { + if (totals.testCases.total() > 0) { + std::size_t failedRatio = + makeRatio(totals.testCases.failed, totals.testCases.total()); + std::size_t failedButOkRatio = + makeRatio(totals.testCases.failedButOk, totals.testCases.total()); + std::size_t passedRatio = + makeRatio(totals.testCases.passed, totals.testCases.total()); + while (failedRatio + failedButOkRatio + passedRatio < + CATCH_CONFIG_CONSOLE_WIDTH - 1) + findMax(failedRatio, failedButOkRatio, passedRatio)++; + while (failedRatio + failedButOkRatio + passedRatio > + CATCH_CONFIG_CONSOLE_WIDTH - 1) + findMax(failedRatio, failedButOkRatio, passedRatio)--; + + stream << Colour(Colour::Error) << std::string(failedRatio, '='); + stream << Colour(Colour::ResultExpectedFailure) + << std::string(failedButOkRatio, '='); + if (totals.testCases.allPassed()) + stream << Colour(Colour::ResultSuccess) + << std::string(passedRatio, '='); + else + stream << Colour(Colour::Success) << std::string(passedRatio, '='); + } else { + stream << Colour(Colour::Warning) + << std::string(CATCH_CONFIG_CONSOLE_WIDTH - 1, '='); + } + stream << "\n"; + } + void printSummaryDivider() { stream << getLineOfChars<'-'>() << "\n"; } - INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter ) +private: + bool m_headerPrinted; +}; + +INTERNAL_CATCH_REGISTER_REPORTER("console", ConsoleReporter) } // end namespace Catch @@ -9921,351 +9966,344 @@ namespace Catch { namespace Catch { - struct CompactReporter : StreamingReporterBase { +struct CompactReporter : StreamingReporterBase { - CompactReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ) - {} + CompactReporter(ReporterConfig const &_config) + : StreamingReporterBase(_config) {} - virtual ~CompactReporter(); + virtual ~CompactReporter(); - static std::string getDescription() { - return "Reports test results on a single line, suitable for IDEs"; - } + static std::string getDescription() { + return "Reports test results on a single line, suitable for IDEs"; + } - virtual ReporterPreferences getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = false; - return prefs; - } + virtual ReporterPreferences getPreferences() const { + ReporterPreferences prefs; + prefs.shouldRedirectStdOut = false; + return prefs; + } - virtual void noMatchingTestCases( std::string const& spec ) { - stream << "No test cases matched '" << spec << "'" << std::endl; - } + virtual void noMatchingTestCases(std::string const &spec) { + stream << "No test cases matched '" << spec << "'" << std::endl; + } - virtual void assertionStarting( AssertionInfo const& ) { - } + virtual void assertionStarting(AssertionInfo const &) {} - virtual bool assertionEnded( AssertionStats const& _assertionStats ) { - AssertionResult const& result = _assertionStats.assertionResult; + virtual bool assertionEnded(AssertionStats const &_assertionStats) { + AssertionResult const &result = _assertionStats.assertionResult; - bool printInfoMessages = true; + bool printInfoMessages = true; - // Drop out if result was successful and we're not printing those - if( !m_config->includeSuccessfulResults() && result.isOk() ) { - if( result.getResultType() != ResultWas::Warning ) - return false; - printInfoMessages = false; - } + // Drop out if result was successful and we're not printing those + if (!m_config->includeSuccessfulResults() && result.isOk()) { + if (result.getResultType() != ResultWas::Warning) + return false; + printInfoMessages = false; + } - AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); - printer.print(); + AssertionPrinter printer(stream, _assertionStats, printInfoMessages); + printer.print(); - stream << std::endl; - return true; - } + stream << std::endl; + return true; + } - virtual void testRunEnded( TestRunStats const& _testRunStats ) { - printTotals( _testRunStats.totals ); - stream << "\n" << std::endl; - StreamingReporterBase::testRunEnded( _testRunStats ); - } + virtual void testRunEnded(TestRunStats const &_testRunStats) { + printTotals(_testRunStats.totals); + stream << "\n" << std::endl; + StreamingReporterBase::testRunEnded(_testRunStats); + } - private: - class AssertionPrinter { - void operator= ( AssertionPrinter const& ); - public: - AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) - : stream( _stream ) - , stats( _stats ) - , result( _stats.assertionResult ) - , messages( _stats.infoMessages ) - , itMessage( _stats.infoMessages.begin() ) - , printInfoMessages( _printInfoMessages ) - {} - - void print() { - printSourceInfo(); - - itMessage = messages.begin(); - - switch( result.getResultType() ) { - case ResultWas::Ok: - printResultType( Colour::ResultSuccess, passedString() ); - printOriginalExpression(); - printReconstructedExpression(); - if ( ! result.hasExpression() ) - printRemainingMessages( Colour::None ); - else - printRemainingMessages(); - break; - case ResultWas::ExpressionFailed: - if( result.isOk() ) - printResultType( Colour::ResultSuccess, failedString() + std::string( " - but was ok" ) ); - else - printResultType( Colour::Error, failedString() ); - printOriginalExpression(); - printReconstructedExpression(); - printRemainingMessages(); - break; - case ResultWas::ThrewException: - printResultType( Colour::Error, failedString() ); - printIssue( "unexpected exception with message:" ); - printMessage(); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::FatalErrorCondition: - printResultType( Colour::Error, failedString() ); - printIssue( "fatal error condition with message:" ); - printMessage(); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::DidntThrowException: - printResultType( Colour::Error, failedString() ); - printIssue( "expected exception, got none" ); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::Info: - printResultType( Colour::None, "info" ); - printMessage(); - printRemainingMessages(); - break; - case ResultWas::Warning: - printResultType( Colour::None, "warning" ); - printMessage(); - printRemainingMessages(); - break; - case ResultWas::ExplicitFailure: - printResultType( Colour::Error, failedString() ); - printIssue( "explicitly" ); - printRemainingMessages( Colour::None ); - break; - // These cases are here to prevent compiler warnings - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - printResultType( Colour::Error, "** internal error **" ); - break; - } - } +private: + class AssertionPrinter { + void operator=(AssertionPrinter const &); + + public: + AssertionPrinter(std::ostream &_stream, AssertionStats const &_stats, + bool _printInfoMessages) + : stream(_stream), stats(_stats), result(_stats.assertionResult), + messages(_stats.infoMessages), itMessage(_stats.infoMessages.begin()), + printInfoMessages(_printInfoMessages) {} + + void print() { + printSourceInfo(); + + itMessage = messages.begin(); + + switch (result.getResultType()) { + case ResultWas::Ok: + printResultType(Colour::ResultSuccess, passedString()); + printOriginalExpression(); + printReconstructedExpression(); + if (!result.hasExpression()) + printRemainingMessages(Colour::None); + else + printRemainingMessages(); + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) + printResultType(Colour::ResultSuccess, + failedString() + std::string(" - but was ok")); + else + printResultType(Colour::Error, failedString()); + printOriginalExpression(); + printReconstructedExpression(); + printRemainingMessages(); + break; + case ResultWas::ThrewException: + printResultType(Colour::Error, failedString()); + printIssue("unexpected exception with message:"); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::FatalErrorCondition: + printResultType(Colour::Error, failedString()); + printIssue("fatal error condition with message:"); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::DidntThrowException: + printResultType(Colour::Error, failedString()); + printIssue("expected exception, got none"); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::Info: + printResultType(Colour::None, "info"); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::Warning: + printResultType(Colour::None, "warning"); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::ExplicitFailure: + printResultType(Colour::Error, failedString()); + printIssue("explicitly"); + printRemainingMessages(Colour::None); + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + printResultType(Colour::Error, "** internal error **"); + break; + } + } - private: - // Colour::LightGrey + private: + // Colour::LightGrey - static Colour::Code dimColour() { return Colour::FileName; } + static Colour::Code dimColour() { return Colour::FileName; } #ifdef CATCH_PLATFORM_MAC - static const char* failedString() { return "FAILED"; } - static const char* passedString() { return "PASSED"; } + static const char *failedString() { return "FAILED"; } + static const char *passedString() { return "PASSED"; } #else - static const char* failedString() { return "failed"; } - static const char* passedString() { return "passed"; } + static const char *failedString() { return "failed"; } + static const char *passedString() { return "passed"; } #endif - void printSourceInfo() const { - Colour colourGuard( Colour::FileName ); - stream << result.getSourceInfo() << ":"; - } + void printSourceInfo() const { + Colour colourGuard(Colour::FileName); + stream << result.getSourceInfo() << ":"; + } - void printResultType( Colour::Code colour, std::string passOrFail ) const { - if( !passOrFail.empty() ) { - { - Colour colourGuard( colour ); - stream << " " << passOrFail; - } - stream << ":"; - } - } + void printResultType(Colour::Code colour, std::string passOrFail) const { + if (!passOrFail.empty()) { + { + Colour colourGuard(colour); + stream << " " << passOrFail; + } + stream << ":"; + } + } - void printIssue( std::string issue ) const { - stream << " " << issue; - } + void printIssue(std::string issue) const { stream << " " << issue; } - void printExpressionWas() { - if( result.hasExpression() ) { - stream << ";"; - { - Colour colour( dimColour() ); - stream << " expression was:"; - } - printOriginalExpression(); - } - } + void printExpressionWas() { + if (result.hasExpression()) { + stream << ";"; + { + Colour colour(dimColour()); + stream << " expression was:"; + } + printOriginalExpression(); + } + } - void printOriginalExpression() const { - if( result.hasExpression() ) { - stream << " " << result.getExpression(); - } - } + void printOriginalExpression() const { + if (result.hasExpression()) { + stream << " " << result.getExpression(); + } + } - void printReconstructedExpression() const { - if( result.hasExpandedExpression() ) { - { - Colour colour( dimColour() ); - stream << " for: "; - } - stream << result.getExpandedExpression(); - } - } + void printReconstructedExpression() const { + if (result.hasExpandedExpression()) { + { + Colour colour(dimColour()); + stream << " for: "; + } + stream << result.getExpandedExpression(); + } + } - void printMessage() { - if ( itMessage != messages.end() ) { - stream << " '" << itMessage->message << "'"; - ++itMessage; - } - } + void printMessage() { + if (itMessage != messages.end()) { + stream << " '" << itMessage->message << "'"; + ++itMessage; + } + } - void printRemainingMessages( Colour::Code colour = dimColour() ) { - if ( itMessage == messages.end() ) - return; - - // using messages.end() directly yields compilation error: - std::vector::const_iterator itEnd = messages.end(); - const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); - - { - Colour colourGuard( colour ); - stream << " with " << pluralise( N, "message" ) << ":"; - } - - for(; itMessage != itEnd; ) { - // If this assertion is a warning ignore any INFO messages - if( printInfoMessages || itMessage->type != ResultWas::Info ) { - stream << " '" << itMessage->message << "'"; - if ( ++itMessage != itEnd ) { - Colour colourGuard( dimColour() ); - stream << " and"; - } - } - } - } + void printRemainingMessages(Colour::Code colour = dimColour()) { + if (itMessage == messages.end()) + return; - private: - std::ostream& stream; - AssertionStats const& stats; - AssertionResult const& result; - std::vector messages; - std::vector::const_iterator itMessage; - bool printInfoMessages; - }; - - // Colour, message variants: - // - white: No tests ran. - // - red: Failed [both/all] N test cases, failed [both/all] M assertions. - // - white: Passed [both/all] N test cases (no assertions). - // - red: Failed N tests cases, failed M assertions. - // - green: Passed [both/all] N tests cases with M assertions. - - std::string bothOrAll( std::size_t count ) const { - return count == 1 ? "" : count == 2 ? "both " : "all " ; - } + // using messages.end() directly yields compilation error: + std::vector::const_iterator itEnd = messages.end(); + const std::size_t N = + static_cast(std::distance(itMessage, itEnd)); - void printTotals( const Totals& totals ) const { - if( totals.testCases.total() == 0 ) { - stream << "No tests ran."; - } - else if( totals.testCases.failed == totals.testCases.total() ) { - Colour colour( Colour::ResultError ); - const std::string qualify_assertions_failed = - totals.assertions.failed == totals.assertions.total() ? - bothOrAll( totals.assertions.failed ) : ""; - stream << - "Failed " << bothOrAll( totals.testCases.failed ) - << pluralise( totals.testCases.failed, "test case" ) << ", " - "failed " << qualify_assertions_failed << - pluralise( totals.assertions.failed, "assertion" ) << "."; - } - else if( totals.assertions.total() == 0 ) { - stream << - "Passed " << bothOrAll( totals.testCases.total() ) - << pluralise( totals.testCases.total(), "test case" ) - << " (no assertions)."; - } - else if( totals.assertions.failed ) { - Colour colour( Colour::ResultError ); - stream << - "Failed " << pluralise( totals.testCases.failed, "test case" ) << ", " - "failed " << pluralise( totals.assertions.failed, "assertion" ) << "."; - } - else { - Colour colour( Colour::ResultSuccess ); - stream << - "Passed " << bothOrAll( totals.testCases.passed ) - << pluralise( totals.testCases.passed, "test case" ) << - " with " << pluralise( totals.assertions.passed, "assertion" ) << "."; - } + { + Colour colourGuard(colour); + stream << " with " << pluralise(N, "message") << ":"; + } + + for (; itMessage != itEnd;) { + // If this assertion is a warning ignore any INFO messages + if (printInfoMessages || itMessage->type != ResultWas::Info) { + stream << " '" << itMessage->message << "'"; + if (++itMessage != itEnd) { + Colour colourGuard(dimColour()); + stream << " and"; + } } - }; + } + } + + private: + std::ostream &stream; + AssertionStats const &stats; + AssertionResult const &result; + std::vector messages; + std::vector::const_iterator itMessage; + bool printInfoMessages; + }; + + // Colour, message variants: + // - white: No tests ran. + // - red: Failed [both/all] N test cases, failed [both/all] M assertions. + // - white: Passed [both/all] N test cases (no assertions). + // - red: Failed N tests cases, failed M assertions. + // - green: Passed [both/all] N tests cases with M assertions. + + std::string bothOrAll(std::size_t count) const { + return count == 1 ? "" : count == 2 ? "both " : "all "; + } + + void printTotals(const Totals &totals) const { + if (totals.testCases.total() == 0) { + stream << "No tests ran."; + } else if (totals.testCases.failed == totals.testCases.total()) { + Colour colour(Colour::ResultError); + const std::string qualify_assertions_failed = + totals.assertions.failed == totals.assertions.total() + ? bothOrAll(totals.assertions.failed) + : ""; + stream << "Failed " << bothOrAll(totals.testCases.failed) + << pluralise(totals.testCases.failed, "test case") + << ", " + "failed " + << qualify_assertions_failed + << pluralise(totals.assertions.failed, "assertion") << "."; + } else if (totals.assertions.total() == 0) { + stream << "Passed " << bothOrAll(totals.testCases.total()) + << pluralise(totals.testCases.total(), "test case") + << " (no assertions)."; + } else if (totals.assertions.failed) { + Colour colour(Colour::ResultError); + stream << "Failed " << pluralise(totals.testCases.failed, "test case") + << ", " + "failed " + << pluralise(totals.assertions.failed, "assertion") << "."; + } else { + Colour colour(Colour::ResultSuccess); + stream << "Passed " << bothOrAll(totals.testCases.passed) + << pluralise(totals.testCases.passed, "test case") << " with " + << pluralise(totals.assertions.passed, "assertion") << "."; + } + } +}; - INTERNAL_CATCH_REGISTER_REPORTER( "compact", CompactReporter ) +INTERNAL_CATCH_REGISTER_REPORTER("compact", CompactReporter) } // end namespace Catch namespace Catch { - // These are all here to avoid warnings about not having any out of line - // virtual methods - NonCopyable::~NonCopyable() {} - IShared::~IShared() {} - IStream::~IStream() CATCH_NOEXCEPT {} - FileStream::~FileStream() CATCH_NOEXCEPT {} - CoutStream::~CoutStream() CATCH_NOEXCEPT {} - DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {} - StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {} - IContext::~IContext() {} - IResultCapture::~IResultCapture() {} - ITestCase::~ITestCase() {} - ITestCaseRegistry::~ITestCaseRegistry() {} - IRegistryHub::~IRegistryHub() {} - IMutableRegistryHub::~IMutableRegistryHub() {} - IExceptionTranslator::~IExceptionTranslator() {} - IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {} - IReporter::~IReporter() {} - IReporterFactory::~IReporterFactory() {} - IReporterRegistry::~IReporterRegistry() {} - IStreamingReporter::~IStreamingReporter() {} - AssertionStats::~AssertionStats() {} - SectionStats::~SectionStats() {} - TestCaseStats::~TestCaseStats() {} - TestGroupStats::~TestGroupStats() {} - TestRunStats::~TestRunStats() {} - CumulativeReporterBase::SectionNode::~SectionNode() {} - CumulativeReporterBase::~CumulativeReporterBase() {} - - StreamingReporterBase::~StreamingReporterBase() {} - ConsoleReporter::~ConsoleReporter() {} - CompactReporter::~CompactReporter() {} - IRunner::~IRunner() {} - IMutableContext::~IMutableContext() {} - IConfig::~IConfig() {} - XmlReporter::~XmlReporter() {} - JunitReporter::~JunitReporter() {} - TestRegistry::~TestRegistry() {} - FreeFunctionTestCase::~FreeFunctionTestCase() {} - IGeneratorInfo::~IGeneratorInfo() {} - IGeneratorsForTest::~IGeneratorsForTest() {} - WildcardPattern::~WildcardPattern() {} - TestSpec::Pattern::~Pattern() {} - TestSpec::NamePattern::~NamePattern() {} - TestSpec::TagPattern::~TagPattern() {} - TestSpec::ExcludedPattern::~ExcludedPattern() {} - - Matchers::Impl::StdString::Equals::~Equals() {} - Matchers::Impl::StdString::Contains::~Contains() {} - Matchers::Impl::StdString::StartsWith::~StartsWith() {} - Matchers::Impl::StdString::EndsWith::~EndsWith() {} - - void Config::dummy() {} - - namespace TestCaseTracking { - ITracker::~ITracker() {} - TrackerBase::~TrackerBase() {} - SectionTracker::~SectionTracker() {} - IndexTracker::~IndexTracker() {} - } -} +// These are all here to avoid warnings about not having any out of line +// virtual methods +NonCopyable::~NonCopyable() {} +IShared::~IShared() {} +IStream::~IStream() CATCH_NOEXCEPT {} +FileStream::~FileStream() CATCH_NOEXCEPT {} +CoutStream::~CoutStream() CATCH_NOEXCEPT {} +DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {} +StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {} +IContext::~IContext() {} +IResultCapture::~IResultCapture() {} +ITestCase::~ITestCase() {} +ITestCaseRegistry::~ITestCaseRegistry() {} +IRegistryHub::~IRegistryHub() {} +IMutableRegistryHub::~IMutableRegistryHub() {} +IExceptionTranslator::~IExceptionTranslator() {} +IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {} +IReporter::~IReporter() {} +IReporterFactory::~IReporterFactory() {} +IReporterRegistry::~IReporterRegistry() {} +IStreamingReporter::~IStreamingReporter() {} +AssertionStats::~AssertionStats() {} +SectionStats::~SectionStats() {} +TestCaseStats::~TestCaseStats() {} +TestGroupStats::~TestGroupStats() {} +TestRunStats::~TestRunStats() {} +CumulativeReporterBase::SectionNode::~SectionNode() {} +CumulativeReporterBase::~CumulativeReporterBase() {} + +StreamingReporterBase::~StreamingReporterBase() {} +ConsoleReporter::~ConsoleReporter() {} +CompactReporter::~CompactReporter() {} +IRunner::~IRunner() {} +IMutableContext::~IMutableContext() {} +IConfig::~IConfig() {} +XmlReporter::~XmlReporter() {} +JunitReporter::~JunitReporter() {} +TestRegistry::~TestRegistry() {} +FreeFunctionTestCase::~FreeFunctionTestCase() {} +IGeneratorInfo::~IGeneratorInfo() {} +IGeneratorsForTest::~IGeneratorsForTest() {} +WildcardPattern::~WildcardPattern() {} +TestSpec::Pattern::~Pattern() {} +TestSpec::NamePattern::~NamePattern() {} +TestSpec::TagPattern::~TagPattern() {} +TestSpec::ExcludedPattern::~ExcludedPattern() {} + +Matchers::Impl::StdString::Equals::~Equals() {} +Matchers::Impl::StdString::Contains::~Contains() {} +Matchers::Impl::StdString::StartsWith::~StartsWith() {} +Matchers::Impl::StdString::EndsWith::~EndsWith() {} + +void Config::dummy() {} + +namespace TestCaseTracking { +ITracker::~ITracker() {} +TrackerBase::~TrackerBase() {} +SectionTracker::~SectionTracker() {} +IndexTracker::~IndexTracker() {} +} // namespace TestCaseTracking +} // namespace Catch #ifdef __clang__ #pragma clang diagnostic pop @@ -10280,26 +10318,24 @@ namespace Catch { #ifndef __OBJC__ // Standard C/C++ main entry point -int main (int argc, char * argv[]) { - return Catch::Session().run( argc, argv ); -} +int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); } #else // __OBJC__ // Objective-C entry point -int main (int argc, char * const argv[]) { +int main(int argc, char *const argv[]) { #if !CATCH_ARC_ENABLED - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; #endif - Catch::registerTestMethods(); - int result = Catch::Session().run( argc, (char* const*)argv ); + Catch::registerTestMethods(); + int result = Catch::Session().run(argc, (char *const *)argv); #if !CATCH_ARC_ENABLED - [pool drain]; + [pool drain]; #endif - return result; + return result; } #endif // __OBJC__ @@ -10307,154 +10343,289 @@ int main (int argc, char * const argv[]) { #endif #ifdef CLARA_CONFIG_MAIN_NOT_DEFINED -# undef CLARA_CONFIG_MAIN +#undef CLARA_CONFIG_MAIN #endif ////// -// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +// If this config identifier is defined then all CATCH macros are prefixed with +// CATCH_ #ifdef CATCH_CONFIG_PREFIX_ALL -#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" ) -#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" ) - -#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" ) -#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" ) -#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" ) -#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" ) - -#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" ) -#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CATCH_CHECK_FALSE" ) -#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" ) -#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" ) -#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CATCH_CHECK_NOFAIL" ) - -#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" ) -#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" ) -#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CATCH_CHECK_THROWS_WITH" ) -#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" ) - -#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" ) -#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" ) - -#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) -#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg ) -#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) -#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) -#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) +#define CATCH_REQUIRE(expr) \ + INTERNAL_CATCH_TEST(expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE") +#define CATCH_REQUIRE_FALSE(expr) \ + INTERNAL_CATCH_TEST(expr, \ + Catch::ResultDisposition::Normal | \ + Catch::ResultDisposition::FalseTest, \ + "CATCH_REQUIRE_FALSE") + +#define CATCH_REQUIRE_THROWS(expr) \ + INTERNAL_CATCH_THROWS(expr, Catch::ResultDisposition::Normal, "", \ + "CATCH_REQUIRE_THROWS") +#define CATCH_REQUIRE_THROWS_AS(expr, exceptionType) \ + INTERNAL_CATCH_THROWS_AS(expr, exceptionType, \ + Catch::ResultDisposition::Normal, \ + "CATCH_REQUIRE_THROWS_AS") +#define CATCH_REQUIRE_THROWS_WITH(expr, matcher) \ + INTERNAL_CATCH_THROWS(expr, Catch::ResultDisposition::Normal, matcher, \ + "CATCH_REQUIRE_THROWS_WITH") +#define CATCH_REQUIRE_NOTHROW(expr) \ + INTERNAL_CATCH_NO_THROW(expr, Catch::ResultDisposition::Normal, \ + "CATCH_REQUIRE_NOTHROW") + +#define CATCH_CHECK(expr) \ + INTERNAL_CATCH_TEST(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_CHECK") +#define CATCH_CHECK_FALSE(expr) \ + INTERNAL_CATCH_TEST(expr, \ + Catch::ResultDisposition::ContinueOnFailure | \ + Catch::ResultDisposition::FalseTest, \ + "CATCH_CHECK_FALSE") +#define CATCH_CHECKED_IF(expr) \ + INTERNAL_CATCH_IF(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_CHECKED_IF") +#define CATCH_CHECKED_ELSE(expr) \ + INTERNAL_CATCH_ELSE(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_CHECKED_ELSE") +#define CATCH_CHECK_NOFAIL(expr) \ + INTERNAL_CATCH_TEST(expr, \ + Catch::ResultDisposition::ContinueOnFailure | \ + Catch::ResultDisposition::SuppressFail, \ + "CATCH_CHECK_NOFAIL") + +#define CATCH_CHECK_THROWS(expr) \ + INTERNAL_CATCH_THROWS(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_CHECK_THROWS") +#define CATCH_CHECK_THROWS_AS(expr, exceptionType) \ + INTERNAL_CATCH_THROWS_AS(expr, exceptionType, \ + Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_CHECK_THROWS_AS") +#define CATCH_CHECK_THROWS_WITH(expr, matcher) \ + INTERNAL_CATCH_THROWS(expr, Catch::ResultDisposition::ContinueOnFailure, \ + matcher, "CATCH_CHECK_THROWS_WITH") +#define CATCH_CHECK_NOTHROW(expr) \ + INTERNAL_CATCH_NO_THROW(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_CHECK_NOTHROW") + +#define CHECK_THAT(arg, matcher) \ + INTERNAL_CHECK_THAT(arg, matcher, \ + Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_CHECK_THAT") +#define CATCH_REQUIRE_THAT(arg, matcher) \ + INTERNAL_CHECK_THAT(arg, matcher, Catch::ResultDisposition::Normal, \ + "CATCH_REQUIRE_THAT") + +#define CATCH_INFO(msg) INTERNAL_CATCH_INFO(msg, "CATCH_INFO") +#define CATCH_WARN(msg) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::Warning, \ + Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_WARN", msg) +#define CATCH_SCOPED_INFO(msg) INTERNAL_CATCH_INFO(msg, "CATCH_INFO") +#define CATCH_CAPTURE(msg) \ + INTERNAL_CATCH_INFO(#msg " := " << msg, "CATCH_CAPTURE") +#define CATCH_SCOPED_CAPTURE(msg) \ + INTERNAL_CATCH_INFO(#msg " := " << msg, "CATCH_CAPTURE") #ifdef CATCH_CONFIG_VARIADIC_MACROS - #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) - #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) - #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) - #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) - #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) - #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ ) - #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ ) +#define CATCH_TEST_CASE(...) INTERNAL_CATCH_TESTCASE(__VA_ARGS__) +#define CATCH_TEST_CASE_METHOD(className, ...) \ + INTERNAL_CATCH_TEST_CASE_METHOD(className, __VA_ARGS__) +#define CATCH_METHOD_AS_TEST_CASE(method, ...) \ + INTERNAL_CATCH_METHOD_AS_TEST_CASE(method, __VA_ARGS__) +#define CATCH_REGISTER_TEST_CASE(Function, ...) \ + INTERNAL_CATCH_REGISTER_TESTCASE(Function, __VA_ARGS__) +#define CATCH_SECTION(...) INTERNAL_CATCH_SECTION(__VA_ARGS__) +#define CATCH_FAIL(...) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::ExplicitFailure, \ + Catch::ResultDisposition::Normal, "CATCH_FAIL", \ + __VA_ARGS__) +#define CATCH_SUCCEED(...) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::Ok, \ + Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_SUCCEED", __VA_ARGS__) #else - #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) - #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) - #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) - #define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description ) - #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) - #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg ) - #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg ) +#define CATCH_TEST_CASE(name, description) \ + INTERNAL_CATCH_TESTCASE(name, description) +#define CATCH_TEST_CASE_METHOD(className, name, description) \ + INTERNAL_CATCH_TEST_CASE_METHOD(className, name, description) +#define CATCH_METHOD_AS_TEST_CASE(method, name, description) \ + INTERNAL_CATCH_METHOD_AS_TEST_CASE(method, name, description) +#define CATCH_REGISTER_TEST_CASE(function, name, description) \ + INTERNAL_CATCH_REGISTER_TESTCASE(function, name, description) +#define CATCH_SECTION(name, description) \ + INTERNAL_CATCH_SECTION(name, description) +#define CATCH_FAIL(msg) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::ExplicitFailure, \ + Catch::ResultDisposition::Normal, "CATCH_FAIL", msg) +#define CATCH_SUCCEED(msg) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::Ok, \ + Catch::ResultDisposition::ContinueOnFailure, \ + "CATCH_SUCCEED", msg) #endif -#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE("", "") -#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) -#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) +#define CATCH_REGISTER_REPORTER(name, reporterType) \ + INTERNAL_CATCH_REGISTER_REPORTER(name, reporterType) +#define CATCH_REGISTER_LEGACY_REPORTER(name, reporterType) \ + INTERNAL_CATCH_REGISTER_LEGACY_REPORTER(name, reporterType) -#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) +#define CATCH_GENERATE(expr) INTERNAL_CATCH_GENERATE(expr) // "BDD-style" convenience wrappers #ifdef CATCH_CONFIG_VARIADIC_MACROS -#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) -#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) +#define CATCH_SCENARIO(...) CATCH_TEST_CASE("Scenario: " __VA_ARGS__) +#define CATCH_SCENARIO_METHOD(className, ...) \ + INTERNAL_CATCH_TEST_CASE_METHOD(className, "Scenario: " __VA_ARGS__) #else -#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags ) -#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) +#define CATCH_SCENARIO(name, tags) CATCH_TEST_CASE("Scenario: " name, tags) +#define CATCH_SCENARIO_METHOD(className, name, tags) \ + INTERNAL_CATCH_TEST_CASE_METHOD(className, "Scenario: " name, tags) #endif -#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" ) -#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" ) -#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" ) -#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" ) -#define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" ) - -// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#define CATCH_GIVEN(desc) CATCH_SECTION(std::string("Given: ") + desc, "") +#define CATCH_WHEN(desc) CATCH_SECTION(std::string(" When: ") + desc, "") +#define CATCH_AND_WHEN(desc) CATCH_SECTION(std::string(" And: ") + desc, "") +#define CATCH_THEN(desc) CATCH_SECTION(std::string(" Then: ") + desc, "") +#define CATCH_AND_THEN(desc) CATCH_SECTION(std::string(" And: ") + desc, "") + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not +// required #else -#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" ) -#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" ) - -#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" ) -#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" ) -#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" ) -#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" ) - -#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" ) -#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CHECK_FALSE" ) -#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" ) -#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" ) -#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" ) - -#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" ) -#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" ) -#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" ) -#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" ) - -#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" ) -#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" ) - -#define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) -#define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg ) -#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) -#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) -#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) +#define REQUIRE(expr) \ + INTERNAL_CATCH_TEST(expr, Catch::ResultDisposition::Normal, "REQUIRE") +#define REQUIRE_FALSE(expr) \ + INTERNAL_CATCH_TEST(expr, \ + Catch::ResultDisposition::Normal | \ + Catch::ResultDisposition::FalseTest, \ + "REQUIRE_FALSE") + +#define REQUIRE_THROWS(expr) \ + INTERNAL_CATCH_THROWS(expr, Catch::ResultDisposition::Normal, "", \ + "REQUIRE_THROWS") +#define REQUIRE_THROWS_AS(expr, exceptionType) \ + INTERNAL_CATCH_THROWS_AS(expr, exceptionType, \ + Catch::ResultDisposition::Normal, \ + "REQUIRE_THROWS_AS") +#define REQUIRE_THROWS_WITH(expr, matcher) \ + INTERNAL_CATCH_THROWS(expr, Catch::ResultDisposition::Normal, matcher, \ + "REQUIRE_THROWS_WITH") +#define REQUIRE_NOTHROW(expr) \ + INTERNAL_CATCH_NO_THROW(expr, Catch::ResultDisposition::Normal, \ + "REQUIRE_NOTHROW") + +#define CHECK(expr) \ + INTERNAL_CATCH_TEST(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CHECK") +#define CHECK_FALSE(expr) \ + INTERNAL_CATCH_TEST(expr, \ + Catch::ResultDisposition::ContinueOnFailure | \ + Catch::ResultDisposition::FalseTest, \ + "CHECK_FALSE") +#define CHECKED_IF(expr) \ + INTERNAL_CATCH_IF(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CHECKED_IF") +#define CHECKED_ELSE(expr) \ + INTERNAL_CATCH_ELSE(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CHECKED_ELSE") +#define CHECK_NOFAIL(expr) \ + INTERNAL_CATCH_TEST(expr, \ + Catch::ResultDisposition::ContinueOnFailure | \ + Catch::ResultDisposition::SuppressFail, \ + "CHECK_NOFAIL") + +#define CHECK_THROWS(expr) \ + INTERNAL_CATCH_THROWS(expr, Catch::ResultDisposition::ContinueOnFailure, "", \ + "CHECK_THROWS") +#define CHECK_THROWS_AS(expr, exceptionType) \ + INTERNAL_CATCH_THROWS_AS(expr, exceptionType, \ + Catch::ResultDisposition::ContinueOnFailure, \ + "CHECK_THROWS_AS") +#define CHECK_THROWS_WITH(expr, matcher) \ + INTERNAL_CATCH_THROWS(expr, Catch::ResultDisposition::ContinueOnFailure, \ + matcher, "CHECK_THROWS_WITH") +#define CHECK_NOTHROW(expr) \ + INTERNAL_CATCH_NO_THROW(expr, Catch::ResultDisposition::ContinueOnFailure, \ + "CHECK_NOTHROW") + +#define CHECK_THAT(arg, matcher) \ + INTERNAL_CHECK_THAT( \ + arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT") +#define REQUIRE_THAT(arg, matcher) \ + INTERNAL_CHECK_THAT(arg, matcher, Catch::ResultDisposition::Normal, \ + "REQUIRE_THAT") + +#define INFO(msg) INTERNAL_CATCH_INFO(msg, "INFO") +#define WARN(msg) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::Warning, \ + Catch::ResultDisposition::ContinueOnFailure, "WARN", msg) +#define SCOPED_INFO(msg) INTERNAL_CATCH_INFO(msg, "INFO") +#define CAPTURE(msg) INTERNAL_CATCH_INFO(#msg " := " << msg, "CAPTURE") +#define SCOPED_CAPTURE(msg) INTERNAL_CATCH_INFO(#msg " := " << msg, "CAPTURE") #ifdef CATCH_CONFIG_VARIADIC_MACROS - #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) - #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) - #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) - #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) - #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) - #define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ ) - #define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ ) +#define TEST_CASE(...) INTERNAL_CATCH_TESTCASE(__VA_ARGS__) +#define TEST_CASE_METHOD(className, ...) \ + INTERNAL_CATCH_TEST_CASE_METHOD(className, __VA_ARGS__) +#define METHOD_AS_TEST_CASE(method, ...) \ + INTERNAL_CATCH_METHOD_AS_TEST_CASE(method, __VA_ARGS__) +#define REGISTER_TEST_CASE(Function, ...) \ + INTERNAL_CATCH_REGISTER_TESTCASE(Function, __VA_ARGS__) +#define SECTION(...) INTERNAL_CATCH_SECTION(__VA_ARGS__) +#define FAIL(...) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::ExplicitFailure, \ + Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__) +#define SUCCEED(...) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::Ok, \ + Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", \ + __VA_ARGS__) #else - #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) - #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) - #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) - #define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description ) - #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) - #define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg ) - #define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg ) +#define TEST_CASE(name, description) INTERNAL_CATCH_TESTCASE(name, description) +#define TEST_CASE_METHOD(className, name, description) \ + INTERNAL_CATCH_TEST_CASE_METHOD(className, name, description) +#define METHOD_AS_TEST_CASE(method, name, description) \ + INTERNAL_CATCH_METHOD_AS_TEST_CASE(method, name, description) +#define REGISTER_TEST_CASE(method, name, description) \ + INTERNAL_CATCH_REGISTER_TESTCASE(method, name, description) +#define SECTION(name, description) INTERNAL_CATCH_SECTION(name, description) +#define FAIL(msg) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::ExplicitFailure, \ + Catch::ResultDisposition::Normal, "FAIL", msg) +#define SUCCEED(msg) \ + INTERNAL_CATCH_MSG(Catch::ResultWas::Ok, \ + Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", \ + msg) #endif -#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE("", "") -#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) -#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) +#define REGISTER_REPORTER(name, reporterType) \ + INTERNAL_CATCH_REGISTER_REPORTER(name, reporterType) +#define REGISTER_LEGACY_REPORTER(name, reporterType) \ + INTERNAL_CATCH_REGISTER_LEGACY_REPORTER(name, reporterType) -#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) +#define GENERATE(expr) INTERNAL_CATCH_GENERATE(expr) #endif -#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) +#define CATCH_TRANSLATE_EXCEPTION(signature) \ + INTERNAL_CATCH_TRANSLATE_EXCEPTION(signature) // "BDD-style" convenience wrappers #ifdef CATCH_CONFIG_VARIADIC_MACROS -#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) -#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) +#define SCENARIO(...) TEST_CASE("Scenario: " __VA_ARGS__) +#define SCENARIO_METHOD(className, ...) \ + INTERNAL_CATCH_TEST_CASE_METHOD(className, "Scenario: " __VA_ARGS__) #else -#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) -#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) +#define SCENARIO(name, tags) TEST_CASE("Scenario: " name, tags) +#define SCENARIO_METHOD(className, name, tags) \ + INTERNAL_CATCH_TEST_CASE_METHOD(className, "Scenario: " name, tags) #endif -#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" ) -#define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" ) -#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" ) -#define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" ) -#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" ) +#define GIVEN(desc) SECTION(std::string(" Given: ") + desc, "") +#define WHEN(desc) SECTION(std::string(" When: ") + desc, "") +#define AND_WHEN(desc) SECTION(std::string("And when: ") + desc, "") +#define THEN(desc) SECTION(std::string(" Then: ") + desc, "") +#define AND_THEN(desc) SECTION(std::string(" And: ") + desc, "") using Catch::Detail::Approx; #endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED - diff --git a/command/cxxopts/test/options.cpp b/command/cxxopts/test/options.cpp index 86ce77611..7364404b2 100644 --- a/command/cxxopts/test/options.cpp +++ b/command/cxxopts/test/options.cpp @@ -5,12 +5,9 @@ #include "cxxopts.hpp" class Argv { - public: - - Argv(std::initializer_list args) - : m_argv(new char*[args.size()]) - , m_argc(args.size()) - { +public: + Argv(std::initializer_list args) + : m_argv(new char *[args.size()]), m_argc(args.size()) { int i = 0; auto iter = args.begin(); while (iter != args.end()) { @@ -26,50 +23,41 @@ class Argv { } } - char** argv() const { - return m_argv.get(); - } + char **argv() const { return m_argv.get(); } - int argc() const { - return m_argc; - } - - private: + int argc() const { return m_argc; } +private: std::vector> m_args; - std::unique_ptr m_argv; + std::unique_ptr m_argv; int m_argc; }; -TEST_CASE("Basic options", "[options]") -{ +TEST_CASE("Basic options", "[options]") { cxxopts::Options options("tester", " - test basic options"); - options.add_options() - ("long", "a long option") - ("s,short", "a short option") - ("value", "an option with a value", cxxopts::value()) - ("a,av", "a short option with a value", cxxopts::value()) - ("6,six", "a short number option") - ("p, space", "an option with space between short and long") - ("nothing", "won't exist", cxxopts::value()) - ; + options.add_options()("long", "a long option")("s,short", "a short option")( + "value", "an option with a value", cxxopts::value())( + "a,av", "a short option with a value", + cxxopts::value())("6,six", "a short number option")( + "p, space", "an option with space between short and long")( + "nothing", "won't exist", cxxopts::value()); Argv argv({ - "tester", - "--long", - "-s", - "--value", - "value", - "-a", - "b", - "-6", - "-p", - "--space", + "tester", + "--long", + "-s", + "--value", + "value", + "-a", + "b", + "-6", + "-p", + "--space", }); - char** actual_argv = argv.argv(); + char **actual_argv = argv.argv(); auto argc = argv.argc(); auto result = options.parse(argc, actual_argv); @@ -84,7 +72,7 @@ TEST_CASE("Basic options", "[options]") CHECK(result.count("p") == 2); CHECK(result.count("space") == 2); - auto& arguments = result.arguments(); + auto &arguments = result.arguments(); REQUIRE(arguments.size() == 7); CHECK(arguments[0].key() == "long"); CHECK(arguments[0].value() == "true"); @@ -93,16 +81,14 @@ TEST_CASE("Basic options", "[options]") CHECK(arguments[1].key() == "short"); CHECK(arguments[2].key() == "value"); CHECK(arguments[3].key() == "av"); - - CHECK_THROWS_AS(result["nothing"].as(), std::domain_error&); + + CHECK_THROWS_AS(result["nothing"].as(), std::domain_error &); } -TEST_CASE("Short options", "[options]") -{ +TEST_CASE("Short options", "[options]") { cxxopts::Options options("test_short", " - test short options"); - options.add_options() - ("a", "a short option", cxxopts::value()); + options.add_options()("a", "a short option", cxxopts::value()); Argv argv({"test_short", "-a", "value"}); @@ -115,17 +101,16 @@ TEST_CASE("Short options", "[options]") CHECK(result["a"].as() == "value"); REQUIRE_THROWS_AS(options.add_options()("", "nothing option"), - cxxopts::invalid_option_format_error&); + cxxopts::invalid_option_format_error &); } -TEST_CASE("No positional", "[positional]") -{ +TEST_CASE("No positional", "[positional]") { cxxopts::Options options("test_no_positional", - " - test no positional options"); + " - test no positional options"); Argv av({"tester", "a", "b", "def"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -133,15 +118,12 @@ TEST_CASE("No positional", "[positional]") CHECK(strcmp(argv[1], "a") == 0); } -TEST_CASE("All positional", "[positional]") -{ +TEST_CASE("All positional", "[positional]") { std::vector positional; cxxopts::Options options("test_all_positional", " - test all positional"); - options.add_options() - ("positional", "Positional parameters", - cxxopts::value>(positional)) - ; + options.add_options()("positional", "Positional parameters", + cxxopts::value>(positional)); Argv av({"tester", "a", "b", "c"}); @@ -162,22 +144,19 @@ TEST_CASE("All positional", "[positional]") CHECK(positional[2] == "c"); } -TEST_CASE("Some positional explicit", "[positional]") -{ +TEST_CASE("Some positional explicit", "[positional]") { cxxopts::Options options("positional_explicit", " - test positional"); - options.add_options() - ("input", "Input file", cxxopts::value()) - ("output", "Output file", cxxopts::value()) - ("positional", "Positional parameters", - cxxopts::value>()) - ; + options.add_options()("input", "Input file", cxxopts::value())( + "output", "Output file", cxxopts::value())( + "positional", "Positional parameters", + cxxopts::value>()); options.parse_positional({"input", "output", "positional"}); Argv av({"tester", "--output", "a", "b", "c", "d"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -187,23 +166,20 @@ TEST_CASE("Some positional explicit", "[positional]") CHECK(result["input"].as() == "b"); CHECK(result["output"].as() == "a"); - auto& positional = result["positional"].as>(); + auto &positional = result["positional"].as>(); REQUIRE(positional.size() == 2); CHECK(positional[0] == "c"); CHECK(positional[1] == "d"); } -TEST_CASE("No positional with extras", "[positional]") -{ +TEST_CASE("No positional with extras", "[positional]") { cxxopts::Options options("posargmaster", "shows incorrect handling"); - options.add_options() - ("dummy", "oh no", cxxopts::value()) - ; + options.add_options()("dummy", "oh no", cxxopts::value()); Argv av({"extras", "--", "a", "b", "c", "d"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto old_argv = argv; @@ -218,30 +194,27 @@ TEST_CASE("No positional with extras", "[positional]") TEST_CASE("Positional not valid", "[positional]") { cxxopts::Options options("positional_invalid", "invalid positional argument"); - options.add_options() - ("long", "a long option", cxxopts::value()) - ; + options.add_options()("long", "a long option", cxxopts::value()); options.parse_positional("something"); Argv av({"foobar", "bar", "baz"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); - CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_not_exists_exception&); + CHECK_THROWS_AS(options.parse(argc, argv), + cxxopts::option_not_exists_exception &); } -TEST_CASE("Empty with implicit value", "[implicit]") -{ +TEST_CASE("Empty with implicit value", "[implicit]") { cxxopts::Options options("empty_implicit", "doesn't handle empty"); - options.add_options() - ("implicit", "Has implicit", cxxopts::value() - ->implicit_value("foo")); + options.add_options()("implicit", "Has implicit", + cxxopts::value()->implicit_value("foo")); Argv av({"implicit", "--implicit="}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -250,26 +223,25 @@ TEST_CASE("Empty with implicit value", "[implicit]") REQUIRE(result["implicit"].as() == ""); } -TEST_CASE("Boolean without implicit value", "[implicit]") -{ +TEST_CASE("Boolean without implicit value", "[implicit]") { cxxopts::Options options("no_implicit", "bool without an implicit value"); - options.add_options() - ("bool", "Boolean without implicit", cxxopts::value() - ->no_implicit_value()); + options.add_options()("bool", "Boolean without implicit", + cxxopts::value()->no_implicit_value()); SECTION("When no value provided") { Argv av({"no_implicit", "--bool"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); - CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::missing_argument_exception&); + CHECK_THROWS_AS(options.parse(argc, argv), + cxxopts::missing_argument_exception &); } SECTION("With equal-separated true") { Argv av({"no_implicit", "--bool=true"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -280,7 +252,7 @@ TEST_CASE("Boolean without implicit value", "[implicit]") SECTION("With equal-separated false") { Argv av({"no_implicit", "--bool=false"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -291,7 +263,7 @@ TEST_CASE("Boolean without implicit value", "[implicit]") SECTION("With space-separated true") { Argv av({"no_implicit", "--bool", "true"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -302,7 +274,7 @@ TEST_CASE("Boolean without implicit value", "[implicit]") SECTION("With space-separated false") { Argv av({"no_implicit", "--bool", "false"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -311,26 +283,24 @@ TEST_CASE("Boolean without implicit value", "[implicit]") } } -TEST_CASE("Default values", "[default]") -{ +TEST_CASE("Default values", "[default]") { cxxopts::Options options("defaults", "has defaults"); - options.add_options() - ("default", "Has implicit", cxxopts::value()->default_value("42")) - ("v,vector", "Default vector", cxxopts::value>() - ->default_value("1,4")) - ; + options.add_options()("default", "Has implicit", + cxxopts::value()->default_value("42"))( + "v,vector", "Default vector", + cxxopts::value>()->default_value("1,4")); SECTION("Sets defaults") { Argv av({"implicit"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); CHECK(result.count("default") == 0); CHECK(result["default"].as() == 42); - auto& v = result["vector"].as>(); + auto &v = result["vector"].as>(); REQUIRE(v.size() == 2); CHECK(v[0] == 1); CHECK(v[1] == 4); @@ -339,7 +309,7 @@ TEST_CASE("Default values", "[default]") SECTION("When values provided") { Argv av({"implicit", "--default", "5"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -348,13 +318,11 @@ TEST_CASE("Default values", "[default]") } } -TEST_CASE("Parse into a reference", "[reference]") -{ +TEST_CASE("Parse into a reference", "[reference]") { int value = 0; cxxopts::Options options("into_reference", "parses into a reference"); - options.add_options() - ("ref", "A reference", cxxopts::value(value)); + options.add_options()("ref", "A reference", cxxopts::value(value)); Argv av({"into_reference", "--ref", "42"}); @@ -366,15 +334,14 @@ TEST_CASE("Parse into a reference", "[reference]") CHECK(value == 42); } -TEST_CASE("Integers", "[options]") -{ +TEST_CASE("Integers", "[options]") { cxxopts::Options options("parses_integers", "parses integers correctly"); - options.add_options() - ("positional", "Integers", cxxopts::value>()); + options.add_options()("positional", "Integers", + cxxopts::value>()); Argv av({"ints", "--", "5", "6", "-6", "0", "0xab", "0xAf", "0x0"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); options.parse_positional("positional"); @@ -382,7 +349,7 @@ TEST_CASE("Integers", "[options]") REQUIRE(result.count("positional") == 7); - auto& positional = result["positional"].as>(); + auto &positional = result["positional"].as>(); REQUIRE(positional.size() == 7); CHECK(positional[0] == 5); CHECK(positional[1] == 6); @@ -393,15 +360,14 @@ TEST_CASE("Integers", "[options]") CHECK(positional[6] == 0x0); } -TEST_CASE("Leading zero integers", "[options]") -{ +TEST_CASE("Leading zero integers", "[options]") { cxxopts::Options options("parses_integers", "parses integers correctly"); - options.add_options() - ("positional", "Integers", cxxopts::value>()); + options.add_options()("positional", "Integers", + cxxopts::value>()); Argv av({"ints", "--", "05", "06", "0x0ab", "0x0001"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); options.parse_positional("positional"); @@ -409,7 +375,7 @@ TEST_CASE("Leading zero integers", "[options]") REQUIRE(result.count("positional") == 4); - auto& positional = result["positional"].as>(); + auto &positional = result["positional"].as>(); REQUIRE(positional.size() == 4); CHECK(positional[0] == 5); CHECK(positional[1] == 6); @@ -417,29 +383,27 @@ TEST_CASE("Leading zero integers", "[options]") CHECK(positional[3] == 0x1); } -TEST_CASE("Unsigned integers", "[options]") -{ +TEST_CASE("Unsigned integers", "[options]") { cxxopts::Options options("parses_unsigned", "detects unsigned errors"); - options.add_options() - ("positional", "Integers", cxxopts::value>()); + options.add_options()("positional", "Integers", + cxxopts::value>()); Argv av({"ints", "--", "-2"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); options.parse_positional("positional"); - CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::argument_incorrect_type&); + CHECK_THROWS_AS(options.parse(argc, argv), + cxxopts::argument_incorrect_type &); } -TEST_CASE("Integer bounds", "[integer]") -{ +TEST_CASE("Integer bounds", "[integer]") { cxxopts::Options options("integer_boundaries", "check min/max integer"); - options.add_options() - ("positional", "Integers", cxxopts::value>()); + options.add_options()("positional", "Integers", + cxxopts::value>()); - SECTION("No overflow") - { + SECTION("No overflow") { Argv av({"ints", "--", "127", "-128", "0x7f", "-0x80", "0x7e"}); auto argv = av.argv(); @@ -450,7 +414,7 @@ TEST_CASE("Integer bounds", "[integer]") REQUIRE(result.count("positional") == 5); - auto& positional = result["positional"].as>(); + auto &positional = result["positional"].as>(); CHECK(positional[0] == 127); CHECK(positional[1] == -128); CHECK(positional[2] == 0x7f); @@ -459,28 +423,32 @@ TEST_CASE("Integer bounds", "[integer]") } } -TEST_CASE("Overflow on boundary", "[integer]") -{ +TEST_CASE("Overflow on boundary", "[integer]") { using namespace cxxopts::values; int8_t si; uint8_t ui; - CHECK_THROWS_AS((integer_parser("128", si)), cxxopts::argument_incorrect_type&); - CHECK_THROWS_AS((integer_parser("-129", si)), cxxopts::argument_incorrect_type&); - CHECK_THROWS_AS((integer_parser("256", ui)), cxxopts::argument_incorrect_type&); - CHECK_THROWS_AS((integer_parser("-0x81", si)), cxxopts::argument_incorrect_type&); - CHECK_THROWS_AS((integer_parser("0x80", si)), cxxopts::argument_incorrect_type&); - CHECK_THROWS_AS((integer_parser("0x100", ui)), cxxopts::argument_incorrect_type&); + CHECK_THROWS_AS((integer_parser("128", si)), + cxxopts::argument_incorrect_type &); + CHECK_THROWS_AS((integer_parser("-129", si)), + cxxopts::argument_incorrect_type &); + CHECK_THROWS_AS((integer_parser("256", ui)), + cxxopts::argument_incorrect_type &); + CHECK_THROWS_AS((integer_parser("-0x81", si)), + cxxopts::argument_incorrect_type &); + CHECK_THROWS_AS((integer_parser("0x80", si)), + cxxopts::argument_incorrect_type &); + CHECK_THROWS_AS((integer_parser("0x100", ui)), + cxxopts::argument_incorrect_type &); } -TEST_CASE("Integer overflow", "[options]") -{ +TEST_CASE("Integer overflow", "[options]") { using namespace cxxopts::values; cxxopts::Options options("reject_overflow", "rejects overflowing integers"); - options.add_options() - ("positional", "Integers", cxxopts::value>()); + options.add_options()("positional", "Integers", + cxxopts::value>()); Argv av({"ints", "--", "128"}); @@ -488,23 +456,24 @@ TEST_CASE("Integer overflow", "[options]") auto argc = av.argc(); options.parse_positional("positional"); - CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::argument_incorrect_type&); + CHECK_THROWS_AS(options.parse(argc, argv), + cxxopts::argument_incorrect_type &); int integer = 0; - CHECK_THROWS_AS((integer_parser("23423423423", integer)), cxxopts::argument_incorrect_type&); - CHECK_THROWS_AS((integer_parser("234234234234", integer)), cxxopts::argument_incorrect_type&); + CHECK_THROWS_AS((integer_parser("23423423423", integer)), + cxxopts::argument_incorrect_type &); + CHECK_THROWS_AS((integer_parser("234234234234", integer)), + cxxopts::argument_incorrect_type &); } -TEST_CASE("Floats", "[options]") -{ +TEST_CASE("Floats", "[options]") { cxxopts::Options options("parses_floats", "parses floats correctly"); - options.add_options() - ("double", "Double precision", cxxopts::value()) - ("positional", "Floats", cxxopts::value>()); + options.add_options()("double", "Double precision", cxxopts::value())( + "positional", "Floats", cxxopts::value>()); Argv av({"floats", "--double", "0.5", "--", "4", "-4", "1.5e6", "-1.5e6"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); options.parse_positional("positional"); @@ -515,7 +484,7 @@ TEST_CASE("Floats", "[options]") CHECK(result["double"].as() == 0.5); - auto& positional = result["positional"].as>(); + auto &positional = result["positional"].as>(); CHECK(positional[0] == 4); CHECK(positional[1] == -4); CHECK(positional[2] == 1.5e6); @@ -523,38 +492,38 @@ TEST_CASE("Floats", "[options]") } TEST_CASE("Invalid integers", "[integer]") { - cxxopts::Options options("invalid_integers", "rejects invalid integers"); - options.add_options() - ("positional", "Integers", cxxopts::value>()); + cxxopts::Options options("invalid_integers", "rejects invalid integers"); + options.add_options()("positional", "Integers", + cxxopts::value>()); - Argv av({"ints", "--", "Ae"}); + Argv av({"ints", "--", "Ae"}); - char **argv = av.argv(); - auto argc = av.argc(); + char **argv = av.argv(); + auto argc = av.argc(); - options.parse_positional("positional"); - CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::argument_incorrect_type&); + options.parse_positional("positional"); + CHECK_THROWS_AS(options.parse(argc, argv), + cxxopts::argument_incorrect_type &); } TEST_CASE("Booleans", "[boolean]") { cxxopts::Options options("parses_floats", "parses floats correctly"); - options.add_options() - ("bool", "A Boolean", cxxopts::value()) - ("debug", "Debugging", cxxopts::value()) - ("timing", "Timing", cxxopts::value()) - ("verbose", "Verbose", cxxopts::value()) - ("dry-run", "Dry Run", cxxopts::value()) - ("noExplicitDefault", "No Explicit Default", cxxopts::value()) - ("defaultTrue", "Timing", cxxopts::value()->default_value("true")) - ("defaultFalse", "Timing", cxxopts::value()->default_value("false")) - ("others", "Other arguments", cxxopts::value>()) - ; + options.add_options()("bool", "A Boolean", cxxopts::value())( + "debug", "Debugging", cxxopts::value())("timing", "Timing", + cxxopts::value())( + "verbose", "Verbose", cxxopts::value())("dry-run", "Dry Run", + cxxopts::value())( + "noExplicitDefault", "No Explicit Default", cxxopts::value())( + "defaultTrue", "Timing", cxxopts::value()->default_value("true"))( + "defaultFalse", "Timing", cxxopts::value()->default_value("false"))( + "others", "Other arguments", cxxopts::value>()); options.parse_positional("others"); - Argv av({"booleans", "--bool=false", "--debug=true", "--timing", "--verbose=1", "--dry-run=0", "extra"}); + Argv av({"booleans", "--bool=false", "--debug=true", "--timing", + "--verbose=1", "--dry-run=0", "extra"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); auto result = options.parse(argc, argv); @@ -583,12 +552,12 @@ TEST_CASE("Booleans", "[boolean]") { TEST_CASE("std::vector", "[vector]") { std::vector vector; cxxopts::Options options("vector", " - tests vector"); - options.add_options() - ("vector", "an vector option", cxxopts::value>(vector)); + options.add_options()("vector", "an vector option", + cxxopts::value>(vector)); Argv av({"vector", "--vector", "1,-2.1,3,4.5"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); options.parse(argc, argv); @@ -604,12 +573,12 @@ TEST_CASE("std::vector", "[vector]") { TEST_CASE("std::optional", "[optional]") { std::optional optional; cxxopts::Options options("optional", " - tests optional"); - options.add_options() - ("optional", "an optional option", cxxopts::value>(optional)); + options.add_options()("optional", "an optional option", + cxxopts::value>(optional)); Argv av({"optional", "--optional", "foo"}); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); options.parse(argc, argv); @@ -622,23 +591,22 @@ TEST_CASE("std::optional", "[optional]") { TEST_CASE("Unrecognised options", "[options]") { cxxopts::Options options("unknown_options", " - test unknown options"); - options.add_options() - ("long", "a long option") - ("s,short", "a short option"); + options.add_options()("long", "a long option")("s,short", "a short option"); Argv av({ - "unknown_options", - "--unknown", - "--long", - "-su", - "--another_unknown", + "unknown_options", + "--unknown", + "--long", + "-su", + "--another_unknown", }); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); SECTION("Default behaviour") { - CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_not_exists_exception&); + CHECK_THROWS_AS(options.parse(argc, argv), + cxxopts::option_not_exists_exception &); } SECTION("After allowing unrecognised options") { @@ -652,20 +620,19 @@ TEST_CASE("Unrecognised options", "[options]") { TEST_CASE("Allow bad short syntax", "[options]") { cxxopts::Options options("unknown_options", " - test unknown options"); - options.add_options() - ("long", "a long option") - ("s,short", "a short option"); + options.add_options()("long", "a long option")("s,short", "a short option"); Argv av({ - "unknown_options", - "-some_bad_short", + "unknown_options", + "-some_bad_short", }); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); SECTION("Default behaviour") { - CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_syntax_exception&); + CHECK_THROWS_AS(options.parse(argc, argv), + cxxopts::option_syntax_exception &); } SECTION("After allowing unrecognised options") { @@ -680,14 +647,15 @@ TEST_CASE("Invalid option syntax", "[options]") { cxxopts::Options options("invalid_syntax", " - test invalid syntax"); Argv av({ - "invalid_syntax", - "--a", + "invalid_syntax", + "--a", }); - char** argv = av.argv(); + char **argv = av.argv(); auto argc = av.argc(); SECTION("Default behaviour") { - CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_syntax_exception&); + CHECK_THROWS_AS(options.parse(argc, argv), + cxxopts::option_syntax_exception &); } } diff --git a/common/API.h b/common/API.h index 4313699f7..07d126f87 100644 --- a/common/API.h +++ b/common/API.h @@ -23,28 +23,28 @@ // From https://gcc.gnu.org/wiki/Visibility #if defined _WIN32 || defined __CYGWIN__ - #ifdef EXPORT_PSY_API - #ifdef __GNUC__ - #define PSY_API __attribute__ ((dllexport)) - #else - #define PSY_API __declspec(dllexport) - #endif - #else - #ifdef __GNUC__ - #define PSY_API __attribute__ ((dllimport)) - #else - #define PSY_API __declspec(dllimport) - #endif - #endif - #define PSY_API_LOCAL +#ifdef EXPORT_PSY_API +#ifdef __GNUC__ +#define PSY_API __attribute__((dllexport)) #else - #if __GNUC__ >= 4 - #define PSY_API __attribute__ ((visibility ("default"))) - #define PSY_API_LOCAL __attribute__ ((visibility ("hidden"))) - #else - #define PSY_API - #define PSY_API_LOCAL - #endif +#define PSY_API __declspec(dllexport) +#endif +#else +#ifdef __GNUC__ +#define PSY_API __attribute__((dllimport)) +#else +#define PSY_API __declspec(dllimport) +#endif +#endif +#define PSY_API_LOCAL +#else +#if __GNUC__ >= 4 +#define PSY_API __attribute__((visibility("default"))) +#define PSY_API_LOCAL __attribute__((visibility("hidden"))) +#else +#define PSY_API +#define PSY_API_LOCAL +#endif #endif #endif diff --git a/common/diagnostics/Diagnostic.cpp b/common/diagnostics/Diagnostic.cpp index e76b517b1..d56a7b2a4 100644 --- a/common/diagnostics/Diagnostic.cpp +++ b/common/diagnostics/Diagnostic.cpp @@ -24,47 +24,40 @@ using namespace psy; -Diagnostic::Diagnostic(DiagnosticDescriptor descriptor, - Location location, +Diagnostic::Diagnostic(DiagnosticDescriptor descriptor, Location location, std::string snippet) - : descriptor_(std::move(descriptor)) - , location_(std::move(location)) - , snippet_(std::move(snippet)) - , outputIndent_(0) -{} + : descriptor_(std::move(descriptor)), location_(std::move(location)), + snippet_(std::move(snippet)), outputIndent_(0) {} -DiagnosticSeverity Diagnostic::severity() const -{ - // TODO: Implement "warning as error". +DiagnosticSeverity Diagnostic::severity() const { + // TODO: Implement "warning as error". - return descriptor_.defaultSeverity(); + return descriptor_.defaultSeverity(); } namespace psy { -std::ostream& operator<<(std::ostream& os, const Diagnostic& diagnostic) -{ - if (diagnostic.outputIndent_) - os << std::string(diagnostic.outputIndent_, '\t'); +std::ostream &operator<<(std::ostream &os, const Diagnostic &diagnostic) { + if (diagnostic.outputIndent_) + os << std::string(diagnostic.outputIndent_, '\t'); - os << diagnostic.location().lineSpan().path() << ":" - << diagnostic.location().lineSpan().span().start() << " " - << diagnostic.severity() << ": " - << diagnostic.descriptor().description(); + os << diagnostic.location().lineSpan().path() << ":" + << diagnostic.location().lineSpan().span().start() << " " + << diagnostic.severity() << ": " << diagnostic.descriptor().description(); - if (!diagnostic.snippet().empty()) { - os << "\n"; + if (!diagnostic.snippet().empty()) { + os << "\n"; - auto s = diagnostic.snippet(); - if (diagnostic.outputIndent_) { - std::string indent(diagnostic.outputIndent_, '\t'); - os << indent; - s = std::regex_replace(s, std::regex("\n"), "\n" + indent); - } - os << s; + auto s = diagnostic.snippet(); + if (diagnostic.outputIndent_) { + std::string indent(diagnostic.outputIndent_, '\t'); + os << indent; + s = std::regex_replace(s, std::regex("\n"), "\n" + indent); } + os << s; + } - return os; + return os; } -} // psy +} // namespace psy diff --git a/common/diagnostics/Diagnostic.h b/common/diagnostics/Diagnostic.h index 10ae759ba..1814bb222 100644 --- a/common/diagnostics/Diagnostic.h +++ b/common/diagnostics/Diagnostic.h @@ -38,50 +38,53 @@ namespace psy { -namespace C { class InternalsTestSuite; } +namespace C { +class InternalsTestSuite; +} /** * The Diagnostics class. */ -class PSY_API Diagnostic -{ +class PSY_API Diagnostic { public: - Diagnostic(DiagnosticDescriptor descriptor, - Location location, - std::string snippet = ""); - - /** - * The DiagnosticDescriptor of \c this Diagnostic. - */ - const DiagnosticDescriptor& descriptor() const { return descriptor_; } - - /** - * The actual severity (according to compilation options) of \c this Diagnostic. - */ - DiagnosticSeverity severity() const; - - /** - * The Location of \c this Location. - */ - const Location& location() const { return location_; } - - /** - * The code snippet associated to \c this Diagnostic. - */ - const std::string& snippet() const { return snippet_; } + Diagnostic(DiagnosticDescriptor descriptor, Location location, + std::string snippet = ""); + + /** + * The DiagnosticDescriptor of \c this Diagnostic. + */ + const DiagnosticDescriptor &descriptor() const { return descriptor_; } + + /** + * The actual severity (according to compilation options) of \c this + * Diagnostic. + */ + DiagnosticSeverity severity() const; + + /** + * The Location of \c this Location. + */ + const Location &location() const { return location_; } + + /** + * The code snippet associated to \c this Diagnostic. + */ + const std::string &snippet() const { return snippet_; } private: - DiagnosticDescriptor descriptor_; - Location location_; - std::string snippet_; - std::string::size_type outputIndent_; - - friend std::ostream& operator<<(std::ostream& os, const Diagnostic& diagnostic); - friend class C::InternalsTestSuite; + DiagnosticDescriptor descriptor_; + Location location_; + std::string snippet_; + std::string::size_type outputIndent_; + + friend std::ostream &operator<<(std::ostream &os, + const Diagnostic &diagnostic); + friend class C::InternalsTestSuite; }; -PSY_API std::ostream& operator<<(std::ostream& os, const Diagnostic& diagnostic); +PSY_API std::ostream &operator<<(std::ostream &os, + const Diagnostic &diagnostic); -} // psy +} // namespace psy #endif diff --git a/common/diagnostics/DiagnosticCategory.cpp b/common/diagnostics/DiagnosticCategory.cpp index f34d841a2..f23e3abe2 100644 --- a/common/diagnostics/DiagnosticCategory.cpp +++ b/common/diagnostics/DiagnosticCategory.cpp @@ -22,27 +22,26 @@ namespace psy { -std::ostream& operator<<(std::ostream& os, DiagnosticCategory category) -{ - switch (category) { - case DiagnosticCategory::Syntax: - os << "syntax"; - break; - - case DiagnosticCategory::Binding: - os << "binding"; - break; - - case DiagnosticCategory::Typing: - os << "typing"; - break; - - case DiagnosticCategory::UNSPECIFIED: - os << "generic"; - break; - } - - return os; +std::ostream &operator<<(std::ostream &os, DiagnosticCategory category) { + switch (category) { + case DiagnosticCategory::Syntax: + os << "syntax"; + break; + + case DiagnosticCategory::Binding: + os << "binding"; + break; + + case DiagnosticCategory::Typing: + os << "typing"; + break; + + case DiagnosticCategory::UNSPECIFIED: + os << "generic"; + break; + } + + return os; } -} // psy +} // namespace psy diff --git a/common/diagnostics/DiagnosticCategory.h b/common/diagnostics/DiagnosticCategory.h index f40f9f952..5817b4f12 100644 --- a/common/diagnostics/DiagnosticCategory.h +++ b/common/diagnostics/DiagnosticCategory.h @@ -25,17 +25,16 @@ namespace psy { -enum class DiagnosticCategory : char -{ - UNSPECIFIED = 0, +enum class DiagnosticCategory : char { + UNSPECIFIED = 0, - Syntax, - Binding, - Typing, + Syntax, + Binding, + Typing, }; -std::ostream& operator<<(std::ostream& os, DiagnosticCategory category); +std::ostream &operator<<(std::ostream &os, DiagnosticCategory category); -} // psy +} // namespace psy #endif diff --git a/common/diagnostics/DiagnosticDescriptor.cpp b/common/diagnostics/DiagnosticDescriptor.cpp index 7f3ca4ada..608f19480 100644 --- a/common/diagnostics/DiagnosticDescriptor.cpp +++ b/common/diagnostics/DiagnosticDescriptor.cpp @@ -22,39 +22,23 @@ using namespace psy; -DiagnosticDescriptor::DiagnosticDescriptor(std::string id, - std::string title, +DiagnosticDescriptor::DiagnosticDescriptor(std::string id, std::string title, std::string description, DiagnosticSeverity defaultSeverity, DiagnosticCategory category) - : id_(std::move(id)) - , title_(std::move(title)) - , description_(description) - , defaultSeverity_(defaultSeverity) - , category_(category) -{} - -const std::string& DiagnosticDescriptor::id() const -{ - return id_; -} + : id_(std::move(id)), title_(std::move(title)), description_(description), + defaultSeverity_(defaultSeverity), category_(category) {} -const std::string& DiagnosticDescriptor::title() const -{ - return title_; -} +const std::string &DiagnosticDescriptor::id() const { return id_; } -const std::string& DiagnosticDescriptor::description() const -{ - return description_; -} +const std::string &DiagnosticDescriptor::title() const { return title_; } -DiagnosticSeverity DiagnosticDescriptor::defaultSeverity() const -{ - return defaultSeverity_; +const std::string &DiagnosticDescriptor::description() const { + return description_; } -DiagnosticCategory DiagnosticDescriptor::category() const -{ - return category_; +DiagnosticSeverity DiagnosticDescriptor::defaultSeverity() const { + return defaultSeverity_; } + +DiagnosticCategory DiagnosticDescriptor::category() const { return category_; } diff --git a/common/diagnostics/DiagnosticDescriptor.h b/common/diagnostics/DiagnosticDescriptor.h index de1bd43c7..95f67683c 100644 --- a/common/diagnostics/DiagnosticDescriptor.h +++ b/common/diagnostics/DiagnosticDescriptor.h @@ -37,48 +37,46 @@ namespace psy { /** * The DiagnosticDescriptor class. */ -class PSY_API DiagnosticDescriptor -{ +class PSY_API DiagnosticDescriptor { public: - DiagnosticDescriptor(std::string id, - std::string title, - std::string description, - DiagnosticSeverity defaultSeverity, - DiagnosticCategory category); + DiagnosticDescriptor(std::string id, std::string title, + std::string description, + DiagnosticSeverity defaultSeverity, + DiagnosticCategory category); - /** - * The ID of \c this DiagnosticDescriptor. - */ - const std::string& id() const; + /** + * The ID of \c this DiagnosticDescriptor. + */ + const std::string &id() const; - /** - * The title of \c this DiagnosticDescriptor. - */ - const std::string& title() const; + /** + * The title of \c this DiagnosticDescriptor. + */ + const std::string &title() const; - /** - * The description of \c this DiagnosticDescriptor. - */ - const std::string& description() const; + /** + * The description of \c this DiagnosticDescriptor. + */ + const std::string &description() const; - /** - * The default severity of \c this DiagnosticDescriptor. - */ - DiagnosticSeverity defaultSeverity() const; + /** + * The default severity of \c this DiagnosticDescriptor. + */ + DiagnosticSeverity defaultSeverity() const; - /** - * The category of \c this DiagnosticDescriptor. - */ - DiagnosticCategory category() const; + /** + * The category of \c this DiagnosticDescriptor. + */ + DiagnosticCategory category() const; private: - std::string id_; - std::string title_; - std::string description_; - DiagnosticSeverity defaultSeverity_; - DiagnosticCategory category_; + std::string id_; + std::string title_; + std::string description_; + DiagnosticSeverity defaultSeverity_; + DiagnosticCategory category_; }; -} // psy +} // namespace psy #endif diff --git a/common/diagnostics/DiagnosticSeverity.cpp b/common/diagnostics/DiagnosticSeverity.cpp index efb49c989..5487de36e 100644 --- a/common/diagnostics/DiagnosticSeverity.cpp +++ b/common/diagnostics/DiagnosticSeverity.cpp @@ -24,23 +24,21 @@ namespace psy { -std::ostream& operator<<(std::ostream& os, DiagnosticSeverity severity) -{ - switch (severity) - { - case DiagnosticSeverity::Warning: - os << "warning"; - break; - - case DiagnosticSeverity::Error: - os << "error"; - break; - - default: - PSY_ESCAPE_VIA_RETURN(os); - } - - return os; +std::ostream &operator<<(std::ostream &os, DiagnosticSeverity severity) { + switch (severity) { + case DiagnosticSeverity::Warning: + os << "warning"; + break; + + case DiagnosticSeverity::Error: + os << "error"; + break; + + default: + PSY_ESCAPE_VIA_RETURN(os); + } + + return os; } -} // psy +} // namespace psy diff --git a/common/diagnostics/DiagnosticSeverity.h b/common/diagnostics/DiagnosticSeverity.h index 6ea919e19..44035cc30 100644 --- a/common/diagnostics/DiagnosticSeverity.h +++ b/common/diagnostics/DiagnosticSeverity.h @@ -25,16 +25,15 @@ namespace psy { -enum class DiagnosticSeverity : char -{ - UNSPECIFIED = 0, +enum class DiagnosticSeverity : char { + UNSPECIFIED = 0, - Warning, - Error + Warning, + Error }; -std::ostream& operator<<(std::ostream& os, DiagnosticSeverity severity); +std::ostream &operator<<(std::ostream &os, DiagnosticSeverity severity); -} // psy +} // namespace psy #endif diff --git a/common/infra/Assertions.h b/common/infra/Assertions.h index f1c7e92bd..2961ca223 100644 --- a/common/infra/Assertions.h +++ b/common/infra/Assertions.h @@ -25,22 +25,23 @@ #include #ifndef NDEBUG - #define PSY_ASSERT_W_MSG(COND_EXPR, STMT, MSG) \ - do { \ - if (COND_EXPR) {} \ - else { \ - std::cout << "[ASSERT] at " \ - << __FILE__ << ":" << __LINE__ << " " \ - << MSG << std::endl; \ - STMT; \ - } \ - } while (0) - #define PSY_ASSERT(COND_EXPR, STMT) PSY_ASSERT_W_MSG(COND_EXPR, STMT, "") - #define PSY_ASSERT_NO_STMT(COND_EXPR) PSY_ASSERT_W_MSG(COND_EXPR, {}, "") +#define PSY_ASSERT_W_MSG(COND_EXPR, STMT, MSG) \ + do { \ + if (COND_EXPR) { \ + } else { \ + std::cout << "[ASSERT] at " << __FILE__ << ":" << __LINE__ << " " << MSG \ + << std::endl; \ + STMT; \ + } \ + } while (0) +#define PSY_ASSERT(COND_EXPR, STMT) \ + PSY_ASSERT_W_MSG(COND_EXPR, STMT, "") +#define PSY_ASSERT_NO_STMT(COND_EXPR) \ + PSY_ASSERT_W_MSG(COND_EXPR, {}, "") #else - #define PSY_ASSERT_W_MSG(COND_EXPR, STMT, MSG) - #define PSY_ASSERT(COND_EXPR, STMT) - #define PSY_ASSERT_NO_STMT(COND_EXPR) +#define PSY_ASSERT_W_MSG(COND_EXPR, STMT, MSG) +#define PSY_ASSERT(COND_EXPR, STMT) +#define PSY_ASSERT_NO_STMT(COND_EXPR) #endif #endif diff --git a/common/infra/Escape.h b/common/infra/Escape.h index 06169643a..e3814c0cd 100644 --- a/common/infra/Escape.h +++ b/common/infra/Escape.h @@ -23,13 +23,12 @@ #include -#define PSY_ESCAPE(STMT) \ -do { \ - std::cout << "[ESCAPE] at " \ - << __FILE__ << ":" << __LINE__ << " " \ - << std::endl; \ - STMT; \ -} while (0) +#define PSY_ESCAPE(STMT) \ + do { \ + std::cout << "[ESCAPE] at " << __FILE__ << ":" << __LINE__ << " " \ + << std::endl; \ + STMT; \ + } while (0) #define PSY_ESCAPE_VIA_RETURN(EXPR) PSY_ESCAPE(return EXPR) #define PSY_ESCAPE_VIA_BREAK PSY_ESCAPE(break) diff --git a/common/infra/Pimpl.h b/common/infra/Pimpl.h index 4c499ad61..b7c5cbf3f 100644 --- a/common/infra/Pimpl.h +++ b/common/infra/Pimpl.h @@ -29,17 +29,17 @@ #include -#define DECL_PIMPL(CLASS) \ - struct CLASS##Impl; \ - std::unique_ptr impl_; +#define DECL_PIMPL(CLASS) \ + struct CLASS##Impl; \ + std::unique_ptr impl_; -#define DECL_PIMPL_SUB(CLASS) \ - struct CLASS##Impl; \ - CLASS##Impl* CAST() const { return ((CLASS##Impl*)impl_.get()); } +#define DECL_PIMPL_SUB(CLASS) \ + struct CLASS##Impl; \ + CLASS##Impl *CAST() const { return ((CLASS##Impl *)impl_.get()); } -#define DECL_SHARED_DATA(CLASS) \ - struct CLASS##Impl; \ - std::shared_ptr impl_; +#define DECL_SHARED_DATA(CLASS) \ + struct CLASS##Impl; \ + std::shared_ptr impl_; #define P impl_ #define P_CAST CAST() diff --git a/common/location/FileLinePositionSpan.cpp b/common/location/FileLinePositionSpan.cpp index 4f9894b0d..0ab8d28a9 100644 --- a/common/location/FileLinePositionSpan.cpp +++ b/common/location/FileLinePositionSpan.cpp @@ -22,15 +22,13 @@ namespace psy { -bool operator==(const FileLinePositionSpan& a, const FileLinePositionSpan& b) -{ - return a.path() == b.path() && a.span() == b.span(); +bool operator==(const FileLinePositionSpan &a, const FileLinePositionSpan &b) { + return a.path() == b.path() && a.span() == b.span(); } -std::ostream& operator<<(std::ostream& os, const FileLinePositionSpan& span) -{ - os << span.path() << ":" << span.span(); - return os; +std::ostream &operator<<(std::ostream &os, const FileLinePositionSpan &span) { + os << span.path() << ":" << span.span(); + return os; } -} // psy +} // namespace psy diff --git a/common/location/FileLinePositionSpan.h b/common/location/FileLinePositionSpan.h index 746583a6d..4d1e990c8 100644 --- a/common/location/FileLinePositionSpan.h +++ b/common/location/FileLinePositionSpan.h @@ -37,53 +37,48 @@ namespace psy { * within a file. * * \note - * This API is inspired by that of \c Microsoft.CodeAnalysis.FileLinePositionSpan - * from Roslyn, the .NET Compiler Platform. + * This API is inspired by that of \c + * Microsoft.CodeAnalysis.FileLinePositionSpan from Roslyn, the .NET Compiler + * Platform. */ -class PSY_API FileLinePositionSpan -{ +class PSY_API FileLinePositionSpan { public: - FileLinePositionSpan(std::string path, LinePositionSpan span) - : path_(std::move(path)) - , span_(std::move(span)) - {} - - FileLinePositionSpan(std::string path, - const LinePosition& start, - const LinePosition& end) - : path_(std::move(path)) - , span_(start, end) - {} - - /** - * The path of the file. - */ - std::string path() const { return path_; } - - /** - * The line span within the file. - */ - LinePositionSpan span() const { return span_; } - - /** - * The line position of the end of the span. - */ - LinePosition endLinePosition() const { return span_.end(); } - - /** - * The line position of the start of the span. - */ - LinePosition starLinePosition() const { return span_.start(); } + FileLinePositionSpan(std::string path, LinePositionSpan span) + : path_(std::move(path)), span_(std::move(span)) {} + + FileLinePositionSpan(std::string path, const LinePosition &start, + const LinePosition &end) + : path_(std::move(path)), span_(start, end) {} + + /** + * The path of the file. + */ + std::string path() const { return path_; } + + /** + * The line span within the file. + */ + LinePositionSpan span() const { return span_; } + + /** + * The line position of the end of the span. + */ + LinePosition endLinePosition() const { return span_.end(); } + + /** + * The line position of the start of the span. + */ + LinePosition starLinePosition() const { return span_.start(); } private: - std::string path_; - LinePositionSpan span_; + std::string path_; + LinePositionSpan span_; }; -bool operator==(const FileLinePositionSpan& a, const FileLinePositionSpan& b); +bool operator==(const FileLinePositionSpan &a, const FileLinePositionSpan &b); -std::ostream& operator<<(std::ostream& os, const FileLinePositionSpan& span); +std::ostream &operator<<(std::ostream &os, const FileLinePositionSpan &span); -} // psy +} // namespace psy #endif diff --git a/common/location/LinePosition.cpp b/common/location/LinePosition.cpp index 873d787d2..2bc1606c8 100644 --- a/common/location/LinePosition.cpp +++ b/common/location/LinePosition.cpp @@ -22,23 +22,20 @@ namespace psy { -bool operator==(const LinePosition& a, const LinePosition& b) -{ - return a.line() == b.line() && a.character() == b.character(); +bool operator==(const LinePosition &a, const LinePosition &b) { + return a.line() == b.line() && a.character() == b.character(); } -bool operator<(const LinePosition& a, const LinePosition& b) -{ - const int al = a.line(); - const int bl = b.line(); +bool operator<(const LinePosition &a, const LinePosition &b) { + const int al = a.line(); + const int bl = b.line(); - return al != bl ? al < bl : a.character() < b.character(); + return al != bl ? al < bl : a.character() < b.character(); } -std::ostream& operator<<(std::ostream& os, const LinePosition& pos) -{ - os << pos.line() << ":" << pos.character(); - return os; +std::ostream &operator<<(std::ostream &os, const LinePosition &pos) { + os << pos.line() << ":" << pos.character(); + return os; } -} // psy +} // namespace psy diff --git a/common/location/LinePosition.h b/common/location/LinePosition.h index 43f9cc446..a632a1369 100644 --- a/common/location/LinePosition.h +++ b/common/location/LinePosition.h @@ -31,35 +31,31 @@ namespace psy { -class PSY_API LinePosition -{ +class PSY_API LinePosition { public: - LinePosition(int line, int character) - : line_(line) - , character_(character) - {} + LinePosition(int line, int character) : line_(line), character_(character) {} - /** - * The line number. - */ - int line() const { return line_; } + /** + * The line number. + */ + int line() const { return line_; } - /** - * The character position within the line. - */ - int character() const { return character_; } + /** + * The character position within the line. + */ + int character() const { return character_; } private: - int line_ = 0; - int character_ = 0; + int line_ = 0; + int character_ = 0; }; -bool operator==(const LinePosition& a, const LinePosition& b); +bool operator==(const LinePosition &a, const LinePosition &b); -bool operator<(const LinePosition& a, const LinePosition& b); +bool operator<(const LinePosition &a, const LinePosition &b); -PSY_API std::ostream& operator<<(std::ostream& os, const LinePosition& pos); +PSY_API std::ostream &operator<<(std::ostream &os, const LinePosition &pos); -} // psy +} // namespace psy #endif diff --git a/common/location/LinePositionSpan.cpp b/common/location/LinePositionSpan.cpp index e60ad57df..141875f83 100644 --- a/common/location/LinePositionSpan.cpp +++ b/common/location/LinePositionSpan.cpp @@ -22,15 +22,13 @@ namespace psy { -bool operator==(const LinePositionSpan& a, const LinePositionSpan& b) -{ - return a.start() == b.start() && a.end() == b.end(); +bool operator==(const LinePositionSpan &a, const LinePositionSpan &b) { + return a.start() == b.start() && a.end() == b.end(); } -std::ostream& operator<<(std::ostream& os, const LinePositionSpan& span) -{ - os << span.start() << "-" << span.end(); - return os; +std::ostream &operator<<(std::ostream &os, const LinePositionSpan &span) { + os << span.start() << "-" << span.end(); + return os; } -} // psy +} // namespace psy diff --git a/common/location/LinePositionSpan.h b/common/location/LinePositionSpan.h index 5d902bff2..804746405 100644 --- a/common/location/LinePositionSpan.h +++ b/common/location/LinePositionSpan.h @@ -34,36 +34,34 @@ namespace psy { * An abstraction representation of a line within a file. * * \note - * This API is inspired by that of \c Microsoft.CodeAnalysis.Text.LinePositionSpan - * from Roslyn, the .NET Compiler Platform. + * This API is inspired by that of \c + * Microsoft.CodeAnalysis.Text.LinePositionSpan from Roslyn, the .NET Compiler + * Platform. */ -class PSY_API LinePositionSpan -{ +class PSY_API LinePositionSpan { public: - LinePositionSpan(const LinePosition& start, const LinePosition& end) - : start_(start) - , end_(end) - {} + LinePositionSpan(const LinePosition &start, const LinePosition &end) + : start_(start), end_(end) {} - /** - * The start position of \c this span. - */ - LinePosition start() const { return start_; } + /** + * The start position of \c this span. + */ + LinePosition start() const { return start_; } - /** - * The end position of \c this span. - */ - LinePosition end() const { return end_; } + /** + * The end position of \c this span. + */ + LinePosition end() const { return end_; } private: - LinePosition start_; - LinePosition end_; + LinePosition start_; + LinePosition end_; }; -bool operator==(const LinePositionSpan& a, const LinePositionSpan& b); +bool operator==(const LinePositionSpan &a, const LinePositionSpan &b); -std::ostream& operator<<(std::ostream& os, const LinePositionSpan& span); +std::ostream &operator<<(std::ostream &os, const LinePositionSpan &span); -} // psy +} // namespace psy #endif diff --git a/common/location/Location.cpp b/common/location/Location.cpp index 609ecb67d..2dd3a16c6 100644 --- a/common/location/Location.cpp +++ b/common/location/Location.cpp @@ -23,35 +23,29 @@ using namespace psy; Location::Location(std::string filePath, LinePositionSpan lineSpan) - : fileLineSpan_(filePath, lineSpan) -{} + : fileLineSpan_(filePath, lineSpan) {} Location::Location(FileLinePositionSpan fileLineSpan) - : fileLineSpan_(std::move(fileLineSpan)) -{} + : fileLineSpan_(std::move(fileLineSpan)) {} -Location Location::create(std::string filePath, LinePositionSpan span) -{ - Location loc(filePath, span); - return loc; +Location Location::create(std::string filePath, LinePositionSpan span) { + Location loc(filePath, span); + return loc; } -Location Location::create(FileLinePositionSpan fileLineSpan) -{ - return Location(std::move(fileLineSpan)); +Location Location::create(FileLinePositionSpan fileLineSpan) { + return Location(std::move(fileLineSpan)); } namespace psy { -bool operator==(const Location& a, const Location& b) -{ - return a.lineSpan() == b.lineSpan(); +bool operator==(const Location &a, const Location &b) { + return a.lineSpan() == b.lineSpan(); } -std::ostream& operator<<(std::ostream& os, const Location& loc) -{ - os << loc.lineSpan(); - return os; +std::ostream &operator<<(std::ostream &os, const Location &loc) { + os << loc.lineSpan(); + return os; } -} // psy +} // namespace psy diff --git a/common/location/Location.h b/common/location/Location.h index e46667a5f..21cb6f4aa 100644 --- a/common/location/Location.h +++ b/common/location/Location.h @@ -37,28 +37,27 @@ namespace psy { * This API is inspired by that of \c Microsoft.CodeAnalysis.Location * from Roslyn, the .NET Compiler Platform. */ -class PSY_API Location -{ +class PSY_API Location { public: - static Location create(std::string filePath, LinePositionSpan lineSpan); - static Location create(FileLinePositionSpan fileLineSpan); + static Location create(std::string filePath, LinePositionSpan lineSpan); + static Location create(FileLinePositionSpan fileLineSpan); - /** - * The file, line, and column of \c this Location. - */ - const FileLinePositionSpan& lineSpan() const { return fileLineSpan_; } + /** + * The file, line, and column of \c this Location. + */ + const FileLinePositionSpan &lineSpan() const { return fileLineSpan_; } private: - Location(std::string filePath, LinePositionSpan lineSpan); - Location(FileLinePositionSpan fileLineSpan); + Location(std::string filePath, LinePositionSpan lineSpan); + Location(FileLinePositionSpan fileLineSpan); - FileLinePositionSpan fileLineSpan_; + FileLinePositionSpan fileLineSpan_; }; -bool operator==(const Location& a, const Location& b); +bool operator==(const Location &a, const Location &b); -std::ostream& operator<<(std::ostream& os, const Location& loc); +std::ostream &operator<<(std::ostream &os, const Location &loc); -} // psy +} // namespace psy #endif diff --git a/common/text/SourceText.cpp b/common/text/SourceText.cpp index b4a04679d..b9eec3bcc 100644 --- a/common/text/SourceText.cpp +++ b/common/text/SourceText.cpp @@ -22,11 +22,6 @@ using namespace psy; -SourceText::SourceText(std::string rawText) - : rawText_(std::move(rawText)) -{} +SourceText::SourceText(std::string rawText) : rawText_(std::move(rawText)) {} -const std::string& SourceText::rawText() const -{ - return rawText_; -} +const std::string &SourceText::rawText() const { return rawText_; } diff --git a/common/text/SourceText.h b/common/text/SourceText.h index ef9d41e4b..f5ae18e58 100644 --- a/common/text/SourceText.h +++ b/common/text/SourceText.h @@ -34,17 +34,16 @@ namespace psy { /** * The SourceText class. */ -class PSY_API SourceText -{ +class PSY_API SourceText { public: - SourceText(std::string rawText); + SourceText(std::string rawText); - const std::string& rawText() const; + const std::string &rawText() const; private: - std::string rawText_; + std::string rawText_; }; -} // psy +} // namespace psy #endif diff --git a/common/text/TextElement.cpp b/common/text/TextElement.cpp index 2faac21f5..8b1ac42bb 100644 --- a/common/text/TextElement.cpp +++ b/common/text/TextElement.cpp @@ -25,55 +25,47 @@ using namespace psy; -TextElement::TextElement(const char* chars, unsigned int size) - : size_(size) - , chars_(new char[size + 1]) - , next_(nullptr) -{ - std::strncpy(chars_, chars, size); - chars_[size] = 0; - hashCode_ = hashCode(chars_, size_); +TextElement::TextElement(const char *chars, unsigned int size) + : size_(size), chars_(new char[size + 1]), next_(nullptr) { + std::strncpy(chars_, chars, size); + chars_[size] = 0; + hashCode_ = hashCode(chars_, size_); } -TextElement::~TextElement() -{ - delete[] chars_; -} +TextElement::~TextElement() { delete[] chars_; } -unsigned int TextElement::hashCode(const char* chars, unsigned int size) -{ - // Hash taken from QtCore's qHash for strings, which in turn has the note: +unsigned int TextElement::hashCode(const char *chars, unsigned int size) { + // Hash taken from QtCore's qHash for strings, which in turn has the note: - /* - These functions are based on Peter J. Weinberger's hash function - (from the Dragon Book). The constant 24 in the original function - was replaced with 23 to produce fewer collisions on input such as - "a", "aa", "aaa", "aaaa", ... - */ + /* + These functions are based on Peter J. Weinberger's hash function + (from the Dragon Book). The constant 24 in the original function + was replaced with 23 to produce fewer collisions on input such as + "a", "aa", "aaa", "aaaa", ... + */ - unsigned int h = 0; - while (size--) { - h = (h << 4) + *chars++; - h ^= (h & 0xf0000000) >> 23; - h &= 0x0fffffff; - } - return h; + unsigned int h = 0; + while (size--) { + h = (h << 4) + *chars++; + h ^= (h & 0xf0000000) >> 23; + h &= 0x0fffffff; + } + return h; } namespace psy { -bool operator==(const TextElement& a, const TextElement& b) -{ - if (&a == &b) - return true; +bool operator==(const TextElement &a, const TextElement &b) { + if (&a == &b) + return true; - if (a.size() != b.size()) - return false; + if (a.size() != b.size()) + return false; - if (a.hashCode() != b.hashCode()) - return false; + if (a.hashCode() != b.hashCode()) + return false; - return !std::strcmp(a.c_str(), b.c_str()); + return !std::strcmp(a.c_str(), b.c_str()); } -} // psy +} // namespace psy diff --git a/common/text/TextElement.h b/common/text/TextElement.h index 69b78e51e..56ad74bbd 100644 --- a/common/text/TextElement.h +++ b/common/text/TextElement.h @@ -34,51 +34,50 @@ namespace psy { * * \see TextElementTable */ -class PSY_API TextElement -{ +class PSY_API TextElement { public: - TextElement(const char* c_str, unsigned int size); - TextElement(const TextElement& other) = delete; - virtual ~TextElement(); - void operator=(const TextElement& other) = delete; + TextElement(const char *c_str, unsigned int size); + TextElement(const TextElement &other) = delete; + virtual ~TextElement(); + void operator=(const TextElement &other) = delete; - typedef const char* iterator; - typedef iterator const_iterator; + typedef const char *iterator; + typedef iterator const_iterator; - iterator begin() const { return chars_; } - iterator end() const { return chars_ + size_; } + iterator begin() const { return chars_; } + iterator end() const { return chars_ + size_; } - //!@{ - /** - * The number of characters in the text. - */ - unsigned int size() const { return size_; } - unsigned int length() const { return size_; } - //!@} + //!@{ + /** + * The number of characters in the text. + */ + unsigned int size() const { return size_; } + unsigned int length() const { return size_; } + //!@} - /** - * The character at the given index \c idx. - */ - char at(unsigned int idx) const { return chars_[idx]; } + /** + * The character at the given index \c idx. + */ + char at(unsigned int idx) const { return chars_[idx]; } - /** - * A null-terminated C-style string of the text. - */ - const char* c_str() const { return chars_; } + /** + * A null-terminated C-style string of the text. + */ + const char *c_str() const { return chars_; } private: - template friend class TextElementTable; - friend bool operator==(const TextElement& a, const TextElement& b); + template friend class TextElementTable; + friend bool operator==(const TextElement &a, const TextElement &b); - unsigned int size_; - char* chars_; - unsigned int hashCode_; - TextElement* next_; + unsigned int size_; + char *chars_; + unsigned int hashCode_; + TextElement *next_; - unsigned int hashCode() const { return hashCode_; } - static unsigned int hashCode(const char* c_str, unsigned int size); + unsigned int hashCode() const { return hashCode_; } + static unsigned int hashCode(const char *c_str, unsigned int size); }; -} // psy +} // namespace psy #endif diff --git a/common/text/TextElementTable.h b/common/text/TextElementTable.h index 2f8d90523..39f7674b3 100644 --- a/common/text/TextElementTable.h +++ b/common/text/TextElementTable.h @@ -27,123 +27,111 @@ namespace psy { -template -class TextElementTable -{ +template class TextElementTable { public: - TextElementTable(const TextElementTable&) = delete; - void operator=(const TextElementTable&) = delete; - - TextElementTable() - : elements_(nullptr) - , count_(-1) - , allocated_(0) - , buckets_(nullptr) - , bucketCount_(0) - {} - - ~TextElementTable() - { - reset(); + TextElementTable(const TextElementTable &) = delete; + void operator=(const TextElementTable &) = delete; + + TextElementTable() + : elements_(nullptr), count_(-1), allocated_(0), buckets_(nullptr), + bucketCount_(0) {} + + ~TextElementTable() { reset(); } + + typedef ElemT *const *iterator; + iterator begin() const { return elements_; } + iterator end() const { return elements_ + count_ + 1; } + + bool empty() const { return count_ == -1; } + unsigned int size() const { return count_ + 1; } + const ElemT *at(unsigned int idx) const { return elements_[idx]; } + + const ElemT *find(const char *chars, unsigned int size) const { + if (buckets_) { + unsigned int h = ElemT::hashCode(chars, size); + ElemT *elem = buckets_[h % bucketCount_]; + for (; elem; elem = static_cast(elem->next_)) { + if (elem->size() == size && !std::strncmp(elem->c_str(), chars, size)) + return elem; + } } - - typedef ElemT* const* iterator; - iterator begin() const { return elements_; } - iterator end() const { return elements_ + count_ + 1; } - - bool empty() const { return count_ == -1; } - unsigned int size() const { return count_ + 1; } - const ElemT* at(unsigned int idx) const { return elements_[idx]; } - - const ElemT* find(const char* chars, unsigned int size) const - { - if (buckets_) { - unsigned int h = ElemT::hashCode(chars, size); - ElemT* elem = buckets_[h % bucketCount_]; - for (; elem; elem = static_cast(elem->next_)) { - if (elem->size() == size && !std::strncmp(elem->c_str(), chars, size)) - return elem; - } - } - return nullptr; + return nullptr; + } + + const ElemT *findOrInsert(const char *chars, unsigned int size) { + ElemT *elem = const_cast(find(chars, size)); + if (elem) + return elem; + + if (++count_ == allocated_) { + if (!allocated_) + allocated_ = 4; + else + allocated_ <<= 1; + elements_ = + (ElemT **)std::realloc(elements_, sizeof(ElemT *) * allocated_); } - const ElemT* findOrInsert(const char *chars, unsigned int size) - { - ElemT* elem = const_cast(find(chars, size)); - if (elem) - return elem; - - if (++count_ == allocated_) { - if (!allocated_) - allocated_ = 4; - else - allocated_ <<= 1; - elements_ = (ElemT**) std::realloc(elements_, sizeof(ElemT*)* allocated_); - } - - elem = new ElemT(chars, size); - elements_[count_] = elem; - - if (!buckets_ || count_ * 5 >= bucketCount_ * 3) - rehash(); - else { - unsigned h = elem->hashCode() % bucketCount_; - elem ->next_ = buckets_[h]; - buckets_[h] = elem; - } - - return elem; + elem = new ElemT(chars, size); + elements_[count_] = elem; + + if (!buckets_ || count_ * 5 >= bucketCount_ * 3) + rehash(); + else { + unsigned h = elem->hashCode() % bucketCount_; + elem->next_ = buckets_[h]; + buckets_[h] = elem; } - void reset() - { - if (elements_) { - ElemT** last = elements_ + count_ + 1; - for (ElemT** it = elements_; it != last; ++it) - delete *it; - std::free(elements_); - } - - if (buckets_) - std::free(buckets_); - - elements_ = 0; - buckets_ = 0; - allocated_ = 0; - count_ = -1; - bucketCount_ = 0; + return elem; + } + + void reset() { + if (elements_) { + ElemT **last = elements_ + count_ + 1; + for (ElemT **it = elements_; it != last; ++it) + delete *it; + std::free(elements_); } + if (buckets_) + std::free(buckets_); + + elements_ = 0; + buckets_ = 0; + allocated_ = 0; + count_ = -1; + bucketCount_ = 0; + } + private: - void rehash() - { - if (buckets_) - std::free(buckets_); - - if (!bucketCount_) - bucketCount_ = 4; - else - bucketCount_ <<= 1; - - buckets_ = (ElemT**)std::calloc(bucketCount_, sizeof(ElemT*)); - - ElemT** last = elements_ + (count_ + 1); - for (ElemT** it = elements_; it != last; ++it) { - ElemT* cur = *it; - unsigned int h = cur->hashCode() % bucketCount_; - cur->next_ = buckets_[h]; - buckets_[h] = cur; - } + void rehash() { + if (buckets_) + std::free(buckets_); + + if (!bucketCount_) + bucketCount_ = 4; + else + bucketCount_ <<= 1; + + buckets_ = (ElemT **)std::calloc(bucketCount_, sizeof(ElemT *)); + + ElemT **last = elements_ + (count_ + 1); + for (ElemT **it = elements_; it != last; ++it) { + ElemT *cur = *it; + unsigned int h = cur->hashCode() % bucketCount_; + cur->next_ = buckets_[h]; + buckets_[h] = cur; } + } - ElemT** elements_; - int count_; - int allocated_; - ElemT** buckets_; - int bucketCount_; + ElemT **elements_; + int count_; + int allocated_; + ElemT **buckets_; + int bucketCount_; }; -} // psy +} // namespace psy #endif diff --git a/common/text/TextSpan.cpp b/common/text/TextSpan.cpp index 3b2dd333e..658dcaa8d 100644 --- a/common/text/TextSpan.cpp +++ b/common/text/TextSpan.cpp @@ -23,15 +23,13 @@ namespace psy { -bool operator==(const TextSpan& a, const TextSpan& b) -{ - return a.start() == b.start() && a.end() == b.end(); +bool operator==(const TextSpan &a, const TextSpan &b) { + return a.start() == b.start() && a.end() == b.end(); } -std::ostream& operator<<(std::ostream& os, const TextSpan& span) -{ - os << span.start() << ".." << span.end(); - return os; +std::ostream &operator<<(std::ostream &os, const TextSpan &span) { + os << span.start() << ".." << span.end(); + return os; } -} // psy +} // namespace psy diff --git a/common/text/TextSpan.h b/common/text/TextSpan.h index 94f394278..03887209a 100644 --- a/common/text/TextSpan.h +++ b/common/text/TextSpan.h @@ -35,39 +35,36 @@ namespace psy { * * \attention * The memory under which a piece of text is stored is unknown to this class; - * it is reponsibility of the user to employ this abstraction in consistent manner. + * it is reponsibility of the user to employ this abstraction in consistent + * manner. * * \note * This API is inspired by that of \c Microsoft.CodeAnalysis.Text.TextSpan * from Roslyn, the .NET Compiler Platform. */ -class PSY_API TextSpan -{ +class PSY_API TextSpan { public: - TextSpan(unsigned int start, unsigned int end) - : start_(start) - , end_(end) - {} + TextSpan(unsigned int start, unsigned int end) : start_(start), end_(end) {} - /** - * The start of \c this span. - */ - unsigned int start() const { return start_; } + /** + * The start of \c this span. + */ + unsigned int start() const { return start_; } - /** - * The end of \c this span. - */ - unsigned int end() const { return end_; } + /** + * The end of \c this span. + */ + unsigned int end() const { return end_; } private: - unsigned int start_; - unsigned int end_; + unsigned int start_; + unsigned int end_; }; -bool operator==(const TextSpan& a, const TextSpan& b); +bool operator==(const TextSpan &a, const TextSpan &b); -std::ostream& operator<<(std::ostream& os, const TextSpan& span); +std::ostream &operator<<(std::ostream &os, const TextSpan &span); -} // psy +} // namespace psy #endif diff --git a/data-types/Substitution.cpp b/data-types/Substitution.cpp index 3dab7cba6..def288e24 100644 --- a/data-types/Substitution.cpp +++ b/data-types/Substitution.cpp @@ -26,39 +26,38 @@ namespace psy { -template -Substitution Substitution::Trivial; +template Substitution Substitution::Trivial; template <> -std::string applyAll(const Substitution& sub, const std::string& input) -{ - if (sub == Substitution::Trivial) - return input; - - std::string substituted = input; - std::string::size_type pos = 0; - while ((pos = substituted.find(sub.from(), pos)) != std::string::npos) { - substituted.replace(pos, sub.from().size(), sub.to()); - pos += sub.to().size(); - } - return substituted; +std::string applyAll(const Substitution &sub, + const std::string &input) { + if (sub == Substitution::Trivial) + return input; + + std::string substituted = input; + std::string::size_type pos = 0; + while ((pos = substituted.find(sub.from(), pos)) != std::string::npos) { + substituted.replace(pos, sub.from().size(), sub.to()); + pos += sub.to().size(); + } + return substituted; } template <> -std::string applyOnce(const std::vector>& seq, const std::string& input) -{ - std::string substituted = input; - std::string::size_type pos = 0; - for (const auto& sub : seq) { - if (sub == Substitution::Trivial) - continue; +std::string applyOnce(const std::vector> &seq, + const std::string &input) { + std::string substituted = input; + std::string::size_type pos = 0; + for (const auto &sub : seq) { + if (sub == Substitution::Trivial) + continue; - if ((pos = substituted.find(sub.from(), pos)) != std::string::npos) { - substituted.replace(pos, sub.from().size(), sub.to()); - pos += sub.to().size(); - } + if ((pos = substituted.find(sub.from(), pos)) != std::string::npos) { + substituted.replace(pos, sub.from().size(), sub.to()); + pos += sub.to().size(); } - return substituted; + } + return substituted; } -} // psy +} // namespace psy diff --git a/data-types/Substitution.h b/data-types/Substitution.h index 19b0e407a..d92462daa 100644 --- a/data-types/Substitution.h +++ b/data-types/Substitution.h @@ -25,54 +25,44 @@ namespace psy { -template -class Substitution -{ +template class Substitution { public: - Substitution() - : from_() - , to_() - {} + Substitution() : from_(), to_() {} - Substitution(const T& from, const T& to) - : from_(from) - , to_(to) - {} + Substitution(const T &from, const T &to) : from_(from), to_(to) {} - const T& from() const { return from_; } - const T& to() const { return to_; } + const T &from() const { return from_; } + const T &to() const { return to_; } - static Substitution Trivial; + static Substitution Trivial; private: - T from_; - T to_; + T from_; + T to_; }; template -ContentT applyAll(const Substitution& sub, const ContentT& input); +ContentT applyAll(const Substitution &sub, const ContentT &input); template -ContentT applyAll(const SeqT& seq, const ContentT& input); +ContentT applyAll(const SeqT &seq, const ContentT &input); template -ContentT applyOnce(const Substitution& sub, const ContentT& input); +ContentT applyOnce(const Substitution &sub, const ContentT &input); template -ContentT applyOnce(const SeqT& seq, const ContentT& input); +ContentT applyOnce(const SeqT &seq, const ContentT &input); template -bool operator==(const Substitution& s1, const Substitution& s2) -{ - return s1.from() == s2.from() && s1.to() == s2.to(); +bool operator==(const Substitution &s1, const Substitution &s2) { + return s1.from() == s2.from() && s1.to() == s2.to(); } template -bool operator!=(const Substitution& s1, const Substitution& s2) -{ - return !(s1 == s2); +bool operator!=(const Substitution &s1, const Substitution &s2) { + return !(s1 == s2); } -} // psy +} // namespace psy #endif diff --git a/data-types/VersionedMap.h b/data-types/VersionedMap.h index 521db713b..595ef2cbc 100644 --- a/data-types/VersionedMap.h +++ b/data-types/VersionedMap.h @@ -23,147 +23,133 @@ #include #include -#include #include +#include namespace psy { /*! * A versioned map. */ -template -class VersionedMap -{ +template class VersionedMap { private: - using BaseMap = std::unordered_map; + using BaseMap = std::unordered_map; public: - using iterator = typename BaseMap::iterator; - using const_iterator = typename BaseMap::const_iterator; + using iterator = typename BaseMap::iterator; + using const_iterator = typename BaseMap::const_iterator; - VersionedMap() = default; + VersionedMap() = default; - void insertOrAssign(const KeyT& key, const ValueT& value); - void insertOrAssign(const KeyT& key, ValueT&& value); + void insertOrAssign(const KeyT &key, const ValueT &value); + void insertOrAssign(const KeyT &key, ValueT &&value); - void applyRevision(uint32_t revision); - uint32_t revision() const { return curRevision_; } + void applyRevision(uint32_t revision); + uint32_t revision() const { return curRevision_; } - // Basic traversal. - const_iterator begin() const { return map_.begin(); } - const_iterator end() const { return map_.end(); } - const_iterator cbegin() const { return map_.begin(); } - const_iterator cend() const { return map_.end(); } - const_iterator find(const KeyT& key) const { return map_.find(key); } + // Basic traversal. + const_iterator begin() const { return map_.begin(); } + const_iterator end() const { return map_.end(); } + const_iterator cbegin() const { return map_.begin(); } + const_iterator cend() const { return map_.end(); } + const_iterator find(const KeyT &key) const { return map_.find(key); } private: - void insertOrAssignCore(const KeyT& key, const ValueT& value); - void insertOrAssignCore(const KeyT& key, ValueT&& value); - - // Encapsulates the action, as GoF's command other. - struct Command - { - enum OpCode - { - Insert, - Remove - }; - - Command(const KeyT& key, const ValueT& value, OpCode code) - : key_(key), value_(value), opCode_(code) - {} - const KeyT key_; - const ValueT value_; - OpCode opCode_; - }; - - void storeCommand(const Command& command); - - //! Commands for each given revision. - std::vector commands_; - - //!@{ - /*! - * Revisioning mechanism. - */ - uint32_t curRevision_ { 0 }; - uint32_t revisionCnt_ { 0 }; - std::unordered_map reverts_; - //!@} - - //! The actual underlying map. - BaseMap map_; + void insertOrAssignCore(const KeyT &key, const ValueT &value); + void insertOrAssignCore(const KeyT &key, ValueT &&value); + + // Encapsulates the action, as GoF's command other. + struct Command { + enum OpCode { Insert, Remove }; + + Command(const KeyT &key, const ValueT &value, OpCode code) + : key_(key), value_(value), opCode_(code) {} + const KeyT key_; + const ValueT value_; + OpCode opCode_; + }; + + void storeCommand(const Command &command); + + //! Commands for each given revision. + std::vector commands_; + + //!@{ + /*! + * Revisioning mechanism. + */ + uint32_t curRevision_{0}; + uint32_t revisionCnt_{0}; + std::unordered_map reverts_; + //!@} + + //! The actual underlying map. + BaseMap map_; }; template -void VersionedMap::insertOrAssign(const KeyT& key, - const ValueT& value) -{ - storeCommand(Command(key, value, Command::Insert)); - insertOrAssignCore(key, value); +void VersionedMap::insertOrAssign(const KeyT &key, + const ValueT &value) { + storeCommand(Command(key, value, Command::Insert)); + insertOrAssignCore(key, value); } template -void VersionedMap::insertOrAssignCore(const KeyT& key, - const ValueT& value) -{ - map_[key] = value; +void VersionedMap::insertOrAssignCore(const KeyT &key, + const ValueT &value) { + map_[key] = value; } template -void VersionedMap::insertOrAssign(const KeyT& key, - ValueT&& value) -{ - storeCommand(Command(key, value, Command::Insert)); - insertOrAssignCore(key, std::move(value)); +void VersionedMap::insertOrAssign(const KeyT &key, + ValueT &&value) { + storeCommand(Command(key, value, Command::Insert)); + insertOrAssignCore(key, std::move(value)); } template -void VersionedMap::insertOrAssignCore(const KeyT& key, - ValueT&& value) -{ - // We don't want to use operator[] because this would require ValueT to - // have a default constructor (Range, for instance, doesn't have one, and - // this is by design). C++17 has already insert_or_assign. - auto it = map_.find(key); - if (it != map_.end()) - it->second = std::move(value); - else - map_.insert(std::make_pair(key, std::move(value))); +void VersionedMap::insertOrAssignCore(const KeyT &key, + ValueT &&value) { + // We don't want to use operator[] because this would require ValueT to + // have a default constructor (Range, for instance, doesn't have one, and + // this is by design). C++17 has already insert_or_assign. + auto it = map_.find(key); + if (it != map_.end()) + it->second = std::move(value); + else + map_.insert(std::make_pair(key, std::move(value))); } template -void VersionedMap::storeCommand(const Command& command) -{ - commands_.push_back(command); - reverts_.insert(std::make_pair(++revisionCnt_, curRevision_)); - curRevision_ = revisionCnt_; +void VersionedMap::storeCommand(const Command &command) { + commands_.push_back(command); + reverts_.insert(std::make_pair(++revisionCnt_, curRevision_)); + curRevision_ = revisionCnt_; } template -void VersionedMap::applyRevision(uint32_t revision) -{ - std::vector ordered; - auto it = reverts_.find(revision); - while (it != reverts_.end()) { - ordered.push_back(it->second); - it = reverts_.find(it->second); - } - - curRevision_ = revision; - if (ordered.empty()) - return; // Nothing to do. - - std::reverse(ordered.begin(), ordered.end()); - map_.clear(); - for (auto current : ordered) { - const auto& command = commands_[current]; - ValueT value = command.value_; - if (command.opCode_ == Command::Insert) - insertOrAssignCore(command.key_, std::move(value)); - } +void VersionedMap::applyRevision(uint32_t revision) { + std::vector ordered; + auto it = reverts_.find(revision); + while (it != reverts_.end()) { + ordered.push_back(it->second); + it = reverts_.find(it->second); + } + + curRevision_ = revision; + if (ordered.empty()) + return; // Nothing to do. + + std::reverse(ordered.begin(), ordered.end()); + map_.clear(); + for (auto current : ordered) { + const auto &command = commands_[current]; + ValueT value = command.value_; + if (command.opCode_ == Command::Insert) + insertOrAssignCore(command.key_, std::move(value)); + } } -} // psy +} // namespace psy #endif diff --git a/formalism/test002.c b/formalism/test002.c index 3fec93bcf..472e4832a 100644 --- a/formalism/test002.c +++ b/formalism/test002.c @@ -1,6 +1,5 @@ -T f() -{ - T abc; - abc = 2; - return abc; +T f() { + T abc; + abc = 2; + return abc; } diff --git a/formalism/test003.c b/formalism/test003.c index edb8596fd..709747870 100644 --- a/formalism/test003.c +++ b/formalism/test003.c @@ -1,7 +1,5 @@ -T1 f() -{ - T2 a; - a = 10; - return a; +T1 f() { + T2 a; + a = 10; + return a; } - diff --git a/formalism/test004.c b/formalism/test004.c index 88ba72b15..7f2123d6a 100644 --- a/formalism/test004.c +++ b/formalism/test004.c @@ -1,6 +1,5 @@ -T1 f() -{ - T2 x; - *x = 99; - return *x; +T1 f() { + T2 x; + *x = 99; + return *x; } diff --git a/formalism/test005.c b/formalism/test005.c index a6c8e5ae7..d03921280 100644 --- a/formalism/test005.c +++ b/formalism/test005.c @@ -1,8 +1,7 @@ -T1 f() -{ - T2 a; - a = 99; - T3 b; - b = &a; - return a; +T1 f() { + T2 a; + a = 99; + T3 b; + b = &a; + return a; } diff --git a/formalism/test006.c b/formalism/test006.c index e7d27c95e..e320be4c3 100644 --- a/formalism/test006.c +++ b/formalism/test006.c @@ -1,10 +1,9 @@ -T1 f() -{ - T2 a; - T3 b; - T4 c; - a = b; - c = a; - b = 10; - return c; +T1 f() { + T2 a; + T3 b; + T4 c; + a = b; + c = a; + b = 10; + return c; } diff --git a/formalism/test007.c b/formalism/test007.c index f4e2e369b..ebf819f19 100644 --- a/formalism/test007.c +++ b/formalism/test007.c @@ -1,5 +1,4 @@ -RT f(PT1 param) -{ - param = 42; - return param; +RT f(PT1 param) { + param = 42; + return param; } diff --git a/formalism/test008.c b/formalism/test008.c index 38b12cd37..45623e441 100644 --- a/formalism/test008.c +++ b/formalism/test008.c @@ -1,6 +1,5 @@ -T1 f() -{ - T2* r; - r->x = 42; - return r->x; +T1 f() { + T2 *r; + r->x = 42; + return r->x; } diff --git a/formalism/test009.c b/formalism/test009.c index 749878d96..c41938b68 100644 --- a/formalism/test009.c +++ b/formalism/test009.c @@ -1,9 +1,8 @@ -T1 f() -{ - T2 x; - x = 42; - T3 y; - y = 3.14; - x = y; - return x; +T1 f() { + T2 x; + x = 42; + T3 y; + y = 3.14; + x = y; + return x; } diff --git a/formalism/test010.c b/formalism/test010.c index fcce172ce..0a6749556 100644 --- a/formalism/test010.c +++ b/formalism/test010.c @@ -1,6 +1,5 @@ -T1 f() -{ - T2 r; - r->x = 42; - return r->x; +T1 f() { + T2 r; + r->x = 42; + return r->x; } diff --git a/formalism/test011.c b/formalism/test011.c index a46e7fbf2..6e340fda0 100644 --- a/formalism/test011.c +++ b/formalism/test011.c @@ -1,5 +1,4 @@ -T1 f() -{ - int x; - return x; +T1 f() { + int x; + return x; } diff --git a/formalism/test012.c b/formalism/test012.c index cf2e8a6d9..4dce4a76e 100644 --- a/formalism/test012.c +++ b/formalism/test012.c @@ -1,5 +1,4 @@ -T1 f() -{ - int* x; - return x; +T1 f() { + int *x; + return x; } diff --git a/formalism/test013.c b/formalism/test013.c index ce3c48ae3..8296034d0 100644 --- a/formalism/test013.c +++ b/formalism/test013.c @@ -1,5 +1,4 @@ -T1 f() -{ - const int x; - return x; +T1 f() { + const int x; + return x; } diff --git a/formalism/test014.c b/formalism/test014.c index 47b7be6cd..1532bcae5 100644 --- a/formalism/test014.c +++ b/formalism/test014.c @@ -1,7 +1,6 @@ -T1 f() -{ - const int x; - T1 y; - y = x; - return y; +T1 f() { + const int x; + T1 y; + y = x; + return y; } diff --git a/formalism/test015.c b/formalism/test015.c index c5af6524b..dc346b8de 100644 --- a/formalism/test015.c +++ b/formalism/test015.c @@ -1,7 +1,6 @@ -T1 f() -{ - const int* x; - T1 y; - y = x; - return y; +T1 f() { + const int *x; + T1 y; + y = x; + return y; } diff --git a/formalism/test016.c b/formalism/test016.c index 836bede0a..31de87f45 100644 --- a/formalism/test016.c +++ b/formalism/test016.c @@ -1,7 +1,6 @@ -T1 f() -{ - const int* x; - T1 y; - x = y; - return y; +T1 f() { + const int *x; + T1 y; + x = y; + return y; } diff --git a/formalism/test017.c b/formalism/test017.c index 69dad7d09..4031c2e43 100644 --- a/formalism/test017.c +++ b/formalism/test017.c @@ -1,9 +1,8 @@ -T1 f() -{ - T1 x; - int* y; - const int* z; - x = y; - x = z; - return x; +T1 f() { + T1 x; + int *y; + const int *z; + x = y; + x = z; + return x; } diff --git a/formalism/test018.c b/formalism/test018.c index a709cae79..77a2b6ece 100644 --- a/formalism/test018.c +++ b/formalism/test018.c @@ -1,9 +1,8 @@ -T1 f() -{ - T1 x; - int* y; - const int* z; - x = z; - x = y; - return x; +T1 f() { + T1 x; + int *y; + const int *z; + x = z; + x = y; + return x; } diff --git a/formalism/test019.c b/formalism/test019.c index bbafe2789..f9fa8a03d 100644 --- a/formalism/test019.c +++ b/formalism/test019.c @@ -1,5 +1,4 @@ -int f() -{ - T x; - return x; +int f() { + T x; + return x; } diff --git a/formalism/test020.c b/formalism/test020.c index bdec62f6a..ea6532e7e 100644 --- a/formalism/test020.c +++ b/formalism/test020.c @@ -1,8 +1,7 @@ -T f() -{ - T1 r; - r->x = 42; - T2 q; - q = r; - return r->x; +T f() { + T1 r; + r->x = 42; + T2 q; + q = r; + return r->x; } diff --git a/formalism/test021.c b/formalism/test021.c index 0e18291cb..b5892e5a4 100644 --- a/formalism/test021.c +++ b/formalism/test021.c @@ -1,9 +1,8 @@ -T f() -{ - T1 r; - r->x = 42; - T2 q; - q = r; - q->x = r->x; - return r->x; +T f() { + T1 r; + r->x = 42; + T2 q; + q = r; + q->x = r->x; + return r->x; } diff --git a/formalism/test022.c b/formalism/test022.c index 53a869ba1..39128b77b 100644 --- a/formalism/test022.c +++ b/formalism/test022.c @@ -1,8 +1,7 @@ -T f() -{ - T1 r; - r->x = 42; - T2 q; - q->x = r->x; - return r->x; +T f() { + T1 r; + r->x = 42; + T2 q; + q->x = r->x; + return r->x; } diff --git a/formalism/test023.c b/formalism/test023.c index bd37b74c6..c52af72f7 100644 --- a/formalism/test023.c +++ b/formalism/test023.c @@ -1,9 +1,8 @@ -T1 f() -{ - T2 x; - x = 42; - T3 y; - y = 3.14; - y = x; - return x; +T1 f() { + T2 x; + x = 42; + T3 y; + y = 3.14; + y = x; + return x; } diff --git a/formalism/test024.c b/formalism/test024.c index 67ae5ca3f..3cc6ed0cb 100644 --- a/formalism/test024.c +++ b/formalism/test024.c @@ -1,14 +1,13 @@ -T f() -{ - const int* cip; - T1 x; - x = cip; - - const double* cdp; - T2 y; - y = cdp; +T f() { + const int *cip; + T1 x; + x = cip; - y = x; + const double *cdp; + T2 y; + y = cdp; - return 42; + y = x; + + return 42; } diff --git a/formalism/test025.c b/formalism/test025.c index ef51010af..1433eae0d 100644 --- a/formalism/test025.c +++ b/formalism/test025.c @@ -1,14 +1,13 @@ -T f() -{ - const int* cip; - T1 x; - x = cip; - - const double* cdp; - T2 y; - y = cdp; +T f() { + const int *cip; + T1 x; + x = cip; - x = y; + const double *cdp; + T2 y; + y = cdp; - return 42; + x = y; + + return 42; } diff --git a/formalism/test026.c b/formalism/test026.c index 5efce1658..b133657d6 100644 --- a/formalism/test026.c +++ b/formalism/test026.c @@ -1,13 +1,12 @@ -T f() -{ - const int* cip; - T1 x; - x = cip; - - int* ip; - T2 y; - y = ip; +T f() { + const int *cip; + T1 x; + x = cip; - x = y; - return 42; + int *ip; + T2 y; + y = ip; + + x = y; + return 42; } diff --git a/formalism/test027.c b/formalism/test027.c index cfa44582c..10656a9e3 100644 --- a/formalism/test027.c +++ b/formalism/test027.c @@ -1,12 +1,11 @@ -T f() -{ - int* ip; - T1 y; - y = ip; - const int* cip; - T2 x; - x = cip; +T f() { + int *ip; + T1 y; + y = ip; + const int *cip; + T2 x; + x = cip; - x = y; - return 42; + x = y; + return 42; } diff --git a/formalism/test029.c b/formalism/test029.c index 337a2d9d3..19af574dd 100644 --- a/formalism/test029.c +++ b/formalism/test029.c @@ -1,7 +1,6 @@ -T f() -{ - const int* x; - int* y; - x = y; - return 0; +T f() { + const int *x; + int *y; + x = y; + return 0; } diff --git a/formalism/test030.c b/formalism/test030.c index d936ef1d0..0309add8f 100644 --- a/formalism/test030.c +++ b/formalism/test030.c @@ -1,17 +1,16 @@ -T f() -{ - const int* cip; - T1 x; - x = cip; - T11 xx; - xx = x; - - int* ip; - T2 y; - y = ip; - T22 yy; - yy = y; +T f() { + const int *cip; + T1 x; + x = cip; + T11 xx; + xx = x; - xx = yy; - return 42; + int *ip; + T2 y; + y = ip; + T22 yy; + yy = y; + + xx = yy; + return 42; } diff --git a/formalism/test031.c b/formalism/test031.c index edb24e4d5..5695b209b 100644 --- a/formalism/test031.c +++ b/formalism/test031.c @@ -1,14 +1,13 @@ -T f() -{ - const int* x; - T1* xx; - xx = x; +T f() { + const int *x; + T1 *xx; + xx = x; - int* y; - T2* yy; - yy = y; + int *y; + T2 *yy; + yy = y; - xx = yy; - - return 1; + xx = yy; + + return 1; } diff --git a/formalism/test032.c b/formalism/test032.c index dc6b7b6ec..d28e50e8c 100644 --- a/formalism/test032.c +++ b/formalism/test032.c @@ -1,14 +1,13 @@ -T f() -{ - const int* x; - T1* xx; - xx = x; +T f() { + const int *x; + T1 *xx; + xx = x; - int* y; - T2* yy; - yy = y; + int *y; + T2 *yy; + yy = y; - yy = xx; - - return 1; + yy = xx; + + return 1; } diff --git a/formalism/test033.c b/formalism/test033.c index fca7aa047..ded0267b3 100644 --- a/formalism/test033.c +++ b/formalism/test033.c @@ -1,16 +1,15 @@ -T f() -{ - const int* x; - T1* xx; - xx = x; - T11 xxx; - xxx = xx; +T f() { + const int *x; + T1 *xx; + xx = x; + T11 xxx; + xxx = xx; - int* y; - T2* yy; - yy = y; + int *y; + T2 *yy; + yy = y; - xxx = yy; - - return 1; + xxx = yy; + + return 1; } diff --git a/formalism/test034.c b/formalism/test034.c index fd3558bb1..0a763991a 100644 --- a/formalism/test034.c +++ b/formalism/test034.c @@ -1,6 +1,5 @@ -T1 f() -{ - const int x; - x = 10; - return x; +T1 f() { + const int x; + x = 10; + return x; } diff --git a/formalism/test035.c b/formalism/test035.c index d8563cb93..f659a6d66 100644 --- a/formalism/test035.c +++ b/formalism/test035.c @@ -1,7 +1,6 @@ -T f() -{ - const int* cip; - int* ip; - cip = ip; - return 42; +T f() { + const int *cip; + int *ip; + cip = ip; + return 42; } diff --git a/formalism/test036.c b/formalism/test036.c index 5854603dc..ba21d0895 100644 --- a/formalism/test036.c +++ b/formalism/test036.c @@ -1,7 +1,6 @@ -T f() -{ - const int* cip; - int* ip; - ip = cip; - return 42; +T f() { + const int *cip; + int *ip; + ip = cip; + return 42; } diff --git a/formalism/test037.c b/formalism/test037.c index d5d534715..0dc23939f 100644 --- a/formalism/test037.c +++ b/formalism/test037.c @@ -1,11 +1,9 @@ -int f() -{ - int a; - a = 10; - int b; - a = 88; - T c; - c = a || b; - return 42; +int f() { + int a; + a = 10; + int b; + a = 88; + T c; + c = a || b; + return 42; } - diff --git a/formalism/test038.c b/formalism/test038.c index 61d8b1c23..843ab1ba2 100644 --- a/formalism/test038.c +++ b/formalism/test038.c @@ -1,10 +1,9 @@ -int f() -{ - int a; - a = 33; - double b; - b = 3.14; - T c; - c = a || b; - return 42; +int f() { + int a; + a = 33; + double b; + b = 3.14; + T c; + c = a || b; + return 42; } diff --git a/formalism/test039.c b/formalism/test039.c index 7b50d7d4c..d810065ea 100644 --- a/formalism/test039.c +++ b/formalism/test039.c @@ -1,10 +1,9 @@ -int f() -{ - double a; - a = 3.14; - int b; - b = 44; - T c; - c = a || b; - return 42; +int f() { + double a; + a = 3.14; + int b; + b = 44; + T c; + c = a || b; + return 42; } diff --git a/formalism/test040.c b/formalism/test040.c index da0b7a530..3636da9a0 100644 --- a/formalism/test040.c +++ b/formalism/test040.c @@ -1,12 +1,11 @@ -int f() -{ - double a; - a = 3.14; - T1 aa; - aa = a; - int b; - b = 9; - T c; - c = aa || b; - return 42; +int f() { + double a; + a = 3.14; + T1 aa; + aa = a; + int b; + b = 9; + T c; + c = aa || b; + return 42; } diff --git a/formalism/test041.c b/formalism/test041.c index da8dd0ed6..8e60fd5c9 100644 --- a/formalism/test041.c +++ b/formalism/test041.c @@ -1,12 +1,11 @@ -int f() -{ - double a; - a = 3.14; - T1 aa; - aa = a; - int b; - b = 48; - T c; - c = b || aa; - return 42; +int f() { + double a; + a = 3.14; + T1 aa; + aa = a; + int b; + b = 48; + T c; + c = b || aa; + return 42; } diff --git a/formalism/test042.c b/formalism/test042.c index ceb906771..2c45b83a2 100644 --- a/formalism/test042.c +++ b/formalism/test042.c @@ -1,14 +1,13 @@ -int f() -{ - double a; - a = 3.14; - T1 aa; - aa = a; - int b; - b = 8; - T2 bb; - bb = b; - T c; - c = bb || aa; - return 42; +int f() { + double a; + a = 3.14; + T1 aa; + aa = a; + int b; + b = 8; + T2 bb; + bb = b; + T c; + c = bb || aa; + return 42; } diff --git a/formalism/test043.c b/formalism/test043.c index 6bfed4972..f41a4f78c 100644 --- a/formalism/test043.c +++ b/formalism/test043.c @@ -1,14 +1,13 @@ -int f() -{ - double a; - a = 3.14; - T1 aa; - aa = a; - int b; - b = 77; - T2 bb; - bb = b; - T c; - c = aa || bb; - return 42; +int f() { + double a; + a = 3.14; + T1 aa; + aa = a; + int b; + b = 77; + T2 bb; + bb = b; + T c; + c = aa || bb; + return 42; } diff --git a/formalism/test044.c b/formalism/test044.c index ef3feb2e4..49929c826 100644 --- a/formalism/test044.c +++ b/formalism/test044.c @@ -1,14 +1,13 @@ -int f() -{ - double a; - a = 3.14; - T1 aa; - aa = a; - double b; - b = 1.61; - T2 bb; - bb = b; - T c; - c = aa || bb; - return 42; +int f() { + double a; + a = 3.14; + T1 aa; + aa = a; + double b; + b = 1.61; + T2 bb; + bb = b; + T c; + c = aa || bb; + return 42; } diff --git a/formalism/test045.c b/formalism/test045.c index 190478ad8..b291f3c50 100644 --- a/formalism/test045.c +++ b/formalism/test045.c @@ -1,10 +1,9 @@ -T f() -{ - double a; - a = 3.14; - double b; - b = 3.14; - T1 c; - c = a || b; - return 42; +T f() { + double a; + a = 3.14; + double b; + b = 3.14; + T1 c; + c = a || b; + return 42; } diff --git a/formalism/test046.c b/formalism/test046.c index 518d5e776..1d4a3d517 100644 --- a/formalism/test046.c +++ b/formalism/test046.c @@ -1,10 +1,9 @@ -T f() -{ - T1 a; - a = 3.14; - T2 b; - b = 88; - T3 c; - c = a / b; - return 42; +T f() { + T1 a; + a = 3.14; + T2 b; + b = 88; + T3 c; + c = a / b; + return 42; } diff --git a/formalism/test047.c b/formalism/test047.c index 434351c57..a318adfd5 100644 --- a/formalism/test047.c +++ b/formalism/test047.c @@ -1,10 +1,9 @@ -T f() -{ - T1 a; - a = 3.14; - T2 b; - b = 88; - T3 c; - c = b / a; - return 42; +T f() { + T1 a; + a = 3.14; + T2 b; + b = 88; + T3 c; + c = b / a; + return 42; } diff --git a/formalism/test048.c b/formalism/test048.c index 27426c3b2..1503534d7 100644 --- a/formalism/test048.c +++ b/formalism/test048.c @@ -1,10 +1,9 @@ -T f() -{ - T1 a; - a = 3.14; - int b; - b = 88; - T3 c; - c = b / a; - return 42; +T f() { + T1 a; + a = 3.14; + int b; + b = 88; + T3 c; + c = b / a; + return 42; } diff --git a/formalism/test049.c b/formalism/test049.c index ec5d4541f..4176b8c5d 100644 --- a/formalism/test049.c +++ b/formalism/test049.c @@ -1,10 +1,9 @@ -T f() -{ - T1 a; - a = 3.14; - int b; - b = 88; - T3 c; - c = a / b; - return 42; +T f() { + T1 a; + a = 3.14; + int b; + b = 88; + T3 c; + c = a / b; + return 42; } diff --git a/formalism/test050.c b/formalism/test050.c index eae3a79fa..014a33058 100644 --- a/formalism/test050.c +++ b/formalism/test050.c @@ -1,11 +1,10 @@ -T f() -{ - const int* x; - T1 y; - y = x; - T2 z; - z = y; - T3 w; - w = z; - return 0; +T f() { + const int *x; + T1 y; + y = x; + T2 z; + z = y; + T3 w; + w = z; + return 0; } diff --git a/formalism/test051.c b/formalism/test051.c index 8b1dcfaaa..096be8c93 100644 --- a/formalism/test051.c +++ b/formalism/test051.c @@ -1,11 +1,10 @@ -T f() -{ - const int* x; - T1 y; - y = x; - T2 z; - z = x; - T3 w; - w = x; - return 0; +T f() { + const int *x; + T1 y; + y = x; + T2 z; + z = x; + T3 w; + w = x; + return 0; } diff --git a/formalism/test052.c b/formalism/test052.c index 6441eacc3..a7de74d1d 100644 --- a/formalism/test052.c +++ b/formalism/test052.c @@ -1,13 +1,12 @@ -T f() -{ - int* x; - T1 y; - y = x; - T2 z; - z = x; - const int* w; - w = z; - T3 k; - k = w; - return 0; +T f() { + int *x; + T1 y; + y = x; + T2 z; + z = x; + const int *w; + w = z; + T3 k; + k = w; + return 0; } diff --git a/formalism/test053.c b/formalism/test053.c index 3281a8562..57936d07f 100644 --- a/formalism/test053.c +++ b/formalism/test053.c @@ -1,12 +1,11 @@ -T f() -{ - int* x; - T1 y; - y = x; - T2 z; - z = x; - const int* w; - y = w; +T f() { + int *x; + T1 y; + y = x; + T2 z; + z = x; + const int *w; + y = w; - return 0; + return 0; } diff --git a/formalism/test054.c b/formalism/test054.c index ad4d02d01..d85b1af84 100644 --- a/formalism/test054.c +++ b/formalism/test054.c @@ -1,12 +1,11 @@ -T f() -{ - const int* w; - T1 y; - y = w; - int* x; - y = x; - T2 z; - z = x; +T f() { + const int *w; + T1 y; + y = w; + int *x; + y = x; + T2 z; + z = x; - return 0; + return 0; } diff --git a/formalism/test055.c b/formalism/test055.c index b585e0979..fc5d178d3 100644 --- a/formalism/test055.c +++ b/formalism/test055.c @@ -1,30 +1,28 @@ -T fun() -{ - int* ip; - const int* cip; - T1 a; - T2 b; - T3 c; - T4 d; - T5 e; - T6 f; - T7 g; - T8 h; - T9 i; +T fun() { + int *ip; + const int *cip; + T1 a; + T2 b; + T3 c; + T4 d; + T5 e; + T6 f; + T7 g; + T8 h; + T9 i; - a = cip; - b = ip; - - c = b; - d = c; - e = d; - f = e; - - g = a; - h = g; - i = h; - i = e; + a = cip; + b = ip; + c = b; + d = c; + e = d; + f = e; - return 0; + g = a; + h = g; + i = h; + i = e; + + return 0; } diff --git a/formalism/test056.c b/formalism/test056.c index 42f9236c9..e2a371e7f 100644 --- a/formalism/test056.c +++ b/formalism/test056.c @@ -1,7 +1,6 @@ -T f() -{ - T1 rec; - rec->x = 42; - rec->next = rec; - return rec->x; +T f() { + T1 rec; + rec->x = 42; + rec->next = rec; + return rec->x; } diff --git a/formalism/test057.c b/formalism/test057.c index e9be29a2c..6163b98d1 100644 --- a/formalism/test057.c +++ b/formalism/test057.c @@ -1,10 +1,9 @@ -T f() -{ - T1 x; - x->i = 42; - T2 y; - y->f = 3.14; - x->other = y; +T f() { + T1 x; + x->i = 42; + T2 y; + y->f = 3.14; + x->other = y; - return 0; + return 0; } diff --git a/formalism/test058.c b/formalism/test058.c index a8bf01cd4..6531c0505 100644 --- a/formalism/test058.c +++ b/formalism/test058.c @@ -1,5 +1,4 @@ -int f() -{ - T a; - return 1; +int f() { + T a; + return 1; } diff --git a/formalism/test059.c b/formalism/test059.c index a06723712..8b71483e2 100644 --- a/formalism/test059.c +++ b/formalism/test059.c @@ -1,5 +1,4 @@ -int f() -{ - struct T a; - return 1; +int f() { + struct T a; + return 1; } diff --git a/formalism/test060.c b/formalism/test060.c index 237933062..ebfb40463 100644 --- a/formalism/test060.c +++ b/formalism/test060.c @@ -1,5 +1,4 @@ -int f() -{ +int f() { T c; c = 0; *c = 10; diff --git a/formalism/test061.c b/formalism/test061.c index 047d99b91..9ed5526dc 100644 --- a/formalism/test061.c +++ b/formalism/test061.c @@ -1,8 +1,7 @@ -T f() -{ - T1 x; - *x = 100; - T2 y; - y = x + 30; - return y; +T f() { + T1 x; + *x = 100; + T2 y; + y = x + 30; + return y; } diff --git a/formalism/test062.c b/formalism/test062.c index 8f1a4f739..4e13a2467 100644 --- a/formalism/test062.c +++ b/formalism/test062.c @@ -1,9 +1,8 @@ -T f() -{ - T1 x; - *x = 100; - T2 y; - T3 z; - z = x + y; - return y; +T f() { + T1 x; + *x = 100; + T2 y; + T3 z; + z = x + y; + return y; } diff --git a/formalism/test063.c b/formalism/test063.c index f6f9bc6eb..ed7462355 100644 --- a/formalism/test063.c +++ b/formalism/test063.c @@ -1,9 +1,8 @@ -T f() -{ - T1 x; - x = 100; - T2 y; - T3 z; - z = x + y; - return y; +T f() { + T1 x; + x = 100; + T2 y; + T3 z; + z = x + y; + return y; } diff --git a/formalism/test064.c b/formalism/test064.c index 063ebe41e..b31d6d856 100644 --- a/formalism/test064.c +++ b/formalism/test064.c @@ -1,9 +1,8 @@ -T f() -{ - T1 x; - *x = 100; - T2 y; - T3 z; - z = y + x; - return y; +T f() { + T1 x; + *x = 100; + T2 y; + T3 z; + z = y + x; + return y; } diff --git a/formalism/test065.c b/formalism/test065.c index 6cee61bd9..91f61deb5 100644 --- a/formalism/test065.c +++ b/formalism/test065.c @@ -1,9 +1,8 @@ -double f() -{ - T1* p; - *p; - T2 d; - T3* q; - q = p + d; - return *p; +double f() { + T1 *p; + *p; + T2 d; + T3 *q; + q = p + d; + return *p; } diff --git a/formalism/test066.c b/formalism/test066.c index e68704363..4c3a1ef80 100644 --- a/formalism/test066.c +++ b/formalism/test066.c @@ -1,9 +1,8 @@ -double f() -{ - T1* p; - *p; - T2 d; - T3* q; - q = p + d; - return *q; +double f() { + T1 *p; + *p; + T2 d; + T3 *q; + q = p + d; + return *q; } diff --git a/formalism/test067.c b/formalism/test067.c index 7d592cab8..13531d20b 100644 --- a/formalism/test067.c +++ b/formalism/test067.c @@ -1,8 +1,7 @@ -typedef double* T; -int f() -{ - T x; - T2 y; - y = x; - return 0; +typedef double *T; +int f() { + T x; + T2 y; + y = x; + return 0; } diff --git a/formalism/test068.c b/formalism/test068.c index b81823ecb..3c2ff3867 100644 --- a/formalism/test068.c +++ b/formalism/test068.c @@ -1,10 +1,9 @@ -int f() -{ - int a; - a = 33; - double b; - b = 3.14; - T c; - c = a + b; - return 42; +int f() { + int a; + a = 33; + double b; + b = 3.14; + T c; + c = a + b; + return 42; } diff --git a/formalism/test069.c b/formalism/test069.c index 9dd54c217..d2631f87d 100644 --- a/formalism/test069.c +++ b/formalism/test069.c @@ -1,10 +1,9 @@ -int f() -{ - int a; - a = 33; - double b; - b = 3.14; - T c; - c = a / b; - return 42; +int f() { + int a; + a = 33; + double b; + b = 3.14; + T c; + c = a / b; + return 42; } diff --git a/formalism/test070.c b/formalism/test070.c index 2ba880a65..be007ba4f 100644 --- a/formalism/test070.c +++ b/formalism/test070.c @@ -1,10 +1,9 @@ -int f() -{ - int a; - a = 33; - double b; - b = 3.14; - T c; - c = b + a; - return 42; +int f() { + int a; + a = 33; + double b; + b = 3.14; + T c; + c = b + a; + return 42; } diff --git a/formalism/test071.c b/formalism/test071.c index 2f6ea7e32..538308680 100644 --- a/formalism/test071.c +++ b/formalism/test071.c @@ -1,10 +1,9 @@ -int f() -{ - int a; - a = 33; - double b; - b = 3.14; - T c; - c = b / a; - return 42; +int f() { + int a; + a = 33; + double b; + b = 3.14; + T c; + c = b / a; + return 42; } diff --git a/formalism/test072.c b/formalism/test072.c index a7844d737..6a78c7e21 100644 --- a/formalism/test072.c +++ b/formalism/test072.c @@ -1,7 +1,6 @@ -int f() -{ - const int* a; - int* b; - b = a; - return 0; +int f() { + const int *a; + int *b; + b = a; + return 0; } diff --git a/formalism/test073.c b/formalism/test073.c index 3fec2690a..bb537459b 100644 --- a/formalism/test073.c +++ b/formalism/test073.c @@ -1,6 +1,5 @@ -int f() -{ - int* p; +int f() { + int *p; p = 0; return 0; } diff --git a/formalism/test074.c b/formalism/test074.c index f63a77bde..dbce1615f 100644 --- a/formalism/test074.c +++ b/formalism/test074.c @@ -1,6 +1,5 @@ -int f() -{ - T* i; - i = 0; - return 0; +int f() { + T *i; + i = 0; + return 0; } diff --git a/formalism/test075.c b/formalism/test075.c index 95875b90c..266d95aa1 100644 --- a/formalism/test075.c +++ b/formalism/test075.c @@ -1,5 +1,4 @@ -int* f() -{ +int *f() { T p; return p; } diff --git a/formalism/test076.c b/formalism/test076.c index f0b2b55b3..b202c8613 100644 --- a/formalism/test076.c +++ b/formalism/test076.c @@ -1,5 +1,4 @@ -int f() -{ - int* p; - return *p; +int f() { + int *p; + return *p; } diff --git a/formalism/test077.c b/formalism/test077.c index 426c6e9bf..4e41052fa 100644 --- a/formalism/test077.c +++ b/formalism/test077.c @@ -1,5 +1,4 @@ -int f() -{ - const int* p; +int f() { + const int *p; return *p; } diff --git a/formalism/test078.c b/formalism/test078.c index 8cd12c778..92e8c22e1 100644 --- a/formalism/test078.c +++ b/formalism/test078.c @@ -1,5 +1,4 @@ -int f() -{ +int f() { const int x; return x; } diff --git a/formalism/test079.c b/formalism/test079.c index d2145cf58..514393f26 100644 --- a/formalism/test079.c +++ b/formalism/test079.c @@ -1,5 +1,4 @@ -int f() -{ +int f() { const int v; int w; w = v; diff --git a/formalism/test080.c b/formalism/test080.c index 6b891bbe6..263b8633c 100644 --- a/formalism/test080.c +++ b/formalism/test080.c @@ -1,6 +1,5 @@ -int f() -{ - const int* p; +int f() { + const int *p; int v; v = *p; return 0; diff --git a/formalism/test081.c b/formalism/test081.c index 04aad3c6d..80db14ae5 100644 --- a/formalism/test081.c +++ b/formalism/test081.c @@ -1,4 +1 @@ -int* f() -{ - return 0; -} +int *f() { return 0; } diff --git a/formalism/test082.c b/formalism/test082.c index 07816c6af..a56ee9d12 100644 --- a/formalism/test082.c +++ b/formalism/test082.c @@ -1,5 +1,4 @@ -int f() -{ +int f() { T1 r; r->m = 42; r->n = r; diff --git a/formalism/test083.c b/formalism/test083.c index 6f3772a34..b40f6b9e6 100644 --- a/formalism/test083.c +++ b/formalism/test083.c @@ -1,5 +1,4 @@ -int f() -{ +int f() { T1 r; r->o = 42; r->n = r; diff --git a/formalism/test085.c b/formalism/test085.c index 2713ae0cc..cfbda2a18 100644 --- a/formalism/test085.c +++ b/formalism/test085.c @@ -1,5 +1,4 @@ -node_t new_node(value_t value, node_t next) -{ +node_t new_node(value_t value, node_t next) { node_t node; node = 0; node->next = next; diff --git a/formalism/test086.c b/formalism/test086.c index 7d11f23cd..9bc41a594 100644 --- a/formalism/test086.c +++ b/formalism/test086.c @@ -1,7 +1,6 @@ -int f() -{ - const int x; - double y; - y = x; - return 0; +int f() { + const int x; + double y; + y = x; + return 0; } diff --git a/formalism/test087.c b/formalism/test087.c index 8633f2567..20e68dba0 100644 --- a/formalism/test087.c +++ b/formalism/test087.c @@ -1,7 +1,6 @@ -int f() -{ - const int* x; - double* y; - x = y; - return 0; +int f() { + const int *x; + double *y; + x = y; + return 0; } diff --git a/formalism/test088.c b/formalism/test088.c index 23e92a418..0001bc4fa 100644 --- a/formalism/test088.c +++ b/formalism/test088.c @@ -1,8 +1,7 @@ -int main() -{ - T* v; - v->next = v; - v->next->next = v; - v->next->next->next = v; - return 0; +int main() { + T *v; + v->next = v; + v->next->next = v; + v->next->next->next = v; + return 0; } diff --git a/formalism/test089.c b/formalism/test089.c index 0a795c211..3fd57d1fd 100644 --- a/formalism/test089.c +++ b/formalism/test089.c @@ -1,9 +1,8 @@ -int main() -{ - T* v; - v->next = v; - v->next->next = v; - v->next->next->next = v; - v->next->next->next->next = v; - return 0; +int main() { + T *v; + v->next = v; + v->next->next = v; + v->next->next->next = v; + v->next->next->next->next = v; + return 0; } diff --git a/formalism/test090.c b/formalism/test090.c index 88dd4b34a..eb533daf3 100644 --- a/formalism/test090.c +++ b/formalism/test090.c @@ -1,10 +1,9 @@ -int main() -{ - T* v; - v->next = v; - v->next->next = v; - v->next->next->next = v; - v->next->next->next->next = v; - v->next->next = v->next->next; - return 0; +int main() { + T *v; + v->next = v; + v->next->next = v; + v->next->next->next = v; + v->next->next->next->next = v; + v->next->next = v->next->next; + return 0; } diff --git a/formalism/test091.c b/formalism/test091.c index 7e8bd58b5..cdd9c0008 100644 --- a/formalism/test091.c +++ b/formalism/test091.c @@ -1,8 +1,7 @@ -int f() -{ - T1 e1; - T2 e2; - T3 e; - e = e1 /e2; - return 0; +int f() { + T1 e1; + T2 e2; + T3 e; + e = e1 / e2; + return 0; } diff --git a/formalism/test092.c b/formalism/test092.c index 45accd970..f89b18133 100644 --- a/formalism/test092.c +++ b/formalism/test092.c @@ -1,9 +1,8 @@ -T1 f() -{ - int x; - x = 42; - T3 y; - y = 3.14; - x = y; - return x; +T1 f() { + int x; + x = 42; + T3 y; + y = 3.14; + x = y; + return x; } diff --git a/formalism/test093.c b/formalism/test093.c index db24736e9..a1774e8e8 100644 --- a/formalism/test093.c +++ b/formalism/test093.c @@ -1,9 +1,8 @@ -T1 f() -{ - double x; - x = 42; - T3 y; - y = 3.14; - x = y; - return x; +T1 f() { + double x; + x = 42; + T3 y; + y = 3.14; + x = y; + return x; } diff --git a/formalism/test094.c b/formalism/test094.c index e75caad55..b4118a2b7 100644 --- a/formalism/test094.c +++ b/formalism/test094.c @@ -1,10 +1,9 @@ -int f() -{ - T1 e1; - T2 e2; - T x; - e1 = 123; - e2 = 44; - x = e1 / e2; - return x; +int f() { + T1 e1; + T2 e2; + T x; + e1 = 123; + e2 = 44; + x = e1 / e2; + return x; } diff --git a/formalism/test096.c b/formalism/test096.c index 45accd970..f89b18133 100644 --- a/formalism/test096.c +++ b/formalism/test096.c @@ -1,9 +1,8 @@ -T1 f() -{ - int x; - x = 42; - T3 y; - y = 3.14; - x = y; - return x; +T1 f() { + int x; + x = 42; + T3 y; + y = 3.14; + x = y; + return x; } diff --git a/formalism/test097.c b/formalism/test097.c index 382cc95a2..93d570068 100644 --- a/formalism/test097.c +++ b/formalism/test097.c @@ -1,9 +1,8 @@ -T1 f() -{ - int x; - x = 42; - T3 y; - y = 3.14; - y = x; - return x; +T1 f() { + int x; + x = 42; + T3 y; + y = 3.14; + y = x; + return x; } diff --git a/formalism/test098.c b/formalism/test098.c index 3067f58e4..94db95066 100644 --- a/formalism/test098.c +++ b/formalism/test098.c @@ -1,17 +1,16 @@ -int fff() -{ - int iii; - SSS www; - iii = www; - www = iii; +int fff() { + int iii; + SSS www; + iii = www; + www = iii; - double ddd; - QQQ uuu; - uuu = ddd; + double ddd; + QQQ uuu; + uuu = ddd; - TTT* aaa; - aaa = &www; - aaa = &uuu; + TTT *aaa; + aaa = &www; + aaa = &uuu; - return iii; + return iii; } diff --git a/formalism/test099.c b/formalism/test099.c index 361bd7ead..52d59dccb 100644 --- a/formalism/test099.c +++ b/formalism/test099.c @@ -1,6 +1,5 @@ -int fff() -{ - int iii; - iii = 0; - return iii; +int fff() { + int iii; + iii = 0; + return iii; } diff --git a/formalism/test100.c b/formalism/test100.c index ef6d908b8..14fab217e 100644 --- a/formalism/test100.c +++ b/formalism/test100.c @@ -1,10 +1,9 @@ -int fff() -{ - int* i; - double* d; - T* v; - v = i; - v = d; +int fff() { + int *i; + double *d; + T *v; + v = i; + v = d; - return 10; + return 10; } diff --git a/formalism/test101.c b/formalism/test101.c index 3689073a1..19d6c9ecb 100644 --- a/formalism/test101.c +++ b/formalism/test101.c @@ -1,9 +1,8 @@ -int g() -{ - const int i; - const int c; - T1 v1; - v1 = i + c; +int g() { + const int i; + const int c; + T1 v1; + v1 = i + c; - return 10; + return 10; } diff --git a/formalism/test102.c b/formalism/test102.c index 60133a950..4d41bc555 100644 --- a/formalism/test102.c +++ b/formalism/test102.c @@ -1,9 +1,8 @@ -int g() -{ - const int i; - const double d; - T v; - v = d/i; +int g() { + const int i; + const double d; + T v; + v = d / i; - return 10; + return 10; } diff --git a/formalism/test103.c b/formalism/test103.c index c7e51faf8..1463c6f25 100644 --- a/formalism/test103.c +++ b/formalism/test103.c @@ -1,9 +1,8 @@ -int g() -{ - const int i; - const double d; - T v; - v = i/d; +int g() { + const int i; + const double d; + T v; + v = i / d; - return 10; + return 10; } diff --git a/formalism/test104.c b/formalism/test104.c index 335916de9..0818f2982 100644 --- a/formalism/test104.c +++ b/formalism/test104.c @@ -1,8 +1,7 @@ -int k() -{ - const int x; - int y; - x = y; +int k() { + const int x; + int y; + x = y; - return 23; + return 23; } diff --git a/formalism/test105.c b/formalism/test105.c index a9e224e08..69dee319b 100644 --- a/formalism/test105.c +++ b/formalism/test105.c @@ -1,8 +1,7 @@ -int k() -{ - const int x; - T y; - x = y; +int k() { + const int x; + T y; + x = y; - return 23; + return 23; } diff --git a/formalism/test106.c b/formalism/test106.c index 7c8e50f74..24399cb3f 100644 --- a/formalism/test106.c +++ b/formalism/test106.c @@ -1,8 +1,7 @@ -int k() -{ - const double x; - int y; - x = y; +int k() { + const double x; + int y; + x = y; - return 23; + return 23; } diff --git a/formalism/test107.c b/formalism/test107.c index 432496d5c..a50c87b07 100644 --- a/formalism/test107.c +++ b/formalism/test107.c @@ -1,23 +1,22 @@ -int k() -{ - const int x; - const int y; - int z; +int k() { + const int x; + const int y; + int z; - T1 m; - m = x || y; - T2 n; - n = x || z; - T3 p; - p = z || x; - T4 q; - q = x + z; - T5 s; - s = z + x; - T6 t; - t = z / x; - T7 l; - l = x / z; + T1 m; + m = x || y; + T2 n; + n = x || z; + T3 p; + p = z || x; + T4 q; + q = x + z; + T5 s; + s = z + x; + T6 t; + t = z / x; + T7 l; + l = x / z; - return 23; + return 23; } diff --git a/formalism/test108.c b/formalism/test108.c index b6c7f3132..a24e66011 100644 --- a/formalism/test108.c +++ b/formalism/test108.c @@ -1,12 +1,11 @@ -int k() -{ - const int* p; - const int cv; +int k() { + const int *p; + const int cv; - T1 x; - x = p + cv; - T2 y; - y = cv + p; + T1 x; + x = p + cv; + T2 y; + y = cv + p; - return 23; + return 23; } diff --git a/formalism/test109.c b/formalism/test109.c index ad05ce95e..7c099bc6e 100644 --- a/formalism/test109.c +++ b/formalism/test109.c @@ -1,6 +1,5 @@ -int f() -{ - const int* ppp; - int* const qqq; - return 1; +int f() { + const int *ppp; + int *const qqq; + return 1; } diff --git a/formalism/test110.c b/formalism/test110.c index c5c647f23..c5cba9b38 100644 --- a/formalism/test110.c +++ b/formalism/test110.c @@ -1,10 +1,9 @@ -int f() -{ - T a; - a / 2; +int f() { + T a; + a / 2; - T b; - 2/b; + T b; + 2 / b; - return 1; + return 1; } diff --git a/formalism/test111.c b/formalism/test111.c index 509facf06..d60a6eb70 100644 --- a/formalism/test111.c +++ b/formalism/test111.c @@ -1,9 +1,8 @@ -int f() -{ - T1 a; - T1* b; - T2 c; - c = a * 2; +int f() { + T1 a; + T1 *b; + T2 c; + c = a * 2; - return 1; + return 1; } diff --git a/tests/TestSuite.cpp b/tests/TestSuite.cpp index 7cfca033e..c5e9d6d5e 100644 --- a/tests/TestSuite.cpp +++ b/tests/TestSuite.cpp @@ -20,35 +20,32 @@ #include "TestSuite.h" -#include "C/tests/TestSuite_Internals.h" #include "C/tests/TestSuite_API.h" +#include "C/tests/TestSuite_Internals.h" #include using namespace psy; -void TestSuite::runTests() -{ - std::cout << "TESTS..." << std::endl; +void TestSuite::runTests() { + std::cout << "TESTS..." << std::endl; - C::InternalsTestSuite suite0; - auto [passed0, failed0] = suite0.testAll(); + C::InternalsTestSuite suite0; + auto [passed0, failed0] = suite0.testAll(); - C::APITestSuite suite1; - auto [passed1, failed1] = suite1.testAll(); + C::APITestSuite suite1; + auto [passed1, failed1] = suite1.testAll(); - std::cout << suite0.description() << std::endl; - suite0.printSummary(); + std::cout << suite0.description() << std::endl; + suite0.printSummary(); - std::cout << suite1.description() << std::endl; - suite1.printSummary(); + std::cout << suite1.description() << std::endl; + suite1.printSummary(); - auto accErrorCnt = failed0 + failed1; - if (!accErrorCnt) - std::cout << "All passed" << std::endl; - else - std::cout << std::string(17, '.') << " \n" - << "> Total failures: " - << failed0 + failed1 - << std::endl; + auto accErrorCnt = failed0 + failed1; + if (!accErrorCnt) + std::cout << "All passed" << std::endl; + else + std::cout << std::string(17, '.') << " \n" + << "> Total failures: " << failed0 + failed1 << std::endl; } diff --git a/tests/TestSuite.h b/tests/TestSuite.h index 6a3b2dcd0..a03ceef2e 100644 --- a/tests/TestSuite.h +++ b/tests/TestSuite.h @@ -27,17 +27,16 @@ namespace psy { -class TestSuite -{ +class TestSuite { public: - virtual ~TestSuite() {} - virtual std::string description() const = 0; - virtual std::tuple testAll() = 0; - virtual void printSummary() const = 0; + virtual ~TestSuite() {} + virtual std::string description() const = 0; + virtual std::tuple testAll() = 0; + virtual void printSummary() const = 0; - static void runTests(); + static void runTests(); }; -} // psy +} // namespace psy #endif diff --git a/tests/Tester.h b/tests/Tester.h index f121ac270..97f1659b7 100644 --- a/tests/Tester.h +++ b/tests/Tester.h @@ -28,53 +28,58 @@ #define PSY__internals__EQ_OPTR(A, B) A == B #define PSY__internals__EQ_STD(A, B) std::equal(A.begin(), A.end(), B.begin()) -#define PSY__internals__FAIL(MSG) \ - do { \ - std::cout << "\n!\tFAIL\n" \ - << "\tReason: " << MSG << "\n" \ - << "\t\t" << __FILE__ << ":" << __LINE__ << std::endl; \ - throw TestFailed(); \ - } while (0) - - -#define PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, EQ) \ - do { \ - if (!(EQ(ACTUAL, EXPECTED))) { \ - std::cout << "\n!\tFAIL\n" \ - << "\t\tActual : " << ACTUAL << "\n" \ - << "\t\tExpected: " << EXPECTED << "\n" \ - << "\t\t" << __FILE__ << ":" << __LINE__ << std::endl; \ - throw TestFailed(); \ - } \ - } while (0) - -#define PSY__internals__EXPECT_EQ_UNDER_TYPE(ACTUAL, EXPECTED, UNDER_TYPE) \ - do { \ - if (!(PSY__internals__EQ_OPTR(std::underlying_type_t(ACTUAL), \ - std::underlying_type_t(EXPECTED)))) { \ - std::cout << "\n!\tFAIL\n" \ - << "\t\tActual : " << to_string(ACTUAL) << "\n" \ - << "\t\tExpected: " << to_string(EXPECTED) << "\n" \ - << "\t\t" << __FILE__ << ":" << __LINE__ << std::endl; \ - throw TestFailed(); \ - } \ - } while (0) - -#define PSY__internals__EXPECT_BOOL(EXPR, BOOLEAN) \ - do { \ - if (bool(EXPR) != BOOLEAN) { \ - std::cout << "\n!\tFAIL\n" \ - << "\t\tExpression is NOT " << #BOOLEAN << "\n" \ - << "\t\t" << __FILE__ << ":" << __LINE__ << std::endl; \ - throw TestFailed(); \ - } \ - } while (0) - -#define PSY_EXPECT_EQ_PTR(ACTUAL, EXPECTED) PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, PSY__internals__EQ_OPTR) -#define PSY_EXPECT_EQ_STR(ACTUAL, EXPECTED) PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, PSY__internals__EQ_OPTR) -#define PSY_EXPECT_EQ_INT(ACTUAL, EXPECTED) PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, PSY__internals__EQ_OPTR) -#define PSY_EXPECT_EQ_ENU(ACTUAL, EXPECTED, ENUM_TYPE) PSY__internals__EXPECT_EQ_UNDER_TYPE(ACTUAL, EXPECTED, ENUM_TYPE) -#define PSY_EXPECT_EQ_STD(ACTUAL, EXPECTED) PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, PSY__internals__EQ_STD) +#define PSY__internals__FAIL(MSG) \ + do { \ + std::cout << "\n!\tFAIL\n" \ + << "\tReason: " << MSG << "\n" \ + << "\t\t" << __FILE__ << ":" << __LINE__ << std::endl; \ + throw TestFailed(); \ + } while (0) + +#define PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, EQ) \ + do { \ + if (!(EQ(ACTUAL, EXPECTED))) { \ + std::cout << "\n!\tFAIL\n" \ + << "\t\tActual : " << ACTUAL << "\n" \ + << "\t\tExpected: " << EXPECTED << "\n" \ + << "\t\t" << __FILE__ << ":" << __LINE__ << std::endl; \ + throw TestFailed(); \ + } \ + } while (0) + +#define PSY__internals__EXPECT_EQ_UNDER_TYPE(ACTUAL, EXPECTED, UNDER_TYPE) \ + do { \ + if (!(PSY__internals__EQ_OPTR( \ + std::underlying_type_t(ACTUAL), \ + std::underlying_type_t(EXPECTED)))) { \ + std::cout << "\n!\tFAIL\n" \ + << "\t\tActual : " << to_string(ACTUAL) << "\n" \ + << "\t\tExpected: " << to_string(EXPECTED) << "\n" \ + << "\t\t" << __FILE__ << ":" << __LINE__ << std::endl; \ + throw TestFailed(); \ + } \ + } while (0) + +#define PSY__internals__EXPECT_BOOL(EXPR, BOOLEAN) \ + do { \ + if (bool(EXPR) != BOOLEAN) { \ + std::cout << "\n!\tFAIL\n" \ + << "\t\tExpression is NOT " << #BOOLEAN << "\n" \ + << "\t\t" << __FILE__ << ":" << __LINE__ << std::endl; \ + throw TestFailed(); \ + } \ + } while (0) + +#define PSY_EXPECT_EQ_PTR(ACTUAL, EXPECTED) \ + PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, PSY__internals__EQ_OPTR) +#define PSY_EXPECT_EQ_STR(ACTUAL, EXPECTED) \ + PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, PSY__internals__EQ_OPTR) +#define PSY_EXPECT_EQ_INT(ACTUAL, EXPECTED) \ + PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, PSY__internals__EQ_OPTR) +#define PSY_EXPECT_EQ_ENU(ACTUAL, EXPECTED, ENUM_TYPE) \ + PSY__internals__EXPECT_EQ_UNDER_TYPE(ACTUAL, EXPECTED, ENUM_TYPE) +#define PSY_EXPECT_EQ_STD(ACTUAL, EXPECTED) \ + PSY__internals__EXPECT_EQ(ACTUAL, EXPECTED, PSY__internals__EQ_STD) #define PSY_EXPECT_TRUE(EXPR) PSY__internals__EXPECT_BOOL(EXPR, true) #define PSY_EXPECT_FALSE(EXPR) PSY__internals__EXPECT_BOOL(EXPR, false) @@ -85,56 +90,50 @@ struct TestFailed {}; class TestSuite; -class Tester -{ +class Tester { public: - virtual ~Tester() {} + virtual ~Tester() {} - virtual std::string name() const = 0; + virtual std::string name() const = 0; - virtual void setUp() {} - virtual void tearDown() {} + virtual void setUp() {} + virtual void tearDown() {} - int totalPassed() const { return cntPassed_; } - int totalFailed() const { return cntFailed_; } + int totalPassed() const { return cntPassed_; } + int totalFailed() const { return cntFailed_; } protected: - Tester(TestSuite* suite) - : suite_(suite) - , cntPassed_(0) - , cntFailed_(0) - {} - - TestSuite* suite_; - int cntPassed_; - int cntFailed_; - - template - void run(const TestContT& tests) - { - for (auto testData : tests) { - setUp(); - - curTestFunc_ = testData.second; - std::cout << "\t" << TesterT::Name << "-" << curTestFunc_ << "... "; - - try { - auto curTestFunc = testData.first; - curTestFunc(static_cast(this)); - std::cout << "OK"; - ++cntPassed_; - } catch (const TestFailed&) { - ++cntFailed_; - } - std::cout << "\n\t-------------------------------------------------" << std::endl; - - tearDown(); - } + Tester(TestSuite *suite) : suite_(suite), cntPassed_(0), cntFailed_(0) {} + + TestSuite *suite_; + int cntPassed_; + int cntFailed_; + + template void run(const TestContT &tests) { + for (auto testData : tests) { + setUp(); + + curTestFunc_ = testData.second; + std::cout << "\t" << TesterT::Name << "-" << curTestFunc_ << "... "; + + try { + auto curTestFunc = testData.first; + curTestFunc(static_cast(this)); + std::cout << "OK"; + ++cntPassed_; + } catch (const TestFailed &) { + ++cntFailed_; + } + std::cout << "\n\t-------------------------------------------------" + << std::endl; + + tearDown(); } + } - std::string curTestFunc_; + std::string curTestFunc_; }; -} // psy +} // namespace psy #endif diff --git a/tools/GnuCompilerFacade.cpp b/tools/GnuCompilerFacade.cpp index d22307b17..b69cba1d0 100644 --- a/tools/GnuCompilerFacade.cpp +++ b/tools/GnuCompilerFacade.cpp @@ -25,61 +25,55 @@ #include #include -namespace -{ -const char * const kInclude = "#include"; +namespace { +const char *const kInclude = "#include"; } using namespace psy; -GnuCompilerFacade::GnuCompilerFacade(const std::string& compilerName, - const std::string& std, - const std::vector& D, - const std::vector& U) - : compilerName_(compilerName) - , std_(std) - , D_(D) - , U_(U) -{} +GnuCompilerFacade::GnuCompilerFacade(const std::string &compilerName, + const std::string &std, + const std::vector &D, + const std::vector &U) + : compilerName_(compilerName), std_(std), D_(D), U_(U) {} -std::pair GnuCompilerFacade::preprocess(const std::string& srcText) -{ - std::string in = "cat << 'EOF' | "; - in += compilerName_; - in += assembleMacroCmd(); - in += " "; - in += "-std=" + std_ + " "; - in += "-E -x c -CC -"; - in += "\n" + srcText + "\nEOF"; +std::pair +GnuCompilerFacade::preprocess(const std::string &srcText) { + std::string in = "cat << 'EOF' | "; + in += compilerName_; + in += assembleMacroCmd(); + in += " "; + in += "-std=" + std_ + " "; + in += "-E -x c -CC -"; + in += "\n" + srcText + "\nEOF"; - return Process().execute(in); + return Process().execute(in); } -std::pair GnuCompilerFacade::preprocess_IgnoreIncludes(const std::string& srcText) -{ - std::string srcText_P; - srcText_P.reserve(srcText.length()); +std::pair +GnuCompilerFacade::preprocess_IgnoreIncludes(const std::string &srcText) { + std::string srcText_P; + srcText_P.reserve(srcText.length()); - std::istringstream iss(srcText); - std::string line; - while (std::getline(iss, line)) { - line.erase(0, line.find_first_not_of(' ')); + std::istringstream iss(srcText); + std::string line; + while (std::getline(iss, line)) { + line.erase(0, line.find_first_not_of(' ')); - if (line.find(kInclude) == 0) - continue; + if (line.find(kInclude) == 0) + continue; - srcText_P += (line + "\n"); - } + srcText_P += (line + "\n"); + } - return preprocess(srcText_P); + return preprocess(srcText_P); } -std::string GnuCompilerFacade::assembleMacroCmd() const -{ - std::string s; - for (const auto& d : D_) - s += " -D " + d; - for (const auto& u : U_) - s += " -U " + u; - return s; +std::string GnuCompilerFacade::assembleMacroCmd() const { + std::string s; + for (const auto &d : D_) + s += " -D " + d; + for (const auto &u : U_) + s += " -U " + u; + return s; } diff --git a/tools/GnuCompilerFacade.h b/tools/GnuCompilerFacade.h index b596ee26d..ef29b6782 100644 --- a/tools/GnuCompilerFacade.h +++ b/tools/GnuCompilerFacade.h @@ -27,26 +27,25 @@ namespace psy { -class GnuCompilerFacade -{ +class GnuCompilerFacade { public: - GnuCompilerFacade(const std::string& compilerName, - const std::string& std, - const std::vector& D, - const std::vector& U); + GnuCompilerFacade(const std::string &compilerName, const std::string &std, + const std::vector &D, + const std::vector &U); - std::pair preprocess(const std::string& srcText); - std::pair preprocess_IgnoreIncludes(const std::string& srcText); + std::pair preprocess(const std::string &srcText); + std::pair + preprocess_IgnoreIncludes(const std::string &srcText); private: - std::string assembleMacroCmd() const; + std::string assembleMacroCmd() const; - std::string compilerName_; - std::string std_; - std::vector D_; - std::vector U_; + std::string compilerName_; + std::string std_; + std::vector D_; + std::vector U_; }; -} // psy +} // namespace psy #endif diff --git a/utility/FileInfo.cpp b/utility/FileInfo.cpp index 1cf19f4a2..bb5d6a52a 100644 --- a/utility/FileInfo.cpp +++ b/utility/FileInfo.cpp @@ -22,66 +22,50 @@ using namespace psy; -struct FileInfo::FileInfoImpl -{ - FileInfoImpl(const std::string& fullFileName) - : fullFileName_(fullFileName) - {} +struct FileInfo::FileInfoImpl { + FileInfoImpl(const std::string &fullFileName) : fullFileName_(fullFileName) {} - std::string fullFileName_; + std::string fullFileName_; }; -FileInfo::FileInfo(const std::string& fullFileName) - : impl_(new FileInfoImpl(fullFileName)) -{} +FileInfo::FileInfo(const std::string &fullFileName) + : impl_(new FileInfoImpl(fullFileName)) {} -FileInfo::~FileInfo() -{} +FileInfo::~FileInfo() {} -std::string FileInfo::fileName() const -{ - size_t pos = impl_->fullFileName_.rfind('/'); - return impl_->fullFileName_.substr(pos + 1); +std::string FileInfo::fileName() const { + size_t pos = impl_->fullFileName_.rfind('/'); + return impl_->fullFileName_.substr(pos + 1); } -std::string FileInfo::fileBaseName() const -{ - size_t pos2 = impl_->fullFileName_.rfind('.'); - size_t pos1 = impl_->fullFileName_.rfind('/', pos2); - return impl_->fullFileName_.substr(pos1 + 1, pos2 - (pos1 + 1)); +std::string FileInfo::fileBaseName() const { + size_t pos2 = impl_->fullFileName_.rfind('.'); + size_t pos1 = impl_->fullFileName_.rfind('/', pos2); + return impl_->fullFileName_.substr(pos1 + 1, pos2 - (pos1 + 1)); } -std::string FileInfo::fullFileBaseName() const -{ - return fullDir() + "/" + fileBaseName(); +std::string FileInfo::fullFileBaseName() const { + return fullDir() + "/" + fileBaseName(); } -std::string FileInfo::fullFileName() const -{ - return impl_->fullFileName_; -} +std::string FileInfo::fullFileName() const { return impl_->fullFileName_; } -std::string FileInfo::dir() const -{ - size_t pos1 = std::string::npos; - size_t pos2 = impl_->fullFileName_.rfind('/'); - if (pos2 == 0) - return ""; - pos1 = impl_->fullFileName_.rfind('/', pos2 - 1); - if (pos1 == std::string::npos) - pos1 = 0; - return impl_->fullFileName_.substr(pos1 + 1, pos2 - (pos1 + 1)); +std::string FileInfo::dir() const { + size_t pos1 = std::string::npos; + size_t pos2 = impl_->fullFileName_.rfind('/'); + if (pos2 == 0) + return ""; + pos1 = impl_->fullFileName_.rfind('/', pos2 - 1); + if (pos1 == std::string::npos) + pos1 = 0; + return impl_->fullFileName_.substr(pos1 + 1, pos2 - (pos1 + 1)); } -std::string FileInfo::fullDir() const -{ - size_t pos = impl_->fullFileName_.rfind('/'); - if (pos == std::string::npos) - return "./"; - return impl_->fullFileName_.substr(0, pos + 1); +std::string FileInfo::fullDir() const { + size_t pos = impl_->fullFileName_.rfind('/'); + if (pos == std::string::npos) + return "./"; + return impl_->fullFileName_.substr(0, pos + 1); } -char FileInfo::dirSeparator() -{ - return '/'; -} +char FileInfo::dirSeparator() { return '/'; } diff --git a/utility/FileInfo.h b/utility/FileInfo.h index 148bb59ac..a63024660 100644 --- a/utility/FileInfo.h +++ b/utility/FileInfo.h @@ -31,92 +31,90 @@ namespace psy { * \note * From https://github.com/ltcmelo/uaiso */ -class FileInfo final -{ +class FileInfo final { public: - ~FileInfo(); - - /*! - * \brief FileInfo - * \param fullFileName - * - * Within the docs, suppose an instance of this class is created as: - * - * \code - * FileInfo fileInfo("/home/user/project/code.cpp"); - * \endcode - */ - FileInfo(const std::string& fullFileName); - - /*! - * \brief fileName - * \return - * - * According to constructor's assumption, return is: - * "code.cpp" - */ - std::string fileName() const; - - /*! - * \brief fileBaseName - * \return - * - * According to constructor's assumption, return is: - * "code" - */ - std::string fileBaseName() const; - - /*! - * \brief fullFileBaseName - * \return - * - * According to constructor's assumption, return is: - * "/home/user/project/code" - */ - std::string fullFileBaseName() const; - - /*! - * \brief fullFileName - * \return - * - * According to constructor's assumption, return is: - * "/home/user/project/code.cpp" - */ - std::string fullFileName() const; - - /*! - * \brief dir - * \return - * - * According to constructor's assumption, return is: - * "project" - */ - std::string dir() const; - - /*! - * \brief fullDir - * \return - * - * According to constructor's assumption, return is: - * "/home/user/project" - */ - std::string fullDir() const; - - /*! - * \brief dirSeparator - * \return - */ - static char dirSeparator(); + ~FileInfo(); + + /*! + * \brief FileInfo + * \param fullFileName + * + * Within the docs, suppose an instance of this class is created as: + * + * \code + * FileInfo fileInfo("/home/user/project/code.cpp"); + * \endcode + */ + FileInfo(const std::string &fullFileName); + + /*! + * \brief fileName + * \return + * + * According to constructor's assumption, return is: + * "code.cpp" + */ + std::string fileName() const; + + /*! + * \brief fileBaseName + * \return + * + * According to constructor's assumption, return is: + * "code" + */ + std::string fileBaseName() const; + + /*! + * \brief fullFileBaseName + * \return + * + * According to constructor's assumption, return is: + * "/home/user/project/code" + */ + std::string fullFileBaseName() const; + + /*! + * \brief fullFileName + * \return + * + * According to constructor's assumption, return is: + * "/home/user/project/code.cpp" + */ + std::string fullFileName() const; + + /*! + * \brief dir + * \return + * + * According to constructor's assumption, return is: + * "project" + */ + std::string dir() const; + + /*! + * \brief fullDir + * \return + * + * According to constructor's assumption, return is: + * "/home/user/project" + */ + std::string fullDir() const; + + /*! + * \brief dirSeparator + * \return + */ + static char dirSeparator(); private: - struct FileInfoImpl; - FileInfoImpl* impl_; + struct FileInfoImpl; + FileInfoImpl *impl_; }; -bool operator==(const FileInfo& a, const FileInfo& b); -bool operator!=(const FileInfo& a, const FileInfo& b); +bool operator==(const FileInfo &a, const FileInfo &b); +bool operator!=(const FileInfo &a, const FileInfo &b); - -} // psy +} // namespace psy #endif diff --git a/utility/IO.cpp b/utility/IO.cpp index 1aadeebbf..9fd5c202a 100644 --- a/utility/IO.cpp +++ b/utility/IO.cpp @@ -26,31 +26,29 @@ namespace psy { -std::pair readFile(const std::string& fileName) -{ - std::ifstream ifs(fileName); - if (!ifs) { - std::cerr << "file input error: " << fileName << std::endl; - return std::make_pair(1, ""); - } - - std::stringstream ss; - ss << ifs.rdbuf(); - ifs.close(); - return std::make_pair(0, ss.str()); +std::pair readFile(const std::string &fileName) { + std::ifstream ifs(fileName); + if (!ifs) { + std::cerr << "file input error: " << fileName << std::endl; + return std::make_pair(1, ""); + } + + std::stringstream ss; + ss << ifs.rdbuf(); + ifs.close(); + return std::make_pair(0, ss.str()); } -int writeFile(const std::string& fileName, const std::string& content) -{ - std::ofstream ofs(fileName); - if (!ofs) { - std::cerr << "file output error: " << fileName << std::endl; - return 1; - } - - ofs << content; - ofs.close(); - return 0; +int writeFile(const std::string &fileName, const std::string &content) { + std::ofstream ofs(fileName); + if (!ofs) { + std::cerr << "file output error: " << fileName << std::endl; + return 1; + } + + ofs << content; + ofs.close(); + return 0; } -} // psy +} // namespace psy diff --git a/utility/IO.h b/utility/IO.h index ab8a510e3..0ad40a823 100644 --- a/utility/IO.h +++ b/utility/IO.h @@ -26,10 +26,10 @@ namespace psy { -std::pair readFile(const std::string& filePath); +std::pair readFile(const std::string &filePath); -int writeFile(const std::string& filePath, const std::string& content); +int writeFile(const std::string &filePath, const std::string &content); -} // psy +} // namespace psy #endif diff --git a/utility/Process.cpp b/utility/Process.cpp index d77a9fd35..1069e58de 100644 --- a/utility/Process.cpp +++ b/utility/Process.cpp @@ -28,30 +28,27 @@ using namespace psy; namespace { -std::pair executeCore(const char* cmd) -{ - FILE* pipe = popen(cmd, "r"); - if (!pipe) - return std::make_pair(1, ""); - - std::string all; - while (!feof(pipe)) { - std::array buf; - if (fgets(buf.data(), 512, pipe)) - all += buf.data(); - } - - return std::make_pair(pclose(pipe), all); +std::pair executeCore(const char *cmd) { + FILE *pipe = popen(cmd, "r"); + if (!pipe) + return std::make_pair(1, ""); + + std::string all; + while (!feof(pipe)) { + std::array buf; + if (fgets(buf.data(), 512, pipe)) + all += buf.data(); + } + + return std::make_pair(pclose(pipe), all); } -} // anonymous +} // namespace -std::pair Process::execute(std::string&& s) -{ - return executeCore(s.c_str()); +std::pair Process::execute(std::string &&s) { + return executeCore(s.c_str()); } -std::pair Process::execute(const std::string &s) -{ - return executeCore(s.c_str()); +std::pair Process::execute(const std::string &s) { + return executeCore(s.c_str()); } diff --git a/utility/Process.h b/utility/Process.h index d85405cb4..788a209c8 100644 --- a/utility/Process.h +++ b/utility/Process.h @@ -26,13 +26,12 @@ namespace psy { -class Process final -{ +class Process final { public: - std::pair execute(const std::string& cmd); - std::pair execute(std::string&& cmd); + std::pair execute(const std::string &cmd); + std::pair execute(std::string &&cmd); }; -} // psy +} // namespace psy #endif