From 04c5e1af8a03cb943acbebcb7460193c8bd37a26 Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 2 Feb 2022 23:05:33 -0500 Subject: fixed cast parsing bug i hope casts weren't at a different precedence level for a reason --- 05/constants.b | 3 +-- 05/main.c | 2 +- 05/parse.b | 6 +----- 3 files changed, 3 insertions(+), 8 deletions(-) (limited to '05') diff --git a/05/constants.b b/05/constants.b index 1ba49fb..3d0e30a 100644 --- a/05/constants.b +++ b/05/constants.b @@ -25,8 +25,7 @@ ; b << >> ; c + - ; d * / % -; d8 cast -; e sizeof, unary prefixes ++ -- & * + - ~ ! +; e casts, sizeof, unary prefixes ++ -- & * + - ~ ! ; f . -> () [] postfix ++ -- ; highest ; NB: for equal precedence, operators are applied left-to-right except for assignment operators (precedence 2) diff --git a/05/main.c b/05/main.c index 008efd1..34be337 100644 --- a/05/main.c +++ b/05/main.c @@ -46,7 +46,7 @@ /* long b; */ /* } x1[] = {0x1234567890, 1ul<<60|1ul<<3, 77}; */ /* int y1 = 0x12345678; */ -typedef int R[*(int*)3]; +typedef int R[sizeof *(int*)"hello"]; /* struct { */ /* int x[2], y; */ diff --git a/05/parse.b b/05/parse.b index 41ee6fd..18dbcb6 100644 --- a/05/parse.b +++ b/05/parse.b @@ -1619,11 +1619,7 @@ function parse_expression *4type = type_create_pointer(*4a) return out :unary_dereference - print_type(*4a) - putc(10) type_decay_array_to_pointer(*4a) - print_type(*4a) - putc(10) ; @TODO : dereferencing a function (annoyingly, p is the same as *p for function pointers) if *1p != TYPE_POINTER goto unary_bad_type *4type = *4a + 1 @@ -2574,7 +2570,7 @@ function operator_precedence token += 16 b = token_is_type(token) if b == 0 goto return_0xffff - goto return_0xd8 ; it's a cast + goto return_0xe0 ; it's a cast :figre_out_rparen_arity ; given that the token before this one is a right-parenthesis, figure out if -- cgit v1.2.3