int Lex_analyzer_construct() { struct Node *root=NULL; init(); memset(isinput,0,sizeof(isinput)); for(int i=0;i<token_n;i++) { struct Node *x=bds(tokens[i].regular); if(x==NULL) { printf("Token #%d:%s Is Wrong\n",i,tokens[i].name); printf("Lex analyzer construct failed.\n"); return -1; } x->right->token=i; acposition[i]=x->right->n; if(root==NULL)root=x; else root=newNode('|'+256,root,x); } memset(followpos,0,sizeof(followpos)); nfl(root); ptr(root,0); putchar('\n'); print_followpos(); DFA_from_regular(root); print_DFA(); Minimizing_DFA(); print_Minimized_DFA(); return 0; }
NumericMatrix Clmbr::cr4R( double CL, int met, double incr, int verboseR ) { if(Model==M3) { Rcout << model_msg << endl << endl; return NumericMatrix(0,0); } if(CL <=0. || CL >=1.) stop( CLmsg ); const double tmp = SL; set_SL(1.-CL); METHOD MET; if(met==1) MET=GEO; else { if(met==2) MET=AF; else { stop( methods2msg ); } } double inc; if( incr == -1 ) inc= xinc; else inc= incr; const double maxwidth = xs[ns-1] - xs[0] + 2; const int Nmax = maxwidth/inc + ns + 3; double* Btmp= Calloc( Nmax*3, double ); const bool verbose = static_cast<bool>( verboseR ); if( verbose ) stop( "dummy argument for dispatch, should be FALSE" ); const int nrows = cr( MET, incr, false, Btmp ); set_SL(tmp); NumericMatrix bds( nrows, 3 ); for(int i=0;i<nrows;i++) { bds(i,0) = *(Btmp + 0*nrows + i); bds(i,1) = *(Btmp + 1*nrows + i); bds(i,2) = *(Btmp + 2*nrows + i); } Free( Btmp ); return bds; }
/** Generates tperm::Boundary objects and sorts them into tperm::OpposingBoundaries. @todo Different boundaries (internal) from settings file @todo Region support */ Boundaries sort_boundaries(const Model<3> &m, const Settings &s) { const size_t d = dimensionality(m); auto obnames = opposing_boundary_names(m); Boundaries bds(d); for (size_t i(0); i < d; ++i) { bds[i].first.assign(m.Boundary(obnames.at(i).first).NodesBegin(), m.Boundary(obnames.at(i).first).NodesEnd()); // in bds[i].second.assign(m.Boundary(obnames.at(i).second).NodesBegin(), m.Boundary(obnames.at(i).second).NodesEnd()); // out } return bds; }
int Test() { char s[200]; while(gets(s)) { init(); struct Node *x=bds(s); if(x) { memset(followpos,0,sizeof(followpos)); nfl(x); ptr(x,0); putchar('\n'); print_followpos(); DFA_from_regular(x); print_DFA(); Minimizing_DFA(); print_Minimized_DFA(); } } return 0; }