]> granicus.if.org Git - clang/commitdiff
Parse ObjC @protocol expressions.
authorAnders Carlsson <andersca@mac.com>
Thu, 23 Aug 2007 15:25:28 +0000 (15:25 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 23 Aug 2007 15:25:28 +0000 (15:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41320 91177308-0d34-0410-b5e6-96231b3b80d8

Parse/ParseObjc.cpp
clang.xcodeproj/project.pbxproj
include/clang/Parse/Parser.h

index 4f4bdfe01244aa65b8749dfabaefb4c9517e3acd..b1c5366197f8fd28d4230542e0e77cf7af1477b2 100644 (file)
@@ -634,9 +634,15 @@ Parser::ExprResult Parser::ParseObjCExpression() {
     case tok::string_literal:    // primary-expression: string-literal
     case tok::wide_string_literal:
       return ParseObjCStringLiteral();
+    default:
+      break;
+  }
+  
+  switch (Tok.getIdentifierInfo()->getObjCKeywordID()) {
     case tok::objc_encode:
       return ParseObjCEncodeExpression();
-      break;
+    case tok::objc_protocol:
+      return ParseObjCProtocolExpression();
     default:
       Diag(AtLoc, diag::err_unexpected_at);
       SkipUntil(tok::semi);
@@ -679,3 +685,36 @@ Parser::ExprResult Parser::ParseObjCEncodeExpression() {
   return Actions.ParseObjCEncodeExpression(EncLoc, LParenLoc, Ty, 
                                            ConsumeParen());
 }
+
+///     objc-protocol-expression
+///       @protocol ( protocol-name )
+
+Parser::ExprResult Parser::ParseObjCProtocolExpression()
+{
+  SourceLocation ProtoLoc = ConsumeToken();
+  
+  if (Tok.getKind() != tok::l_paren) {
+    Diag(Tok, diag::err_expected_lparen_after, "@protocol");
+    return true;
+  }
+  
+  SourceLocation LParenLoc = ConsumeParen();
+  
+  if (Tok.getKind() != tok::identifier) {
+    Diag(Tok, diag::err_expected_ident);
+    return true;
+  }
+
+  // FIXME: Do something with the protocol name
+  ConsumeToken();
+  
+  if (Tok.getKind() != tok::r_paren) {
+    Diag(Tok, diag::err_expected_rparen);
+    return true;
+  }
+  
+  ConsumeParen();
+
+  // FIXME 
+  return 0;
+}
index 19e984ce33e5de08844de1420641bf6c630817b4..7e38e051dda6344719f9fdb4ee6ba49fcec958d3 100644 (file)
                1ABC36930C7A4BDC006DB0AB /* CGBuiltin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CGBuiltin.cpp; path = CodeGen/CGBuiltin.cpp; sourceTree = "<group>"; };
                84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeList.cpp; path = Parse/AttributeList.cpp; sourceTree = "<group>"; };
                84D9A88B0C1A581300AC7ABC /* AttributeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AttributeList.h; path = clang/Parse/AttributeList.h; sourceTree = "<group>"; };
-               8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
+               8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
                DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = "<group>"; };
                DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = Parse/ParseExprCXX.cpp; sourceTree = "<group>"; };
                DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };
index 90988791deddde7fc05a2fb9c6aaad1bb031c6a5..97c0ca1d452e4f95d8f139583f212163bc5388eb 100644 (file)
@@ -336,6 +336,7 @@ private:
   ExprResult ParseObjCExpression();
   ExprResult ParseObjCStringLiteral();
   ExprResult ParseObjCEncodeExpression();
+  ExprResult ParseObjCProtocolExpression();
 
   //===--------------------------------------------------------------------===//
   // C99 6.8: Statements and Blocks.