fix parser issues

This commit is contained in:
2026-10-02 22:14:03 +03:00
parent 2999c295af
commit 79642d3fd1
4 changed files with 151 additions and 57 deletions
+21 -2
View File
@@ -1,6 +1,7 @@
#pragma once
#include <iostream>
#include <sstream>
#include <memory>
#include <string>
@@ -104,7 +105,25 @@ public:
}
}
const char *type_str(void)
std::shared_ptr<std::string> to_str(void) const
{
switch (t)
{
case VAR:
return v.s;
case CONST:
{
char buffer[128] = {0};
return std::make_shared<std::string>((std::ostringstream() << v.d).str());
}
case OPERATOR:
return std::make_shared<std::string>("OP " + std::string(op_str()));
default:
return std::make_shared<std::string>("Not a valid token!");
}
}
const char *type_str(void) const
{
switch (t)
{
@@ -119,7 +138,7 @@ public:
}
}
const char *op_str(void)
const char *op_str(void) const
{
if (t != OPERATOR)
{