Customize syntax highlighting for CUDA in Kate/KDevelop

June 6, 2008

CUDA is a minimal extension of C/C++ to support programming on newer NVIDIA GPUs. It introduces dozens of new keywords that are frequently used in CUDA programs. Adding syntax highlighting in KDevelop (Kate) only requires several simple steps:

1. Get keywords from “usertype.dat” provided by any Windows version of CUDA SDK, this is a text file. It should be found under $(NVIDIA_CUDA_SDK)\doc\syntax_highlighting.

2. Under your Linux account, cd ~/.kde/share/apps/katepart/syntax/, there should be two xml files regarding C/C++, cpp.xml and c.xml. Make a copy of both and name them properly, e.g. cpp_cuda.xml & c_cuda.xml.

3. Perform a replace operation on each keyword in “usertype.dat” so they match the keyword format in target xml files, and then copy them into the keyword lists of target files.

4. Modify xml header, which includes language description, file extensions and other information. You probably want to add “*.cu” to the file extension list. Remember to distinguish them from the original C/C++ language tag. Save the xml files after you are done.

5. Open Kate/KDevelop, under Tools->Highlighting->Sources you should see two new entries below C++ and C, respectively.

Enjoy.

Entry Filed under: All, Tools. .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

June 2008
M T W T F S S
« May    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Most Recent Posts