/ cpp / api.cpp
api.cpp
 1  #include <string>
 2  
 3  #include "serpent/lllparser.h"
 4  #include "serpent/bignum.h"
 5  #include "serpent/util.h"
 6  #include "serpent/tokenize.h"
 7  #include "serpent/parser.h"
 8  #include "serpent/compiler.h"
 9  
10  #include "cpp/api.h"
11  
12  const char *compileGo(char *code, int *err)
13  {
14      try {
15          std::string c = binToHex(compile(std::string(code)));
16  
17          return c.c_str();
18      }
19      catch(std::string &error) {
20          *err = 1;
21          return error.c_str();
22      }
23      catch(...) {
24          return "Unknown error";
25      }
26  }