Beispiel #1
0
        public static string Create(string code, AphidParserException exception, bool highlight)
        {
            var actualCode = exception?.Filename != null && File.Exists(exception.Filename) ?
                             AphidScript.Read(exception.Filename) :
                             code;

            return
                (exception.UnexpectedToken.TokenType != AphidTokenType.None ? FromToken(actualCode, exception, highlight) :
                 exception.Expression != null?FromExpression(actualCode, exception, highlight) :
                     exception.Message);
        }
        public static string Create(string code, AphidParserException exception)
        {
            var line = TokenHelper.GetIndexPosition(code, exception.UnexpectedToken.Index);

            return string.Format(
                "Unexpected {0} {1} on line {2}\r\n\r\n{3}\r\n",
                exception.UnexpectedToken.TokenType.ToString().ToLower(),
                exception.UnexpectedToken.Lexeme,
                line.Item1,
                TokenHelper.GetCodeExcerpt(code, exception.UnexpectedToken));
        }
Beispiel #3
0
 public static string Create(string code, AphidParserException exception) =>
 Create(code, exception, true);