Skip to content

Commit 70c0ddb

Browse files
committed
Clean parsing routines for dimensions and lengths
1 parent 4b5e4bb commit 70c0ddb

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

fortls/parse_fortran.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,9 +1672,7 @@ def parse_imp_dim(self, line: str):
16721672
tuple[str, str]
16731673
truncated line, dimension string
16741674
"""
1675-
regex = re.compile(r"[ ]*\w+[ ]*(\()", re.I)
1676-
# TODO: replace space
1677-
m = regex.match(line)
1675+
m = re.compile(r"[ ]*\w+[ ]*(\()", re.I).match(line)
16781676
if not m:
16791677
return line, None
16801678
i = find_paren_match(line[m.end(1) :])
@@ -1698,9 +1696,7 @@ def parse_imp_char(self, line: str):
16981696
tuple[str, str]
16991697
truncated line, character length
17001698
"""
1701-
implicit_len = re.compile(r"(\w+)[ ]*\*[ ]*(\d+|\()", re.I)
1702-
# TODO: replace space in name
1703-
match = implicit_len.match(line)
1699+
match = re.compile(r"(\w+)[ ]*\*[ ]*(\d+|\()", re.I).match(line)
17041700
if not match:
17051701
return line, None
17061702
if match.group(2) == "(":
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
! Tests that the parser will not break, when parsing incomplete variables
3+
! constructs. This is particularly important for autocompletion.
4+
program test_incomplete_dims
5+
implicit none
6+
integer :: dim_val(1, 2
7+
character :: char_val*(10
8+
end program test_incomplete_dims

0 commit comments

Comments
 (0)