Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions PEGKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
3D0466A918E1D9770022A1BC /* OCMock.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D37214CA18DF3B0100525058 /* OCMock.framework */; };
4032A4C01C3115D0005442DD /* PKToken+Subclass.h in Headers */ = {isa = PBXBuildFile; fileRef = 4032A4BF1C3115D0005442DD /* PKToken+Subclass.h */; settings = {ATTRIBUTES = (Public, ); }; };
4032A4C21C312D78005442DD /* PKTokenizerState+Subclass.h in Headers */ = {isa = PBXBuildFile; fileRef = 4032A4C11C312D78005442DD /* PKTokenizerState+Subclass.h */; settings = {ATTRIBUTES = (Public, ); }; };
D306298218E1ED5D00EF745E /* TDTestScaffold.m in Sources */ = {isa = PBXBuildFile; fileRef = D306298118E1ED5D00EF745E /* TDTestScaffold.m */; };
D3083AB61705F05C00DA6F95 /* elementsAssign.grammar in Resources */ = {isa = PBXBuildFile; fileRef = D3083AB51705F05C00DA6F95 /* elementsAssign.grammar */; };
D3083AB91705F09B00DA6F95 /* ElementAssignParserTest.m in Sources */ = {isa = PBXBuildFile; fileRef = D3083AB81705F09B00DA6F95 /* ElementAssignParserTest.m */; };
Expand Down Expand Up @@ -478,6 +480,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
4032A4BF1C3115D0005442DD /* PKToken+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "PKToken+Subclass.h"; path = "include/PEGKit/PKToken+Subclass.h"; sourceTree = "<group>"; };
4032A4C11C312D78005442DD /* PKTokenizerState+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "PKTokenizerState+Subclass.h"; path = "include/PEGKit/PKTokenizerState+Subclass.h"; sourceTree = "<group>"; };
D302272A17020F9400594F16 /* PGClassImplementationTemplate.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = PGClassImplementationTemplate.txt; path = res/PGClassImplementationTemplate.txt; sourceTree = "<group>"; };
D306298118E1ED5D00EF745E /* TDTestScaffold.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TDTestScaffold.m; path = test/TDTestScaffold.m; sourceTree = "<group>"; };
D3083AB51705F05C00DA6F95 /* elementsAssign.grammar */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = elementsAssign.grammar; path = res/elementsAssign.grammar; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1161,10 +1165,12 @@
children = (
D3C221C30FFE8C07004514FE /* PKToken.h */,
D34BAE950FF9D20900D7773A /* PKToken.m */,
4032A4BF1C3115D0005442DD /* PKToken+Subclass.h */,
D3C221C90FFE8C15004514FE /* PKTokenizer.h */,
D34BAE990FF9D20900D7773A /* PKTokenizer.m */,
D3C221CC0FFE8C1B004514FE /* PKTokenizerState.h */,
D34BAE9B0FF9D20900D7773A /* PKTokenizerState.m */,
4032A4C11C312D78005442DD /* PKTokenizerState+Subclass.h */,
);
name = tokenizer;
sourceTree = SOURCE_ROOT;
Expand Down Expand Up @@ -1538,7 +1544,9 @@
D3A29E4118E8516F00DC591E /* PKParser+Subclass.h in Headers */,
D317C0E418D1F4050036BE75 /* PKMultiLineCommentState.h in Headers */,
D317C0E718D1F4050036BE75 /* PKTwitterState.h in Headers */,
4032A4C21C312D78005442DD /* PKTokenizerState+Subclass.h in Headers */,
D317C0DF18D1F4050036BE75 /* PKWordState.h in Headers */,
4032A4C01C3115D0005442DD /* PKToken+Subclass.h in Headers */,
D317C0D618D1F4050036BE75 /* PKAssembly.h in Headers */,
D317C0E518D1F4050036BE75 /* PKEmailState.h in Headers */,
D317C0E818D1F4050036BE75 /* PKHashtagState.h in Headers */,
Expand Down
29 changes: 29 additions & 0 deletions include/PEGKit/PKToken+Subclass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// The MIT License (MIT)
//
// Copyright (c) 2014 Todd Ditchendorf
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <PEGKit/PKToken.h>

@interface PKToken ()

@property (nonatomic, readwrite) NSUInteger offset;

@end
36 changes: 36 additions & 0 deletions include/PEGKit/PKTokenizerState+Subclass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// The MIT License (MIT)
//
// Copyright (c) 2014 Todd Ditchendorf
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

@interface PKTokenizerState ()

- (void)resetWithReader:(PKReader *)r;

- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;

- (void)append:(PKUniChar)c;
- (void)appendString:(NSString *)s;

- (NSString *)bufferedString;

@property (nonatomic) NSUInteger offset;

@end
13 changes: 2 additions & 11 deletions src/PKCommentState.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,13 @@

#import <PEGKit/PKCommentState.h>
#import <PEGKit/PKTokenizer.h>
#import <PEGKit/PKToken.h>
#import <PEGKit/PKTokenizerState+Subclass.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKSingleLineCommentState.h>
#import <PEGKit/PKMultiLineCommentState.h>
#import "PKSymbolRootNode.h"

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;
@property (nonatomic) NSUInteger offset;
@end

@interface PKCommentState ()
@property (nonatomic, retain) PKSymbolRootNode *rootNode;
@property (nonatomic, retain) PKSingleLineCommentState *singleLineState;
Expand Down
17 changes: 2 additions & 15 deletions src/PKDelimitState.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,19 @@
#import <PEGKit/PKDelimitState.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKTokenizer.h>
#import <PEGKit/PKToken.h>
#import <PEGKit/PKTokenizerState+Subclass.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKWhitespaceState.h>
#import <PEGKit/PKTypes.h>
#import "PKSymbolRootNode.h"

#import "PKDelimitDescriptorCollection.h"
#import "PKDelimitDescriptor.h"

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizer ()
- (NSInteger)tokenKindForStringValue:(NSString *)str;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (void)append:(PKUniChar)c;
- (void)appendString:(NSString *)s;
- (NSString *)bufferedString;
- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;
- (void)addStartMarker:(NSString *)start endMarker:(NSString *)end allowedCharacterSet:(NSCharacterSet *)set tokenKind:(NSInteger)kind;
@property (nonatomic) NSUInteger offset;
@end

@interface PKDelimitState ()
@property (nonatomic, retain) PKSymbolRootNode *rootNode;
@property (nonatomic, retain) PKDelimitDescriptorCollection *collection;
Expand Down
15 changes: 2 additions & 13 deletions src/PKEmailState.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,10 @@
#import <PEGKit/PKEmailState.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKTokenizer.h>
#import <PEGKit/PKToken.h>
#import <PEGKit/PKTokenizerState+Subclass.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKTypes.h>

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (void)append:(PKUniChar)c;
- (NSString *)bufferedString;
- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;
@property (nonatomic) NSUInteger offset;
@end

@interface PKEmailState ()
- (BOOL)parseNameFromReader:(PKReader *)r;
- (BOOL)parseHostFromReader:(PKReader *)r;
Expand Down
19 changes: 2 additions & 17 deletions src/PKHashtagState.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,8 @@
#import <PEGKit/PKHashtagState.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKTokenizer.h>
#import <PEGKit/PKToken.h>

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (void)append:(PKUniChar)c;
- (NSString *)bufferedString;
- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;
@property (nonatomic) NSUInteger offset;
@end

@interface PKHashtagState ()

@end
#import <PEGKit/PKTokenizerState+Subclass.h>
#import <PEGKit/PKToken+Subclass.h>

@implementation PKHashtagState

Expand Down
15 changes: 2 additions & 13 deletions src/PKMultiLineCommentState.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,11 @@
#import <PEGKit/PKCommentState.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKTokenizer.h>
#import <PEGKit/PKToken.h>
#import <PEGKit/PKTokenizerState+Subclass.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKTypes.h>
#import "PKSymbolRootNode.h"

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (void)append:(PKUniChar)c;
- (void)appendString:(NSString *)s;
- (NSString *)bufferedString;
@property (nonatomic) NSUInteger offset;
@end

@interface PKCommentState ()
@property (nonatomic, retain) PKSymbolRootNode *rootNode;
@end
Expand Down
24 changes: 2 additions & 22 deletions src/PKNumberState.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,14 @@

#import <PEGKit/PKNumberState.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKToken.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKTokenizer.h>
#import <PEGKit/PKTokenizerState+Subclass.h>
#import <PEGKit/PKSymbolState.h>
#import <PEGKit/PKWhitespaceState.h>
#import <PEGKit/PKTypes.h>
#import "PKSymbolRootNode.h"

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;

- (PKUniChar)checkForPositiveNegativeFromReader:(PKReader *)r startingWith:(PKUniChar)cin;
- (PKUniChar)checkForPrefixFromReader:(PKReader *)r startingWith:(PKUniChar)cin;
- (PKUniChar)checkForSuffixFromReader:(PKReader *)r startingWith:(PKUniChar)cin tokenizer:(PKTokenizer *)t;
- (void)parseAllDigitsFromReader:(PKReader *)r startingWith:(PKUniChar)cin;
- (PKToken *)checkForErroneousMatchFromReader:(PKReader *)r tokenizer:(PKTokenizer *)t;
- (void)applySuffixFromReader:(PKReader *)r;

- (void)append:(PKUniChar)c;
- (void)appendString:(NSString *)s;
- (NSString *)bufferedString;
@end

@interface PKNumberState ()
- (double)absorbDigitsFromReader:(PKReader *)r;
- (double)value;
Expand All @@ -71,7 +52,6 @@ - (BOOL)isValidSeparator:(PKUniChar)sepChar forRadix:(NSUInteger)radix;

@property (nonatomic, retain) NSString *prefix;
@property (nonatomic, retain) NSString *suffix;
@property (nonatomic) NSUInteger offset;
@end

@implementation PKNumberState {
Expand Down
15 changes: 2 additions & 13 deletions src/PKQuoteState.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,10 @@

#import <PEGKit/PKQuoteState.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKToken.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKTokenizerState+Subclass.h>
#import <PEGKit/PKTypes.h>

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (void)append:(PKUniChar)c;
- (NSString *)bufferedString;
- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;
@property (nonatomic) NSUInteger offset;
@end

@implementation PKQuoteState

- (instancetype)init {
Expand Down
15 changes: 2 additions & 13 deletions src/PKSingleLineCommentState.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,10 @@
#import <PEGKit/PKCommentState.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKTokenizer.h>
#import <PEGKit/PKToken.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKTokenizerState+Subclass.h>
#import <PEGKit/PKTypes.h>

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (void)append:(PKUniChar)c;
- (void)appendString:(NSString *)s;
- (NSString *)bufferedString;
@property (nonatomic) NSUInteger offset;
@end

@interface PKSingleLineCommentState ()
- (void)addStartMarker:(NSString *)start;
- (void)removeStartMarker:(NSString *)start;
Expand Down
13 changes: 2 additions & 11 deletions src/PKSymbolState.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,12 @@
// THE SOFTWARE.

#import <PEGKit/PKSymbolState.h>
#import <PEGKit/PKToken.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKReader.h>
#import <PEGKit/PKTokenizer.h>
#import <PEGKit/PKTokenizerState+Subclass.h>
#import "PKSymbolRootNode.h"

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger offset;
@end

@interface PKTokenizerState ()
- (void)resetWithReader:(PKReader *)r;
- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;
@property (nonatomic) NSUInteger offset;
@end

@interface PKSymbolState ()
- (PKToken *)symbolTokenWith:(PKUniChar)cin;
- (PKToken *)symbolTokenWithSymbol:(NSString *)s;
Expand Down
3 changes: 1 addition & 2 deletions src/PKToken.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <PEGKit/PKToken.h>
#import <PEGKit/PKToken+Subclass.h>
#import <PEGKit/PKTypes.h>
#import "NSString+PEGKitAdditions.h"

Expand Down Expand Up @@ -80,7 +80,6 @@ - (BOOL)isEqual:(id)obj ignoringCase:(BOOL)ignoringCase;
@property (nonatomic, readwrite) PKTokenType tokenType;
@property (nonatomic, readwrite, copy) id value;

@property (nonatomic, readwrite) NSUInteger offset;
@property (nonatomic, readwrite) NSUInteger lineNumber;
@end

Expand Down
5 changes: 1 addition & 4 deletions src/PKTokenizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
// THE SOFTWARE.

#import <PEGKit/PEGKit.h>
#import <PEGKit/PKTokenizerState+Subclass.h>

#define STATE_COUNT 256

@interface PKToken ()
@property (nonatomic, readwrite) NSUInteger lineNumber;
@end

@interface PKTokenizerState ()
- (PKTokenizerState *)nextTokenizerStateFor:(PKUniChar)c tokenizer:(PKTokenizer *)t;
@end

@interface PKTokenizer ()
- (instancetype)initWithString:(NSString *)str stream:(NSInputStream *)stm;
- (PKTokenizerState *)tokenizerStateFor:(PKUniChar)c;
Expand Down
Loading