From 9899cd93c8362c2c1c7ce9de3de4932d14d0173f Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 16 Jun 2008 22:05:49 +0200 Subject: MLKReadtable: Replace -isDigit: with -isDigit:base:. --- MLKReader.m | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'MLKReader.m') diff --git a/MLKReader.m b/MLKReader.m index 18d6571..05ee0f0 100644 --- a/MLKReader.m +++ b/MLKReader.m @@ -152,7 +152,9 @@ return [self interpretToken:token readtable:readtable]; } -+(BOOL) isPotentialNumber:(NSString *)token readtable:(MLKReadtable *)readtable ++(BOOL) isPotentialNumber:(NSString *)token + readtable:(MLKReadtable *)readtable + base:(int)base { // Check whether the token is a potential number. // @@ -165,7 +167,7 @@ for (i = 0; i < [token length]; i++) { unichar ch = [token characterAtIndex:i]; - if (!([readtable isDigit:ch] + if (!([readtable isDigit:ch inBase:base] || [readtable isSign:ch] || [readtable isRatioMarker:ch] || [readtable isDecimalPoint:ch] @@ -184,7 +186,7 @@ for (i = 0; i < [token length]; i++) { unichar ch = [token characterAtIndex:i]; - if ([readtable isDigit:ch]) + if ([readtable isDigit:ch inBase:base]) goto digitFound; } return NO; @@ -192,7 +194,7 @@ digitFound: // 3. Is the first character okay? first = [token characterAtIndex:0]; - if (!([readtable isDigit:first] + if (!([readtable isDigit:first inBase:base] || [readtable isSign:first] || [readtable isDecimalPoint:first] || first == '^' @@ -208,17 +210,20 @@ +(id) interpretToken:(NSString *)token readtable:(MLKReadtable *)readtable { - if ([self isPotentialNumber:token readtable:readtable]) + int base; + + base = [[[MLKDynamicContext currentContext] + valueForBinding:[[MLKPackage findPackage:@"COMMON-LISP"] + intern:@"*READ-BASE*"]] + intValue]; + + if ([self isPotentialNumber:token readtable:readtable base:base]) { unsigned long i, firstNum, secondNum, exponent, exponentMarkerPos; unichar sign, exponentSign; unichar firstSeparator, exponentMarker; BOOL negative; - MLKInteger *base; - base = [[MLKDynamicContext currentContext] - valueForBinding:[[MLKPackage findPackage:@"COMMON-LISP"] - intern:@"*READ-BASE*"]]; // Read the sign (if present). if ([readtable isSign:[token characterAtIndex:0]]) @@ -340,7 +345,7 @@ digits: i = firstNum; while ((i < [token length]) - && [readtable isDigit:[token characterAtIndex:0]]) + && [readtable isDigit:[token characterAtIndex:0] inBase:base]) i++; if (i == [token length]) @@ -349,7 +354,7 @@ [token substringWithRange: NSMakeRange (firstNum, [token length] - firstNum)] negative:negative - base:[base intValue]]; + base:base]; } // Assume token[i] is a slash. @@ -362,7 +367,7 @@ secondNum - firstNum - 1)] denominatorString:[token substringFromIndex:secondNum] negative:negative - base:[base intValue]]; + base:base]; } else { -- cgit v1.2.3