[TxMt] feature req: TextMate should complain about bad grammar

Matt Neuburg matt at tidbits.com
Wed Jan 15 23:48:48 UTC 2014


It turns out that it is wrong, in a grammar, to put a "patterns" section inside a "name/match" section.

But it isn't _forbidden_. It just makes everything behave wrong. I lost an entire day over this, because none of the documentation made this sufficiently clear, but mostly because TextMate did not complain. I am suggesting that it should do so.

Here is an extremely silly example to illustrate. Start with this:

{	patterns = (
		{	name = 'punctuation.test';
			match = 'this.*?test';
		},
	);
}

It successfully matches the phrase "this is a test" in the middle of a longer sentence such as "I tell you that this is a test of everything".

Now introduce an embedded pattern:

{	patterns = (
		{	name = 'punctuation.test';
			match = 'this.*test';
			patterns = (
				{	name = 'constant.character.escape.untitled';
					match = '\\.';
				},
			);
		},
	);
}

(I told you it was silly!) The result is that "punctuation.test" now wrongly matches the entire document starting with "this is a test". Evidently, TextMate didn't like that. But what I'm saying is, if TextMate doesn't like that, TextMate should forbid it. The lovely dialog that says that this is not a valid property list, for example, might be used to tell me that this is not a valid grammar and will mess things up as we go along.

m.

--
matt neuburg, phd = matt at tidbits.com, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do
iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



More information about the textmate mailing list