cornsea

2011年2月12日 #

flex--扫描器生成工具

摘要: flex是一种功能强大的扫描器生成工具。不仅能用在编译器工具中,而且可以生成其他辅助工具。下面的代码是个统计文件的行数和单词数目的小例子:test.lex:%{int num_lines = 0, num_chars = 0;%}%%\n ++num_lines; ++num_chars;. ++num_chars;%%main(){ yylex(); printf("#of lines = %d, # of chars = %d\n", num_lines,num_chars);}生成c文件:flex -otest.c test.lex编译c文件:gcc -o test 阅读全文

posted @ 2011-02-12 22:57 cornsea 阅读(510) 评论(0) 推荐(0) 编辑

导航