Skip to content

Commit 562dcbd

Browse files
committed
Implement parsing of numeric constants
1 parent 4f6e288 commit 562dcbd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

parse.c

+10
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,17 @@ struct Token token_get(char *code, char **next) {
234234
// Number
235235
token.type = TOK_NUMBER;
236236
token.data = code;
237+
238+
// Include the fractional part if present
239+
if (code[length] == '.') length += scan_string(code + length + 1, char_is_num) + 1;
240+
237241
token.data_len = length;
242+
243+
// Parse the number
244+
char boundary_char = code[length];
245+
code[length] = '\0';
246+
token.number = strtod(code, NULL);
247+
code[length] = boundary_char;
238248
} else if (chrcmp(*code, CHRSET_QUOTE, sizeof CHRSET_QUOTE)) {
239249
// String
240250
token.type = TOK_STRING;

0 commit comments

Comments
 (0)