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 "fill" { return K_FILL; }
43 "rnd" { return K_RND; }
44 "drnd" { return K_DRND; }
45 "dinc" { return K_DINC; }
46 "ddec" { return K_DDEC; }
47 "seqinc" { return K_SEQINC; }
48 "seqdec" { return K_SEQDEC; }
57 "\n" { yylineno++; return K_NEWL; }
58 [ \t\r]+ { return K_WHITE; }
60 "/*"([^\*]|\*[^/])*"*/" { return K_COMMENT; }
62 {number_hex} { yylval.number = strtoul(yytext, NULL, 16);
65 {number_dec} { yylval.number = strtol(yytext, NULL, 10);
68 {number_oct} { yylval.number = strtol(yytext + 1, NULL, 8);
71 {number_bin} { yylval.number = strtol(yytext + 2, NULL, 2);
74 {number_ascii} { yylval.number = (uint8_t) (*yytext);
77 "'"."'" { yylval.number = (uint8_t) (*(yytext + 1));
82 . { printf("Unknown character '%s'", yytext);
83 yyerror("lex Unknown character"); }