fix parser issues
This commit is contained in:
+21
-2
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user