From 44e11303beca15198a2021024f32e1e8c8cf62ab Mon Sep 17 00:00:00 2001 From: pommicket Date: Sat, 29 Jan 2022 11:13:56 -0500 Subject: little corrections --- 05/main.c | 1 + 05/parse.b | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to '05') diff --git a/05/main.c b/05/main.c index e16367b..1c5fb4f 100644 --- a/05/main.c +++ b/05/main.c @@ -38,6 +38,7 @@ typedef struct { int a = -138; double f = 0; +void *p = 0; int j = 3+7<<5, k = 123; /* diff --git a/05/parse.b b/05/parse.b index f44f582..4ab47a8 100644 --- a/05/parse.b +++ b/05/parse.b @@ -271,9 +271,9 @@ function parse_constant_initializer :found_init_end if *1token == SYMBOL_LBRACE goto parse_braced_initializer - + if *1token == TOKEN_STRING_LITERAL goto parse_string_literal_initializer p = types + type - if *1p > TYPE_DOUBLE goto expression_initializer_for_nonscalar_type + if *1p > TYPE_POINTER goto expression_initializer_for_nonscalar_type global 8000 dat_const_initializer expr = &dat_const_initializer @@ -307,13 +307,15 @@ function parse_constant_initializer return - :init_floating_check + :init_floating_check ; also checks pointer types (e.g. don't do static void *x = 1;) if value != 0 goto floating_initializer_other_than_0 goto init_good :parse_braced_initializer byte 0xcc ; @TODO - + :parse_string_literal_initializer + byte 0xcc ; @TODO + :find_init_end_eof token_error(token, .str_find_init_end_eof) :str_find_init_end_eof @@ -332,7 +334,7 @@ function parse_constant_initializer :floating_initializer_other_than_0 token_error(token, .str_floating_initializer_other_than_0) :str_floating_initializer_other_than_0 - string Only 0 is supported as a floating-point initializer. + string Only 0 is supported as a floating-point/pointer initializer. byte 0 ; *p_token should be pointing to a {, this will advance it to point to the matching } function token_skip_to_matching_rbrace -- cgit v1.2.3