Created
November 16, 2011 20:14
-
-
Save cweagans/1371218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 99d8f7d39f15be6905929268e1ee61b8f8ff2afa | |
Author: Cameron Eagans <[email protected]> | |
Date: Wed Nov 16 12:54:53 2011 -0700 | |
Patch for actionscript parsing | |
diff --git a/actionscript.c b/actionscript.c | |
new file mode 100644 | |
index 0000000..39f8d15 | |
--- /dev/null | |
+++ b/actionscript.c | |
@@ -0,0 +1,95 @@ | |
+/* | |
+* $Id: actionscript.c,v 1.1 2004/01/03 03:59:19 svoisen Exp $ | |
+* | |
+* Original file copyright (c) 2004, Sean Voisen | |
+* | |
+* Modified October 8, 2007 By Mike Fahy (VeryVito) of www.turdhead.com | |
+* - Added initial AS3 support | |
+* - Threw in some "TODO" and "NOTE" bits | |
+* | |
+* Modified October 9, 2007 By Ali Rantakari of hasseg.org: | |
+* - Added more allowed AS3 attribute keywords (override, final, internal | |
+* etc...) for classes, getters & setters, variables | |
+* - Allowed varying versions of "note" and "todo" spellings | |
+* - Allowed points (.) in package names so that they would display the | |
+* whole package name instead of just the first level | |
+* - Added interfaces matching support | |
+* - Reformatted some name parameters: | |
+* - Getters and setters: display either "get" or "set" in front | |
+* of the property name | |
+* - Todos & notes: made the name be the text that comes after the | |
+* "todo" or "note" text | |
+* - Variables: Moved the variable type after the name and separated | |
+* them with " : " according to ActionScript syntax | |
+* | |
+* 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 ActionScript language | |
+* files. | |
+*/ | |
+ | |
+/* | |
+* INCLUDE FILES | |
+*/ | |
+#include "general.h" /* must always come first */ | |
+#include "parse.h" | |
+ | |
+/* | |
+* FUNCTION DEFINITIONS | |
+* | |
+*/ | |
+ | |
+static void installActionScriptRegex (const langType language) | |
+{ | |
+ // Functions | |
+ /*addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal|final|override)( \t)]*function[ \t]+([A-Za-z0-9_]+)[ \t]*\\(([^\\{]*)", "\\1 (\\2", "f,function,functions,methods", NULL);*/ | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal|final|override)( \t)]*function[ \t]+([A-Za-z0-9_]+)[ \t]*\\(([^\\{]*)", "\\1", "f,function,functions,methods", NULL); | |
+ | |
+ // Getters and setters | |
+ /*addTagRegex (language, "^[ \t]*[(public|static|internal|final|override)( \t)]*function[ \t]+(set|get)[ \t]+([A-Za-z0-9_]+)[ \t]*\\(", "\\1 \\2", "p,property,properties", NULL);*/ | |
+ addTagRegex (language, "^[ \t]*[(public|static|internal|final|override)( \t)]*function[ \t]+(set|get)[ \t]+([A-Za-z0-9_]+)[ \t]*\\(", "\\1 \\2", "p,property,properties", NULL); | |
+ | |
+ // Variables | |
+ /*addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal)( \t)]*var[ \t]+([A-Za-z0-9_]+)([ \t]*\\:[ \t]*([A-Za-z0-9_]+))*[ \t]*", "\\3 \\: \\1", "v,variable,variables", NULL);*/ | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal)( \t)]*var[ \t]+([A-Za-z0-9_]+)([ \t]*\\:[ \t]*([A-Za-z0-9_]+))*[ \t]*", "\\1", "v,variable,variables", NULL); | |
+ | |
+ // Constants | |
+ /*addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal)( \t)]*const[ \t]+([A-Za-z0-9_]+)([ \t]*\\:[ \t]*([A-Za-z0-9_]+))*[ \t]*", "\\1 : \\3", "v,variable,variables", NULL);*/ | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal)( \t)]*const[ \t]+([A-Za-z0-9_]+)([ \t]*\\:[ \t]*([A-Za-z0-9_]+))*[ \t]*", "\\1", "v,variable,variables", NULL); | |
+ | |
+ // Classes | |
+ /*addTagRegex (language, "^[ \t]*[(private|public|static|dynamic|final|internal)( \t)]*class[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)", "\\1 (\\2)", "c,class,classes", NULL);*/ | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|dynamic|final|internal)( \t)]*class[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)", "\\1", "c,class,classes", NULL); | |
+ | |
+ // Interfaces | |
+ /*addTagRegex (language, "^[ \t]*[(private|public|static|dynamic|final|internal)( \t)]*interface[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)", "\\1 (\\2)", "i,interface,interfaces", NULL); */ | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|dynamic|final|internal)( \t)]*interface[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)", "\\1", "i,interface,interfaces", NULL); | |
+ // Packages | |
+ addTagRegex (language, "^[ \t]*[(private|public|static)( \t)]*package[ \t]+([A-Za-z0-9_.]+)[ \t]*", "\\1", "p,package", NULL); | |
+ | |
+ // Notes | |
+ addTagRegex (language, "\\/\\/[ \t]*(NOTE|note|Note)[ \t]*\\:*(.*)", "\\2", "i,{Notes}", NULL); | |
+ | |
+ // Todos | |
+ addTagRegex (language, "\\/\\/[ \t]*(TODO|todo|ToDo|Todo)[ \t]*\\:*(.*)", "\\2", "i,{To do}", NULL); | |
+ | |
+ // Prototypes (Put this in for AS1 compatibility...) | |
+ addTagRegex (language, ".*\\.prototype\\.([A-Za-z0-9 ]+)[ \t]*\\=([ \t]*)function( [ \t]?)*\\(", "\\1", "p,prototype", NULL); | |
+ | |
+} | |
+ | |
+/* Create parser definition stucture */ | |
+ | |
+ | |
+extern parserDefinition* ActionScriptParser (void) | |
+ | |
+{ | |
+ static const char *const extensions [] = { "as", NULL }; | |
+ parserDefinition *const def = parserNew ("ActionScript"); | |
+ def->extensions = extensions; | |
+ def->initialize = installActionScriptRegex; | |
+ def->regex = TRUE; | |
+ return def; | |
+} | |
+ | |
diff --git a/haxe.c b/haxe.c | |
new file mode 100644 | |
index 0000000..1447783 | |
--- /dev/null | |
+++ b/haxe.c | |
@@ -0,0 +1,102 @@ | |
+/* | |
+* $Id: actionscript.c,v 1.1 2004/01/03 03:59:19 svoisen Exp $ | |
+* | |
+* Original file copyright (c) 2004, Sean Voisen | |
+* | |
+* Modified October 8, 2007 By Mike Fahy (VeryVito) of www.turdhead.com | |
+* - Added initial AS3 support | |
+* - Threw in some "TODO" and "NOTE" bits | |
+* | |
+* Modified October 9, 2007 By Ali Rantakari of hasseg.org: | |
+* - Added more allowed AS3 attribute keywords (override, final, internal | |
+* etc...) for classes, getters & setters, variables | |
+* - Allowed varying versions of "note" and "todo" spellings | |
+* - Allowed points (.) in package names so that they would display the | |
+* whole package name instead of just the first level | |
+* - Added interfaces matching support | |
+* - Reformatted some name parameters: | |
+* - Getters and setters: display either "get" or "set" in front | |
+* of the property name | |
+* - Todos & notes: made the name be the text that comes after the | |
+* "todo" or "note" text | |
+* - Variables: Moved the variable type after the name and separated | |
+* them with " : " according to ActionScript syntax | |
+* | |
+* Modified Jan 20 2010 by DavidWilhelm to use with haxe | |
+* | |
+* 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 ActionScript language | |
+* files. | |
+*/ | |
+ | |
+/* | |
+* INCLUDE FILES | |
+*/ | |
+#include "general.h" /* must always come first */ | |
+#include "parse.h" | |
+ | |
+/* | |
+* FUNCTION DEFINITIONS | |
+* | |
+*/ | |
+ | |
+static void installHaxeRegex (const langType language) | |
+{ | |
+ // Functions | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal|final|override)( \t)]*function[ \t]+([A-Za-z0-9_]+)[ \t]*\\(([^\\{]*)", | |
+ "\\1", "f,function,functions,methods", NULL); | |
+ | |
+ // Getters and setters | |
+ addTagRegex (language, "^[ \t]*[(public|static|internal|final|override)( \t)]*function[ \t]+(set|get)[ \t]+([A-Za-z0-9_]+)[ \t]*\\(", | |
+ "\\2", "p,property,properties", NULL); | |
+ | |
+ // Variables | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal)( \t)]*var[ \t]+([A-Za-z0-9_]+)([ \t]*\\:[ \t]*([A-Za-z0-9_]+))*[ \t]*", | |
+ "\\1", "v,variable,variables", NULL); | |
+ | |
+ // Constants | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal)( \t)]*const[ \t]+([A-Za-z0-9_]+)([ \t]*\\:[ \t]*([A-Za-z0-9_]+))*[ \t]*", | |
+ "\\1", "v,variable,variables", NULL); | |
+ | |
+ // Classes | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|dynamic|final|internal)( \t)]*class[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)", | |
+ "\\1", "c,class,classes", NULL); | |
+ | |
+ // Interfaces | |
+ addTagRegex (language, "^[ \t]*[(private|public|static|dynamic|final|internal)( \t)]*interface[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)", | |
+ "\\1", "i,interface,interfaces", NULL); | |
+ | |
+ // Packages | |
+ addTagRegex (language, "^[ \t]*[(private|public|static)( \t)]*package[ \t]+([A-Za-z0-9_.]+)[ \t]*", | |
+ "\\1", "p,package", NULL); | |
+ | |
+ // Notes | |
+ addTagRegex (language, "\\/\\/[ \t]*(NOTE|note|Note)[ \t]*\\:*(.*)", | |
+ "\\2", "i,{Notes}", NULL); | |
+ | |
+ // Todos | |
+ addTagRegex (language, "\\/\\/[ \t]*(TODO|todo|ToDo|Todo)[ \t]*\\:*(.*)", | |
+ "\\2", "i,{To do}", NULL); | |
+ | |
+ // Prototypes (Put this in for AS1 compatibility...) | |
+ addTagRegex (language, ".*\\.prototype\\.([A-Za-z0-9 ]+)[ \t]*\\=([ \t]*)function( [ \t]?)*\\(", | |
+ "\\1", "p,prototype", NULL); | |
+ | |
+} | |
+ | |
+/* Create parser definition stucture */ | |
+ | |
+ | |
+extern parserDefinition* HaxeParser (void) | |
+ | |
+{ | |
+ static const char *const extensions [] = { "hx", NULL }; | |
+ parserDefinition *const def = parserNew ("Haxe"); | |
+ def->extensions = extensions; | |
+ def->initialize = installHaxeRegex; | |
+ def->regex = TRUE; | |
+ return def; | |
+} | |
+ | |
diff --git a/parsers.h b/parsers.h | |
index 3dcc8ae..e5d162a 100644 | |
--- a/parsers.h | |
+++ b/parsers.h | |
@@ -16,6 +16,7 @@ | |
/* Add the name of any new parser definition function here */ | |
#define PARSER_LIST \ | |
+ ActionScriptParser, \ | |
AntParser, \ | |
AsmParser, \ | |
AspParser, \ | |
@@ -31,6 +32,7 @@ | |
ErlangParser, \ | |
FlexParser, \ | |
FortranParser, \ | |
+ HaxeParser, \ | |
HtmlParser, \ | |
JavaParser, \ | |
JavaScriptParser, \ | |
diff --git a/source.mak b/source.mak | |
index 3e5f740..c8bbbd6 100644 | |
--- a/source.mak | |
+++ b/source.mak | |
@@ -8,6 +8,7 @@ HEADERS = \ | |
strlist.h vstring.h | |
SOURCES = \ | |
+ actionscript.c \ | |
args.c \ | |
ant.c \ | |
asm.c \ | |
@@ -24,6 +25,7 @@ SOURCES = \ | |
flex.c \ | |
fortran.c \ | |
get.c \ | |
+ haxe.c \ | |
html.c \ | |
jscript.c \ | |
keyword.c \ | |
@@ -70,6 +72,7 @@ REGEX_SOURCES = gnu_regex/regex.c | |
REGEX_HEADERS = gnu_regex/regex.h | |
OBJECTS = \ | |
+ actionscript.$(OBJEXT) \ | |
args.$(OBJEXT) \ | |
ant.$(OBJEXT) \ | |
asm.$(OBJEXT) \ | |
@@ -86,6 +89,7 @@ OBJECTS = \ | |
flex.$(OBJEXT) \ | |
fortran.$(OBJEXT) \ | |
get.$(OBJEXT) \ | |
+ haxe.$(OBJEXT) \ | |
html.$(OBJEXT) \ | |
jscript.$(OBJEXT) \ | |
keyword.$(OBJEXT) \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment