blob: 21f59e32b7f1a46fb094cc09fbc9926e0a4e451c [file] [log] [blame]
Chris Lattner4b009652007-07-25 00:24:17 +00001//===--- ParseObjc.cpp - Objective C Parsing ------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Steve Naroff and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Objective-C portions of the Parser interface.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Parse/Parser.h"
Steve Naroff09a0c4c2007-08-22 18:35:33 +000015#include "clang/Parse/DeclSpec.h"
Chris Lattner4b009652007-07-25 00:24:17 +000016#include "clang/Basic/Diagnostic.h"
17#include "llvm/ADT/SmallVector.h"
18using namespace clang;
19
20
21/// ParseExternalDeclaration:
22/// external-declaration: [C99 6.9]
23/// [OBJC] objc-class-definition
24/// [OBJC] objc-class-declaration [TODO]
25/// [OBJC] objc-alias-declaration [TODO]
26/// [OBJC] objc-protocol-definition [TODO]
27/// [OBJC] objc-method-definition [TODO]
28/// [OBJC] '@' 'end' [TODO]
Steve Narofffb367882007-08-20 21:31:48 +000029Parser::DeclTy *Parser::ParseObjCAtDirectives() {
Chris Lattner4b009652007-07-25 00:24:17 +000030 SourceLocation AtLoc = ConsumeToken(); // the "@"
31
Steve Naroff87c329f2007-08-23 18:16:40 +000032 switch (Tok.getObjCKeywordID()) {
Chris Lattner4b009652007-07-25 00:24:17 +000033 case tok::objc_class:
34 return ParseObjCAtClassDeclaration(AtLoc);
35 case tok::objc_interface:
Steve Narofffb367882007-08-20 21:31:48 +000036 return ParseObjCAtInterfaceDeclaration(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000037 case tok::objc_protocol:
Steve Naroff72f17fb2007-08-22 22:17:26 +000038 return ParseObjCAtProtocolDeclaration(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000039 case tok::objc_implementation:
Fariborz Jahanian027c23b2007-09-01 00:26:16 +000040 return ParseObjCAtImplementationDeclaration(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000041 case tok::objc_end:
Fariborz Jahanian027c23b2007-09-01 00:26:16 +000042 return ParseObjCAtEndDeclaration(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000043 case tok::objc_compatibility_alias:
Fariborz Jahanianb62aff32007-09-04 19:26:51 +000044 return ParseObjCAtAliasDeclaration(AtLoc);
Fariborz Jahanian027c23b2007-09-01 00:26:16 +000045 case tok::objc_synthesize:
46 return ParseObjCPropertySynthesize(AtLoc);
47 case tok::objc_dynamic:
48 return ParseObjCPropertyDynamic(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000049 default:
50 Diag(AtLoc, diag::err_unexpected_at);
51 SkipUntil(tok::semi);
Steve Narofffb367882007-08-20 21:31:48 +000052 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +000053 }
54}
55
56///
57/// objc-class-declaration:
58/// '@' 'class' identifier-list ';'
59///
Steve Narofffb367882007-08-20 21:31:48 +000060Parser::DeclTy *Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
Chris Lattner4b009652007-07-25 00:24:17 +000061 ConsumeToken(); // the identifier "class"
62 llvm::SmallVector<IdentifierInfo *, 8> ClassNames;
63
64 while (1) {
65 if (Tok.getKind() != tok::identifier) {
66 Diag(Tok, diag::err_expected_ident);
67 SkipUntil(tok::semi);
Steve Narofffb367882007-08-20 21:31:48 +000068 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +000069 }
Chris Lattner4b009652007-07-25 00:24:17 +000070 ClassNames.push_back(Tok.getIdentifierInfo());
71 ConsumeToken();
72
73 if (Tok.getKind() != tok::comma)
74 break;
75
76 ConsumeToken();
77 }
78
79 // Consume the ';'.
80 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@class"))
Steve Narofffb367882007-08-20 21:31:48 +000081 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +000082
Steve Narofffb367882007-08-20 21:31:48 +000083 return Actions.ParsedObjcClassDeclaration(CurScope,
84 &ClassNames[0], ClassNames.size());
Chris Lattner4b009652007-07-25 00:24:17 +000085}
86
Steve Narofffb367882007-08-20 21:31:48 +000087///
88/// objc-interface:
89/// objc-class-interface-attributes[opt] objc-class-interface
90/// objc-category-interface
91///
92/// objc-class-interface:
93/// '@' 'interface' identifier objc-superclass[opt]
94/// objc-protocol-refs[opt]
95/// objc-class-instance-variables[opt]
96/// objc-interface-decl-list
97/// @end
98///
99/// objc-category-interface:
100/// '@' 'interface' identifier '(' identifier[opt] ')'
101/// objc-protocol-refs[opt]
102/// objc-interface-decl-list
103/// @end
104///
105/// objc-superclass:
106/// ':' identifier
107///
108/// objc-class-interface-attributes:
109/// __attribute__((visibility("default")))
110/// __attribute__((visibility("hidden")))
111/// __attribute__((deprecated))
112/// __attribute__((unavailable))
113/// __attribute__((objc_exception)) - used by NSException on 64-bit
114///
115Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration(
116 SourceLocation atLoc, AttributeList *attrList) {
Steve Naroff87c329f2007-08-23 18:16:40 +0000117 assert(Tok.isObjCAtKeyword(tok::objc_interface) &&
Steve Narofffb367882007-08-20 21:31:48 +0000118 "ParseObjCAtInterfaceDeclaration(): Expected @interface");
119 ConsumeToken(); // the "interface" identifier
120
121 if (Tok.getKind() != tok::identifier) {
122 Diag(Tok, diag::err_expected_ident); // missing class or category name.
123 return 0;
124 }
125 // We have a class or category name - consume it.
Steve Naroff72f17fb2007-08-22 22:17:26 +0000126 IdentifierInfo *nameId = Tok.getIdentifierInfo();
Steve Narofffb367882007-08-20 21:31:48 +0000127 SourceLocation nameLoc = ConsumeToken();
128
Steve Naroffa7f62782007-08-23 19:56:30 +0000129 if (Tok.getKind() == tok::l_paren) { // we have a category.
Steve Narofffb367882007-08-20 21:31:48 +0000130 SourceLocation lparenLoc = ConsumeParen();
131 SourceLocation categoryLoc, rparenLoc;
132 IdentifierInfo *categoryId = 0;
133
Steve Naroffa7f62782007-08-23 19:56:30 +0000134 // For ObjC2, the category name is optional (not an error).
Steve Narofffb367882007-08-20 21:31:48 +0000135 if (Tok.getKind() == tok::identifier) {
136 categoryId = Tok.getIdentifierInfo();
137 categoryLoc = ConsumeToken();
Steve Naroffa7f62782007-08-23 19:56:30 +0000138 } else if (!getLang().ObjC2) {
139 Diag(Tok, diag::err_expected_ident); // missing category name.
140 return 0;
Steve Narofffb367882007-08-20 21:31:48 +0000141 }
142 if (Tok.getKind() != tok::r_paren) {
143 Diag(Tok, diag::err_expected_rparen);
144 SkipUntil(tok::r_paren, false); // don't stop at ';'
145 return 0;
146 }
147 rparenLoc = ConsumeParen();
148 // Next, we need to check for any protocol references.
149 if (Tok.getKind() == tok::less) {
150 if (ParseObjCProtocolReferences())
151 return 0;
152 }
153 if (attrList) // categories don't support attributes.
154 Diag(Tok, diag::err_objc_no_attributes_on_category);
155
Steve Naroff0bbffd82007-08-22 16:35:03 +0000156 ParseObjCInterfaceDeclList(0/*FIXME*/);
Steve Narofffb367882007-08-20 21:31:48 +0000157
Steve Naroff0bbffd82007-08-22 16:35:03 +0000158 // The @ sign was already consumed by ParseObjCInterfaceDeclList().
Steve Naroff87c329f2007-08-23 18:16:40 +0000159 if (Tok.isObjCAtKeyword(tok::objc_end)) {
Steve Naroff0bbffd82007-08-22 16:35:03 +0000160 ConsumeToken(); // the "end" identifier
Steve Narofffb367882007-08-20 21:31:48 +0000161 return 0;
162 }
Steve Naroff0bbffd82007-08-22 16:35:03 +0000163 Diag(Tok, diag::err_objc_missing_end);
Steve Narofffb367882007-08-20 21:31:48 +0000164 return 0;
165 }
166 // Parse a class interface.
167 IdentifierInfo *superClassId = 0;
168 SourceLocation superClassLoc;
Steve Naroff72f17fb2007-08-22 22:17:26 +0000169
170 // FIXME: temporary hack to grok class names (until we have sema support).
171 llvm::SmallVector<IdentifierInfo *, 1> ClassName;
172 ClassName.push_back(nameId);
173 Actions.ParsedObjcClassDeclaration(CurScope, &ClassName[0], 1);
Steve Narofffb367882007-08-20 21:31:48 +0000174
175 if (Tok.getKind() == tok::colon) { // a super class is specified.
176 ConsumeToken();
177 if (Tok.getKind() != tok::identifier) {
178 Diag(Tok, diag::err_expected_ident); // missing super class name.
179 return 0;
180 }
181 superClassId = Tok.getIdentifierInfo();
182 superClassLoc = ConsumeToken();
183 }
184 // Next, we need to check for any protocol references.
185 if (Tok.getKind() == tok::less) {
186 if (ParseObjCProtocolReferences())
187 return 0;
188 }
Steve Naroffc4474992007-08-21 21:17:12 +0000189 // FIXME: add Actions.StartObjCClassInterface(nameId, superClassId, ...)
Steve Narofffb367882007-08-20 21:31:48 +0000190 if (Tok.getKind() == tok::l_brace)
Steve Naroffc4474992007-08-21 21:17:12 +0000191 ParseObjCClassInstanceVariables(0/*FIXME*/);
Steve Narofffb367882007-08-20 21:31:48 +0000192
Steve Naroff0bbffd82007-08-22 16:35:03 +0000193 ParseObjCInterfaceDeclList(0/*FIXME*/);
194
195 // The @ sign was already consumed by ParseObjCInterfaceDeclList().
Steve Naroff87c329f2007-08-23 18:16:40 +0000196 if (Tok.isObjCAtKeyword(tok::objc_end)) {
Steve Naroff0bbffd82007-08-22 16:35:03 +0000197 ConsumeToken(); // the "end" identifier
Steve Narofffb367882007-08-20 21:31:48 +0000198 return 0;
199 }
Steve Naroff0bbffd82007-08-22 16:35:03 +0000200 Diag(Tok, diag::err_objc_missing_end);
Steve Narofffb367882007-08-20 21:31:48 +0000201 return 0;
202}
203
204/// objc-interface-decl-list:
205/// empty
Steve Narofffb367882007-08-20 21:31:48 +0000206/// objc-interface-decl-list objc-property-decl [OBJC2]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000207/// objc-interface-decl-list objc-method-requirement [OBJC2]
208/// objc-interface-decl-list objc-method-proto
Steve Narofffb367882007-08-20 21:31:48 +0000209/// objc-interface-decl-list declaration
210/// objc-interface-decl-list ';'
211///
Steve Naroff0bbffd82007-08-22 16:35:03 +0000212/// objc-method-requirement: [OBJC2]
213/// @required
214/// @optional
215///
216void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl) {
217 while (1) {
218 if (Tok.getKind() == tok::at) {
219 SourceLocation AtLoc = ConsumeToken(); // the "@"
Steve Naroff87c329f2007-08-23 18:16:40 +0000220 tok::ObjCKeywordKind ocKind = Tok.getObjCKeywordID();
Steve Naroff0bbffd82007-08-22 16:35:03 +0000221
222 if (ocKind == tok::objc_end) { // terminate list
223 return;
224 } else if (ocKind == tok::objc_required) { // protocols only
225 ConsumeToken();
226 continue;
227 } else if (ocKind == tok::objc_optional) { // protocols only
228 ConsumeToken();
229 continue;
230 } else if (ocKind == tok::objc_property) {
Fariborz Jahanian6668b8c2007-08-31 16:11:31 +0000231 ParseObjCPropertyDecl(0/*FIXME*/);
Steve Naroff0bbffd82007-08-22 16:35:03 +0000232 continue;
233 } else {
234 Diag(Tok, diag::err_objc_illegal_interface_qual);
235 ConsumeToken();
236 }
237 }
238 if (Tok.getKind() == tok::minus || Tok.getKind() == tok::plus) {
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000239 ParseObjCMethodPrototype(true);
Steve Naroff0bbffd82007-08-22 16:35:03 +0000240 continue;
241 }
242 if (Tok.getKind() == tok::semi)
243 ConsumeToken();
244 else if (Tok.getKind() == tok::eof)
245 return;
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000246 else
247 // FIXME: as the name implies, this rule allows function definitions.
248 // We could pass a flag or check for functions during semantic analysis.
Steve Naroff0bbffd82007-08-22 16:35:03 +0000249 ParseDeclarationOrFunctionDefinition();
250 }
251}
252
Fariborz Jahanian6668b8c2007-08-31 16:11:31 +0000253/// Parse property attribute declarations.
254///
255/// property-attr-decl: '(' property-attrlist ')'
256/// property-attrlist:
257/// property-attribute
258/// property-attrlist ',' property-attribute
259/// property-attribute:
260/// getter '=' identifier
261/// setter '=' identifier ':'
262/// readonly
263/// readwrite
264/// assign
265/// retain
266/// copy
267/// nonatomic
268///
269void Parser::ParseObjCPropertyAttribute (DeclTy *interfaceDecl) {
270 SourceLocation loc = ConsumeParen(); // consume '('
271 while (isObjCPropertyAttribute()) {
272 const IdentifierInfo *II = Tok.getIdentifierInfo();
273 // getter/setter require extra treatment.
274 if (II == ObjcPropertyAttrs[objc_getter] ||
275 II == ObjcPropertyAttrs[objc_setter]) {
276 // skip getter/setter part.
277 SourceLocation loc = ConsumeToken();
278 if (Tok.getKind() == tok::equal) {
279 loc = ConsumeToken();
280 if (Tok.getKind() == tok::identifier) {
281 if (II == ObjcPropertyAttrs[objc_setter]) {
282 loc = ConsumeToken(); // consume method name
283 if (Tok.getKind() != tok::colon) {
284 Diag(loc, diag::err_expected_colon);
285 SkipUntil(tok::r_paren,true,true);
286 break;
287 }
288 }
289 }
290 else {
291 Diag(loc, diag::err_expected_ident);
292 SkipUntil(tok::r_paren,true,true);
293 break;
294 }
295 }
296 else {
297 Diag(loc, diag::err_objc_expected_equal);
298 SkipUntil(tok::r_paren,true,true);
299 break;
300 }
301 }
302 ConsumeToken(); // consume last attribute token
303 if (Tok.getKind() == tok::comma) {
304 loc = ConsumeToken();
305 continue;
306 }
307 if (Tok.getKind() == tok::r_paren)
308 break;
309 Diag(loc, diag::err_expected_rparen);
310 SkipUntil(tok::semi);
311 return;
312 }
313 if (Tok.getKind() == tok::r_paren)
314 ConsumeParen();
315 else {
316 Diag(loc, diag::err_objc_expected_property_attr);
317 SkipUntil(tok::r_paren); // recover from error inside attribute list
318 }
319}
320
321/// Main routine to parse property declaration.
322///
323/// @property property-attr-decl[opt] property-component-decl ';'
324///
325void Parser::ParseObjCPropertyDecl(DeclTy *interfaceDecl) {
326 assert(Tok.isObjCAtKeyword(tok::objc_property) &&
327 "ParseObjCPropertyDecl(): Expected @property");
328 ConsumeToken(); // the "property" identifier
329 // Parse property attribute list, if any.
330 if (Tok.getKind() == tok::l_paren) {
331 // property has attribute list.
332 ParseObjCPropertyAttribute(0/*FIXME*/);
333 }
334 // Parse declaration portion of @property.
335 llvm::SmallVector<DeclTy*, 32> PropertyDecls;
336 ParseStructDeclaration(interfaceDecl, PropertyDecls);
337 if (Tok.getKind() == tok::semi)
338 ConsumeToken();
339 else {
340 Diag(Tok, diag::err_expected_semi_decl_list);
341 SkipUntil(tok::r_brace, true, true);
342 }
Chris Lattner4b009652007-07-25 00:24:17 +0000343}
Steve Narofffb367882007-08-20 21:31:48 +0000344
Steve Naroff0bbffd82007-08-22 16:35:03 +0000345/// objc-methodproto:
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000346/// objc-instance-method objc-method-decl objc-method-attributes[opt]
347/// ';'[opt]
348/// objc-class-method objc-method-decl objc-method-attributes[opt] ';'[opt]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000349///
350/// objc-instance-method: '-'
351/// objc-class-method: '+'
352///
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000353/// objc-method-attributes: [OBJC2]
354/// __attribute__((deprecated))
355///
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000356void Parser::ParseObjCMethodPrototype(bool decl) {
Steve Naroff0bbffd82007-08-22 16:35:03 +0000357 assert((Tok.getKind() == tok::minus || Tok.getKind() == tok::plus) &&
358 "expected +/-");
359
360 tok::TokenKind methodType = Tok.getKind();
361 SourceLocation methodLoc = ConsumeToken();
362
363 // FIXME: deal with "context sensitive" protocol qualifiers in prototypes
364 ParseObjCMethodDecl(methodType, methodLoc);
365
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000366 // If attributes exist after the method, parse them.
Steve Naroffa7f62782007-08-23 19:56:30 +0000367 if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000368 ParseAttributes();
369
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000370 if (decl)
371 // Consume the ';'.
372 ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "method proto");
Steve Naroff0bbffd82007-08-22 16:35:03 +0000373}
374
375/// objc-selector:
376/// identifier
377/// one of
378/// enum struct union if else while do for switch case default
379/// break continue return goto asm sizeof typeof __alignof
380/// unsigned long const short volatile signed restrict _Complex
381/// in out inout bycopy byref oneway int char float double void _Bool
382///
383IdentifierInfo *Parser::ParseObjCSelector() {
384 tok::TokenKind tKind = Tok.getKind();
385 IdentifierInfo *II = 0;
386
Fariborz Jahanian1e534dc2007-09-05 19:52:07 +0000387 if (tKind == tok::identifier || tKind == tok::kw_typeof ||
388 tKind == tok::kw___alignof ||
Steve Naroff0bbffd82007-08-22 16:35:03 +0000389 (tKind >= tok::kw_auto && tKind <= tok::kw__Complex)) {
Steve Naroff0bbffd82007-08-22 16:35:03 +0000390 II = Tok.getIdentifierInfo();
391 ConsumeToken();
392 }
393 return II;
394}
395
Steve Naroffa8ee2262007-08-22 23:18:22 +0000396/// objc-type-qualifier: one of
397/// in out inout bycopy byref oneway
398///
Steve Naroffa8ee2262007-08-22 23:18:22 +0000399bool Parser::isObjCTypeQualifier() {
400 if (Tok.getKind() == tok::identifier) {
Chris Lattner32352462007-08-29 22:54:08 +0000401 const IdentifierInfo *II = Tok.getIdentifierInfo();
402 for (unsigned i = 0; i < objc_NumQuals; ++i)
403 if (II == ObjcTypeQuals[i]) return true;
Steve Naroffa8ee2262007-08-22 23:18:22 +0000404 }
405 return false;
406}
407
Fariborz Jahanian6668b8c2007-08-31 16:11:31 +0000408/// property-attrlist: one of
409/// readonly getter setter assign retain copy nonatomic
410///
411bool Parser::isObjCPropertyAttribute() {
412 if (Tok.getKind() == tok::identifier) {
413 const IdentifierInfo *II = Tok.getIdentifierInfo();
414 for (unsigned i = 0; i < objc_NumAttrs; ++i)
415 if (II == ObjcPropertyAttrs[i]) return true;
416 }
417 return false;
418}
419
Steve Naroff0bbffd82007-08-22 16:35:03 +0000420/// objc-type-name:
421/// '(' objc-type-qualifiers[opt] type-name ')'
422/// '(' objc-type-qualifiers[opt] ')'
423///
424/// objc-type-qualifiers:
425/// objc-type-qualifier
426/// objc-type-qualifiers objc-type-qualifier
427///
Steve Naroff0bbffd82007-08-22 16:35:03 +0000428void Parser::ParseObjCTypeName() {
429 assert(Tok.getKind() == tok::l_paren && "expected (");
430
431 SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
432
Steve Naroffa8ee2262007-08-22 23:18:22 +0000433 while (isObjCTypeQualifier())
434 ConsumeToken();
435
Steve Naroff0bbffd82007-08-22 16:35:03 +0000436 if (isTypeSpecifierQualifier()) {
Steve Naroff72f17fb2007-08-22 22:17:26 +0000437 //TypeTy *Ty = ParseTypeName();
438 //assert(Ty && "Parser::ParseObjCTypeName(): missing type");
439 ParseTypeName(); // FIXME: when sema support is added.
Steve Naroff0bbffd82007-08-22 16:35:03 +0000440 }
441 if (Tok.getKind() != tok::r_paren) {
442 MatchRHSPunctuation(tok::r_paren, LParenLoc);
443 return;
444 }
445 RParenLoc = ConsumeParen();
446}
447
448/// objc-method-decl:
449/// objc-selector
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000450/// objc-keyword-selector objc-parmlist[opt]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000451/// objc-type-name objc-selector
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000452/// objc-type-name objc-keyword-selector objc-parmlist[opt]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000453///
454/// objc-keyword-selector:
Steve Naroff72f17fb2007-08-22 22:17:26 +0000455/// objc-keyword-decl
Steve Naroff0bbffd82007-08-22 16:35:03 +0000456/// objc-keyword-selector objc-keyword-decl
457///
458/// objc-keyword-decl:
Steve Naroff72f17fb2007-08-22 22:17:26 +0000459/// objc-selector ':' objc-type-name objc-keyword-attributes[opt] identifier
460/// objc-selector ':' objc-keyword-attributes[opt] identifier
461/// ':' objc-type-name objc-keyword-attributes[opt] identifier
462/// ':' objc-keyword-attributes[opt] identifier
Steve Naroff0bbffd82007-08-22 16:35:03 +0000463///
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000464/// objc-parmlist:
465/// objc-parms objc-ellipsis[opt]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000466///
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000467/// objc-parms:
468/// objc-parms , parameter-declaration
Steve Naroff0bbffd82007-08-22 16:35:03 +0000469///
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000470/// objc-ellipsis:
Steve Naroff0bbffd82007-08-22 16:35:03 +0000471/// , ...
472///
Steve Naroff72f17fb2007-08-22 22:17:26 +0000473/// objc-keyword-attributes: [OBJC2]
474/// __attribute__((unused))
475///
Steve Naroff0bbffd82007-08-22 16:35:03 +0000476void Parser::ParseObjCMethodDecl(tok::TokenKind mType, SourceLocation mLoc) {
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000477
478 // Parse the return type.
Steve Naroff0bbffd82007-08-22 16:35:03 +0000479 if (Tok.getKind() == tok::l_paren)
480 ParseObjCTypeName();
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000481 IdentifierInfo *selIdent = ParseObjCSelector();
482
483 if (Tok.getKind() == tok::colon) {
484 IdentifierInfo *keywordSelector = selIdent;
485 while (1) {
486 // Each iteration parses a single keyword argument.
487 if (Tok.getKind() != tok::colon) {
488 Diag(Tok, diag::err_expected_colon);
489 break;
490 }
491 ConsumeToken(); // Eat the ':'.
492 if (Tok.getKind() == tok::l_paren) // Parse the argument type.
493 ParseObjCTypeName();
Steve Naroff72f17fb2007-08-22 22:17:26 +0000494
495 // If attributes exist before the argument name, parse them.
Steve Naroffa7f62782007-08-23 19:56:30 +0000496 if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
Steve Naroff72f17fb2007-08-22 22:17:26 +0000497 ParseAttributes();
498
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000499 if (Tok.getKind() != tok::identifier) {
500 Diag(Tok, diag::err_expected_ident); // missing argument name.
501 break;
502 }
503 ConsumeToken(); // Eat the identifier.
504 // FIXME: add Actions.BuildObjCKeyword()
505
506 keywordSelector = ParseObjCSelector();
507 if (!keywordSelector && Tok.getKind() != tok::colon)
508 break;
509 // We have a selector or a colon, continue parsing.
510 }
511 // Parse the (optional) parameter list.
512 while (Tok.getKind() == tok::comma) {
513 ConsumeToken();
514 if (Tok.getKind() == tok::ellipsis) {
515 ConsumeToken();
516 break;
517 }
Fariborz Jahanian1e534dc2007-09-05 19:52:07 +0000518 // Parse the c-style argument declaration-specifier.
519 DeclSpec DS;
520 ParseDeclarationSpecifiers(DS);
521 // Parse the declarator.
522 Declarator ParmDecl(DS, Declarator::PrototypeContext);
523 ParseDeclarator(ParmDecl);
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000524 }
525 } else if (!selIdent) {
526 Diag(Tok, diag::err_expected_ident); // missing selector name.
527 }
528 // FIXME: add Actions.BuildMethodSignature().
Steve Naroff0bbffd82007-08-22 16:35:03 +0000529}
530
Steve Narofffb367882007-08-20 21:31:48 +0000531/// objc-protocol-refs:
532/// '<' identifier-list '>'
533///
534bool Parser::ParseObjCProtocolReferences() {
535 assert(Tok.getKind() == tok::less && "expected <");
536
537 ConsumeToken(); // the "<"
538 llvm::SmallVector<IdentifierInfo *, 8> ProtocolRefs;
539
540 while (1) {
541 if (Tok.getKind() != tok::identifier) {
542 Diag(Tok, diag::err_expected_ident);
543 SkipUntil(tok::greater);
544 return true;
545 }
546 ProtocolRefs.push_back(Tok.getIdentifierInfo());
547 ConsumeToken();
548
549 if (Tok.getKind() != tok::comma)
550 break;
551 ConsumeToken();
552 }
553 // Consume the '>'.
554 return ExpectAndConsume(tok::greater, diag::err_expected_greater);
555}
556
557/// objc-class-instance-variables:
558/// '{' objc-instance-variable-decl-list[opt] '}'
559///
560/// objc-instance-variable-decl-list:
561/// objc-visibility-spec
562/// objc-instance-variable-decl ';'
563/// ';'
564/// objc-instance-variable-decl-list objc-visibility-spec
565/// objc-instance-variable-decl-list objc-instance-variable-decl ';'
566/// objc-instance-variable-decl-list ';'
567///
568/// objc-visibility-spec:
569/// @private
570/// @protected
571/// @public
Steve Naroffc4474992007-08-21 21:17:12 +0000572/// @package [OBJC2]
Steve Narofffb367882007-08-20 21:31:48 +0000573///
574/// objc-instance-variable-decl:
575/// struct-declaration
576///
Steve Naroffc4474992007-08-21 21:17:12 +0000577void Parser::ParseObjCClassInstanceVariables(DeclTy *interfaceDecl) {
578 assert(Tok.getKind() == tok::l_brace && "expected {");
579
580 SourceLocation LBraceLoc = ConsumeBrace(); // the "{"
581 llvm::SmallVector<DeclTy*, 32> IvarDecls;
582
583 // While we still have something to read, read the instance variables.
584 while (Tok.getKind() != tok::r_brace &&
585 Tok.getKind() != tok::eof) {
586 // Each iteration of this loop reads one objc-instance-variable-decl.
587
588 // Check for extraneous top-level semicolon.
589 if (Tok.getKind() == tok::semi) {
590 Diag(Tok, diag::ext_extra_struct_semi);
591 ConsumeToken();
592 continue;
593 }
594 // Set the default visibility to private.
595 tok::ObjCKeywordKind visibility = tok::objc_private;
596 if (Tok.getKind() == tok::at) { // parse objc-visibility-spec
597 ConsumeToken(); // eat the @ sign
Steve Naroff87c329f2007-08-23 18:16:40 +0000598 switch (Tok.getObjCKeywordID()) {
Steve Naroffc4474992007-08-21 21:17:12 +0000599 case tok::objc_private:
600 case tok::objc_public:
601 case tok::objc_protected:
602 case tok::objc_package:
Steve Naroff87c329f2007-08-23 18:16:40 +0000603 visibility = Tok.getObjCKeywordID();
Steve Naroffc4474992007-08-21 21:17:12 +0000604 ConsumeToken();
605 continue;
606 default:
607 Diag(Tok, diag::err_objc_illegal_visibility_spec);
608 ConsumeToken();
609 continue;
610 }
611 }
612 ParseStructDeclaration(interfaceDecl, IvarDecls);
613
614 if (Tok.getKind() == tok::semi) {
615 ConsumeToken();
616 } else if (Tok.getKind() == tok::r_brace) {
617 Diag(Tok.getLocation(), diag::ext_expected_semi_decl_list);
618 break;
619 } else {
620 Diag(Tok, diag::err_expected_semi_decl_list);
621 // Skip to end of block or statement
622 SkipUntil(tok::r_brace, true, true);
623 }
624 }
625 MatchRHSPunctuation(tok::r_brace, LBraceLoc);
626 return;
Chris Lattner4b009652007-07-25 00:24:17 +0000627}
Steve Narofffb367882007-08-20 21:31:48 +0000628
629/// objc-protocol-declaration:
630/// objc-protocol-definition
631/// objc-protocol-forward-reference
632///
633/// objc-protocol-definition:
634/// @protocol identifier
635/// objc-protocol-refs[opt]
636/// objc-methodprotolist
637/// @end
638///
639/// objc-protocol-forward-reference:
640/// @protocol identifier-list ';'
641///
642/// "@protocol identifier ;" should be resolved as "@protocol
643/// identifier-list ;": objc-methodprotolist may not start with a
644/// semicolon in the first alternative if objc-protocol-refs are omitted.
645
Steve Naroff72f17fb2007-08-22 22:17:26 +0000646Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc) {
Steve Naroff87c329f2007-08-23 18:16:40 +0000647 assert(Tok.isObjCAtKeyword(tok::objc_protocol) &&
Steve Naroff72f17fb2007-08-22 22:17:26 +0000648 "ParseObjCAtProtocolDeclaration(): Expected @protocol");
649 ConsumeToken(); // the "protocol" identifier
650
651 if (Tok.getKind() != tok::identifier) {
652 Diag(Tok, diag::err_expected_ident); // missing protocol name.
653 return 0;
654 }
655 // Save the protocol name, then consume it.
656 IdentifierInfo *protocolName = Tok.getIdentifierInfo();
657 SourceLocation nameLoc = ConsumeToken();
658
659 if (Tok.getKind() == tok::semi) { // forward declaration.
660 ConsumeToken();
661 return 0; // FIXME: add protocolName
662 }
663 if (Tok.getKind() == tok::comma) { // list of forward declarations.
664 // Parse the list of forward declarations.
665 llvm::SmallVector<IdentifierInfo *, 8> ProtocolRefs;
666 ProtocolRefs.push_back(protocolName);
667
668 while (1) {
669 ConsumeToken(); // the ','
670 if (Tok.getKind() != tok::identifier) {
671 Diag(Tok, diag::err_expected_ident);
672 SkipUntil(tok::semi);
673 return 0;
674 }
675 ProtocolRefs.push_back(Tok.getIdentifierInfo());
676 ConsumeToken(); // the identifier
677
678 if (Tok.getKind() != tok::comma)
679 break;
680 }
681 // Consume the ';'.
682 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@protocol"))
683 return 0;
684 return 0; // FIXME
685 }
686 // Last, and definitely not least, parse a protocol declaration.
687 if (Tok.getKind() == tok::less) {
688 if (ParseObjCProtocolReferences())
689 return 0;
690 }
691 ParseObjCInterfaceDeclList(0/*FIXME*/);
692
693 // The @ sign was already consumed by ParseObjCInterfaceDeclList().
Steve Naroff87c329f2007-08-23 18:16:40 +0000694 if (Tok.isObjCAtKeyword(tok::objc_end)) {
Steve Naroff72f17fb2007-08-22 22:17:26 +0000695 ConsumeToken(); // the "end" identifier
696 return 0;
697 }
698 Diag(Tok, diag::err_objc_missing_end);
Steve Narofffb367882007-08-20 21:31:48 +0000699 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +0000700}
Steve Narofffb367882007-08-20 21:31:48 +0000701
702/// objc-implementation:
703/// objc-class-implementation-prologue
704/// objc-category-implementation-prologue
705///
706/// objc-class-implementation-prologue:
707/// @implementation identifier objc-superclass[opt]
708/// objc-class-instance-variables[opt]
709///
710/// objc-category-implementation-prologue:
711/// @implementation identifier ( identifier )
712
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000713Parser::DeclTy *Parser::ParseObjCAtImplementationDeclaration(
714 SourceLocation atLoc) {
715 assert(Tok.isObjCAtKeyword(tok::objc_implementation) &&
716 "ParseObjCAtImplementationDeclaration(): Expected @implementation");
717 ConsumeToken(); // the "implementation" identifier
718
719 if (Tok.getKind() != tok::identifier) {
720 Diag(Tok, diag::err_expected_ident); // missing class or category name.
721 return 0;
722 }
723 // We have a class or category name - consume it.
724 SourceLocation nameLoc = ConsumeToken(); // consume class or category name
725
726 if (Tok.getKind() == tok::l_paren) {
727 // we have a category implementation.
728 SourceLocation lparenLoc = ConsumeParen();
729 SourceLocation categoryLoc, rparenLoc;
730 IdentifierInfo *categoryId = 0;
731
732 if (Tok.getKind() == tok::identifier) {
733 categoryId = Tok.getIdentifierInfo();
734 categoryLoc = ConsumeToken();
735 } else {
736 Diag(Tok, diag::err_expected_ident); // missing category name.
737 return 0;
738 }
739 if (Tok.getKind() != tok::r_paren) {
740 Diag(Tok, diag::err_expected_rparen);
741 SkipUntil(tok::r_paren, false); // don't stop at ';'
742 return 0;
743 }
744 rparenLoc = ConsumeParen();
745 return 0;
746 }
747 // We have a class implementation
748 if (Tok.getKind() == tok::colon) {
749 // We have a super class
750 ConsumeToken();
751 if (Tok.getKind() != tok::identifier) {
752 Diag(Tok, diag::err_expected_ident); // missing super class name.
753 return 0;
754 }
755 ConsumeToken(); // Consume super class name
756 }
757 if (Tok.getKind() == tok::l_brace)
758 ParseObjCClassInstanceVariables(0/*FIXME*/); // we have ivars
759
Steve Narofffb367882007-08-20 21:31:48 +0000760 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +0000761}
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000762Parser::DeclTy *Parser::ParseObjCAtEndDeclaration(SourceLocation atLoc) {
763 assert(Tok.isObjCAtKeyword(tok::objc_end) &&
764 "ParseObjCAtEndDeclaration(): Expected @end");
765 ConsumeToken(); // the "end" identifier
766
Steve Narofffb367882007-08-20 21:31:48 +0000767 return 0;
768}
Fariborz Jahanianb62aff32007-09-04 19:26:51 +0000769
770/// compatibility-alias-decl:
771/// @compatibility_alias alias-name class-name ';'
772///
773Parser::DeclTy *Parser::ParseObjCAtAliasDeclaration(SourceLocation atLoc) {
774 assert(Tok.isObjCAtKeyword(tok::objc_compatibility_alias) &&
775 "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
776 ConsumeToken(); // consume compatibility_alias
777 if (Tok.getKind() != tok::identifier) {
778 Diag(Tok, diag::err_expected_ident);
779 return 0;
780 }
781 ConsumeToken(); // consume alias-name
782 if (Tok.getKind() != tok::identifier) {
783 Diag(Tok, diag::err_expected_ident);
784 return 0;
785 }
786 ConsumeToken(); // consume class-name;
787 if (Tok.getKind() != tok::semi)
Fariborz Jahanian6c30fa62007-09-04 21:42:12 +0000788 Diag(Tok, diag::err_expected_semi_after, "@compatibility_alias");
Steve Narofffb367882007-08-20 21:31:48 +0000789 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +0000790}
791
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000792/// property-synthesis:
793/// @synthesize property-ivar-list ';'
794///
795/// property-ivar-list:
796/// property-ivar
797/// property-ivar-list ',' property-ivar
798///
799/// property-ivar:
800/// identifier
801/// identifier '=' identifier
802///
803Parser::DeclTy *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
804 assert(Tok.isObjCAtKeyword(tok::objc_synthesize) &&
805 "ParseObjCPropertyDynamic(): Expected '@synthesize'");
806 SourceLocation loc = ConsumeToken(); // consume dynamic
807 if (Tok.getKind() != tok::identifier) {
808 Diag(Tok, diag::err_expected_ident);
809 return 0;
810 }
811 while (Tok.getKind() == tok::identifier) {
812 ConsumeToken(); // consume property name
813 if (Tok.getKind() == tok::equal) {
814 // property '=' ivar-name
815 ConsumeToken(); // consume '='
816 if (Tok.getKind() != tok::identifier) {
817 Diag(Tok, diag::err_expected_ident);
818 break;
819 }
820 ConsumeToken(); // consume ivar-name
821 }
822 if (Tok.getKind() != tok::comma)
823 break;
824 ConsumeToken(); // consume ','
825 }
826 if (Tok.getKind() != tok::semi)
827 Diag(Tok, diag::err_expected_semi_after, "@synthesize");
828 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +0000829}
830
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000831/// property-dynamic:
832/// @dynamic property-list
833///
834/// property-list:
835/// identifier
836/// property-list ',' identifier
837///
838Parser::DeclTy *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
839 assert(Tok.isObjCAtKeyword(tok::objc_dynamic) &&
840 "ParseObjCPropertyDynamic(): Expected '@dynamic'");
841 SourceLocation loc = ConsumeToken(); // consume dynamic
842 if (Tok.getKind() != tok::identifier) {
843 Diag(Tok, diag::err_expected_ident);
844 return 0;
845 }
846 while (Tok.getKind() == tok::identifier) {
847 ConsumeToken(); // consume property name
848 if (Tok.getKind() != tok::comma)
849 break;
850 ConsumeToken(); // consume ','
851 }
852 if (Tok.getKind() != tok::semi)
853 Diag(Tok, diag::err_expected_semi_after, "@dynamic");
854 return 0;
855}
856
857/// objc-method-def: objc-methodproto ';'[opt] '{' body '}'
858///
859void Parser::ParseObjCInstanceMethodDefinition() {
860 assert(Tok.getKind() == tok::minus &&
861 "ParseObjCInstanceMethodDefinition(): Expected '-'");
862 ParseObjCMethodPrototype(false);
863 // parse optional ';'
864 if (Tok.getKind() == tok::semi)
865 ConsumeToken();
866
867 if (Tok.getKind() != tok::l_brace) {
868 Diag (Tok, diag::err_expected_lbrace);
869 return;
870 }
871
872 StmtResult FnBody = ParseCompoundStatementBody();
873}
874
875/// objc-method-def: objc-methodproto ';'[opt] '{' body '}'
876///
Steve Naroff72f17fb2007-08-22 22:17:26 +0000877void Parser::ParseObjCClassMethodDefinition() {
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000878 assert(Tok.getKind() == tok::plus &&
879 "ParseObjCClassMethodDefinition(): Expected '+'");
880 ParseObjCMethodPrototype(false);
881 // parse optional ';'
882 if (Tok.getKind() == tok::semi)
883 ConsumeToken();
884 if (Tok.getKind() != tok::l_brace) {
885 Diag (Tok, diag::err_expected_lbrace);
886 return;
887 }
888
889 StmtResult FnBody = ParseCompoundStatementBody();
Chris Lattner4b009652007-07-25 00:24:17 +0000890}
Anders Carlssona66cad42007-08-21 17:43:55 +0000891
892Parser::ExprResult Parser::ParseObjCExpression() {
893 SourceLocation AtLoc = ConsumeToken(); // the "@"
894
895 switch (Tok.getKind()) {
896 case tok::string_literal: // primary-expression: string-literal
897 case tok::wide_string_literal:
898 return ParseObjCStringLiteral();
Anders Carlsson2996b4e2007-08-23 15:25:28 +0000899 default:
900 break;
901 }
902
903 switch (Tok.getIdentifierInfo()->getObjCKeywordID()) {
Anders Carlsson8be1d402007-08-22 15:14:15 +0000904 case tok::objc_encode:
905 return ParseObjCEncodeExpression();
Anders Carlsson2996b4e2007-08-23 15:25:28 +0000906 case tok::objc_protocol:
907 return ParseObjCProtocolExpression();
Anders Carlssona66cad42007-08-21 17:43:55 +0000908 default:
909 Diag(AtLoc, diag::err_unexpected_at);
910 SkipUntil(tok::semi);
911 break;
912 }
913
914 return 0;
915}
916
Fariborz Jahanian1e534dc2007-09-05 19:52:07 +0000917/// objc-message-expr:
918/// '[' objc-receiver objc-message-args ']'
919///
920/// objc-receiver:
921/// expression
922/// class-name
923/// type-name
924///
925/// objc-message-args:
926/// objc-selector
927/// objc-keywordarg-list
928///
929/// objc-keywordarg-list:
930/// objc-keywordarg
931/// objc-keywordarg-list objc-keywordarg
932///
933/// objc-keywordarg:
934/// selector-name[opt] ':' objc-keywordexpr
935///
936/// objc-keywordexpr:
937/// nonempty-expr-list
938///
939/// nonempty-expr-list:
940/// assignment-expression
941/// nonempty-expr-list , assignment-expression
942///
943Parser::ExprResult Parser::ParseObjCMessageExpression() {
Fariborz Jahaniand4462f92007-09-05 23:08:20 +0000944 assert(Tok.getKind() == tok::l_square && "'[' expected");
945 SourceLocation Loc = ConsumeBracket(); // consume '['
946 // Parse receiver
947 // FIXME: receiver as type-name/class-name
948 ParseAssignmentExpression();
949 // Parse objc-selector
950 IdentifierInfo *selIdent = ParseObjCSelector();
951 if (Tok.getKind() == tok::colon) {
952 while (1) {
953 // Each iteration parses a single keyword argument.
954 if (Tok.getKind() != tok::colon) {
955 Diag(Tok, diag::err_expected_colon);
956 SkipUntil(tok::semi);
957 return 0;
958 }
959 ConsumeToken(); // Eat the ':'.
960 /// Parse the expression after ':'
961 ParseAssignmentExpression();
962 IdentifierInfo *keywordSelector = ParseObjCSelector();
963
964 if (!keywordSelector && Tok.getKind() != tok::colon)
965 break;
966 // We have a selector or a colon, continue parsing.
967 }
968 // Parse the, optional, argument list, comma separated.
969 while (Tok.getKind() == tok::comma) {
970 ConsumeToken();
971 /// Parse the expression after ','
972 ParseAssignmentExpression();
973 }
974 } else if (!selIdent) {
975 Diag(Tok, diag::err_expected_ident); // missing selector name.
976 SkipUntil(tok::semi);
977 return 0;
978 }
979 if (Tok.getKind() != tok::r_square) {
980 Diag(Tok, diag::err_expected_rsquare);
981 SkipUntil(tok::semi);
982 return 0;
983 }
984 ConsumeBracket(); // consume ']'
Fariborz Jahanian1e534dc2007-09-05 19:52:07 +0000985 return 0;
986}
987
Anders Carlssona66cad42007-08-21 17:43:55 +0000988Parser::ExprResult Parser::ParseObjCStringLiteral() {
989 ExprResult Res = ParseStringLiteralExpression();
990
991 if (Res.isInvalid) return Res;
992
993 return Actions.ParseObjCStringLiteral(Res.Val);
994}
Anders Carlsson8be1d402007-08-22 15:14:15 +0000995
996/// objc-encode-expression:
997/// @encode ( type-name )
998Parser::ExprResult Parser::ParseObjCEncodeExpression() {
Steve Naroff87c329f2007-08-23 18:16:40 +0000999 assert(Tok.isObjCAtKeyword(tok::objc_encode) && "Not an @encode expression!");
Anders Carlsson8be1d402007-08-22 15:14:15 +00001000
1001 SourceLocation EncLoc = ConsumeToken();
1002
1003 if (Tok.getKind() != tok::l_paren) {
1004 Diag(Tok, diag::err_expected_lparen_after, "@encode");
1005 return true;
1006 }
1007
1008 SourceLocation LParenLoc = ConsumeParen();
1009
1010 TypeTy *Ty = ParseTypeName();
1011
Anders Carlsson92faeb82007-08-23 15:31:37 +00001012 SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
Anders Carlsson8be1d402007-08-22 15:14:15 +00001013
1014 return Actions.ParseObjCEncodeExpression(EncLoc, LParenLoc, Ty,
Anders Carlsson92faeb82007-08-23 15:31:37 +00001015 RParenLoc);
Anders Carlsson8be1d402007-08-22 15:14:15 +00001016}
Anders Carlsson2996b4e2007-08-23 15:25:28 +00001017
1018/// objc-protocol-expression
1019/// @protocol ( protocol-name )
1020
1021Parser::ExprResult Parser::ParseObjCProtocolExpression()
1022{
1023 SourceLocation ProtoLoc = ConsumeToken();
1024
1025 if (Tok.getKind() != tok::l_paren) {
1026 Diag(Tok, diag::err_expected_lparen_after, "@protocol");
1027 return true;
1028 }
1029
1030 SourceLocation LParenLoc = ConsumeParen();
1031
1032 if (Tok.getKind() != tok::identifier) {
1033 Diag(Tok, diag::err_expected_ident);
1034 return true;
1035 }
1036
1037 // FIXME: Do something with the protocol name
1038 ConsumeToken();
1039
Anders Carlsson92faeb82007-08-23 15:31:37 +00001040 SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
Anders Carlsson2996b4e2007-08-23 15:25:28 +00001041
1042 // FIXME
1043 return 0;
1044}