[cfe-commits] r41731 - in /cfe/trunk: Parse/ParseObjc.cpp test/Parser/objc-messaging-1.m
Fariborz Jahanian
fjahanian at apple.com
Wed Sep 5 16:08:21 PDT 2007
Author: fjahanian
Date: Wed Sep 5 18:08:20 2007
New Revision: 41731
URL: http://llvm.org/viewvc/llvm-project?rev=41731&view=rev
Log:
Patch for parsing objective-c style method calls.
Added:
cfe/trunk/test/Parser/objc-messaging-1.m
Modified:
cfe/trunk/Parse/ParseObjc.cpp
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=41731&r1=41730&r2=41731&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Wed Sep 5 18:08:20 2007
@@ -941,7 +941,47 @@
/// nonempty-expr-list , assignment-expression
///
Parser::ExprResult Parser::ParseObjCMessageExpression() {
- assert(false && "Unimp");
+ assert(Tok.getKind() == tok::l_square && "'[' expected");
+ SourceLocation Loc = ConsumeBracket(); // consume '['
+ // Parse receiver
+ // FIXME: receiver as type-name/class-name
+ ParseAssignmentExpression();
+ // Parse objc-selector
+ IdentifierInfo *selIdent = ParseObjCSelector();
+ if (Tok.getKind() == tok::colon) {
+ while (1) {
+ // Each iteration parses a single keyword argument.
+ if (Tok.getKind() != tok::colon) {
+ Diag(Tok, diag::err_expected_colon);
+ SkipUntil(tok::semi);
+ return 0;
+ }
+ ConsumeToken(); // Eat the ':'.
+ /// Parse the expression after ':'
+ ParseAssignmentExpression();
+ IdentifierInfo *keywordSelector = ParseObjCSelector();
+
+ if (!keywordSelector && Tok.getKind() != tok::colon)
+ break;
+ // We have a selector or a colon, continue parsing.
+ }
+ // Parse the, optional, argument list, comma separated.
+ while (Tok.getKind() == tok::comma) {
+ ConsumeToken();
+ /// Parse the expression after ','
+ ParseAssignmentExpression();
+ }
+ } else if (!selIdent) {
+ Diag(Tok, diag::err_expected_ident); // missing selector name.
+ SkipUntil(tok::semi);
+ return 0;
+ }
+ if (Tok.getKind() != tok::r_square) {
+ Diag(Tok, diag::err_expected_rsquare);
+ SkipUntil(tok::semi);
+ return 0;
+ }
+ ConsumeBracket(); // consume ']'
return 0;
}
Added: cfe/trunk/test/Parser/objc-messaging-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-messaging-1.m?rev=41731&view=auto
==============================================================================
--- cfe/trunk/test/Parser/objc-messaging-1.m (added)
+++ cfe/trunk/test/Parser/objc-messaging-1.m Wed Sep 5 18:08:20 2007
@@ -0,0 +1,14 @@
+// RUN: clang %s -parse-noop
+int main ()
+{
+ int i,j;
+ struct S *p;
+ [p ii];
+ [p if: 1 :2];
+ [p inout: 1 :2 another:(2,3,4)];
+ [p inout: 1 :2 another:(2,3,4), 6,6,8];
+ [p inout: 1 :2 another:(2,3,4), (6,4,5),6,8];
+ [p inout: 1 :2 another:(i+10), (i,j-1,5),6,8];
+ [p long: 1 :2 another:(i+10), (i,j-1,5),6,8];
+ [p : "Hello\n" :2 another:(i+10), (i,j-1,5),6,8];
+}
More information about the cfe-commits
mailing list