1 /*
2 * Copyright (c) 2008, David Fishburn
3 *
4 * This source code is released for free distribution under the terms of the
5 * GNU General Public License version 2 or (at your option) any later version.
6 *
7 * This module contains functions for generating tags for MATLAB language files.
8 */
9
10 /*
11 * INCLUDE FILES
12 */
13 #include "general.h" /* must always come first */
14
15 #include <string.h>
16 #include "parse.h"
17 #include "routines.h"
18 #include "selectors.h"
19
20 static tagRegexTable matlabTagRegexTable [] = {
21 /* function [x,y,z] = asdf */
22 { "^[ \t]*function[ \t]*\\[.*\\][ \t]*=[ \t]*([a-zA-Z0-9_]+)",
23 "\\1", "f,function", NULL},
24 /* function x = asdf */
25 {"^[ \t]*function[ \t]*[a-zA-Z0-9_]+[ \t]*=[ \t]*([a-zA-Z0-9_]+)",
26 "\\1", "f,function", NULL},
27 /* function asdf */
28 {"^[ \t]*function[ \t]*([a-zA-Z0-9_]+)[^=]*$", "\\1",
29 "f,function", NULL},
30 /* variables */
31 {"^[ \t]*([a-zA-Z0-9_]+)[ \t]*=[ \t]", "\\1",
32 "v,variable", NULL},
33 /* class definitions */
34 {"^[ \t]*classdef[ \t]*([a-zA-Z0-9_]+)", "\\1",
35 "c,class", NULL},
36 };
37
38 /*
39 * FUNCTION DEFINITIONS
40 */
MatLabParser(void)41 extern parserDefinition* MatLabParser (void)
42 {
43 static const char *const extensions [] = { "m", NULL };
44 static selectLanguage selectors [] = { selectByObjectiveCAndMatLabKeywords,
45 NULL };
46 parserDefinition* const def = parserNew ("MatLab");
47 def->extensions = extensions;
48 def->tagRegexTable = matlabTagRegexTable;
49 def->tagRegexCount = ARRAY_SIZE (matlabTagRegexTable);
50 def->method = METHOD_NOT_CRAFTED|METHOD_REGEX;
51 def->selectLanguage = selectors;
52 return def;
53 }
54