summaryrefslogtreecommitdiffstats
path: root/lib/route/pktloc_grammar.l
blob: f710430431ecf76d436988f0f58ac098577a3b5c (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
%{
 #include <netlink-local.h>
 #include <netlink-tc.h>
 #include <netlink/netlink.h>
 #include <netlink/utils.h>
 #include <netlink/route/pktloc.h>
 #include "pktloc_syntax.h"
%}

%option 8bit
%option reentrant
%option warn
%option noyywrap
%option nounput
%option bison-bridge
%option bison-locations
%option prefix="pktloc_"

%%

[ \t\r\n]+

"#".*

[[:digit:]]+		|
0[xX][[:xdigit:]]+	{
				yylval->i = strtoul(yytext, NULL, 0);
				return NUMBER;
			}

"+"			{ return yylval->i = yytext[0]; }

[lL][iI][nN][kK]	{ yylval->i = TCF_LAYER_LINK; return LAYER; }
[nN][eE][tT]		{ yylval->i = TCF_LAYER_NETWORK; return LAYER; }
[tT][cC][pP]		{ yylval->i = TCF_LAYER_TRANSPORT; return LAYER; }

[^ \t\r\n+]+		{
				yylval->s = strdup(yytext);
				if (yylval->s == NULL)
					return ERROR;
				return NAME;
			}