]> git.mdlowis.com Git - projs/onward.git/commitdiff
Added support for compiling literals
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 22 Nov 2014 04:11:01 +0000 (23:11 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 22 Nov 2014 04:11:01 +0000 (23:11 -0500)
source/onward/onward.c

index a040f53701192df08ca9bb534fdc58255670b956..f18bcb0bf07ad8dabce854049f7356c3db0bb634 100755 (executable)
@@ -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();