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

📄 lexer.l

📁 学习lemon语法分析的windows程序
💻 L
字号:
%{#include "lexglobal.h" #include "example5.h"#include <string.h>#include <math.h>int line = 1, col = 1;%}%%[0-9]+|[0-9]*\.[0-9]+    {                      col += (int) strlen(yytext);                                                 yylval.dval = atof(yytext);                                                 return NUM; }[ \t]   { col += (int) strlen(yytext); }               /* ignore but count white space */[A-Za-z][A-Za-z0-9]*                           { /* ignore but needed for variables */                                                return 0;                                               }"+"           {  return PLUS; }"-"           {  return MINUS; }"*"           {  return TIMES; }"/"           {  return DIVIDE; }\n      { col = 0; ++line; return NEWLINE; }.       { col += (int) strlen(yytext); return yytext[0]; }%%/** * reset the line and column count * * */void reset_lexer(void){  line = 1;  col  = 1;}/** * yyerror() is invoked when the lexer or the parser encounter * an error. The error message is passed via *s * * */void yyerror(char *s){  printf("error: %s at line: %d col: %d\n",s,line,col);}int yywrap(void){  return 1;}

⌨️ 快捷键说明

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