summaryrefslogtreecommitdiffstats
path: root/src/lex.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-01-26 02:21:57 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-01-26 02:21:57 +0100
commitcc498848b36b347aa9b710ab55c1fcc8643a4633 (patch)
tree316675cd0ab0aae180b2e8313ef621acb6c8c0c5 /src/lex.c
parent17019f0db3c0def60f50de62693c507c624e67a8 (diff)
downloadfastd-cc498848b36b347aa9b710ab55c1fcc8643a4633.tar
fastd-cc498848b36b347aa9b710ab55c1fcc8643a4633.zip
lex: add support for octal and hexadecimal integer literals
Diffstat (limited to 'src/lex.c')
-rw-r--r--src/lex.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lex.c b/src/lex.c
index 9fbab9e..b22bf40 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -318,21 +318,27 @@ static int parse_ipv4_address(YYSTYPE *yylval, YYLTYPE *yylloc, fastd_lex_t *lex
}
static int parse_number(YYSTYPE *yylval, YYLTYPE *yylloc, fastd_lex_t *lex) {
+ bool digitonly = true;
+
if (lex->needspace)
return syntax_error(yylval, lex);
while (next(yylloc, lex, false)) {
char cur = current(lex);
- if (cur == '.')
+ if (cur == '.' && digitonly)
return parse_ipv4_address(yylval, yylloc, lex);
- if (!(cur >= '0' && cur <= '9'))
- break;
+ if (!(cur >= '0' && cur <= '9')) {
+ if ((cur >= 'a' && cur <= 'z') || (cur >= 'A' && cur <= 'Z'))
+ digitonly = false;
+ else
+ break;
+ }
}
char *endptr, *token = get_token(lex);
- yylval->uint64 = strtoull(token, &endptr, 10);
+ yylval->uint64 = strtoull(token, &endptr, 0);
bool ok = !*endptr;
free(token);