Discussion:CIDE (2003) Michel

De CIDE

Cet article sert à la mise au point d'un programme lex pour les biblio CIDE

cat <<... >biblioCIDE.lex
 int reste;
%START Z1
%START Z2
%START URL
%%
^"["   { if (reste>0) printf("}}\n");
         reste=1;
         printf ("{{CIDE biblio\n  |id="); BEGIN Z1;}
^"<"    { if (reste>0) printf("}}\n");
          printf(":<small><nowiki>< </nowiki>");
          BEGIN URL;
         }
<URL>">" { printf("<nowiki> > </nowiki></small>"); reste=0;}
<URL>.   ECHO;
<Z1>"]"/[\t ]*[A-Z][a-z]+[ ]+[A-Z]".," {printf ("\n  |auteur="); BEGIN Z2;}

<Z1>"]"   {printf ("\n  |texte="); BEGIN 0;}
<Z1>.   ECHO;
<Z2>".,"   {printf (".\n  |texte="); BEGIN 0;}
<Z2>.   ECHO;
%%
main ()
{
  reste=0;
  yylex();
  if (reste>0) printf("}}\n");
}
...
lex biblioCIDE.lex
gcc lex.yy.c -ll -o biblioCIDE
./biblioCIDE <<...
...