SF.net SVN: geany:[4474] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Dec 7 17:51:41 UTC 2009


Revision: 4474
          http://geany.svn.sourceforge.net/geany/?rev=4474&view=rev
Author:   ntrel
Date:     2009-12-07 17:51:37 +0000 (Mon, 07 Dec 2009)

Log Message:
-----------
Apply patch from Kelvin Gardiner to add Verilog filetype (thanks).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/THANKS
    trunk/data/filetype_extensions.conf
    trunk/scintilla/KeyWords.cxx
    trunk/scintilla/Makefile.am
    trunk/scintilla/makefile.win32
    trunk/src/filetypes.c
    trunk/src/filetypes.h
    trunk/src/highlighting.c
    trunk/src/symbols.c
    trunk/tagmanager/Makefile.am
    trunk/tagmanager/makefile.win32
    trunk/tagmanager/parsers.h
    trunk/wscript

Added Paths:
-----------
    trunk/data/filetypes.verilog
    trunk/scintilla/LexVerilog.cxx
    trunk/tagmanager/verilog.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/ChangeLog	2009-12-07 17:51:37 UTC (rev 4474)
@@ -9,6 +9,13 @@
  * src/highlighting.c:
    Only show debug message once if recursive lexer_filetype is set.
    Tidy highlighting_init_styles code for filetype None handling.
+ * scintilla/makefile.win32, scintilla/KeyWords.cxx,
+   scintilla/LexVerilog.cxx, scintilla/Makefile.am, src/highlighting.c,
+   src/filetypes.c, src/filetypes.h, src/symbols.c, THANKS,
+   tagmanager/parsers.h, tagmanager/makefile.win32,
+   tagmanager/verilog.c, tagmanager/Makefile.am,
+   data/filetypes.verilog, data/filetype_extensions.conf, wscript:
+   Apply patch from Kelvin Gardiner to add Verilog filetype (thanks).
 
 
 2009-12-03  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/THANKS
===================================================================
--- trunk/THANKS	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/THANKS	2009-12-07 17:51:37 UTC (rev 4474)
@@ -72,7 +72,7 @@
 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
+Kelvin Gardiner <kelvin.mbmn.net> - VHDL symbol list patch, Verilog filetype
 
 Translators:
 ------------

Modified: trunk/data/filetype_extensions.conf
===================================================================
--- trunk/data/filetype_extensions.conf	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/data/filetype_extensions.conf	2009-12-07 17:51:37 UTC (rev 4474)
@@ -21,6 +21,7 @@
 Pascal=*.pas;*.pp;*.inc;*.dpr;*.dpk;
 Vala=*.vala;*.vapi;
 VHDL=*.vhd;*.vhdl;
+Verilog=*.v;
 Ferite=*.fe;
 Javascript=*.js;
 Lua=*.lua;

Added: trunk/data/filetypes.verilog
===================================================================
--- trunk/data/filetypes.verilog	                        (rev 0)
+++ trunk/data/filetypes.verilog	2009-12-07 17:51:37 UTC (rev 4474)
@@ -0,0 +1,47 @@
+# For complete documentation of this file, please see Geany's main documentation
+[styling]
+# foreground;background;bold;italic
+default=0xd3d7cf;0x2e3436;false;false
+comment=0x888a85;0x2e3436;false;false
+comment_line=0x888a85;0x2e3436;false;false
+comment_line_bang=0x888a85;0x2e3436;false;false;
+number=0xedd400;0x2e3436;false;false
+word=0xffffff;0x2e3436;true;false
+string=0xedd400;0x2e3436;false;false
+word2=0xad7fa8;0x2e3436;false;false
+word3=0x8ae234;0x2e3436;true;false
+preprocessor=0xad7fa8;0x2e3436;false;false
+operator=0xd3d7cf;0x2e3436;false;false
+identifier=0x729fcf;0x2e3436;false;false
+stringeol=0xffffff;0x2e3436;false;false
+userword=0xffffff;0x2e3436;true;false
+
+[keywords]
+# all items must be in one line
+word=always and assign attribute begin buf bufif0 bufif1 case casex casez cmos deassign default defparam disable edge else end endattribute endcase endfunction endmodule endprimitive endspecify endtable endtask event for force forever fork function highz0 highz1 if ifnone initial join medium module large macromodule nand negedge nmos nor not notif0 notif1 or parameter pmos posedge primitive pull0 pull1 pulldown pullup rcmos realtime release repeat rnmos rpmos rtran rtranif0 rtranif1 scalared signed small specify specparam strength strong0 strong1 supply0 supply1 table task tran tranif0 tranif1 tri tri0 tri1 triand trior trireg unsigned vectored wait wand weak0 weak1 while wor xnor xor @
+word2=$display $write $fdisplay $fwrite $strobe $fstrobe $monitor $fmonitor $time $realtime $finish $stop $setup $hold $width $setuphold $readmemb $readmemh $sreadmemb $sreadmemh $getpattern $history $save $restart $incsave $shm_open $shm_probe $shm_close $scale $showscopes $showvars
+word3=real integer time reg wire input output inout
+
+[settings]
+# default extension used when saving files
+extension=v
+
+# the following characters are these which a "word" can contains, see documentation
+#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
+
+# if only single comment char is supported like # in this file, leave comment_close blank
+comment_open=/*
+comment_close=*/
+
+# set to false if a comment character/string should start at column 0 of a line, true uses any
+# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d
+	#command_example();
+# setting to false would generate this
+#	command_example();
+# This setting works only for single line comments
+comment_use_indent=true
+
+# context action command (please see Geany's main documentation for details)
+context_action_cmd=
+
+


Property changes on: trunk/data/filetypes.verilog
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Modified: trunk/scintilla/KeyWords.cxx
===================================================================
--- trunk/scintilla/KeyWords.cxx	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/scintilla/KeyWords.cxx	2009-12-07 17:51:37 UTC (rev 4474)
@@ -172,6 +172,7 @@
 	LINK_LEXER(lmSQL);
 	LINK_LEXER(lmTCL);
 	LINK_LEXER(lmVHDL);
+	LINK_LEXER(lmVerilog);
 	LINK_LEXER(lmXML);
 	LINK_LEXER(lmYAML);
 

Added: trunk/scintilla/LexVerilog.cxx
===================================================================
--- trunk/scintilla/LexVerilog.cxx	                        (rev 0)
+++ trunk/scintilla/LexVerilog.cxx	2009-12-07 17:51:37 UTC (rev 4474)
@@ -0,0 +1,305 @@
+// Scintilla source code edit control
+/** @file LexVerilog.cxx
+ ** Lexer for Verilog.
+ ** Written by Avi Yegudin, based on C++ lexer by Neil Hodgson
+ **/
+// Copyright 1998-2002 by Neil Hodgson <neilh at scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(const int ch) {
+	return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\'');
+}
+
+static inline bool IsAWordStart(const int ch) {
+	return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '$');
+}
+
+static void ColouriseVerilogDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+                            Accessor &styler) {
+
+	WordList &keywords = *keywordlists[0];
+	WordList &keywords2 = *keywordlists[1];
+	WordList &keywords3 = *keywordlists[2];
+	WordList &keywords4 = *keywordlists[3];
+
+	// Do not leak onto next line
+	if (initStyle == SCE_V_STRINGEOL)
+		initStyle = SCE_V_DEFAULT;
+
+	StyleContext sc(startPos, length, initStyle, styler);
+
+	for (; sc.More(); sc.Forward()) {
+
+		if (sc.atLineStart && (sc.state == SCE_V_STRING)) {
+			// Prevent SCE_V_STRINGEOL from leaking back to previous line
+			sc.SetState(SCE_V_STRING);
+		}
+
+		// Handle line continuation generically.
+		if (sc.ch == '\\') {
+			if (sc.chNext == '\n' || sc.chNext == '\r') {
+				sc.Forward();
+				if (sc.ch == '\r' && sc.chNext == '\n') {
+					sc.Forward();
+				}
+				continue;
+			}
+		}
+
+		// Determine if the current state should terminate.
+		if (sc.state == SCE_V_OPERATOR) {
+			sc.SetState(SCE_V_DEFAULT);
+		} else if (sc.state == SCE_V_NUMBER) {
+			if (!IsAWordChar(sc.ch)) {
+				sc.SetState(SCE_V_DEFAULT);
+			}
+		} else if (sc.state == SCE_V_IDENTIFIER) {
+			if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
+				char s[100];
+                                sc.GetCurrent(s, sizeof(s));
+				if (keywords.InList(s)) {
+					sc.ChangeState(SCE_V_WORD);
+				} else if (keywords2.InList(s)) {
+					sc.ChangeState(SCE_V_WORD2);
+				} else if (keywords3.InList(s)) {
+					sc.ChangeState(SCE_V_WORD3);
+                                } else if (keywords4.InList(s)) {
+					sc.ChangeState(SCE_V_USER);
+				}
+				sc.SetState(SCE_V_DEFAULT);
+			}
+		} else if (sc.state == SCE_V_PREPROCESSOR) {
+                        if (!IsAWordChar(sc.ch)) {
+                                sc.SetState(SCE_V_DEFAULT);
+                        }
+		} else if (sc.state == SCE_V_COMMENT) {
+			if (sc.Match('*', '/')) {
+				sc.Forward();
+				sc.ForwardSetState(SCE_V_DEFAULT);
+			}
+		} else if (sc.state == SCE_V_COMMENTLINE || sc.state == SCE_V_COMMENTLINEBANG) {
+			if (sc.atLineStart) {
+				sc.SetState(SCE_V_DEFAULT);
+			}
+                } else if (sc.state == SCE_V_STRING) {
+			if (sc.ch == '\\') {
+				if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+					sc.Forward();
+				}
+			} else if (sc.ch == '\"') {
+				sc.ForwardSetState(SCE_V_DEFAULT);
+			} else if (sc.atLineEnd) {
+				sc.ChangeState(SCE_V_STRINGEOL);
+				sc.ForwardSetState(SCE_V_DEFAULT);
+			}
+		}
+
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_V_DEFAULT) {
+			if (IsADigit(sc.ch) || (sc.ch == '\'') || (sc.ch == '.' && IsADigit(sc.chNext))) {
+				sc.SetState(SCE_V_NUMBER);
+			} else if (IsAWordStart(sc.ch)) {
+				sc.SetState(SCE_V_IDENTIFIER);
+			} else if (sc.Match('/', '*')) {
+                                sc.SetState(SCE_V_COMMENT);
+				sc.Forward();	// Eat the * so it isn't used for the end of the comment
+			} else if (sc.Match('/', '/')) {
+				if (sc.Match("//!"))	// Nice to have a different comment style
+					sc.SetState(SCE_V_COMMENTLINEBANG);
+				else
+					sc.SetState(SCE_V_COMMENTLINE);
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_V_STRING);
+			} else if (sc.ch == '`') {
+				sc.SetState(SCE_V_PREPROCESSOR);
+				// Skip whitespace between ` and preprocessor word
+				do {
+					sc.Forward();
+				} while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
+				if (sc.atLineEnd) {
+					sc.SetState(SCE_V_DEFAULT);
+				}
+			} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '#') {
+				sc.SetState(SCE_V_OPERATOR);
+			}
+		}
+	}
+	sc.Complete();
+}
+
+static bool IsStreamCommentStyle(int style) {
+	return style == SCE_V_COMMENT;
+}
+
+// Store both the current line's fold level and the next lines in the
+// level store to make it easy to pick up with each increment
+// and to make it possible to fiddle the current level for "} else {".
+static void FoldNoBoxVerilogDoc(unsigned int startPos, int length, int initStyle,
+                            Accessor &styler) {
+	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+	bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
+	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+	bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
+        // Verilog specific folding options:
+        // fold_at_module -
+        //      Generally used methodology in verilog code is
+        //      one module per file, so folding at module definition is useless.
+        // fold_at_brace/parenthese -
+        //      Folding of long port lists can be convenient.
+	bool foldAtModule = styler.GetPropertyInt("fold.verilog.flags", 0) != 0;
+	bool foldAtBrace  = 1;
+	bool foldAtParenthese  = 1;
+
+	unsigned int endPos = startPos + length;
+	int visibleChars = 0;
+	int lineCurrent = styler.GetLine(startPos);
+	int levelCurrent = SC_FOLDLEVELBASE;
+	if (lineCurrent > 0)
+		levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+	int levelMinCurrent = levelCurrent;
+	int levelNext = levelCurrent;
+	char chNext = styler[startPos];
+	int styleNext = styler.StyleAt(startPos);
+	int style = initStyle;
+	for (unsigned int i = startPos; i < endPos; i++) {
+		char ch = chNext;
+		chNext = styler.SafeGetCharAt(i + 1);
+		int stylePrev = style;
+		style = styleNext;
+		styleNext = styler.StyleAt(i + 1);
+		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+		if (foldComment && IsStreamCommentStyle(style)) {
+			if (!IsStreamCommentStyle(stylePrev)) {
+				levelNext++;
+			} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
+				// Comments don't end at end of line and the next character may be unstyled.
+				levelNext--;
+			}
+		}
+		if (foldComment && (style == SCE_V_COMMENTLINE)) {
+			if ((ch == '/') && (chNext == '/')) {
+				char chNext2 = styler.SafeGetCharAt(i + 2);
+				if (chNext2 == '{') {
+					levelNext++;
+				} else if (chNext2 == '}') {
+					levelNext--;
+				}
+			}
+		}
+		if (foldPreprocessor && (style == SCE_V_PREPROCESSOR)) {
+			if (ch == '`') {
+				unsigned int j = i + 1;
+				while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
+					j++;
+				}
+				if (styler.Match(j, "if")) {
+					levelNext++;
+				} else if (styler.Match(j, "end")) {
+					levelNext--;
+				}
+			}
+		}
+                if (style == SCE_V_OPERATOR) {
+                    if (foldAtParenthese) {
+			if (ch == '(') {
+				levelNext++;
+			} else if (ch == ')') {
+				levelNext--;
+			}
+                    }
+		}
+                if (style == SCE_V_OPERATOR) {
+                    if (foldAtBrace) {
+			if (ch == '{') {
+				levelNext++;
+			} else if (ch == '}') {
+				levelNext--;
+			}
+                    }
+		}
+                if (style == SCE_V_WORD && stylePrev != SCE_V_WORD) {
+                        unsigned int j = i;
+                        if (styler.Match(j, "case") ||
+                            styler.Match(j, "casex") ||
+                            styler.Match(j, "casez") ||
+                            styler.Match(j, "function") ||
+                            styler.Match(j, "fork") ||
+                            styler.Match(j, "table") ||
+                            styler.Match(j, "task") ||
+                            styler.Match(j, "generate") ||
+                            styler.Match(j, "specify") ||
+                            styler.Match(j, "primitive") ||
+                            (styler.Match(j, "module") && foldAtModule) ||
+                            styler.Match(j, "begin")) {
+                                levelNext++;
+                        } else if (styler.Match(j, "endcase") ||
+                                   styler.Match(j, "endfunction") ||
+                                   styler.Match(j, "join") ||
+                                   styler.Match(j, "endtask") ||
+                                   styler.Match(j, "endgenerate") ||
+                                   styler.Match(j, "endtable") ||
+                                   styler.Match(j, "endspecify") ||
+                                   styler.Match(j, "endprimitive") ||
+                                   (styler.Match(j, "endmodule") && foldAtModule) ||
+                                   (styler.Match(j, "end") && !IsAWordChar(styler.SafeGetCharAt(j+3)))) {
+                                levelNext--;
+                        }
+		}
+		if (atEOL) {
+			int levelUse = levelCurrent;
+			if (foldAtElse) {
+				levelUse = levelMinCurrent;
+			}
+			int lev = levelUse | levelNext << 16;
+			if (visibleChars == 0 && foldCompact)
+				lev |= SC_FOLDLEVELWHITEFLAG;
+			if (levelUse < levelNext)
+				lev |= SC_FOLDLEVELHEADERFLAG;
+			if (lev != styler.LevelAt(lineCurrent)) {
+				styler.SetLevel(lineCurrent, lev);
+			}
+			lineCurrent++;
+			levelCurrent = levelNext;
+			levelMinCurrent = levelCurrent;
+			visibleChars = 0;
+		}
+		if (!isspacechar(ch))
+			visibleChars++;
+	}
+}
+
+static void FoldVerilogDoc(unsigned int startPos, int length, int initStyle, WordList *[],
+                       Accessor &styler) {
+	FoldNoBoxVerilogDoc(startPos, length, initStyle, styler);
+}
+
+static const char * const verilogWordLists[] = {
+            "Primary keywords and identifiers",
+            "Secondary keywords and identifiers",
+            "System Tasks",
+            "User defined tasks and identifiers",
+            "Unused",
+            0,
+        };
+
+
+LexerModule lmVerilog(SCLEX_VERILOG, ColouriseVerilogDoc, "verilog", FoldVerilogDoc, verilogWordLists);


Property changes on: trunk/scintilla/LexVerilog.cxx
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Modified: trunk/scintilla/Makefile.am
===================================================================
--- trunk/scintilla/Makefile.am	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/scintilla/Makefile.am	2009-12-07 17:51:37 UTC (rev 4474)
@@ -32,6 +32,7 @@
 LexSQL.cxx \
 LexTCL.cxx \
 LexVHDL.cxx \
+LexVerilog.cxx \
 LexYAML.cxx
 
 SRCS= \

Modified: trunk/scintilla/makefile.win32
===================================================================
--- trunk/scintilla/makefile.win32	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/scintilla/makefile.win32	2009-12-07 17:51:37 UTC (rev 4474)
@@ -61,7 +61,7 @@
 #**LEXOBJS=\\\n\(\*.o \)
 LEXOBJS=\
 LexAda.o LexBash.o LexAsm.o LexCSS.o LexCPP.o LexCrontab.o LexHTML.o LexOthers.o LexPascal.o \
-LexPerl.o LexPython.o LexSQL.o LexCaml.o LexTCL.o LexRuby.o LexFortran.o LexVHDL.o \
+LexPerl.o LexPython.o LexSQL.o LexCaml.o LexTCL.o LexRuby.o LexFortran.o LexVHDL.o LexVerilog.o\
 LexMarkdown.o LexMatlab.o \
 LexD.o LexLua.o LexHaskell.o LexBasic.o LexR.o LexYAML.o LexCmake.o LexNsis.o
 #--Autogenerated -- end of automatically generated section

Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/src/filetypes.c	2009-12-07 17:51:37 UTC (rev 4474)
@@ -504,6 +504,17 @@
 	ft->comment_open = g_strdup("--");
 	ft->comment_close = NULL;
 	ft->group = GEANY_FILETYPE_GROUP_COMPILED;
+	
+#define VERILOG
+	ft = filetypes[GEANY_FILETYPES_VERILOG];
+	ft->lang = 39;
+	ft->name = g_strdup("Verilog");
+	filetype_make_title(ft, TITLE_SOURCE_FILE);
+	ft->extension = g_strdup("v");
+	ft->pattern = utils_strv_new("*.v", "*.verilog", NULL);
+	ft->comment_open = g_strdup("/*");
+	ft->comment_close = g_strdup("*/");
+	ft->group = GEANY_FILETYPE_GROUP_COMPILED;
 
 #define DIFF
 	ft = filetypes[GEANY_FILETYPES_DIFF];

Modified: trunk/src/filetypes.h
===================================================================
--- trunk/src/filetypes.h	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/src/filetypes.h	2009-12-07 17:51:37 UTC (rev 4474)
@@ -83,6 +83,7 @@
 	GEANY_FILETYPES_MARKDOWN,
 	GEANY_FILETYPES_TXT2TAGS,
 	GEANY_FILETYPES_ABC,
+	GEANY_FILETYPES_VERILOG,
 	/* ^ append items here */
 	GEANY_MAX_BUILT_IN_FILETYPES	/* Don't use this, use filetypes_array->len instead */
 }

Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/src/highlighting.c	2009-12-07 17:51:37 UTC (rev 4474)
@@ -2698,6 +2698,59 @@
 }
 
 
+static void styleset_verilog_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
+{
+	new_styleset(ft_id, 14);
+
+	get_keyfile_style(config, config_home, "default", &style_sets[ft_id].styling[0]);
+	get_keyfile_style(config, config_home, "comment", &style_sets[ft_id].styling[1]);
+	get_keyfile_style(config, config_home, "comment_line", &style_sets[ft_id].styling[2]);
+	get_keyfile_style(config, config_home, "comment_line_bang", &style_sets[ft_id].styling[3]);
+	get_keyfile_style(config, config_home, "number", &style_sets[ft_id].styling[4]);
+	get_keyfile_style(config, config_home, "word", &style_sets[ft_id].styling[5]);
+	get_keyfile_style(config, config_home, "string", &style_sets[ft_id].styling[6]);
+	get_keyfile_style(config, config_home, "word2", &style_sets[ft_id].styling[7]);
+	get_keyfile_style(config, config_home, "word3", &style_sets[ft_id].styling[8]);
+	get_keyfile_style(config, config_home, "preprocessor", &style_sets[ft_id].styling[9]);
+	get_keyfile_style(config, config_home, "operator", &style_sets[ft_id].styling[10]);
+	get_keyfile_style(config, config_home, "identifier", &style_sets[ft_id].styling[11]);
+	get_keyfile_style(config, config_home, "stringeol", &style_sets[ft_id].styling[12]);
+	get_keyfile_style(config, config_home, "userword", &style_sets[ft_id].styling[13]);
+
+	style_sets[ft_id].keywords = g_new(gchar*, 4);
+	get_keyfile_keywords(config, config_home, "word", ft_id, 0);
+	get_keyfile_keywords(config, config_home, "word2", ft_id, 1);
+	get_keyfile_keywords(config, config_home, "word3", ft_id, 2);
+	style_sets[ft_id].keywords[3] = NULL;
+}
+
+
+static void styleset_verilog(ScintillaObject *sci, gint ft_id)
+{
+	apply_filetype_properties(sci, SCLEX_VERILOG, ft_id);
+
+	sci_set_keywords(sci, 0, style_sets[ft_id].keywords[0]);
+	sci_set_keywords(sci, 1, style_sets[ft_id].keywords[1]);
+	sci_set_keywords(sci, 2, style_sets[ft_id].keywords[2]);
+
+	set_sci_style(sci, STYLE_DEFAULT, ft_id, 0);
+	set_sci_style(sci, SCE_V_DEFAULT, ft_id, 0);
+	set_sci_style(sci, SCE_V_COMMENT, ft_id, 1);
+	set_sci_style(sci, SCE_V_COMMENTLINE, ft_id, 2);
+	set_sci_style(sci, SCE_V_COMMENTLINEBANG, ft_id, 3);
+	set_sci_style(sci, SCE_V_NUMBER, ft_id, 4);
+	set_sci_style(sci, SCE_V_WORD, ft_id,5);
+	set_sci_style(sci, SCE_V_STRING, ft_id, 6);
+	set_sci_style(sci, SCE_V_WORD2, ft_id, 7);
+	set_sci_style(sci, SCE_V_WORD3, ft_id, 8);
+	set_sci_style(sci, SCE_V_PREPROCESSOR, ft_id, 9);
+	set_sci_style(sci, SCE_V_OPERATOR, ft_id, 10);
+	set_sci_style(sci, SCE_V_IDENTIFIER, ft_id, 11);
+	set_sci_style(sci, SCE_V_STRINGEOL, ft_id, 12);
+	set_sci_style(sci, SCE_V_USER, ft_id, 13);
+}
+
+
 static void styleset_yaml_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
 {
 	new_styleset(ft_id, 10);
@@ -3113,6 +3166,7 @@
 		init_styleset_case(GEANY_FILETYPES_SQL,		styleset_sql_init);
 		init_styleset_case(GEANY_FILETYPES_TCL,		styleset_tcl_init);
 		init_styleset_case(GEANY_FILETYPES_VHDL,	styleset_vhdl_init);
+		init_styleset_case(GEANY_FILETYPES_VERILOG,	styleset_verilog_init);
 		init_styleset_case(GEANY_FILETYPES_XML,		styleset_markup_init);
 		init_styleset_case(GEANY_FILETYPES_YAML,	styleset_yaml_init);
 		default:
@@ -3181,6 +3235,7 @@
 		styleset_case(GEANY_FILETYPES_SQL,		styleset_sql);
 		styleset_case(GEANY_FILETYPES_TCL,		styleset_tcl);
 		styleset_case(GEANY_FILETYPES_VHDL,		styleset_vhdl);
+		styleset_case(GEANY_FILETYPES_VERILOG,	styleset_verilog);
 		styleset_case(GEANY_FILETYPES_XML,		styleset_xml);
 		styleset_case(GEANY_FILETYPES_YAML,		styleset_yaml);
 		case GEANY_FILETYPES_NONE:

Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/src/symbols.c	2009-12-07 17:51:37 UTC (rev 4474)
@@ -758,6 +758,17 @@
 				NULL);
 			break;
 		}
+		case GEANY_FILETYPES_VERILOG:
+		{
+			tag_list_add_groups(tag_store,
+				&(tv_iters.tag_type), _("Events"), "classviewer-macro",
+				&(tv_iters.tag_class), _("Modules"), "classviewer-class",
+				&(tv_iters.tag_function), _("Functions / Tasks"), "classviewer-method",
+				&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
+				&(tv_iters.tag_other), _("Other"), "classviewer-other",
+				NULL);
+			break;
+		}
 		case GEANY_FILETYPES_JAVA:
 		{
 			tag_list_add_groups(tag_store,

Modified: trunk/tagmanager/Makefile.am
===================================================================
--- trunk/tagmanager/Makefile.am	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/tagmanager/Makefile.am	2009-12-07 17:51:37 UTC (rev 4474)
@@ -64,6 +64,7 @@
 	sh.c\
 	txt2tags.c\
 	vhdl.c\
+	verilog.c\
 	actionscript.c\
 	nsis.c\
 	ctags.c\

Modified: trunk/tagmanager/makefile.win32
===================================================================
--- trunk/tagmanager/makefile.win32	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/tagmanager/makefile.win32	2009-12-07 17:51:37 UTC (rev 4474)
@@ -39,7 +39,7 @@
 clean:
 	-$(RM) deps.mak *.o $(COMPLIB)
 
-$(COMPLIB): abc.o args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o diff.o vhdl.o lua.o js.o \
+$(COMPLIB): abc.o args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o diff.o vhdl.o verilog.o lua.o js.o \
 actionscript.o nsis.o \
 haskell.o haxe.o html.o python.o lregex.o rest.o sh.o ctags.o entry.o get.o keyword.o nestlevel.o \
 options.o \

Modified: trunk/tagmanager/parsers.h
===================================================================
--- trunk/tagmanager/parsers.h	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/tagmanager/parsers.h	2009-12-07 17:51:37 UTC (rev 4474)
@@ -53,7 +53,8 @@
     NsisParser, \
     MarkdownParser, \
     Txt2tagsParser, \
-    AbcParser
+    AbcParser, \
+    VerilogParser
 /*
 langType of each parser
  0	CParser
@@ -95,6 +96,7 @@
 36  MarkdownParser
 37  Txt2tagsParser
 38  AbcParser
+39  Verilog
 */
 #endif	/* _PARSERS_H */
 

Added: trunk/tagmanager/verilog.c
===================================================================
--- trunk/tagmanager/verilog.c	                        (rev 0)
+++ trunk/tagmanager/verilog.c	2009-12-07 17:51:37 UTC (rev 4474)
@@ -0,0 +1,339 @@
+/*
+*   $Id$
+*
+*   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 the Verilog HDL
+*   (Hardware Description Language).
+*
+*   Language definition documents:
+*       http://www.eg.bucknell.edu/~cs320/verilog/verilog-manual.html
+*       http://www.sutherland-hdl.com/on-line_ref_guide/vlog_ref_top.html
+*       http://www.verilog.com/VerilogBNF.html
+*       http://eesun.free.fr/DOC/VERILOG/verilog_manual1.html
+*/
+
+/*
+ *   INCLUDE FILES
+ */
+#include "general.h"  /* must always come first */
+
+#include <string.h>
+#include <setjmp.h>
+
+#include "keyword.h"
+#include "parse.h"
+#include "read.h"
+#include "vstring.h"
+#include "get.h"
+
+/*
+ *   DATA DECLARATIONS
+ */
+typedef enum eException { ExceptionNone, ExceptionEOF } exception_t;
+
+typedef enum {
+	K_UNDEFINED = -1,
+	K_CONSTANT,
+	K_EVENT,
+	K_FUNCTION,
+	K_MODULE,
+	K_NET,
+	K_PORT,
+	K_REGISTER,
+	K_TASK
+} verilogKind;
+
+typedef struct {
+	const char *keyword;
+	verilogKind kind;
+} keywordAssoc;
+
+/*
+ *   DATA DEFINITIONS
+ */
+static int Ungetc;
+static int Lang_verilog;
+static jmp_buf Exception;
+
+static kindOption VerilogKinds [] = {
+ { TRUE, 'c', "variable",  "constants (define, parameter, specparam)" },
+ { TRUE, 'e', "typedef",     "events" },
+ { TRUE, 'f', "function",  "functions" },
+ { TRUE, 'm', "class",    "modules" },
+ { TRUE, 'n', "variable",  "net data types" },
+ { TRUE, 'p', "variable",  "ports" },
+ { TRUE, 'r', "variable",  "register data types" },
+ { TRUE, 't', "function",  "tasks" }
+};
+
+static keywordAssoc VerilogKeywordTable [] = {
+	{ "`define",   K_CONSTANT },
+	{ "event",     K_EVENT },
+	{ "function",  K_FUNCTION },
+	{ "inout",     K_PORT },
+	{ "input",     K_PORT },
+	{ "integer",   K_REGISTER },
+	{ "module",    K_MODULE },
+	{ "output",    K_PORT },
+	{ "parameter", K_CONSTANT },
+	{ "real",      K_REGISTER },
+	{ "realtime",  K_REGISTER },
+	{ "reg",       K_REGISTER },
+	{ "specparam", K_CONSTANT },
+	{ "supply0",   K_NET },
+	{ "supply1",   K_NET },
+	{ "task",      K_TASK },
+	{ "time",      K_REGISTER },
+	{ "tri0",      K_NET },
+	{ "tri1",      K_NET },
+	{ "triand",    K_NET },
+	{ "tri",       K_NET },
+	{ "trior",     K_NET },
+	{ "trireg",    K_NET },
+	{ "wand",      K_NET },
+	{ "wire",      K_NET },
+	{ "wor",       K_NET }
+};
+
+/*
+ *   FUNCTION DEFINITIONS
+ */
+
+static void initialize (const langType language)
+{
+	size_t i;
+	const size_t count =
+			sizeof (VerilogKeywordTable) / sizeof (VerilogKeywordTable [0]);
+	Lang_verilog = language;
+	for (i = 0  ;  i < count  ;  ++i)
+	{
+		const keywordAssoc* const p = &VerilogKeywordTable [i];
+		addKeyword (p->keyword, language, (int) p->kind);
+	}
+}
+
+static void vUngetc (int c)
+{
+	Assert (Ungetc == '\0');
+	Ungetc = c;
+}
+
+static int vGetc (void)
+{
+	int c;
+	if (Ungetc == '\0')
+		c = fileGetc ();
+	else
+	{
+		c = Ungetc;
+		Ungetc = '\0';
+	}
+	if (c == '/')
+	{
+		int c2 = fileGetc ();
+		if (c2 == EOF)
+			longjmp (Exception, (int) ExceptionEOF);
+		else if (c2 == '/')  /* strip comment until end-of-line */
+		{
+			do
+				c = fileGetc ();
+			while (c != '\n'  &&  c != EOF);
+		}
+		else if (c2 == '*')  /* strip block comment */
+		{
+			c = skipOverCComment();
+		}
+		else
+		{
+			fileUngetc (c2);
+		}
+	}
+	else if (c == '"')  /* strip string contents */
+	{
+		int c2;
+		do
+			c2 = fileGetc ();
+		while (c2 != '"'  &&  c2 != EOF);
+		c = '@';
+	}
+	if (c == EOF)
+		longjmp (Exception, (int) ExceptionEOF);
+	return c;
+}
+
+static boolean isIdentifierCharacter (const int c)
+{
+	return (boolean)(isalnum (c)  ||  c == '_'  ||  c == '`');
+}
+
+static int skipWhite (int c)
+{
+	while (isspace (c))
+		c = vGetc ();
+	return c;
+}
+
+static int skipPastMatch (const char *const pair)
+{
+	const int begin = pair [0], end = pair [1];
+	int matchLevel = 1;
+	int c;
+	do
+	{
+		c = vGetc ();
+		if (c == begin)
+			++matchLevel;
+		else if (c == end)
+			--matchLevel;
+	}
+	while (matchLevel > 0);
+	return vGetc ();
+}
+
+static boolean readIdentifier (vString *const name, int c)
+{
+	vStringClear (name);
+	if (isIdentifierCharacter (c))
+	{
+		while (isIdentifierCharacter (c))
+		{
+			vStringPut (name, c);
+			c = vGetc ();
+		}
+		vUngetc (c);
+		vStringTerminate (name);
+	}
+	return (boolean)(name->length > 0);
+}
+
+static void tagNameList (const verilogKind kind, int c)
+{
+	vString *name = vStringNew ();
+	boolean repeat;
+	Assert (isIdentifierCharacter (c));
+	do
+	{
+		repeat = FALSE;
+		if (isIdentifierCharacter (c))
+		{
+			readIdentifier (name, c);
+			makeSimpleTag (name, VerilogKinds, kind);
+		}
+		else
+			break;
+		c = skipWhite (vGetc ());
+		if (c == '[')
+			c = skipPastMatch ("[]");
+		c = skipWhite (c);
+		if (c == '=')
+		{
+			if (c == '{')
+				skipPastMatch ("{}");
+			else
+			{
+				do
+					c = vGetc ();
+				while (c != ','  &&  c != ';');
+			}
+		}
+		if (c == ',')
+		{
+			c = skipWhite (vGetc ());
+			repeat = TRUE;
+		}
+		else
+			repeat = FALSE;
+	} while (repeat);
+	vStringDelete (name);
+	vUngetc (c);
+}
+
+static void findTag (vString *const name)
+{
+	const verilogKind kind = (verilogKind) lookupKeyword (vStringValue (name), Lang_verilog);
+	if (kind == K_CONSTANT && vStringItem (name, 0) == '`')
+	{
+		/* Bug #961001: Verilog compiler directives are line-based. */
+		int c = skipWhite (vGetc ());
+		readIdentifier (name, c);
+		makeSimpleTag (name, VerilogKinds, kind);
+		/* Skip the rest of the line. */
+		do {
+			c = vGetc();
+		} while (c != '\n');
+		vUngetc (c);
+	}
+	else if (kind != K_UNDEFINED)
+	{
+		int c = skipWhite (vGetc ());
+
+		/* Many keywords can have bit width.
+		*   reg [3:0] net_name;
+		*   inout [(`DBUSWIDTH-1):0] databus;
+		*/
+		if (c == '(')
+			c = skipPastMatch ("()");
+		c = skipWhite (c);
+		if (c == '[')
+			c = skipPastMatch ("[]");
+		c = skipWhite (c);
+		if (c == '#')
+		{
+			c = vGetc ();
+			if (c == '(')
+				c = skipPastMatch ("()");
+		}
+		c = skipWhite (c);
+		if (isIdentifierCharacter (c))
+			tagNameList (kind, c);
+	}
+}
+
+static void findVerilogTags (void)
+{
+	vString *const name = vStringNew ();
+	volatile boolean newStatement = TRUE;
+	volatile int c = '\0';
+	exception_t exception = (exception_t) setjmp (Exception);
+
+	if (exception == ExceptionNone) while (c != EOF)
+	{
+		c = vGetc ();
+		switch (c)
+		{
+			case ';':
+			case '\n':
+				newStatement = TRUE;
+				break;
+
+			case ' ':
+			case '\t':
+				break;
+
+			default:
+				if (newStatement && readIdentifier (name, c))
+					findTag (name);
+				newStatement = FALSE;
+				break;
+		}
+	}
+	vStringDelete (name);
+}
+
+extern parserDefinition* VerilogParser (void)
+{
+	static const char *const extensions [] = { "v", NULL };
+	parserDefinition* def = parserNew ("Verilog");
+	def->kinds      = VerilogKinds;
+	def->kindCount  = KIND_COUNT (VerilogKinds);
+	def->extensions = extensions;
+	def->parser     = findVerilogTags;
+	def->initialize = initialize;
+	return def;
+}
+
+/* vi:set tabstop=4 shiftwidth=4: */


Property changes on: trunk/tagmanager/verilog.c
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Modified: trunk/wscript
===================================================================
--- trunk/wscript	2009-12-07 17:23:33 UTC (rev 4473)
+++ trunk/wscript	2009-12-07 17:51:37 UTC (rev 4474)
@@ -76,7 +76,7 @@
 	'tagmanager/tm_file_entry.c',
 	'tagmanager/tm_project.c', 'tagmanager/tm_source_file.c', 'tagmanager/tm_symbol.c',
 	'tagmanager/tm_tag.c', 'tagmanager/tm_tagmanager.c', 'tagmanager/tm_work_object.c',
-	'tagmanager/tm_workspace.c', 'tagmanager/vhdl.c', 'tagmanager/vstring.c' ]
+	'tagmanager/tm_workspace.c', 'tagmanager/vhdl.c', 'tagmanager/verilog.c', 'tagmanager/vstring.c' ]
 
 scintilla_sources = [
 	'scintilla/AutoComplete.cxx', 'scintilla/CallTip.cxx', 'scintilla/CellBuffer.cxx',
@@ -93,7 +93,7 @@
 	'scintilla/LexPascal.cxx', 'scintilla/LexPerl.cxx', 'scintilla/LexPython.cxx',
 	'scintilla/LexR.cxx',
 	'scintilla/LexRuby.cxx', 'scintilla/LexSQL.cxx', 'scintilla/LexTCL.cxx',
-	'scintilla/LexVHDL.cxx', 'scintilla/LexYAML.cxx',
+	'scintilla/LexVHDL.cxx', 'scintilla/LexVerilog.cxx', 'scintilla/LexYAML.cxx',
 	'scintilla/LineMarker.cxx', 'scintilla/PerLine.cxx',
 	'scintilla/PlatGTK.cxx',
 	'scintilla/PositionCache.cxx', 'scintilla/PropSet.cxx', 'scintilla/RESearch.cxx',


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