[cfe-commits] r41251 - in /cfe/trunk: Parse/ParseObjc.cpp include/clang/Basic/DiagnosticKinds.def include/clang/Basic/TokenKinds.def include/clang/Parse/Parser.h
Steve Naroff
snaroff at apple.com
Tue Aug 21 14:17:12 PDT 2007
Author: snaroff
Date: Tue Aug 21 16:17:12 2007
New Revision: 41251
URL: http://llvm.org/viewvc/llvm-project?rev=41251&view=rev
Log:
Implement parsing for objc instance variables.
Next step, method...
Modified:
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=41251&r1=41250&r2=41251&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Tue Aug 21 16:17:12 2007
@@ -179,8 +179,9 @@
if (ParseObjCProtocolReferences())
return 0;
}
+ // FIXME: add Actions.StartObjCClassInterface(nameId, superClassId, ...)
if (Tok.getKind() == tok::l_brace)
- ParseObjCClassInstanceVariables();
+ ParseObjCClassInstanceVariables(0/*FIXME*/);
//ParseObjCInterfaceDeclList();
@@ -249,12 +250,62 @@
/// @private
/// @protected
/// @public
+/// @package [OBJC2]
///
/// objc-instance-variable-decl:
/// struct-declaration
///
-void Parser::ParseObjCClassInstanceVariables() {
- assert(0 && "Unimp");
+void Parser::ParseObjCClassInstanceVariables(DeclTy *interfaceDecl) {
+ assert(Tok.getKind() == tok::l_brace && "expected {");
+
+ SourceLocation LBraceLoc = ConsumeBrace(); // the "{"
+ llvm::SmallVector<DeclTy*, 32> IvarDecls;
+
+ // While we still have something to read, read the instance variables.
+ while (Tok.getKind() != tok::r_brace &&
+ Tok.getKind() != tok::eof) {
+ // Each iteration of this loop reads one objc-instance-variable-decl.
+
+ // Check for extraneous top-level semicolon.
+ if (Tok.getKind() == tok::semi) {
+ Diag(Tok, diag::ext_extra_struct_semi);
+ ConsumeToken();
+ continue;
+ }
+ // Set the default visibility to private.
+ tok::ObjCKeywordKind visibility = tok::objc_private;
+ if (Tok.getKind() == tok::at) { // parse objc-visibility-spec
+ ConsumeToken(); // eat the @ sign
+ IdentifierInfo *specId = Tok.getIdentifierInfo();
+ switch (specId->getObjCKeywordID()) {
+ case tok::objc_private:
+ case tok::objc_public:
+ case tok::objc_protected:
+ case tok::objc_package:
+ visibility = specId->getObjCKeywordID();
+ ConsumeToken();
+ continue;
+ default:
+ Diag(Tok, diag::err_objc_illegal_visibility_spec);
+ ConsumeToken();
+ continue;
+ }
+ }
+ ParseStructDeclaration(interfaceDecl, IvarDecls);
+
+ if (Tok.getKind() == tok::semi) {
+ ConsumeToken();
+ } else if (Tok.getKind() == tok::r_brace) {
+ Diag(Tok.getLocation(), diag::ext_expected_semi_decl_list);
+ break;
+ } else {
+ Diag(Tok, diag::err_expected_semi_decl_list);
+ // Skip to end of block or statement
+ SkipUntil(tok::r_brace, true, true);
+ }
+ }
+ MatchRHSPunctuation(tok::r_brace, LBraceLoc);
+ return;
}
/// objc-protocol-declaration:
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=41251&r1=41250&r2=41251&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Tue Aug 21 16:17:12 2007
@@ -382,6 +382,8 @@
"attributes may not be specified on a category")
DIAG(err_objc_missing_end, ERROR,
"missing @end")
+DIAG(err_objc_illegal_visibility_spec, ERROR,
+ "illegal visibility specification")
//===----------------------------------------------------------------------===//
// Semantic Analysis
Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=41251&r1=41250&r2=41251&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Aug 21 16:17:12 2007
@@ -349,6 +349,7 @@
// I'm guessing this is an objc2 keyword, what are the others?
OBJC2_AT_KEYWORD(property)
+OBJC2_AT_KEYWORD(package)
// TODO: What to do about context-sensitive keywords like:
// bycopy/byref/in/inout/oneway/out?
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=41251&r1=41250&r2=41251&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Aug 21 16:17:12 2007
@@ -258,7 +258,7 @@
DeclTy *ParseObjCAtClassDeclaration(SourceLocation atLoc);
DeclTy *ParseObjCAtInterfaceDeclaration(SourceLocation atLoc,
AttributeList *prefixAttrs = 0);
- void ParseObjCClassInstanceVariables();
+ void ParseObjCClassInstanceVariables(DeclTy *interfaceDecl);
bool ParseObjCProtocolReferences();
void ParseObjCInterfaceDeclList();
DeclTy *ParseObjCAtProtocolDeclaration();
More information about the cfe-commits
mailing list