Hi,

I'd like to expand to typed/racket syntax from my custom language (which 
for now contains only 0 and 1).
Ultimately, I am trying to compile programs from the J language, which 
cannot be parsed and has no BNF.
J parsing and execution is interleaved, and I am trying to circumvent that 
by specializing a J interpreter through types at compile time (using 
Futamura projections).

If I build a trivial language as such:

reader.rkt
#lang racket
(provide read-syntax)
(define (read-syntax _ port)
  (define module-datum `(module j-mod "expander.rkt" (1)))
  (datum->syntax #f module-datum))

expander.rkt
#lang racket
(provide (rename-out [module-begin/j #%module-begin])
         #%app
         #%datum
         #%top)
(define-syntax (module-begin/j stx)
  (syntax-case stx ()
    [(_ a) #`(#%module-begin 2)]))

test.rkt
#lang reader "reader.rkt"

I get the correct value "2" (a value not defined in my language) from 
test.rkt, proving that the test works.

Now if I change my expander to:
#lang type-expander
(provide (rename-out [module-begin/j #%module-begin])
         #%app
         #%datum
         #%top)
(define-syntax (module-begin/j stx)
  (syntax-case stx ()
    [(_ a) #`(#%module-begin 2)]))

I get the error "module: expansion of #%module-begin is not a 
#%plain-module-begin form in: (begin (#%module-begin (1)))". Using #lang 
typed/racket yields the exact same error, suggesting the problem does not 
lie in the type-expander lib.
Is there a way to achieve expansion to typed/racket from my custom 
language, please?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to