3

I'm writing a grammar file for the Atom Editor for a specific (yet unsupported language).

While I'm getting expected results up to now, I'm not sure how to accomplish the following.

I want functions declared in the current file that are called in the same file to be highlighted. For now, the function calls don't get matched/highlighted.

I know it is possible as C files are properly highlighted. For example, in the following screenshot, the call to function my_function() gets highlighted in blue:

helloworld.c

Right now, function definitions are matched with the following cson snippet:

{
    'comment':  'Functions'
    'match':    '^\\s*(function)\\s*(\\w*)'
    'captures':
        '1':
            'name':     'variable.other.newlang'
        '2':
            'name':     'support.function.any-method.newlang'
}

which is quite basic but work fine. But unfortunately the function calls will not be highlighted the same way as in C.

How can I achieve this?

Note that Atom uses the (almost) same grammar file syntax as Sublime Text 3 and TextMate.

Thanks!

big_gie
  • 2,829
  • 3
  • 31
  • 45
  • From what I understand as to now, this is not possible. Atom's C grammar is able to highlights the function call because it can recognize _a_ function call, not _the_ function call. So in the above example line 3 and line 11 are not related; it's two different matching rules in the grammar. I'm saying it's not possible because in the new language I'm working with, there is not way to reliably recognize a function call; it is not using the parenthesis as in C (or any other characters). – big_gie Jun 03 '15 at 19:16
  • Well your language has to have _some_ sort of defined syntax of how a function call has to look like. – TabascoEye Feb 12 '16 at 16:05
  • This was the issue back then; that language did not have delimiters for the function calls! You could for example chain multiple commands like this `result = commandOne commandTwo commandThree argument` where the output of one `command*` is the input of the other... – big_gie Feb 12 '16 at 23:39

0 Answers0