summaryrefslogtreecommitdiffstats
path: root/lib/route/pktloc_grammar.l
diff options
context:
space:
mode:
Diffstat (limited to 'lib/route/pktloc_grammar.l')
-rw-r--r--lib/route/pktloc_grammar.l42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/route/pktloc_grammar.l b/lib/route/pktloc_grammar.l
new file mode 100644
index 0000000..f710430
--- /dev/null
+++ b/lib/route/pktloc_grammar.l
@@ -0,0 +1,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;
+ }