Permalink
Browse files

Merge branch 'master' of git://github.com/andrimarjonsson/CoreParse i…

…nto mergePull
  • Loading branch information...
2 parents ae77624 + 28095c5 commit a0851b32aa0dee121d747591d8668575ed8c4413 @beelsebob committed Aug 23, 2012
@@ -771,7 +771,7 @@
1F0E88EC130462F300537D04 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0450;
+ LastUpgradeCheck = 0430;
ORGANIZATIONNAME = "In The Beginning...";
};
buildConfigurationList = 1F0E88EF130462F300537D04 /* Build configuration list for PBXProject "CoreParse" */;
@@ -1029,7 +1029,7 @@
1F0E891B130462F300537D04 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
COMBINE_HIDPI_IMAGES = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -1058,7 +1058,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
- SDKROOT = macosx;
+ SDKROOT = macosx10.6;
SUPPORTED_PLATFORMS = macosx;
VALID_ARCHS = "armv6 i386 x86_64 armv7";
};
@@ -1067,7 +1067,7 @@
1F0E891C130462F300537D04 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
COMBINE_HIDPI_IMAGES = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
@@ -1094,7 +1094,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = NO;
- SDKROOT = macosx;
+ SDKROOT = macosx10.6;
SUPPORTED_PLATFORMS = macosx;
VALID_ARCHS = "armv6 i386 x86_64 armv7";
};
@@ -1130,6 +1130,7 @@
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
INFOPLIST_FILE = "CoreParse/CoreParse-Info.plist";
+ INSTALL_PATH = "@rpath";
OTHER_CFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_AFTER_BUILD = YES;
@@ -1167,6 +1168,7 @@
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
INFOPLIST_FILE = "CoreParse/CoreParse-Info.plist";
+ INSTALL_PATH = "@rpath";
OTHER_CFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_AFTER_BUILD = YES;
@@ -87,6 +87,15 @@
* @warning Note that CPParser is an abstract superclass. Use one of its subclasses to construct your parser.
*/
@interface CPParser : NSObject
+{
+ struct
+ {
+ unsigned int didProduceSyntaxTree:1;
+ unsigned int didEncounterErrorOnInput:1;
+ unsigned int didEncounterErrorOnInputExpecting:1;
+
+ } delegateRespondsTo;
+}
///---------------------------------------------------------------------------------------
/// @name Creating and Initialising a Parser
@@ -115,7 +124,7 @@
/**
* The parser's delegate.
*/
-@property (readwrite,assign) id<CPParserDelegate> delegate;
+@property (readwrite,assign, nonatomic) id<CPParserDelegate> delegate;
///---------------------------------------------------------------------------------------
/// @name Finding out about the parsed Grammar
@@ -56,4 +56,14 @@ - (id)parse:(CPTokenStream *)tokenStream
return nil;
}
+- (void)setDelegate:(id<CPParserDelegate>)aDelegate
+{
+ if (delegate != aDelegate)
+ {
+ delegateRespondsTo.didProduceSyntaxTree = [delegate respondsToSelector:@selector(parser:didProduceSyntaxTree:)];
+ delegateRespondsTo.didEncounterErrorOnInput = [delegate respondsToSelector:@selector(parser:didEncounterErrorOnInput:)];
+ delegateRespondsTo.didEncounterErrorOnInputExpecting = [delegate respondsToSelector:@selector(parser:didEncounterErrorOnInput:expecting:)];
+ }
+}
+
@end
@@ -169,7 +169,7 @@ - (id)parse:(CPTokenStream *)tokenStream
if (nil == result)
{
result = tree;
- if ([[self delegate] respondsToSelector:@selector(parser:didProduceSyntaxTree:)])
+ if (delegateRespondsTo.didProduceSyntaxTree)
{
result = [[self delegate] parser:self didProduceSyntaxTree:tree];
}
@@ -234,11 +234,11 @@ - (id)parse:(CPTokenStream *)tokenStream
- (CPRecoveryAction *)error:(CPTokenStream *)tokenStream expecting:(NSSet *)acceptableTokens
{
- if ([[self delegate] respondsToSelector:@selector(parser:didEncounterErrorOnInput:expecting:)])
+ if (delegateRespondsTo.didEncounterErrorOnInputExpecting)
{
return [[self delegate] parser:self didEncounterErrorOnInput:tokenStream expecting:acceptableTokens];
}
- else if ([[self delegate] respondsToSelector:@selector(parser:didEncounterErrorOnInput:)])
+ else if (delegateRespondsTo.didEncounterErrorOnInput)
{
return [[self delegate] parser:self didEncounterErrorOnInput:tokenStream];
}
@@ -65,6 +65,15 @@
* the output stream.
*/
@interface CPTokeniser : NSObject <NSCoding>
+{
+ struct
+ {
+ unsigned int shouldConsumeToken:1;
+ unsigned int willProduceToken:1;
+ unsigned int didNotFindTokenOnInputPositionError:1;
+
+ } delegateRespondsTo;
+}
///---------------------------------------------------------------------------------------
/// @name Managing the Delegate
@@ -73,7 +82,7 @@
/**
* The object that acts as a delegate to the receiving CPTokeniser.
*/
-@property (readwrite, assign) id<CPTokeniserDelegate> delegate;
+@property (readwrite, assign, nonatomic) id<CPTokeniserDelegate> delegate;
///---------------------------------------------------------------------------------------
/// @name Managing recognised tokens
@@ -120,8 +120,9 @@ - (void)tokenise:(NSString *)input into:(CPTokenStream *)stream
[tok setLineNumber:currentLineNumber];
[tok setColumnNumber:currentColumnNumber];
[tok setCharacterNumber:lastTokenOffset];
+ [tok setLength:currentTokenOffset - lastTokenOffset];
- if ([delegate respondsToSelector:@selector(tokeniser:shouldConsumeToken:)])
+ if (delegateRespondsTo.shouldConsumeToken)
{
if ([delegate tokeniser:self shouldConsumeToken:tok])
{
@@ -147,7 +148,7 @@ - (void)tokenise:(NSString *)input into:(CPTokenStream *)stream
if (!recognised)
{
- if ([delegate respondsToSelector:@selector(tokeniser:didNotFindTokenOnInput:position:error:)])
+ if (delegateRespondsTo.didNotFindTokenOnInputPositionError)
{
NSString *err = nil;
currentTokenOffset = [delegate tokeniser:self didNotFindTokenOnInput:input position:currentTokenOffset error:&err];
@@ -182,7 +183,7 @@ - (void)tokenise:(NSString *)input into:(CPTokenStream *)stream
- (void)addToken:(CPToken *)tok toStream:(CPTokenStream *)stream
{
NSArray *toks;
- if ([delegate respondsToSelector:@selector(tokeniser:willProduceToken:)])
+ if (delegateRespondsTo.willProduceToken)
{
toks = [delegate tokeniser:self willProduceToken:tok];
}
@@ -216,4 +217,16 @@ - (void)advanceLineNumber:(NSUInteger *)ln columnNumber:(NSUInteger *)cn withInp
}
}
+- (void)setDelegate:(id<CPTokeniserDelegate>)aDelegate
+{
+ if (delegate != aDelegate)
+ {
+ delegate = aDelegate;
+
+ delegateRespondsTo.shouldConsumeToken = [delegate respondsToSelector:@selector(tokeniser:shouldConsumeToken:)];
+ delegateRespondsTo.willProduceToken = [delegate respondsToSelector:@selector(tokeniser:willProduceToken:)];
+ delegateRespondsTo.didNotFindTokenOnInputPositionError = [delegate respondsToSelector:@selector(tokeniser:didNotFindTokenOnInput:position:error:)];
+ }
+}
+
@end
@@ -37,6 +37,11 @@
*/
@property (readwrite, assign) NSUInteger characterNumber;
+/**
+ * The character length of the token.
+ */
+@property (readwrite, assign) NSUInteger length;
+
@end
@interface NSObject (CPIsToken)
@@ -13,6 +13,7 @@ @implementation CPToken
@synthesize lineNumber;
@synthesize columnNumber;
@synthesize characterNumber;
+@synthesize length;
- (NSString *)name
{

0 comments on commit a0851b3

Please sign in to comment.