Link to home
Start Free TrialLog in
Avatar of wizcool
wizcool

asked on

multi-line comments in syntax highlighting

I'm making a program that uses a richedit control and has to do syntax highlighting to the text. I figured out how to do the most part, but it remains a problem :
multi-line comments!

It's not difficult to highlight ML comments if I parse the whole text every time, but that is, obviously, incredibly slow. So I have to parse only the lines that were actually changed.
The problem is, when I have to parse a line, the parser needs to know if that line is to be highlighted normally or if is to be highlighted as a comment (if the line is inside a ML comment).

How can I know if a line is inside a ML comment ?

Note: I focused on the ML comments, but it can also exist multi-line strings in the same text.
ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wizcool
wizcool

ASKER

That sounds like a good solution.
I will implement it and then let you know (it shouldn't take long) :)
Avatar of wizcool

ASKER

It worked great, scrapdog.
Thanks
That's great.  You're welcome.