From 9f9930e774039c5487a9236a25d9dabd5df39355 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 15 Nov 2019 19:11:32 +0100 Subject: scanner: Introduce numberstring This token combines decstring and hexstring. The latter two had identical action blocks (which were not completely trivial), this allows to merge them. Signed-off-by: Phil Sutter Acked-by: Pablo Neira Ayuso --- src/scanner.l | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/scanner.l') diff --git a/src/scanner.l b/src/scanner.l index 3de5a9e0..80b5a5f0 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -116,6 +116,7 @@ digit [0-9] hexdigit [0-9a-fA-F] decstring {digit}+ hexstring 0[xX]{hexdigit}+ +numberstring ({decstring}|{hexstring}) letter [a-zA-Z] string ({letter}|[_.])({letter}|{digit}|[/\-_\.])* quotedstring \"[^"]*\" @@ -608,17 +609,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) return STRING; } -{decstring} { - errno = 0; - yylval->val = strtoull(yytext, NULL, 0); - if (errno != 0) { - yylval->string = xstrdup(yytext); - return STRING; - } - return NUM; - } - -{hexstring} { +{numberstring} { errno = 0; yylval->val = strtoull(yytext, NULL, 0); if (errno != 0) { -- cgit v1.2.3