mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-22 11:11:21 +00:00
o added exception names constants
o added GSWDeclarationFormatException o added declaration caching (work in progress) o use GSWDeclarationFormatException instead of NSException git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@19948 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
745cc96e55
commit
4a0617e007
2 changed files with 346 additions and 131 deletions
|
@ -33,6 +33,36 @@
|
|||
#define _GSWDeclarationParser_h__
|
||||
|
||||
|
||||
GS_EXPORT NSString* const GSWDFEMissingDeclarationForElement;
|
||||
GS_EXPORT NSString* const GSWDFEMissingElementName;
|
||||
GS_EXPORT NSString* const GSWDFEMissingClassNameForElement;
|
||||
GS_EXPORT NSString* const GSWDFEElementCreationFailed;
|
||||
GS_EXPORT NSString* const GSWDFEMissingIdentifier;
|
||||
GS_EXPORT NSString* const GSWDFEMissingPragmaDelegate;
|
||||
GS_EXPORT NSString* const GSWDFEUnknownPragmaDirective;
|
||||
GS_EXPORT NSString* const GSWDFEMissingQuotedStringEnd;
|
||||
GS_EXPORT NSString* const GSWDFEMissingHexStringDataEnd;
|
||||
GS_EXPORT NSString* const GSWDFEMissingQuotedKeyPathEnd;
|
||||
GS_EXPORT NSString* const GSWDFEWrongKeyPathFormat;
|
||||
GS_EXPORT NSString* const GSWDFEEmptyKeyPath;
|
||||
GS_EXPORT NSString* const GSWDFEWrongNumberFormat;
|
||||
GS_EXPORT NSString* const GSWDFEWrongHexNumberFormat;
|
||||
GS_EXPORT NSString* const GSWDFEUnexpectedBufferEnd;
|
||||
GS_EXPORT NSString* const GSWDFEMissingValue;
|
||||
GS_EXPORT NSString* const GSWDFEMissingSeparator;
|
||||
GS_EXPORT NSString* const GSWDFEDictionaryParsingError;
|
||||
GS_EXPORT NSString* const GSWDFEArrayParsingError;
|
||||
GS_EXPORT NSString* const GSWDFEUnexpectedCharacter;
|
||||
GS_EXPORT NSString* const GSWDFEMissingAliasedDeclaration;
|
||||
|
||||
|
||||
//====================================================================
|
||||
@interface GSWDeclarationFormatException : NSException
|
||||
/** Returns YES if we can delay exception reporting (so all errors are
|
||||
accumulated instead of blocking on first error) **/
|
||||
-(BOOL)canDelay;
|
||||
@end
|
||||
|
||||
//====================================================================
|
||||
@protocol GSWDeclarationParserPragmaDelegate
|
||||
-(NSDictionary*)includedDeclarationsFromFilePath:(NSString*)file
|
||||
|
|
|
@ -38,6 +38,7 @@ RCS_ID("$Id$")
|
|||
|
||||
#include "GSWDeclarationParser.h"
|
||||
#include <GNUstepBase/Unicode.h>
|
||||
#include <gscrypt/GSMD5.h>
|
||||
|
||||
static inline BOOL _parserIsIdentifierChar(unichar c)
|
||||
{
|
||||
|
@ -67,10 +68,85 @@ static inline BOOL _parserIsIdentifierChar(unichar c)
|
|||
};
|
||||
};
|
||||
|
||||
NSString* const GSWDFEMissingDeclarationForElement = @"GSWDFEMissingDeclarationForElement";
|
||||
NSString* const GSWDFEMissingElementName = @"GSWDFEMissingElementName";
|
||||
NSString* const GSWDFEMissingClassNameForElement = @"GSWDFEMissingClassNameForElement";
|
||||
NSString* const GSWDFEElementCreationFailed = @"GSWDFEElementCreationFailed";
|
||||
NSString* const GSWDFEMissingIdentifier = @"GSWDFEMissingIdentifier";
|
||||
NSString* const GSWDFEMissingPragmaDelegate = @"GSWDFEMissingPragmaDelegate";
|
||||
NSString* const GSWDFEUnknownPragmaDirective = @"GSWDFEUnknownPragmaDirective";
|
||||
NSString* const GSWDFEMissingQuotedStringEnd = @"GSWDFEMissingQuotedStringEnd";
|
||||
NSString* const GSWDFEMissingHexStringDataEnd = @"GSWDFEMissingHexStringDataEnd";
|
||||
NSString* const GSWDFEMissingQuotedKeyPathEnd = @"GSWDFEMissingQuotedKeyPathEnd";
|
||||
NSString* const GSWDFEWrongKeyPathFormat = @"GSWDFEWrongKeyPathFormat";
|
||||
NSString* const GSWDFEEmptyKeyPath = @"GSWDFEEmptyKeyPath";
|
||||
NSString* const GSWDFEWrongNumberFormat = @"GSWDFEWrongNumberFormat";
|
||||
NSString* const GSWDFEWrongHexNumberFormat = @"GSWDFEWrongHexNumberFormat";
|
||||
NSString* const GSWDFEUnexpectedBufferEnd = @"GSWDFEUnexpectedBufferEnd";
|
||||
NSString* const GSWDFEMissingValue = @"GSWDFEMissingValue";
|
||||
NSString* const GSWDFEMissingSeparator = @"GSWDFEMissingSeparator";
|
||||
NSString* const GSWDFEDictionaryParsingError = @"GSWDFEDictionaryParsingError";
|
||||
NSString* const GSWDFEArrayParsingError = @"GSWDFEArrayParsingError";
|
||||
NSString* const GSWDFEUnexpectedCharacter = @"GSWDFEUnexpectedCharacter";
|
||||
NSString* const GSWDFEMissingAliasedDeclaration = @"GSWDFEMissingAliasedDeclaration";
|
||||
|
||||
static NSSet* delayedDeclarationFormatExceptionNames = nil;
|
||||
static NSMutableDictionary* declarationsCache=nil;
|
||||
//====================================================================
|
||||
@implementation GSWDeclarationFormatException
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSWDeclarationFormatException class])
|
||||
{
|
||||
ASSIGN(delayedDeclarationFormatExceptionNames,
|
||||
([NSSet setWithObjects:
|
||||
GSWDFEMissingDeclarationForElement,
|
||||
GSWDFEMissingElementName,
|
||||
GSWDFEMissingClassNameForElement,
|
||||
GSWDFEElementCreationFailed,
|
||||
GSWDFEMissingIdentifier,
|
||||
GSWDFEMissingPragmaDelegate,
|
||||
GSWDFEUnknownPragmaDirective,
|
||||
GSWDFEMissingQuotedStringEnd,
|
||||
GSWDFEMissingHexStringDataEnd,
|
||||
GSWDFEMissingQuotedKeyPathEnd,
|
||||
GSWDFEWrongKeyPathFormat,
|
||||
GSWDFEEmptyKeyPath,
|
||||
GSWDFEWrongNumberFormat,
|
||||
GSWDFEWrongHexNumberFormat,
|
||||
GSWDFEUnexpectedBufferEnd,
|
||||
GSWDFEMissingValue,
|
||||
GSWDFEMissingSeparator,
|
||||
GSWDFEDictionaryParsingError,
|
||||
GSWDFEArrayParsingError,
|
||||
GSWDFEUnexpectedCharacter,
|
||||
nil]));
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
/** Returns YES if we can delay exception reporting (so all errors are
|
||||
accumulated instead of blocking on first error) **/
|
||||
-(BOOL)canDelay
|
||||
{
|
||||
return [delayedDeclarationFormatExceptionNames containsObject:[self name]];
|
||||
};
|
||||
|
||||
|
||||
@end
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWDeclarationParser
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSWDeclarationParser class])
|
||||
{
|
||||
declarationsCache=[NSMutableDictionary new];
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+(GSWDeclarationParser*)declarationParserWithPragmaDelegate:(id<GSWDeclarationParserPragmaDelegate>)pragmaDelegate
|
||||
{
|
||||
|
@ -104,12 +180,12 @@ static inline BOOL _parserIsIdentifierChar(unichar c)
|
|||
named:(NSString*)declarationFileName
|
||||
inFrameworkNamed:(NSString*)declarationFrameworkName
|
||||
{
|
||||
NSData* md5=nil;
|
||||
NSDictionary* declarations=nil;
|
||||
LOGObjectFnStart();
|
||||
|
||||
if (_declarations)
|
||||
[_declarations removeAllObjects];
|
||||
else
|
||||
_declarations=(NSMutableDictionary*)[NSMutableDictionary new];
|
||||
|
||||
ASSIGN(_string,declarationString);
|
||||
ASSIGN(_fileName,declarationFileName);
|
||||
|
@ -118,6 +194,19 @@ static inline BOOL _parserIsIdentifierChar(unichar c)
|
|||
NSDebugMLog(@"declarationString=%@",declarationString);
|
||||
_length=[_string length];
|
||||
|
||||
if ([_string rangeOfString:@"#include"].length==0)
|
||||
{
|
||||
md5=[GSMD5 digestOfString:_string
|
||||
usingEncoding:NSUnicodeStringEncoding];
|
||||
declarations=[declarationsCache objectForKey:md5];
|
||||
NSDebugMLog(@"declaration (%@) is %scached",declarationFileName,(declarations ? "" : "not "));
|
||||
}
|
||||
|
||||
if (!declarations)
|
||||
{
|
||||
if (!_declarations)
|
||||
_declarations=(NSMutableDictionary*)[NSMutableDictionary new];
|
||||
|
||||
_uniBuf = (unichar*)objc_malloc(sizeof(unichar)*(_length+1));
|
||||
NS_DURING
|
||||
{
|
||||
|
@ -148,8 +237,9 @@ static inline BOOL _parserIsIdentifierChar(unichar c)
|
|||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No identifier %@",
|
||||
[GSWDeclarationFormatException raise:GSWDFEMissingIdentifier
|
||||
format:@"In %@ %@: No identifier %@",
|
||||
_frameworkName,_fileName,
|
||||
[self currentLineAndColumnIndexesString]];
|
||||
};
|
||||
};
|
||||
|
@ -168,10 +258,15 @@ static inline BOOL _parserIsIdentifierChar(unichar c)
|
|||
NS_ENDHANDLER;
|
||||
|
||||
NSDebugMLog(@"_declarations=%@",_declarations);
|
||||
declarations=[NSDictionary dictionaryWithDictionary:_declarations];
|
||||
if (md5)
|
||||
[declarationsCache setObject:declarations
|
||||
forKey:md5];
|
||||
};
|
||||
|
||||
LOGObjectFnStop();
|
||||
|
||||
return _declarations;
|
||||
return declarations;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -301,8 +396,10 @@ static inline BOOL _parserIsIdentifierChar(unichar c)
|
|||
{
|
||||
if (!_pragmaDelegate)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No pragma delegate for pragma directive '%@'"];
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingPragmaDelegate
|
||||
format:@"In %@ %@: No pragma delegate for pragma directive '%@'",
|
||||
_frameworkName,_fileName];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -325,8 +422,10 @@ static inline BOOL _parserIsIdentifierChar(unichar c)
|
|||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"unknown pragma directive '%@' at line %@",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnknownPragmaDirective
|
||||
format:@"In %@ %@: Unknown pragma directive '%@' at line %@",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
|
||||
|
@ -353,8 +452,10 @@ Returns a NSString
|
|||
|
||||
if (index-startIndex==0)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No identifier %@",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingIdentifier
|
||||
format:@"IN %@ %@: No identifier %@",
|
||||
_frameworkName,_fileName,
|
||||
[self currentLineAndColumnIndexesString]];
|
||||
}
|
||||
else
|
||||
|
@ -402,8 +503,10 @@ Returns a NSString without '"' pefix and suffix
|
|||
_index++;
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No end '\"' for quoted string starting at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingQuotedStringEnd
|
||||
format:@"In %@ %@: No end '\"' for quoted string starting at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
|
||||
|
@ -437,8 +540,10 @@ Returns a NSData
|
|||
_index++;
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No end '>' for data starting at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingHexStringDataEnd
|
||||
format:@"In %@ %@: No end '>' for data starting at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
|
||||
|
@ -479,8 +584,10 @@ Returns a NSString
|
|||
_index++;
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No end '\'' for keyPath starting at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingQuotedKeyPathEnd
|
||||
format:@"In %@ %@: No end '\'' for keyPath starting at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
|
||||
|
@ -496,8 +603,10 @@ Returns a NSString
|
|||
_index++;
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No end '\"' for keyPath starting at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingQuotedKeyPathEnd
|
||||
format:@"In %@ %@:No end '\"' for keyPath starting at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
|
||||
|
@ -505,8 +614,10 @@ Returns a NSString
|
|||
case '.':
|
||||
if (_index==startIndex)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"keyPath can't begin with '.' line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEWrongKeyPathFormat
|
||||
format:@"In %@ %@: keyPath can't begin with '.' line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
}
|
||||
else
|
||||
|
@ -523,8 +634,10 @@ Returns a NSString
|
|||
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
|
||||
if ((index-startIndex)==0)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Empty keyPath at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEEmptyKeyPath
|
||||
format:@"In %@ %@: Empty keyPath at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
}
|
||||
else
|
||||
|
@ -655,8 +768,10 @@ Returns a NSNumber
|
|||
_index++;
|
||||
if (_index>=_length)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Bad number line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEWrongNumberFormat
|
||||
format:@"In %@ %@: Bad number line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
};
|
||||
|
@ -668,8 +783,10 @@ Returns a NSNumber
|
|||
{
|
||||
if (seenDot)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"2 dots in a number line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEWrongNumberFormat
|
||||
format:@"In %@ %@: 2 dots in a number line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
}
|
||||
else
|
||||
|
@ -727,8 +844,10 @@ Returns a NSNumber
|
|||
NSDebugMLog(@"cString='%s' endPtr='%s'",cString,endPtr);
|
||||
if (endPtr && *endPtr)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Bad hex number line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEWrongHexNumberFormat
|
||||
format:@"In %@ %@: Bad hex number line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
value=[NSNumber numberWithInt:intValue];
|
||||
|
@ -856,8 +975,10 @@ Returns a NSString
|
|||
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
|
||||
if (_index>=_length)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Reached buffer end while trying to parse value of a dictionary entry",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedBufferEnd
|
||||
format:@"In %@ %@: Reached buffer end while trying to parse value of a dictionary entry",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:keyStartIndex]];
|
||||
}
|
||||
else if (_uniBuf[_index]=='=')
|
||||
|
@ -869,8 +990,10 @@ Returns a NSString
|
|||
|
||||
if (_index>=_length)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Reached buffer end while trying to parse value of a dictionary entry",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedBufferEnd
|
||||
format:@"In %@ %@: Reached buffer end while trying to parse value of a dictionary entry",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:keyStartIndex]];
|
||||
}
|
||||
else
|
||||
|
@ -884,8 +1007,10 @@ Returns a NSString
|
|||
forKey:key];
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No value for key '%@' at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingValue
|
||||
format:@"In %@ %@: No value for key '%@' at line %d",
|
||||
_frameworkName,_fileName,
|
||||
key,[self lineIndexFromIndex:keyStartIndex]];
|
||||
};
|
||||
|
||||
|
@ -893,8 +1018,10 @@ Returns a NSString
|
|||
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
|
||||
if (_index>=_length)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Reached buffer end while parse dictionary starting at %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedBufferEnd
|
||||
format:@"In %@ %@: Reached buffer end while parse dictionary starting at %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:keyStartIndex]];
|
||||
}
|
||||
else if (_uniBuf[_index]==';')
|
||||
|
@ -905,22 +1032,28 @@ Returns a NSString
|
|||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No '=' sign when parsing dictionary entry (key = '%@') at line %d but '%c'",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingSeparator
|
||||
format:@"In %@ %@: No '=' sign when parsing dictionary entry (key = '%@') at line %d but '%c'",
|
||||
_frameworkName,_fileName,
|
||||
key,[self lineIndexFromIndex:keyStartIndex],(char)_uniBuf[_index]];
|
||||
};
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Reached buffer end while trying to parse dictionary started at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedBufferEnd
|
||||
format:@"In %@ %@: Reached buffer end while trying to parse dictionary started at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
if (_index==startIndex)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Found nothing when parsing dictionary at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEDictionaryParsingError
|
||||
format:@"In %@ %@: Found nothing when parsing dictionary at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
}
|
||||
|
@ -970,8 +1103,10 @@ Returns a NSString
|
|||
[array addObject:value];
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No value at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingValue
|
||||
format:@"IN %@ %@: No value at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:valueStartIndex]];
|
||||
};
|
||||
|
||||
|
@ -979,8 +1114,10 @@ Returns a NSString
|
|||
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
|
||||
if (_index>=_length)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Reached buffer end parsing array line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedBufferEnd
|
||||
format:@"In %@ %@: Reached buffer end parsing array line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
}
|
||||
else if (_uniBuf[_index]==',')
|
||||
|
@ -990,23 +1127,29 @@ Returns a NSString
|
|||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Bad character '%c' parsing array line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedCharacter
|
||||
format:@"In %@ %@: Bad character '%c' parsing array line %d",
|
||||
_frameworkName,_fileName,
|
||||
(char)_uniBuf[_index],[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Reached buffer end while trying to parse array started at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedBufferEnd
|
||||
format:@"In %@ %@: Reached buffer end while trying to parse array started at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
|
||||
if (_index==valueStartIndex)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Found nothing when parsing array at line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEArrayParsingError
|
||||
format:@"In %@ %@: Found nothing when parsing array at line %d",
|
||||
_frameworkName,_fileName,
|
||||
[self lineIndexFromIndex:startIndex]];
|
||||
};
|
||||
}
|
||||
|
@ -1035,8 +1178,10 @@ Returns a GSWDeclaration.
|
|||
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
|
||||
if (_index>=_length)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"End of buffer before getting declaration type for '%@' line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedBufferEnd
|
||||
format:@"In %@ %@: End of buffer before getting declaration type for '%@' line %d",
|
||||
_frameworkName,_fileName,
|
||||
identifier,[self currentLineIndex]];
|
||||
}
|
||||
else if (_uniBuf[_index]==':')
|
||||
|
@ -1050,8 +1195,10 @@ Returns a GSWDeclaration.
|
|||
[self skipBlanksAndComments];
|
||||
if (_index>=_length)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"End of buffer before getting declaration bindings for '%@' (type '%@') line %d",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedBufferEnd
|
||||
format:@"In %@ %@: End of buffer before getting declaration bindings for '%@' (type '%@') line %d",
|
||||
_frameworkName,_fileName,
|
||||
identifier,type,[self currentLineIndex]];
|
||||
}
|
||||
else if (_uniBuf[_index]=='{')
|
||||
|
@ -1072,14 +1219,52 @@ Returns a GSWDeclaration.
|
|||
associations:associations];
|
||||
}
|
||||
else
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"don't know whet do do with '%c' line %d.",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEUnexpectedCharacter
|
||||
format:@"In %@ %@: Don't know what do do with '%c' line %d.",
|
||||
_frameworkName,_fileName,
|
||||
(char)_uniBuf[_index],[self currentLineIndex]];
|
||||
}
|
||||
else if (_uniBuf[_index]=='=') // Alias like Identifier1=Identifier2;
|
||||
{
|
||||
NSString* aliasedIdentifier=nil;
|
||||
GSWDeclaration* aliasedDeclaration=nil;
|
||||
_index++;
|
||||
[self skipBlanksAndComments];
|
||||
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
|
||||
aliasedIdentifier=[self parseIdentifier];
|
||||
[self skipBlanksAndComments];
|
||||
if (_index<_length)
|
||||
{
|
||||
if (_uniBuf[_index]==';')
|
||||
{
|
||||
_index++;
|
||||
};
|
||||
};
|
||||
NSDebugMLog(@"aliasedIdentifier=%@",aliasedIdentifier);
|
||||
aliasedDeclaration=[_declarations objectForKey:aliasedIdentifier];
|
||||
if (aliasedDeclaration)
|
||||
{
|
||||
declaration=[GSWDeclaration declarationWithName:identifier
|
||||
type:[aliasedDeclaration type]
|
||||
associations:[aliasedDeclaration associations]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"No ':' delimiter while parsing declaration for '%@' line %d. Found '%c'",
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingAliasedDeclaration
|
||||
format:@"In %@ %@: Can't find declaration named '%@' to be aliased as '%@'. line %d.",
|
||||
_frameworkName,_fileName,
|
||||
aliasedIdentifier,identifier,
|
||||
[self currentLineIndex]];
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
[GSWDeclarationFormatException
|
||||
raise:GSWDFEMissingSeparator
|
||||
format:@"In %@ %@: No ':' delimiter while parsing declaration for '%@' line %d. Found '%c'",
|
||||
_frameworkName,_fileName,
|
||||
identifier,[self currentLineIndex],(char)_uniBuf[_index]];
|
||||
};
|
||||
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
|
||||
|
|
Loading…
Reference in a new issue