Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 48 lines (39 sloc) 1.08 kb
7aa6b9d The remaining "core" files OBJJified (with probable errors)
Ross Boucher authored
1
2 @import "TDTokenizerState.j"
3
4 @implementation TDSymbolState : TDTokenizerState
5 {
6 TDSymbolRootNode rootNode;
7 CPArray addedSymbols;
8 }
9
10 - (id)init
11 {
12 self = [super init];
13 if (self) {
14 rootNode = [[TDSymbolRootNode alloc] init];
15 addedSymbols = [];
16 }
17 return self;
18 }
19
20 - (TDToken)nextTokenFromReader:(TDReader)r startingWith:(int)cin tokenizer:(TDTokenizer)t
21 {
22 var symbol = [rootNode nextSymbol:r startingWith:cin],
23 len = symbol.length;
24
25 if (0 == len || (len > 1 && [addedSymbols containsObject:symbol])) {
26 return [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:symbol floatValue:0.0];
27 } else {
28 for (var i=0 ; i < len - 1; i++) {
29 [r unread];
30 }
31 return [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:[CPString stringWithFormat:@"%C", cin] floatValue:0.0];
32 }
33 }
34
35 - (void)add:(CPString)s
36 {
37 [rootNode add:s];
38 [addedSymbols addObject:s];
39 }
40
41 - (void)remove:(CPString)s
42 {
43 [rootNode remove:s];
44 [addedSymbols removeObject:s];
45 }
46
47 @end
Something went wrong with that request. Please try again.