help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"input in flex scanner failed " help me please


From: Franck PAULUS
Subject: "input in flex scanner failed " help me please
Date: Thu, 22 May 2003 11:54:10 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826

hi,
i have made that code, and i have got this result "input in flex scanner failed" under solaris and linux with gcc 2.96 & 3.2. flex 2.5.4
Please could you tell me why it append.

thank Franck.



/***************************************************************************
                          jobfile.l  -  description
                             -------------------                                
         
    begin                : mar déc 3 2002                                       
    
    copyright            : (C) 2002 by f.paulus                         
    email                : address@hidden                                     
 ***************************************************************************/


%{

//#define DEBUG
#include <stdio.h>
#include <string.h>
#include "structjob.h"
#include "job.h"
//#ifdef DEBUG
char* fichier="/proj/SDIFF3/data/echangePilote/exabyte/job/7_209960.job";
job jobfile;
//#endif
int i=0;
int tmp=0;

/* Comments and definitions goes here. So does options. */
/* Specifically, if you want to use more than one lexical file in each */
/* project you will have to use the option '%option prefix="whatever"'.*/
/* This will replace the "yy" part in function and variable names with */
/* the string "whatever". For more information, as well as documentation */
/* of other options, see the GNU Flex manual. */
%}

virgule                   [,]
blanc                     [ \t]
debut                     [[]
fin                       []]
guillemet                 ["]
deuxpoints                [:]  
lettre                    [A-Za-z/]
date_creation             DATE_CREATION
infos_dem                 INFOS_DEM             
infos_doc                 INFOS_DOC
infos_diff                INFOS_DIFF
infos_lot                 INFOS_LOT
lots_diffusion_id         NO_LOT
ordre_diffusion           NO_DANS_LOT
lots_diffusion_nb_ordre   TOTAL_LOT
nb_exemplaires            NB_EXEMPLAIRE
infos_diff_pages          INFOS_DIFF_PAGE
format_de_sortie          FORMAT_DE_SORTIE
page                      PAGE
mode                      mode
code                      code
bac_entree                bac_entree
format                    gr4|st33|tiff|eps|pdf|tif|tiffmono
mod                       R|V
pixels                    pixels
lignes                    lignes
type                      A0|A1|A2|A3|A4|B1|B2|B3|B4
numero                    Num
tiret                     [-]
chiffre                   [0-9]
nombre                    [0-9]+
filename                  [a-zA-Z0-9\/._,-]+


%x pformat_de_sortie
%x pdate_creation
%x pinfos_dem
%x pinfos_doc
%x pinfos_diff
%x pinfos_lot
%x plots_diffusion_id
%x pordre_diffusion 
%x plots_diffusion_nb_ordre
%x pnb_exemplaires 
%x pinfos_diff_pages
%x ppage
%x pformat
%x pcode
%x pmode
%x pbac_entree
%x ppixels
%x plignes
%x pnumero
%x ptype
%x finptype
%x finplignes
%x attentenombre
%%

{date_creation}                                       {
                                                       #ifdef DEBUG  
                                                       printf("DEBUG:date 
creation:%s \n",jobtext); 
                                                       #endif 
                                                      BEGIN(pdate_creation);
                                                      }

{infos_dem}                                           {
                                                       #ifdef DEBUG  
                                                       printf("DEBUG:infos 
dem:%s \n",jobtext); 
                                                       #endif 
                                                      BEGIN(pinfos_dem);
                                                      }

{infos_doc}                                           {
                                                       #ifdef DEBUG
                                                       printf("DEBUG:infos 
doc:%s \n",jobtext); 
                                                       #endif 
                                                       BEGIN(pinfos_doc);
                                                      }

{infos_lot}                                           {
                                                       #ifdef DEBUG  
                                                       printf("DEBUG:infos 
lot:%s \n",jobtext); 
                                                       #endif 
                                                       BEGIN(pinfos_lot);
                                                      }

{infos_diff}                                          {
                                                       #ifdef DEBUG
                                                       printf("DEBUG:debut 
infos diff:%s \n",jobtext);
                                                       #endif
                                                       BEGIN(pinfos_diff);
                                                      }

{lots_diffusion_id}                                   {
                                                        #ifdef DEBUG 
                                                        printf("DEBUG:lots 
diffusion id :%s \n",jobtext); 
                                                        #endif 
                                                        
BEGIN(plots_diffusion_id);
                                                      }

{ordre_diffusion}                                     {
                                                       #ifdef DEBUG  
                                                       printf("DEBUG:ordre 
diffusion :%s \n",jobtext);
                                                       #endif 
                                                       BEGIN(pordre_diffusion);
                                                      } 

{lots_diffusion_nb_ordre}                             {
                                                       #ifdef DEBUG
                                                       printf("DEBUG:lots 
diffusion nb ordre :%s \n",jobtext); 
                                                       #endif 
                                                       
BEGIN(plots_diffusion_nb_ordre);
                                                      }

{nb_exemplaires}                                      {
                                                       #ifdef DEBUG  
                                                       printf("DEBUG:debut nb 
exemplaires :%s \n",jobtext); 
                                                       #endif 
                                                       BEGIN(pnb_exemplaires);
                                                      }

{infos_diff_pages}                                    {
                                                       #ifdef DEBUG  
                                                       printf("DEBUG:debut 
infos diff pages:%s \n",jobtext); 
                                                       #endif  
                                                       BEGIN(pinfos_diff_pages);
                                                      }

{page}                                                {
                                                       #ifdef DEBUG
                                                       printf("DEBUG:debut 
PAGE:%s \n",jobtext);
                                                       #endif
                                                       BEGIN(ppage);
                                                      }

<pdate_creation>.+                                   {
                                                       #ifdef DEBUG
                                                       printf("DEBUG:date 
creation:%s \n",jobtext);
                                                       #endif
                                                       
strcpy(jobfile.DATE_CREATION,jobtext);
                                                       BEGIN(INITIAL);
                                                      }

<pinfos_dem>.+                                       {
                                                       #ifdef DEBUG
                                                       printf("DEBUG:infos 
dem::%s \n",jobtext);
                                                       #endif
                                                       
strcpy(jobfile.INFOS_DEM,jobtext);
                                                       BEGIN(INITIAL);
                                                      }


<pinfos_lot>.+                                        {
                                                       #ifdef DEBUG
                                                        printf("DEBUG:infos 
lot:%s \n",jobtext);
                                                       #endif
                                                       
strcpy(jobfile.INFOS_LOT,jobtext);
                                                       BEGIN(INITIAL);
                                                      }

                       

<pinfos_diff>.+                                      {
                                                       #ifdef DEBUG
                                                       printf("DEBUG:infos 
diff:%s \n",jobtext);
                                                       #endif
                                                       
strcpy(jobfile.INFOS_DIFF,jobtext);
                                                       BEGIN(INITIAL);
                                                     }

<pinfos_doc>{blanc}*{guillemet}.*{numero}{blanc}*{deuxpoints}            {
                                                                           
#ifdef DEBUG
                                                                           
printf("DEBUG:pinfos doc:%s \n",jobtext);
                                                                           
#endif
                                                                           
BEGIN(pnumero); 
                                                                         }

<pnumero>{blanc}*{nombre}                            { 
                                                      
strcpy(jobfile.NUM,jobtext);
                                                      #ifdef DEBUG
                                                      
printf("DEBUG:jobfile.NUM:%s \n",jobfile.NUM);
                                                      #endif
                                                      BEGIN(ptype);
                                                     }

<ptype>{virgule}{blanc}*{tiret}                      {
                                                      #ifdef DEBUG
                                                      printf("DEBUG:type:%s 
\n",jobtext);
                                                      #endif
                                                     } 

<ptype>{type}                                        {
                                                      #ifdef DEBUG
                                                      printf("DEBUG:type:%s 
\n",jobtext);
                                                      #endif
                                                      
strcpy(jobfile.TYPE,jobtext);
                                                      BEGIN(finptype);
                                                     } 
                  
<finptype>{tiret}+{nombre}                           {
                                                      
                                                     tmp=atoi(jobtext);
                                                     tmp=abs(tmp);
                                                     
jobfile.INFOS[i].nombre=tmp;
                                                                                
                         #ifdef DEBUG
                                                                            
printf("DEBUG:fin type :%s \n",jobtext);
                                                                                
                                                                        
printf("nb NUM:%s\n",jobfile.NUM);
                                                                                
                                                                        
printf("nb TYPE:%s\n",jobfile.TYPE);
                                                      #endif
                                                     BEGIN(attentenombre);
                                                    }

<attentenombre>{tiret}+{nombre}                     {
                                                     
                                                     tmp=atoi(jobtext);
                                                     tmp=abs(tmp);
                                                     jobfile.INFOS[i].debut=tmp;
                                                     i++;
                                                                                
                         #ifdef DEBUG
                                                                            
printf("DEBUG:fin type :%s \n",jobtext);
                                                                                
                                                                        
printf("nb NUM:%s\n",jobfile.NUM);
                                                                                
                                                                        
printf("nb TYPE:%s\n",jobfile.TYPE);
                                                     #endif
                                                     BEGIN(finptype);
                                                    }


<finptype>-{guillemet}                             {
                                                      #ifdef DEBUG
                                                                            
printf("DEBUG:fin type :%s \n",jobtext);
                                                      #endif
                                                     BEGIN(INITIAL);
                                                    }

<finptype>{guillemet}                              {
                                                      #ifdef DEBUG
                                                                            
printf("DEBUG:fin type fini fini  :%s \n",jobtext);
                                                      #endif
                                                     BEGIN(INITIAL);
                                                    }

<attentenombre>-{guillemet}                             {
                                                      #ifdef DEBUG
                                                                            
printf("DEBUG:fin type :%s \n",jobtext);
                                                      #endif
                                                     BEGIN(INITIAL);
                                                    }

<attentenombre>{guillemet}                              {
                                                      #ifdef DEBUG
                                                                            
printf("DEBUG:fin type fini fini  :%s \n",jobtext);
                                                      #endif
                                                     BEGIN(INITIAL);
                                                    }

<plots_diffusion_id>{nombre}                         {
                                                       
jobfile.NO_LOT=atoi(jobtext);
                                                       BEGIN(INITIAL);
                                                      }


<pordre_diffusion>{nombre}                            {
                                                       
jobfile.NO_DANS_LOT=atoi(jobtext);
                                                       BEGIN(INITIAL);
                                                      }

<plots_diffusion_nb_ordre>{nombre}                    {
                                                       
jobfile.TOTAL_LOT=atoi(jobtext);
                                                       BEGIN(INITIAL);
                                                      }

<pnb_exemplaires>{nombre}                            {
                                                       
jobfile.NB_EXEMPLAIRES=atoi(jobtext);
                                                       BEGIN(INITIAL);
                                                      }
                        

<pinfos_diff_pages>{blanc}*{guillemet}{blanc}*{code}{blanc}*{deuxpoints}     {
                                                                             
BEGIN(pcode);
                                                                             
#ifdef DEBUG
                                                                             
printf("DEBUG:pcode:%s \n",jobtext);
                                                                             
#endif
                                                                             }


<pcode>{blanc}*{format}                                {
                                                       
strcpy(jobfile.FORMAT,jobtext); // a mettre en commentaire
                                                       #ifdef DEBUG
                                                       printf("DEBUG:code:%s 
\n",jobtext);
                                                       #endif
                                                       }

{format_de_sortie}{blanc}{guillemet}                   { 
                                                       
BEGIN(pformat_de_sortie);             
                                                       }

<pformat_de_sortie>{format}                            { 
                                                       
strcpy(jobfile.FORMAT,jobtext);
                                                       #ifdef DEBUG
                                                       printf("DEBUG:format de 
sortie :%s \n",jobtext);
                                                       #endif
                                                       BEGIN(INITIAL);          
   
                                                       } 

<pcode>{blanc}*{mode}{blanc}*{deuxpoints}              {
                                                       BEGIN(pmode);
                                                       }

 
<pmode>{blanc}*{mod}                                   {
                                                       
strcpy(jobfile.MODE,jobtext);
                                                       #ifdef DEBUG
                                                       printf("DEBUG:mode:%s 
\n",jobtext);
                                                       #endif
                                                       }

<pmode>{blanc}*{bac_entree}{blanc}*{deuxpoints}        {
                                                       BEGIN(pbac_entree);
                                                       }

<pbac_entree>{blanc}*{nombre}                          {
                                                       
jobfile.BAC_ENTREE=atoi(jobtext);
                                                       #ifdef DEBUG
                                                       
printf("DEBUG:bac_entree:%d \n",jobfile.BAC_ENTREE);
                                                       #endif
                                                       }


<pbac_entree>{blanc}*{pixels}{blanc}*{deuxpoints}      {
                                                        BEGIN(ppixels);
                                                       }


<pbac_entree>{blanc}*{guillemet}                       {
                                                        BEGIN(INITIAL);
                                                       }

<ppixels>{blanc}*{nombre}                              {
                                                       
jobfile.PIXELS=atoi(jobtext);
                                                       #ifdef DEBUG
                                                       printf("DEBUG:pixels:%d 
\n",jobfile.PIXELS);
                                                       #endif
                                                       } 

<ppixels>{blanc}*{lignes}{blanc}*{deuxpoints}          {
                                                        BEGIN(plignes);
                                                       }

<plignes>{blanc}*{nombre}                              {
                                                       
jobfile.LIGNES=atoi(jobtext);
                                                       #ifdef DEBUG
                                                       printf("DEBUG:lignes:%d 
\n",jobfile.LIGNES);
                                                       #endif
                                                       BEGIN(finplignes);
                                                       } 

<finplignes>.+                                        { 
                                                        #ifdef DEBUG
                                                         printf("DEBUG:fin 
pligne: %s \n" , jobtext);
                                                        #endif 
                                                        
                                                        BEGIN(INITIAL);
                                                       }




<ppage>{filename}                                        {
                                                       #ifdef DEBUG
                                                       printf("DEBUG: %s 
NOMBRE_DE_PAGES=%d\n" , jobtext,jobfile.NOMBRE_DE_PAGES);
                                                       #endif 

                                                       
jobfile.PAGE[jobfile.NOMBRE_DE_PAGES]=(char *)malloc(500);
                                                       if 
(jobfile.PAGE[jobfile.NOMBRE_DE_PAGES]!=NULL)  
                                                                 {
                                                                 
strcpy(jobfile.PAGE[jobfile.NOMBRE_DE_PAGES],jobtext);
                                                                 
jobfile.nROWS[jobfile.NOMBRE_DE_PAGES]=jobfile.LIGNES;
                                                                 
jobfile.nPIXELSPERROW[jobfile.NOMBRE_DE_PAGES]=jobfile.PIXELS;
                                                                 
jobfile.RESOLUTION[jobfile.NOMBRE_DE_PAGES]=300;
                                                                 #ifdef DEBUG
                                                                 
printf("DEBUG:jobfile.PAGE[%d] alloue avec succes\n" ,jobfile.NOMBRE_DE_PAGES);
                                                                 #endif 
                                                                 }
                                                       else
                                                       {
                                                       #ifdef DEBUG
                                                       
printf("DEBUG:jobfile.PAGE[%d] echec malloc \n" ,jobfile.NOMBRE_DE_PAGES);
                                                       #endif 
                                                       }
                                                       
jobfile.NOMBRE_DE_PAGES=jobfile.NOMBRE_DE_PAGES+1;
                                                       BEGIN(INITIAL);
                                                      }

<<EOF>>                                               {
                                                       #ifdef DEBUG
                                                       printf("DEBUG: EOF \n");
                                                       #endif
                                                       BEGIN(INITIAL);
                                                       yyterminate();
                                                       }
                        

%%

int ecrireJob(char* fichier)
  {
    FILE * fp;
    fp=fopen(fichier,"w");
    if (fp==NULL) {return -1;};
    fclose(fp);
    return 0;
  }

int lirejob(char* fichier)
    {

    yy_flex_realloc( jobin, 100000);
    yy_flush_buffer(NULL);
    //FILE * fp;
    jobin=fopen(fichier,"r");
    if (jobin==NULL) {return -1;};
    //jobin=fp;
    #ifdef DEBUG
    printf("DEBUT ANALYSE-->\n");
    #endif
    joblex(); 
    #ifdef DEBUG
    printf("FIN ANALYSE-->\n");
    printf("DATE de creation:%s\n",jobfile.DATE_CREATION);
    printf("infos_dem:%s\n",jobfile.INFOS_DEM);
    printf("infos_doc:%s\n",jobfile.INFOS_DOC);
    printf("infos_diff:%s\n",jobfile.INFOS_DIFF);
    printf("infos_lot:%s\n",jobfile.INFOS_LOT);
    printf("no_lot:%d\n",jobfile.NO_LOT);
    printf("nb NUM:%s\n",jobfile.NUM);
    printf("nb TYPE:%s\n",jobfile.TYPE);
    #endif
    fclose(jobin);
    free(jobin);
    fflush(NULL);
    return 0;
  }

int initjobstruct()
  {
   int comp;
   
   strcpy(jobfile.DATE_CREATION,"");
   strcpy(jobfile.INFOS_DEM,"");
   strcpy(jobfile.INFOS_DOC,"");
   strcpy(jobfile.INFOS_DIFF,"");
   strcpy(jobfile.INFOS_LOT,"");
   strcpy(jobfile.NUM,"");
   strcpy(jobfile.TYPE,"");
   jobfile.NO_LOT=0;
   jobfile.NO_DANS_LOT=0;
   jobfile.TOTAL_LOT=0;
   jobfile.NB_EXEMPLAIRES=0;
   strcpy(jobfile.INFOS_DIFF_PAGE,"");
   strcpy(jobfile.FORMAT,"");
   strcpy(jobfile.MODE,"");
   jobfile.PIXELS=0;
   jobfile.LIGNES=0;
   jobfile.BAC_ENTREE=0;
   strcpy(jobfile.NUM,"");
   strcpy(jobfile.TYPE,"");
   for (comp=jobfile.NOMBRE_DE_PAGES+1; comp==0; comp--)
     {
      jobfile.RESOLUTION[comp]=300;
      jobfile.nPIXELSPERROW[comp]=0;
      jobfile.nROWS[comp]=0;
      free(jobfile.PAGE[comp]);
     }
  //free(jobfile.PAGE);
  jobfile.NOMBRE_DE_PAGES=0;
  //free(jobfile.INFOS);
  fflush(yyin);
  free(jobin);
  //clearerr(jobin);
  fflush(NULL);
  return 0;
  }


int jobwrap()
  {
   return 1;
  }

int main()
   {  
    long i=0; 
    while(i!=-10)
    {   
    initjobstruct();
    lirejob(fichier);
    i++;        
    //printf("Il y a %d  page(s)  de garde qui commence a la page %d \n", 
jobfile.INFOS[GARDE].nombre, jobfile.INFOS[GARDE].debut);
    //printf("Il y a %d  page(s)  de revendication  qui commence a la page %d 
\n",jobfile.INFOS[REVENDICATION].nombre,jobfile.INFOS[REVENDICATION].debut);
    //printf("Il y a %d  page(s)  de dessin qui commence a la page %d 
\n",jobfile.INFOS[DESSIN].nombre,jobfile.INFOS[DESSIN].debut);
    //printf("Il y a %d  page(s)  de erratas qui commence a la page %d 
\n",jobfile.INFOS[ERRATAS].nombre,jobfile.INFOS[ERRATAS].debut);
    //printf("Il y a %d  page(s)  de description  qui commence a la page %d 
\n",jobfile.INFOS[DESCRIPTION].nombre,jobfile.INFOS[DESCRIPTION].debut);
    //printf("Il y a %d  page(s)  de abrege  qui commence a la page %d 
\n",jobfile.INFOS[ABREGE].nombre,jobfile.INFOS[ABREGE].debut);
    //printf("Il y a %d  page(s)  de rapport  qui commence a la page %d 
\n",jobfile.INFOS[RAPPORT].nombre,jobfile.INFOS[RAPPORT].debut);
    //printf(" \n Format de sortie : %s  \n",jobfile.FORMAT);
    printf("\nsize of jobfile struct %d \n", sizeof(jobfile));
    printf("\nFICHIER %d NUM %s TYPE %s \n",i,jobfile.NUM, jobfile.TYPE);
    if (strcmp (jobfile.NUM,"")==0)
        {
         printf("comparaison NUM %s ", jobfile.NUM);
         return(-1);
        };
    //sleep(1);
    }
    return 1;
   }
/***************************************************************************
                          job.h  -  description
                             -------------------
    begin                : mar déc 3 2002
    copyright            : (C) 2002 by f.paulus
    email                : address@hidden
 ***************************************************************************/


int ecrireJob(char* fichier);
int lirejob(char* fichier);
int initjobstruct();
/***************************************************************************
                          structconf.h  -  description
                             -------------------
    begin                : mar déc 3 2002
    copyright            : (C) 2002 by f.paulus
    email                : address@hidden
 ***************************************************************************/

// definition des constantes
#define TAILLE_PATH                             500
#define NBR_PAGES                               2000
#define NBR_MAX_VOLUMES                 20
#define GARDE                                   0
#define REVENDICATION                           1
#define DESSIN                                  2
#define ERRATAS                                 3
#define DESCRIPTION                             4
#define ABREGE                                  5
#define RAPPORT                                 6


typedef struct infos_pages{
  
  int debut;
  int nombre;

}pages;


typedef struct job_struct{
        
    // ATTENTION 17/4/03 1.2 JPG pb free memoire a resoudre: pb interface C/C++
  char DATE_CREATION[40];
  char INFOS_DEM[40];
  char INFOS_DOC[40];
  char NUM[10];
  char TYPE[10];
  char INFOS_DIFF[40];
  char INFOS_LOT[40];
  int  NO_LOT;
  int  NO_DANS_LOT;
  int  TOTAL_LOT;
  int  NB_EXEMPLAIRES;
  char INFOS_DIFF_PAGE[80];
  char FORMAT[15];
  char MODE[4];
  int  PIXELS;
  int  LIGNES;
  int  BAC_ENTREE;
  int  NOMBRE_DE_PAGES;
  int  RESOLUTION[NBR_PAGES];
  int  nPIXELSPERROW[NBR_PAGES];
  int  nROWS[NBR_PAGES];
  pages INFOS[16];
  char *(PAGE[NBR_PAGES]);
   
  

}job;


extern job jobfile;
DATE_CREATION "Wed Apr 16 18:44:45 2003"
INFOS_DEM "BOPI ANNEE:%2c SEMAINE:%2c!%33c!%33c!%33c!%33c!%6c!%27c!%20"
INFOS_DOC "Ty:A Num:2831387 An:03,                 
-A1-1-1-2-10-2-12-0-0-8-2-1-1-2-14-0-0"
INFOS_DIFF "0             A4 R"
INFOS_LOT "Echange avec OEB A:2003/18"
EMAIL ""
FAX ""
NO_LOT 1358
NO_DANS_LOT 2
TOTAL_LOT 380
NB_EXEMPLAIRE 1
INFOS_DIFF_PAGE "code:st33 mode:R bac_entree:0 pixels:2592 lignes:3508"
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0001.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0002.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0003.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0004.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0005.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0006.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0007.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0008.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0009.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0010.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0011.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0012.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0013.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0014.gr4
PAGE /proj/SDIFF3/data/echangePilote/3480ibm/doc/209960_0015.gr4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]