Hi all,
I'd like to be able to compile Nim (or generate from Nim) code in a specialised
C-based DSL. For example I'd like to write something like this in Nim
func_declare test1(arg: DATA): DATA
func_create test2(arg: int): string = do_something(arg)
Run
which would generate a file with
//DSL code
// function declaration for function 'test1' - DATA is a C typedef
DATA func_test1(DATA arg);
// implementing a function 'test2 '- do_something is a C macro
STRING func_test2(INT arg) {
do_something(arg);
}
Run
I've been looking at the [emit
pragma](https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma)
and [Source code filters](https://nim-lang.org/docs/filters.html) in order to
achieve this but I'm not quite sure this is the best way to go. If you have any
suggestions, can point me to the right direction, or to some code that does
something similar, I'd be grateful. Thanks.