2006-11-05 10:08:13 +08:00
|
|
|
//===--- ParseObjc.cpp - Objective C Parsing ------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by Steve Naroff and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the Objective-C portions of the Parser interface.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Parse/Parser.h"
|
|
|
|
#include "clang/Basic/Diagnostic.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
|
|
|
|
/// ParseExternalDeclaration:
|
|
|
|
/// external-declaration: [C99 6.9]
|
|
|
|
/// [OBJC] objc-class-definition
|
|
|
|
/// [OBJC] objc-class-declaration [TODO]
|
|
|
|
/// [OBJC] objc-alias-declaration [TODO]
|
|
|
|
/// [OBJC] objc-protocol-definition [TODO]
|
|
|
|
/// [OBJC] objc-method-definition [TODO]
|
|
|
|
/// [OBJC] '@' 'end' [TODO]
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCAtDirectives() {
|
2006-11-05 10:08:13 +08:00
|
|
|
SourceLocation AtLoc = ConsumeToken(); // the "@"
|
|
|
|
|
|
|
|
IdentifierInfo *II = Tok.getIdentifierInfo();
|
|
|
|
switch (II ? II->getObjCKeywordID() : tok::objc_not_keyword) {
|
|
|
|
case tok::objc_class:
|
2006-11-08 14:10:32 +08:00
|
|
|
return ParseObjCAtClassDeclaration(AtLoc);
|
2006-11-05 10:08:13 +08:00
|
|
|
case tok::objc_interface:
|
2006-11-08 14:10:32 +08:00
|
|
|
return ParseObjCAtInterfaceDeclaration();
|
2006-11-05 10:08:13 +08:00
|
|
|
case tok::objc_protocol:
|
2006-11-08 14:10:32 +08:00
|
|
|
return ParseObjCAtProtocolDeclaration();
|
2006-11-05 10:08:13 +08:00
|
|
|
case tok::objc_implementation:
|
2006-11-08 14:10:32 +08:00
|
|
|
return ParseObjCAtImplementationDeclaration();
|
2006-11-05 10:08:13 +08:00
|
|
|
case tok::objc_end:
|
2006-11-08 14:10:32 +08:00
|
|
|
return ParseObjCAtEndDeclaration();
|
2006-11-05 10:08:13 +08:00
|
|
|
case tok::objc_compatibility_alias:
|
2006-11-08 14:10:32 +08:00
|
|
|
return ParseObjCAtAliasDeclaration();
|
2006-11-05 10:08:13 +08:00
|
|
|
default:
|
|
|
|
Diag(AtLoc, diag::err_unexpected_at);
|
|
|
|
SkipUntil(tok::semi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
/// objc-class-declaration:
|
|
|
|
/// '@' 'class' identifier-list ';'
|
|
|
|
///
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
|
2006-11-05 10:08:13 +08:00
|
|
|
ConsumeToken(); // the identifier "class"
|
|
|
|
SmallVector<IdentifierInfo *, 8> ClassNames;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (Tok.getKind() != tok::identifier) {
|
|
|
|
Diag(diag::err_expected_ident);
|
|
|
|
SkipUntil(tok::semi);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClassNames.push_back(Tok.getIdentifierInfo());
|
|
|
|
ConsumeToken();
|
|
|
|
|
|
|
|
if (Tok.getKind() != tok::comma)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ConsumeToken();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Consume the ';'.
|
|
|
|
if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@class"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Actions.ParsedClassDeclaration(CurScope, &ClassNames[0], ClassNames.size());
|
|
|
|
}
|
|
|
|
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCAtInterfaceDeclaration() {
|
2006-11-05 10:08:13 +08:00
|
|
|
assert(0 && "Unimp");
|
|
|
|
}
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCAtProtocolDeclaration() {
|
2006-11-05 10:08:13 +08:00
|
|
|
assert(0 && "Unimp");
|
|
|
|
}
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCAtImplementationDeclaration() {
|
2006-11-05 10:08:13 +08:00
|
|
|
assert(0 && "Unimp");
|
|
|
|
}
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCAtEndDeclaration() {
|
2006-11-05 10:08:13 +08:00
|
|
|
assert(0 && "Unimp");
|
|
|
|
}
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCAtAliasDeclaration() {
|
2006-11-05 10:08:13 +08:00
|
|
|
assert(0 && "Unimp");
|
|
|
|
}
|
|
|
|
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCInstanceMethodDeclaration() {
|
2006-11-05 10:08:13 +08:00
|
|
|
assert(0 && "Unimp");
|
|
|
|
}
|
|
|
|
|
2006-11-08 14:10:32 +08:00
|
|
|
void Parser::ParseObjCClassMethodDeclaration() {
|
2006-11-05 10:08:13 +08:00
|
|
|
assert(0 && "Unimp");
|
|
|
|
}
|