flex

flex 词法分析

fb.l

 1 %option noyywrap
 2 %{
 3 #include <stdio.h>
 4 int chars = 0;
 5 int words = 0;
 6 int lines = 0;
 7 %}
 8 
 9 %%
10 
11 [a-zA-Z]+    { words++; chars += strlen(yytext); }
12 \n            { chars++; lines++; }
13 .            { chars++; }
14 
15 %%
16 
17 int main(int argc, char **argv)
18 {
19     yylex();
20     printf("%8d%8d%8d\n", lines, words, chars);
21 }

 

$ flex fb.l

$ cc lex.yy.c

$ cat fb.l | ./a.out

 

%option noyywrap

http://stackoverflow.com/questions/1811125/undefined-reference-to-yywrap

 

posted on 2016-04-15 00:27  明天有风吹  阅读(173)  评论(0编辑  收藏  举报

导航

+V atob('d2h5X251bGw=')

请备注:from博客园