Skip to content

Commit

Permalink
Add skipping of generics in a few more places.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Oct 21, 2024
1 parent e14da97 commit bd6c52e
Showing 1 changed file with 47 additions and 27 deletions.
74 changes: 47 additions & 27 deletions Tools/AGSParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -1855,34 +1855,21 @@ - (NSMutableArray*) parseDeclarations
*/
if ([self parseSpace] < length && buffer[pos] == '<')
{
unsigned save = pos;
NSString *p;
NSArray *protocols = [self parseProtocolList];

do
{
pos++;
p = [self parseIdentifier];
if (p != nil)
{
[a addObject: p];
}
}
while ([self parseSpace] < length && buffer[pos] == ',');
if ('>' == buffer[pos])
{
pos++;
[self parseSpace];
if (protocols)
{
[a addObjectsFromArray: protocols];
[a sortUsingSelector: @selector(compare:)];
[t appendString: @"<"];
[t appendString: [a componentsJoinedByString: @","]];
[t appendString: @">"];
[a removeAllObjects];
}
else
{
pos = save;
[self skipGeneric];
}
}
else
{
[self skipGeneric];
}
}
baseType = t;
}
Expand Down Expand Up @@ -2464,7 +2451,7 @@ - (NSMutableDictionary*) parseImplementation
{
pos++;
if ((base = [self parseIdentifier]) == nil
|| [self parseSpace] >= length)
|| [self parseSpaceOrGeneric] >= length)
{
[self log: @"@interface with bad base class"];
goto fail;
Expand Down Expand Up @@ -2561,7 +2548,7 @@ - (NSMutableDictionary*) parseInterface
}

if ((name = [self parseIdentifier]) == nil
|| [self parseSpace] >= length)
|| [self parseSpaceOrGeneric] >= length)
{
[self log: @"interface with bad name"];
goto fail;
Expand Down Expand Up @@ -2626,7 +2613,17 @@ - (NSMutableDictionary*) parseInterface

if (protocols == nil)
{
goto fail;
unsigned saved = pos;

if ([self skipGeneric] > saved)
{
[self parseSpace];
}
else
{
[self log: @"bad protocol list"];
goto fail;
}
}
else if ([protocols count] > 0)
{
Expand Down Expand Up @@ -4329,6 +4326,7 @@ - (NSMutableDictionary*) parseProtocol

if (protocols == nil)
{
[self log: @"bad protocol list"];
goto fail;
}
else if ([protocols count] > 0)
Expand Down Expand Up @@ -4389,6 +4387,7 @@ - (NSMutableArray*) parseProtocolList
{
NSMutableArray *protocols;
NSString *p;
unsigned start = pos;

protocols = [NSMutableArray arrayWithCapacity: 2];
pos++;
Expand All @@ -4411,7 +4410,7 @@ - (NSMutableArray*) parseProtocolList
if (pos >= length || buffer[pos] != '>' || ++pos >= length
|| [self parseSpace] >= length || [protocols count] == 0)
{
[self log: @"bad protocol list"];
pos = start;
return nil;
}
return protocols;
Expand Down Expand Up @@ -4523,7 +4522,28 @@ - (unsigned) parseSpace: (NSCharacterSet*)spaceSet

- (unsigned) parseSpace
{
return [self parseSpace: spacenl];
[self parseSpace: spacenl];
return pos;
}

- (unsigned) parseSpaceOrGeneric
{
[self parseSpace: spacenl];

if (pos < length && '<' == buffer[pos])
{
unsigned saved = pos;

if ([self skipGeneric] > saved)
{
[self parseSpace];
}
else
{
[self log: @"bad generic"];
}
}
return pos;
}

- (NSString*) parseVersion
Expand Down

0 comments on commit bd6c52e

Please sign in to comment.