[cfe-commits] r41320 - in /cfe/trunk: Parse/ParseObjc.cpp clang.xcodeproj/project.pbxproj include/clang/Parse/Parser.h
Anders Carlsson
andersca at mac.com
Thu Aug 23 08:25:29 PDT 2007
Author: andersca
Date: Thu Aug 23 10:25:28 2007
New Revision: 41320
URL: http://llvm.org/viewvc/llvm-project?rev=41320&view=rev
Log:
Parse ObjC @protocol expressions.
Modified:
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=41320&r1=41319&r2=41320&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Thu Aug 23 10:25:28 2007
@@ -634,9 +634,15 @@
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 @@
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;
+}
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=41320&r1=41319&r2=41320&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Thu Aug 23 10:25:28 2007
@@ -206,7 +206,7 @@
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>"; };
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=41320&r1=41319&r2=41320&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Aug 23 10:25:28 2007
@@ -336,6 +336,7 @@
ExprResult ParseObjCExpression();
ExprResult ParseObjCStringLiteral();
ExprResult ParseObjCEncodeExpression();
+ ExprResult ParseObjCProtocolExpression();
//===--------------------------------------------------------------------===//
// C99 6.8: Statements and Blocks.
More information about the cfe-commits
mailing list