IsolateQuotedWord( string Text, int Bx, TextTraits Traits) { ScanPatternResults spr = null; int? ex = null; string wordText = null; char ch1 = Text[Bx]; LiteralType litType = LiteralType.none; // is start of a verbatim string literal if ((Traits.VerbatimLiteralPattern != null) && (Traits.VerbatimLiteralPattern.Match(Text, Bx))) { var rv = VerbatimLiteral.ScanCloseQuote( Text, Traits.VerbatimLiteralPattern, Bx); ex = rv.Item1; wordText = rv.Item2; litType = LiteralType.VerbatimString; } // is a quoted literal else if (Traits.IsQuoteChar(ch1) == true) { ex = Scanner.ScanCloseQuote(Text, Bx, Traits.QuoteEncapsulation); if (ex.Value != -1) { int lx = ex.Value - Bx + 1; wordText = Text.Substring(Bx, lx); // correct the following at some point. Should be either string or // char lit. litType = LiteralType.String; } } // not a quoted literal if ((ex == null) || (ex.Value == -1)) { throw (new ApplicationException( "Closing quote not found starting at position " + Bx.ToString() + " in " + Text)); } else { // setup the non word which follows the closing quote. int ix = ex.Value + 1; if (Text.IsPastEnd(ix)) { spr = new ScanPatternResults(-1); } else { // the char that follows the closing quote must be a delim int remLx = Text.Length - ix; spr = Scanner.ScanEqualAny(Text, ix, remLx, Traits.NonWordPatterns); if (spr.FoundPos != ix) { throw new ApplicationException( "invalid char follows close quote at pos " + ix.ToString() + " in " + Stringer.Head(Text, 80)); } } } return(new Tuple <int, int?, string, LiteralType, ScanPatternResults> (Bx, ex, wordText, litType, spr)); }