SF.net SVN: geany:[4685] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Feb 21 14:54:53 UTC 2010
Revision: 4685
http://geany.svn.sourceforge.net/geany/?rev=4685&view=rev
Author: eht16
Date: 2010-02-21 14:54:53 +0000 (Sun, 21 Feb 2010)
Log Message:
-----------
Add R tagmanager symbol parser (patch by Jon Senior, thanks).
Modified Paths:
--------------
trunk/ChangeLog
trunk/THANKS
trunk/src/about.c
trunk/src/filetypes.c
trunk/src/symbols.c
trunk/tagmanager/Makefile.am
trunk/tagmanager/makefile.win32
trunk/tagmanager/parsers.h
trunk/wscript
Added Paths:
-----------
trunk/tagmanager/r.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/ChangeLog 2010-02-21 14:54:53 UTC (rev 4685)
@@ -6,6 +6,10 @@
* plugins/genapi.py:
Minor fixes.
Replace tabs by spaces.
+ * tagmanager/r.c, plugins/geanyfunctions.h, src/about.c,
+ src/filetypes.c, src/symbols.c, tagmanager/Makefile.am,
+ tagmanager/makefile.win32, tagmanager/parsers.h, wscript, THANKS:
+ Add R tagmanager symbol parser (patch by Jon Senior, thanks).
2010-02-20 Dominic Hopf <dmaphy(at)googlemail(dot)com>
Modified: trunk/THANKS
===================================================================
--- trunk/THANKS 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/THANKS 2010-02-21 14:54:53 UTC (rev 4685)
@@ -72,7 +72,8 @@
Ross McKay <rosko<at>zeta<dot>org<dot>au> - ASP preferred language option
Alexey Antipov <1a_antipov(at)mail(dot)ru> - Apply file open encoding only to non-Unicode files
Jörn Reder <joern(at)zyn(dot)de> - --socket-file command line option patch
-Kelvin Gardiner <kelvin.mbmn.net> - VHDL symbol list patch, Verilog filetype
+Kelvin Gardiner <kelvin(at)mbmn(dot)net> - VHDL symbol list patch, Verilog filetype
+Jon Senior <jon(at)restlesslemon(dot)co(dot)uk> - R tagmanager parser patch
Translators:
------------
Modified: trunk/src/about.c
===================================================================
--- trunk/src/about.c 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/src/about.c 2010-02-21 14:54:53 UTC (rev 4685)
@@ -86,7 +86,7 @@
"Chris Macksey, Christoph Berg, Colomban Wendling, Conrad Steenberg, Daniel Richard G., Dave Moore, "
"Dirk Weber, Elias Pschernig, Eric Forgeot, Eugene Arshinov, Felipe Pena, François Cami, "
"Giuseppe Torelli, Guillaume de Rorthais, Guillaume Hoffmann, Herbert Voss, Jason Oster, "
-"Jean-François Wauthy, Jeff Pohlmeyer, Jesse Mayes, John Gabriele, Jon Strait, Josef Whiter, "
+"Jean-François Wauthy, Jeff Pohlmeyer, Jesse Mayes, John Gabriele, Jon Senior, Jon Strait, Josef Whiter, "
"Jörn Reder, Kelvin Gardiner, Kevin Ellwood, Kristoffer A. Tjernås, Lex Trotman, Marko Peric, Matti Mårds, "
"Moritz Barsnick, Peter Strand, Philipp Gildein, Pierre Joye, Rob van der Linde, Robert McGinley, "
"Roland Baudin, Ross McKay, S Jagannathan, Saleem Abdulrasool, "
Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/src/filetypes.c 2010-02-21 14:54:53 UTC (rev 4685)
@@ -574,7 +574,7 @@
#define R
ft = filetypes[GEANY_FILETYPES_R];
- ft->lang = 34;
+ ft->lang = 40;
ft->name = g_strdup("R");
ft->title = g_strdup_printf(_("%s script file"), "R");
ft->extension = g_strdup("R");
Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/src/symbols.c 2010-02-21 14:54:53 UTC (rev 4685)
@@ -650,6 +650,14 @@
NULL);
break;
}
+ case GEANY_FILETYPES_R:
+ {
+ tag_list_add_groups(tag_store,
+ &(tv_iters.tag_function), _("Functions"), "classviewer-method",
+ &(tv_iters.tag_struct), _("Other"), NULL,
+ NULL);
+ break;
+ }
case GEANY_FILETYPES_PERL:
{
tag_list_add_groups(tag_store,
Modified: trunk/tagmanager/Makefile.am
===================================================================
--- trunk/tagmanager/Makefile.am 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/tagmanager/Makefile.am 2010-02-21 14:54:53 UTC (rev 4685)
@@ -67,6 +67,7 @@
verilog.c\
actionscript.c\
nsis.c\
+ r.c \
ctags.c\
entry.c\
get.c\
Modified: trunk/tagmanager/makefile.win32
===================================================================
--- trunk/tagmanager/makefile.win32 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/tagmanager/makefile.win32 2010-02-21 14:54:53 UTC (rev 4685)
@@ -45,7 +45,7 @@
options.o \
parse.o basic.o read.o sort.o strlist.o latex.o markdown.o matlab.o docbook.o tcl.o ruby.o asm.o sql.o txt2tags.o css.o \
vstring.o regex.o tm_workspace.o tm_work_object.o tm_source_file.o tm_project.o tm_tag.o \
-tm_symbol.o tm_file_entry.o tm_tagmanager.o
+tm_symbol.o tm_file_entry.o tm_tagmanager.o r.o
$(AR) rc $@ $^
$(RANLIB) $@
Modified: trunk/tagmanager/parsers.h
===================================================================
--- trunk/tagmanager/parsers.h 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/tagmanager/parsers.h 2010-02-21 14:54:53 UTC (rev 4685)
@@ -54,7 +54,8 @@
MarkdownParser, \
Txt2tagsParser, \
AbcParser, \
- VerilogParser
+ VerilogParser, \
+ RParser
/*
langType of each parser
0 CParser
@@ -97,6 +98,7 @@
37 Txt2tagsParser
38 AbcParser
39 Verilog
+40 RParser
*/
#endif /* _PARSERS_H */
Added: trunk/tagmanager/r.c
===================================================================
--- trunk/tagmanager/r.c (rev 0)
+++ trunk/tagmanager/r.c 2010-02-21 14:54:53 UTC (rev 4685)
@@ -0,0 +1,197 @@
+/*
+* $Id$
+*
+* Copyright (c) 2003-2004, Ascher Stefan <stievie at utanet.at>
+*
+* 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 R language files.
+* R is a programming language for statistical computing.
+* R is GPL Software, get it from http://www.r-project.org/
+*/
+
+/*
+* INCLUDE FILES
+*/
+#include "general.h" /* must always come first */
+
+#include <string.h>
+#include <ctype.h> /* to define isalpha(), isalnum(), isspace() */
+
+#include "entry.h"
+#include "read.h"
+#include "vstring.h"
+
+/*#define R_REGEX*/
+
+#define SKIPSPACE(ch) while (isspace((int)*ch)) \
+ ch++
+
+#ifndef R_REGEX
+static kindOption RKinds [] = {
+ { TRUE, 'f', "function", "functions" },
+ { TRUE, 's', "other", "libraries" }
+};
+#endif
+
+#ifdef R_REGEX
+static void installRRegex (const langType language)
+{
+ /* This is a function, looks as follows:
+ * itent <- function(arg1, arg2) {
+ * do_something;
+ * }
+ */
+ addTagRegex (language,
+ "^[ \t]*([.a-zA-Z0-9_]+)([ \t]*)<-([ \t]*)function", "\\1", "f,function", NULL);
+ /* This loads someting, e.g. a library, simply: library(libname) */
+ addTagRegex (language,
+ "^[ \t]*(library|source|load|data)[\\(]([a-zA-Z0-9_]+)[\\)]", "\\2", "s,other", NULL);
+}
+#else
+static void makeRTag(const vString* const name, int kind)
+{
+ tagEntryInfo e;
+ initTagEntry(&e, vStringValue(name));
+
+ e.kindName = RKinds[kind].name;
+ e.kind = RKinds[kind].letter;
+
+ makeTagEntry(&e);
+}
+
+extern void createRTags(void)
+{
+ vString *vLine = vStringNew();
+ vString *name = vStringNew();
+ int ikind;
+ const unsigned char *line;
+
+ while ((line = fileReadLine()) != NULL)
+ {
+ const unsigned char *cp = (const unsigned char*)line;
+
+ vStringClear(name);
+ while ((*cp != '\0') && (*cp != '#')) {
+ /* iterate to the end of line or to a comment */
+ ikind = -1;
+ switch (*cp) {
+ case 'l':
+ case 's':
+ if (strncasecmp((const char*)cp, "library", (size_t)7) == 0) {
+ /* load a library: library(tools) */
+ cp += 7;
+ SKIPSPACE(cp);
+ if (*cp == '(')
+ ikind = 1;
+ else
+ cp -= 7;
+ } else if (strncasecmp((const char*)cp, "source", (size_t)6) == 0) {
+ /* load a source file: source("myfile.r") */
+ cp += 6;
+ SKIPSPACE(cp);
+ if (*cp == '(')
+ ikind = 2;
+ else
+ cp -= 6;
+ }
+ if (ikind != -1) {
+ cp++;
+
+ vStringClear(name);
+ while ((!isspace((int)*cp)) && *cp != '\0' && *cp != ')') {
+ vStringPut(name, (int)*cp);
+ cp++;
+ }
+ vStringTerminate(name);
+
+ /* if the string really exists, make a tag of it */
+ if (vStringLength(name) > 0)
+ makeRTag(name, ikind);
+
+ /* prepare for the next iteration */
+ vStringClear(name);
+ } else {
+ vStringPut(name, (int)*cp);
+ cp++;
+ }
+ break;
+ case '<':
+ cp++;
+ if (*cp == '-') {
+ /* assignment: ident <- someval */
+ cp++;
+ SKIPSPACE(cp);
+
+ if (*cp == '\0') {
+ /* not in this line, read next */
+ /* sometimes functions are declared this way:
+ ident <-
+ function(...)
+ {
+ ...
+ }
+ I don't know if there is a reason to write the function keyword
+ in a new line
+ */
+ if ((line = fileReadLine()) != NULL) {
+ cp = (const unsigned char*)line;
+ SKIPSPACE(cp);
+ }
+ }
+
+ if (strncasecmp((const char*)cp, "function", (size_t)8) == 0) {
+ /* it's a function: ident <- function(args) */
+ cp += 8;
+ vStringTerminate(name);
+ /* if the string really exists, make a tag of it */
+ if (vStringLength(name) > 0)
+ makeRTag(name, 0);
+
+ /* prepare for the next iteration */
+ vStringClear(name);
+ break;
+ }
+ }
+ case ' ':
+ case '\x009':
+ /* skip whitespace */
+ cp++;
+ break;
+ default:
+ /* collect all characters that could be a part of an identifier */
+ vStringPut(name, (int)*cp);
+ cp++;
+ break;
+ }
+ }
+ }
+
+ vStringDelete(name);
+ vStringDelete(vLine);
+}
+#endif
+
+extern parserDefinition* RParser (void)
+{
+ /* *.r: R files
+ * *.s;*.q: S files
+ */
+ static const char *const extensions [] = { "r", "s", "q", NULL };
+ parserDefinition* const def = parserNew ("R");
+#ifndef R_REGEX
+ def->kinds = RKinds;
+ def->kindCount = 4;
+#endif
+ def->extensions = extensions;
+#ifndef R_REGEX
+ def->parser = createRTags;
+#else
+ def->initialize = installRRegex;
+ def->regex = TRUE;
+#endif
+ return def;
+}
+
+/* vi:set tabstop=8 shiftwidth=4: */
Property changes on: trunk/tagmanager/r.c
___________________________________________________________________
Added: svn:mime-type
+ text/x-csrc
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/wscript
===================================================================
--- trunk/wscript 2010-02-21 13:30:31 UTC (rev 4684)
+++ trunk/wscript 2010-02-21 14:54:53 UTC (rev 4685)
@@ -70,7 +70,7 @@
'tagmanager/keyword.c', 'tagmanager/latex.c', 'tagmanager/lregex.c', 'tagmanager/lua.c',
'tagmanager/make.c', 'tagmanager/markdown.c', 'tagmanager/matlab.c', 'tagmanager/nsis.c',
'tagmanager/nestlevel.c', 'tagmanager/options.c',
- 'tagmanager/parse.c', 'tagmanager/pascal.c',
+ 'tagmanager/parse.c', 'tagmanager/pascal.c', 'tagmanager/r.c',
'tagmanager/perl.c', 'tagmanager/php.c', 'tagmanager/python.c', 'tagmanager/read.c',
'tagmanager/rest.c', 'tagmanager/ruby.c', 'tagmanager/sh.c', 'tagmanager/sort.c',
'tagmanager/sql.c', 'tagmanager/strlist.c', 'tagmanager/txt2tags.c', 'tagmanager/tcl.c',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list