mylexer.l
来自「自动生成工具lex yacc构造的小计算器」· L 代码 · 共 42 行
L
42 行
%{
/****************************************************************************
mylexer.l
ParserWizard generated Lex file.
Date: 2007年12月5日
****************************************************************************/
#include "string.h"
#include "myparser.h"
#include "ctype.h"
#include "mylexer.h"
extern int yylval;
%}
/////////////////////////////////////////////////////////////////////////////
// declarations section
// place any declarations here
%%
/////////////////////////////////////////////////////////////////////////////
// rules section
[0-9]+ { int i = 0;yylval = 0; while (yytext[i]) {yylval = yylval * 10 + yytext[i] - '0'; i++; } return(NUMBER);}
"+" {return PLUS;}
"-" { return MINUS; }
"*" { return TIMES; }
"(" { return LEFT; }
")" { return RIGHT; }
"." {return 0;}
// place your Lex rules here
%%
/////////////////////////////////////////////////////////////////////////////
// programs section
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?