forked from qt-creator/qt-creator
Parse ObjC @class declarations.
This commit is contained in:
@@ -3864,4 +3864,71 @@ unsigned WhileStatementAST::lastToken() const
|
||||
return while_token + 1;
|
||||
}
|
||||
|
||||
// ObjC++
|
||||
unsigned IdentifierListAST::firstToken() const
|
||||
{
|
||||
return identifier_token;
|
||||
}
|
||||
|
||||
unsigned IdentifierListAST::lastToken() const
|
||||
{
|
||||
for (const IdentifierListAST *it = this; it; it = it->next) {
|
||||
if (! it->next && it->identifier_token) {
|
||||
return it->identifier_token + 1;
|
||||
}
|
||||
}
|
||||
// ### assert?
|
||||
return 0;
|
||||
}
|
||||
|
||||
IdentifierListAST *IdentifierListAST::clone(MemoryPool *pool) const
|
||||
{
|
||||
IdentifierListAST *ast = new (pool) IdentifierListAST;
|
||||
ast->identifier_token = identifier_token;
|
||||
if (next)
|
||||
ast->next = next->clone(pool);
|
||||
return ast;
|
||||
}
|
||||
|
||||
void IdentifierListAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned ObjCClassDeclarationAST::firstToken() const
|
||||
{
|
||||
return class_token;
|
||||
}
|
||||
|
||||
unsigned ObjCClassDeclarationAST::lastToken() const
|
||||
{
|
||||
if (semicolon_token)
|
||||
return semicolon_token + 1;
|
||||
|
||||
for (IdentifierListAST *it = identifier_list; it; it = it->next) {
|
||||
if (! it->next && it->identifier_token)
|
||||
return it->identifier_token + 1;
|
||||
}
|
||||
|
||||
return class_token + 1;
|
||||
}
|
||||
|
||||
ObjCClassDeclarationAST *ObjCClassDeclarationAST::clone(MemoryPool *pool) const
|
||||
{
|
||||
ObjCClassDeclarationAST *ast = new (pool) ObjCClassDeclarationAST;
|
||||
ast->class_token = class_token;
|
||||
if (identifier_list)
|
||||
ast->identifier_list = identifier_list->clone(pool);
|
||||
ast->semicolon_token = semicolon_token;
|
||||
return ast;
|
||||
}
|
||||
|
||||
void ObjCClassDeclarationAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CPLUSPLUS_END_NAMESPACE
|
||||
|
||||
@@ -1928,6 +1928,41 @@ protected:
|
||||
virtual void accept0(ASTVisitor *visitor);
|
||||
};
|
||||
|
||||
|
||||
// ObjC++
|
||||
class CPLUSPLUS_EXPORT IdentifierListAST: public AST
|
||||
{
|
||||
public:
|
||||
unsigned identifier_token;
|
||||
IdentifierListAST *next;
|
||||
|
||||
public:
|
||||
virtual unsigned firstToken() const;
|
||||
virtual unsigned lastToken() const;
|
||||
|
||||
virtual IdentifierListAST *clone(MemoryPool *pool) const;
|
||||
|
||||
protected:
|
||||
virtual void accept0(ASTVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCClassDeclarationAST: public DeclarationAST
|
||||
{
|
||||
public:
|
||||
unsigned class_token;
|
||||
IdentifierListAST *identifier_list;
|
||||
unsigned semicolon_token;
|
||||
|
||||
public:
|
||||
virtual unsigned firstToken() const;
|
||||
virtual unsigned lastToken() const;
|
||||
|
||||
virtual ObjCClassDeclarationAST *clone(MemoryPool *pool) const;
|
||||
|
||||
protected:
|
||||
virtual void accept0(ASTVisitor *visitor);
|
||||
};
|
||||
|
||||
CPLUSPLUS_END_NAMESPACE
|
||||
CPLUSPLUS_END_HEADER
|
||||
|
||||
|
||||
@@ -185,6 +185,10 @@ public:
|
||||
virtual bool visit(WhileStatementAST *) { return true; }
|
||||
virtual bool visit(QtMethodAST *) { return true; }
|
||||
|
||||
// ObjC++
|
||||
virtual bool visit(IdentifierListAST *) { return true; }
|
||||
virtual bool visit(ObjCClassDeclarationAST *) { return true; }
|
||||
|
||||
private:
|
||||
Control *_control;
|
||||
};
|
||||
|
||||
@@ -167,6 +167,10 @@ class UsingDirectiveAST;
|
||||
class WhileStatementAST;
|
||||
class QtMethodAST;
|
||||
|
||||
// ObjC++
|
||||
class IdentifierListAST;
|
||||
class ObjCClassDeclarationAST;
|
||||
|
||||
CPLUSPLUS_END_NAMESPACE
|
||||
CPLUSPLUS_END_HEADER
|
||||
|
||||
|
||||
@@ -3285,7 +3285,15 @@ bool Parser::parseThrowExpression(ExpressionAST *&node)
|
||||
|
||||
bool Parser::parseObjCClassDeclaration(DeclarationAST *&node)
|
||||
{
|
||||
return false;
|
||||
if (LA() != T_AT_CLASS)
|
||||
return false;
|
||||
|
||||
ObjCClassDeclarationAST *ast = new (_pool) ObjCClassDeclarationAST;
|
||||
ast->class_token = consumeToken();
|
||||
parseObjCIdentifierList(ast->identifier_list);
|
||||
match(T_SEMICOLON, &ast->semicolon_token);
|
||||
node = ast;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Parser::parseObjCInterfaceDeclaration(DeclarationAST *&node)
|
||||
@@ -3318,4 +3326,9 @@ bool Parser::parseObjCPropertyDynamic(DeclarationAST *&node)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Parser::parseObjCIdentifierList(IdentifierListAST *&node)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CPLUSPLUS_END_NAMESPACE
|
||||
|
||||
@@ -212,6 +212,8 @@ public:
|
||||
bool parseObjCPropertySynthesize(DeclarationAST *&node);
|
||||
bool parseObjCPropertyDynamic(DeclarationAST *&node);
|
||||
|
||||
bool parseObjCIdentifierList(IdentifierListAST *&node);
|
||||
|
||||
// Qt MOC run
|
||||
bool parseQtMethod(ExpressionAST *&node);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user