Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,67 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
#include "SL_Generated.h"
|
||||
|
||||
int cores = 0;
|
||||
string fileName = "../../INPUT/irrational.tm";
|
||||
string flag = "tape";
|
||||
string fileContents = "";
|
||||
|
||||
using namespace std;
|
||||
|
||||
std::string get_file_contents(const char *filename);
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
if(argc >= 2)
|
||||
{
|
||||
fileName = argv[1];
|
||||
}
|
||||
|
||||
if(argc >= 3)
|
||||
{
|
||||
flag = argv[2];
|
||||
}
|
||||
|
||||
if(argc >= 4)
|
||||
{
|
||||
cores = atoi(argv[3]);
|
||||
}
|
||||
|
||||
int flagDims[] = { flag.length(), 0};
|
||||
Sequence<char> flagSeq((void*)(flag.c_str()), flagDims);
|
||||
|
||||
fileContents = get_file_contents(fileName.c_str());
|
||||
int inputDims[] = { fileContents.length(), 0};
|
||||
Sequence<char> input((void*)(fileContents.c_str()), inputDims);
|
||||
|
||||
Sequence<char> result;
|
||||
|
||||
sl_init(cores);
|
||||
|
||||
sl_RunMachine(input, flagSeq, cores, result);
|
||||
|
||||
cout<<result<<endl;
|
||||
|
||||
sl_done();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string get_file_contents(const char *filename)
|
||||
{
|
||||
std::ifstream in(filename, std::ios::in | std::ios::binary);
|
||||
if (in)
|
||||
{
|
||||
std::string contents;
|
||||
in.seekg(0, std::ios::end);
|
||||
contents.resize(in.tellg());
|
||||
in.seekg(0, std::ios::beg);
|
||||
in.read(&contents[0], contents.size());
|
||||
in.close();
|
||||
return(contents);
|
||||
}
|
||||
throw(errno);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue