summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-19 20:15:06 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-19 20:15:06 +0200
commitbc49c6720e20a64dc8708e96df89b616c90e4ddf (patch)
tree843f6bcabd3275fef35dd629fdda8a91ef0bec8f
parent8337945090fe3fd0e142fda4dd98bb3fca23fbf5 (diff)
Fix the reader's token recognition code.
-rw-r--r--MLKError.m5
-rw-r--r--MLKReader.h2
-rw-r--r--MLKReader.m17
-rw-r--r--MLKReadtable.m2
4 files changed, 23 insertions, 3 deletions
diff --git a/MLKError.m b/MLKError.m
index eeb59b1..3aad324 100644
--- a/MLKError.m
+++ b/MLKError.m
@@ -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