I’m looking to render a bunch of Rust code out from a Racket program, is there a text templating tool that works well for this?
So your Racket program emits Rust?
yes, it will
in the past, I’ve used Antlr + Stringtemplate
(for JVM languages)
In the past I have had success with emitting in two stages. First make a tree of strings, symbols (and possibly numbers). Second emit all the leaves of the tree to the output port.
The idea is that , say, (list line1 line2 ...)
is cheaper than (string-append line1 line2)
.
There are a few template related packages: https://docs.racket-lang.org/dali/index.html
thank you!
I suspected that I might not need a templating tool in Racket
but I suppose I’ll find out when I get there
FWIW here is an emitter I wrote to emit JavaScript. https://github.com/soegaard/urlang/blob/master/urlang/main.rkt#L2342
oh, excellent
I’ll dig into that
Change the link to the correct line.
Sometimes the #lang at-exp
is useful for that sort of thing too. If there are long stretches of text.
+1
@~a{some rust code here @|a-racket-identifier|} @~a{some rust code here @(a-racket-function-call-here)}
interested, haven’t seen that before