From b8a4b38c668915c015f94283220fef7b8bfc7a77 Mon Sep 17 00:00:00 2001 From: Todd Ditchendorf Date: Thu, 17 Apr 2014 10:56:12 -0500 Subject: [PATCH] * delimit state rewrite done. --- res/quote_symbol.grammar | 2 +- src/PKDelimitState.m | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/res/quote_symbol.grammar b/res/quote_symbol.grammar index 031a294..27b33b5 100644 --- a/res/quote_symbol.grammar +++ b/res/quote_symbol.grammar @@ -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+; diff --git a/src/PKDelimitState.m b/src/PKDelimitState.m index 7f7b15a..b469d1e 100644 --- a/src/PKDelimitState.m +++ b/src/PKDelimitState.m @@ -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) { @@ -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 { @@ -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; }