If you accept the preprocessing being accomplished by an external
tool, instead of being executed by your parser itself, I can propose
you a simple solution.

I suppose that you recognize C-like comments. It could be a inline
format too (but as you are applying a RR scan, it can't be something
like // ... \n), however my solution is more readable with multi-line
comments.

CodeWorker is a universal parsing tool (don't care here) and a
versatile source code generator. It knows various techniques in source
code generation. I call one of them "auto-expansion". It consists of
detecting markups like '##markup##"a constant string"' embedded
between comments, in any kind of text file, and executing the script
located between '##script##' tags just below.