From 335574dd6d784f7c8140fe648572298c3a8bd0c4 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 5 Oct 2024 09:56:52 +0000 Subject: [PATCH] updated some error messages --- lib/comp.c | 17 ++++++++++++++--- t/feed-5001.err | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/comp.c b/lib/comp.c index 0bda111..03d2d8e 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -3656,7 +3656,11 @@ static int compile_set (hcl_t* hcl, hcl_cnode_t* src) obj = HCL_CNODE_CONS_CDR(obj); if (!obj) { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(src), HCL_NULL, "no value specified in %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); + hcl_setsynerrbfmt ( + hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(var), HCL_NULL, + "no value after '%.*js' for '%.*js'", + HCL_CNODE_GET_TOKLEN(var), HCL_CNODE_GET_TOKPTR(var), + HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); return -1; } else if (!HCL_CNODE_IS_CONS(obj)) @@ -3748,7 +3752,11 @@ static int compile_set_r (hcl_t* hcl, hcl_cnode_t* src) if (!obj) { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(src), HCL_NULL, "no value specified in %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); + hcl_setsynerrbfmt ( + hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(var), HCL_NULL, + "no value after '%.*js' for '%.*js'", + HCL_CNODE_GET_TOKLEN(var), HCL_CNODE_GET_TOKPTR(var), + HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); return -1; } else if (!HCL_CNODE_IS_CONS(obj)) @@ -4079,7 +4087,10 @@ static int compile_throw (hcl_t* hcl, hcl_cnode_t* src) /* TODO: should i allow (throw)? does it return the last value on the stack? */ /* no value */ hcl_cnode_t* tmp = HCL_CNODE_CONS_CAR(src); - hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(src), HCL_NULL, "no value specified in %.*js", HCL_CNODE_GET_TOKLEN(tmp), HCL_CNODE_GET_TOKPTR(tmp)); + hcl_setsynerrbfmt ( + hcl, HCL_SYNERR_ARGCOUNT, HCL_CNODE_GET_LOC(src), HCL_NULL, + "no value or expression after '%.*js'", + HCL_CNODE_GET_TOKLEN(tmp), HCL_CNODE_GET_TOKPTR(tmp)); return -1; } else if (!HCL_CNODE_IS_CONS(obj)) diff --git a/t/feed-5001.err b/t/feed-5001.err index 0ad782f..54e6bc5 100644 --- a/t/feed-5001.err +++ b/t/feed-5001.err @@ -186,3 +186,7 @@ abc.? := 20 ##ERROR: syntax error - '?' prohibited as first character of identif --- 1 \ 2 ##ERROR: syntax error - stray backslash + +--- + +throw ##ERROR: syntax error - no value or expression after 'throw'