From 29ed62021c9ffc1a13992d0533532f1c1317b026 Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Tue, 27 Jul 2010 16:22:50 -0600 Subject: [PATCH] convert syntax back to honu form --- collects/honu/core/private/canonical.rkt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 collects/honu/core/private/canonical.rkt diff --git a/collects/honu/core/private/canonical.rkt b/collects/honu/core/private/canonical.rkt new file mode 100644 index 0000000000..e06472e6f0 --- /dev/null +++ b/collects/honu/core/private/canonical.rkt @@ -0,0 +1,24 @@ +#lang racket/base + +(provide (all-defined-out)) + +(require "literals.rkt" + (for-template "honu-typed-scheme.rkt") + syntax/parse) + +;; syntax -> string +(define (to-honu-string stx) + (syntax-parse stx + #:literal-sets ([cruft #:at stx]) + #:literals (honu-unparsed-begin) + [(f (#%parens x ...) rest ...) + (format "~a(~a)~a" + (to-honu-string #'f) + (to-honu-string #'(x ...)) + (to-honu-string #'(rest ...)))] + [(x1) (to-honu-string #'x1)] + [(x1 x2 ...) + (format "~a ~a" (to-honu-string #'x1) + (to-honu-string #'(x2 ...)))] + [() ""] + [else (format "~a" (syntax->datum stx))]))