topazc
exception.cpp
Go to the documentation of this file.
1
6
7
#include "
../../include/exception/exception.hpp
"
8
#include <iostream>
9
17
std::string
convert_subsystem_type_to_string
(
SubsystemType
type) {
18
switch
(type) {
19
case
SUB_LEXER
:
20
return
"lexer"
;
21
case
SUB_PARSER
:
22
return
"parser"
;
23
case
SUB_SEMANTIC
:
24
return
"semantic"
;
25
case
SUB_CODEGEN
:
26
return
"codegen"
;
27
}
28
}
29
30
void
throw_exception
(
SubsystemType
type, std::string msg, uint32_t line, std::string file_name,
bool
is_debug) {
31
if
(is_debug) {
32
std::cerr <<
"\033[31mSubsystem \033[0m'"
<<
convert_subsystem_type_to_string
(type) <<
"'\033[31m handled the error\n"
;
33
}
34
std::cerr <<
"\033[31mCompilation error at:\033[0m "
<< file_name <<
':'
<< line <<
"\n\033[31m"
<< msg <<
"\033[0m\n"
;
35
exit(1);
36
}
convert_subsystem_type_to_string
std::string convert_subsystem_type_to_string(SubsystemType type)
Function for converting passed subsystem type into string.
Definition
exception.cpp:17
throw_exception
void throw_exception(SubsystemType type, std::string msg, uint32_t line, std::string file_name, bool is_debug)
Function for throwing exception.
Definition
exception.cpp:30
exception.hpp
Header file for defining thrown exceptions by the compiler.
SubsystemType
SubsystemType
Subsystem from which the exception throwed.
Definition
exception.hpp:14
SUB_LEXER
@ SUB_LEXER
Definition
exception.hpp:15
SUB_PARSER
@ SUB_PARSER
Definition
exception.hpp:16
SUB_CODEGEN
@ SUB_CODEGEN
Definition
exception.hpp:18
SUB_SEMANTIC
@ SUB_SEMANTIC
Definition
exception.hpp:17
src
exception
exception.cpp
Generated by
1.15.0