Aide:Sommaires
De Wicri Chanson de Roland
Révision datée du 20 mai 2022 à 17:23 par Jacques Ducloy (discussion | contributions) (→Programme Lex)
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