c ++ – Generate code without specification

I have to work with software written in C ++ for which a Lua link exists.
I mean by that I can write a Lua script file that will use the
corresponding C ++ implementation. The Lua file must have some
structure / program flow is valid, but there is no specification
available for these script files – some examples only explain how to write
a valid script.

My task is to create valid Lua script files from C ++. I think I should first add a specification for the Lua script program structure / flow to facilitate code generation? Or would it be the wrong way to tackle the problem? Would it be better to specify a DSL?

Sincere friendships.