[TxMt] Language grammar, matching multiple lines

Jacob Carlborg doob at me.com
Mon Mar 9 19:30:21 UTC 2015


I have this piece of language grammar to match a struct in D :

begin = '(?x)^\s*	 
((?:\b(public|private|protected|static|final|synchronized|abstract|export|shared)\b\s*)*) 
# modifier
     (struct)\s+
     (\w+)\s* # identifier
     (?:\(\s*([^\)]+)\s*\)|)\s* # Template type
     (if\s*\(\s*([^\)]+)\s*\)|)?\s* # Template constraint
     ';
end = '(?={|;)';

It will match this code, as an example:

struct Foo(A) if (true)
{
}

The problem is if I put the "if" on a new line it won't match. How can I 
make the rule match across several lines?

-- 
/Jacob Carlborg



More information about the textmate mailing list