diff options
Diffstat (limited to 'include/clang/Parse/Parser.h')
-rw-r--r-- | include/clang/Parse/Parser.h | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 9a4634a..42a41d6 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -41,6 +41,29 @@ public: virtual void print(llvm::raw_ostream &OS) const; }; +/// PrecedenceLevels - These are precedences for the binary/ternary +/// operators in the C99 grammar. These have been named to relate +/// with the C99 grammar productions. Low precedences numbers bind +/// more weakly than high numbers. +namespace prec { + enum Level { + Unknown = 0, // Not binary operator. + Comma = 1, // , + Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= + Conditional = 3, // ? + LogicalOr = 4, // || + LogicalAnd = 5, // && + InclusiveOr = 6, // | + ExclusiveOr = 7, // ^ + And = 8, // & + Equality = 9, // ==, != + Relational = 10, // >=, <=, >, < + Shift = 11, // <<, >> + Additive = 12, // -, + + Multiplicative = 13, // *, /, % + PointerToMember = 14 // .*, ->* + }; +} /// Parser - This implements a parser for the C family of languages. After /// parsing units of the grammar, productions are invoked to handle whatever has @@ -460,9 +483,11 @@ private: //===--------------------------------------------------------------------===// // Diagnostic Emission and Error recovery. +public: DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID); +private: void SuggestParentheses(SourceLocation Loc, unsigned DK, SourceRange ParenRange); @@ -771,9 +796,15 @@ private: const ParsedTemplateInfo &TemplateInfo); void ParseLexedMethodDeclarations(ParsingClass &Class); void ParseLexedMethodDefs(ParsingClass &Class); + bool ConsumeAndStoreUntil(tok::TokenKind T1, + CachedTokens &Toks, + bool StopAtSemi = true, + bool ConsumeFinalToken = true) { + return ConsumeAndStoreUntil(T1, T1, Toks, StopAtSemi, ConsumeFinalToken); + } bool ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2, CachedTokens &Toks, - tok::TokenKind EarlyAbortIf = tok::unknown, + bool StopAtSemi = true, bool ConsumeFinalToken = true); //===--------------------------------------------------------------------===// @@ -846,7 +877,7 @@ private: //===--------------------------------------------------------------------===// // C99 6.5: Expressions. - + OwningExprResult ParseExpression(); OwningExprResult ParseConstantExpression(); // Expr that doesn't include commas. @@ -857,7 +888,7 @@ private: OwningExprResult ParseExpressionWithLeadingExtension(SourceLocation ExtLoc); OwningExprResult ParseRHSOfBinaryExpression(OwningExprResult LHS, - unsigned MinPrec); + prec::Level MinPrec); OwningExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, @@ -954,6 +985,8 @@ private: // C++ 5.2.3: Explicit type conversion (functional notation) OwningExprResult ParseCXXTypeConstructExpression(const DeclSpec &DS); + bool isCXXSimpleTypeSpecifier() const; + /// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers. /// This should only be called when the current token is known to be part of /// simple-type-specifier. @@ -998,18 +1031,6 @@ private: //===--------------------------------------------------------------------===// // Objective-C Expressions - - bool isTokObjCMessageIdentifierReceiver() const { - if (!Tok.is(tok::identifier)) - return false; - - IdentifierInfo *II = Tok.getIdentifierInfo(); - if (Actions.getTypeName(*II, Tok.getLocation(), CurScope)) - return true; - - return II == Ident_super; - } - OwningExprResult ParseObjCAtExpression(SourceLocation AtLocation); OwningExprResult ParseObjCStringLiteral(SourceLocation AtLoc); OwningExprResult ParseObjCEncodeExpression(SourceLocation AtLoc); @@ -1017,12 +1038,13 @@ private: OwningExprResult ParseObjCProtocolExpression(SourceLocation AtLoc); OwningExprResult ParseObjCMessageExpression(); OwningExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc, - SourceLocation NameLoc, - IdentifierInfo *ReceiverName, + SourceLocation SuperLoc, + TypeTy *ReceiverType, ExprArg ReceiverExpr); OwningExprResult ParseAssignmentExprWithObjCMessageExprStart( - SourceLocation LBracloc, SourceLocation NameLoc, - IdentifierInfo *ReceiverName, ExprArg ReceiverExpr); + SourceLocation LBracloc, SourceLocation SuperLoc, + TypeTy *ReceiverType, ExprArg ReceiverExpr); + bool ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr); //===--------------------------------------------------------------------===// // C99 6.8: Statements and Blocks. @@ -1354,7 +1376,7 @@ private: //===--------------------------------------------------------------------===// // C++ 9: classes [class] and C structs/unions. TypeResult ParseClassName(SourceLocation &EndLocation, - const CXXScopeSpec *SS = 0); + CXXScopeSpec *SS = 0); void ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation TagLoc, DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), |