Skip to content

Commit

Permalink
matlab: Parse variables in Matlab cod
Browse files Browse the repository at this point in the history
  • Loading branch information
vhda committed Sep 22, 2015
1 parent c13d9dd commit c480869
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Units/matlab-tg-corpus.d/expected.tags
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
backtrack input.m /^function [xn,fn,fcall] = backtrack(xc,d,fc,fnc,DDfnc,c,gamma,eps)$/;" f
cDDfnc input.m /^ cDDfnc = gamma*cDDfnc;$/;" v
cDDfnc input.m /^cDDfnc = c*DDfnc;$/;" v
d input.m /^ d = gamma*d;$/;" v
fcall input.m /^ fcall = fcall+1;$/;" v
fcall input.m /^fcall = 1 ;$/;" v
fn input.m /^ fn = feval(fnc,xn);$/;" v
fn input.m /^fn = feval(fnc,xn);$/;" v
func1 input.m /^function [x,y,z] = func1 $/;" f
func2 input.m /^function x = func2 $/;" f
func3 input.m /^function func3 $/;" f
xn input.m /^ xn = xc;$/;" v
xn input.m /^ xn = xc+d;$/;" v
xn input.m /^xn = xc+d;$/;" v
10 changes: 10 additions & 0 deletions Units/noext-tg-matlab.d/expected.tags
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
backtrack input.nolang /^function [xn,fn,fcall] = backtrack(xc,d,fc,fnc,DDfnc,c,gamma,eps)$/;" f
cDDfnc input.nolang /^ cDDfnc = gamma*cDDfnc;$/;" v
cDDfnc input.nolang /^cDDfnc = c*DDfnc;$/;" v
d input.nolang /^ d = gamma*d;$/;" v
fcall input.nolang /^ fcall = fcall+1;$/;" v
fcall input.nolang /^fcall = 1 ;$/;" v
fn input.nolang /^ fn = feval(fnc,xn);$/;" v
fn input.nolang /^fn = feval(fnc,xn);$/;" v
func1 input.nolang /^function [x,y,z] = func1 $/;" f
func2 input.nolang /^function x = func2 $/;" f
func3 input.nolang /^function func3 $/;" f
xn input.nolang /^ xn = xc;$/;" v
xn input.nolang /^ xn = xc+d;$/;" v
xn input.nolang /^xn = xc+d;$/;" v
10 changes: 10 additions & 0 deletions Units/review-needed.r/matlab_backtracking.m.t/expected.tags
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
backtrack input.m /^function [xn,fn,fcall] = backtrack(xc,d,fc,fnc,DDfnc,c,gamma,eps)$/;" f
cDDfnc input.m /^ cDDfnc = gamma*cDDfnc;$/;" v
cDDfnc input.m /^cDDfnc = c*DDfnc;$/;" v
d input.m /^ d = gamma*d;$/;" v
fcall input.m /^ fcall = fcall+1;$/;" v
fcall input.m /^fcall = 1 ;$/;" v
fn input.m /^ fn = feval(fnc,xn);$/;" v
fn input.m /^fn = feval(fnc,xn);$/;" v
xn input.m /^ xn = xc;$/;" v
xn input.m /^ xn = xc+d;$/;" v
xn input.m /^xn = xc+d;$/;" v
2 changes: 2 additions & 0 deletions Units/review-needed.r/matlab_test.m.t/expected.tags
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
A input.m /^A = magic(4);$/;" v
R input.m /^R = randn(3,4,5);$/;" v
func1 input.m /^function [x,y,z] = func1 $/;" f
func2 input.m /^function x = func2 $/;" f
func3 input.m /^function func3 $/;" f
2 changes: 2 additions & 0 deletions Units/review-needed.r/matlab_test.m.t/input.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
function x = func2
function func3

A = magic(4);
R = randn(3,4,5);
2 changes: 2 additions & 0 deletions parsers/matlab.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static void installMatLabRegex (const langType language)
addTagRegex (language, "^function[ \t]*[a-zA-Z0-9_]+[ \t]*=[ \t]*([a-zA-Z0-9_]+)", "\\1", "f,function", NULL);
/* function asdf */
addTagRegex (language, "^function[ \t]*([a-zA-Z0-9_]+)[^=]*$", "\\1", "f,function", NULL);
/* variables */
addTagRegex (language, "^[ \t]*([a-zA-Z0-9_]+)[ \t]*=[ \t]", "\\1", "v,variable", NULL);
}

extern parserDefinition* MatLabParser (void)
Expand Down

0 comments on commit c480869

Please sign in to comment.