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.
9 /* lex-func-prefix: yy */
18 #include "trafgen_parser.tab.h"
21 extern void yyerror(const char *);
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 "csumip" { return K_CSUMIP; }
46 "csumip4" { return K_CSUMIP; }
47 "csumudp" { return K_CSUMUDP; }
48 "csumtcp" { return K_CSUMTCP; }
49 "drnd" { return K_DRND; }
50 "dinc" { return K_DINC; }
51 "ddec" { return K_DDEC; }
52 "seqinc" { return K_SEQINC; }
53 "seqdec" { return K_SEQDEC; }
64 ([ \t\r\n]+)? { return K_WHITE; }
66 "/*"([^\*]|\*[^/])*"*/" { return K_COMMENT; }
67 "#"[^\n]* { return K_COMMENT; }
69 {number_hex} { yylval.number = strtoul(yytext, NULL, 16);
72 {number_dec} { yylval.number = strtol(yytext, NULL, 10);
75 {number_oct} { yylval.number = strtol(yytext + 1, NULL, 8);
78 {number_bin} { yylval.number = strtol(yytext + 2, NULL, 2);
81 {number_ascii} { yylval.number = (uint8_t) (*yytext);
84 "'"."'" { yylval.number = (uint8_t) (*(yytext + 1));
88 . { printf("Unknown character '%s'", yytext);
89 yyerror("lex Unknown character"); }