From 38779b29f3ea58311de7c2dc05489703c68668e1 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 21 Nov 2014 23:11:01 -0500 Subject: [PATCH] Added support for compiling literals --- source/onward/onward.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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(); -- 2.54.0