| V I S U A L I Z Z A D I S C U S S I O N E |
| ioboss |
Inserito il - 24/02/2004 : 20:30:46 <REG_NUM> ::= <REG> | <NUM> <FATTORE> ::= <REG_NUM> { * | / } <REG_NUM> <ESPR> ::= <FATTORE> { + | - } <FATTORE> <REG> ::= AX | BX | CX | DX ragazzi ma queste regole vanno bene per la mia grammatica? ho paura di doverle modificare perchè hanno due prefessi comuni.. come le modifico?? aiutatemi.. :D |
| 3 U L T I M E R I S P O S T E (in alto le più recenti) |
| ioboss |
Inserito il - 25/02/2004 : 23:37:22 mi dite xkè queste funzioni nn funzionano come si deve? javascript:insertsmilie(' ') javascript:insertsmilie(' ') il compilatore nn mi da errore ma nn si comportano come dovrebbero. /******************************************************************************* **********************************Tabella Hash********************************** *******************************************************************************/ unsigned hash(char *s) /*Funzione che calcola il valore hash di s*/ { int hashval = 0, i = 0;
for ( ;s[i] != '\0'; i++) hashval = s[i] + 17 * hashval;
return hashval % HASHSIZE; }
/*Funzione che verifica se la posizione dell'array è già occupata da una lista */ int esiste(char *s) { if (hashtab[hash(s)] != NULL ) return 1; else return 0; }
/*************Funzione ke ricerca un Identificatore nella taballa**************/ int trova(char *s) { miotoken *pt; pt = hashtab[hash(s)]; if (esiste(s)) if ( pt->tipo.name == s) return 1; else while (pt->succ != NULL) { pt = pt->succ; if (pt->tipo.name == s) return 1; } return 0; }
/************Funzione ke inserisce un Identificatore nella taballa*************/ void inserisci(char *s) { if(!trova(s)) { miotoken *pt; pt = &token; pt->succ = NULL; if (!esiste(s)) hashtab[hash(s)] = pt; else { pt->succ = hashtab[hash(s)]; hashtab[hash(s)] = pt; } } else errore(6); }
void printhash() { int i = 0; miotoken *pt; pt = hashtab[i]; for (; i < HASHSIZE; i++) { printf("\nposizione: %d\n elemento: %9s", i, pt->tipo.name); for (; pt->succ != NULL; pt = pt->succ) printf("\nposizione_: %d\n elemento: %9s", i, pt->tipo.name); } }   |
| ioboss |
Inserito il - 25/02/2004 : 00:51:28                   grazie, nn c'avevo pensato..  |
| nicux |
Inserito il - 24/02/2004 : 21:43:16 che ne dici, ti piace ora?
<OP_PRIMARIO> ::= * | / <OP_SECONDARIO> ::= + | - <REG_NUM> ::= <REG> | <NUM> <FATTORE> ::= <REG_NUM><OP_PRIMARIO> <REG_NUM> <ESPR> ::= <FATTORE><OP_SECONDARIO><FATTORE> <REG> ::= AX | BX | CX | DX
|