Closed stadelmanma closed 1 year ago
This also seems to apply to identifiers like double
which form part of white-spaced keywords like double precision
:
elemental integer function double(x)
integer, intent(in) :: x
double = 2 * x
end function double
I asked about this in the tree-sitter discussion forum, and the solution is to basically add all the keywords to identifier
:
identifier: $ => choice(
/[a-zA-Z_]\w*/,
caseInsensitive('data'),
caseInsensitive('double'),
caseInsensitive('elseif'),
caseInsensitive('end'),
caseInsensitive('endif'),
caseInsensitive('error'),
caseInsensitive('exit'),
caseInsensitive('if'),
caseInsensitive('select'),
caseInsensitive('stop'),
caseInsensitive('value'),
)
Quite a few of these then needed the rules also adding to conflicts
, but I have been able to get this to work. It's a bit of a pain if we have to list all the keywords, though I'm not certain we do need everything.
Fortran allows any variable to be assigned to and we get an error when that occurs with a keyword. See the pared down snippet from the Fire Models FDS code base (file: pois.f90, line 6115).