diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-19 20:15:06 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-19 20:15:06 +0200 |
commit | bc49c6720e20a64dc8708e96df89b616c90e4ddf (patch) | |
tree | 843f6bcabd3275fef35dd629fdda8a91ef0bec8f | |
parent | 8337945090fe3fd0e142fda4dd98bb3fca23fbf5 (diff) |
Fix the reader's token recognition code.
-rw-r--r-- | MLKError.m | 5 | ||||
-rw-r--r-- | MLKReader.h | 2 | ||||
-rw-r--r-- | MLKReader.m | 17 | ||||
-rw-r--r-- | MLKReadtable.m | 2 |
4 files changed, 23 insertions, 3 deletions
@@ -32,6 +32,11 @@ return AUTORELEASE ([[MLKError alloc] initWithMessage:aString]); } +-(NSString *) reason +{ + return message; +} + -(void) dealloc { RELEASE (message); diff --git a/MLKReader.h b/MLKReader.h index 072829a..ec30c40 100644 --- a/MLKReader.h +++ b/MLKReader.h @@ -28,6 +28,8 @@ recursive:(BOOL)recursive preserveWhitespace:(BOOL)preserveWhitespace; ++(id) readFromString:(NSString *)string; + +(id) interpretToken:(NSString *)token readtable:(MLKReadtable *)table; +(BOOL) isPotentialNumber:(NSString *)token diff --git a/MLKReader.m b/MLKReader.m index 2341d32..779ffdd 100644 --- a/MLKReader.m +++ b/MLKReader.m @@ -29,6 +29,7 @@ #import "MLKFloat.h" #import "MLKInteger.h" #import "MLKRatio.h" +#import "MLKStringInputStream.h" #import <Foundation/NSArray.h> #import <Foundation/NSRange.h> @@ -106,13 +107,14 @@ if ([readtable isConstituentCharacter:ch]) { + //NSLog (@"--> Constituent"); token = [NSMutableString stringWithCapacity:8]; - [token appendFormat:@"%C", [readtable charWithReadtableCase: - [stream readChar]]]; + [token appendFormat:@"%C", [readtable charWithReadtableCase:ch]]; } while (![stream isEOF]) { + //NSLog (@"..."); ch = [stream readChar]; if ([readtable isConstituentCharacter:ch] || [readtable isNonTerminatingMacroCharacter:ch] || @@ -150,6 +152,7 @@ } } + //NSLog (@"--> Interpret token: %@", token); return [self interpretToken:token readtable:readtable]; } @@ -450,4 +453,14 @@ return symbol; } } + ++(id) readFromString:(NSString *)string +{ + return [self readFromStream:[[MLKStringInputStream alloc] + initWithString:string] + eofError:YES + eofValue:nil + recursive:NO + preserveWhitespace:NO]; +} @end diff --git a/MLKReadtable.m b/MLKReadtable.m index 393c4d1..dd2a428 100644 --- a/MLKReadtable.m +++ b/MLKReadtable.m @@ -63,7 +63,7 @@ -(enum MLKSyntaxType) characterSyntaxType:(unichar)ch { - NSNumber *type = [_traits objectForKey:[NSNumber numberWithLong:ch]]; + NSNumber *type = [_syntaxTable objectForKey:[NSNumber numberWithLong:ch]]; if (!type) return CONSTITUENT; else |