Add first parser draft for temp prfiles.

This commit is contained in:
2024-01-18 23:27:06 +01:00
parent dc6e973d52
commit 223de7f190
8 changed files with 122 additions and 2 deletions

View File

@@ -0,0 +1,52 @@
#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_ */

View File

@@ -0,0 +1,21 @@
#ifndef _TPR_FRONTEND_HPP_
#define _TPR_FRONTEND_HPP_
#include <string>
#include <lang/temp-lang-frontend.hpp>
#include <tpr/tpr-scanner.hpp>
namespace tpr {
class TprFrontend : public TempLangFrontend {
private:
public:
TprFrontend(const std::string &source_file);
int analyze();
};
}
#endif /* _TPR_FRONTEND_HPP_ */