GCC Code Coverage Report


Directory: ../
File: src/exception/ParserError.h
Date: 2025-02-05 01:09:36
Exec Total Coverage
Lines: 0 0 -%
Functions: 0 0 -%
Branches: 0 0 -%

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 ParserErrorType : uint8_t {
15 PARSING_FAILED,
16 NUMBER_OUT_OF_RANGE,
17 INVALID_QUALIFIER_COMBINATION,
18 INVALID_CHAR_LITERAL,
19 INVALID_ATTR_VALUE_TYPE,
20 RESERVED_KEYWORD
21 };
22
23 /**
24 * Custom exception for errors, occurring while parsing
25 */
26 class ParserError final : public std::exception {
27 public:
28 // Constructors
29 ParserError(const CodeLoc &codeLoc, const ParserErrorType &type, const std::string &message);
30
31 // Public methods
32 [[nodiscard]] const char *what() const noexcept override;
33 [[nodiscard]] static std::string getMessagePrefix(ParserErrorType errorType);
34
35 // Public members
36 std::string errorMessage;
37 };
38
39 } // namespace spice::compiler
40