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 *);
42 number_dec {digit_n}|{digit_s}{digit}*
43 number_oct {digit_n}{digit}+
44 number_hex {digit_n}{hex_x}{hex}+
45 number_bin {digit_n}{bindigit_b}{bindigit}+
50 "fill" { return K_FILL; }
51 "rnd" { return K_RND; }
52 "drnd" { return K_DRND; }
53 "dinc" { return K_DINC; }
54 "ddec" { return K_DDEC; }
55 "seqinc" { return K_SEQINC; }
56 "seqdec" { return K_SEQDEC; }
65 "\n" { yylineno++; return K_NEWL; }
66 [ \t\r]+ { return K_WHITE; }
68 "/*"([^\*]|\*[^/])*"*/" { return K_COMMENT; }
70 {number_hex} { yylval.number = strtoul(yytext, NULL, 16);
73 {number_dec} { yylval.number = strtol(yytext, NULL, 10);
76 {number_oct} { yylval.number = strtol(yytext, NULL, 8);
79 {number_bin} { yylval.number = strtol(yytext + 2, NULL, 2);
82 {number_ascii} { yylval.number = (uint8_t) (*yytext);
83 return number_ascii; }
85 "'"."'" { yylval.number = (uint8_t) (*(yytext + 1));
86 return number_ascii; }
90 . { printf("Unknown character '%s'", yytext);
91 yyerror("lex Unknown character"); }