Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Интерпретатор / _sources / MyLanguage / Poliz
.hpp#ifndef POLIZ_HPP_
#define POLIZ_HPP_
#include <vector>
#include <string>
#include <stack>
#include "LookupTable.hpp"
namespace Parser_impl {
enum ElementTypes { VOID, INT, FLOAT, STRING };
enum InstType {TFunction, TLiteral, TVariable, TStrLit, TOperation, TIfNot,
TGoto, TReturn, TWrite, TRead, TWasError, TExit, TPOP};
struct Variable {
ElementTypes type;
long double value;
Variable(ElementTypes t = FLOAT, long double v = 0.0) : type(t), value(v) {}
};
struct PolizInstruction {
InstType inst_type;
int val;
long double value;
bool local;
std::string str;
PolizInstruction(InstType t, int v=0) : inst_type(t), val(v) {};
};
struct Function {
ElementTypes return_type;
int args_count;
LookupTable<Variable> local;
std::vector<PolizInstruction> code;
bool declared;
std::string name;
Function() : args_count(0) {}
bool hasParamsEqualTo(Function& f)
{
bool ret = true;
ret &= return_type == f.return_type;
ret &= args_count == f.args_count;
for (int i=0; i<args_count; ++i)
ret &= local.get(i).type == f.local.get(i).type;
return ret;
}
};
struct PolizProgram {
LookupTable<Variable> global;
LookupTable<Function> functions;
int main;
};
}
#endif /*POLIZ_HPP_*/
Соседние файлы в папке MyLanguage