I am trying to make a simple scripting laungange in qt that you can change variables from c++ in the script and the return it back so far this what I have:
QString Script
= "def SH_Script Print hello hey; Print hey;";
if(Script.startsWith("def SH_Script", Qt::CaseInsensitive))
{
Script.
replace(QRegExp("def SH_Script"),
"");
for(int i = 0; i < Lines.count(); i++)
{
Words[i] = Lines.at(i).split(" ");
for(int w = 0; w < Words[i].count(); w++)
{
if(Words[i].at(w) == "Print")
{
for(int h = 0; h < Words[i].count(); h++)
{
if(Words[i].at(h) == "Print")
{
Words[i].removeAt(h);
}
}
for(int a = 1; a < Words[i].count(); a++)
{
output += Words[i].at(a) + " ";
}
qDebug() << output << endl;
output = "";
}
else if(Words[i].at(w) == "def")
{
//creates a new varible
}
else if(Words[i].at(w).startsWith('$'))
{
//refers to a varible
}
else if(Words[i].at(w).startsWith("--"))
{
Words[i].clear();
}
else if(Words[i].at(w) == " ")
{
//reconizing space instead of errors
}
else if(Words[i].at(w) == "")
{
//reconizing space instead of errors
}
else
{
qDebug() << "syntax error at line:" << i;
}
}
}
}
else
{
qDebug() << "Not decarled as a SH Script";
}
QString Script = "def SH_Script Print hello hey; Print hey;";
if(Script.startsWith("def SH_Script", Qt::CaseInsensitive))
{
Script.replace(QRegExp("def SH_Script"), "");
QStringList Lines = Script.split(";");
QStringList Words[Lines.count()];
for(int i = 0; i < Lines.count(); i++)
{
Words[i] = Lines.at(i).split(" ");
for(int w = 0; w < Words[i].count(); w++)
{
if(Words[i].at(w) == "Print")
{
for(int h = 0; h < Words[i].count(); h++)
{
if(Words[i].at(h) == "Print")
{
Words[i].removeAt(h);
}
}
QString output;
for(int a = 1; a < Words[i].count(); a++)
{
output += Words[i].at(a) + " ";
}
qDebug() << output << endl;
output = "";
}
else if(Words[i].at(w) == "def")
{
//creates a new varible
}
else if(Words[i].at(w).startsWith('$'))
{
//refers to a varible
}
else if(Words[i].at(w).startsWith("--"))
{
Words[i].clear();
}
else if(Words[i].at(w) == " ")
{
//reconizing space instead of errors
}
else if(Words[i].at(w) == "")
{
//reconizing space instead of errors
}
else
{
qDebug() << "syntax error at line:" << i;
}
}
}
}
else
{
qDebug() << "Not decarled as a SH Script";
}
To copy to clipboard, switch view to plain text mode
Any suggestions or help would be great
Bookmarks