Aide:Sommaires : Différence entre versions
De Wicri Chanson de Roland
(→Programme Lex) |
(→Programme Lex) |
||
Ligne 24 : | Ligne 24 : | ||
... | ... | ||
− | lex | + | lex SommaireListNotes.lex |
gcc lex.yy.c -ll -o SommaireListNotes.o | gcc lex.yy.c -ll -o SommaireListNotes.o | ||
</source> | </source> |
Version du 20 mai 2022 à 17:07
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(num, 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