You can start by having a look at CodeDocument CodeEditorComponent and CodeTokeniser in the documentation, here : http://www.rawmaterialsoftware.com/juce/api/classes.html
I think there’s a code editor included in the demo. You can look at the code and see how it’s done there. Good luck !