mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
* Source/NSPredicate.m: Fixup parsing of function expressions.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36011 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
abb9304bbd
commit
dde8376be9
2 changed files with 37 additions and 22 deletions
|
@ -1,3 +1,7 @@
|
|||
2013-01-22 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSPredicate.m: Fixup parsing of function expressions.
|
||||
|
||||
2013-01-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSLocale.m: ([-_getExemplarCharacterSet]) Fix error in handling
|
||||
|
|
|
@ -784,7 +784,7 @@ static NSExpression *evaluatedObjectExpression = nil;
|
|||
opt = @"[cd]";
|
||||
break;
|
||||
default:
|
||||
opt = @"[?options?]";
|
||||
//opt = @"[?options?]";
|
||||
break;
|
||||
}
|
||||
return [NSString stringWithFormat: @"%@%@ %@%@ %@",
|
||||
|
@ -1096,7 +1096,7 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
NSString *s;
|
||||
|
||||
e = [[GSFunctionExpression alloc] initWithExpressionType: NSFunctionExpressionType];
|
||||
s = [NSString stringWithFormat: @"_eval_%@: context: ", name];
|
||||
s = [NSString stringWithFormat: @"_eval_%@:", name];
|
||||
e->_selector = NSSelectorFromString(s);
|
||||
if (![e respondsToSelector: e->_selector])
|
||||
{
|
||||
|
@ -1398,6 +1398,11 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
return _function;
|
||||
}
|
||||
|
||||
- (NSString *) keyPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) expressionValueWithObject: (id)object
|
||||
context: (NSMutableDictionary *)context
|
||||
{
|
||||
|
@ -2047,11 +2052,32 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
return [self parseBinaryExpression];
|
||||
}
|
||||
|
||||
- (NSExpression *) parseSimpleExpression
|
||||
- (NSExpression *) parseIdentifierExpression
|
||||
{
|
||||
static NSCharacterSet *_identifier;
|
||||
unsigned location;
|
||||
NSString *ident;
|
||||
|
||||
// skip # as prefix (reserved words)
|
||||
[self scanString: @"#" intoString: NULL];
|
||||
if (!_identifier)
|
||||
{
|
||||
ASSIGN(_identifier, [NSCharacterSet characterSetWithCharactersInString:
|
||||
@"_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"]);
|
||||
}
|
||||
|
||||
if (![self scanCharactersFromSet: _identifier intoString: &ident])
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Missing identifier: %@",
|
||||
[[self string] substringFromIndex: [self scanLocation]]];
|
||||
}
|
||||
|
||||
return [NSExpression expressionForKeyPath: ident];
|
||||
}
|
||||
|
||||
- (NSExpression *) parseSimpleExpression
|
||||
{
|
||||
unsigned location;
|
||||
double dbl;
|
||||
|
||||
if ([self scanDouble: &dbl])
|
||||
|
@ -2128,7 +2154,7 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
if ([self scanString: @"$" intoString: NULL])
|
||||
{
|
||||
// variable
|
||||
NSExpression *var = [self parseExpression];
|
||||
NSExpression *var = [self parseIdentifierExpression];
|
||||
|
||||
if (![var keyPath])
|
||||
{
|
||||
|
@ -2247,7 +2273,7 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
|
||||
if ([self scanString: @"@" intoString: NULL])
|
||||
{
|
||||
NSExpression *e = [self parseExpression];
|
||||
NSExpression *e = [self parseIdentifierExpression];
|
||||
|
||||
if (![e keyPath])
|
||||
{
|
||||
|
@ -2260,22 +2286,7 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
[NSString stringWithFormat: @"@%@", [e keyPath]]];
|
||||
}
|
||||
|
||||
// skip # as prefix (reserved words)
|
||||
[self scanString: @"#" intoString: NULL];
|
||||
if (!_identifier)
|
||||
{
|
||||
ASSIGN(_identifier, [NSCharacterSet characterSetWithCharactersInString:
|
||||
@"_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"]);
|
||||
}
|
||||
|
||||
if (![self scanCharactersFromSet: _identifier intoString: &ident])
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Missing identifier: %@",
|
||||
[[self string] substringFromIndex: [self scanLocation]]];
|
||||
}
|
||||
|
||||
return [NSExpression expressionForKeyPath: ident];
|
||||
return [self parseIdentifierExpression];
|
||||
}
|
||||
|
||||
- (NSExpression *) parseFunctionalExpression
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue