ParsingExceptions.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_EXCEPTION__PARSING_EXCEPTIONS
18 #define COM_BORA_SOFTWARE__BALAU_EXCEPTION__PARSING_EXCEPTIONS
19 
22 
23 namespace Balau::Exception {
24 
29  public: const Lang::CodeSpan codeSpan;
30 
31  public: SyntaxErrorException(const char * file,
32  int line,
33  const std::string & st,
34  const std::string & text,
35  const Lang::CodeSpan & codeSpan_)
36  : BalauException(file, line, st, "Network", text)
37  , codeSpan(codeSpan_) {}
38 };
39 
40 inline bool operator == (const SyntaxErrorException & lhs, const SyntaxErrorException & rhs) {
41  return lhs.message == rhs.message && lhs.codeSpan == rhs.codeSpan;
42 }
43 
44 template <typename AllocatorT>
46  return toString<AllocatorT>(e.message, " - ", e.codeSpan);
47 }
48 
49 inline std::string toString(const SyntaxErrorException & e) {
50  return e.message + " - " + toString(e.codeSpan);
51 }
52 
53 } // namespace Balau::Exception
54 
55 #endif // COM_BORA_SOFTWARE__BALAU_EXCEPTION__PARSING_EXCEPTIONS
Thrown when a parser incurs invalid syntax.
Definition: ParsingExceptions.hpp:28
bool operator==(const BalauException &lhs, const BalauException &rhs)
Base class comparison function for Balau exceptions.
Definition: BalauException.hpp:112
All exception classes.
Definition: BalauException.hpp:50
Information on the span of some source code text.
Definition: CodeSpan.hpp:91
Balau::U8String< AllocatorT > toString(const BalauException &e)
Base class toString<AllocatorT> function for Balau exceptions.
Definition: BalauException.hpp:122
A position in a piece of multi-line text.
const std::string message
The message.
Definition: BalauException.hpp:59
Base Balau exception classes.
std::basic_string< char, std::char_traits< char >, AllocatorT > U8String
UTF-8 string type with selectable allocator.
Definition: ToStringA.hpp:41
Base class of all Balau exceptions.
Definition: BalauException.hpp:55