PUBLIC int main(int ac, char **av) { int i, n_files; char **files; argc = ac; argv = av; while (--argc > 0 && (*++argv)[0] == '-') do_flags(*argv); files = argv; n_files = argc; if (debflag('v')) { fprintf(errout, "%s\n%s\n%s\n", fuzz_banner, fuzz_rcsid, fuzz_copyright); fflush(errout); } debugging = debflag('p'); init_sym(); init_type(); init_dict(); open_prelude(); read_a_file(); if (dflag) { check_file(); clear_temp((univ) NULL); } debugging = TRUE; if (n_files == 0) { /* Finished prelude, no args: read stdin */ file_name = "standard input"; yyrestart(stdin); read_a_file(); } else { for (i = 0; i < n_files; i++) { reopen_input(files[i]); yyrestart(yyin); read_a_file(); } } if (dflag) { check_file(); clear_temp((univ) NULL); } #ifdef DEBUG if (debflag('h')) dump_hash(); #endif return (n_errors > 0 ? 1 : 0); }
void readFile(Register reg, char* fileName) { if ((yyin = fopen(fileName, "r" )) == NULL) { yyrestart(stdin); makeNull(reg); } read(reg); yyrestart(stdin); }
void ScannerRestart(FILE* fp) { if(fp==NULL) { if ( yyin != stdin ) { fclose( yyin ); yyrestart( stdin ); } return; } yyrestart(fp); }
Object readFile(char* fileName) { Object obj; if ((yyin = fopen(fileName, "r" )) == NULL) { yyrestart(stdin); return makeNull(); } obj = read(); yyrestart(stdin); return obj; }
/* * === FUNCTION ====================================================================== * Name: main * Description: this is the main method for the complier, * for now it is used for lyntax, and there * may have a tree method under this. * ===================================================================================== */ int main(int argc, char** argv){ if(argc <= 1) return 1; FILE* f = fopen(argv[1], "r"); if (!f){ perror(argv[1]); return 1; } yyrestart(f); //extern FILE* yydebug; //yydebug = 1; yyparse(); //PrintTree(); SemanticAnalyze(); printTestError(); /* code for IR*/ optIRCode(); optIRCode2(); optIRCode3(); optIRCode4(); printCodeList(); printSCODE(argv[2]); /* code end */ return 0; }
int main(int argc, char** argv) { if(argc <= 1) return 1; FILE *f = fopen(argv[1], "r"); if (!f) { perror(argv[1]); return 1; } FILE *fp = stdout; if(argc == 3) { fp = fopen(argv[2], "w"); } yyrestart(f); #if YYDEBUG yydebug = 1; #endif yyparse(); if(!err) { #ifdef DEBUG print_tree(root); #endif main_parse(root); //print_code(&code, stdout); init_mips(fp); gen_mips(&code, fp); } return 0; }
int main(int argc, char* argv[]) { debug = 0; int OpenFlag = 1; DEBUG printf("before check debug\n"); if( argc>1 && strcmp( argv[1], "-debug")==0) { debug = 1; OpenFlag = 2; } FILE *f; if(argc == 1 || (argc == 2 && debug) ) { DEBUG printf("before CreatNonTreeNode guard\n"); guard = CreatNonTreeNode("guard"); f = fopen("./example2.txt","r"); root = NULL; assert(f!=NULL); yyrestart(f); //yylex(); yyparse(); //TravelTree(root, 0); init(); analysis(root); fclose(f); } return 0; };
void ESDLcompiler::Process() { CriticalBlock block(m_critSect); yyInitESDLGlobals(this); Owned<IException> parseException; yyrestart (yyin); try { yyparse(); } catch(IException* e) { parseException.setown(e); } if (nCommentStartLine > -1) { char tempBuf[256]; sprintf(tempBuf, "The comment that started at line %d is not ended yet", nCommentStartLine); yyerror(tempBuf); } if(!parseException) write_esxdl(); fclose(yyin); if (gOutfile > 0) close (gOutfile); yyCleanupESDLGlobals(); yylex_destroy(); if(parseException) throw parseException.getLink(); }
static Interpreter __Interpreter_new (Value filePath) { Interpreter node = struct_new(Interpreter); InitFunc func = NULL; node->filePath = filePath; at_currentInterpreter = node; yylineno = 1; if (filePath) { if (func = LIB_getInitFunc(filePath->u.string)) { node->result = func(); return node; } yyin = fopen(filePath->u.string, "rt"); if (!yyin) { perror(filePath->u.string); return NULL; } yyrestart(yyin); yyparse(); fclose(yyin); } else { //yyin = stdin; printf("Interpreter._new: yyparse\n"); //yyrestart(yyin); yyparse(); printf("Interpreter._new: yyparse end\n"); } node->result = Procedure_eval(node->proc, node->proc->exp); return node; }
int parse_input(FILE* f) { parse_init(); yyrestart(f); return yyparse(); }
void Ventana_Principal::AnalisisJSON() { Pestana *actual = (Pestana*)ui->tabWidget->currentWidget(); if(actual != NULL){ QFile file("temp.txt"); //SE CREA UN ARCHIVO TEMPORAL PARA COMPILARLO if ( file.open( file.WriteOnly ) ) { //BUFFER PARA EL TEXTO QUE SE DESEA COMPILAR QTextStream stream1( &file ); stream1 << actual->enviar_texto(); } const char* x = "temp.txt"; FILE* input = fopen(x, "r" ); errores_json->ven()->clear(); SetVentanita_json(errores_json->ven()); setFila(); setColumna(); setEdit(actual->textedit()); yyrestart(input);//SE PASA LA CADENA DE ENTRADA A FLEX yyparse();//SE INICIA LA COMPILACION ArbolJ *nuevo = setArbolito(); if(nuevo != NULL && correctojson() != 1){ //nuevo->Dibujar(); } } }
int main(int argc, char** argv) { if (argc <= 2) return 1; FILE *fin = fopen(argv[1], "r"); if (!fin) { perror(argv[1]); return 1; } FILE *fout = fopen(argv[2], "w"); if (!fout) { perror(argv[2]); return 1; } yyrestart(fin); yyparse(); if (syntaxError) return 0; // printTree(root); checkSemantic(root); if (semanticError) return 0; generateIR(root); generateMIPS(icsHead, fout); fclose(fout); return 0; }
int parse_input(parser_state* p, FILE* f) { parse_init(p); yyrestart(f); return yyparse(p); }
/*----------------------------------------------- | test_main +---------------------------------------------*/ static int test_main(int argc, char **argv) { int i; if(argc < 2) { /* we'll take input from stdin */ currfilename= "(stdin)"; yylineno= 1; yylex(); } else { for(i=1; i<argc; i++) { FILE *f= fopen(argv[i], "r"); if(!f) { perror(argv[i]); return 1; } currfilename= argv[i]; yyrestart(f); yylineno= 1; yylex(); fclose(f); } } /* printtabs(); */ return 0; }
void read(Register to) { yyparse(); yyrestart(stdin); copyReg(to, regSimple); }
Object loadFile(char* fileName) { if ((yyin = fopen(fileName, "r" )) == NULL) { yyrestart(stdin); return makeNull(); } while (1) { setReg(regExp, read()); if (isEOF(getReg(regExp))) break; eval(); } yyrestart(stdin); return makeSymbol("ok"); }
int tree_insert_importDefinition(struct tree **t) { //t = importDefinition, so get the ident subtree struct tree *t_sub = NULL; tree_get_subtree("ident", (*t), &t_sub); if(t_sub == NULL) { return(1); //failure } //Get symbol pointer to variable name //TODO: need to use more generic getter char * import_name = t_sub->kids[0]->leaf->text; //Parse the import file tree_init(); //inits YY_TREE //open the file and store its reference in global variable yyin tree_import_ident_to_path(import_name, &YY_FNAME); //yyrestart for multiple file parsing FILE *yyfile = fopen(YY_FNAME, "r"); yyrestart(yyfile); lineno = 1; colno = 1; //instead of - yyin = fopen(YY_FNAME,"r"); if (yyin == NULL) { fprintf(stderr, "ERROR: import: Cannot open '%s'. ",\ YY_FNAME); #ifdef DEBUG_TREE fprintf(stderr, "Continuing anyway...\n"); #else fprintf(stderr, "Cannot continue.\n"); exit(ERROR_SEMANTIC); #endif } else { //print the name of the file printf("%s\n", YY_FNAME); //parse import file yyparse(); //delete the importDefinition subtree... tree_del((*t)); //...and replace it with the newly parsed YY_TREE //TODO: do we really want to replace with a as3CompilationUnit // subtree, or it's children? Leaving for now. (*t) = YY_TREE; } return(0); //success }
void parse(FILE *fp) { init_symbol_table(&symbol_table); symbol_table_enter_next_scope(symbol_table); init_dll(&call_patch_list); init_dll(&var_patch_list); yyrestart(fp); yyparse(); }
void loadFile(Register reg, char* fileName) { if ((yyin = fopen(fileName, "r" )) == NULL) { yyrestart(stdin); makeNull(reg); } while (1) { read(reg); if (isEOF(reg)) break; #if 0 eval(); #endif } yyrestart(stdin); makeSymbol(reg, "ok"); }
int main(int argc, char** argv) { FILE *file; filename = argv[1]; file = fopen(argv[1], "r"); if(file) { yyrestart(file); yyparse(); check_prog(); gen_prog("a.out", "a.out.defs"); } else fprintf(stderr, "Source file does not exist\n"); }
int main(int argc, char** argv) { if (argc <= 1) return 1; FILE *f = fopen(argv[1], "r"); if (!f) { perror(argv[1]); return 1; } yyrestart(f); yyparse(); return 0; }
int node_parse_input(parser_state* p, FILE* f, const char* fname) { int n; /* yydebug = 1; */ yyrestart(f); n = yyparse(p); if (n == 0 && p->nerr == 0) { return 0; } return 1; }
int main(int argc, char** argv) { FILE *fp; int i; for(i=1;i < argc;i++) { if (argc > 1){ fp = fopen(argv[i], "r"); yyrestart(fp); yylex(); } else printf("please enter a file in the argument....\n USAGE :>> ./algolLexer test"); } return 0; }
int main(int argc, char** argv) { if(argc <= 1) return 1; FILE *f = fopen(argv[1], "r"); if (!f) { perror(argv[1]); return 1; } yyrestart(f); #if YYDEBUG yydebug = 1; #endif yyparse(); if(!err) print_tree(root); return 0; }
int ss_parse_file( ss_state* state, const char* src, FILE* file ){ bool is_close_file = false; if ( null == file ){ file = fopen( src, "rb" ); if ( null == file ){ SS_PUTS_ERRCODE( errno ); SS_PUTS_ERR( "fopen error %s", src ); return 1; } is_close_file = true; } state->src = src; state->line = 1; yyrestart( file ); int result = yyparse( state ); if ( is_close_file ) fclose( file ); return ( ( 0 == result ) && ( 0 == state->err ) ); }
// start pasring fnParseFile file (may include mesh,skeleton,animset,...) BOOL StartParser(CTString fnParseFile) { CTFileName fnFull; fnFull = _fnmApplicationPath + fnParseFile; yyin = NULL; astrText.PopAll(); astrText.Clear(); // initialize pre-parsing variables yyin = fopen(fnFull, "r"); // reset include depth ptr include_stack_ptr = 0; strCurentFileName = fnFull; _yy_iIndex = 0; _yy_jIndex = 0; _yy_iLine = 1; // load data try { if (yyin==NULL) { ThrowF_t("Cannot open file '%s'!", (const char*)fnParseFile ); } yyrestart(yyin); yyparse(); fclose(yyin); } // if an error in parsing occured catch(char *strError) { WarningMessage(strError); // AfxMessageBox(strError); theApp.ErrorMessage(strError); if(yyin!=NULL) fclose(yyin); return FALSE; } return TRUE; }
int Parser::parse( const std::string& filename, FILE* fstream, const boost::shared_ptr<Database>& database) { d_errors = 0; d_warnings = 0; // Find the path in the filename, if one exists std::string::size_type slash_pos = filename.find_last_of('/'); if (slash_pos == std::string::npos) { d_pathname = ""; } else { d_pathname = filename.substr(0, slash_pos + 1); } ParseData pd; pd.d_filename = filename; pd.d_fstream = fstream; pd.d_linenumber = 1; pd.d_cursor = 1; pd.d_nextcursor = 1; d_parse_stack.clear(); d_parse_stack.push_front(pd); d_scope_stack.clear(); d_scope_stack.push_front(database); s_default_parser = this; yyrestart(0); if (yyparse() && (d_errors == 0)) { error("Unexpected parse error"); } s_default_parser = 0; d_parse_stack.clear(); d_scope_stack.clear(); return d_errors; }
int TSDef_ConstructUnitFromFile ( char* file, char* name, struct tsdef_unit* unit, struct tsdef_def_error_list* errors ) { int error; yyin = fopen(file, "rt"); if(yyin == NULL) return TSDEF_ERROR_FILE_OPEN; yyrestart(yyin); error = ParseInput(name, unit, errors); fclose(yyin); return error; }
void IntrHandler() { extern jmp_buf env; #if defined(BSD) && BSD >= 199006 extern FILE *yyin; /* scanner input file */ extern void yyrestart(); /* routine to restart scanner after interrupt */ #endif SendRequest_close(); ListHost_close(); if (filePtr != NULL && filePtr != stdout) { fclose(filePtr); filePtr = NULL; } printf("\n"); #if defined(BSD) && BSD >= 199006 yyrestart(yyin); #endif longjmp(env, 1); }
int main(int argc, char ** argv) { if (argc <= 1) return 1; int i; FILE* f; for(i = 1; i < argc; i++) { f = fopen(argv[i], "r"); if(!f) { perror(argv[i]); return 1; } yylineno = 1; yyrestart(f); // yydebug = 1; yyparse(); } return 0; }