OSDN Git Service

Print true, false, and lists.
authorSimon Forman <sforman@hushmail.com>
Thu, 2 Feb 2023 04:33:04 +0000 (20:33 -0800)
committerSimon Forman <sforman@hushmail.com>
Thu, 2 Feb 2023 04:33:04 +0000 (20:33 -0800)
implementations/C/joy.c

index 8cbcd2f..17f5502 100644 (file)
@@ -161,6 +161,10 @@ text_to_expression(char *text)
        return result;
 }
 
+/* Pre-declare so we can use it in print_node(). */
+void
+print_list(struct list_node* el);
+
 
 void
 print_node(struct JoyType j)
@@ -172,6 +176,17 @@ print_node(struct JoyType j)
         case joySymbol:
                 printf("%s", j.value.symbol);
                 break;
+        case joyTrue:
+                printf("true");
+                break;
+        case joyFalse:
+                printf("false");
+                break;
+        case joyList:
+                printf("[");
+                print_list(j.value.el);
+                printf("]");
+                break;
         default:
                 printf("wtf");
         }