SILUBS.ScriptureChecks.ProcessPunctationTokens.BasicFinalize C# (CSharp) Method

BasicFinalize() private method

Basic finalize is complicated because it generates a pattern for every punctuation mark. An exception is if multiple consecutive periods occur, then a string of periods will be in one pattern.
private BasicFinalize ( string desiredKey, List result ) : void
desiredKey string If specified, indicates a specific punctuation pattern to /// seek (all others will be discarded); To retrieve all punctation substrings, specify /// the empty string.
result List List of TextTokenSubstring items that will be added to
return void
		private void BasicFinalize(string desiredKey, List<TextTokenSubstring> result)
		{
			PunctuationToken pTok;
			for (int i = 0; i < m_puncts.Count; ++i)
			{
				pTok = m_puncts[i];
				if (pTok.TokenType != PunctuationTokenType.punctuation)
					continue;

				// Normally i and j end up the same.
				// When multiple consecutive periods occur (e.g. blah...blah)
				// i will be the first period and j the last period.
				int j = i;
				while (m_puncts[i].ToString() == "." && j + 1 < m_puncts.Count &&
					m_puncts[j + 1].ToString() == ".")
				{
					++j;
				}

				string pattern = PunctuationSequencePatternPrefix(i);
				for (int k = i; k <= j; ++k)
					pattern += m_puncts[k].ToString();

				pattern += PunctuationSequencePatternSuffix(j);
				pTok.Tts.InventoryText = pattern;

				if (desiredKey == String.Empty || desiredKey == pTok.Tts.InventoryText)
					result.Add(pTok.Tts);

				i = j;
			}
		}