forked from qt-creator/qt-creator
Split Objective-C keyword parsing to handle the '@' separately.
Because apparently, while designing the Objective-C language, somebody
thought it was a world-class idea to allow any white-space between the
'@' character and the subsequent keyword. With this fix, we now
correctly parse:
@ dynamic
and:
@
selector
and:
@"foo"
"bar"
@"mooze"
(This last one is 1 single string split over multiple lines.)
Wonderful, isn't it?
What we (and Clang) do not support, but what GCC supports is something
like:
@"foo"@@ "bar" @"mooze" @@
which is equivalent to @"foobarmooze".
This commit is contained in:
@@ -1561,14 +1561,16 @@ unsigned SizeofExpressionAST::lastToken() const
|
||||
|
||||
unsigned StringLiteralAST::firstToken() const
|
||||
{
|
||||
return literal_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned StringLiteralAST::lastToken() const
|
||||
{
|
||||
if (next)
|
||||
return next->lastToken();
|
||||
return literal_token + 1;
|
||||
if (literal_token)
|
||||
return literal_token + 1;
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1910,7 +1912,7 @@ unsigned ObjCClassForwardDeclarationAST::firstToken() const
|
||||
if (attribute_list)
|
||||
return attribute_list->firstToken();
|
||||
|
||||
return class_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCClassForwardDeclarationAST::lastToken() const
|
||||
@@ -1921,7 +1923,10 @@ unsigned ObjCClassForwardDeclarationAST::lastToken() const
|
||||
else if (identifier_list)
|
||||
return identifier_list->lastToken();
|
||||
|
||||
return class_token + 1;
|
||||
else if (class_token)
|
||||
return class_token + 1;
|
||||
else
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCProtocolForwardDeclarationAST::firstToken() const
|
||||
@@ -1929,7 +1934,7 @@ unsigned ObjCProtocolForwardDeclarationAST::firstToken() const
|
||||
if (attribute_list)
|
||||
return attribute_list->firstToken();
|
||||
|
||||
return protocol_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCProtocolForwardDeclarationAST::lastToken() const
|
||||
@@ -1940,7 +1945,10 @@ unsigned ObjCProtocolForwardDeclarationAST::lastToken() const
|
||||
else if (identifier_list)
|
||||
return identifier_list->lastToken();
|
||||
|
||||
return protocol_token + 1;
|
||||
else if (protocol_token)
|
||||
return protocol_token + 1;
|
||||
else
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCClassDeclarationAST::firstToken() const
|
||||
@@ -1948,15 +1956,14 @@ unsigned ObjCClassDeclarationAST::firstToken() const
|
||||
if (attribute_list)
|
||||
return attribute_list->firstToken();
|
||||
|
||||
if (interface_token)
|
||||
return interface_token;
|
||||
else
|
||||
return implementation_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCClassDeclarationAST::lastToken() const
|
||||
{
|
||||
if (end_token) return end_token + 1;
|
||||
if (ending_at_token)
|
||||
return ending_at_token + 1;
|
||||
if (member_declaration_list) return member_declaration_list->lastToken();
|
||||
if (inst_vars_decl) return inst_vars_decl->lastToken();
|
||||
if (protocol_refs)
|
||||
@@ -1974,21 +1981,25 @@ unsigned ObjCClassDeclarationAST::lastToken() const
|
||||
|
||||
if (interface_token)
|
||||
return interface_token + 1;
|
||||
else
|
||||
else if (implementation_token)
|
||||
return implementation_token + 1;
|
||||
else
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCProtocolDeclarationAST::firstToken() const
|
||||
{
|
||||
if (attribute_list)
|
||||
return attribute_list->firstToken();
|
||||
return protocol_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCProtocolDeclarationAST::lastToken() const
|
||||
{
|
||||
if (end_token)
|
||||
return end_token + 1;
|
||||
else if (ending_at_token)
|
||||
return ending_at_token + 1;
|
||||
|
||||
else if (member_declaration_list)
|
||||
return member_declaration_list->lastToken();
|
||||
@@ -2001,8 +2012,10 @@ unsigned ObjCProtocolDeclarationAST::lastToken() const
|
||||
|
||||
else if (attribute_list)
|
||||
return attribute_list->lastToken();
|
||||
|
||||
return protocol_token + 1;
|
||||
else if (protocol_token)
|
||||
return protocol_token + 1;
|
||||
else
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCProtocolRefsAST::firstToken() const
|
||||
@@ -2063,7 +2076,7 @@ unsigned ObjCMessageArgumentAST::lastToken() const
|
||||
|
||||
unsigned ObjCProtocolExpressionAST::firstToken() const
|
||||
{
|
||||
return protocol_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCProtocolExpressionAST::lastToken() const
|
||||
@@ -2077,7 +2090,10 @@ unsigned ObjCProtocolExpressionAST::lastToken() const
|
||||
if (lparen_token)
|
||||
return lparen_token + 1;
|
||||
|
||||
return protocol_token + 1;
|
||||
if (protocol_token)
|
||||
return protocol_token + 1;
|
||||
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCTypeNameAST::firstToken() const
|
||||
@@ -2101,7 +2117,7 @@ unsigned ObjCTypeNameAST::lastToken() const
|
||||
|
||||
unsigned ObjCEncodeExpressionAST::firstToken() const
|
||||
{
|
||||
return encode_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCEncodeExpressionAST::lastToken() const
|
||||
@@ -2109,7 +2125,10 @@ unsigned ObjCEncodeExpressionAST::lastToken() const
|
||||
if (type_name)
|
||||
return type_name->lastToken();
|
||||
|
||||
return encode_token + 1;
|
||||
if (encode_token)
|
||||
return encode_token + 1;
|
||||
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCSelectorWithoutArgumentsAST::firstToken() const
|
||||
@@ -2147,7 +2166,7 @@ unsigned ObjCSelectorWithArgumentsAST::lastToken() const
|
||||
|
||||
unsigned ObjCSelectorExpressionAST::firstToken() const
|
||||
{
|
||||
return selector_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCSelectorExpressionAST::lastToken() const
|
||||
@@ -2158,7 +2177,9 @@ unsigned ObjCSelectorExpressionAST::lastToken() const
|
||||
return selector->lastToken();
|
||||
if (lparen_token)
|
||||
return rparen_token + 1;
|
||||
return selector_token + 1;
|
||||
if (selector_token)
|
||||
return selector_token + 1;
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCInstanceVariablesDeclarationAST::firstToken() const
|
||||
@@ -2179,12 +2200,15 @@ unsigned ObjCInstanceVariablesDeclarationAST::lastToken() const
|
||||
|
||||
unsigned ObjCVisibilityDeclarationAST::firstToken() const
|
||||
{
|
||||
return visibility_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCVisibilityDeclarationAST::lastToken() const
|
||||
{
|
||||
return visibility_token + 1;
|
||||
if (visibility_token)
|
||||
return visibility_token + 1;
|
||||
else
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCPropertyAttributeAST::firstToken() const
|
||||
@@ -2207,7 +2231,7 @@ unsigned ObjCPropertyDeclarationAST::firstToken() const
|
||||
if (attribute_list)
|
||||
return attribute_list->firstToken();
|
||||
|
||||
return property_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCPropertyDeclarationAST::lastToken() const
|
||||
@@ -2220,8 +2244,10 @@ unsigned ObjCPropertyDeclarationAST::lastToken() const
|
||||
return property_attribute_list->lastToken();
|
||||
else if (lparen_token)
|
||||
return lparen_token + 1;
|
||||
|
||||
return property_token + 1;
|
||||
else if (property_token)
|
||||
return property_token + 1;
|
||||
else
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
unsigned ObjCMessageArgumentDeclarationAST::firstToken() const
|
||||
@@ -2354,7 +2380,7 @@ unsigned ObjCFastEnumerationAST::lastToken() const
|
||||
|
||||
unsigned ObjCSynchronizedStatementAST::firstToken() const
|
||||
{
|
||||
return synchronized_token;
|
||||
return at_token;
|
||||
}
|
||||
|
||||
unsigned ObjCSynchronizedStatementAST::lastToken() const
|
||||
@@ -2363,5 +2389,6 @@ unsigned ObjCSynchronizedStatementAST::lastToken() const
|
||||
if (rparen_token) return rparen_token + 1;
|
||||
if (synchronized_object) return synchronized_object->lastToken();
|
||||
if (lparen_token) return lparen_token + 1;
|
||||
return synchronized_token + 1;
|
||||
if (synchronized_token) return synchronized_token + 1;
|
||||
return at_token + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user