Lothar Scholz <llothar / web.de> writes:

> I'm just trying to write a syntax highlighting plug in for my editor
> and found this task very very hard.
> 
> For example look at the following string:
> 
> print "String #{ ($a={1=>2, 2=> "mystring" , 4=>6}).length }"

This is solveable if one uses stack-based parser instead of a regex
since a regex cannot count.

> print "String #{ ($a={1=>2, 2=> "})mystring" , 4=>6}).length }"

Full grammar parser.

> What do you expect from editor syntax highlighting ?

I don't expect perfectness. I'd expect, however, a way to reset the
state. For example, a complicated regex will most certainly mess up
all but the most sophisticated highlighter. However, at least in
emacs, if you put a line of comment after the regex, everything will
be all right again.

As you said, the perfect parser is too expensive to write. However a
reset button (like a line of comment) is cheap.

YS.