: Hi everyone,
: 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)
For better "EFFICIENCY" try to do ALL your checks in just ONE LOOP or reduce the number of loops.
Then your code will be quicker.
Hope this helps.