发现学英语的好处了,用中文搜到%s,%x的区别是相当的困难!
The former (%s) declares inclusive start
the latter (%x) declares exclusive start
|
具体区别看pdf
|
文件: | data.pdf |
大小: | 37KB |
下载: | 下载 |
|
又了现了一个对C语言注释进行处理的方法
%x comment
%%
int line_num = 1;
"/*" BEGIN(comment);
<comment>[^*\n] ;
<comment>"*"+[^*/\n]* ;/*Perhaps you could wonder if it contains the kind "***" or more "*".The myths is that it match one "*" every time*/
<comment>\n ++line_num;
<comment>"*/" {printf("%d lines\n",line_num); BEGIN(INITIAL); }
%%
int main()
{
yylex();
return 0;
}
int yywrap()
{
return 1;
}
|
阅读(1988) | 评论(0) | 转发(0) |