/// <summary> /// /// </summary> /// <param name="stream"></param> /// <returns></returns> /// <remarks> /// /// See http://www.dmtf.org/sites/default/files/standards/documents/DSP0221_3.0.0a.pdf /// /// A.17.3 String values /// /// Unless explicitly specified via ABNF rule WS, no whitespace is allowed between the elements of the rules /// in this ABNF section. /// /// stringValue = DOUBLEQUOTE *stringChar DOUBLEQUOTE /// *( *WS DOUBLEQUOTE *stringChar DOUBLEQUOTE ) /// stringChar = stringUCSchar / stringEscapeSequence /// /// </remarks> private static StringLiteralToken ReadStringLiteralToken(ILexerStream stream) { // BUGBUG - no support for *( *WS DOUBLEQUOTE *stringChar DOUBLEQUOTE ) // BUGBUG - incomplete escape sequences // BUGBUG - no support for UCS characters var sourceChars = new List <SourceChar>(); // read the first character sourceChars.Add(stream.ReadChar('"')); // read the remaining characters var parser = new StringLiteralParser(); while (!stream.Eof) { var peek = stream.Peek(); if (StringValidator.IsDoubleQuote(peek.Value) && !parser.IsEscaped) { parser.ConsumeEos(); break; } else { sourceChars.Add(peek); parser.ConsumeChar(stream.Read()); } } // read the last character sourceChars.Add(stream.ReadChar('"')); // process any escape sequences in the string var unescaped = parser.OutputString.ToString(); // return the result var extent = new SourceExtent(sourceChars); return(new StringLiteralToken(extent, unescaped)); }
public static void IsDoubleQuoteTest(char value, bool expectedResult) { var result = StringValidator.IsDoubleQuote(value); Assert.AreEqual(expectedResult, result); }