Hi Joel,
For simplicity, I recommend to use the ripper extension for that. It has a lexer API. I don't know if there is sample code available, but the API itself isn't very difficult to understand and use. Look for the Ripper::Lexer class.
Based on the returned tokens, you can then colorize your text storage by yourself (assuming you're using an NSTextView).
This is probably not a very good solution if you want to colorize a large amount of text every time the user changes it, but for small snippets, it should be okay. You can also schedule the lexing in a separate thread/GCD queue and colorize the storage from the main thread, grouping all the changes between -beginEditing / -endEditing calls, for better performance.
Laurent
On Jan 10, 2011, at 10:00 AM, Joel Reymont wrote: