Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 68 lines (53 sloc) 1.48 kB
98b7f3c Beginnings of porting the Obj-C code to Obj-J.
Ross Boucher authored
1
2 @import "TDParser.j"
3 @import "TDAssembly.j"
4
5 @implementation TDRepetition : TDParser
6 {
7 TDParser subparser;
8 id preassembler;
9 SEL preassemblerSelector;
10 }
11
12 + (id)repetitionWithSubparser:(TDParser *)p
13 {
14 return [[self alloc] initWithSubparser:p];
15 }
16
17 - (id)init
18 {
19 return [self initWithSubparser:nil];
20 }
21
22 - (id)initWithSubparser:(TDParser)p
23 {
24 if (self = [super init])
25 self.subparser = p;
26
27 return self;
28 }
29
30 - (void)setPreassembler:(id)a selector:(SEL)sel
31 {
32 preassembler = a;
33 preassemblerSelector = sel;
34 }
35
36 - (TDParser)parserNamed:(CPString)s
37 {
38 if (name === s)
39 return self;
40 else
41 return [subparser parserNamed:s];
42 }
43
44 - (CPSet)allMatchesFor:(CPSet)inAssemblies
45 {
46 if (preassembler) {
47 //NSAssert2([preassembler respondsToSelector:preassemblerSelector], @"provided preassembler %@ should respond to %s", preassembler, preassemblerSelector);
48 var values = [inAssemblies allValues],
49 length = [values count];
50
51 for (var i=0; i<length; i++)
52 [preassembler performSelector:preassemblerSelector withObject:values[a]];
53 }
54
55 //NSMutableSet *outAssemblies = [[[NSSet alloc] initWithSet:inAssemblies copyItems:YES] autorelease];
56 var outAssemblies = [inAssemblies copy],
57 s = inAssemblies;
58
59 while ([s count]) {
60 s = [subparser matchAndAssemble:s];
61 [outAssemblies unionSet:s];
62 }
63
64 return outAssemblies;
65 }
66
67 @end
Something went wrong with that request. Please try again.