Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2021-2024 ChilliBits. All rights reserved. | ||
2 | |||
3 | #include "AntlrThrowingErrorListener.h" | ||
4 | |||
5 | #include <exception/LexerError.h> | ||
6 | #include <exception/ParserError.h> | ||
7 | #include <util/CodeLoc.h> | ||
8 | |||
9 | namespace spice::compiler { | ||
10 | |||
11 | 3 | void AntlrThrowingErrorListener::syntaxError(antlr4::Recognizer *recognizer, antlr4::Token *offendingSymbol, size_t line, | |
12 | size_t charPositionInLine, const std::string &msg, std::exception_ptr e) { | ||
13 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | const CodeLoc codeLoc(line, charPositionInLine, sourceFile); |
14 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | if (mode == ThrowingErrorListenerMode::LEXER) |
15 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | throw LexerError(codeLoc, TOKENIZING_FAILED, msg); |
16 | else | ||
17 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | throw ParserError(codeLoc, PARSING_FAILED, msg); |
18 | } | ||
19 | |||
20 | } // namespace spice::compiler | ||
21 |