Rust macro designator to capture arbitary line with given splitting punctuation

Considering that the content feeding to macro is non-Rust syntax text like:

hello!(
hello world 1000, 500 to 5000, 1000;
good 100032:5352, 312313 - 24;
good morning ...;
)

There is many lines in side the bracket. And for each line, the only thing guarantee in-common is that at the ending of each line, there is only single ;. And there is no ; in other position in each line.

I am wondering what designator is used to capture arbitary string. and repeat for a given punctuation.

what are you trying to achieve?

in theory, as long the macro argument contains only valid rust tokens (but without unbalanced parenthesis/brace/bracket pairs), you can do very complicated things using the "incremental tt muncher" technique, but even if it can be done, it doesn't mean you should always do it.

at the end of day, the macro has to emit valid rust syntax.

Yes, it will eventually emit valid rust synatx.

But the input initially is a custom-DSL for my specific task only.

Is there any straight-forward method to achieve that?

please provide more context or example. depending on your exact use cases, it might be relative easy, it could also be very difficult.

the declarative macro system in rust can do amazingly complicated tasks, but it might requires a lot of experience and creativity. if you are new to macros, I would suggest you read the excellent "the little book of rust macros", where the "incremental tt muncher" technique (among many other techniques and patterns) is explained.

https://danielkeep.github.io/tlborm/

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.