Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 74 lines (62 sloc) 2.114 kB
7aa6b9d The remaining "core" files OBJJified (with probable errors)
Ross Boucher authored
1
2 @import "TDTokenizerState.j"
3 @import "TDToken.j"
4 @import "TDReader.j"
5 @import "TDSymbolRootNode.j"
6 @import "TDMultiLineCommentState.j"
7 @import "TDSingleLineCommentState.j"
8
9 @implementation TDCommentState : TDTokenizerState
10 {
11 TDSymbolRootNode rootNode;
12 TDSingleLineCommentState singleLineState;
13 TDMultiLineCommentState multiLineState;
14
15 BOOL reportsCommentTokens;
16 BOOL balancesEOFTerminatedComments;
17 }
18
19 - (id)init
20 {
21 self = [super init];
22 if (self) {
23 rootNode = [[TDSymbolRootNode alloc] init];
24 singleLineState = [[TDSingleLineCommentState alloc] init];
25 multiLineState = [[TDMultiLineCommentState alloc] init];
26 }
27 return self;
28 }
29
30 - (void)addSingleLineStartSymbol:(CPString)start
31 {
32 [rootNode add:start];
33 [singleLineState addStartSymbol:start];
34 }
35
36 - (void)removeSingleLineStartSymbol:(CPString)start
37 {
38 [rootNode remove:start];
39 [singleLineState removeStartSymbol:start];
40 }
41
42 - (void)addMultiLineStartSymbol:(CPString)start endSymbol:(CPString)end
43 {
44 [rootNode add:start];
45 [rootNode add:end];
46 [multiLineState addStartSymbol:start endSymbol:end];
47 }
48
49 - (void)removeMultiLineStartSymbol:(CPString)start
50 {
51 [rootNode remove:start];
52 [multiLineState removeStartSymbol:start];
53 }
54
55 - (TDToken)nextTokenFromReader:(TDReader)r startingWith:(int)cin tokenizer:(TDTokenizer)t
56 {
57 var symbol = [rootNode nextSymbol:r startingWith:cin];
58
59 if ([multiLineState.startSymbols containsObject:symbol]) {
60 multiLineState.currentStartSymbol = symbol;
61 return [multiLineState nextTokenFromReader:r startingWith:cin tokenizer:t];
62 } else if ([singleLineState.startSymbols containsObject:symbol]) {
63 singleLineState.currentStartSymbol = symbol;
64 return [singleLineState nextTokenFromReader:r startingWith:cin tokenizer:t];
65 } else {
66 for (var i=0, length = symbol.length ; i < symbol.length - 1; i++) {
67 [r unread];
68 }
69 return [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:[CPString stringWithFormat:@"%C", cin] floatValue:0.0];
70 }
71 }
72
73 @end
Something went wrong with that request. Please try again.