Skip to content

Commit

Permalink
* delimit state rewrite done.
Browse files Browse the repository at this point in the history
  • Loading branch information
itod committed Apr 17, 2014
1 parent 9d48fa6 commit b8a4b38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion res/quote_symbol.grammar
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@before {
PKTokenizer *t = self.tokenizer;
[t setTokenizerState:t.symbolState from:'"' to:'"'];
[t setTokenizerState:t.symbolState from:'\'' to:'\''];
[t setTokenizerState:t.symbolState from:'\\'' to:'\\''];
}

start = sym+;
Expand Down
15 changes: 7 additions & 8 deletions src/PKDelimitState.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ - (PKToken *)nextTokenFromReader:(PKReader *)r startingWith:(PKUniChar)cin token

for (;;) {
c = [r read];
// if ('\\' == c) {
// c = [r read];
// [self append:c];
// continue;
// }
if ('\\' == c) {
c = [r read];
[self append:c];
continue;
}

if (PKEOF == c) {
if (!_balancesEOFTerminatedStrings) {
Expand All @@ -154,11 +154,11 @@ - (PKToken *)nextTokenFromReader:(PKReader *)r startingWith:(PKUniChar)cin token
NSString *marker = [currRootNode nextSymbol:r startingWith:c];
if ([marker length]) {
for (PKDelimitDescriptor *desc in matchingDescs) {
if (_allowsNestedMarkers && [marker isEqualToString:desc.startMarker]) {
if (_allowsNestedMarkers && [marker isEqualToString:desc.startMarker] && ![desc.startMarker isEqualToString:desc.endMarker]) {
++stackCount;
break;
} else if ([marker isEqualToString:desc.endMarker]) {
if (_allowsNestedMarkers && stackCount > 0) {
if (_allowsNestedMarkers && stackCount > 0 && ![desc.startMarker isEqualToString:desc.endMarker]) {
--stackCount;
break;
} else {
Expand Down Expand Up @@ -215,7 +215,6 @@ - (PKToken *)nextTokenFromReader:(PKReader *)r startingWith:(PKUniChar)cin token
tok = [[self nextTokenizerStateFor:cin tokenizer:t] nextTokenFromReader:r startingWith:cin tokenizer:t];
}

NSAssert(0 == stackCount, @"");
return tok;
}

Expand Down

0 comments on commit b8a4b38

Please sign in to comment.