Bonjour,

dsl pour ma langue je parle pas bien le français;
je suis entrin de devlopper un analyseur lexical pour un programme (pascal) prèci ,et j'ai des pbs,dans mon prog
j'ouvre le texte a analyser a partir d'un fichier et le texte source je le met dans un notre fichier.le pb c que a l'execution j'ai un texte vide.
.voila mon code:
*********************************************************************
#include<stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
char c;
char buffer[100];
char *motcle[]={"program","var","integer","real","boolean","begin","true","while","writeln","readln",
"if","then","end","else","false"};
char *separa[]={";",":",",",":=","'","/","(",")","<>",">","+","-","."};
char *ident[100];
int k,i,p,nident=0;
//:declaration de struct*********************
struct Ttoken{
int type;
int pos;
int li;
int col;
} token;
//******************************************
// la foncton qui che *************************
int trouv(char *t[],char *s,int n)
{
int j,pos=-1;
for(j=0;j<n;j++)
{if(strcmp(t[j],s)==0)
pos= j;
}
return pos;
}//********************************************
int main(void)
{
FILE *f,*fs;
int etat = 0;
int ib=0;
f=fopen("tp1.pas","r");
fs=fopen("tp10.txt","w");
while(fread(&c,sizeof(char),1,f))
{
if (c!='\r')
{
switch(etat)
{case 0:
{
if (isalpha(c))
{
etat = 1;
i=0;
buffer[i]=c;
i++;
ib++;
continue;
}
}
case 1:
{
if (isalnum(c)) {
buffer[i]=buffer[i]+c;
i++;
ib++;
} else {
p=trouv(motcle,buffer,13);
if(p!=-1){
token.type=1;
token.pos=p;
token.li=0;
token.col=0;
fwrite(&token,sizeof(token),1,fs);
}
else
{
p=trouv(ident,buffer,nident);
if(p!=-1){
token.type=2;
token.pos=p;
token.li;
token.col;
fwrite(&token,sizeof(token),1,fs);
}
else
{
ident[nident]=malloc(sizeof(buffer[i]));
strcpy(ident[nident],buffer);
buffer[i]='\0';
token.type=2;
token.pos=p;
token.li;
token.col;
fwrite(&token,sizeof(token),1,fs);
nident=nident+1;
}}
}
etat = 0;
ungetc(c,f);
}
token.col++;
}}
else token.li++;
}
fclose(f);
fclose(fs);
}
***********************merci d'avance**************************