Rust's macros require them to be delimited by either parentheses, braces, or brackets, such as println!(arg)
or foo! { bar, baz }
. However, I have seen many examples of embedded scripting languages implemented via a macro. How does the Rust parser figure out where the macro ends? The language might have rogue braces or something in it, such as
python! {
print("}")
}
While this can be solved by having the parser detect inner strings, what if my strings are delimited by <
and >
? Or what if my language does not require pairing brackets/braces, like many esolangs? Obviously pair matching cannot be used here, so how does Rust parse such macros?
<
and>
are not delimiters in Rust token trees. $\endgroup$