Improve identifier mapping

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13546 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-04-26 09:13:30 +00:00
parent 828a2d4ea4
commit 412bca2a25
2 changed files with 73 additions and 16 deletions

View file

@ -1,7 +1,13 @@
2002-04-25 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/AGSParser.m: Improve handling of identifier mapping so that
an identifier mapped to an empty string (or //) an any place where
whitespace is permissable is treated as part of that white space.
2002-04-25 Richard Frith-Macdonald <rfm@gnu.org> 2002-04-25 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/AGSParser.m: Interpret a mapping to '//' in the WordMap as * Tools/AGSParser.m: Interpret a mapping to '//' in the WordMap as
meaning that the resto of the line containing the mapped value meaning that the rest of the line containing the mapped value
should be ignored. should be ignored.
2002-04-24 Gregory John Casamento <greg_casamento@yahoo.com> 2002-04-24 Gregory John Casamento <greg_casamento@yahoo.com>

View file

@ -1146,15 +1146,17 @@ try:
NSString *tmp; NSString *tmp;
NSString *val; NSString *val;
tmp = [NSString stringWithCharacters: &buffer[start] tmp = [[NSString alloc] initWithCharacters: &buffer[start]
length: pos - start]; length: pos - start];
val = [wordMap objectForKey: tmp]; val = [wordMap objectForKey: tmp];
if (val == nil) if (val == nil)
{ {
return tmp; // No mapping found. return AUTORELEASE(tmp); // No mapping found.
} }
else if ([val length] > 0) RELEASE(tmp);
if ([val length] > 0)
{ {
if ([val isEqualToString: @"//"] == YES) if ([val isEqualToString: @"//"] == YES)
{ {
[self skipRemainderOfLine]; [self skipRemainderOfLine];
@ -2965,25 +2967,74 @@ fail:
*/ */
- (unsigned) skipWhiteSpace - (unsigned) skipWhiteSpace
{ {
while (pos < length) BOOL tryAgain;
do
{ {
unichar c = buffer[pos]; unsigned start;
if (c == '/') tryAgain = NO;
while (pos < length)
{ {
unsigned old = pos; unichar c = buffer[pos];
if ([self skipComment] > old) if (c == '/')
{ {
continue; // Found a comment ... go on as if it was a space. unsigned old = pos;
if ([self skipComment] > old)
{
continue; // Found a comment ... act as if it was a space.
}
}
if ([spacenl characterIsMember: c] == NO)
{
break; // Not whitespace ... done.
}
pos++; // Step past space character.
}
start = pos;
if (pos < length && [identifier characterIsMember: buffer[pos]] == YES)
{
while (pos < length)
{
if ([identifier characterIsMember: buffer[pos]] == NO)
{
NSString *tmp;
NSString *val;
tmp = [[NSString alloc] initWithCharacters: &buffer[start]
length: pos - start];
val = [wordMap objectForKey: tmp];
RELEASE(tmp);
if (val == nil)
{
pos = start; // No mapping found
}
else if ([val length] > 0)
{
if ([val isEqualToString: @"//"] == YES)
{
[self skipRemainderOfLine];
tryAgain = YES;
}
else
{
pos = start; // Not mapped to a comment.
}
}
else
{
tryAgain = YES; // Identifier ignored.
}
break;
}
pos++;
} }
} }
if ([spacenl characterIsMember: c] == NO)
{
break; // Not whitespace ... done.
}
pos++; // Step past space character.
} }
while (tryAgain == YES);
return pos; return pos;
} }