blob: 2a4ffb28da721b3b495019c6d8969268f9e06214 (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
%top {
#include "grammar.h"
}
%option noyywrap
%option nounput
%option noinput
%option yylineno
%option stack
%option noyy_top_state
%x binval
%x hexval
%%
%{
/* Choix d'un des démarrages multiples */
if (*init_token != ALLOW_ALL)
{
unsigned int first;
first = *init_token;
*init_token = ALLOW_ALL;
return first;
}
%}
[A-Za-z_][A-Za-z0-9_]* {
if (strcmp(yytext, "NOT") == 0) return NOT;
else if (strcmp(yytext, "AND") == 0) return AND_LOG;
else if (strcmp(yytext, "EOR") == 0) return EOR;
else
{
yylvalp->string = strdup(yytext);
return NAME;
}
}
[0-9][0-9]* { yylvalp->integer = atoi(yytext); return NUMBER; }
"'" { yy_push_state(binval); }
<binval>[01][01]* { yylvalp->string = strdup(yytext); return BINVAL; }
<binval>"'" { yy_pop_state(); }
\"[^\"]*\" { yylvalp->string = strndup(yytext + 1, strlen(yytext) - 2); printf("str = '%s'\n", yylvalp->string); return STRING; }
"0x" { yy_push_state(hexval); }
<hexval>[0-9a-f][0-9a-f]* { yylvalp->string = strdup(yytext); yy_pop_state(); return HEXVAL; }
"," { return COMMA; }
":" { return COLON; }
"&" { return AND_LOG; }
"==" { return EQ; }
"!=" { return NE; }
"&&" { return AND_BOOL; }
"||" { return OR_BOOL; }
"(" { yy_push_state(INITIAL); return OP; }
")" { yy_pop_state(); return CP; }
[ ]+ { }
%%
|