Sublime Forum

Modify exisiting syntax (objective-c) to suit RSL (Renderman

#1

Hi,

I hope there is no such a question like a stupid question - so here we go.

I am trying to learn** RSL (Renderman Shading language) **and it comes close to **Objective-C **in regards to syntax - so I am using it as my syntax highlighter.

In objective-c variable types like *int, float, char *get syntax highlighted.

My goal is to modify the existing objective-c package and include some additional RSL variable types like ***color, normal, … ** *. I tried to hack the file
Objective-C.tmLanguage file but somehow not able to find where the “int, floats, char, are defined”.

Can anyone help me out in this one? It would TOTALLY make my day!
Highly appreciated.
Peter

0 Likes

#2

When you’re trying to modify language files, I highly recommend you use the following keybinding: alt+command+p (Ctrl + ⇧ + Alt + P on windows/linux) to show the name of the scope in the status bar. When you put your cursor over int/float/char/etc. the scope name is “storage.type.c”

This is because the Objective-c language file has the following line: <dict> <key>include</key> <string>source.c</string> </dict>

This means that objective-c.tmlanguage inherits from c.tmlanguage (found in the c++ folder for some reason…). In c.tmlanguage, there is the following line: <dict> <key>match</key> <string>\b(asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void)\b</string> <key>name</key> <string>storage.type.c</string> </dict>
If you wanted, you could just edit the c file(the easier way), or you could define a new rule in the objective-c file(the better way).

0 Likes

#3

THANK YOU sooooooooo much. It works.

Thats all I needed to know to make it RSL ready. :smile:

Happy times.

0 Likes