Closed t0mpr1c3 closed 1 year ago
There isn't really a documented way to do this (because sweet-exp
is intended to be used as a language, rather than a parsing utility or library), but it's possible by using some of the internal modules. For example:
#lang racket/base
(require (submod sweet-exp/main link-reader))
(define-values (read* read-syntax*)
(sweet-link read read-syntax)) ;; parameterize this with the underlying `read` that you want to use
(read* (open-input-file "sweet.rkt"))
The reason why your example didn't work is because the read
binding of the underlying language is not overridden by sweet-exp
, because the language mixin essentially only changes the surface syntax.
Just like at-expressions have scribble/reader
, we could add a module sweet-exp/reader
that provided those read
and read-syntax
functions.
Though I would name them sweet-read
and sweet-read-syntax
to avoid naming collisions.
Asumu, that works perfectly, thanks.
I would like to
read
a sweetened source file like so:I'm fairly new to Racket, so I am not sure why that doesn't work or how to get it to work.
A workaround would be to use the
unsweeten
utility -- do you know of a Racket port of this?