forked from gavinkwoe/todparsekit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKSequence.m
50 lines (38 loc) · 1.01 KB
/
PKSequence.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
//
// PKSequence.m
// ParseKit
//
// Created by Todd Ditchendorf on 7/13/08.
// Copyright 2009 Todd Ditchendorf. All rights reserved.
//
#import <ParseKit/PKSequence.h>
#import <ParseKit/PKAssembly.h>
@interface PKParser ()
- (NSSet *)matchAndAssemble:(NSSet *)inAssemblies;
@end
@interface PKCollectionParser ()
+ (id)collectionParserWithFirst:(PKParser *)p1 rest:(va_list)rest;
@end
@implementation PKSequence
+ (id)sequence {
return [self sequenceWithSubparsers:nil];
}
+ (id)sequenceWithSubparsers:(PKParser *)p1, ... {
va_list vargs;
va_start(vargs, p1);
PKSequence *seq = [self collectionParserWithFirst:p1 rest:vargs];
va_end(vargs);
return seq;
}
- (NSSet *)allMatchesFor:(NSSet *)inAssemblies {
NSParameterAssert(inAssemblies);
NSSet *outAssemblies = inAssemblies;
for (PKParser *p in subparsers) {
outAssemblies = [p matchAndAssemble:outAssemblies];
if (![outAssemblies count]) {
break;
}
}
return outAssemblies;
}
@end