src: setfsuid / setfsgid
[netsniff-ng.git] / src / trafgen_lexer.l
blobb5a452999b4d7c44c62836c1594d28c96e30b19e
1 /*
2  * netsniff-ng - the packet sniffing beast
3  * By Daniel Borkmann <daniel@netsniff-ng.org>
4  * Copyright 2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5  * Swiss federal institute of technology (ETH Zurich)
6  * Subject to the GPL, version 2.
7  */
9 /* lex-func-prefix: yy */
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <ctype.h>
18 #include "trafgen_parser.tab.h"
19 #include "xmalloc.h"
21 extern void yyerror(const char *);
25 %option align
26 %option nounput
27 %option noyywrap
28 %option noreject
29 %option 8bit
30 %option caseless
31 %option noinput
32 %option nodefault
34 number_oct      ([0][0-9]+)
35 number_hex      ([0][x][a-fA-F0-9]+)
36 number_bin      ([0][b][0-1]+)
37 number_dec      (([0])|([-+]?[1-9][0-9]*))
38 number_ascii    ([a-zA-Z])
42 "cpu"           { return K_CPU; }
43 "fill"          { return K_FILL; }
44 "rnd"           { return K_RND; }
45 "drnd"          { return K_DRND; }
46 "dinc"          { return K_DINC; }
47 "ddec"          { return K_DDEC; }
48 "seqinc"        { return K_SEQINC; }
49 "seqdec"        { return K_SEQDEC; }
51 "{"             { return '{'; }
52 "}"             { return '}'; }
53 "("             { return '('; }
54 ")"             { return ')'; }
55 "["             { return '['; }
56 "]"             { return ']'; }
57 ","             { return ','; }
58 ":"             { return ':'; }
59 "\n"            { yylineno++; }
60 ([ \t\r\n]+)?   { return K_WHITE; }
62 "/*"([^\*]|\*[^/])*"*/" { return K_COMMENT; }
64 {number_hex}    { yylval.number = strtoul(yytext, NULL, 16);
65                   return number; }
67 {number_dec}    { yylval.number = strtol(yytext, NULL, 10);
68                   return number; }
70 {number_oct}    { yylval.number = strtol(yytext + 1, NULL, 8);
71                   return number; }
73 {number_bin}    { yylval.number = strtol(yytext + 2, NULL, 2);
74                   return number; }
76 {number_ascii}  { yylval.number = (uint8_t) (*yytext);
77                   return number; }
79 "'"."'"         { yylval.number = (uint8_t) (*(yytext + 1));
80                   return number; }
82 ";"[^\n]*       {/* NOP */}
83 "#"[^\n]*       {/* NOP */}
84 .               { printf("Unknown character '%s'", yytext);
85                   yyerror("lex Unknown character"); }