Browse files

cleaning up factory method return types. adding twitter state test.

  • Loading branch information...
1 parent 0068c57 commit 32bd9bfaeaab31fdd81e6e891b2dd237a88d0d79 @itod committed Apr 7, 2010
Showing with 232 additions and 149 deletions.
  1. +2 −0 ParseKit.xcodeproj/project.pbxproj
  2. +2 −2 include/ParseKit/PKAlternation.h
  3. +1 −1 include/ParseKit/PKAny.h
  4. +1 −1 include/ParseKit/PKAssembly.h
  5. +1 −1 include/ParseKit/PKChar.h
  6. +1 −0 include/ParseKit/PKCharacterAssembly.h
  7. +1 −1 include/ParseKit/PKComment.h
  8. +3 −3 include/ParseKit/PKDelimitedString.h
  9. +1 −1 include/ParseKit/PKDifference.h
  10. +1 −1 include/ParseKit/PKDigit.h
  11. +1 −0 include/ParseKit/PKEmailState.h
  12. +1 −1 include/ParseKit/PKEmpty.h
  13. +2 −2 include/ParseKit/PKIntersection.h
  14. +1 −1 include/ParseKit/PKLetter.h
  15. +1 −1 include/ParseKit/PKLiteral.h
  16. +1 −1 include/ParseKit/PKNegation.h
  17. +1 −1 include/ParseKit/PKNumber.h
  18. +1 −1 include/ParseKit/PKParser.h
  19. +2 −1 include/ParseKit/PKParserFactory.h
  20. +3 −2 include/ParseKit/PKPattern.h
  21. +1 −1 include/ParseKit/PKQuotedString.h
  22. +1 −1 include/ParseKit/PKRepetition.h
  23. +2 −2 include/ParseKit/PKSequence.h
  24. +1 −1 include/ParseKit/PKSpecificChar.h
  25. +2 −2 include/ParseKit/PKSymbol.h
  26. +1 −1 include/ParseKit/PKToken.h
  27. +4 −2 include/ParseKit/PKTokenAssembly.h
  28. +2 −2 include/ParseKit/PKTokenizer.h
  29. +2 −2 include/ParseKit/PKTrack.h
  30. +1 −0 include/ParseKit/PKURLState.h
  31. +1 −1 include/ParseKit/PKWhitespace.h
  32. +1 −1 include/ParseKit/PKWord.h
  33. +4 −4 src/PKAlternation.m
  34. +1 −1 src/PKAny.m
  35. +1 −1 src/PKAssembly.m
  36. +1 −1 src/PKChar.m
  37. +5 −0 src/PKCharacterAssembly.m
  38. +2 −2 src/PKCollectionParser.m
  39. +1 −1 src/PKComment.m
  40. +3 −3 src/PKDelimitedString.m
  41. +1 −1 src/PKDifference.m
  42. +1 −1 src/PKDigit.m
  43. +8 −1 src/PKEmailState.m
  44. +1 −1 src/PKEmpty.m
  45. +1 −1 src/PKGrammarParser.h
  46. +2 −2 src/PKGrammarParser.m
  47. +4 −4 src/PKIntersection.m
  48. +1 −1 src/PKLetter.m
  49. +1 −1 src/PKLiteral.m
  50. +1 −1 src/PKNegation.m
  51. +1 −1 src/PKNumber.m
  52. +1 −1 src/PKParser.m
  53. +2 −2 src/PKParserFactory.m
  54. +2 −2 src/PKPattern.m
  55. +1 −1 src/PKQuotedString.m
  56. +1 −1 src/PKRepetition.m
  57. +4 −4 src/PKSequence.m
  58. +1 −1 src/PKSpecificChar.m
  59. +2 −2 src/PKSymbol.m
  60. +1 −1 src/PKToken.m
  61. +10 −5 src/PKTokenAssembly.m
  62. +2 −2 src/PKTokenizer.m
  63. +4 −4 src/PKTrack.m
  64. +12 −5 src/PKURLState.m
  65. +1 −1 src/PKWhitespace.m
  66. +1 −1 src/PKWord.m
  67. +1 −1 test/PKAST.h
  68. +1 −1 test/PKAST.m
  69. +1 −1 test/PKExclusion.h
  70. +1 −1 test/PKExclusion.m
  71. +1 −1 test/PKParseTree.h
  72. +1 −1 test/PKParseTree.m
  73. +1 −1 test/PKRuleNode.h
  74. +1 −1 test/PKRuleNode.m
  75. +1 −1 test/PKTokenNode.h
  76. +1 −1 test/PKTokenNode.m
  77. +8 −8 test/SRGSParser.h
  78. +4 −4 test/SRGSParser.m
  79. +1 −1 test/TDArithmeticParserTest.m
  80. +2 −2 test/TDBlob.h
  81. +2 −2 test/TDBlob.m
  82. +4 −4 test/TDJavaScriptParser.h
  83. +2 −2 test/TDJavaScriptParser.m
  84. +1 −1 test/TDJavaScriptParserTest.m
  85. +2 −2 test/TDJsonParser.m
  86. +1 −1 test/TDJsonParserTest.m
  87. +1 −1 test/TDLetterTest.h
  88. +2 −2 test/TDNSPredicateBuilder.h
  89. +1 −1 test/TDNSPredicateBuilder.m
  90. +1 −1 test/TDPatternTest.h
  91. +1 −1 test/TDRegularParser.m
  92. +1 −1 test/TDRegularParserTest.m
  93. +1 −1 test/TDSpecificCharTest.h
  94. +2 −2 test/TDTestScaffold.m
  95. +2 −2 test/TDTokenizerTest.m
  96. +50 −0 test/TDURLStateTest.m
  97. +1 −1 test/TDXmlTokenizerTest.m
View
2 ParseKit.xcodeproj/project.pbxproj
@@ -3591,6 +3591,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_VERSION = com.apple.compilers.llvmgcc42;
HEADER_SEARCH_PATHS = "$(LIBXML_PATH)";
INFOPLIST_FILE = "test/Tests-Info.plist";
@@ -3637,6 +3638,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_VERSION = com.apple.compilers.llvmgcc42;
HEADER_SEARCH_PATHS = "$(LIBXML_PATH)";
INFOPLIST_FILE = "test/Tests-Info.plist";
View
4 include/ParseKit/PKAlternation.h
@@ -27,7 +27,7 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKAlternation</tt> parser.
@result an initialized autoreleased <tt>PKAlternation</tt> parser.
*/
-+ (id)alternation;
++ (PKAlternation *)alternation;
-+ (id)alternationWithSubparsers:(PKParser *)p1, ...;
++ (PKAlternation *)alternationWithSubparsers:(PKParser *)p1, ...;
@end
View
2 include/ParseKit/PKAny.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKAny</tt> object.
@result an initialized autoreleased <tt>PKAny</tt> object
*/
-+ (id)any;
++ (PKAny *)any;
@end
View
2 include/ParseKit/PKAssembly.h
@@ -33,7 +33,7 @@
@param s string to be worked on
@result an initialized autoreleased assembly
*/
-+ (id)assemblyWithString:(NSString *)s;
++ (PKAssembly *)assemblyWithString:(NSString *)s;
/*!
@brief Designated Initializer. Initializes an assembly with a given string.
View
2 include/ParseKit/PKChar.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKChar</tt> parser.
@result an initialized autoreleased <tt>PKChar</tt> parser.
*/
-+ (id)char;
++ (PKChar *)char;
@end
View
1 include/ParseKit/PKCharacterAssembly.h
@@ -22,4 +22,5 @@
}
++ (PKCharacterAssembly *)assemblyWithString:(NSString *)s;
@end
View
2 include/ParseKit/PKComment.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKComment</tt> object.
@result an initialized autoreleased <tt>PKComment</tt> object
*/
-+ (id)comment;
++ (PKComment *)comment;
@end
View
6 include/ParseKit/PKDelimitedString.h
@@ -28,9 +28,9 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKDelimitedString</tt> object.
@result an initialized autoreleased <tt>PKDelimitedString</tt> object
*/
-+ (id)delimitedString;
++ (PKDelimitedString *)delimitedString;
-+ (id)delimitedStringWithStartMarker:(NSString *)start;
++ (PKDelimitedString *)delimitedStringWithStartMarker:(NSString *)start;
-+ (id)delimitedStringWithStartMarker:(NSString *)start endMarker:(NSString *)end;
++ (PKDelimitedString *)delimitedStringWithStartMarker:(NSString *)start endMarker:(NSString *)end;
@end
View
2 include/ParseKit/PKDifference.h
@@ -39,7 +39,7 @@
@param minus the parser whose matches will be exluded
@result an initialized autoreleased <tt>PKDifference</tt> parser.
*/
-+ (id)differenceWithSubparser:(PKParser *)s minus:(PKParser *)m;
++ (PKDifference *)differenceWithSubparser:(PKParser *)s minus:(PKParser *)m;
/*!
@brief Designated initializer
View
2 include/ParseKit/PKDigit.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKDigit</tt> parser.
@result an initialized autoreleased <tt>PKDigit</tt> parser.
*/
-+ (id)digit;
++ (PKDigit *)digit;
@end
View
1 include/ParseKit/PKEmailState.h
@@ -16,6 +16,7 @@
*/
@interface PKEmailState : PKTokenizerState {
PKUniChar c;
+ PKUniChar lastChar;
}
@end
View
2 include/ParseKit/PKEmpty.h
@@ -28,5 +28,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKEmpty</tt> parser.
@result an initialized autoreleased <tt>PKEmpty</tt> parser.
*/
-+ (id)empty;
++ (PKEmpty *)empty;
@end
View
4 include/ParseKit/PKIntersection.h
@@ -35,7 +35,7 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKIntersection</tt> parser.
@result an initialized autoreleased <tt>PKIntersection</tt> parser.
*/
-+ (id)intersection;
++ (PKIntersection *)intersection;
-+ (id)intersectionWithSubparsers:(PKParser *)p1, ...;
++ (PKIntersection *)intersectionWithSubparsers:(PKParser *)p1, ...;
@end
View
2 include/ParseKit/PKLetter.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKLetter</tt> parser.
@result an initialized autoreleased <tt>PKLetter</tt> parser.
*/
-+ (id)letter;
++ (PKLetter *)letter;
@end
View
2 include/ParseKit/PKLiteral.h
@@ -30,5 +30,5 @@
@param s the word represented by this literal
@result an initialized autoreleased <tt>PKLiteral</tt> object representing <tt>s</tt>
*/
-+ (id)literalWithString:(NSString *)s;
++ (PKLiteral *)literalWithString:(NSString *)s;
@end
View
2 include/ParseKit/PKNegation.h
@@ -35,7 +35,7 @@
@param subparser the parser whose matching logic is negated
@result an initialized autoreleased <tt>PKNegation</tt> parser.
*/
-+ (id)negationWithSubparser:(PKParser *)s;
++ (PKNegation *)negationWithSubparser:(PKParser *)s;
/*!
@brief Designated initializer
View
2 include/ParseKit/PKNumber.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKNumber</tt> object.
@result an initialized autoreleased <tt>PKNumber</tt> object
*/
-+ (id)number;
++ (PKNumber *)number;
@end
View
2 include/ParseKit/PKParser.h
@@ -57,7 +57,7 @@
@brief Convenience factory method for initializing an autoreleased parser.
@result an initialized autoreleased parser.
*/
-+ (id)parser;
++ (PKParser *)parser;
/*!
@brief Sets the object and method that will work on an assembly whenever this parser successfully matches against the assembly.
View
3 include/ParseKit/PKParserFactory.h
@@ -36,7 +36,8 @@ typedef enum {
PKToken *paren;
BOOL isGatheringClasses;
}
-+ (id)factory;
+
++ (PKParserFactory *)factory;
- (PKParser *)parserFromGrammar:(NSString *)s assembler:(id)a;
- (PKParser *)parserFromGrammar:(NSString *)s assembler:(id)a preassembler:(id)pa;
View
5 include/ParseKit/PKPattern.h
@@ -28,9 +28,10 @@ typedef enum {
@interface PKPattern : PKTerminal {
PKPatternOptions options;
}
-+ (id)patternWithString:(NSString *)s;
-+ (id)patternWithString:(NSString *)s options:(PKPatternOptions)opts;
++ (PKPattern *)patternWithString:(NSString *)s;
+
++ (PKPattern *)patternWithString:(NSString *)s options:(PKPatternOptions)opts;
- (id)initWithString:(NSString *)s;
View
2 include/ParseKit/PKQuotedString.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKQuotedString</tt> object.
@result an initialized autoreleased <tt>PKQuotedString</tt> object
*/
-+ (id)quotedString;
++ (PKQuotedString *)quotedString;
@end
View
2 include/ParseKit/PKRepetition.h
@@ -28,7 +28,7 @@
@param p the subparser against wich to repeatedly match
@result an initialized autoreleased <tt>PKRepetition</tt> parser.
*/
-+ (id)repetitionWithSubparser:(PKParser *)p;
++ (PKRepetition *)repetitionWithSubparser:(PKParser *)p;
/*!
@brief Designated Initializer. Initialize a <tt>PKRepetition</tt> parser to repeatedly match against subparser <tt>p</tt>.
View
4 include/ParseKit/PKSequence.h
@@ -27,7 +27,7 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKSequence</tt> parser.
@result an initialized autoreleased <tt>PKSequence</tt> parser.
*/
-+ (id)sequence;
++ (PKSequence *)sequence;
-+ (id)sequenceWithSubparsers:(PKParser *)p1, ...;
++ (PKSequence *)sequenceWithSubparsers:(PKParser *)p1, ...;
@end
View
2 include/ParseKit/PKSpecificChar.h
@@ -29,7 +29,7 @@
@param c the character this object should match
@result an initialized autoreleased <tt>PKSpecificChar</tt> parser.
*/
-+ (id)specificCharWithChar:(PKUniChar)c;
++ (PKSpecificChar *)specificCharWithChar:(PKUniChar)c;
/*!
@brief Designated Initializer. Initializes a <tt>PKSpecificChar</tt> parser.
View
4 include/ParseKit/PKSymbol.h
@@ -29,12 +29,12 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKSymbol</tt> object with a <tt>nil</tt> string value.
@result an initialized autoreleased <tt>PKSymbol</tt> object with a <tt>nil</tt> string value
*/
-+ (id)symbol;
++ (PKSymbol *)symbol;
/*!
@brief Convenience factory method for initializing an autoreleased <tt>PKSymbol</tt> object with <tt>s</tt> as a string value.
@param s the string represented by this symbol
@result an initialized autoreleased <tt>PKSymbol</tt> object with <tt>s</tt> as a string value
*/
-+ (id)symbolWithString:(NSString *)s;
++ (PKSymbol *)symbolWithString:(NSString *)s;
@end
View
2 include/ParseKit/PKToken.h
@@ -79,7 +79,7 @@ typedef enum {
@param n the number falue of this token.
@result an autoreleased initialized token.
*/
-+ (id)tokenWithTokenType:(PKTokenType)t stringValue:(NSString *)s floatValue:(CGFloat)n;
++ (PKToken *)tokenWithTokenType:(PKTokenType)t stringValue:(NSString *)s floatValue:(CGFloat)n;
/*!
@brief Designated initializer. Constructs a token of the indicated type and associated string or numeric values.
View
6 include/ParseKit/PKTokenAssembly.h
@@ -32,14 +32,16 @@
@param t tokenizer whose string will be worked on
@result an initialized autoreleased assembly
*/
-+ (id)assemblyWithTokenizer:(PKTokenizer *)t;
++ (PKTokenAssembly *)assemblyWithTokenizer:(PKTokenizer *)t;
/*!
@brief Convenience factory method for initializing an autoreleased assembly with the token array <tt>a</tt> and its string
@param a token array whose string will be worked on
@result an initialized autoreleased assembly
*/
-+ (id)assemblyWithTokenArray:(NSArray *)a;
++ (PKTokenAssembly *)assemblyWithTokenArray:(NSArray *)a;
+
++ (PKTokenAssembly *)assemblyWithString:(NSString *)s;
/*!
@brief Initializes an assembly with the tokenizer <tt>t</tt> and its string
View
4 include/ParseKit/PKTokenizer.h
@@ -74,14 +74,14 @@
@brief Convenience factory method. Sets string from which to to read to <tt>nil</tt>.
@result An initialized tokenizer.
*/
-+ (id)tokenizer;
++ (PKTokenizer *)tokenizer;
/*!
@brief Convenience factory method.
@param s string to read from.
@result An autoreleased initialized tokenizer.
*/
-+ (id)tokenizerWithString:(NSString *)s;
++ (PKTokenizer *)tokenizerWithString:(NSString *)s;
/*!
@brief Designated Initializer. Constructs a tokenizer to read from the supplied string.
View
4 include/ParseKit/PKTrack.h
@@ -28,7 +28,7 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKTrack</tt> parser.
@result an initialized autoreleased <tt>PKTrack</tt> parser.
*/
-+ (id)track;
++ (PKTrack *)track;
-+ (id)trackWithSubparsers:(PKParser *)p1, ...;
++ (PKTrack *)trackWithSubparsers:(PKParser *)p1, ...;
@end
View
1 include/ParseKit/PKURLState.h
@@ -16,6 +16,7 @@
*/
@interface PKURLState : PKTokenizerState {
PKUniChar c;
+ PKUniChar lastChar;
BOOL allowsWWWPrefix;
}
View
2 include/ParseKit/PKWhitespace.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKWhitespace</tt> object.
@result an initialized autoreleased <tt>PKWhitespace</tt> object
*/
-+ (id)whitespace;
++ (PKWhitespace *)whitespace;
@end
View
2 include/ParseKit/PKWord.h
@@ -27,5 +27,5 @@
@brief Convenience factory method for initializing an autoreleased <tt>PKWord</tt> object.
@result an initialized autoreleased <tt>PKWord</tt> object
*/
-+ (id)word;
++ (PKWord *)word;
@end
View
8 src/PKAlternation.m
@@ -21,20 +21,20 @@ - (NSSet *)allMatchesFor:(NSSet *)inAssemblies;
@end
@interface PKCollectionParser ()
-+ (id)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
++ (PKCollectionParser *)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
@end
@implementation PKAlternation
-+ (id)alternation {
++ (PKAlternation *)alternation {
return [self alternationWithSubparsers:nil];
}
-+ (id)alternationWithSubparsers:(PKParser *)p1, ... {
++ (PKAlternation *)alternationWithSubparsers:(PKParser *)p1, ... {
va_list vargs;
va_start(vargs, p1);
- PKAlternation *alt = [self collectionParserWithFirst:p1 rest:vargs];
+ PKAlternation *alt = (PKAlternation *)[self collectionParserWithFirst:p1 rest:vargs];
va_end(vargs);
return alt;
}
View
2 src/PKAny.m
@@ -17,7 +17,7 @@
@implementation PKAny
-+ (id)any {
++ (PKAny *)any {
return [[[self alloc] initWithString:nil] autorelease];
}
View
2 src/PKAssembly.m
@@ -34,7 +34,7 @@ - (NSString *)remainingObjectsJoinedByString:(NSString *)delimiter;
@implementation PKAssembly
-+ (id)assemblyWithString:(NSString *)s {
++ (PKAssembly *)assemblyWithString:(NSString *)s {
return [[[self alloc] initWithString:s] autorelease];
}
View
2 src/PKChar.m
@@ -16,7 +16,7 @@
@implementation PKChar
-+ (id)char {
++ (PKChar *)char {
return [[[self alloc] initWithString:nil] autorelease];
}
View
5 src/PKCharacterAssembly.m
@@ -21,6 +21,11 @@ @interface PKAssembly ()
@implementation PKCharacterAssembly
++ (PKCharacterAssembly *)assemblyWithString:(NSString *)s {
+ return (PKCharacterAssembly *)[super assemblyWithString:s];
+}
+
+
- (id)init {
return [self initWithString:nil];
}
View
4 src/PKCollectionParser.m
@@ -15,14 +15,14 @@
#import <ParseKit/PKCollectionParser.h>
@interface PKCollectionParser ()
-+ (id)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
++ (PKCollectionParser *)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
@property (nonatomic, readwrite, retain) NSMutableArray *subparsers;
@end
@implementation PKCollectionParser
-+ (id)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest {
++ (PKCollectionParser *)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest {
PKCollectionParser *cp = [[[self alloc] init] autorelease];
if (p1) {
View
2 src/PKComment.m
@@ -17,7 +17,7 @@
@implementation PKComment
-+ (id)comment {
++ (PKComment *)comment {
return [[[self alloc] initWithString:nil] autorelease];
}
View
6 src/PKDelimitedString.m
@@ -22,17 +22,17 @@ @interface PKDelimitedString ()
@implementation PKDelimitedString
-+ (id)delimitedString {
++ (PKDelimitedString *)delimitedString {
return [self delimitedStringWithStartMarker:nil];
}
-+ (id)delimitedStringWithStartMarker:(NSString *)start {
++ (PKDelimitedString *)delimitedStringWithStartMarker:(NSString *)start {
return [self delimitedStringWithStartMarker:start endMarker:nil];
}
-+ (id)delimitedStringWithStartMarker:(NSString *)start endMarker:(NSString *)end {
++ (PKDelimitedString *)delimitedStringWithStartMarker:(NSString *)start endMarker:(NSString *)end {
PKDelimitedString *ds = [[[self alloc] initWithString:nil] autorelease];
ds.startMarker = start;
ds.endMarker = end;
View
2 src/PKDifference.m
@@ -44,7 +44,7 @@ @interface PKDifference ()
@implementation PKDifference
-+ (id)differenceWithSubparser:(PKParser *)s minus:(PKParser *)m {
++ (PKDifference *)differenceWithSubparser:(PKParser *)s minus:(PKParser *)m {
return [[[self alloc] initWithSubparser:s minus:m] autorelease];
}
View
2 src/PKDigit.m
@@ -17,7 +17,7 @@
@implementation PKDigit
-+ (id)digit {
++ (PKDigit *)digit {
return [[[self alloc] initWithString:nil] autorelease];
}
View
9 src/PKEmailState.m
@@ -35,10 +35,17 @@ - (void)dealloc {
}
+- (void)append:(PKUniChar)ch {
+ lastChar = ch;
+ [super append:ch];
+}
+
+
- (PKToken *)nextTokenFromReader:(PKReader *)r startingWith:(PKUniChar)cin tokenizer:(PKTokenizer *)t {
NSParameterAssert(r);
[self resetWithReader:r];
+ lastChar = PKEOF;
c = cin;
BOOL matched = [self parseNameFromReader:r];
if (matched) {
@@ -51,7 +58,7 @@ - (PKToken *)nextTokenFromReader:(PKReader *)r startingWith:(PKUniChar)cin token
NSString *s = [self bufferedString];
if (matched) {
- if ([s hasSuffix:@"."]) {
+ if ('.' == lastChar) {
s = [s substringToIndex:[s length] - 1];
[r unread];
}
View
2 src/PKEmpty.m
@@ -16,7 +16,7 @@
@implementation PKEmpty
-+ (id)empty {
++ (PKEmpty *)empty {
return [[[self alloc] init] autorelease];
}
View
2 src/PKGrammarParser.h
@@ -79,5 +79,5 @@
@property (nonatomic, retain) PKParser *variableParser;
@property (nonatomic, retain) PKParser *constantParser;
@property (nonatomic, retain, readonly) PKParser *whitespaceParser;
-@property (nonatomic, retain, readonly) PKCollectionParser *optionalWhitespaceParser;
+@property (nonatomic, retain, readonly) PKParser *optionalWhitespaceParser;
@end
View
4 src/PKGrammarParser.m
@@ -462,7 +462,7 @@ - (PKCollectionParser *)cardinalityParser {
self.cardinalityParser = [PKSequence sequence];
cardinalityParser.name = @"cardinality";
- PKTrack *commaNum = [PKSequence sequence];
+ PKSequence *commaNum = [PKSequence sequence];
[commaNum add:self.optionalWhitespaceParser];
[commaNum add:[[PKSymbol symbolWithString:@","] discard]];
[commaNum add:self.optionalWhitespaceParser];
@@ -610,7 +610,7 @@ - (PKParser *)whitespaceParser {
}
-- (PKCollectionParser *)optionalWhitespaceParser {
+- (PKParser *)optionalWhitespaceParser {
return [PKRepetition repetitionWithSubparser:self.whitespaceParser];
}
View
8 src/PKIntersection.m
@@ -44,20 +44,20 @@ - (NSSet *)allMatchesFor:(NSSet *)inAssemblies;
@end
@interface PKCollectionParser ()
-+ (id)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
++ (PKCollectionParser *)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
@end
@implementation PKIntersection
-+ (id)intersection {
++ (PKIntersection *)intersection {
return [self intersectionWithSubparsers:nil];
}
-+ (id)intersectionWithSubparsers:(PKParser *)p1, ... {
++ (PKIntersection *)intersectionWithSubparsers:(PKParser *)p1, ... {
va_list vargs;
va_start(vargs, p1);
- PKIntersection *inter = [self collectionParserWithFirst:p1 rest:vargs];
+ PKIntersection *inter = (PKIntersection *)[self collectionParserWithFirst:p1 rest:vargs];
va_end(vargs);
return inter;
}
View
2 src/PKLetter.m
@@ -17,7 +17,7 @@
@implementation PKLetter
-+ (id)letter {
++ (PKLetter *)letter {
return [[[self alloc] initWithString:nil] autorelease];
}
View
2 src/PKLiteral.m
@@ -21,7 +21,7 @@ @interface PKLiteral ()
@implementation PKLiteral
-+ (id)literalWithString:(NSString *)s {
++ (PKLiteral *)literalWithString:(NSString *)s {
return [[[self alloc] initWithString:s] autorelease];
}
View
2 src/PKNegation.m
@@ -28,7 +28,7 @@ @interface PKNegation ()
@implementation PKNegation
-+ (id)negationWithSubparser:(PKParser *)s {
++ (PKNegation *)negationWithSubparser:(PKParser *)s {
return [[[self alloc] initWithSubparser:s] autorelease];
}
View
2 src/PKNumber.m
@@ -17,7 +17,7 @@
@implementation PKNumber
-+ (id)number {
++ (PKNumber *)number {
return [[[self alloc] initWithString:nil] autorelease];
}
View
2 src/PKParser.m
@@ -33,7 +33,7 @@ - (void)setTokenizer:(PKTokenizer *)t;
@implementation PKParser
-+ (id)parser {
++ (PKParser *)parser {
return [[[self alloc] init] autorelease];
}
View
4 src/PKParserFactory.m
@@ -146,7 +146,7 @@ - (void)didMatchNegation:(PKAssembly *)a;
@implementation PKParserFactory
-+ (id)factory {
++ (PKParserFactory *)factory {
return [[[PKParserFactory alloc] init] autorelease];
}
@@ -790,7 +790,7 @@ - (void)didMatchVariable:(PKAssembly *)a {
// if its not there, or still a token array, just spoof it with a sequence
NSMutableDictionary *d = a.target;
p = [d objectForKey:parserName];
- if (![p isKindOfClass:[PKParser parser]]) {
+ if (![p isKindOfClass:[PKParser class]]) {
p = [PKSequence sequence];
}
} else {
View
4 src/PKPattern.m
@@ -17,12 +17,12 @@
@implementation PKPattern
-+ (id)patternWithString:(NSString *)s {
++ (PKPattern *)patternWithString:(NSString *)s {
return [self patternWithString:s options:PKPatternOptionsNone];
}
-+ (id)patternWithString:(NSString *)s options:(PKPatternOptions)opts {
++ (PKPattern *)patternWithString:(NSString *)s options:(PKPatternOptions)opts {
return [[[self alloc] initWithString:s options:opts] autorelease];
}
View
2 src/PKQuotedString.m
@@ -17,7 +17,7 @@
@implementation PKQuotedString
-+ (id)quotedString {
++ (PKQuotedString *)quotedString {
return [[[self alloc] initWithString:nil] autorelease];
}
View
2 src/PKRepetition.m
@@ -25,7 +25,7 @@ @interface PKRepetition ()
@implementation PKRepetition
-+ (id)repetitionWithSubparser:(PKParser *)p {
++ (PKRepetition *)repetitionWithSubparser:(PKParser *)p {
return [[[self alloc] initWithSubparser:p] autorelease];
}
View
8 src/PKSequence.m
@@ -20,20 +20,20 @@ - (NSSet *)matchAndAssemble:(NSSet *)inAssemblies;
@end
@interface PKCollectionParser ()
-+ (id)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
++ (PKCollectionParser *)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
@end
@implementation PKSequence
-+ (id)sequence {
++ (PKSequence *)sequence {
return [self sequenceWithSubparsers:nil];
}
-+ (id)sequenceWithSubparsers:(PKParser *)p1, ... {
++ (PKSequence *)sequenceWithSubparsers:(PKParser *)p1, ... {
va_list vargs;
va_start(vargs, p1);
- PKSequence *seq = [self collectionParserWithFirst:p1 rest:vargs];
+ PKSequence *seq = (PKSequence *)[self collectionParserWithFirst:p1 rest:vargs];
va_end(vargs);
return seq;
}
View
2 src/PKSpecificChar.m
@@ -17,7 +17,7 @@
@implementation PKSpecificChar
-+ (id)specificCharWithChar:(PKUniChar)c {
++ (PKSpecificChar *)specificCharWithChar:(PKUniChar)c {
return [[[self alloc] initWithSpecificChar:c] autorelease];
}
View
4 src/PKSymbol.m
@@ -21,12 +21,12 @@ @interface PKSymbol ()
@implementation PKSymbol
-+ (id)symbol {
++ (PKSymbol *)symbol {
return [[[self alloc] initWithString:nil] autorelease];
}
-+ (id)symbolWithString:(NSString *)s {
++ (PKSymbol *)symbolWithString:(NSString *)s {
return [[[self alloc] initWithString:s] autorelease];
}
View
2 src/PKToken.m
@@ -114,7 +114,7 @@ + (PKToken *)EOFToken {
}
-+ (id)tokenWithTokenType:(PKTokenType)t stringValue:(NSString *)s floatValue:(CGFloat)n {
++ (PKToken *)tokenWithTokenType:(PKTokenType)t stringValue:(NSString *)s floatValue:(CGFloat)n {
return [[[self alloc] initWithTokenType:t stringValue:s floatValue:n] autorelease];
}
View
15 src/PKTokenAssembly.m
@@ -27,18 +27,23 @@ - (NSString *)objectsFrom:(PKUniChar)start to:(PKUniChar)end separatedBy:(NSStri
@implementation PKTokenAssembly
-+ (id)assemblyWithTokenizer:(PKTokenizer *)t {
++ (PKTokenAssembly *)assemblyWithTokenizer:(PKTokenizer *)t {
return [[[self alloc] initWithTokenzier:t] autorelease];
}
-- (id)initWithTokenzier:(PKTokenizer *)t {
- return [self initWithString:t.string tokenzier:t tokenArray:nil];
++ (PKTokenAssembly *)assemblyWithTokenArray:(NSArray *)a {
+ return [[[self alloc] initWithTokenArray:a] autorelease];
}
-+ (id)assemblyWithTokenArray:(NSArray *)a {
- return [[[self alloc] initWithTokenArray:a] autorelease];
++ (PKTokenAssembly *)assemblyWithString:(NSString *)s {
+ return (PKTokenAssembly *)[super assemblyWithString:s];
+}
+
+
+- (id)initWithTokenzier:(PKTokenizer *)t {
+ return [self initWithString:t.string tokenzier:t tokenArray:nil];
}
View
4 src/PKTokenizer.m
@@ -30,12 +30,12 @@ - (PKTokenizerState *)defaultTokenizerStateFor:(PKUniChar)c;
@implementation PKTokenizer
-+ (id)tokenizer {
++ (PKTokenizer *)tokenizer {
return [self tokenizerWithString:nil];
}
-+ (id)tokenizerWithString:(NSString *)s {
++ (PKTokenizer *)tokenizerWithString:(NSString *)s {
return [[[self alloc] initWithString:s] autorelease];
}
View
8 src/PKTrack.m
@@ -31,20 +31,20 @@ - (void)throwTrackExceptionWithPreviousState:(NSSet *)inAssemblies parser:(PKPar
@end
@interface PKCollectionParser ()
-+ (id)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
++ (PKCollectionParser *)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
@end
@implementation PKTrack
-+ (id)track {
++ (PKTrack *)track {
return [self trackWithSubparsers:nil];
}
-+ (id)trackWithSubparsers:(PKParser *)p1, ... {
++ (PKTrack *)trackWithSubparsers:(PKParser *)p1, ... {
va_list vargs;
va_start(vargs, p1);
- PKTrack *tr = [self collectionParserWithFirst:p1 rest:vargs];
+ PKTrack *tr = (PKTrack *)[self collectionParserWithFirst:p1 rest:vargs];
va_end(vargs);
return tr;
}
View
17 src/PKURLState.m
@@ -48,10 +48,17 @@ - (void)dealloc {
}
+- (void)append:(PKUniChar)ch {
+ lastChar = ch;
+ [super append:ch];
+}
+
+
- (PKToken *)nextTokenFromReader:(PKReader *)r startingWith:(PKUniChar)cin tokenizer:(PKTokenizer *)t {
NSParameterAssert(r);
[self resetWithReader:r];
+ lastChar = PKEOF;
c = cin;
BOOL matched = NO;
if (allowsWWWPrefix && 'w' == c) {
@@ -74,13 +81,14 @@ - (PKToken *)nextTokenFromReader:(PKReader *)r startingWith:(PKUniChar)cin token
[self parsePathFromReader:r];
}
+ NSString *s = [self bufferedString];
+
if (PKEOF != c) {
[r unread];
- }
-
- NSString *s = [self bufferedString];
+ }
+
if (matched) {
- if ([s hasSuffix:@"."]) {
+ if ('.' == lastChar || ',' == lastChar) {
s = [s substringToIndex:[s length] - 1];
[r unread];
}
@@ -168,7 +176,6 @@ - (BOOL)parseHostFromReader:(PKReader *)r {
result = hasAtLeastOneChar;
break;
} else if ('/' == c && hasAtLeastOneChar/* && hasDot*/) {
- //[self append:c];
result = YES;
break;
} else {
View
2 src/PKWhitespace.m
@@ -17,7 +17,7 @@
@implementation PKWhitespace
-+ (id)whitespace {
++ (PKWhitespace *)whitespace {
return [[[self alloc] initWithString:nil] autorelease];
}
View
2 src/PKWord.m
@@ -17,7 +17,7 @@
@implementation PKWord
-+ (id)word {
++ (PKWord *)word {
return [[[self alloc] initWithString:nil] autorelease];
}
View
2 test/PKAST.h
@@ -21,7 +21,7 @@
NSMutableArray *children;
}
-+ (id)ASTWithToken:(PKToken *)tok;
++ (PKAST *)ASTWithToken:(PKToken *)tok;
- (id)initWithToken:(PKToken *)tok;
View
2 test/PKAST.m
@@ -21,7 +21,7 @@ @interface PKAST ()
@implementation PKAST
-+ (id)ASTWithToken:(PKToken *)tok {
++ (PKAST *)ASTWithToken:(PKToken *)tok {
return [[[self alloc] initWithToken:tok] autorelease];
}
View
2 test/PKExclusion.h
@@ -18,5 +18,5 @@
}
-+ (id)exclusion;
++ (PKExclusion *)exclusion;
@end
View
2 test/PKExclusion.m
@@ -58,7 +58,7 @@ - (NSSet *)allMatchesFor:(NSSet *)inAssemblies;
@implementation PKExclusion
-+ (id)exclusion {
++ (PKExclusion *)exclusion {
return [[[self alloc] init] autorelease];
}
View
2 test/PKParseTree.h
@@ -24,7 +24,7 @@
id userInfo;
BOOL matched;
}
-+ (id)parseTree;
++ (PKParseTree *)parseTree;
- (PKRuleNode *)addChildRule:(NSString *)name;
- (PKTokenNode *)addChildToken:(PKToken *)tok;
View
2 test/PKParseTree.m
@@ -23,7 +23,7 @@ @interface PKParseTree ()
@implementation PKParseTree
-+ (id)parseTree {
++ (PKParseTree *)parseTree {
return [[[self alloc] init] autorelease];
}
View
2 test/PKRuleNode.h
@@ -18,7 +18,7 @@
NSString *name;
}
-+ (id)ruleNodeWithName:(NSString *)s;
++ (PKRuleNode *)ruleNodeWithName:(NSString *)s;
// designated initializer
- (id)initWithName:(NSString *)s;
View
2 test/PKRuleNode.m
@@ -20,7 +20,7 @@ @interface PKRuleNode ()
@implementation PKRuleNode
-+ (id)ruleNodeWithName:(NSString *)s {
++ (PKRuleNode *)ruleNodeWithName:(NSString *)s {
return [[[self alloc] initWithName:s] autorelease];
}
View
2 test/PKTokenNode.h
@@ -20,7 +20,7 @@
PKToken *token;
}
-+ (id)tokenNodeWithToken:(PKToken *)tok;
++ (PKTokenNode *)tokenNodeWithToken:(PKToken *)tok;
// designated initializer
- (id)initWithToken:(PKToken *)tok;
View
2 test/PKTokenNode.m
@@ -21,7 +21,7 @@ @interface PKTokenNode ()
@implementation PKTokenNode
-+ (id)tokenNodeWithToken:(PKToken *)s {
++ (PKTokenNode *)tokenNodeWithToken:(PKToken *)s {
return [[[self alloc] initWithToken:s] autorelease];
}
View
16 test/SRGSParser.h
@@ -17,7 +17,7 @@
@interface SRGSParser : PKSequence {
PKCollectionParser *selfIdentHeader;
PKCollectionParser *ruleName;
- PKCollectionParser *tagFormat;
+ PKParser *tagFormat;
PKCollectionParser *lexiconURI;
PKCollectionParser *weight;
PKCollectionParser *repeat;
@@ -47,17 +47,17 @@
PKCollectionParser *specialRuleRef;
PKCollectionParser *repeatOperator;
- PKCollectionParser *baseURI;
+ PKParser *baseURI;
PKCollectionParser *languageCode;
- PKCollectionParser *ABNF_URI;
- PKCollectionParser *ABNF_URI_with_Media_Type;
+ PKParser *ABNF_URI;
+ PKParser *ABNF_URI_with_Media_Type;
}
- (id)parse:(NSString *)s;
- (PKAssembly *)assemblyWithString:(NSString *)s;
@property (nonatomic, retain) PKCollectionParser *selfIdentHeader;
@property (nonatomic, retain) PKCollectionParser *ruleName;
-@property (nonatomic, retain) PKCollectionParser *tagFormat;
+@property (nonatomic, retain) PKParser *tagFormat;
@property (nonatomic, retain) PKCollectionParser *lexiconURI;
@property (nonatomic, retain) PKCollectionParser *weight;
@property (nonatomic, retain) PKCollectionParser *repeat;
@@ -87,8 +87,8 @@
@property (nonatomic, retain) PKCollectionParser *specialRuleRef;
@property (nonatomic, retain) PKCollectionParser *repeatOperator;
-@property (nonatomic, retain) PKCollectionParser *baseURI;
+@property (nonatomic, retain) PKParser *baseURI;
@property (nonatomic, retain) PKCollectionParser *languageCode;
-@property (nonatomic, retain) PKCollectionParser *ABNF_URI;
-@property (nonatomic, retain) PKCollectionParser *ABNF_URI_with_Media_Type;
+@property (nonatomic, retain) PKParser *ABNF_URI;
+@property (nonatomic, retain) PKParser *ABNF_URI_with_Media_Type;
@end
View
8 test/SRGSParser.m
@@ -132,7 +132,7 @@ - (PKCollectionParser *)ruleName {
}
//TagFormat ::= ABNF_URI
-- (PKCollectionParser *)tagFormat {
+- (PKParser *)tagFormat {
if (!tagFormat) {
self.tagFormat = self.ABNF_URI;
}
@@ -608,7 +608,7 @@ - (PKCollectionParser *)repeatOperator {
//BaseURI ::= ABNF_URI
-- (PKCollectionParser *)baseURI {
+- (PKParser *)baseURI {
if (!baseURI) {
self.baseURI = [PKWord word];
}
@@ -628,15 +628,15 @@ - (PKCollectionParser *)languageCode {
}
-- (PKCollectionParser *)ABNF_URI {
+- (PKParser *)ABNF_URI {
if (!ABNF_URI) {
self.ABNF_URI = [PKWord word];
}
return ABNF_URI;
}
-- (PKCollectionParser *)ABNF_URI_with_Media_Type {
+- (PKParser *)ABNF_URI_with_Media_Type {
if (!ABNF_URI_with_Media_Type) {
self.ABNF_URI_with_Media_Type = [PKWord word];
}
View
2 test/TDArithmeticParserTest.m
@@ -17,7 +17,7 @@
@implementation TDArithmeticParserTest
- (void)setUp {
- p = [TDArithmeticParser parser];
+ p = (TDArithmeticParser *)[TDArithmeticParser parser];
}
View
4 test/TDBlob.h
@@ -17,7 +17,7 @@
@interface TDBlob : PKTerminal {
}
-+ (id)blob;
++ (TDBlob *)blob;
-+ (id)blobWithStartMarker:(NSString *)s;
++ (TDBlob *)blobWithStartMarker:(NSString *)s;
@end
View
4 test/TDBlob.m
@@ -18,12 +18,12 @@
@implementation TDBlob
-+ (id)blob {
++ (TDBlob *)blob {
return [self blobWithStartMarker:nil];
}
-+ (id)blobWithStartMarker:(NSString *)s {
++ (TDBlob *)blobWithStartMarker:(NSString *)s {
return [[[self alloc] initWithString:s] autorelease];
}
View
8 test/TDJavaScriptParser.h
@@ -23,14 +23,14 @@
PKCollectionParser *unaryOpParser;
PKCollectionParser *multiplicativeOpParser;
- PKCollectionParser *programParser;
+ PKParser *programParser;
PKCollectionParser *elementParser;
PKCollectionParser *funcParser;
PKCollectionParser *paramListOptParser;
PKCollectionParser *paramListParser;
PKCollectionParser *commaIdentifierParser;
PKCollectionParser *compoundStmtParser;
- PKCollectionParser *stmtsParser;
+ PKParser *stmtsParser;
PKCollectionParser *stmtParser;
PKCollectionParser *ifStmtParser;
PKCollectionParser *ifElseStmtParser;
@@ -191,14 +191,14 @@
@property (nonatomic, retain) PKCollectionParser *unaryOpParser;
@property (nonatomic, retain) PKCollectionParser *multiplicativeOpParser;
-@property (nonatomic, retain) PKCollectionParser *programParser;
+@property (nonatomic, retain) PKParser *programParser;
@property (nonatomic, retain) PKCollectionParser *elementParser;
@property (nonatomic, retain) PKCollectionParser *funcParser;
@property (nonatomic, retain) PKCollectionParser *paramListOptParser;
@property (nonatomic, retain) PKCollectionParser *paramListParser;
@property (nonatomic, retain) PKCollectionParser *commaIdentifierParser;
@property (nonatomic, retain) PKCollectionParser *compoundStmtParser;
-@property (nonatomic, retain) PKCollectionParser *stmtsParser;
+@property (nonatomic, retain) PKParser *stmtsParser;
@property (nonatomic, retain) PKCollectionParser *stmtParser;
@property (nonatomic, retain) PKCollectionParser *ifStmtParser;
@property (nonatomic, retain) PKCollectionParser *ifElseStmtParser;
View
4 test/TDJavaScriptParser.m
@@ -377,7 +377,7 @@ - (PKCollectionParser *)multiplicativeOpParser {
// Element Program
//
//program = element*;
-- (PKCollectionParser *)programParser {
+- (PKParser *)programParser {
if (!programParser) {
self.programParser = [PKRepetition repetitionWithSubparser:self.elementParser];
programParser.name = @"program";
@@ -482,7 +482,7 @@ - (PKCollectionParser *)compoundStmtParser {
// Statement Statements
//
//stmts = stmt*;
-- (PKCollectionParser *)stmtsParser {
+- (PKParser *)stmtsParser {
if (!stmtsParser) {
self.stmtsParser = [PKRepetition repetitionWithSubparser:self.stmtParser];
stmtsParser.name = @"stmts";
View
2 test/TDJavaScriptParserTest.m
@@ -17,7 +17,7 @@
@implementation TDJavaScriptParserTest
- (void)setUp {
- jsp = [TDJavaScriptParser parser];
+ jsp = (TDJavaScriptParser *)[TDJavaScriptParser parser];
}
View
4 test/TDJsonParser.m
@@ -144,7 +144,7 @@ - (PKCollectionParser *)arrayParser {
// content = Empty | actualArray
// actualArray = value commaValue*
- PKTrack *actualArray = [PKTrack sequence];
+ PKTrack *actualArray = [PKTrack track];
[actualArray add:self.valueParser];
[actualArray add:[PKRepetition repetitionWithSubparser:self.commaValueParser]];
@@ -174,7 +174,7 @@ - (PKCollectionParser *)objectParser {
// property = QuotedString ':' value
// commaProperty = ',' property
- PKTrack *actualObject = [PKTrack sequence];
+ PKTrack *actualObject = [PKTrack track];
[actualObject add:self.propertyParser];
[actualObject add:[PKRepetition repetitionWithSubparser:self.commaPropertyParser]];
View
2 test/TDJsonParserTest.m
@@ -19,7 +19,7 @@
@implementation TDJsonParserTest
- (void)setUp {
- p = [TDJsonParser parser];
+ p = (TDJsonParser *)[TDJsonParser parser];
}
View
2 test/TDLetterTest.h
@@ -18,7 +18,7 @@
@interface TDLetterTest : SenTestCase {
NSString *s;
PKCharacterAssembly *a;
- PKChar *p;
+ PKLetter *p;
PKAssembly *result;
}
View
4 test/TDNSPredicateBuilder.h
@@ -42,7 +42,7 @@
PKParser *quotedStringParser;
PKCollectionParser *unquotedStringParser;
PKCollectionParser *reservedWordParser;
- PKCollectionParser *nonReservedWordParser;
+ PKParser *nonReservedWordParser;
PKPattern *reservedWordPattern;
PKParser *numberParser;
@@ -76,7 +76,7 @@
@property (nonatomic, retain) PKParser *quotedStringParser;
@property (nonatomic, retain) PKCollectionParser *unquotedStringParser;
@property (nonatomic, retain) PKCollectionParser *reservedWordParser;
-@property (nonatomic, retain) PKCollectionParser *nonReservedWordParser;
+@property (nonatomic, retain) PKParser *nonReservedWordParser;
@property (nonatomic, retain) PKPattern *reservedWordPattern;
@property (nonatomic, retain) PKParser *numberParser;
@end
View
2 test/TDNSPredicateBuilder.m
@@ -389,7 +389,7 @@ - (PKCollectionParser *)reservedWordParser {
// nonReservedWord = Word
-- (PKCollectionParser *)nonReservedWordParser {
+- (PKParser *)nonReservedWordParser {
if (!nonReservedWordParser) {
self.nonReservedWordParser = [PKDifference differenceWithSubparser:[PKWord word] minus:self.reservedWordParser];
nonReservedWordParser.name = @"nonReservedWord";
View
2 test/TDPatternTest.h
@@ -16,7 +16,7 @@
@interface TDPatternTest : SenTestCase {
PKTokenizer *t;
- PKPattern *p;
+ PKParser *p;
PKIntersection *inter;
PKAssembly *a;
NSString *s;
View
2 test/TDRegularParser.m
@@ -50,7 +50,7 @@ - (void)dealloc {
+ (id)parserFromGrammar:(NSString *)s {
- TDRegularParser *p = [TDRegularParser parser];
+ TDRegularParser *p = (TDRegularParser *)[TDRegularParser parser];
PKAssembly *a = [PKCharacterAssembly assemblyWithString:s];
a = [p completeMatchFor:a];
return [a pop];
View
2 test/TDRegularParserTest.m
@@ -17,7 +17,7 @@
@implementation TDRegularParserTest
- (void)setUp {
- p = [TDRegularParser parser];
+ p = (TDRegularParser *)[TDRegularParser parser];
}
View
2 test/TDSpecificCharTest.h
@@ -18,7 +18,7 @@
@interface TDSpecificCharTest : SenTestCase {
NSString *s;
PKCharacterAssembly *a;
- PKChar *p;
+ PKSpecificChar *p;
PKAssembly *result;
}
View
4 test/TDTestScaffold.m
@@ -14,8 +14,8 @@
#import "TDTestScaffold.h"
-#define RUN_ALL_TEST_CASES 0
-#define SOLO_TEST_CASE @"TDTwitterStateTest"
+#define RUN_ALL_TEST_CASES 1
+#define SOLO_TEST_CASE @"TDURLStateTest"
@interface SenTestSuite (TDAdditions)
- (void)addSuitesForClassNames:(NSArray *)classNames;
View
4 test/TDTokenizerTest.m
@@ -27,15 +27,15 @@ - (void)tearDown {
- (void)testBlastOff {
s = @"\"It's 123 blast-off!\", she said, // watch out!\n"
- @"and <= 3 'ticks' later /* wince */, it's blast-off!";
+ @"and <= 3 'ticks' later /* wince */, it's blast-off (to http://google.com)!";
t = [PKTokenizer tokenizerWithString:s];
PKToken *eof = [PKToken EOFToken];
PKToken *tok = nil;
//NSLog(@"\n\n starting!!! \n\n");
while ((tok = [t nextToken]) != eof) {
- //NSLog(@"(%@)", tok.stringValue);
+ NSLog(@"(%@)", tok.stringValue);
}
//NSLog(@"\n\n done!!! \n\n");
View
50 test/TDURLStateTest.m
@@ -100,6 +100,36 @@ - (void)testFooComBlahBlahWiki {
}
+- (void)testFooComBlahBlahDotHtml {
+ s = @"http://foo.com/blah_blah.html";
+ t.string = s;
+
+ tok = [t nextToken];
+
+ TDTrue(tok.isURL);
+ TDEqualObjects(tok.stringValue, s);
+ TDEquals(tok.floatValue, (CGFloat)0.0);
+
+ tok = [t nextToken];
+ TDEqualObjects(tok, [PKToken EOFToken]);
+}
+
+
+- (void)testFooComBlahBlahWikiDotHtml {
+ s = @"http://foo.com/blah_blah_(wikipedia).html";
+ t.string = s;
+
+ tok = [t nextToken];
+
+ TDTrue(tok.isURL);
+ TDEqualObjects(tok.stringValue, s);
+ TDEquals(tok.floatValue, (CGFloat)0.0);
+
+ tok = [t nextToken];
+ TDEqualObjects(tok, [PKToken EOFToken]);
+}
+
+
- (void)testSomethingLikeFooComBlahBlahWiki {
s = @"(Something like http://foo.com/blah_blah_(wikipedia))";
t.string = s;
@@ -154,6 +184,26 @@ - (void)testFooComBlahBlahDot {
}
+- (void)testFooComBlahBlahComma {
+ s = @"http://foo.com/blah_blah,";
+ t.string = s;
+
+ tok = [t nextToken];
+
+ TDTrue(tok.isURL);
+ TDEqualObjects(tok.stringValue, @"http://foo.com/blah_blah");
+ TDEquals(tok.floatValue, (CGFloat)0.0);
+
+ tok = [t nextToken];
+ TDTrue(tok.isSymbol);
+ TDEqualObjects(tok.stringValue, @",");
+ TDEquals(tok.floatValue, (CGFloat)0.0);
+
+ tok = [t nextToken];
+ TDEqualObjects(tok, [PKToken EOFToken]);
+}
+
+
- (void)testFooComBlahBlahSlashDot {
s = @"http://foo.com/blah_blah/.";
t.string = s;
View
2 test/TDXmlTokenizerTest.m
@@ -48,7 +48,7 @@ - (void)testAppleBoss {
[s add:[TDXmlEndTag endTagWithString:@"result"]];
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"small-xml-file" ofType:@"xml"];
- TDXmlTokenAssembly *a = [TDXmlTokenAssembly assemblyWithString:path];
+ TDXmlTokenAssembly *a = (TDXmlTokenAssembly *)[TDXmlTokenAssembly assemblyWithString:path];
PKAssembly *result = [s bestMatchFor:a];
NSLog(@"\n\n\n result: %@ \n\n\n", result);

0 comments on commit 32bd9bf

Please sign in to comment.