int main(int argc, char *argv[]) { ATerm tree; ATinit(argc, argv, &tree); ATprotect((ATerm*)&imported); ATprotect(&parse_tree); ATprotect((ATerm*)&includes); process_options(argc, argv); imported = ATmakeList0(); yydebug = 0; open_dependencies(input_file); tree = parse_file(input_file); /* Open output file */ if (output_file == NULL) outfile = stdout; else outfile = fopen(output_file, "w"); if(binary_output) ATwriteToBinaryFile(tree, outfile); else ATwriteToTextFile(tree, outfile); /* print_dependencies(input_file, imported); */ exit(0); }
int main (int argc, char* argv[]) { printf ("Building ATerm bottom; \n"); ATerm bottom; printf ("Building the ROSE AST \n"); SgProject* project = frontend(argc,argv); printf ("Calling ATinit \n"); ATinit(argc, argv, &bottom); printf ("Calling convertNodeToAterm \n"); ATerm term = convertNodeToAterm(project /*.get_file(0).get_root()*/); printf ("DONE: Calling convertNodeToAterm \n"); ROSE_ASSERT (term != NULL); #if 0 // DQ (3/23/2013): This was already commented out... AST_FILE_IO::startUp(sageProject); std::string astBlob = AST_FILE_IO::writeASTToString(); term = ATsetAnnotation(term, ATmake("ast"), ATmake("<blob>", astBlob.length(), astBlob.data())); #endif #if 0 // DQ (3/23/2013): commented out while debugging. // This can be usefull for piping output to other Stratego and Aterm tools/phases. ATwriteToBinaryFile(term, stdout); #endif // Open a file for writing... FILE* f = fopen("atermFile.aterm","w"); // Write the aterm to the file. ATbool status = ATwriteToTextFile(term,f); ROSE_ASSERT(status == ATtrue); // Close the file. fclose(f); #if 0 // Testing the ATerm file I/O. // Open a file for writing... FILE* file = fopen("atermFile.aterm","r"); printf ("Read aterm file \n"); // Write the aterm to the file. ATerm term2 = ATreadFromTextFile(file); ROSE_ASSERT(term2 != NULL); printf ("Closing file after reading aterm \n"); // Close the file. fclose(file); #endif return 0; }
ATerm SSL_write_term_to_stream_text(ATerm stream_term, ATerm term) { FILE* stream = stream_from_term(stream_term); if(stream == NULL) _fail(stream_term); ATwriteToTextFile(term, stream); return stream_term; }
int main(int argc, char **argv) { int i; ATerm bos; ATermList list; ATinit(argc,argv,&bos); list = ATempty; for (i = 1; i < argc; i++) { FILE *f = fopen(argv[i], "r"); ATwarning("Adding %s.\n", argv[i]); if (!f) ATabort("Error opening file %s.\n", argv[i]); list = ATconcat(list,(ATermList)ATreadFromTextFile(f)); fclose(f); } ATwriteToTextFile((ATerm)list,stdout); return 0; }
int main (int argc, char *argv[]) { int c; /* option character */ ATerm bottomOfStack; ATerm tree; Graph graph; char *input_file_name = "-"; char *output_file_name = "-"; ATbool characters = ATfalse; ATbool productions = ATfalse; ATbool layout = ATfalse; ATbool literals = ATtrue; ATbool binary = ATtrue; ATbool sharing = ATfalse; #ifndef WITHOUT_TOOLBUS ATbool use_toolbus = ATfalse; int i; for (i=1; !use_toolbus && i < argc; i++) { use_toolbus = !strcmp(argv[i], "-TB_TOOL_NAME"); } if (use_toolbus) { int cid; ATBinit(argc, argv, &bottomOfStack); PT_initMEPTApi(); initGraphApi(); cid = ATBconnect(NULL, NULL, -1, graph_converter_handler); ATBeventloop(); } else #endif { while ((c = getopt(argc, argv, myarguments)) != EOF) switch (c) { case 'b': binary = ATtrue; break; case 'c': characters = ATtrue; break; case 'h': usage(); exit(0); case 'i': input_file_name = optarg; break; case 'l': layout = ATtrue; break; case 'm': literals = ATfalse; break; case 'o': output_file_name = optarg; break; case 'p': productions = ATtrue; break; case 't': binary = ATfalse; break; case 's': sharing = ATtrue; break; case 'V': fprintf(stderr, "%s %s\n", myname, myversion); exit(0); default : usage(); exit(1); } ATinit(argc, argv, &bottomOfStack); PT_initMEPTApi(); initGraphApi(); tree = ATreadFromNamedFile(input_file_name); if(tree == NULL) { ATerror("%s: could not read term from input file %s\n", myname, input_file_name); } graph = PT_printAnyToGraph(tree, characters, productions, layout, literals, sharing); if (!strcmp(output_file_name,"-")) { if (binary) { ATwriteToBinaryFile(GraphToTerm(graph), stdout); } else { ATwriteToTextFile(GraphToTerm(graph), stdout); } } else { if (binary) { ATwriteToNamedBinaryFile(GraphToTerm(graph), output_file_name); } else { ATwriteToNamedTextFile(GraphToTerm(graph), output_file_name); } } } return 0; }
int main(int argc, char *argv[]) { double duration; struct tms start, end; ATerm in_term, out_term; ATinit(argc, argv, &in_term); ATprotectArray(term_stack, TSIZE); ATprotectArray(environment, ESIZE); process_options(argc, argv); /* Open input file */ if (input_file == NULL) infile = stdin; else infile = fopen(input_file, "r"); /* Push term to be reduced on term stack */ if ((in_term = ATreadFromFile(infile)) == NULL) { ATfprintf(stderr, "not a valid term\n"); exit(1); } in_term = /*list_to_consnil*/(in_term); debugs(ATfprintf(stderr, "in_term (b) = %t\n", in_term)); /* Execute the strategy */ times(&start); out_term = doit(in_term); times(&end); duration = ((double)(end.tms_utime - start.tms_utime))/((double)CLK_TCK); if(out_term != NULL) { /* Open output file */ if (output_file == NULL) outfile = stdout; else outfile = fopen(output_file, "w"); /* ATfprintf(stdout, "%t\n", out_term); */ if(binary_output) ATwriteToBinaryFile(/*consnil_to_list*/(out_term), outfile); else ATwriteToTextFile(/*consnil_to_list*/(out_term), outfile); } print_profile(duration); if (!failed) { ATfprintf(stderr, " rewriting succeeded\n"); exit(0); } else { ATfprintf(stderr, " rewriting failed\n"); exit(1); } }