Hi,
I may be missing something obvious here, but I have a question about code reuse within a language grammar. I have a language (Stata) which permits constructs of this form
<prefix cmd> [options]: <cmd>
Moreover, prefixes can be combined. If we call
<prefix cmd> [options]:
the prefix, then we may have
<prefix> [[<prefix>] ...] <cmd>
I'd like to match the prefix (and scope it as meta.prefix), and then match the <cmd> when it follows the prefix. However, the <cmd> can also appear in other contexts too (where it should also be matched). As I'm thinking about this now, it seems that it would be ideal if I could define the prefix (which itself requires a rather complicated regex) in one place, and then refer to that in other places, such as where a specific command that can follow a prefix is defined. I am familiar with the language repository and have used it for recursive constructs and to embed one grammar within another, but can't figure out how it might be used here (if at all).
Should I be thinking about this a different way?
Thanks,
-- Phil