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