⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wordcount.l

📁 语法分析 语法分析
💻 L
字号:
%{{*    下面的例子改编自lex和yacc第二版    对单词计数    编译:lex wordcount wordcnt.dpr    用法: wordcnt 或者 wordcnt wordcount.l *} program WordCnt;{$APPTYPE CONSOLE}uses  SysUtils, LexLib;var  CharCount, WordCount, LineCount:integer;%}word [^ \t\n]+eol  \n%%{word}	begin          inc(WordCount);	  inc(CharCount,yyleng); 	end;{eol}	begin          inc(CharCount);	  inc(LineCount);	end;.	inc(CharCount);%%begin  if paramcount >1 then  begin    if not FileExists(ParamStr(1)) then    begin      Writeln('无法打开输入文件');      Halt;    end;    AssignFile(yyinput, ParamStr(1));    reset(yyinput);  end;  yylex;  Writeln(format('字符数:%d 单词数:%d 行数:%d', [CharCount, WordCount, LineCount]));  readln;end.

⌨️ 快捷键说明

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