ch2-09.l
来自「《Lex与Yacc》中文第二版,附带书中的程序」· L 代码 · 共 33 行
L
33 行
%{int comments, code, whiteSpace;%}%s COMMENT%%^[ \t]*"/*" { BEGIN COMMENT; /* enter comment eating state */ }^[ \t]*"/*".*"*/"[ \t]*\n { comments++; /* self-contained comment */ }<COMMENT>"*/"[ \t]*\n { BEGIN 0; comments++;}<COMMENT>"*/" { BEGIN 0; }<COMMENT>\n { comments++; }<COMMENT>.\n { comments++; }^[ \t]*\n { whiteSpace++; }.+"/*".*"*/".*\n { code++; }.*"/*".*"*/".+\n { code++; }.+"/*".*\n { code++; BEGIN COMMENT; }.\n { code++; }. ; /* ignore everything else */%%main(){ yylex(); printf("code: %d, comments %d, white space %d\n", code, comments, whiteSpace);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?