-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmgllex.l
48 lines (43 loc) · 1.03 KB
/
mgllex.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
%{
#include "mglyac.tab.h"
#include "mglhdr.h"
extern int lineno;
%}
ws [ \t]+
comment #.*
qstring \"[^\"\n]*[\"\n]
id [a-zA-Z][a-zA-Z0-9]*
nl \n
%%
{ws} ;
{comment} ;
{qstring} { yylval.string = strdup(yytext+1); /* skip open quote */
if(yylval.string[yyleng-2] != '"')
warning("Unterminated character string",(char *)0);
else
yylval.string[yyleng-2] = '\0'; /* remove close quote */
return QSTRING;
}
screen { return YSCREEN; }
title { return TITLE; }
item { return ITEM; }
command { return COMMAND; }
action { return ACTION; }
execute { return EXECUTE; }
menu { return MENU; }
quit { return QUIT; }
ignore { return IGNORE; }
attribute { return ATTRIBUTE; }
visible { return VISIBLE; }
invisible { return INVISIBLE; }
end { return END; }
{id} { yylval.string = strdup(yytext);
return ID;
}
{nl} { lineno++; }
. { return yytext[0]; }
%%
int yywrap()
{
return 1;
}