diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2007-09-05 23:08:20 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2007-09-05 23:08:20 +0000 |
commit | bd25f7d4a59bae27504dda2b55d761472d23a2c7 (patch) | |
tree | 36da2af69c44b26531d42365540b01cbbe0e6ebf /clang/Parse/ParseObjc.cpp | |
parent | 26038c39181aedbf4114b7dd284f78afe4e83630 (diff) | |
download | bcm5719-llvm-bd25f7d4a59bae27504dda2b55d761472d23a2c7.tar.gz bcm5719-llvm-bd25f7d4a59bae27504dda2b55d761472d23a2c7.zip |
Patch for parsing objective-c style method calls.
llvm-svn: 41731
Diffstat (limited to 'clang/Parse/ParseObjc.cpp')
-rw-r--r-- | clang/Parse/ParseObjc.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/clang/Parse/ParseObjc.cpp b/clang/Parse/ParseObjc.cpp index cb65c1c27ae..21f59e32b7f 100644 --- a/clang/Parse/ParseObjc.cpp +++ b/clang/Parse/ParseObjc.cpp @@ -941,7 +941,47 @@ Parser::ExprResult Parser::ParseObjCExpression() { /// 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; } |