internal static string ResolveExceptionMessage(LexerExceptionCodes code, int length) { switch (code) { case LexerExceptionCodes.InvalidEscapeSequence: return("Invalid escape sequence '{0}'"); case LexerExceptionCodes.Unknown: return("Unknown lexer error."); case LexerExceptionCodes.UnexpectedEndOfStream: return("Unexpected end of stream."); case LexerExceptionCodes.UnexpectedSymbol: return(length == 0 ? "Unexpected symbol." : "Unexpected symbol '{0}'."); case LexerExceptionCodes.UnterminatedBlockComment: return("Unterminated block comment."); case LexerExceptionCodes.UnterminatedStringLiteral: return("Unterminated string literal."); case LexerExceptionCodes.UnterminatedStringContainer: return("Unterminated string container."); default: throw new ArgumentOutOfRangeException(nameof(code), code, null); } }
private LexerException Exception(LexerExceptionCodes code, params object[] args) { var e = new LexerException(code, args); if (!_recordPosition) { return(e); } e.HasMoreInformation = true; e.ExceptionLine = _currentLine; e.ExceptionColumn = _currentColumn; e.ReferenceLine = _tokenLine; e.ReferenceColumn = _tokenColumn; return(e); }
public LexerException(LexerExceptionCodes code, params object[] args) : base(string.Format(ResolveExceptionMessage(code, args.Length), args)) { Code = code; }
public LexerException(LexerExceptionCodes code) : this(code, new object[0]) { }