diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-03-25 20:21:15 +0100 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-03-25 20:21:15 +0100 |
commit | f9591eebe40c9d898483c83c6d4d23d553ec43fc (patch) | |
tree | 250a0d19c678bd9fed9c09402673a6102dde36c9 | |
parent | 08c2dc1fcb403519a86a1129ad27c3188294e18f (diff) |
trafgen: lexer/parser: fix cpu() selection and whitespacing
It looks unintuitive when once needs to write cpu(0:3), so also allow
cpu(0-3). Then it's quite stupid to enforce whitespace after the double
colon before the curley braces open. So make this rather optional here.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r-- | trafgen_lexer.l | 4 | ||||
-rw-r--r-- | trafgen_parser.y | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l index 72bd56c..be6917f 100644 --- a/trafgen_lexer.l +++ b/trafgen_lexer.l @@ -72,7 +72,7 @@ static char *try_convert_shellcode(char *sstr) number_oct ([0][0-9]+) number_hex ([0][x][a-fA-F0-9]+) number_bin ([0][b][0-1]+) -number_dec (([0])|([-+]?[1-9][0-9]*)) +number_dec (([0])|([1-9][0-9]*)) number_ascii ([a-zA-Z]) %% @@ -120,7 +120,7 @@ number_ascii ([a-zA-Z]) "\""[^\"]+"\"" { yylval.str = try_convert_shellcode(xstrdup(yytext)); return string; } -([ \t\r\n]+)? { return K_WHITE; } +([ \t\n]+)? { return K_WHITE; } "/*"([^\*]|\*[^/])*"*/" { return K_COMMENT; } diff --git a/trafgen_parser.y b/trafgen_parser.y index 9d2dd09..b0e7e33 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -344,12 +344,22 @@ inline_comment : K_COMMENT { } ; +cpu_delim + : ':' { } + | '-' { } + ; + +noenforce_white + : { } + | K_WHITE { } + ; + packet : '{' delimiter payload delimiter '}' { min_cpu = max_cpu = -1; realloc_packet(); } - | K_CPU '(' number ':' number ')' ':' K_WHITE '{' delimiter payload delimiter '}' { + | K_CPU '(' number cpu_delim number ')' ':' noenforce_white '{' delimiter payload delimiter '}' { min_cpu = $3; max_cpu = $5; @@ -362,7 +372,7 @@ packet realloc_packet(); } - | K_CPU '(' number ')' ':' K_WHITE '{' delimiter payload delimiter '}' { + | K_CPU '(' number ')' ':' noenforce_white '{' delimiter payload delimiter '}' { min_cpu = max_cpu = $3; realloc_packet(); } |