Ajout test mot_clef, reparation des fonction de test
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#define is_min(c)(('a' <= (c)) && ((c) <= 'z'))
|
||||
#define is_alpha(c)(is_maj(c) || is_min(c) || (c) == '_' || (c) == '$')
|
||||
#define is_alphanum(c)(is_num((c)) || is_alpha((c)))
|
||||
#define is_space(c)((c) == ' ' || (c) == '\n' || (c) == '\t' || (c) == '#' )
|
||||
|
||||
extern FILE *yyin;
|
||||
|
||||
@@ -107,9 +108,9 @@ int yylex(void)
|
||||
c = lireCar();
|
||||
|
||||
// Nombre
|
||||
if( isdigit( c ) )
|
||||
if( is_num( c ) )
|
||||
{
|
||||
while( isdigit( lireCar() ) );
|
||||
while( is_num( lireCar() ) );
|
||||
delireCar();
|
||||
|
||||
affiche_element( "nombre", yytext, 1 );
|
||||
@@ -118,15 +119,15 @@ int yylex(void)
|
||||
|
||||
//id_var
|
||||
if( c == '$' ) {
|
||||
int compteur = 1; // 1 pour $
|
||||
i = 1; // 1 pour $
|
||||
|
||||
while( is_alphanum( lireCar() )){
|
||||
compteur++;
|
||||
i++;
|
||||
}
|
||||
delireCar();
|
||||
|
||||
if(compteur > 99) {
|
||||
erreur("Nom variable > 99 character");
|
||||
if(i > 99) {
|
||||
erreur("Nom variable > 99 characters");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -134,6 +135,25 @@ int yylex(void)
|
||||
return ID_VAR;
|
||||
}
|
||||
|
||||
//id_fct
|
||||
if( is_alpha( c ) ) {
|
||||
int i = 1; // 1 pour $
|
||||
|
||||
while( is_alphanum(lireCar())) {
|
||||
i++;
|
||||
}
|
||||
|
||||
delireCar();
|
||||
|
||||
if(i > 99) {
|
||||
erreur("Nom fonction > 99 characters");
|
||||
return -1;
|
||||
}
|
||||
|
||||
affiche_element( "id_fonction", yytext, 1 );
|
||||
return ID_FCT;
|
||||
}
|
||||
|
||||
// Symbole simple
|
||||
for( int i = 0; tableSymbole[i] != '\0'; ++i ) {
|
||||
if( c == tableSymbole[i] ) {
|
||||
@@ -144,8 +164,17 @@ int yylex(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mot clefs
|
||||
while( !is_space( lireCar() ) );
|
||||
delireCar();
|
||||
|
||||
for( int i = 0; tableMotsClefs[i] != '\0'; ++i )
|
||||
{
|
||||
if( strcmp( tableMotsClefs[i], yytext ) == 0 ) {
|
||||
affiche_element( "mot-clef", yytext, 1 );
|
||||
return codeMotClefs[i];
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user