spike for scheme->javascript syntax transformation (subset)

more debug info in process-file
This commit is contained in:
2026-04-12 16:51:24 +02:00
parent 1ca6e4e083
commit 41dd0adb27
2 changed files with 70 additions and 0 deletions

69
private/js-transform.rkt Normal file
View File

@@ -0,0 +1,69 @@
#lang racket/base
(define-syntax js-let
(syntax-rules ()
((_ (a b))
(string-append "let " (js1 a) " = " (js1 b) ";\n")
)
)
)
(define-syntax js1
(syntax-rules (if let* *)
((_ (if cond body1 body2))
(string-append "if (" (js1 cond) ") then {\n"
(js1 body1) "; }\n"
"else {\n"
(js1 body2)
"; }\n"
)
)
((_ (let (a ...)))
(string-append
(js-let a)
...)
)
((_ a)
(format "~a" 'a))
)
)
#|
((_ (if cond
body1
body2))
(string-append "if ("
(js1 cond) ") then {\n"
(js1 body1) " }\n"
"else { \n"
(js1 body2)
" }\n"
)
)
((_ (let ((a b) ...)
body))
(string-append "let " (js1 a)
" = " (js1 b) ";\n")
...
)
((_ (* a b ...))
(string-append (js1 a) "*" (js1 b) ...))
((_ a)
(format "~a" 'a))
)
)
|#
(define-syntax js
(syntax-rules ()
((_ js-statement ...)
(string-append
"{ \n"
(js1 js-statement)
...
"}\n"
)
)
)
)

View File

@@ -196,6 +196,7 @@
(display html* out))))
(define (process-file context ext path out)
(dbg-webview "process-file: ext = ~a, path = ~a" ext path)
(let ((content (file->bytes path)))
(dbg-webview "path = ~a, number of bytes read: ~a" path (bytes-length content))
(display content out)))