metadave
2019-9-23 15:45:28

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?


soegaard2
2019-9-23 15:46:24

So your Racket program emits Rust?


metadave
2019-9-23 15:46:39

yes, it will


metadave
2019-9-23 15:47:00

in the past, I’ve used Antlr + Stringtemplate


metadave
2019-9-23 15:47:04

(for JVM languages)


soegaard2
2019-9-23 15:49:32

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.


soegaard2
2019-9-23 15:50:28

The idea is that , say, (list line1 line2 ...) is cheaper than (string-append line1 line2).


soegaard2
2019-9-23 15:52:06

There are a few template related packages: https://docs.racket-lang.org/dali/index.html



metadave
2019-9-23 15:53:31

thank you!


metadave
2019-9-23 15:53:39

I suspected that I might not need a templating tool in Racket


metadave
2019-9-23 15:53:44

but I suppose I’ll find out when I get there


soegaard2
2019-9-23 15:54:08

FWIW here is an emitter I wrote to emit JavaScript. https://github.com/soegaard/urlang/blob/master/urlang/main.rkt#L2342


metadave
2019-9-23 15:54:27

oh, excellent


metadave
2019-9-23 15:54:32

I’ll dig into that


soegaard2
2019-9-23 15:55:26

Change the link to the correct line.


samdphillips
2019-9-23 16:17:27

Sometimes the #lang at-exp is useful for that sort of thing too. If there are long stretches of text.


soegaard2
2019-9-23 16:17:40

+1


soegaard2
2019-9-23 16:18:50

@~a{some rust code here @|a-racket-identifier|} @~a{some rust code here @(a-racket-function-call-here)}


metadave
2019-9-23 17:40:04

interested, haven’t seen that before


soegaard2
2019-9-23 17:41:22