Done with jscript.c
Author
Zhou Renjian
Create@
2005-12-14 20:50
/*
* $Id: jscript.c,v 1.1 2003/03/03 03:59:19 darren Exp $
*
* Copyright (c) 2003, Darren Hiebert
*
* This source code is released for free distribution under the terms of the
* GNU General Public License.
*
* This module contains functions for generating tags for JavaScript language
* files.
*/
/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */
#include "parse.h"
/*
* FUNCTION DEFINITIONS
*/
static void installJavaScriptRegex (const langType language)
{
/*
* Added by jozz (josson smith: joo@sjtu.org)
* Dec 14, 2005
*/
/*
* $ is a valid name
*/
addTagRegex (language, "^[ \t]*function[ \t]*([A-Za-z0-9_\\$]+)[ \t]*\\(",
"\\1", "f,function,functions", NULL);
/*
* anonymous functions
*/
addTagRegex (language, "([A-Za-z0-9_\\$]+)[ \t]*=[ \t]*function[ \t]*\\(",
"\\1", "f,function,functions", NULL);
/*
* Javaed functions
*/
addTagRegex (language, "^[ \t]*Clazz\\.defineMethod[ \t]*\\([^'\"]+['\"]([^'\"]+)['\"]",
"\\1", "f,function,functions", NULL);
addTagRegex (language, "^[ \t]*Clazz\\.makeConstructor.*[\\(\\.]([^\\.\\(]+),",
"\\1", "f,function,functions", NULL);
}
/* Create parser definition stucture */
extern parserDefinition* JavaScriptParser (void)
{
static const char *const extensions [] = { "js", NULL };
parserDefinition *const def = parserNew ("JavaScript");
def->extensions = extensions;
def->initialize = installJavaScriptRegex;
def->regex = TRUE;
return def;
}