I'm writing a vscode extension for my programming language. I'm having difficulty coming up with a tmlanguage rule to parse my function declarations.
A function can look like this:
def macro_1 macro_2(foo, 20) function1(a: int, b: double) -> int {
}
macro_1
and macro_2
would be keywords while function1
should be a function name
The parser is looking for matching parenthesis and then looking ahead if it is followed by an identifier, in which case it is assumed to be a macro invocation. There can be any amount of macro invocations on a function. Do note that lines can be continued with a backslash, but I'm not trying to implement that yet.
My first idea was to use a single rule to parse both macro invocations and the function name with parameters, but the problem with this is that the macro invocation can have any expression as an argument while a function parameter can only be an identifier followed by colon and a type.