Aide:Sommaires : Différence entre versions
De Wicri Chanson de Roland
(→Programme Lex) |
(→Programme Lex) |
||
Ligne 13 : | Ligne 13 : | ||
<Z1>[ ]+ BEGIN Z2; | <Z1>[ ]+ BEGIN Z2; | ||
<Z2>.+ strcpy(tit, yytext); | <Z2>.+ strcpy(tit, yytext); | ||
− | <Z2>\n {printf ("* \[\[#%s %s|%s <i>%s</i>]]\n)", num, tit, num, tit); BEGIN 0;} | + | <Z2>\n {printf ("* \[\[#%s %s|%s <i>%s</i>\]\]\n)", num, tit, num, tit); BEGIN 0;} |
%% | %% | ||
main() | main() |
Version du 20 mai 2022 à 17:20
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