diff --git a/implementations/scheme-chicken/joy.scm b/implementations/scheme-chicken/joy.scm index 1709d81..2a79cd3 100644 --- a/implementations/scheme-chicken/joy.scm +++ b/implementations/scheme-chicken/joy.scm @@ -33,6 +33,15 @@ (chicken-script (load "defs.scm")) (else)) + +;██╗███╗ ██╗████████╗███████╗██████╗ ██████╗ ██████╗ ███████╗████████╗███████╗██████╗ +;██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝██╔════╝██╔══██╗ +;██║██╔██╗ ██║ ██║ █████╗ ██████╔╝██████╔╝██████╔╝█████╗ ██║ █████╗ ██████╔╝ +;██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗██╔═══╝ ██╔══██╗██╔══╝ ██║ ██╔══╝ ██╔══██╗ +;██║██║ ╚████║ ██║ ███████╗██║ ██║██║ ██║ ██║███████╗ ██║ ███████╗██║ ██║ +;╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ +;Interpreter + (define (joy stack expression dict) (if (null? expression) (values stack dict) @@ -93,6 +102,14 @@ (values (cons (op (cadr stack) (car stack)) (cddr stack)) expression dict))) +; ██████╗ ██████╗ ███╗ ███╗██████╗ ██╗███╗ ██╗ █████╗ ████████╗ ██████╗ ██████╗ ███████╗ +;██╔════╝██╔═══██╗████╗ ████║██╔══██╗██║████╗ ██║██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗██╔════╝ +;██║ ██║ ██║██╔████╔██║██████╔╝██║██╔██╗ ██║███████║ ██║ ██║ ██║██████╔╝███████╗ +;██║ ██║ ██║██║╚██╔╝██║██╔══██╗██║██║╚██╗██║██╔══██║ ██║ ██║ ██║██╔══██╗╚════██║ +;╚██████╗╚██████╔╝██║ ╚═╝ ██║██████╔╝██║██║ ╚████║██║ ██║ ██║ ╚██████╔╝██║ ██║███████║ +; ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ +;Combinators + (define (joy-i stack expression dict) (values (cdr stack) (append (car stack) expression) dict)) @@ -117,6 +134,14 @@ dict))) +;██████╗ █████╗ ██████╗ ███████╗███████╗██████╗ +;██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔════╝██╔══██╗ +;██████╔╝███████║██████╔╝███████╗█████╗ ██████╔╝ +;██╔═══╝ ██╔══██║██╔══██╗╚════██║██╔══╝ ██╔══██╗ +;██║ ██║ ██║██║ ██║███████║███████╗██║ ██║ +;╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ +;Parser + (define (string-replace str from to) (string-intersperse (string-split str from #t) to)) @@ -162,6 +187,14 @@ (define (text->expression text) (parse (tokenize text))) +;██████╗ ██████╗ ██╗███╗ ██╗████████╗███████╗██████╗ +;██╔══██╗██╔══██╗██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗ +;██████╔╝██████╔╝██║██╔██╗ ██║ ██║ █████╗ ██████╔╝ +;██╔═══╝ ██╔══██╗██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗ +;██║ ██║ ██║██║██║ ╚████║ ██║ ███████╗██║ ██║ +;╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ +;Printer + (define (joy-term->string term) (cond ((boolean? term) (if term "true" "false")) ((number? term) (->string term)) @@ -172,6 +205,14 @@ (string-intersperse (map joy-term->string expr) " ")) +;██████╗ ███████╗███████╗██╗███╗ ██╗██╗████████╗██╗ ██████╗ ███╗ ██╗███████╗ +;██╔══██╗██╔════╝██╔════╝██║████╗ ██║██║╚══██╔══╝██║██╔═══██╗████╗ ██║██╔════╝ +;██║ ██║█████╗ █████╗ ██║██╔██╗ ██║██║ ██║ ██║██║ ██║██╔██╗ ██║███████╗ +;██║ ██║██╔══╝ ██╔══╝ ██║██║╚██╗██║██║ ██║ ██║██║ ██║██║╚██╗██║╚════██║ +;██████╔╝███████╗██║ ██║██║ ╚████║██║ ██║ ██║╚██████╔╝██║ ╚████║███████║ +;╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ +;Definitions + (define (initialize) (load-defs (make-hash-table string=? string-hash))) @@ -184,6 +225,14 @@ (hash-table-set! dict (car def_list) (cdr def_list)))) +;██████╗ ███████╗██████╗ ██╗ +;██╔══██╗██╔════╝██╔══██╗██║ +;██████╔╝█████╗ ██████╔╝██║ +;██╔══██╗██╔══╝ ██╔═══╝ ██║ +;██║ ██║███████╗██║ ███████╗ +;╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝ +;REPL + (define (prompt) (display "joy? ") (read-line)) (define DICTIONARY (initialize))