-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTDTrack.j
68 lines (52 loc) · 1.74 KB
/
TDTrack.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
58
59
60
61
62
63
64
65
66
67
68
@import "TDSequence.j"
@import "TDAssembly.j"
//@import "TDTrackException.j"
@implementation TDTrack : TDSequence
{
}
+ (id)track
{
return [[self alloc] init];
}
- (CPSet)allMatchesFor:(CPSet)inAssemblies
{
var inTrack = NO,
lastAssemblies = inAssemblies,
outAssemblies = inAssemblies;
for (var i=0, count=[subparsers count]; i<count; i++)
{
var p = subparsers[i];
outAssemblies = [i matchAndAssemble:outAssemblies];
if (![outAssemblies count])
{
if (inTrack)
[self throwTrackExceptionWithPreviousState:lastAssemblies parser:p];
break;
}
inTrack = YES;
lastAssemblies = outAssemblies;
}
return outAssemblies;
}
- (void)throwTrackExceptionWithPreviousState:(NSSet *)inAssemblies parser:(TDParser *)p
{
[CPException raise:"TDTrackException" reason:"TDTrack"];
/*
TDAssembly *best = [self best:inAssemblies];
NSString *after = [best consumedObjectsJoinedByString:@" "];
if (!after.length) {
after = @"-nothing-";
}
NSString *expected = [p description];
id next = [best peek];
NSString *found = next ? [next description] : @"-nothing-";
NSString *reason = [NSString stringWithFormat:@"\n\nAfter : %@\nExpected : %@\nFound : %@\n\n", after, expected, found];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
after, @"after",
expected, @"expected",
found, @"found",
nil];
[[TDTrackException exceptionWithName:TDTrackExceptionName reason:reason userInfo:userInfo] raise];
*/
}
@end