blob: 00b606ac1a5da2e1abd69e0d9df27154d88c2107 [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"
15#include "clang/Basic/Diagnostic.h"
16#include "llvm/ADT/SmallVector.h"
17using namespace clang;
18
19
20/// ParseExternalDeclaration:
21/// external-declaration: [C99 6.9]
22/// [OBJC] objc-class-definition
23/// [OBJC] objc-class-declaration [TODO]
24/// [OBJC] objc-alias-declaration [TODO]
25/// [OBJC] objc-protocol-definition [TODO]
26/// [OBJC] objc-method-definition [TODO]
27/// [OBJC] '@' 'end' [TODO]
28void Parser::ParseObjCAtDirectives() {
29 SourceLocation AtLoc = ConsumeToken(); // the "@"
30
31 IdentifierInfo *II = Tok.getIdentifierInfo();
32 switch (II ? II->getObjCKeywordID() : tok::objc_not_keyword) {
33 case tok::objc_class:
34 return ParseObjCAtClassDeclaration(AtLoc);
35 case tok::objc_interface:
36 return ParseObjCAtInterfaceDeclaration();
37 case tok::objc_protocol:
38 return ParseObjCAtProtocolDeclaration();
39 case tok::objc_implementation:
40 return ParseObjCAtImplementationDeclaration();
41 case tok::objc_end:
42 return ParseObjCAtEndDeclaration();
43 case tok::objc_compatibility_alias:
44 return ParseObjCAtAliasDeclaration();
45 default:
46 Diag(AtLoc, diag::err_unexpected_at);
47 SkipUntil(tok::semi);
48 }
49}
50
51///
52/// objc-class-declaration:
53/// '@' 'class' identifier-list ';'
54///
55void Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
56 ConsumeToken(); // the identifier "class"
57 llvm::SmallVector<IdentifierInfo *, 8> ClassNames;
58
59 while (1) {
60 if (Tok.getKind() != tok::identifier) {
61 Diag(Tok, diag::err_expected_ident);
62 SkipUntil(tok::semi);
63 return;
64 }
65
66 ClassNames.push_back(Tok.getIdentifierInfo());
67 ConsumeToken();
68
69 if (Tok.getKind() != tok::comma)
70 break;
71
72 ConsumeToken();
73 }
74
75 // Consume the ';'.
76 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@class"))
77 return;
78
79 Actions.ParsedObjcClassDeclaration(CurScope,
80 &ClassNames[0], ClassNames.size());
81}
82
83void Parser::ParseObjCAtInterfaceDeclaration() {
84 assert(0 && "Unimp");
85}
86void Parser::ParseObjCAtProtocolDeclaration() {
87 assert(0 && "Unimp");
88}
89void Parser::ParseObjCAtImplementationDeclaration() {
90 assert(0 && "Unimp");
91}
92void Parser::ParseObjCAtEndDeclaration() {
93 assert(0 && "Unimp");
94}
95void Parser::ParseObjCAtAliasDeclaration() {
96 assert(0 && "Unimp");
97}
98
99void Parser::ParseObjCInstanceMethodDeclaration() {
100 assert(0 && "Unimp");
101}
102
103void Parser::ParseObjCClassMethodDeclaration() {
104 assert(0 && "Unimp");
105}