Commit 6c640b83 authored by Jack's avatar Jack
Browse files

added temporary workaround for ? print operator which is discarded in png and executed in raw code

parent 4733e3a1
......@@ -11,7 +11,12 @@
using namespace retro8;
using namespace retro8::io;
void Loader::fixLine(std::string& line)
{
/* inline ? print operator */
if (!line.empty() && line[0] == '?')
line = "print(" + line.substr(1) + ")";
}
int Loader::valueForHexDigit(char c)
{
......@@ -57,8 +62,11 @@ std::string Loader::load(const std::string& path)
lines.push_back(line);
for (auto& line : lines)
{
if (!line.empty() && line.back() == '\r')
line.resize(line.length() - 1);
fixLine(line);
}
std::stringstream code;
bool started = false;
......
......@@ -21,6 +21,8 @@ namespace retro8
public:
void load(const std::string& path, Machine& dest);
std::string load(const std::string& path);
static void fixLine(std::string& line);
};
}
}
\ No newline at end of file
......@@ -623,6 +623,15 @@ static int llex (LexState *ls, SemInfo *seminfo) {
return TK_INT;
}
case '?':
{
//TODO FIXME: print with ? consume the whole line for now, so it's not executed
while (!check_next1(ls, '\n'))
next(ls);
continue;
}
case EOZ: {
return TK_EOS;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment