Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
here is my problem:
I'm writing a script editor for a certain language and would like my editor to have syntax coloring... I already came up with an algorithm to do so but there are 2 BIIIIG problems:
1) it works only 90% of the time, not 100%
2) when the file contains more than 100 lines of code, it becomes real slow. Since the syntax coloring method is called each time the user press a key in the editor, it s very tiresome to add a letter, wait for 15 sec, then add another letter and so on...
so if anyone can tell me where I can find good algorithms or give me some hints about how such a thing is supposed to be coded that would be GREAT :)
(My current algorithm works basically that way: I have an array storing about 388 keywords... my method, for each of these 388 keywords look for all occurences of them AND verify that each time a keyword is found, it s a whole word (for example, if "END" is a keyword, it will be found in the following phrase: "durENDal" however it must not be put in blue cause it's not a whole word)... after all the 388 keywords have been processed, It deals with strings, then with comments, and finally with numbers... this is not very efficient)