Skip to content

Commit

Permalink
Merge pull request #3999 from b4n/matlab
Browse files Browse the repository at this point in the history
matlab: A couple fixes for corner cases
  • Loading branch information
masatake committed May 15, 2024
2 parents 427159a + c883784 commit b1509ff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions Units/parser-matlab.r/matchfail.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
6 changes: 6 additions & 0 deletions Units/parser-matlab.r/matchfail.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
func1 input.m /^function [x,y,z] = func1 $/;" f
func2 input.m /^function x = func2 $/;" f
func3 input.m /^function func3 $/;" f
func4 input.m /^function y = func4(a, b, c)$/;" f
func5 input.m /^function func5 % this comment should be ignored --> X = FAIL5$/;" f
functionality input.m /^functionality = FAIL6; % this is not a function and should not be parsed$/;" v
11 changes: 11 additions & 0 deletions Units/parser-matlab.r/matchfail.d/input.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function [x,y,z] = func1
end
function x = func2
end
function func3
end
function y = func4(a, b, c)
end
function func5 % this comment should be ignored --> X = FAIL5
end
functionality = FAIL6; % this is not a function and should not be parsed
11 changes: 6 additions & 5 deletions parsers/matlab.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@

static tagRegexTable matlabTagRegexTable [] = {
/* function [x,y,z] = asdf */
{ "^[ \t]*function[ \t]*\\[.*\\][ \t]*=[ \t]*([.a-zA-Z0-9_]+)",
{ "^[ \t]*function[ \t]+\\[.*\\][ \t]*=[ \t]*([.a-zA-Z0-9_]+)",
"\\1", "f,function", NULL},
/* function x = asdf */
{"^[ \t]*function[ \t]*[a-zA-Z0-9_]+[ \t]*=[ \t]*([.a-zA-Z0-9_]+)",
{"^[ \t]*function[ \t]+[a-zA-Z0-9_]+[ \t]*=[ \t]*([.a-zA-Z0-9_]+)",
"\\1", "f,function", NULL},
/* function asdf */
{"^[ \t]*function[ \t]*([.a-zA-Z0-9_]+)[^=]*$", "\\1",
/* function asdf
* function asdf % some comment */
{"^[ \t]*function[ \t]+([.a-zA-Z0-9_]+)[^=%]*($|%)", "\\1",
"f,function", NULL},
/* variables */
{"^[ \t]*([a-zA-Z0-9_]+)[ \t]*=[ \t]", "\\1",
"v,variable", NULL},
/* class definitions */
{"^[ \t]*classdef[ \t]*([a-zA-Z0-9_]+)", "\\1",
{"^[ \t]*classdef[ \t]+([a-zA-Z0-9_]+)", "\\1",
"c,class", NULL},
};

Expand Down

0 comments on commit b1509ff

Please sign in to comment.