Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transitioned to arc #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
10 changes: 6 additions & 4 deletions CoreParse.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1069,9 +1069,9 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
MACOSX_DEPLOYMENT_TARGET = 10.10;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = "";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = macosx;
VALID_ARCHS = "i386 x86_64 armv7 armv7s";
};
Expand Down Expand Up @@ -1108,9 +1108,9 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
MACOSX_DEPLOYMENT_TARGET = 10.10;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = "";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = macosx;
VALID_ARCHS = "i386 x86_64 armv7 armv7s";
};
Expand All @@ -1120,6 +1120,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down Expand Up @@ -1157,6 +1158,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand Down
10 changes: 1 addition & 9 deletions CoreParse/Built In Parsers/CPJSONParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,13 @@ - (id)init
@"15 boolean ::= 'true';"
@"16 boolean ::= 'false';"
error:NULL];
jsonParser = [[CPSLRParser parserWithGrammar:jsonGrammar] retain];
jsonParser = [CPSLRParser parserWithGrammar:jsonGrammar];
[jsonParser setDelegate:self];
}

return self;
}

- (void)dealloc
{
[jsonTokeniser release];
[jsonParser release];

[super dealloc];
}

- (id<NSObject>)parse:(NSString *)json
{
CPTokenStream *tokenStream = [jsonTokeniser tokenise:json];
Expand Down
2 changes: 1 addition & 1 deletion CoreParse/Grammar/CPGrammar.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,6 @@ typedef enum
/**
* The starting symbol for the grammar.
*/
@property (readwrite,retain) NSString *start;
@property (readwrite,strong) NSString *start;

@end
28 changes: 11 additions & 17 deletions CoreParse/Grammar/CPGrammar.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

@interface CPBNFParserDelegate : NSObject <CPTokeniserDelegate,CPParserDelegate>

@property (readwrite, retain, nonatomic) NSError *err;
@property (readwrite, strong, nonatomic) NSError *err;

@end

Expand Down Expand Up @@ -114,7 +114,7 @@ - (id)parser:(CPParser *)parser didProduceSyntaxTree:(CPSyntaxTree *)syntaxTree
}
else
{
CPRHSItem *newI = [[[CPRHSItem alloc] init] autorelease];
CPRHSItem *newI = [[CPRHSItem alloc] init];
[newI setAlternatives:[NSArray arrayWithObject:[NSArray arrayWithObject:i]]];
[newI setRepeats:NO];
[newI setMayNotExist:NO];
Expand All @@ -127,7 +127,7 @@ - (id)parser:(CPParser *)parser didProduceSyntaxTree:(CPSyntaxTree *)syntaxTree
return [children objectAtIndex:0];
case 13:
{
CPRHSItem *i = [[[CPRHSItem alloc] init] autorelease];
CPRHSItem *i = [[CPRHSItem alloc] init];
[i setAlternatives:[NSArray arrayWithObject:[NSArray arrayWithObject:[children objectAtIndex:0]]]];
NSString *symbol = [(CPKeywordToken *)[children objectAtIndex:1] keyword];
if ([symbol isEqualToString:@"*"])
Expand All @@ -151,7 +151,7 @@ - (id)parser:(CPParser *)parser didProduceSyntaxTree:(CPSyntaxTree *)syntaxTree
return [children objectAtIndex:0];
case 15:
{
CPRHSItem *i = [[[CPRHSItem alloc] init] autorelease];
CPRHSItem *i = [[CPRHSItem alloc] init];
[i setAlternatives:[children objectAtIndex:1]];
[i setRepeats:NO];
[i setMayNotExist:NO];
Expand Down Expand Up @@ -206,7 +206,7 @@ @implementation CPGrammar

+ (id)grammarWithStart:(NSString *)start rules:(NSArray *)rules
{
return [[[self alloc] initWithStart:start rules:rules] autorelease];
return [[self alloc] initWithStart:start rules:rules];
}

- (id)initWithStart:(NSString *)initStart rules:(NSArray *)initRules;
Expand All @@ -225,12 +225,12 @@ - (id)initWithStart:(NSString *)initStart rules:(NSArray *)initRules;

+ (id)grammarWithStart:(NSString *)start backusNaurForm:(NSString *)bnf
{
return [[[self alloc] initWithStart:start backusNaurForm:bnf] autorelease];
return [[self alloc] initWithStart:start backusNaurForm:bnf];
}

+ (id)grammarWithStart:(NSString *)start backusNaurForm:(NSString *)bnf error:(NSError **)error
{
return [[[self alloc] initWithStart:start backusNaurForm:bnf error:error] autorelease];
return [[self alloc] initWithStart:start backusNaurForm:bnf error:error];
}

- (id)initWithStart:(NSString *)initStart backusNaurForm:(NSString *)bnf
Expand All @@ -247,8 +247,8 @@ - (id)initWithStart:(NSString *)initStart backusNaurForm:(NSString *)bnf

- (id)initWithStart:(NSString *)initStart backusNaurForm:(NSString *)bnf error:(NSError **)error
{
CPBNFParserDelegate *del = [[[CPBNFParserDelegate alloc] init] autorelease];
CPTokeniser *tokeniser = [[[CPTokeniser alloc] init] autorelease];
CPBNFParserDelegate *del = [[CPBNFParserDelegate alloc] init];
CPTokeniser *tokeniser = [[CPTokeniser alloc] init];
[tokeniser addTokenRecogniser:[CPKeywordRecogniser recogniserForKeyword:@"::="]];
[tokeniser addTokenRecogniser:[CPKeywordRecogniser recogniserForKeyword:@"@"]];
[tokeniser addTokenRecogniser:[CPKeywordRecogniser recogniserForKeyword:@"<"]];
Expand Down Expand Up @@ -313,9 +313,8 @@ - (id)initWithStart:(NSString *)initStart backusNaurForm:(NSString *)bnf error:(
{
if (NULL != error)
{
*error = [[[del err] copy] autorelease];
*error = [[del err] copy];
}
[self release];
return nil;
}

Expand All @@ -326,14 +325,12 @@ - (id)initWithStart:(NSString *)initStart backusNaurForm:(NSString *)bnf error:(
{
*error = e;
}
[self release];
return nil;
}

NSArray *newRules = [self tidyRightHandSides:initRules error:error];
if (nil == newRules)
{
[self release];
return nil;
}

Expand Down Expand Up @@ -369,10 +366,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder

- (void)dealloc
{
[start release];
[self setRules:nil];

[super dealloc];
}

- (NSSet *)allRules
Expand Down Expand Up @@ -405,7 +399,7 @@ - (NSError *)checkForMissingNonTerminalsInRules:(NSArray *)rules
NSSet *usedNonTerminals = [(CPRHSItem *)item nonTerminalsUsed];
if (![usedNonTerminals isSubsetOfSet:definedNonTerminals])
{
NSMutableSet *mutableUsedNonTerminals = [[usedNonTerminals mutableCopy] autorelease];
NSMutableSet *mutableUsedNonTerminals = [usedNonTerminals mutableCopy];
[mutableUsedNonTerminals minusSet:definedNonTerminals];
return [NSError errorWithDomain:CPEBNFParserErrorDomain
code:CPErrorCodeUndefinedNonTerminal
Expand Down
29 changes: 13 additions & 16 deletions CoreParse/Grammar/CPGrammarInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ @implementation CPGrammar (CPGrammarInternal)

- (CPGrammar *)augmentedGrammar
{
return [[[CPGrammar alloc] initWithStart:@"s'"
rules:[[self rules] arrayByAddingObject:[CPRule ruleWithName:@"s'" rightHandSideElements:[NSArray arrayWithObject:[CPGrammarSymbol nonTerminalWithName:[self start]]]]]]
autorelease];
return [[CPGrammar alloc] initWithStart:@"s'"
rules:[[self rules] arrayByAddingObject:[CPRule ruleWithName:@"s'" rightHandSideElements:[NSArray arrayWithObject:[CPGrammarSymbol nonTerminalWithName:[self start]]]]]];
}

- (NSUInteger)indexOfRule:(CPRule *)rule
Expand Down Expand Up @@ -73,9 +72,8 @@ - (NSSet *)lr0Closure:(NSSet *)i
[processingQueue removeObjectAtIndex:0];
}

[processingQueue release];

return [j autorelease];
return j;
}

- (NSSet *)lr0GotoKernelWithItems:(NSSet *)i symbol:(CPGrammarSymbol *)symbol
Expand Down Expand Up @@ -152,9 +150,8 @@ - (NSSet *)lr1Closure:(NSSet *)i
[processingQueue removeObjectAtIndex:0];
}

[processingQueue release];

return [j autorelease];
return j;
}

- (NSSet *)lr1GotoKernelWithItems:(NSSet *)i symbol:(CPGrammarSymbol *)symbol
Expand Down Expand Up @@ -232,7 +229,7 @@ - (NSString *)uniqueSymbolNameBasedOnName:(NSString *)name

- (NSString *)symbolNameNotInSet:(NSSet *)symbols basedOnName:(NSString *)name
{
NSString *testName = [[name copy] autorelease];
NSString *testName = [name copy];
while ([symbols containsObject:testName])
{
testName = [NSString stringWithFormat:@"_%@", testName];
Expand Down Expand Up @@ -280,7 +277,7 @@ - (NSError *)checkRulesForErrors:(NSArray *)rules
{
return error;
}
NSMutableSet *duplicateTags = [[tagNames mutableCopy] autorelease];
NSMutableSet *duplicateTags = [tagNames mutableCopy];
[duplicateTags intersectSet:newTagNames];
if ([duplicateTags count] > 0)
{
Expand All @@ -296,7 +293,7 @@ - (NSError *)checkRulesForErrors:(NSArray *)rules
{
if ([tagNames intersectsSet:tns])
{
NSMutableSet *intersection = [[tagNames mutableCopy] autorelease];
NSMutableSet *intersection = [tagNames mutableCopy];
[intersection intersectSet:tns];
return [NSError errorWithDomain:CPEBNFParserErrorDomain
code:CPErrorCodeDuplicateTag
Expand Down Expand Up @@ -345,7 +342,7 @@ - (NSDictionary *)nameNewRules:(NSSet *)rhsElements withRules:(NSArray *)oldRule

- (NSArray *)addRHSRules:(NSDictionary *)newRules toRules:(NSArray *)oldRules
{
NSMutableArray *rules = [[[NSMutableArray alloc] initWithArray:oldRules] autorelease];
NSMutableArray *rules = [[NSMutableArray alloc] initWithArray:oldRules];

Class rhsItemClass = [CPRHSItemResult class];
for (CPRHSItem *item in newRules)
Expand All @@ -362,12 +359,12 @@ - (NSArray *)addRHSRules:(NSDictionary *)newRules toRules:(NSArray *)oldRules

if ([item mayNotExist])
{
rule = [[[CPRule alloc] initWithName:ruleName rightHandSideElements:[NSArray array]] autorelease];
rule = [[CPRule alloc] initWithName:ruleName rightHandSideElements:[NSArray array]];
[rule setTag:0];
}
else
{
rule = [[[CPRule alloc] initWithName:ruleName rightHandSideElements:[[item alternatives] objectAtIndex:0]] autorelease];
rule = [[CPRule alloc] initWithName:ruleName rightHandSideElements:[[item alternatives] objectAtIndex:0]];
[rule setTag:1];
}
[rule setShouldCollapse:[item shouldCollapse]];
Expand All @@ -377,12 +374,12 @@ - (NSArray *)addRHSRules:(NSDictionary *)newRules toRules:(NSArray *)oldRules

if ([item repeats])
{
rule = [[[CPRule alloc] initWithName:ruleName rightHandSideElements:[[[item alternatives] objectAtIndex:0] arrayByAddingObject:[CPGrammarSymbol nonTerminalWithName:ruleName]]] autorelease];
rule = [[CPRule alloc] initWithName:ruleName rightHandSideElements:[[[item alternatives] objectAtIndex:0] arrayByAddingObject:[CPGrammarSymbol nonTerminalWithName:ruleName]]];
[rule setTag:2];
}
else if ([item mayNotExist])
{
rule = [[[CPRule alloc] initWithName:ruleName rightHandSideElements:[[item alternatives] objectAtIndex:0]] autorelease];
rule = [[CPRule alloc] initWithName:ruleName rightHandSideElements:[[item alternatives] objectAtIndex:0]];
[rule setTag:1];
}
else
Expand All @@ -403,7 +400,7 @@ - (NSArray *)addRHSRules:(NSDictionary *)newRules toRules:(NSArray *)oldRules
NSUInteger i = 0;
for (NSArray *contents in [item alternatives])
{
CPRule *rule = [[[CPRule alloc] initWithName:ruleName rightHandSideElements:contents] autorelease];
CPRule *rule = [[CPRule alloc] initWithName:ruleName rightHandSideElements:contents];
[rule setTag:3 + i];
[rule setRepresentitiveClass:rhsItemClass];
[rule setShouldCollapse:[item shouldCollapse]];
Expand Down
11 changes: 2 additions & 9 deletions CoreParse/Grammar/CPGrammarSymbol.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ @implementation CPGrammarSymbol

+ (id)nonTerminalWithName:(NSString *)name
{
return [[[self alloc] initWithName:name isTerminal:NO] autorelease];
return [[self alloc] initWithName:name isTerminal:NO];
}

+ (id)terminalWithName:(NSString *)name
{
return [[[self alloc] initWithName:name isTerminal:YES] autorelease];
return [[self alloc] initWithName:name isTerminal:YES];
}

- (id)initWithName:(NSString *)initName isTerminal:(BOOL)isTerminal;
Expand Down Expand Up @@ -97,13 +97,6 @@ - (NSString *)description
}
}

- (void)dealloc
{
[name release];

[super dealloc];
}

@end

@implementation NSObject (CPGrammarSymbol)
Expand Down
14 changes: 3 additions & 11 deletions CoreParse/Grammar/CPRHSItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ - (id)copyWithZone:(NSZone *)zone
return other;
}

- (void)dealloc
{
[_alternatives release];
[_tags release];

[super dealloc];
}

- (NSString *)description
{
Expand Down Expand Up @@ -101,14 +94,13 @@ - (NSString *)description

- (NSSet *)tags
{
return [[_tags retain] autorelease];
return _tags;
}

- (void)setTags:(NSSet *)tags
{
if (tags != _tags)
{
[_tags release];
_tags = [tags mutableCopy];
}
}
Expand Down Expand Up @@ -162,7 +154,7 @@ - (NSSet *)tagNamesWithError:(NSError **)err
{
return nil;
}
NSMutableSet *duplicateTags = [[tagNamesInAlternative mutableCopy] autorelease];
NSMutableSet *duplicateTags = [tagNamesInAlternative mutableCopy];
[duplicateTags intersectSet:newTagNames];
if ([duplicateTags count] > 0)
{
Expand All @@ -184,7 +176,7 @@ - (NSSet *)tagNamesWithError:(NSError **)err
{
if (NULL != err)
{
NSMutableSet *intersection = [[tagNamesInAlternative mutableCopy] autorelease];
NSMutableSet *intersection = [tagNamesInAlternative mutableCopy];
[intersection intersectSet:tns];
*err = [NSError errorWithDomain:CPEBNFParserErrorDomain
code:CPErrorCodeDuplicateTag
Expand Down
2 changes: 1 addition & 1 deletion CoreParse/Grammar/CPRHSItemResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@interface CPRHSItemResult : NSObject <CPParseResult>

@property (readwrite, retain) NSMutableArray *contents;
@property (readwrite, strong) NSMutableArray *contents;
@property (readwrite, assign) BOOL shouldCollapse;
@property (readwrite, copy ) NSSet *tagNames;
@property (readwrite, copy ) NSDictionary *tagValues;
Expand Down
Loading