Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename LichTokenizerError_* to LichError_* to

facilitate other implementations (stop exposing
the Cocoa implementation's details).
  • Loading branch information...
commit 723d7d2f91762e75b29f8cdae3721a60b52c0d9e 1 parent 91107a9
@rentzsch authored
View
2  cocoa/LichCocoa.h
@@ -1,4 +1,4 @@
-// LichCocoa.h semver:0.1
+// LichCocoa.h semver:0.2
// Copyright (c) 2012 Jonathan 'Wolf' Rentzsch: http://rentzsch.com
// Some rights reserved: http://opensource.org/licenses/mit
// https://github.com/rentzsch/lich
View
2  cocoa/LichCocoa.m
@@ -1,4 +1,4 @@
-// LichCocoa.m semver:0.1
+// LichCocoa.m semver:0.2
// Copyright (c) 2012 Jonathan 'Wolf' Rentzsch: http://rentzsch.com
// Some rights reserved: http://opensource.org/licenses/mit
// https://github.com/rentzsch/lich
View
16 cocoa/LichTokenizer.h
@@ -1,4 +1,4 @@
-// LichTokenizer.h semver:0.1
+// LichTokenizer.h semver:0.2
// Copyright (c) 2012 Jonathan 'Wolf' Rentzsch: http://rentzsch.com
// Some rights reserved: http://opensource.org/licenses/mit
// https://github.com/rentzsch/lich
@@ -67,15 +67,15 @@ extern NSData * const LichTokenizerEOF;
extern NSString * const LichTokenizerErrorDomain;
typedef enum {
- LichTokenizerError_MissingSizePrefix,
- LichTokenizerError_InvalidSizePrefix,
- LichTokenizerError_ExcessiveSizePrefix,
- LichTokenizerError_IncompleteSizePrefix,
+ LichError_MissingSizePrefix,
+ LichError_InvalidSizePrefix,
+ LichError_ExcessiveSizePrefix,
+ LichError_IncompleteSizePrefix,
- LichTokenizerError_IncompleteData,
+ LichError_IncompleteData,
- LichTokenizerError_MissingClosingMarker,
- LichTokenizerError_IncorrectClosingMarker,
+ LichError_MissingClosingMarker,
+ LichError_IncorrectClosingMarker,
} LichTokenizerErrorCode;
extern NSString* NSStringFromLichTokenizerErrorCode(LichTokenizerErrorCode code);
View
50 cocoa/LichTokenizer.m
@@ -1,4 +1,4 @@
-// LichTokenizer.m semver:0.1
+// LichTokenizer.m semver:0.2
// Copyright (c) 2012 Jonathan 'Wolf' Rentzsch: http://rentzsch.com
// Some rights reserved: http://opensource.org/licenses/mit
// https://github.com/rentzsch/lich
@@ -110,7 +110,7 @@ - (BOOL)tokenizeNextChunk:(NSData*)data error:(NSError**)error {
[self pushNewCurrentTokenWithInputPositionAndByte:b];
self.state = LichTokenizerState_ExpectingAdditionalSizeDigitOrOpenMarker;
} else {
- [self parseError:LichTokenizerError_MissingSizePrefix userInfo:JRMakeErrUserInfo()];
+ [self parseError:LichError_MissingSizePrefix userInfo:JRMakeErrUserInfo()];
}
break;
case LichTokenizerState_ExpectingAdditionalSizeDigitOrOpenMarker:
@@ -120,7 +120,7 @@ - (BOOL)tokenizeNextChunk:(NSData*)data error:(NSError**)error {
self.currentToken->sizeDeclarationRange.length++;
[self.sizeAccumulator appendFormat:@"%c", b];
} else {
- [self parseError:LichTokenizerError_ExcessiveSizePrefix userInfo:JRMakeErrUserInfo()];
+ [self parseError:LichError_ExcessiveSizePrefix userInfo:JRMakeErrUserInfo()];
}
} else if (b == '<' || b == '[' || b == '{') {
self.currentToken->openingMarkerRange = NSMakeRange(self.inputPos, 1);
@@ -128,7 +128,7 @@ - (BOOL)tokenizeNextChunk:(NSData*)data error:(NSError**)error {
NULL,
10);
if (errno == ERANGE) {
- [self parseError:LichTokenizerError_ExcessiveSizePrefix userInfo:JRMakeErrUserInfo()];
+ [self parseError:LichError_ExcessiveSizePrefix userInfo:JRMakeErrUserInfo()];
}
if (!jrErr) {
@@ -166,7 +166,7 @@ - (BOOL)tokenizeNextChunk:(NSData*)data error:(NSError**)error {
[self.observer lichTokenizer:self beginToken:self.currentToken];
}
} else {
- [self parseError:LichTokenizerError_InvalidSizePrefix userInfo:JRMakeErrUserInfo()];
+ [self parseError:LichError_InvalidSizePrefix userInfo:JRMakeErrUserInfo()];
}
break;
case LichTokenizerState_ExpectingDataBytes: {
@@ -197,7 +197,7 @@ - (BOOL)tokenizeNextChunk:(NSData*)data error:(NSError**)error {
}
self.currentToken = self.currentToken.parent;
} else {
- [self parseError:LichTokenizerError_IncorrectClosingMarker userInfo:JRMakeErrUserInfo()];
+ [self parseError:LichError_IncorrectClosingMarker userInfo:JRMakeErrUserInfo()];
}
} break;
default:
@@ -209,17 +209,17 @@ - (BOOL)tokenizeNextChunk:(NSData*)data error:(NSError**)error {
// EOF.
switch (_state) {
case LichTokenizerState_ExpectingLeadingSizeDigit:
- //[self parseError:LichTokenizerError_MissingSizePrefix];
+ //[self parseError:LichError_MissingSizePrefix];
// No-op.
break;
case LichTokenizerState_ExpectingAdditionalSizeDigitOrOpenMarker:
- [self parseError:LichTokenizerError_IncompleteSizePrefix userInfo:JRMakeErrUserInfo()];
+ [self parseError:LichError_IncompleteSizePrefix userInfo:JRMakeErrUserInfo()];
break;
case LichTokenizerState_ExpectingDataBytes:
- [self parseError:LichTokenizerError_IncompleteData userInfo:JRMakeErrUserInfo()];
+ [self parseError:LichError_IncompleteData userInfo:JRMakeErrUserInfo()];
break;
case LichTokenizerState_ExpectingCloseMarker:
- [self parseError:LichTokenizerError_MissingClosingMarker userInfo:JRMakeErrUserInfo()];
+ [self parseError:LichError_MissingClosingMarker userInfo:JRMakeErrUserInfo()];
break;
case LichTokenizerState_AwaitingInitialData:
NSAssert1(NO, @"unknown LichTokenizerState: %d", _state);
@@ -280,21 +280,21 @@ - (void)pushNewCurrentTokenWithInputPositionAndByte:(uint8_t)byte {
NSString* NSStringFromLichTokenizerErrorCode(LichTokenizerErrorCode code) {
switch (code) {
- case LichTokenizerError_MissingSizePrefix:
- return @"LichTokenizerError_MissingSizePrefix";
- case LichTokenizerError_InvalidSizePrefix:
- return @"LichTokenizerError_InvalidSizePrefix";
- case LichTokenizerError_ExcessiveSizePrefix:
- return @"LichTokenizerError_ExcessiveSizePrefix";
- case LichTokenizerError_IncompleteSizePrefix:
- return @"LichTokenizerError_IncompleteSizePrefix";
- case LichTokenizerError_IncompleteData:
- return @"LichTokenizerError_IncompleteData";
- case LichTokenizerError_MissingClosingMarker:
- return @"LichTokenizerError_MissingClosingMarker";
- case LichTokenizerError_IncorrectClosingMarker:
- return @"LichTokenizerError_IncorrectClosingMarker";
+ case LichError_MissingSizePrefix:
+ return @"LichError_MissingSizePrefix";
+ case LichError_InvalidSizePrefix:
+ return @"LichError_InvalidSizePrefix";
+ case LichError_ExcessiveSizePrefix:
+ return @"LichError_ExcessiveSizePrefix";
+ case LichError_IncompleteSizePrefix:
+ return @"LichError_IncompleteSizePrefix";
+ case LichError_IncompleteData:
+ return @"LichError_IncompleteData";
+ case LichError_MissingClosingMarker:
+ return @"LichError_MissingClosingMarker";
+ case LichError_IncorrectClosingMarker:
+ return @"LichError_IncorrectClosingMarker";
default:
- NSCAssert1(NO, @"unknown LichTokenizerErrorCode: %d", code);
+ NSCAssert1(NO, @"unknown LichErrorCode: %d", code);
}
}
View
36 lich-tests.json
@@ -14,26 +14,26 @@
"6[3[0<>]]"
],
"invalid": [
- ["x", "LichTokenizerError_MissingSizePrefix", 0],
- ["-", "LichTokenizerError_MissingSizePrefix", 0],
- [".", "LichTokenizerError_MissingSizePrefix", 0],
- ["<", "LichTokenizerError_MissingSizePrefix", 0],
- ["[", "LichTokenizerError_MissingSizePrefix", 0],
- ["{", "LichTokenizerError_MissingSizePrefix", 0],
- [">", "LichTokenizerError_MissingSizePrefix", 0],
- ["]", "LichTokenizerError_MissingSizePrefix", 0],
- ["}", "LichTokenizerError_MissingSizePrefix", 0],
- ["(", "LichTokenizerError_MissingSizePrefix", 0],
- [")", "LichTokenizerError_MissingSizePrefix", 0],
+ ["x", "LichError_MissingSizePrefix", 0],
+ ["-", "LichError_MissingSizePrefix", 0],
+ [".", "LichError_MissingSizePrefix", 0],
+ ["<", "LichError_MissingSizePrefix", 0],
+ ["[", "LichError_MissingSizePrefix", 0],
+ ["{", "LichError_MissingSizePrefix", 0],
+ [">", "LichError_MissingSizePrefix", 0],
+ ["]", "LichError_MissingSizePrefix", 0],
+ ["}", "LichError_MissingSizePrefix", 0],
+ ["(", "LichError_MissingSizePrefix", 0],
+ [")", "LichError_MissingSizePrefix", 0],
- ["1<>", "LichTokenizerError_MissingClosingMarker", 3],
- ["2<>", "LichTokenizerError_IncompleteData", 3],
- ["9<>", "LichTokenizerError_IncompleteData", 3],
- ["3[0<>0<>]", "LichTokenizerError_IncorrectClosingMarker", 5],
+ ["1<>", "LichError_MissingClosingMarker", 3],
+ ["2<>", "LichError_IncompleteData", 3],
+ ["9<>", "LichError_IncompleteData", 3],
+ ["3[0<>0<>]", "LichError_IncorrectClosingMarker", 5],
- ["18446744073709551615<>", "LichTokenizerError_IncompleteData", 22],
- ["18446744073709551616<>", "LichTokenizerError_ExcessiveSizePrefix", 20],
- ["99999999999999999999<>", "LichTokenizerError_ExcessiveSizePrefix", 20]
+ ["18446744073709551615<>", "LichError_IncompleteData", 22],
+ ["18446744073709551616<>", "LichError_ExcessiveSizePrefix", 20],
+ ["99999999999999999999<>", "LichError_ExcessiveSizePrefix", 20]
],
"encoding": [
["", "0<>"],
Please sign in to comment.
Something went wrong with that request. Please try again.