Skip to content

Commit 45fa511

Browse files
pedro-ricardokrvajal
authored andcommitted
Fix issue #71 (#72)
* Fix subroutine regex for more that one line of arguments. Issue #71 * Add word bound '\b' on subroutine regex. Avoid false positives with matrices. * Allow word (other than end) to precede 'subroutine' declaration.
1 parent 22186a9 commit 45fa511

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const parseSubroutine = (line: TextLine) => {
7575
};
7676
export const _parse = (line: TextLine, type: MethodType) => {
7777
const functionRegEx = /([a-zA-Z]+(\([\w.=]+\))*)*\s*function\s*([a-zA-Z_][a-z0-9_]*)\s*\((\s*[a-z_][a-z0-9_,\s]*)*\s*\)\s*(result\([a-z_][\w]*\))*/i;
78-
const subroutineRegEx = /^\s*subroutine\s*([a-z][a-z0-9_]*)\s*(?:\((\s*[a-z][a-z0-9_,\s]*)*\s*\))*/i;
78+
const subroutineRegEx = /^\s*(?!\bend\b)\w*\s*\bsubroutine\b\s*([a-z][a-z0-9_]*)\s*(?:\((\s*[a-z][a-z0-9_,\s]*)*\s*(\)|\&))*/i;
7979
const regEx =
8080
type === MethodType.Subroutine ? subroutineRegEx : functionRegEx;
8181

0 commit comments

Comments
 (0)