-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexer.l
44 lines (34 loc) · 1 KB
/
lexer.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
%{
#include <string.h>
#include "lexglobal.h"
#include "grammar.h"
%}
%%
"likes:" { yysval.sval = (char*)yytext;return LIKES; }
"hates:" { yysval.sval = (char*)yytext;return HATES; }
"from:" { yysval.sval = (char*)yytext;return FROM; }
"moods:" { yysval.sval = (char*)yytext;return MOODS; }
"info:" { yysval.sval = (char*)yytext;return INFO; }
[A-Za-z0-9]* {
yysval.sval = (char*)yytext;
return VALUE;
}
L?\"(\\.|[^\\"])*\" {
yysval.sval = (char*)yytext;
return VALUE;
}
%%
/**
* yyerror() is invoked when the lexer or the parser encounter
* an error. The error message is passed via *s
*
*
*/
void yyerror(char *s)
{
printf("error: %s",s);
}
int yywrap(void)
{
return 1;
}