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

📄 pl3.l

📁 简介:PL0语言是pascal语言的一个子集。编译VC工程之前
💻 L
字号:
/*extended: identifier are allowed to use dash;multiple-line coments allowed*/
%{
#include "pl3.tab.h"
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
int	lineno = 1;
char* tname;
%}

%%
"do"		{ return DO; }
"write"		{ return WRITE; }
"read"		{ return READ; }
"procedure"	{ return PROCEDURE; }
"var"		{ return VAR; }
"const"		{ return CONST; }
"call"		{ return CALL; }
"if"		{ return IF; }
"else"		{ return ELSE; }
"then"		{ return THEN; }
"odd"		{ return ODD; }
"begin"		{ return BEGINSYM; }
"end"		{ return ENDSYM; }
"while"		{ return WHILE; }
"repeat"	{ return REPEAT; }
"until"		{ return UNTIL; }
":=" 		{ return COLEQ;}
"<="		{ return LE;}
">=" 		{ return RE;}

[0-9]+					{	yylval.val = atoi(yytext);return NUMBER;}
[a-zA-Z_][a-zA-Z0-9_]*	{	tname = (char*)malloc(strlen(yytext)+1);
							strcpy(tname, yytext);
							yylval.name = tname;return LEGAL_ID;}
[\n]					{	lineno++;}
[ \t]+					{		}
\{[^\}\n]*\}			{		}
.               		{	return yytext[0];}
%%

int yywrap()
{
  return 1;
}

⌨️ 快捷键说明

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