Revision: 1791 http://geany.svn.sourceforge.net/geany/?rev=1791&view=rev Author: ntrel Date: 2007-08-14 04:50:03 -0700 (Tue, 14 Aug 2007)
Log Message: ----------- Add reStructuredText filetype and parser.
Modified Paths: -------------- trunk/ChangeLog trunk/src/filetypes.c trunk/src/filetypes.h trunk/src/symbols.c trunk/tagmanager/Makefile.am trunk/tagmanager/makefile.win32 trunk/tagmanager/parsers.h
Added Paths: ----------- trunk/tagmanager/rest.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-08-13 18:27:19 UTC (rev 1790) +++ trunk/ChangeLog 2007-08-14 11:50:03 UTC (rev 1791) @@ -1,3 +1,11 @@ +2007-08-14 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/filetypes.c, src/filetypes.h, src/symbols.c, + tagmanager/parsers.h, tagmanager/makefile.win32, tagmanager/rest.c, + tagmanager/Makefile.am: + Add reStructuredText filetype and parser. + + 2007-08-13 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/about.c: Increase border space in credits tab and align developer
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2007-08-13 18:27:19 UTC (rev 1790) +++ trunk/src/filetypes.c 2007-08-14 11:50:03 UTC (rev 1791) @@ -77,7 +77,8 @@ FILETYPE_UID_HASKELL, // 29 FILETYPE_UID_CS, // 30 FILETYPE_UID_BASIC, // 31 - FILETYPE_UID_HAXE // 32 + FILETYPE_UID_HAXE, // 32 + FILETYPE_UID_REST // 33 };
@@ -535,6 +536,18 @@ filetypes[GEANY_FILETYPES_HAXE]->comment_open = g_strdup("//"); filetypes[GEANY_FILETYPES_HAXE]->comment_close = NULL;
+#define REST + filetypes[GEANY_FILETYPES_REST]->id = GEANY_FILETYPES_REST; + filetypes[GEANY_FILETYPES_REST]->uid = FILETYPE_UID_REST; + filetypes[GEANY_FILETYPES_REST]->lang = 28; + filetypes[GEANY_FILETYPES_REST]->name = g_strdup("reStructuredText"); + filetypes[GEANY_FILETYPES_REST]->title = g_strdup(_("reStructuredText file")); + filetypes[GEANY_FILETYPES_REST]->extension = g_strdup("rest"); + filetypes[GEANY_FILETYPES_REST]->pattern = utils_strv_new("*.rest", "*.reST", NULL); + filetypes[GEANY_FILETYPES_REST]->style_func_ptr = styleset_none; + filetypes[GEANY_FILETYPES_REST]->comment_open = NULL; + filetypes[GEANY_FILETYPES_REST]->comment_close = NULL; + #define ALL filetypes[GEANY_FILETYPES_ALL]->id = GEANY_FILETYPES_ALL; filetypes[GEANY_FILETYPES_ALL]->name = g_strdup("None");
Modified: trunk/src/filetypes.h =================================================================== --- trunk/src/filetypes.h 2007-08-13 18:27:19 UTC (rev 1790) +++ trunk/src/filetypes.h 2007-08-14 11:50:03 UTC (rev 1791) @@ -74,6 +74,7 @@ GEANY_FILETYPES_LATEX, GEANY_FILETYPES_DIFF, GEANY_FILETYPES_CONF, + GEANY_FILETYPES_REST,
GEANY_FILETYPES_ALL, // must be last filetype, used for 'None' item. GEANY_MAX_FILE_TYPES
Modified: trunk/src/symbols.c =================================================================== --- trunk/src/symbols.c 2007-08-13 18:27:19 UTC (rev 1790) +++ trunk/src/symbols.c 2007-08-14 11:50:03 UTC (rev 1791) @@ -552,6 +552,16 @@ //&(tv_iters.tag_other), _("Other"), NULL); break; } + case GEANY_FILETYPES_REST: + { + tag_list_add_groups(tag_store, + &(tv_iters.tag_namespace), _("Chapter"), NULL, + &(tv_iters.tag_member), _("Section"), NULL, + &(tv_iters.tag_macro), _("Subsection"), NULL, + &(tv_iters.tag_variable), _("Subsubsection"), NULL, + NULL); + break; + } case GEANY_FILETYPES_RUBY: { tag_list_add_groups(tag_store,
Modified: trunk/tagmanager/Makefile.am =================================================================== --- trunk/tagmanager/Makefile.am 2007-08-13 18:27:19 UTC (rev 1790) +++ trunk/tagmanager/Makefile.am 2007-08-14 11:50:03 UTC (rev 1791) @@ -38,6 +38,7 @@ docbook.c\ fortran.c\ haskell.c\ + haxe.c\ js.c\ lua.c\ make.c\ @@ -45,6 +46,7 @@ latex.c\ pascal.c\ perl.c\ + rest.c\ ruby.c\ sql.c\ php.c\ @@ -54,7 +56,6 @@ sh.c\ vhdl.c\ ctags.c\ - haxe.c\ entry.c\ get.c\ keyword.c\
Modified: trunk/tagmanager/makefile.win32 =================================================================== --- trunk/tagmanager/makefile.win32 2007-08-13 18:27:19 UTC (rev 1790) +++ trunk/tagmanager/makefile.win32 2007-08-14 11:50:03 UTC (rev 1791) @@ -33,7 +33,7 @@ -$(RM) deps.mak *.o $(COMPLIB)
$(COMPLIB): args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o diff.o vhdl.o lua.o js.o \ -haskell.o python.o regex.o sh.o ctags.o entry.o get.o keyword.o options.o parse.o basic.o haxe.o \ +haskell.o haxe.o python.o regex.o rest.o sh.o ctags.o entry.o get.o keyword.o options.o parse.o basic.o \ read.o sort.o strlist.o latex.o docbook.o tcl.o ruby.o asm.o sql.o css.o vstring.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
Modified: trunk/tagmanager/parsers.h =================================================================== --- trunk/tagmanager/parsers.h 2007-08-13 18:27:19 UTC (rev 1790) +++ trunk/tagmanager/parsers.h 2007-08-14 11:50:03 UTC (rev 1791) @@ -42,7 +42,8 @@ HaskellParser, \ CsharpParser, \ FreeBasicParser,\ - HaxeParser + HaxeParser,\ + RestParser
/* langType of each parser @@ -73,7 +74,8 @@ 24 HaskellParser 25 CsharpParser 26 FreeBasicParser -27 Haxe +27 HaxeParser +28 RestParser */ #endif /* _PARSERS_H */
Added: trunk/tagmanager/rest.c =================================================================== --- trunk/tagmanager/rest.c (rev 0) +++ trunk/tagmanager/rest.c 2007-08-14 11:50:03 UTC (rev 1791) @@ -0,0 +1,112 @@ +/* +* +* Copyright (c) 2007, Nick Treleaven +* +* 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 reStructuredText (reST) files. +*/ + +/* +* INCLUDE FILES +*/ +#include "general.h" /* must always come first */ + +#include <ctype.h> +#include <string.h> + +#include "parse.h" +#include "read.h" +#include "vstring.h" + +/* +* DATA DEFINITIONS +*/ +typedef enum { + K_CHAPTER, + K_SECTION, + K_SUBSECTION, + K_SUBSUBSECTION +} restKind; + +static kindOption RestKinds[] = { + { TRUE, 'n', "namespace", "chapters"}, + { TRUE, 'm', "member", "sections" }, + { TRUE, 'd', "macro", "subsections" }, + { TRUE, 'v', "variable", "subsubsections" } +}; + +/* +* FUNCTION DEFINITIONS +*/ + +static void makeRestTag (const vString* const name, + kindOption* const kinds, const int kind) +{ + if (name != NULL && vStringLength (name) > 0) + { + tagEntryInfo e; + initTagEntry (&e, vStringValue (name)); + + e.lineNumber--; // we want the line before the '---' underline chars + e.kindName = kinds [kind].name; + e.kind = kinds [kind].letter; + + makeTagEntry (&e); + } +} + +static void findRestTags (void) +{ + vString *name = vStringNew (); + const unsigned char *line; + + while ((line = fileReadLine ()) != NULL) + { + if (strlen((const char*) line) > 3 && vStringLength(name) > 0) + if (! strstr((const char*) line, " ")) + { + if (strncmp((const char*) line, "===", 3) == 0) + { + makeRestTag(name, RestKinds, K_CHAPTER); + continue; + } + else if (strncmp((const char*) line, "---", 3) == 0) + { + makeRestTag(name, RestKinds, K_SECTION); + continue; + } + else if (strncmp((const char*) line, "^^^", 3) == 0) + { + makeRestTag(name, RestKinds, K_SUBSECTION); + continue; + } + else if (strncmp((const char*) line, "```", 3) == 0) + { + makeRestTag(name, RestKinds, K_SUBSUBSECTION); + continue; + } + } + vStringClear (name); + if (! isspace(*line)) + vStringCatS(name, (const char*) line); + vStringTerminate(name); + } + vStringDelete (name); +} + +extern parserDefinition* RestParser (void) +{ + static const char *const patterns [] = { "*.rest", "*.reST", NULL }; + static const char *const extensions [] = { "rest", NULL }; + parserDefinition* const def = parserNew ("reStructuredText"); + def->kinds = RestKinds; + def->kindCount = KIND_COUNT (RestKinds); + def->patterns = patterns; + def->extensions = extensions; + def->parser = findRestTags; + return def; +} + +/* vi:set tabstop=8 shiftwidth=4: */
Property changes on: trunk/tagmanager/rest.c ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.