From 412bca2a25fc032bcf62d196305ab62ca3d799d6 Mon Sep 17 00:00:00 2001 From: CaS Date: Fri, 26 Apr 2002 09:13:30 +0000 Subject: [PATCH] Improve identifier mapping git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13546 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++- Tools/AGSParser.m | 81 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 73 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06bdb7ffa..32ef98627 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,13 @@ +2002-04-25 Richard Frith-Macdonald + + * 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 * 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. 2002-04-24 Gregory John Casamento diff --git a/Tools/AGSParser.m b/Tools/AGSParser.m index ebaf2d5ee..613f0c83e 100644 --- a/Tools/AGSParser.m +++ b/Tools/AGSParser.m @@ -1146,15 +1146,17 @@ try: NSString *tmp; NSString *val; - tmp = [NSString stringWithCharacters: &buffer[start] - length: pos - start]; + tmp = [[NSString alloc] initWithCharacters: &buffer[start] + length: pos - start]; val = [wordMap objectForKey: tmp]; 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) { [self skipRemainderOfLine]; @@ -2965,25 +2967,74 @@ fail: */ - (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; }