Line |
Branch |
Exec |
Source |
1 |
|
|
// Copyright (c) 2021-2025 ChilliBits. All rights reserved. |
2 |
|
|
|
3 |
|
|
#pragma once |
4 |
|
|
|
5 |
|
|
#include <cstdint> |
6 |
|
|
#include <exception> |
7 |
|
|
#include <string> |
8 |
|
|
|
9 |
|
|
namespace spice::compiler { |
10 |
|
|
|
11 |
|
|
// Forward declarations |
12 |
|
|
struct CodeLoc; |
13 |
|
|
|
14 |
|
|
enum LexerErrorType : uint8_t { TOKENIZING_FAILED }; |
15 |
|
|
|
16 |
|
|
/** |
17 |
|
|
* Custom exception for errors, occurring while lexing |
18 |
|
|
*/ |
19 |
|
|
class LexerError final : public std::exception { |
20 |
|
|
public: |
21 |
|
|
// Constructors |
22 |
|
|
LexerError(const CodeLoc &codeLoc, const LexerErrorType &type, const std::string &message); |
23 |
|
|
|
24 |
|
|
// Public methods |
25 |
|
|
[[nodiscard]] const char *what() const noexcept override; |
26 |
|
|
[[nodiscard]] static std::string getMessagePrefix(LexerErrorType errorType); |
27 |
|
|
|
28 |
|
|
// Public members |
29 |
|
|
std::string errorMessage; |
30 |
|
|
}; |
31 |
|
|
|
32 |
|
|
} // namespace spice::compiler |
33 |
|
|
|