On 02/08/15 19:15, Xinok wrote:

I guess you're not familiar with the theoretical aspect of "formal
languages". The D grammar is a context-free grammar which cannot be
reduced to a regular expression. As cym13 stated, there are some simple
context-free grammars which can be rewritten as regular expressions, but
the D grammar cannot be. Take a look at the Chomsky Hierarchy [1] for a
better understanding.

The classic example of a context-free language is the set of balanced
parenthesis, i.e. (()) is balanced and ())))) is not. This language is
not regular meaning you cannot write a regular expression for it, but
you can write a context-free grammar for it.

TextMate grammars are not _just_ regular expressions. They can define balanced parentheses [1].

The point of a language grammar in a text editor is not to have a 100% correct implementation of the grammar. Rather it should syntax highlight the code in a way that is useful for the user.

[1] https://manual.macromates.com/en/language_grammars

--
/Jacob Carlborg

Reply via email to