Skip to content

Commit

Permalink
added comments and formalising resposibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
rodnaph committed Aug 9, 2011
1 parent 37d5a01 commit 8b01c80
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion objc-lint.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@
DC206A5313F07BE2001661CD /* Renderer */ = {
isa = PBXGroup;
children = (
DC1C5D1013F19E1000527196 /* OCLRenderer.h */,
DC1C5D0D13F19DD800527196 /* OCLConsoleRenderer.h */,
DC1C5D0E13F19DD800527196 /* OCLConsoleRenderer.m */,
DC1C5D1013F19E1000527196 /* OCLRenderer.h */,
);
name = Renderer;
sourceTree = "<group>";
Expand Down
9 changes: 6 additions & 3 deletions objc-lint/OCLConsoleRenderer.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@

#import "OCLConsoleRenderer.h"
#import "OCLError.h"

@implementation OCLConsoleRenderer

- (void)renderErrors:(NSArray *)errors {

NSLog( @"Renderer..." );

if ( [errors count] > 0 ) {
NSLog( @"Errors..." );

for ( OCLError *error in errors ) {
NSLog( @"ERROR" );
}

}

}
Expand Down
20 changes: 16 additions & 4 deletions objc-lint/OCLDirectoryParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@interface OCLDirectoryParser (Private)

// parse the file for lint errors and return them
- (NSArray *)parseFile:(NSString *)filePath;

@end
Expand Down Expand Up @@ -63,14 +64,25 @@ - (void)addRule:(id<OCLRule>)rule {
- (NSArray *)parseFile:(NSString *)filePath {

OCLTokeniser *tokeniser = [[[OCLTokeniser alloc] initWithPath:filePath] autorelease];
NSMutableArray *fileErrors = [[[NSMutableArray alloc] init] autorelease];
NSMutableArray *errors = [[[NSMutableArray alloc] init] autorelease];
NSArray *tokens = [tokeniser getAllTokens];
int tokenCount = sizeof(tokens) / sizeof(OCLToken *);

for ( OCLToken *token in tokens ) {
// @todo dispatch tokens to parser rules
for ( int i=0; i<tokenCount; i++ ) {

for ( id <OCLRule> rule in rules_ ) {

NSArray *ruleErrors = [rule handleToken:tokens atIndex:i];

if ( ruleErrors != nil ) {
[errors addObjectsFromArray:ruleErrors];
}

}

}

return fileErrors;
return errors;

}

Expand Down
1 change: 1 addition & 0 deletions objc-lint/OCLRenderer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

@protocol OCLRenderer <NSObject>

// render the specified errors, no output if no errors
- (void)renderErrors:(NSArray *)errors;

@end
6 changes: 6 additions & 0 deletions objc-lint/OCLRuleUnderscoredIvars.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@

@implementation OCLRuleUnderscoredIvars

- (NSArray *)handleToken:(NSArray *)tokens atIndex:(int)index {



}

@end
3 changes: 3 additions & 0 deletions objc-lint/OCLTokeniser.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ - (int)read;
// put a character back to be read again
- (void)putBack:(int)chr;

// YES if chr is A-Za-z_, NO otherwise
- (BOOL)isAlpha:(int)chr;

// YES if chr is A-Za-z0-9_, NO otherwise
- (BOOL)isAlphaNumeric:(int)chr;

// YES if chr is 0-9, NO otherwise
- (BOOL)isNumeric:(int)chr;

@end
Expand Down
6 changes: 3 additions & 3 deletions objc-lint/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

int main ( int argc, const char *argv[] ) {

if ( argc != 1 ) {
if ( argc < 2 ) {
NSLog( @"Usage: objc-ling /path/to/src" );
exit( 1 );
}

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *srcPath = @"./"; // argv[ 0 ];
NSString *srcPath = [[[NSString alloc] initWithCString:argv[1] encoding:NSUTF8StringEncoding] autorelease];
OCLDirectoryParser *parser = [[[OCLDirectoryParser alloc] init] autorelease];
OCLConsoleRenderer *renderer = [[[OCLConsoleRenderer alloc] init] autorelease];
NSArray *errors = [parser parseDirectory:srcPath];
Expand Down

0 comments on commit 8b01c80

Please sign in to comment.