示例#1
0
int accepts(const char *str)
{
    std::string input(str);
	Parse p;
	AstNode *stmt = p.parse(input.begin());
	return (stmt->strtail == input.end());
}
示例#2
0
void processFile(string *src) {
  const char *source = src->c_str();
  Parse parse = Parse();
  char *out = NULL;
  string from = input; from += "/"; from += source;
  string to = temp; to += "/"; to += source;
  if(rename(from.c_str(), to.c_str()) < 0) {
    cerr << "rename failed" << endl;
    return;
  }
  out = parse.parse(to.c_str());
  if(out == NULL) {
    cerr << "wystąpił błąd przy parsowaniu" << to << endl;
  } else {
    string dest = output; dest += "/"; dest += source;
    FILE *destFile = fopen(dest.c_str(), "w");
    if(destFile == NULL) {
      cerr << "nie można otworzyć pliku " << dest << endl;
      return;
    }
    //printf("%p\n", destFile);
    if(fprintf(destFile, "%s", out) < 0) {
      cerr << "fprintf failed" << endl;
      return;
    }
    fclose(destFile);
  }
  if(remove(to.c_str()) < 0) {
    cerr << "nie można usunąć " << to << endl;
    return;
  }
  delete[] out;
  delete src;
}
示例#3
0
int main(int argc, char **argv) {
  if(argc < 2) {
    cerr << "musisz podać plik jako argument" << endl;
    return -1;
  }
  Parse parse;
  char *out = parse.parse((const char*)argv[1]);
  if(out != NULL) printf("%s\n", out);
  return 0;
}