/
TDLiteral.m
55 lines (42 loc) · 1.16 KB
/
TDLiteral.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// TDLiteral.m
// TDParseKit
//
// Created by Todd Ditchendorf on 7/13/08.
// Copyright 2008 Todd Ditchendorf. All rights reserved.
//
#import "TDLiteral.h"
#import "TDToken.h"
@interface TDLiteral ()
@property (nonatomic, retain) TDToken *literal;
@end
@implementation TDLiteral
+ (id)literalWithString:(NSString *)s {
return [[[self alloc] initWithString:s] autorelease];
}
- (id)initWithString:(NSString *)s {
//NSParameterAssert(s);
self = [super initWithString:s];
if (self) {
self.literal = [TDToken tokenWithTokenType:TDTokenTypeWord stringValue:s floatValue:0.0];
}
return self;
}
- (void)dealloc {
self.literal = nil;
[super dealloc];
}
- (BOOL)qualifies:(id)obj {
return [literal.stringValue isEqualToString:[obj stringValue]];
//return [literal isEqual:obj];
}
- (NSString *)description {
NSString *className = [[self className] substringFromIndex:2];
if (name.length) {
return [NSString stringWithFormat:@"%@ (%@) %@", className, name, literal.stringValue];
} else {
return [NSString stringWithFormat:@"%@ %@", className, literal.stringValue];
}
}
@synthesize literal;
@end