From 38e8ce9216539f28147814fba1eca67cc9e67507 Mon Sep 17 00:00:00 2001 From: cozis Date: Thu, 5 May 2022 21:58:38 +0200 Subject: [PATCH] supports hex digits now --- c2html.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/c2html.c b/c2html.c index b8bd96e..6bcb5f7 100644 --- a/c2html.c +++ b/c2html.c @@ -185,16 +185,27 @@ static Token *tokenize(const char *str, long len) T.len = i - T.off; } else if(isdigit(str[i])) { + T.off = i; + + // We allow an 'x' if it's after a '0'. + if(i+2 < len && str[i] == '0' && str[i+1] == 'x' && isdigit(str[i+2])) + i += 2; // Skip the '0x'. + while(i < len && isdigit(str[i])) i += 1; + + // If the next character is a dot followed + // by a digit, then we continue to scan. if(i+1 < len && str[i] == '.' && isdigit(str[i+1])) { i += 1; // Skip the '.'. while(i < len && isdigit(str[i])) i += 1; T.kind = T_VFLT; } else T.kind = T_VINT; + T.len = i - T.off; + } else if(isalpha(str[i]) || str[i] == '_') { T.off = i;