From: Michael D. Lowis Date: Sat, 22 Nov 2014 04:11:01 +0000 (-0500) Subject: Added support for compiling literals X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=38779b29f3ea58311de7c2dc05489703c68668e1;p=projs%2Fonward.git Added support for compiling literals --- diff --git a/source/onward/onward.c b/source/onward/onward.c index a040f53..f18bcb0 100755 --- a/source/onward/onward.c +++ b/source/onward/onward.c @@ -252,8 +252,16 @@ defcode("interp", interp, &zbr, 0u) { if (strlen((char*)onward_aspeek(0)) > 0) { /* Try to parse it as a number */ num_code(); - /* If it's not a number */ - if (!onward_aspop()) { + /* If it's a number */ + if (onward_aspop()) { + /* If we're compiling, then append the number to the word */ + if (state == 1) { + onward_aspush(&lit); + comma_code(); + comma_code(); + } + /* otherwise, look it up */ + } else { /* Lookup the word in the dictionary */ find_code(); /* If we found a definition execute it */ @@ -268,6 +276,7 @@ defcode("interp", interp, &zbr, 0u) { { comma_code(); } + /* Report an error */ } else { errno = ERR_UNKNOWN_WORD; (void)onward_aspop();