private static CompilerError CreateErrorFromString(string error_string)
{
#if NET_2_0
if (error_string.StartsWith ("BETA"))
return null;
#endif
if (error_string == null || error_string == "")
return null;
CompilerError error=new CompilerError();
Regex reg = new Regex (@"^(\s*(?<file>.*)\((?<line>\d*)(,(?<column>\d*))?\)(:)?\s+)*(?<level>\w+)\s*(?<number>.*):\s(?<message>.*)",
RegexOptions.Compiled | RegexOptions.ExplicitCapture);
Match match=reg.Match(error_string);
if (!match.Success) {
// We had some sort of runtime crash
error.ErrorText = error_string;
error.IsWarning = false;
error.ErrorNumber = "";
return error;
}
if (String.Empty != match.Result("${file}"))
error.FileName=match.Result("${file}");
if (String.Empty != match.Result("${line}"))
error.Line=Int32.Parse(match.Result("${line}"));
if (String.Empty != match.Result("${column}"))
error.Column=Int32.Parse(match.Result("${column}"));
string level = match.Result ("${level}");
if (level == "warning")
error.IsWarning = true;
else if (level != "error")
return null; // error CS8028 will confuse the regex.
error.ErrorNumber=match.Result("${number}");
error.ErrorText=match.Result("${message}");
return error;
}