Aide:Sommaires

De Wicri Chanson de Roland

Programme Lex

cat <<... > SommaireListNotes.lex
%{
  char *num;
  char *tit;
%}
%START Z1
%START Z2
%%
^[ ]+[1-9][0-9]*\.[0-9]*[ ]  BEGIN Z1;
<Z1>[0-9]+\.        strcpy(num, yytext);
<Z1>[ ]+           BEGIN Z2;
<Z2>.+            strcpy(tit, yytext);
<Z2>\n             {printf ("* \[\[#%s %s|%s <i>%s</i>\]\]\n", num, tit, num, tit); BEGIN 0;}
%%
main()
{
num=malloc(10);
tit=malloc(100);
yylex();
printf ("\n");
}
...

lex SommaireListNotes.lex

gcc lex.yy.c -ll -o SommaireListNotes.o