Esempio n. 1
0
/*******************************************************************************
 * Fonction principale de l'analyseur lexical, lit les caractères de yyin et
 * renvoie les tokens sous forme d'entier. Le code de chaque unité est défini 
 * dans symboles.h sinon (mot clé, idententifiant, etc.). Pour les tokens de 
 * type ID_FCT, ID_VAR et NOMBRE la valeur du token est dans yytext, visible 
 * dans l'analyseur syntaxique.
 ******************************************************************************/
int yylex(void) {
    char c;
    int i;
    yytext[yyleng = 0] = '\0';

    if (mange_espaces() == -1)
        return FIN;

    c = lire_car();

    for (i = 0; i < nb_symboles; i++)
        if (table_symboles[i] == c)
            return code_symboles[i];

    if (is_num(c)) {
        do {
            c = lire_car();
        } while (is_num(c));
        delire_car();

        return NOMBRE;
    }

    if (is_maj(c) || is_min(c)) {
        do {
            if (yyleng >= YYTEXT_MAX - 1) {
                printf("Erreur ligne %d: un nom de fonction fait plus de 99 caractères\n", nb_ligne);
                exit(1);
            }

            c = lire_car();
        } while (is_maj(c) || is_min(c) || (c) == '_');
        delire_car();

        for (i = 0; i < nb_mots_clefs; i++)
            if (strcasecmp(table_mots_clefs[i], yytext) == 0)
                return code_mot_clefs[i];

        return ID_FCT;
    }

    if ((c) == '$') {
        do {
            if (yyleng >= YYTEXT_MAX - 1) {
                printf("Erreur ligne %d: un nom de variable fait plus de 99 caractères\n", nb_ligne);
                exit(1);
            }

            c = lire_car();
        } while (is_maj(c) || is_min(c) || is_num(c) || (c) == '_');
        delire_car();

        return ID_VAR;
    }

    printf("Erreur inconnue ligne %d.\n", nb_ligne);
    exit(1);
}
int analyser_mot(char c) {
	int count = 1;
	
	if (c == '$') {
	//	printf("analyser_mot VARIABLE c = %c \n", c);
		while(count < YYTEXT_MAX - 80) {
			c = lireCar();

			if (count < YYTEXT_MAX && !(is_num(c) || is_min(c) || is_maj(c) || c == '_')) {
				/*//printf("BEFORE, count = %i\n", count);
				for (int i = 0; i < YYTEXT_MAX - 1; i++) 
					printf("%c",yytext[i]);
				printf("\n");*/
				delireCar();
				/*printf("AFTER\n");
				for (int i = 0; i < YYTEXT_MAX - 1; i++) 
					printf("%c",yytext[i]);
				printf("\n");*/
				return ID_VAR;
			}
			else if (count >= YYTEXT_MAX) {
				delireCar();
				return -1;
			}
			count++;	
		} 
	}
	if (is_num(c)) {
		//printf("analyser_mot NUMBER c = %c \n", c);
		while(1) {
			c = lireCar();
			//printf("%c\n", c);
			if (!is_num(c)) {
				delireCar();
				return NOMBRE;
			} 
		}
	}
	//printf("analyser_mot FUNCTION/KEYWORD c = %c \n", c);
	while(count < YYTEXT_MAX) {
		c = lireCar();
		//printf("%c\n", c);
		if (count == YYTEXT_MAX - 1 && c != '(') {
			delireCar();
			return -1;
		}
		//printf("test1\n");
		if (!(is_num(c) || is_min(c) || is_maj(c) || c == '_')) {
			delireCar();
			int resultat = estMotClef();
			if (resultat != -1)
				return resultat;
			return ID_FCT;
		}
		count++;
	}
	return -1;
}
Esempio n. 3
0
void		ft_sort_list2(t_swap **la, t_swap **lb)
{
	if (is_min(*la))
		ft_sort_pb(la, lb);
	else if (is_min((*la)->next))
		ft_sort_sa(la);
	else
		ft_sort_ra(la);
	return ;
}
Esempio n. 4
0
void find_irred_HP(short *S0, char *sequence, double kT, int n){
  int i,j;
  //HP_energy_part=(double**) malloc((n+1)*sizeof(double*));
  //for (i=1;i<=n;i++)
  //  HP_energy_part[i]=(double *) calloc(n+1, sizeof(double));
  for (i=1;i<=n;i++)
    for (j=i+4;j<=n;j++)
      if (pair[S0[i]][S0[j]]){
	if (is_min(i,j, S0, sequence, kT)){
	  HP_energy_part[j][i]=part;
	}
	HP_energy_part[i][j]=energy;
      }
  return;
}
Esempio n. 5
0
char	*ft_strcapitalize(char *str)
{
	int		i;
	int		word;

	i = 0;
	word = 0;
	while (str[i])
	{
		if ((is_min(str[i])) && (word == 0))
			str[i] = str[i] - 32;
		else if ((is_maj(str[i])) && (word == 1))
			str[i] = str[i] + 32;
		if (!(iss_alpha(str[i])))
			word = 0;
		else
			word = 1;
		i++;
	}
	return (str);
}
Esempio n. 6
0
void graph_miner_mpi_dyn::project(Projected &projected, int dfs_level)
{

  if(is_min() == false) {
    return;
  } else {

  }

  // Check if the pattern is frequent enough.
  unsigned int sup = support(projected);

  if(sup < minimal_support) return;

  DEBUG(*logger, "DFS level = " << dfs_level);

  DEBUG(*(graph_miner::logger), "executing project for code: " << DFS_CODE.to_string() << "; support: " << sup);

  // Output the frequent substructure
  report(projected, sup);

  // In case we have a valid upper bound and our graph already exceeds it,
  // return.  Note: we do not check for equality as the DFS exploration may
  // still add edges within an existing subgraph, without increasing the
  // number of nodes.
  //
  //if(maxpat_max > maxpat_min && DFS_CODE.nodeCount() > maxpat_max) return;

  // We just outputted a frequent subgraph.  As it is frequent enough, so
  // might be its (n+1)-extension-graphs, hence we enumerate them all.
  const RMPath &rmpath = DFS_CODE.buildRMPath();
  int minlabel = DFS_CODE[0].fromlabel;
  int maxtoc = DFS_CODE[rmpath[0]].to;

  Projected_map3 new_fwd_root;
  Projected_map2 new_bck_root;
  types::EdgeList edges;

  current_dfs_level = dfs_level;

  // Enumerate all possible one edge extensions of the current substructure.
  for(unsigned int n = 0; n < projected.size(); ++n) {

    unsigned int id = projected[n].id;
    PDFS *cur = &projected[n];
    History history(graph, cur);

    // XXX: do we have to change something here for directed edges?

    // backward
    for(int i = (int)rmpath.size() - 1; i >= 1; --i) {
      Edge *e = get_backward(graph, history[rmpath[i]], history[rmpath[0]], history);
      if(e)
        new_bck_root[DFS_CODE[rmpath[i]].from][e->elabel].push(id, e, cur);
    }

    // pure forward
    // FIXME: here we pass a too large e->to (== history[rmpath[0]]->to
    // into get_forward_pure, such that the assertion fails.
    //
    // The problem is:
    // history[rmpath[0]]->to > graph.size()
    if(get_forward_pure(graph, history[rmpath[0]], minlabel, history, edges)) {
      for(types::EdgeList::iterator it = edges.begin(); it != edges.end(); ++it) {
        new_fwd_root[maxtoc][(*it)->elabel][graph[(*it)->to].label].push(id, *it, cur);
      }
    }

    // backtracked forward
    for(int i = 0; i < (int)rmpath.size(); ++i) {
      if(get_forward_rmpath(graph, history[rmpath[i]], minlabel, history, edges)) {
        for(types::EdgeList::iterator it = edges.begin(); it != edges.end(); ++it) {
          new_fwd_root[DFS_CODE[rmpath[i]].from][(*it)->elabel][graph[(*it)->to].label].push(id, *it, cur);
        } // for it
      } // if
    } // for i
  } // for n


  std::deque<types::DFS> tmp;

  if(dfs_task_queue.size() <= dfs_level) {
    dfs_task_queue.push_back(tmp);
  }

  // Test all extended substructures.
  // backward
  for(Projected_iterator2 to = new_bck_root.begin(); to != new_bck_root.end(); ++to) {
    for(Projected_iterator1 elabel = to->second.begin(); elabel != to->second.end(); ++elabel) {

      DFS dfs(maxtoc, to->first, -1, elabel->first, -1);
      dfs_task_queue[dfs_level].push_back(dfs);

      load_balance();

    }
  }

  // forward
  for(Projected_riterator3 from = new_fwd_root.rbegin();
      from != new_fwd_root.rend(); ++from) {
    for(Projected_iterator2 elabel = from->second.begin();
        elabel != from->second.end(); ++elabel) {
      for(Projected_iterator1 tolabel = elabel->second.begin();
          tolabel != elabel->second.end(); ++tolabel) {

        DFS dfs(from->first, maxtoc + 1, -1, elabel->first, tolabel->first);
        dfs_task_queue[dfs_level].push_back(dfs);

        load_balance();

      }
    }
  }


  //current_dfs_level = dfs_level;
  //current_dfs_level = dfs_level + 1;

  while(dfs_task_queue[dfs_level].size() > 0) {

    DFS dfs = dfs_task_queue[dfs_level].front();
    dfs_task_queue[dfs_level].pop_front();
    DEBUG(*logger, "popped dfs = " << dfs.to_string() );

    current_dfs_level = dfs_level;
    load_balance();

    DFS_CODE.push(dfs.from, dfs.to, dfs.fromlabel, dfs.elabel, dfs.tolabel);

    if(dfs.is_backward())
      project(new_bck_root[dfs.to][dfs.elabel], dfs_level + 1);      //Projected (PDFS vector): each entry contains graph id 0, edge pointer, null PDFS
    else
      project(new_fwd_root[dfs.from][dfs.elabel][dfs.tolabel], dfs_level + 1);      //Projected (PDFS vector): each entry contains graph id 0, edge pointer, null PDFS

    DFS_CODE.pop();
  }

  //current_dfs_level = dfs_level;

  return;
}
Esempio n. 7
0
int main()
{
	unsigned int nr;
	int i, retry;
	int *coeff;
	struct term *tt;
	struct polynomial uit;
	struct polynomial T;
	T.leading = NULL;
	
#ifdef KIJKEN
	printf("Debug is set! To unset do not define KIJKEN.\n");
#endif
	/* Setup the scalars. */
	setup_scalars();

	uit = make_initial_pol(d, 1);
	nr = number_terms(uit);
	coeff = (int *)malloc(nr*sizeof(int));
	for (i = 0; i + 1 <= nr; i++) {
		coeff[i] = 0;
	}
	retry = 1;
	while (retry == 1) {
		next_one(nr, coeff);
		if (is_min(nr, coeff, uit)) {
			myf = copy_pol(uit);
			tt = myf.leading;
			i = 0;
			while (tt) {
				tt->c = coeff[i];
				i++;
				tt = tt->next;
			}
			clean_pol(&myf);
			retry = setup(1);
		} else {
			retry = -1;
		}

		/* retry == 4 means quasi-smooth */
		if (retry == 4) {
			for (i = 0; i + 1 <= nr; i++) {
				printf("%d ", coeff[i]);
			}
			printf("  %d", G.len);
			printf("\n");
		}

		if (retry >= 0) {
			/* Free up G and myf. */
			free_tail(myf.leading);
			for (i = 0; i + 1 <= G.len; i++) {
				free_tail(G.ff[i]->leading);
			}
		}
		retry = 1;
	}
	
	exit(0);
}