Metaprogramming/code generation inside a function

Not sure if that’s what you want or if it’s the recommended way to do it, but have you tried looking into @eval?

(also, if you are writing a parser for Quantum Espresso input files, please put the code online somewhere! :-))