On 06/08/15 10:26, MakersF wrote:

Then your best shot is to approximate the grammar with the regual
expressions you have access to. You'll get to a point where some
constructs can not be correctly represented; at that point you should
probably write a regex which produces what the grammar produces and some
more.

In the example before of generating paired interleaved parentheses, you
could generate every possible combination of parentheses, like
( (|)|[|]|{|}|" )*
where only the external parentheses are syntax for the regex. That regex
matches all the productions of the paired parentheses grammar, and many
more strings.

At the end of the day you want to highlight correct syntax, and if an
user writes wrong syntax is OK to have wrong highlight, so be sure your
regex work for the right syntax, and can do random stuff for the wrong one

I was hoping to enhance the current TextMate grammar for D to get it a bit closer to the D grammar [1]. That's why I started this thread.

[1] http://dlang.org/grammar.html

--
/Jacob Carlborg

Reply via email to