Well, the first place I'd look is at the code of some of the many open source editors available.
If you really want to do it yourself rather than borrow someone else's code, you'll need to first sit down and decide underwhat situations you want to change the colour of words. Just actual keywords, or also well-known things like system types too? All occurrences, or not in strings? What about in comments? etc. etc.
Pick several examples of random, fairly complex code from different places on the internet, print them out and mark them up by hand. Then think about what you highlighted, and why. Maybe get the list of reserved words, keywords and basic types from the Language Spec.
Now begin coding up a set of "unit tests" for the situations you have encountered in your downloaded examples. Write just enough code to make each
test work, then refactor your system as you go along to simplify and remove any duplication, making sure it always passes all the tests so far.
When you've completed all your tests, you'll have a system which does what you want.