logological / gpp

GPP, a generic preprocessor
https://logological.org/gpp
GNU Lesser General Public License v3.0
197 stars 31 forks source link

Unclear how to use gpp with different user-macro syntax but same meta-macro syntax #23

Open jkm opened 6 years ago

jkm commented 6 years ago

I'd like to use gpp for preprocessing text files. There are different formats of these files and I want to support each different format by expressing the macro call as a comment. This way the macro is ignored when not preprocessed. For example consider I have a format where {::something/} is ignored. I call using -U "{::" "/}" "\B" " " "}" "{" "}" "#" "\\". Then there are other files with a different format, say %something. Again I can define appropriate strings using -U. Being able to define the call syntax is probably the most interesting feature to me. Note I only want to change the call syntax. The definition of the macros should use some fixed (probably the default) syntax. But I cannot make it work:

$ echo "{::macroname/}" | gpp --include macros.gpp -U "{::" "/}" "\B" " " "}" "{" "}" "#" "\\"

where macros.gpp is

#define macroname bar

The output is

#define macroname bar
{::macroname/}

(seems like no macro was applied) when I expected

bar

When I change macros.gpp to {::define macroname bar} I'll get almost (note the additional new line) what I want


bar

But I don't want to provide the macros in each call syntax. Apparently I am doing it wrong or it cannot be done using gpp. Any suggestions? This is GPP 2.25 on Linux.

logological commented 6 years ago

After some preliminary investigation, I suspect this is a bug—for some reason the user-defined mode is not being applied to the argument of --include. I will look into this when I have time.