Sublime Forum

Highlight variables local to a scope?

#1

Hello,
I am writing the core rules for a syntax highlighter for MaxScript, the scripting language of Autodesk 3ds Max. I am trying to reproduce some of the useful features I have got in Visual Studio using Visual Assist. In particular, I would like to be able to “highlight local symbols”.

As an example, a function would look like:

function myFunc param =
(
local localVar = 10

if (**param** != 0) do
(
    **localVar** /= **param**
    **localVar** += m_someGlobalVar
)

return **localVar**

)

function / local / if / do / return -> are keywords
param -> is a parameter local to the function, should be highlighted as “LOCAL”
localVar -> is a variable local to the function, should be highlighted as “LOCAL”
m_someGlobalVar -> is a variable defined outside the scope of the function, should be highlighted as “NON LOCAL”

I would like to know if it is possible to capture the parameters of a functions and match them against the entire scope of the function. Same goes for the variable names following the keyword “local”.

I’ve been trying several combinations of regular expressions but I don’t seem to find anything suitable to do that. I am wondering if there is another way with Preferences or something else.

Thank you very much for any help!

  • Enrico
0 Likes