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.
On 16 Jul 2015, at 8:46, Jacob Carlborg wrote:
Is it possible in a language grammar to create a pattern that is based on another pattern?
This is not possible, but it is something I think would be good to have, see e.g. my thoughts on adding variables to grammars here: https://github.com/textmate/textmate/pull/1276#issuecomment-63450941