private static ParsingMessage ToParsingMessage(ParserMessage ironyMessage, string source) { return new ParsingMessage( ironyMessage.Message, (ParsingMessageKind)ironyMessage.Level, ParsingConverter.FromIrony(ironyMessage.Location, source) ); }
private static ParsingMessage ToParsingMessage(ParserMessage ironyMessage, string source) { return(new ParsingMessage( ironyMessage.Message, (ParsingMessageKind)ironyMessage.Level, ParsingConverter.FromIrony(ironyMessage.Location, source) )); }
private static string TranslateMessage(ParserMessage e) { var result = e.Message; if (result == "Unexpected end of file.") { result = "Unfinished expression"; } return(result); }
/// <summary> /// Creates a new GQLParsingException exception /// </summary> /// <param name="myParserError">The parser message from Irony (contains a message from kind of info, warning or error)</param> /// <param name="myQuery">The given query</param> /// <param name="innerException">The exception that is the cause of the current exception, this parameter can be NULL.</param> public GQLParsingException(ParserMessage myParserError, String myQuery, Exception innerException = null) : base(innerException) { ParserError = myParserError; Info = myQuery; if (ParserError != null) { if (ParserError.Exception != null) _msg = String.Format("Parser error during query: [{0}]\n\n gql: [{1}]\n\nAt position: {2}\n\nException:{3}", Info, ParserError.Message, ParserError.Location.ToString(), ParserError.Exception.ToString()); else _msg = String.Format("Parser error during query: [{0}]\n\n gql: [{1}]\n\nAt position: {2}", Info, ParserError.Message, ParserError.Location.ToString()); } }
/// <summary> /// Creates a new GqlSyntaxException exception /// </summary> /// <param name="mySyntaxError">The parser message from Irony (contains a message from kind of info, warning or error)</param> /// <param name="myQuery">The given query</param> /// <param name="innerException">The exception that is the cause of the current exception, this parameter can be NULL.</param> public GqlSyntaxException(ParserMessage mySyntaxError, String myQuery, Exception innerException = null) : base(innerException) { SyntaxError = mySyntaxError; Info = myQuery; if (SyntaxError != null) { if (SyntaxError.Exception != null) _msg = String.Format("Syntax error in query: [{0}]\n\n gql: [{1}]\n\nAt position: {2}\n\nException:{3}", Info, SyntaxError.Message, SyntaxError.Location.ToString(), SyntaxError.Exception.ToString()); else _msg = String.Format("Syntax error in query: [{0}]\n\n gql: [{1}]\n\nAt position: {2}", Info, SyntaxError.Message, SyntaxError.Location.ToString()); } }
public ParserMessage Parse(string source) { ParseCaffePrototxt(source); var converter = new CaffeConverter(Properties); converter.TransformToNetwork(); var message = new ParserMessage { Network = converter.Network, Data = source, ParseDate = DateTime.Now, ParserName = ParserName }; MessageParsedEvent?.Invoke(message); return(message); }
/// <summary> /// Creates a new GqlSyntaxException exception /// </summary> /// <param name="mySyntaxError">The parser message from Irony (contains a message from kind of info, warning or error)</param> /// <param name="myQuery">The given query</param> /// <param name="innerException">The exception that is the cause of the current exception, this parameter can be NULL.</param> public GqlSyntaxException(ParserMessage mySyntaxError, String myQuery, Exception innerException = null) : base(innerException) { SyntaxError = mySyntaxError; Info = myQuery; if (SyntaxError != null) { if (SyntaxError.Exception != null) { _msg = String.Format("Syntax error in query: [{0}]\n\n gql: [{1}]\n\nAt position: {2}\n\nException:{3}", Info, SyntaxError.Message, SyntaxError.Location.ToString(), SyntaxError.Exception.ToString()); } else { _msg = String.Format("Syntax error in query: [{0}]\n\n gql: [{1}]\n\nAt position: {2}", Info, SyntaxError.Message, SyntaxError.Location.ToString()); } } }
/// <summary> /// Creates a new GQLParsingException exception /// </summary> /// <param name="myParserError">The parser message from Irony (contains a message from kind of info, warning or error)</param> /// <param name="myQuery">The given query</param> /// <param name="innerException">The exception that is the cause of the current exception, this parameter can be NULL.</param> public GQLParsingException(ParserMessage myParserError, String myQuery, Exception innerException = null) : base(innerException) { ParserError = myParserError; Info = myQuery; if (ParserError != null) { if (ParserError.Exception != null) { _msg = String.Format("Parser error during query: [{0}]\n\n gql: [{1}]\n\nAt position: {2}\n\nException:{3}", Info, ParserError.Message, ParserError.Location.ToString(), ParserError.Exception.ToString()); } else { _msg = String.Format("Parser error during query: [{0}]\n\n gql: [{1}]\n\nAt position: {2}", Info, ParserError.Message, ParserError.Location.ToString()); } } }
//--- 9 private ParserMessage MessageReceived(BasicDeliverEventArgs args, ref RequireFunction lastMessageType, ref string onDemandLocationId) { var messageString = Encoding.UTF8.GetString(args.Body); count++; //Creates the object for the desired type. var parserMessageTemp = new ParserMessage(messageString); if (!string.IsNullOrEmpty(parserMessageTemp.ErrorMessage)) { logger.Error("code: {0},{1}. message: {2}", parserMessageTemp.GetMessageId(), (int)Errors.ScraperMessageCanotbeAnalysed, parserMessageTemp.ErrorMessage); return new ParserMessage(); } lastMessageType = parserMessageTemp.Parameters.Function; onDemandLocationId = parserMessageTemp.Parameters.LocationId; parserMessageTemp.MessageEventArgs = args; return parserMessageTemp; }
private bool ParseError(string fileName, string errFileName) { bool r = true; if (File.Exists(errFileName)) { StreamReader sr = new StreamReader(errFileName); do { string line = sr.ReadLine(); if (line != null) { if (line.Length == 0 || line.StartsWith("Number of errors:") || line.StartsWith("Number of warnings:") || line.StartsWith("\tIgnoring code generation") || line.StartsWith("Duplicate errors/warnings found in line") ) { //skip } else if (line.StartsWith("Error:")) { int sep = line.IndexOf(':'); ParserMessage message = new ParserMessage(); message.Level = ParseMessageLevel.Error; message.Message = line.Substring(sep + 1) + "\n" + sr.ReadLine(); message.FileName = fileName; if (console != null && message.Level > project.ParserOptions.ErrorLevel) console.ErrorWriteLine(message.Message); r = false; result.Messages.Add(message); } else if (line.StartsWith("Error in line")) { int sep = line.IndexOf(':'); ParserMessage message = new ParserMessage(); message.Level = ParseMessageLevel.Error; message.Message = line.Substring(sep + 1) + "\n" + sr.ReadLine(); message.FileName = fileName; string num = line.Substring(13, sep - 13); int.TryParse(num, out message.Line); if (console != null && message.Level > project.ParserOptions.ErrorLevel) console.ErrorWriteLine(message.Message); r = false; result.Messages.Add(message); } else if (line.StartsWith("Warning:")) { ParserMessage message = new ParserMessage(); message.Level = ParseMessageLevel.Warning; message.Message = sr.ReadLine(); message.FileName = fileName; if (console != null && message.Level > project.ParserOptions.ErrorLevel) console.ErrorWriteLine(message.Message); result.Messages.Add(message); } else if (line.StartsWith("Warning in line")) { int sep = line.IndexOf(':'); ParserMessage message = new ParserMessage(); message.Level = ParseMessageLevel.Warning; message.Message = line.Substring(sep + 1) + "\n" + sr.ReadLine(); message.FileName = fileName; string num = line.Substring(15, sep - 15); int.TryParse(num, out message.Line); if (console != null && message.Level > project.ParserOptions.ErrorLevel) console.ErrorWriteLine(message.Message); result.Messages.Add(message); } else { ParserMessage message = new ParserMessage(); message.Level = ParseMessageLevel.Warning; message.Message = sr.ReadLine(); message.FileName = fileName; if (console != null && message.Level > project.ParserOptions.ErrorLevel) console.ErrorWriteLine(message.Message); r = false; result.Messages.Add(message); } } else { break; } } while (true); sr.Close(); File.Delete(errFileName); } return r; }
private static string TranslateMessage(ParserMessage e) { var result = e.Message; if (result == "Unexpected end of file.") { result = "Unfinished expression"; } return result; }
protected internal void WriteMessage(ParserMessage message) { if (console != null && message.Level > project.ParserOptions.ErrorLevel) console.ErrorWriteLine(message.Message); if (message.Level > ParseMessageLevel.Warning) { errCount++; if (errCount > 10) { if (project.ParserOptions.ErrorLevel <= ParseMessageLevel.Warning && console!=null) { console.ErrorWriteLine("Too much errors"); } throw new ParserException("Too much errors"); } result.Succesfull = false; } result.Messages.Add(message); }