GCC Code Coverage Report


Directory: ../
File: src/exception/AntlrThrowingErrorListener.h
Date: 2024-12-24 01:17:15
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // Copyright (c) 2021-2024 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <filesystem>
6
7 #include <BaseErrorListener.h>
8
9 namespace spice::compiler {
10
11 // Forward declarations
12 class SourceFile;
13
14 enum class ThrowingErrorListenerMode : uint8_t {
15 LEXER,
16 PARSER,
17 };
18
19 class AntlrThrowingErrorListener final : public antlr4::BaseErrorListener {
20 public:
21 // Constructors
22 1803 AntlrThrowingErrorListener(ThrowingErrorListenerMode mode, SourceFile *sourceFile) : mode(mode), sourceFile(sourceFile){};
23
24 // Public methods
25 void syntaxError(antlr4::Recognizer *recognizer, antlr4::Token *offendingSymbol, size_t line, size_t charPositionInLine,
26 const std::string &msg, std::exception_ptr e) override;
27
28 private:
29 // Private members
30 ThrowingErrorListenerMode mode;
31 SourceFile *sourceFile;
32 };
33
34 } // namespace spice::compiler
35