From 42f43b7686038e4cbca16d8d2118b139544e6de3 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 13 Apr 2008 03:35:00 -0400 Subject: Check in all changes made so far toward 3.0. --- error.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'error.h') diff --git a/error.h b/error.h index 7f77db0f..76839157 100644 --- a/error.h +++ b/error.h @@ -122,4 +122,20 @@ class fatal_assert : public fatal { virtual ~fatal_assert() throw() {} }; +inline void unexpected(char c, char wanted) +{ + if ((unsigned char) c == 0xff) { + if (wanted) + throw new error(std::string("Missing '") + wanted + "'"); + else + throw new error("Unexpected end of input"); + } else { + if (wanted) + throw new error(std::string("Invalid char '") + c + + "' (wanted '" + wanted + "')"); + else + throw new error(std::string("Invalid char '") + c + "'"); + } +} + #endif // _ERROR_H -- cgit v1.2.3