hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
295 stars 57 forks source link

KIND_SPEC_REGEX fails on space between * and kind specifier #142

Closed kemlath closed 4 years ago

kemlath commented 4 years ago

fortls failes on variable declarations like 'REAL 8' where there is a space between the and the kind specifier

Adding a [ ] to the *[0-9:] alternative in `[ ]([]?([ ][a-z0-9_:]|*[0-9:])` yields:

KIND_SPEC_REGEX = re.compile(r'[ ]*([*]?\([ ]*[a-z0-9_*:]|\*[ ]*[0-9:]*)', re.I)

which matches '* 8'.

However this match is longer than 2 so in addition in parse_fortran.py line 326 in routine read_var_def one has to replace

kind_str = kind_match.group(1).strip()

with

kind_str = kind_match.group(1).replace(' ','')

which then finally yield '*8' which can be processed by the rest of the routine