mylexer.l

来自「词法分析」· L 代码 · 共 42 行

L
42
字号
%{
/****************************************************************************
exp01.l
ParserWizard generated Lex file.

Date: 2008年5月8日
****************************************************************************/
#include "stdio.h"

%}

/////////////////////////////////////////////////////////////////////////////
// declarations section

// place any declarations here 
// word count
// char count
// line count
 int wcount=0;   
 int ccount=0;    
 int lcount=1;    
%%
[A-Za-z0-9]+ { wcount++; ccount += yyleng; }
\n {lcount++;ccount++;}
. ccount++;

/////////////////////////////////////////////////////////////////////////////
// rules section

// place your Lex rules here

%%

/////////////////////////////////////////////////////////////////////////////
// programs section
int main(void)
{
 yylex();
 printf("in this file , there are : \n %d chars %d words %d lines ",ccount,wcount,lcount);
 return yywrap();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?