Debug 98%
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -11,7 +12,6 @@
|
||||
#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,13 +107,22 @@ int yylex(void)
|
||||
|
||||
c = lireCar();
|
||||
|
||||
// Symbole simple
|
||||
for( int i = 0; tableSymbole[i] != '\0'; ++i ) {
|
||||
if( c == tableSymbole[i] ) {
|
||||
return codeSymbole[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Nombre
|
||||
if( is_num( c ) )
|
||||
{
|
||||
while( is_num( lireCar() ) );
|
||||
do
|
||||
{
|
||||
lireCar();
|
||||
} while( is_num( yytext[yyleng-1] ) );
|
||||
delireCar();
|
||||
|
||||
affiche_element( "nombre", yytext, 1 );
|
||||
return NOMBRE;
|
||||
}
|
||||
|
||||
@@ -121,27 +130,46 @@ int yylex(void)
|
||||
if( c == '$' ) {
|
||||
i = 1; // 1 pour $
|
||||
|
||||
while( is_alphanum( lireCar() )){
|
||||
do
|
||||
{
|
||||
lireCar();
|
||||
i++;
|
||||
}
|
||||
} while( is_alphanum( yytext[yyleng-1] ) );
|
||||
i--;
|
||||
delireCar();
|
||||
|
||||
|
||||
if(i > 99) {
|
||||
erreur("Nom variable > 99 characters");
|
||||
return -1;
|
||||
}
|
||||
|
||||
affiche_element( "id_variable", yytext, 1 );
|
||||
return ID_VAR;
|
||||
}
|
||||
|
||||
// Mot clefs
|
||||
do {
|
||||
lireCar();
|
||||
} while( !isspace( yytext[yyleng-1] ) );
|
||||
delireCar();
|
||||
|
||||
for( int i = 0; tableMotsClefs[i] != '\0'; ++i )
|
||||
{
|
||||
if( strcmp( tableMotsClefs[i], yytext ) == 0 ) {
|
||||
return codeMotClefs[i];
|
||||
}
|
||||
}
|
||||
|
||||
//id_fct
|
||||
if( is_alpha( c ) ) {
|
||||
int i = 1; // 1 pour $
|
||||
|
||||
while( is_alphanum(lireCar())) {
|
||||
|
||||
do
|
||||
{
|
||||
lireCar();
|
||||
i++;
|
||||
}
|
||||
} while( is_alphanum( yytext[yyleng-1] ) );
|
||||
i--;
|
||||
|
||||
delireCar();
|
||||
|
||||
@@ -150,32 +178,10 @@ int yylex(void)
|
||||
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] ) {
|
||||
char tmp[1];
|
||||
tmp[0] = c;
|
||||
affiche_element( "symbole", tmp, 1 );
|
||||
return codeSymbole[i];
|
||||
}
|
||||
}
|
||||
|
||||
// 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];
|
||||
}
|
||||
}
|
||||
|
||||
erreur("Aucune Correspondance");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user