Bonjour,
j'ai jamais utilisé Flex.J'ai téléchargé Flex à partir de ce lien http://sourceforge.net/projects/flex/files/flex/ et je veut écrire ce code comme un exemple ,où je doit l'écrire ?
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 /* * Sample Scanner1: * Description: Replace the string "username" from standard input * with the user's login name (e.g. lgao) * Usage: (1) $ flex sample1.lex * (2) $ gcc lex.yy.c -lfl * (3) $ ./a.out * stdin> username * stdin> Ctrl-D * Question: What is the purpose of '%{' and '%}'? * What else could be included in this section? */ %{ /* need this for the call to getlogin() below */ #include <unistd.h> %} %% username printf("%s\n", getlogin()); %% main() { yylex(); }
Partager