Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switching to the TDParserFactory. Not quite there but promising.

  • Loading branch information...
commit 27a369587d560d2cbc5a4ab98a7c675543980d6b 1 parent 4f5b163
@mmower authored
View
45 HashParser.h
@@ -1,45 +0,0 @@
-//
-// HashParser.h
-// Spike
-//
-// Created by Matt Mower on 13/02/2009.
-// Copyright 2009 LucidMac Software. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-@class TDToken;
-@class TDParser;
-@class TDCollectionParser;
-
-@interface HashParser : NSObject {
- TDToken *bracket;
- TDToken *brace;
- TDCollectionParser *hashParser;
- TDParser *stringParser;
- TDParser *numberParser;
- TDParser *nullParser;
- TDCollectionParser *booleanParser;
- TDCollectionParser *commaValueParser;
- TDCollectionParser *propertyParser;
- TDCollectionParser *valueParser;
- TDCollectionParser *arrayParser;
- TDCollectionParser *commaPropertyParser;
-}
-
-@property (readonly) TDToken *bracket;
-@property (readonly) TDToken *brace;
-@property (readonly) TDCollectionParser *hashParser;
-@property (readonly) TDParser *stringParser;
-@property (readonly) TDParser *numberParser;
-@property (readonly) TDParser *nullParser;
-@property (readonly) TDCollectionParser *booleanParser;
-@property (readonly) TDCollectionParser *commaValueParser;
-@property (readonly) TDCollectionParser *propertyParser;
-@property (readonly) TDCollectionParser *valueParser;
-@property (readonly) TDCollectionParser *arrayParser;
-@property (readonly) TDCollectionParser *commaPropertyParser;
-
-- (NSDictionary *)parseHash:(NSString *)hash;
-
-@end
View
311 HashParser.m
@@ -1,311 +0,0 @@
-//
-// HashParser.m
-// Spike
-//
-// Created by Matt Mower on 13/02/2009.
-// Copyright 2009 LucidMac Software. All rights reserved.
-//
-
-#import "HashParser.h"
-
-#import <TDParseKit/TDParseKit.h>
-
-#import "NSString+TDParseKitAdditions.h"
-
-// Hash structure
-
-// { "key" => "value", "key" => { hash }, ... }
-
-
-@interface HashParser ()
-
-- (void)workOnStringAssembly:(TDAssembly *)assembly;
-- (void)workOnNullAssembly:(TDAssembly *)assembly;
-- (void)workOnBooleanAssembly:(TDAssembly *)assembly;
-- (void)workOnNumberAssembly:(TDAssembly *)assembly;
-- (void)workOnArrayAssembly:(TDAssembly *)assembly;
-- (void)workOnHashAssembly:(TDAssembly *)assembly;
-- (void)workOnPropertyAssembly:(TDAssembly *)assembly;
-
-@end
-
-
-@implementation HashParser
-
-
-- (id)init {
- if( ( self = [super init] ) ) {
- }
-
- return self;
-}
-
-
-@synthesize brace;
-
-- (TDToken *)brace {
- if( !brace ) {
- brace = [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:@"{" floatValue:0.0];
- }
-
- return brace;
-}
-
-
-@synthesize bracket;
-
-- (TDToken *)bracket {
- if( !bracket ) {
- bracket = [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:@"[" floatValue:0.0];
- }
-
- return bracket;
-}
-
-
-@synthesize stringParser;
-
-- (TDParser *)stringParser {
- if( !stringParser ) {
- stringParser = [TDQuotedString quotedString];
- [stringParser setAssembler:self selector:@selector(workOnStringAssembly:)];
- }
-
- return stringParser;
-}
-
-
-- (void)workOnStringAssembly:(TDAssembly *)assembly {
- TDToken *tok = [assembly pop];
- [assembly push:[[tok stringValue] stringByTrimmingQuotes]];
-}
-
-
-@synthesize numberParser;
-
-- (TDParser *)numberParser {
- if( !numberParser ) {
- numberParser = [TDNum num];
- [numberParser setAssembler:self selector:@selector(workOnNumberAssembly:)];
- }
-
- return numberParser;
-}
-
-
-- (void)workOnNumberAssembly:(TDAssembly *)assembly {
- TDToken *tok = [assembly pop];
- [assembly push:[NSNumber numberWithFloat:[tok floatValue]]];
-}
-
-
-@synthesize nullParser;
-
-- (TDParser *)nullParser {
- if (!nullParser) {
- nullParser = [[TDLiteral literalWithString:@"null"] discard];
- [nullParser setAssembler:self selector:@selector(workOnNullAssembly:)];
- }
-
- return nullParser;
-}
-
-
-- (void)workOnNullAssembly:(TDAssembly *)assembly {
- [assembly push:[NSNull null]];
-}
-
-
-@synthesize booleanParser;
-
-- (TDCollectionParser *)booleanParser {
- if (!booleanParser) {
- booleanParser = [TDAlternation alternation];
- [booleanParser add:[TDLiteral literalWithString:@"true"]];
- [booleanParser add:[TDLiteral literalWithString:@"false"]];
- [booleanParser setAssembler:self selector:@selector(workOnBooleanAssembly:)];
- }
-
- return booleanParser;
-}
-
-
-- (void)workOnBooleanAssembly:(TDAssembly *)assembly {
- TDToken *tok = [assembly pop];
- [assembly push:[NSNumber numberWithBool:[[tok stringValue] isEqualToString:@"true"] ? YES : NO]];
-}
-
-
-@synthesize commaValueParser;
-
-- (TDCollectionParser *)commaValueParser {
- if( !commaValueParser ) {
- commaValueParser = [TDTrack sequence];
- [commaValueParser add:[[TDSymbol symbolWithString:@","] discard]];
- [commaValueParser add:[self valueParser]];
- }
-
- return commaValueParser;
-}
-
-
-@synthesize propertyParser;
-
-- (TDCollectionParser *)propertyParser {
- if( !propertyParser ) {
- propertyParser = [TDSequence sequence];
- [propertyParser add:[TDQuotedString quotedString]];
- [propertyParser add:[[TDSymbol symbolWithString:@"=>"] discard]];
- [propertyParser add:[self valueParser]];
- [propertyParser setAssembler:self selector:@selector(workOnPropertyAssembly:)];
- }
-
- return propertyParser;
-}
-
-
-- (void)workOnPropertyAssembly:(TDAssembly *)assembly {
- id value = [assembly pop];
- TDToken *tok = [assembly pop];
- NSString *key = [[tok stringValue] stringByTrimmingQuotes];
-
- [assembly push:key];
- [assembly push:value];
-}
-
-
-@synthesize valueParser;
-
-- (TDCollectionParser *)valueParser {
- if( !valueParser ) {
- valueParser = [TDAlternation alternation];
- [valueParser add:[self stringParser]];
- [valueParser add:[self numberParser]];
- [valueParser add:[self nullParser]];
- [valueParser add:[self booleanParser]];
- [valueParser add:[self arrayParser]];
- [valueParser add:[self hashParser]];
- }
-
- return valueParser;
-}
-
-
-@synthesize commaPropertyParser;
-
-- (TDCollectionParser *)commaPropertyParser {
- if( !commaPropertyParser ) {
- commaPropertyParser = [TDTrack sequence];
- [commaPropertyParser add:[[TDSymbol symbolWithString:@","] discard]];
- [commaPropertyParser add:[self propertyParser]];
- }
-
- return commaPropertyParser;
-}
-
-
-@synthesize arrayParser;
-
-- (TDCollectionParser *)arrayParser {
- if (!arrayParser) {
-
- // array = '[' content ']'
- // content = Empty | actualArray
- // actualArray = value commaValue*
-
- TDTrack *actualArray = [TDTrack sequence];
- [actualArray add:[self valueParser]];
- [actualArray add:[TDRepetition repetitionWithSubparser:[self commaValueParser]]];
-
- TDAlternation *content = [TDAlternation alternation];
- [content add:[TDEmpty empty]];
- [content add:actualArray];
-
- arrayParser = [TDSequence sequence];
- [arrayParser add:[TDSymbol symbolWithString:@"["]]; // serves as fence
- [arrayParser add:content];
- [arrayParser add:[[TDSymbol symbolWithString:@"]"] discard]];
-
- [arrayParser setAssembler:self selector:@selector(workOnArrayAssembly:)];
- }
-
- return arrayParser;
-}
-
-
-- (void)workOnArrayAssembly:(TDAssembly *)assembly {
- NSArray *elements = [assembly objectsAbove:[self bracket]];
- NSMutableArray *array = [NSMutableArray arrayWithCapacity:elements.count];
-
- for( id element in [elements reverseObjectEnumerator] ) {
- if( element ) {
- [array addObject:element];
- }
- }
- [assembly pop]; // pop the [
- [assembly push:array];
-}
-
-
-// object = '{' content '}'
-// content = Empty | actualObject
-// actualObject = property commaProperty*
-// property = QuotedString ':' value
-// commaProperty = ',' property
-@synthesize hashParser;
-
-- (TDCollectionParser *)hashParser {
- if( !hashParser ) {
- TDTrack *actualObject = [TDTrack sequence];
- [actualObject add:[self propertyParser]];
- [actualObject add:[TDRepetition repetitionWithSubparser:[self commaPropertyParser]]];
-
- TDAlternation *content = [TDAlternation alternation];
- [content add:[TDEmpty empty]];
- [content add:actualObject];
-
- hashParser = [TDSequence sequence];
- [hashParser add:[TDSymbol symbolWithString:@"{"]]; // serves as fence
- [hashParser add:content];
- [hashParser add:[[TDSymbol symbolWithString:@"}"] discard]];
-
- [hashParser setAssembler:self selector:@selector(workOnHashAssembly:)];
- }
-
- return hashParser;
-}
-
-
-- (void)workOnHashAssembly:(TDAssembly *)assembly {
- NSArray *elements = [assembly objectsAbove:[self brace]];
- NSMutableDictionary *d = [NSMutableDictionary dictionaryWithCapacity:[elements count]/2];
-
- int i = 0;
- while( i < [elements count] ) {
- id value = [elements objectAtIndex:i];
- NSString *key = [elements objectAtIndex:i+1];
- if( key && value ) {
- [d setObject:value forKey:key];
- }
- i += 2;
- }
-
- [assembly pop]; // pop the {
- [assembly push:d];
-}
-
-
-- (NSDictionary *)parseHash:(NSString *)hash {
- TDTokenizer *tokenizer = [[TDTokenizer alloc] init];
- [tokenizer setString:hash];
- [tokenizer.symbolState add:@"=>"];
-
- TDTokenAssembly *assembly = [TDTokenAssembly assemblyWithTokenizer:tokenizer];
-
- TDAssembly *result = [[self hashParser] completeMatchFor:assembly];
-
- return [result pop];
-}
-
-
-@end
View
54 ParamParser.h
@@ -8,40 +8,42 @@
#import <Cocoa/Cocoa.h>
-@class TDToken;
+// @class TDToken;
@class TDParser;
@class TDTokenizer;
-@class TDCollectionParser;
+// @class TDCollectionParser;
@interface ParamParser : NSObject {
TDTokenizer *tokenizer;
- TDToken *bracket;
- TDToken *brace;
- TDCollectionParser *hashParser;
- TDParser *stringParser;
- TDParser *numberParser;
- TDParser *nullParser;
- TDCollectionParser *booleanParser;
- TDCollectionParser *commaValueParser;
- TDCollectionParser *propertyParser;
- TDCollectionParser *valueParser;
- TDCollectionParser *arrayParser;
- TDCollectionParser *commaPropertyParser;
+ TDParser *parser;
+ // TDToken *bracket;
+ // TDToken *brace;
+ // TDCollectionParser *hashParser;
+ // TDParser *stringParser;
+ // TDParser *numberParser;
+ // TDParser *nullParser;
+ // TDCollectionParser *booleanParser;
+ // TDCollectionParser *commaValueParser;
+ // TDCollectionParser *propertyParser;
+ // TDCollectionParser *valueParser;
+ // TDCollectionParser *arrayParser;
+ // TDCollectionParser *commaPropertyParser;
}
@property (readonly) TDTokenizer *tokenizer;
-@property (readonly) TDToken *bracket;
-@property (readonly) TDToken *brace;
-@property (readonly) TDCollectionParser *hashParser;
-@property (readonly) TDParser *stringParser;
-@property (readonly) TDParser *numberParser;
-@property (readonly) TDParser *nullParser;
-@property (readonly) TDCollectionParser *booleanParser;
-@property (readonly) TDCollectionParser *commaValueParser;
-@property (readonly) TDCollectionParser *propertyParser;
-@property (readonly) TDCollectionParser *valueParser;
-@property (readonly) TDCollectionParser *arrayParser;
-@property (readonly) TDCollectionParser *commaPropertyParser;
+@property (readonly) TDParser *parser;
+// @property (readonly) TDToken *bracket;
+// @property (readonly) TDToken *brace;
+// @property (readonly) TDCollectionParser *hashParser;
+// @property (readonly) TDParser *stringParser;
+// @property (readonly) TDParser *numberParser;
+// @property (readonly) TDParser *nullParser;
+// @property (readonly) TDCollectionParser *booleanParser;
+// @property (readonly) TDCollectionParser *commaValueParser;
+// @property (readonly) TDCollectionParser *propertyParser;
+// @property (readonly) TDCollectionParser *valueParser;
+// @property (readonly) TDCollectionParser *arrayParser;
+// @property (readonly) TDCollectionParser *commaPropertyParser;
- (NSArray *)parseParams:(NSString *)unparsedParams;
View
317 ParamParser.m
@@ -13,14 +13,16 @@
#import "Parameter.h"
-@interface ParamParser ()
+@interface ParamParser (PrivateMethods)
+
+- (NSString *)grammarPath;
- (void)workOnStringAssembly:(TDAssembly *)assembly;
- (void)workOnNullAssembly:(TDAssembly *)assembly;
- (void)workOnBooleanAssembly:(TDAssembly *)assembly;
- (void)workOnNumberAssembly:(TDAssembly *)assembly;
- (void)workOnArrayAssembly:(TDAssembly *)assembly;
-- (void)workOnHashAssembly:(TDAssembly *)assembly;
+- (void)workOnObjectAssembly:(TDAssembly *)assembly;
- (void)workOnPropertyAssembly:(TDAssembly *)assembly;
@end
@@ -29,48 +31,44 @@ @implementation ParamParser
- (id)init {
if( ( self = [super init] ) ) {
- tokenizer = [[TDTokenizer alloc] init];
- [tokenizer.symbolState add:@"=>"];
+ NSString *rubyHashGrammar = [NSString stringWithContentsOfFile:[self grammarPath]
+ encoding:NSUTF8StringEncoding
+ error:nil];
+ parser = [[TDParserFactory factory] parserFromGrammar:rubyHashGrammar
+ assembler:self
+ getTokenizer:&tokenizer];
+ TDReleaseSubparserTree( parser );
+ NSLog( @"Built parser = %@", parser );
}
return self;
}
-@synthesize tokenizer;
-
-
-@synthesize brace;
-
-- (TDToken *)brace {
- if( !brace ) {
- brace = [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:@"{" floatValue:0.0];
- }
-
- return brace;
+- (BOOL)respondsToSelector:(SEL)selector {
+ BOOL doesRespond = [super respondsToSelector:selector];
+ NSLog( @"respondsToSelector:%@ -> %@", NSStringFromSelector(selector), doesRespond ? @"YES" : @"NO" );
+ return doesRespond;
}
-@synthesize bracket;
+@synthesize parser;
+@synthesize tokenizer;
-- (TDToken *)bracket {
- if( !bracket ) {
- bracket = [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:@"[" floatValue:0.0];
- }
-
- return bracket;
-}
+- (NSString *)grammarPath {
+ return [[NSBundle bundleForClass:[self class]] pathForResource:@"rubyhash"
+ ofType:@"grammar"];
+}
-@synthesize stringParser;
-- (TDParser *)stringParser {
- if( !stringParser ) {
- stringParser = [TDQuotedString quotedString];
- [stringParser setAssembler:self selector:@selector(workOnStringAssembly:)];
- }
+- (NSArray *)parseParams:(NSString *)unparsedParams {
+ [[self tokenizer] setString:unparsedParams];
- return stringParser;
+ TDTokenAssembly *assembly = [TDTokenAssembly assemblyWithTokenizer:tokenizer];
+ TDAssembly *result = [[self parser] bestMatchFor:assembly];
+
+ return [result pop];
}
@@ -80,237 +78,80 @@ - (void)workOnStringAssembly:(TDAssembly *)assembly {
}
-@synthesize numberParser;
-
-- (TDParser *)numberParser {
- if( !numberParser ) {
- numberParser = [TDNum num];
- [numberParser setAssembler:self selector:@selector(workOnNumberAssembly:)];
- }
-
- return numberParser;
-}
-
-
- (void)workOnNumberAssembly:(TDAssembly *)assembly {
TDToken *tok = [assembly pop];
[assembly push:[NSNumber numberWithFloat:[tok floatValue]]];
}
-@synthesize nullParser;
-
-- (TDParser *)nullParser {
- if (!nullParser) {
- nullParser = [[TDLiteral literalWithString:@"null"] discard];
- [nullParser setAssembler:self selector:@selector(workOnNullAssembly:)];
- }
-
- return nullParser;
-}
-
-
- (void)workOnNullAssembly:(TDAssembly *)assembly {
[assembly push:[NSNull null]];
}
-@synthesize booleanParser;
-
-- (TDCollectionParser *)booleanParser {
- if (!booleanParser) {
- booleanParser = [TDAlternation alternation];
- [booleanParser add:[TDLiteral literalWithString:@"true"]];
- [booleanParser add:[TDLiteral literalWithString:@"false"]];
- [booleanParser setAssembler:self selector:@selector(workOnBooleanAssembly:)];
- }
-
- return booleanParser;
-}
-
-
- (void)workOnBooleanAssembly:(TDAssembly *)assembly {
- TDToken *tok = [assembly pop];
- [assembly push:[NSNumber numberWithBool:[[tok stringValue] isEqualToString:@"true"] ? YES : NO]];
-}
-
-
-@synthesize commaValueParser;
-
-- (TDCollectionParser *)commaValueParser {
- if( !commaValueParser ) {
- commaValueParser = [TDTrack sequence];
- [commaValueParser add:[[TDSymbol symbolWithString:@","] discard]];
- [commaValueParser add:[self valueParser]];
- }
-
- return commaValueParser;
-}
-
-
-@synthesize propertyParser;
-
-- (TDCollectionParser *)propertyParser {
- if( !propertyParser ) {
- propertyParser = [TDSequence sequence];
- [propertyParser add:[TDQuotedString quotedString]];
- [propertyParser add:[[TDSymbol symbolWithString:@"=>"] discard]];
- [propertyParser add:[self valueParser]];
- [propertyParser setAssembler:self selector:@selector(workOnPropertyAssembly:)];
- }
-
- return propertyParser;
+ TDToken *token = [assembly pop];
+ [assembly push:[NSNumber numberWithBool:[[token stringValue] isEqualToString:@"true"] ? YES : NO]];
}
- (void)workOnPropertyAssembly:(TDAssembly *)assembly {
- id value = [assembly pop];
- TDToken *tok = [assembly pop];
- NSString *key = [[tok stringValue] stringByTrimmingQuotes];
-
- [assembly push:key];
- [assembly push:value];
-}
-
-
-@synthesize valueParser;
-
-- (TDCollectionParser *)valueParser {
- if( !valueParser ) {
- valueParser = [TDAlternation alternation];
- [valueParser add:[self stringParser]];
- [valueParser add:[self numberParser]];
- [valueParser add:[self nullParser]];
- [valueParser add:[self booleanParser]];
- [valueParser add:[self arrayParser]];
- [valueParser add:[self hashParser]];
- }
-
- return valueParser;
+ NSLog( @"workOnPropertyAssembly: %@", assembly );
+ // id value = [assembly pop];
+ // TDToken *tok = [assembly pop];
+ // NSString *key = [[tok stringValue] stringByTrimmingQuotes];
+ //
+ // [assembly push:key];
+ // [assembly push:value];
}
-@synthesize commaPropertyParser;
-
-- (TDCollectionParser *)commaPropertyParser {
- if( !commaPropertyParser ) {
- commaPropertyParser = [TDTrack sequence];
- [commaPropertyParser add:[[TDSymbol symbolWithString:@","] discard]];
- [commaPropertyParser add:[self propertyParser]];
- }
-
- return commaPropertyParser;
-}
-
-
-@synthesize arrayParser;
-
-- (TDCollectionParser *)arrayParser {
- if (!arrayParser) {
-
- // array = '[' content ']'
- // content = Empty | actualArray
- // actualArray = value commaValue*
-
- TDTrack *actualArray = [TDTrack sequence];
- [actualArray add:[self valueParser]];
- [actualArray add:[TDRepetition repetitionWithSubparser:[self commaValueParser]]];
-
- TDAlternation *content = [TDAlternation alternation];
- [content add:[TDEmpty empty]];
- [content add:actualArray];
-
- arrayParser = [TDSequence sequence];
- [arrayParser add:[TDSymbol symbolWithString:@"["]]; // serves as fence
- [arrayParser add:content];
- [arrayParser add:[[TDSymbol symbolWithString:@"]"] discard]];
-
- [arrayParser setAssembler:self selector:@selector(workOnArrayAssembly:)];
- }
-
- return arrayParser;
+- (void)workOnValueAssembly:(TDAssembly *)assembly {
+ NSLog( @"workOnValueAssembly: %@", assembly );
}
- (void)workOnArrayAssembly:(TDAssembly *)assembly {
- NSArray *elements = [assembly objectsAbove:[self bracket]];
- NSMutableArray *array = [NSMutableArray arrayWithCapacity:elements.count];
-
- for( id element in [elements reverseObjectEnumerator] ) {
- if( element ) {
- [array addObject:element];
- }
- }
- [assembly pop]; // pop the [
- [assembly push:array];
-}
-
-
-// object = '{' content '}'
-// content = Empty | actualObject
-// actualObject = property commaProperty*
-// property = QuotedString ':' value
-// commaProperty = ',' property
-@synthesize hashParser;
-
-- (TDCollectionParser *)hashParser {
- if( !hashParser ) {
- TDTrack *actualObject = [TDTrack sequence];
- [actualObject add:[self propertyParser]];
- [actualObject add:[TDRepetition repetitionWithSubparser:[self commaPropertyParser]]];
-
- TDAlternation *content = [TDAlternation alternation];
- [content add:[TDEmpty empty]];
- [content add:actualObject];
-
- hashParser = [TDSequence sequence];
- [hashParser add:[TDSymbol symbolWithString:@"{"]]; // serves as fence
- [hashParser add:content];
- [hashParser add:[[TDSymbol symbolWithString:@"}"] discard]];
-
- [hashParser setAssembler:self selector:@selector(workOnHashAssembly:)];
- }
-
- return hashParser;
-}
-
-
-- (void)workOnHashAssembly:(TDAssembly *)assembly {
- NSArray *elements = [assembly objectsAbove:[self brace]];
-
- NSMutableArray *params = [NSMutableArray arrayWithCapacity:[elements count]/2];
-
- int i = 0;
- while( i < [elements count] ) {
- id value = [elements objectAtIndex:i];
- NSString *name = [elements objectAtIndex:i+1];
-
- if( name && value ) {
- Parameter *param = [[Parameter alloc] initWithName:name];
- if( [value isKindOfClass:[NSArray class]] ) {
- [param setGroupedParams:value];
- } else {
- [param setValue:value];
- }
- [params addObject:param];
- }
-
- i += 2;
- }
-
- [assembly pop]; // pop the {
- [assembly push:params];
-}
-
-
-- (NSArray *)parseParams:(NSString *)unparsedParams {
- [[self tokenizer] setString:unparsedParams];
-
- TDTokenAssembly *assembly = [TDTokenAssembly assemblyWithTokenizer:tokenizer];
-
- TDAssembly *result = [[self hashParser] completeMatchFor:assembly];
-
- return [result pop];
+ NSLog( @"workOnArrayAssembly: %@", assembly );
+ // NSArray *elements = [assembly objectsAbove:[self bracket]];
+ // NSMutableArray *array = [NSMutableArray arrayWithCapacity:elements.count];
+ //
+ // for( id element in [elements reverseObjectEnumerator] ) {
+ // if( element ) {
+ // [array addObject:element];
+ // }
+ // }
+ // [assembly pop]; // pop the [
+ // [assembly push:array];
+}
+
+
+- (void)workOnObjectAssembly:(TDAssembly *)assembly {
+ NSLog( @"workOnObjectAssebly: %@", assembly );
+ // NSArray *elements = [assembly objectsAbove:[self brace]];
+ //
+ // NSMutableArray *params = [NSMutableArray arrayWithCapacity:[elements count]/2];
+ //
+ // int i = 0;
+ // while( i < [elements count] ) {
+ // id value = [elements objectAtIndex:i];
+ // NSString *name = [elements objectAtIndex:i+1];
+ //
+ // if( name && value ) {
+ // Parameter *param = [[Parameter alloc] initWithName:name];
+ // if( [value isKindOfClass:[NSArray class]] ) {
+ // [param setGroupedParams:value];
+ // } else {
+ // [param setValue:value];
+ // }
+ // [params addObject:param];
+ // }
+ //
+ // i += 2;
+ // }
+ //
+ // [assembly pop]; // pop the {
+ // [assembly push:params];
}
View
12 Spike.xcodeproj/project.pbxproj
@@ -32,7 +32,7 @@
C95930A70F48AE54004A49FA /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C95930A60F48AE54004A49FA /* Sparkle.framework */; };
C95930AD0F48AEE3004A49FA /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = C95930A60F48AE54004A49FA /* Sparkle.framework */; };
C95930BB0F48B4AF004A49FA /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = C95930BA0F48B4AF004A49FA /* dsa_pub.pem */; };
- C9AAECF60F46D05D00D6C171 /* HashParser.m in Sources */ = {isa = PBXBuildFile; fileRef = C9AAECF50F46D05D00D6C171 /* HashParser.m */; };
+ C99F74340F59458400EBB1AB /* rubyhash.grammar in Resources */ = {isa = PBXBuildFile; fileRef = C99F74330F59458400EBB1AB /* rubyhash.grammar */; };
C9AAED650F46EF0900D6C171 /* NSArray+TDParseKitAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = C9AAED620F46EF0900D6C171 /* NSArray+TDParseKitAdditions.m */; };
C9AAED660F46EF0900D6C171 /* NSString+TDParseKitAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = C9AAED640F46EF0900D6C171 /* NSString+TDParseKitAdditions.m */; };
C9AAEDD70F4781C500D6C171 /* Parameter.m in Sources */ = {isa = PBXBuildFile; fileRef = C9AAEDD60F4781C500D6C171 /* Parameter.m */; };
@@ -93,8 +93,7 @@
C95930690F4871B0004A49FA /* HaltedColumnTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HaltedColumnTransformer.m; sourceTree = "<group>"; };
C95930A60F48AE54004A49FA /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = frameworks/Sparkle.framework; sourceTree = "<group>"; };
C95930BA0F48B4AF004A49FA /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
- C9AAECF40F46D05D00D6C171 /* HashParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashParser.h; sourceTree = "<group>"; };
- C9AAECF50F46D05D00D6C171 /* HashParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HashParser.m; sourceTree = "<group>"; };
+ C99F74330F59458400EBB1AB /* rubyhash.grammar */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rubyhash.grammar; sourceTree = "<group>"; };
C9AAED610F46EF0900D6C171 /* NSArray+TDParseKitAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+TDParseKitAdditions.h"; sourceTree = "<group>"; };
C9AAED620F46EF0900D6C171 /* NSArray+TDParseKitAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+TDParseKitAdditions.m"; sourceTree = "<group>"; };
C9AAED630F46EF0900D6C171 /* NSString+TDParseKitAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+TDParseKitAdditions.h"; sourceTree = "<group>"; };
@@ -137,8 +136,6 @@
C9AAED620F46EF0900D6C171 /* NSArray+TDParseKitAdditions.m */,
C9AAED630F46EF0900D6C171 /* NSString+TDParseKitAdditions.h */,
C9AAED640F46EF0900D6C171 /* NSString+TDParseKitAdditions.m */,
- C9AAECF40F46D05D00D6C171 /* HashParser.h */,
- C9AAECF50F46D05D00D6C171 /* HashParser.m */,
C9EEFC270F45B59900054345 /* RailsRequest.h */,
C9EEFC280F45B59900054345 /* RailsRequest.m */,
C9EEFC2C0F45B5A300054345 /* LogParser.h */,
@@ -216,6 +213,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ C99F74330F59458400EBB1AB /* rubyhash.grammar */,
C9522C0F0F4F738E00CE32AA /* ticked_checkbox.png */,
C905F48A0F4D8164008C9DEC /* close_32.gif */,
C905F48B0F4D8164008C9DEC /* refresh_32.gif */,
@@ -298,6 +296,7 @@
C905F48F0F4D8164008C9DEC /* search_32.gif in Resources */,
C905F56A0F4E20F3008C9DEC /* Credits.rtf in Resources */,
C9522C100F4F738E00CE32AA /* ticked_checkbox.png in Resources */,
+ C99F74340F59458400EBB1AB /* rubyhash.grammar in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -312,7 +311,6 @@
C9EEFC290F45B59900054345 /* RailsRequest.m in Sources */,
C9EEFC2E0F45B5A300054345 /* LogParser.m in Sources */,
C9EEFC510F45C82000054345 /* AppController.m in Sources */,
- C9AAECF60F46D05D00D6C171 /* HashParser.m in Sources */,
C9AAED650F46EF0900D6C171 /* NSArray+TDParseKitAdditions.m in Sources */,
C9AAED660F46EF0900D6C171 /* NSString+TDParseKitAdditions.m in Sources */,
C9AAEDD70F4781C500D6C171 /* Parameter.m in Sources */,
@@ -389,6 +387,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Spike_Prefix.pch;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
OTHER_LDFLAGS = "-lz";
@@ -411,6 +410,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Spike_Prefix.pch;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
OTHER_LDFLAGS = "-lz";
View
8 rubyhash.grammar
@@ -16,11 +16,15 @@
object = openCurly objectContent closeCurly;
objectContent = Empty | actualObject;
actualObject = property commaProperty*;
+array = openSquare arrayContent closeSquare;
+arrayContent = Empty | actualArray;
+actualArray = value commaValue*;
property = propertyName arrow value;
commaProperty = comma property;
+commaValue = comma value;
propertyName = QuotedString; // NOTE: property names are quoted
-value = null | true | false | object | number | string | fileRef;
+value = null | true | false | object | array | number | string | fileRef;
string = QuotedString;
number = Num;
@@ -31,5 +35,7 @@ false = 'false';
openCurly = '{';
closeCurly = '}';
+openSquare = '[';
+closeSquare = ']';
comma = ',';
arrow = '=>';
Please sign in to comment.
Something went wrong with that request. Please try again.