📄 pl3.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 + -