eirik-kjonstad / modern-fortran-syntax

Modern Fortran syntax highlighting for Sublime Text 3/4
MIT License
10 stars 2 forks source link

Functions are in some cases incorrectly scoped as objects #35

Open eirik-kjonstad opened 3 years ago

eirik-kjonstad commented 3 years ago

I've noticed that the syntax will sometimes incorrectly scope expressions involving functions and object-accessing. Here is an example:

result = foo(object%member)    ! foo scoped as variable.function
result = foo(object(k)%member) ! foo scoped as storage.type.class

The reason for the wrong scope is the following:

    - match: '(\w+)\s*(?=\%|\[.*\]\(.*\)\%|\(.*\)\%|\[.*\]\%)'
      scope: storage.type.class.fortran

It assumes that the ) in object(k) is the closing parenthesis of foo and so misinterprets foo as an storage.type.class.

eirik-kjonstad commented 3 years ago

This issue is partly resolved in #44 and release 1.2.0.

I will leave the issue open because there are still cases where expressions are misinterpreted because the syntax is not able to "match" parentheses when interpreting the expression, e.g.

result = foo(object(k)%otherObject(myFoo(k))%member)