forked from cappuccino/socratic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TMLanguageRuleReference.j
57 lines (44 loc) · 1.2 KB
/
TMLanguageRuleReference.j
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
56
57
@implementation TMLanguageRuleReference : CPObject
{
TMLanguageRule rule;
CPString referenceName @accessors(readonly);
TMLanguageGrammar grammar @accessors(readonly);
}
- (id)initWithReferenceName:(CPString)aReferenceName grammar:(TMLanguageGrammar)aGrammar
{
self = [super init];
if (self)
{
referenceName = aReferenceName;
grammar = aGrammar;
}
return self;
}
- (id)rule
{
if (!rule)
{
if (referenceName === @"$self" || referenceName === @"$base")
rule = [grammar baseRule];
else if (referenceName.charAt(0) === "#")
rule = [[grammar repository] objectForKey:referenceName.substr(1)];
else
rule = [TMLanguageGrammar grammarWithScopeName:referenceName];
}
return rule;
}
-(CPMethodSignature)methodSignatureForSelector:(SEL)aSelector
{
if ([[self rule] respondsToSelector:aSelector])
return 1;
return nil;//[_preparedTarget methodSignatureForSelector:selector];
}
- (void)forwardInvocation:(CPInvocation)anInvocation
{
[anInvocation invokeWithTarget:[self rule]];
}
- (void)description
{
return [super description] + " (" + referenceName + ")";
}
@end