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

📄 lexer.l

📁 YYCC语言编译器
💻 L
字号:
%{
/************************************************************
lexer.l
Lexical analyser for the multiple instance example. Note
that the lexical analyser now recognises illegal characters
on the input stream.
************************************************************/

/* multiple instance lex conversion file */
#include "milconv.h"
%}

%name calc_lexer		// give the lexical analyser a name

digit	[0-9]
exp		((e|E)("+"|"-")?{digit}+)

%%
%{
/*
This code goes at the top of our action routine. It allows
us to easily extract yylval for use later on in any
actions.
*/
YYSTYPE *yymlvalptr = (YYSTYPE *) yy->yymdata;
yyassert(yymlvalptr != NULL);
#define yylval (*yymlvalptr)
%}

{digit}+"."{digit}*{exp}?	|
"."{digit}+{exp}?			|
{digit}+{exp}?				{ sscanf(yytext, "%lf", &yylval); return NUMBER; }

"\n"						{ return '\n'; }
"+"							{ return '+'; }
"-"							{ return '-'; }
"*"							{ return '*'; }
"/"							{ return '/'; }
"("							{ return '('; }
")"							{ return ')'; }

.							{ printf("invalid character\n"); }

⌨️ 快捷键说明

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