How do you implement syntax highlighting?

Posted by ML on Stack Overflow See other posts from Stack Overflow or by ML
Published on 2010-04-17T00:56:17Z Indexed on 2010/04/17 6:33 UTC
Read the original article Hit count: 265

Filed under:
|
|
|

I am embarking on some learning and I want to write my own syntax highlighting for files in C++.

Can anyone give me ideas on how to go about doing this?

To me it seems that when a file is opened:

  1. It would need to be parsed and decided what type of source file it is. Trusting the extension might not be fool-proof

  2. A way to know what keywords/commands apply to what language

  3. A way to decide what color each keyword/command gets

I want to do this on OS X, using C++ or Objective-C.

Can anyone provide pointers on how I might get started with this?

© Stack Overflow or respective owner

Related posts about c++

Related posts about lexical-analyser