Is it possible in a language grammar to create a pattern that is based on another pattern? I know that you can create a pattern which matches some text and inserts another pattern in a capture group. But I would like to reuse the actual regular expression from another pattern.
It's a bit hard to explain but the equivalent in Ruby would look something like this:
identifier = /\w+/ mod = /module #{identifier};/
The point here is to avoid duplicating the "identifier" pattern in the "mod" pattern.