52 lines
830 B
C++
52 lines
830 B
C++
|
#ifndef _TEMP_LANG_FRONTEND_HPP_
|
||
|
#define _TEMP_LANG_FRONTEND_HPP_
|
||
|
|
||
|
#include <string>
|
||
|
#include <iostream>
|
||
|
#include <fstream>
|
||
|
#include <istream>
|
||
|
#include <streambuf>
|
||
|
|
||
|
class TempLangFrontend {
|
||
|
public:
|
||
|
enum class LogLevel {
|
||
|
DEBUG,
|
||
|
INFO,
|
||
|
WARNING,
|
||
|
ERROR,
|
||
|
};
|
||
|
|
||
|
|
||
|
TempLangFrontend(const std::string &source_file)
|
||
|
{
|
||
|
m_source_file = source_file;
|
||
|
}
|
||
|
|
||
|
int analyze();
|
||
|
|
||
|
const std::string &get_src_file()
|
||
|
{
|
||
|
return m_source_file;
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
std::string m_source_file;
|
||
|
|
||
|
void log(LogLevel lvl, const std::string &message) const
|
||
|
{
|
||
|
switch (lvl) {
|
||
|
case LogLevel::ERROR:
|
||
|
std::cerr << "[ERR]" << message << std::endl;
|
||
|
break;
|
||
|
case LogLevel::WARNING:
|
||
|
std::cerr << "[WARN]" << message << std::endl;
|
||
|
break;
|
||
|
default:
|
||
|
std::cout << message << std::endl;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif /* _TEMP_LANG_FRONTEND_HPP_ */
|