I would like to combine different macros for example this pattern:
#[flags(-a,-b)]
fun!(...)
i would like to pass the flags to the fun macro to influence the way how the code passed to fun is treated.
in my understanding for the flags macro fun! is just an item in its tokenstream
and the tokenstream describing the passed flags is not visible to the fun macro.
how to complex crates like serde etc deal with this problem?
This is not normally done by using multiple macros. Instead, the macro (which must come first, not second) searches the syntax it is given for other attributes it is expecting and interprets them.
In the case of an attribute macro, the macro must also remove those attributes, as otherwise they would be an error. In the case of derive macros (such as serde's macros) which can't change anything, only add new things, you have to declare helper attributes.
It would be possible to get the syntax you are asking for by making flags an attribute macro which rewrites fun!() calls it is given, but that would be a very unusual thing to do.
I think I need a fun macro because I want to translate a dsl to rust.
If I understand it correctly I cannot use derive or attribute macros to translate code.