diff --git a/HTMLKit/HTMLParseErrorToken.h b/HTMLKit/HTMLParseErrorToken.h
index 5aac863..0f27a57 100644
--- a/HTMLKit/HTMLParseErrorToken.h
+++ b/HTMLKit/HTMLParseErrorToken.h
@@ -12,7 +12,8 @@
@interface HTMLParseErrorToken : HTMLToken
@property (nonatomic, copy) NSString *reason;
+@property (nonatomic, assign) NSUInteger location;
-- (instancetype)initWithReasonMessage:(NSString *)reason;
+- (instancetype)initWithReasonMessage:(NSString *)reason andStreamLocation:(NSUInteger)location;
@end
diff --git a/HTMLKit/HTMLParseErrorToken.m b/HTMLKit/HTMLParseErrorToken.m
index e670b76..6097443 100644
--- a/HTMLKit/HTMLParseErrorToken.m
+++ b/HTMLKit/HTMLParseErrorToken.m
@@ -11,20 +11,28 @@
@interface HTMLParseErrorToken ()
{
NSString *_reason;
+ NSUInteger _location;
}
@end
@implementation HTMLParseErrorToken
@synthesize reason = _reason;
+@synthesize location = _location;
-- (instancetype)initWithReasonMessage:(NSString *)reason
+- (instancetype)initWithReasonMessage:(NSString *)reason andStreamLocation:(NSUInteger)location
{
self = [super init];
if (self) {
self.type = HTMLTokenTypeParseError;
_reason = [reason copy];
+ _location = location;
}
return self;
}
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"<%@: %p Reason=%@ Location=%lu>", self.class, self, _reason, _location];
+}
+
@end
diff --git a/HTMLKit/HTMLTokenizer.m b/HTMLKit/HTMLTokenizer.m
index 66eb95d..e411e46 100644
--- a/HTMLKit/HTMLTokenizer.m
+++ b/HTMLKit/HTMLTokenizer.m
@@ -166,7 +166,8 @@
va_start(args, format);
NSString *message = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);
- HTMLParseErrorToken *token = [[HTMLParseErrorToken alloc] initWithReasonMessage:message];
+ HTMLParseErrorToken *token = [[HTMLParseErrorToken alloc] initWithReasonMessage:message
+ andStreamLocation:_inputStreamReader.currentLocation];
[self emitToken:token];
}