-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpl.l
49 lines (49 loc) · 1.19 KB
/
mpl.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
%{
/* definitions part */
#include "y.tab.h" // generated by yacc and defines tokens
#include <stdlib.h>
#include <string.h>
void extern yyerror(char*);
%}
%option case-insensitive
digit [0-9]
whitespace [ \t\r\f\v]+
newline \n
sign [+-]
%%
"end" {return END;}
">=" {return GE;}
"<=" {return LE;}
"alpha" {return ALPHA;}
"number" {return NUMBER;}
"real" {return REAL;}
"is" {return IS;}
"isnt" {return ISNT;}
"and" {return AND;}
"or" {return OR;}
"not" {return NOT;}
"until" {return UNTIL;}
"do" {return DO;}
"end loop" {return END_LOOP;}
"if" {return IF;}
"then" {return THEN;}
"default" {return DEFAULT;}
":" |
"-" |
"+" |
"*" |
"/" |
"," |
")" |
"(" |
">" |
"<" {return yytext[0];}
[a-z][_a-z]* {return IDENTIFIER;}
{sign}?{digit}+ {return NUMBERVAL;}
\'[a-z]\' {return ALPHAVAL;}
{sign}?{digit}*\.?{digit}+ {return REALVAL;}
{newline} {yylineno++;}
{whitespace} ;
. {yyerror("invalid token");}
%%
int yywrap(void){return 1;}