private string ReadLongString(int fromLine, int fromCol, string startpattern, string subtypeforerrors) { // here we are at the first '=' or second '[' StringBuilder text = new StringBuilder(1024); string end_pattern = "]"; if (startpattern == null) { for (char c = CursorChar(); ; c = CursorCharNext()) { if (c == '\0' || !CursorNotEof()) { throw new SyntaxErrorException( CreateToken(TokenType.Invalid, fromLine, fromCol), "unfinished long {0} near '<eof>'", subtypeforerrors) { IsPrematureStreamTermination = true }; } else if (c == '=') { end_pattern += "="; } else if (c == '[') { end_pattern += "]"; break; } else { throw new SyntaxErrorException( CreateToken(TokenType.Invalid, fromLine, fromCol), "invalid long {0} delimiter near '{1}'", subtypeforerrors, c) { IsPrematureStreamTermination = true }; } } } else { end_pattern = startpattern.Replace('[', ']'); } for (char c = CursorCharNext(); ; c = CursorCharNext()) { if (c == '\r') // XXI century and we still debate on how a newline is made. throw new DeveloperExtremelyAngryException. { continue; } if (c == '\0' || !CursorNotEof()) { throw new SyntaxErrorException( CreateToken(TokenType.Invalid, fromLine, fromCol), "unfinished long {0} near '{1}'", subtypeforerrors, text.ToString()) { IsPrematureStreamTermination = true }; } else if (c == ']' && CursorMatches(end_pattern)) { for (int i = 0; i < end_pattern.Length; i++) { CursorCharNext(); } return(LexerUtils.AdjustLuaLongString(text.ToString())); } else { text.Append(c); } } }