SF.net SVN: geany: [991] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Mon Nov 13 22:11:43 UTC 2006


Revision: 991
          http://svn.sourceforge.net/geany/?rev=991&view=rev
Author:   eht16
Date:     2006-11-13 14:11:19 -0800 (Mon, 13 Nov 2006)

Log Message:
-----------
Added new filetype VHDL.

Modified Paths:
--------------
    trunk/ChangeLog
    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/highlighting.h
    trunk/src/treeviews.c
    trunk/tagmanager/Makefile.am
    trunk/tagmanager/makefile.win32
    trunk/tagmanager/parsers.h

Added Paths:
-----------
    trunk/data/filetypes.vhdl
    trunk/scintilla/LexVHDL.cxx
    trunk/tagmanager/vhdl.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/ChangeLog	2006-11-13 22:11:19 UTC (rev 991)
@@ -1,3 +1,14 @@
+2006-11-13  Enrico Tröger  <enrico.troeger at uvena.de>
+
+ * src/filetypes.c, src/filetypes.h, src/highlighting.c,
+   src/highlighting.h, src/treeviews.c, scintilla/Makefile.am,
+   scintilla/makefile.win32, scintilla/KeyWords.cxx,
+   scintilla/LexVHDL.cxx, tagmanager/vhdl.c, tagmanager/parsers.h,
+   tagmanager/Makefile.am, tagmanager/makefile.win32,
+   data/filetype_extensions.conf, data/filetypes.vhdl:
+   Added new filetype VHDL.
+
+
 2006-11-13  Nick Treleaven  <nick.treleaven at btinternet.com>
 
  * src/sci_cb.c: Fix invalid memory read in sci_cb_get_indent().

Modified: trunk/data/filetype_extensions.conf
===================================================================
--- trunk/data/filetype_extensions.conf	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/data/filetype_extensions.conf	2006-11-13 22:11:19 UTC (rev 991)
@@ -25,6 +25,7 @@
 SQL=*.sql;
 LaTeX=*.tex;*.sty;*.idx;
 O-Matrix=*.oms;
+VHDL=*.vhd;*.vhdl;
 Diff=*.diff;*.patch;
 Conf=*.conf;*.ini;config;*rc;*.cfg;
 None=*;

Added: trunk/data/filetypes.vhdl
===================================================================
--- trunk/data/filetypes.vhdl	                        (rev 0)
+++ trunk/data/filetypes.vhdl	2006-11-13 22:11:19 UTC (rev 991)
@@ -0,0 +1,46 @@
+# For complete documentation of this file, please see Geany's main documentation
+[styling]
+# foreground;background;bold;italic
+default=0x000000;0xffffff;false;false
+comment=0xd00000;0xffffff;false;false
+comment_line_bang=0x3f5fbf;0xffffff;false;false;
+number=0x007f00=0xffffff;false;false
+string=0xff901e=0xffffff;false;false
+operator=0x301010;0xffffff;false;false
+identifier=0x000000;0xffffff;false;false
+stringeol=0x000000;0xe0c0e0;false;false
+keyword=0x001a7f;0xffffff;true;false
+stdoperator=0x007f7f;0xffffff;false;false
+attribute=0x804020;0xffffff;false;false
+stdfunction=0x808020;0xffffff;true;false
+stdpackage=0x208020;0xffffff;false;false
+stdtype=0x208080;0xffffff;false;false
+userword=0x804020;0xffffff;true;false
+
+[keywords]
+# all items must be in one line
+keywords=access after alias all architecture array assert attribute begin block body buffer bus case component configuration constant disconnect downto else elsif end entity exit file for function generate generic group guarded if impure in inertial inout is label library linkage literal loop map new next null of on open others out package port postponed procedure process pure range record register reject report return select severity shared signal subtype then to transport type unaffected units until use variable wait when while with
+operators=abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor
+attributes=left right low high ascending image value pos val succ pred leftof rightof base range reverse_range length delayed stable quiet transaction event active last_event last_active last_value driving driving_value simple_name path_name instance_name
+std_functions=now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left rotate_right resize to_integer to_unsigned to_signed std_match to_01
+std_packages=std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives vital_timing
+std_types=boolean bit character severity_level integer real time delay_length natural positive string bit_vector file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic std_logic_vector X01 X01Z UX01 UX01Z unsigned signed
+userwords=
+
+[settings]
+# 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
+# indention 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
+
+

Modified: trunk/scintilla/KeyWords.cxx
===================================================================
--- trunk/scintilla/KeyWords.cxx	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/scintilla/KeyWords.cxx	2006-11-13 22:11:19 UTC (rev 991)
@@ -165,6 +165,7 @@
 	LINK_LEXER(lmRuby);
 	LINK_LEXER(lmSQL);
 	LINK_LEXER(lmTCL);
+	LINK_LEXER(lmVHDL);
 
 //--Autogenerated -- end of automatically generated section
 

Added: trunk/scintilla/LexVHDL.cxx
===================================================================
--- trunk/scintilla/LexVHDL.cxx	                        (rev 0)
+++ trunk/scintilla/LexVHDL.cxx	2006-11-13 22:11:19 UTC (rev 991)
@@ -0,0 +1,473 @@
+// Scintilla source code edit control
+/** @file LexVHDL.cxx
+ ** Lexer for VHDL
+ ** Written by Phil Reid, 
+ ** Based on:
+ **  - The Verilog Lexer by Avi Yegudin 
+ **  - The Fortran Lexer by Chuan-jian Shen
+ **  - The 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"
+
+static void ColouriseVHDLDoc(
+  unsigned int startPos,
+  int length,
+  int initStyle,
+  WordList *keywordlists[],
+  Accessor &styler);
+
+
+/***************************************/
+static inline bool IsAWordChar(const int ch) {
+  return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' );
+}
+
+/***************************************/
+static inline bool IsAWordStart(const int ch) {
+  return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+/***************************************/
+inline bool IsABlank(unsigned int ch) {
+    return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ;
+}
+
+/***************************************/
+static void ColouriseVHDLDoc(
+  unsigned int startPos,
+  int length,
+  int initStyle,
+  WordList *keywordlists[],
+  Accessor &styler)
+{
+  WordList &Keywords   = *keywordlists[0];
+  WordList &Operators  = *keywordlists[1];
+  WordList &Attributes = *keywordlists[2];
+  WordList &Functions  = *keywordlists[3];
+  WordList &Packages   = *keywordlists[4];
+  WordList &Types      = *keywordlists[5];
+  WordList &User       = *keywordlists[6];
+
+  StyleContext sc(startPos, length, initStyle, styler);
+
+  for (; sc.More(); sc.Forward())
+  {
+
+    // Determine if the current state should terminate.
+    if (sc.state == SCE_VHDL_OPERATOR) {
+      sc.SetState(SCE_VHDL_DEFAULT);
+    } else if (sc.state == SCE_VHDL_NUMBER) {
+      if (!IsAWordChar(sc.ch) && (sc.ch != '#')) {
+        sc.SetState(SCE_VHDL_DEFAULT);
+      }
+    } else if (sc.state == SCE_VHDL_IDENTIFIER) {
+      if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
+        char s[100];
+        sc.GetCurrentLowered(s, sizeof(s));
+        if (Keywords.InList(s)) {
+          sc.ChangeState(SCE_VHDL_KEYWORD);
+        } else if (Operators.InList(s)) {
+          sc.ChangeState(SCE_VHDL_STDOPERATOR);
+        } else if (Attributes.InList(s)) {
+          sc.ChangeState(SCE_VHDL_ATTRIBUTE);
+        } else if (Functions.InList(s)) {
+          sc.ChangeState(SCE_VHDL_STDFUNCTION);
+        } else if (Packages.InList(s)) {
+          sc.ChangeState(SCE_VHDL_STDPACKAGE);
+        } else if (Types.InList(s)) {
+          sc.ChangeState(SCE_VHDL_STDTYPE);
+        } else if (User.InList(s)) {
+          sc.ChangeState(SCE_VHDL_USERWORD);
+        }
+        sc.SetState(SCE_VHDL_DEFAULT);
+      }
+    } else if (sc.state == SCE_VHDL_COMMENT || sc.state == SCE_V_COMMENTLINEBANG) {
+      if (sc.atLineEnd) {
+        sc.SetState(SCE_VHDL_DEFAULT);
+      }
+    } else if (sc.state == SCE_VHDL_STRING) {
+      if (sc.ch == '\\') {
+        if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+          sc.Forward();
+        }
+      } else if (sc.ch == '\"') {
+        sc.ForwardSetState(SCE_VHDL_DEFAULT);
+      } else if (sc.atLineEnd) {
+        sc.ChangeState(SCE_V_STRINGEOL);
+        sc.ForwardSetState(SCE_VHDL_DEFAULT);
+      }
+    }
+
+    // Determine if a new state should be entered.
+    if (sc.state == SCE_VHDL_DEFAULT) {
+      if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+        sc.SetState(SCE_VHDL_NUMBER);
+      } else if (IsAWordStart(sc.ch)) {
+        sc.SetState(SCE_VHDL_IDENTIFIER);
+      } else if (sc.Match('-', '-')) {
+        sc.SetState(SCE_VHDL_COMMENT);
+        sc.Forward(); 
+      } else if (sc.Match('-', '-')) {
+        if (sc.Match("--!"))  // Nice to have a different comment style
+          sc.SetState(SCE_VHDL_COMMENTLINEBANG);
+        else
+          sc.SetState(SCE_VHDL_COMMENT);
+      } else if (sc.ch == '\"') {
+        sc.SetState(SCE_VHDL_STRING);
+      } else if (isoperator(static_cast<char>(sc.ch))) {
+        sc.SetState(SCE_VHDL_OPERATOR);
+      }
+    }
+  }
+  sc.Complete();
+}
+//=============================================================================
+static bool IsCommentLine(int line, Accessor &styler) {
+	int pos = styler.LineStart(line);
+	int eol_pos = styler.LineStart(line + 1) - 1;
+	for (int i = pos; i < eol_pos; i++) {
+		char ch = styler[i];
+		char chNext = styler[i+1];
+		if ((ch == '-') && (chNext == '-'))
+			return true;
+		else if (ch != ' ' && ch != '\t')
+			return false;
+	}
+	return false;
+}
+
+//=============================================================================
+// Folding the code
+static void FoldNoBoxVHDLDoc(
+  unsigned int startPos,
+  int length,
+  int initStyle,
+  Accessor &styler)
+{
+  // Decided it would be smarter to have the lexer have all keywords included. Therefore I
+  // don't check if the style for the keywords that I use to adjust the levels.
+  char words[] =
+    "architecture begin case component else elsif end entity generate loop package process record then "
+    "procedure function when";
+  WordList keywords;
+  keywords.Set(words);
+
+  bool foldComment      = styler.GetPropertyInt("fold.comment", 1) != 0;
+  bool foldCompact      = styler.GetPropertyInt("fold.compact", 1) != 0;
+  bool foldAtElse       = styler.GetPropertyInt("fold.at.else", 1) != 0;
+  bool foldAtBegin      = styler.GetPropertyInt("fold.at.Begin", 1) != 0;
+  bool foldAtParenthese = styler.GetPropertyInt("fold.at.Parenthese", 1) != 0;
+  //bool foldAtWhen       = styler.GetPropertyInt("fold.at.When", 1) != 0;  //< fold at when in case statements
+
+  int  visibleChars     = 0;
+  unsigned int endPos   = startPos + length;
+
+  int lineCurrent       = styler.GetLine(startPos);
+  int levelCurrent      = SC_FOLDLEVELBASE;
+  if(lineCurrent > 0)
+    levelCurrent        = styler.LevelAt(lineCurrent-1) >> 16;
+  //int levelMinCurrent   = levelCurrent;
+  int levelMinCurrentElse = levelCurrent;   //< Used for folding at 'else'
+  int levelMinCurrentBegin = levelCurrent;  //< Used for folding at 'begin'
+  int levelNext         = levelCurrent;
+
+  /***************************************/
+  int lastStart         = 0;
+  char prevWord[32]     = "";
+
+  /***************************************/
+  // Find prev word
+  // The logic for going up or down a level depends on a the previous keyword
+  // This code could be cleaned up.
+  int end = 0;
+  unsigned int j;
+  for(j = startPos; j>0; j--)
+  {
+    char ch       = styler.SafeGetCharAt(j);
+    char chPrev   = styler.SafeGetCharAt(j-1);
+    int style     = styler.StyleAt(j);
+    int stylePrev = styler.StyleAt(j-1);
+    if ((stylePrev != SCE_VHDL_COMMENT) && (stylePrev != SCE_VHDL_STRING))
+    {
+      if(IsAWordChar(chPrev) && !IsAWordChar(ch))
+      {
+        end = j-1;
+      }
+    }
+    if ((style != SCE_VHDL_COMMENT) && (style != SCE_VHDL_STRING))
+    {
+      if(!IsAWordChar(chPrev) && IsAWordStart(ch) && (end != 0))
+      {
+        char s[32];
+        unsigned int k;
+        for(k=0; (k<31 ) && (k<end-j+1 ); k++) {
+          s[k] = static_cast<char>(tolower(styler[j+k]));
+        }
+        s[k] = '\0';
+
+        if(keywords.InList(s)) {
+          strcpy(prevWord, s);
+          break;
+        }
+      }
+    }
+  }
+  for(j=j+strlen(prevWord); j<endPos; j++)
+  {
+    char ch       = styler.SafeGetCharAt(j);
+    int style     = styler.StyleAt(j);
+    if ((style != SCE_VHDL_COMMENT) && (style != SCE_VHDL_STRING))
+    {
+      if((ch == ';') && (strcmp(prevWord, "end") == 0))
+      {
+        strcpy(prevWord, ";");
+      }
+    }
+  }
+
+  char  chNext          = styler[startPos];
+  char  chPrev          = '\0';
+  char  chNextNonBlank;
+  int   styleNext       = styler.StyleAt(startPos);
+  int   style           = initStyle;
+  //Platform::DebugPrintf("Line[%04d] Prev[%20s] ************************* Level[%x]\n", lineCurrent+1, prevWord, levelCurrent);
+
+  /***************************************/
+  for (unsigned int i = startPos; i < endPos; i++)
+  {
+    char ch         = chNext;
+    chNext          = styler.SafeGetCharAt(i + 1);
+    chPrev          = styler.SafeGetCharAt(i - 1);
+    chNextNonBlank  = chNext;
+    unsigned int j  = i+1;
+    while(IsABlank(chNextNonBlank) && j<endPos)
+    {
+      j ++ ;
+      chNextNonBlank = styler.SafeGetCharAt(j);
+    }
+    style           = styleNext;
+    styleNext       = styler.StyleAt(i + 1);
+    bool atEOL      = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+		if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) 
+    {
+      if(!IsCommentLine(lineCurrent-1, styler) && IsCommentLine(lineCurrent+1, styler))
+      {
+        levelNext++;
+      } 
+      else if(IsCommentLine(lineCurrent-1, styler) && !IsCommentLine(lineCurrent+1, styler))
+      {
+        levelNext--;
+      }
+    }
+
+    if ((style == SCE_VHDL_OPERATOR) && foldAtParenthese)
+    {
+      if(ch == '(') {
+        levelNext++;
+      } else if (ch == ')') {
+        levelNext--;
+      }
+    }
+
+    if ((style != SCE_VHDL_COMMENT) && (style != SCE_VHDL_STRING))
+    {
+      if((ch == ';') && (strcmp(prevWord, "end") == 0))
+      {
+        strcpy(prevWord, ";");
+      }
+
+      if(!IsAWordChar(chPrev) && IsAWordStart(ch))
+      {
+        lastStart = i;
+      }
+
+      if(iswordchar(ch) && !iswordchar(chNext)) {
+        char s[32];
+        unsigned int k;
+        for(k=0; (k<31 ) && (k<i-lastStart+1 ); k++) {
+          s[k] = static_cast<char>(tolower(styler[lastStart+k]));
+        }
+        s[k] = '\0';
+
+        if(keywords.InList(s))
+        {
+          if (
+            strcmp(s, "architecture") == 0  ||
+            strcmp(s, "case") == 0          ||
+            strcmp(s, "component") == 0     ||
+            strcmp(s, "entity") == 0        ||
+            strcmp(s, "generate") == 0      ||
+            strcmp(s, "loop") == 0          ||
+            strcmp(s, "package") ==0        ||
+            strcmp(s, "process") == 0       ||
+            strcmp(s, "record") == 0        ||
+            strcmp(s, "then") == 0)
+          {
+            if (strcmp(prevWord, "end") != 0)
+            {
+              if (levelMinCurrentElse > levelNext) {
+                levelMinCurrentElse = levelNext;
+              }
+              levelNext++;
+            }
+          } else if (
+            strcmp(s, "procedure") == 0     ||
+            strcmp(s, "function") == 0)
+          {
+            if (strcmp(prevWord, "end") != 0) // check for "end procedure" etc.
+            { // This code checks to see if the procedure / function is a definition within a "package"
+              // rather than the actual code in the body.
+              int BracketLevel = 0;
+              for(int j=i+1; j<styler.Length(); j++)
+              {
+                int LocalStyle = styler.StyleAt(j);
+                char LocalCh = styler.SafeGetCharAt(j);
+                if(LocalCh == '(') BracketLevel++;
+                if(LocalCh == ')') BracketLevel--;
+                if(
+                  (BracketLevel == 0) &&
+                  (LocalStyle != SCE_VHDL_COMMENT) &&
+                  (LocalStyle != SCE_VHDL_STRING) &&
+                  !iswordchar(styler.SafeGetCharAt(j-1)) &&
+                  styler.Match(j, "is") &&
+                  !iswordchar(styler.SafeGetCharAt(j+2)))
+                {
+                  if (levelMinCurrentElse > levelNext) {
+                    levelMinCurrentElse = levelNext;
+                  }
+                  levelNext++;
+                  break;
+                }
+                if((BracketLevel == 0) && (LocalCh == ';'))
+                {
+                  break;
+                }
+              }
+            }
+
+          } else if (strcmp(s, "end") == 0) {
+            levelNext--;
+          }  else if(strcmp(s, "elsif") == 0) { // elsif is followed by then so folding occurs correctly
+            levelNext--;
+          } else if (strcmp(s, "else") == 0) {
+            if(strcmp(prevWord, "when") != 0)  // ignore a <= x when y else z;
+            {
+              levelMinCurrentElse = levelNext - 1;  // VHDL else is all on its own so just dec. the min level
+            }
+          } else if(
+            ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "architecture") == 0)) ||
+            ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "function") == 0)) ||
+            ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "procedure") == 0)))
+          {
+            levelMinCurrentBegin = levelNext - 1;  
+          }
+          //Platform::DebugPrintf("Line[%04d] Prev[%20s] Cur[%20s] Level[%x]\n", lineCurrent+1, prevWord, s, levelCurrent);
+          strcpy(prevWord, s);
+        }
+      }
+    }
+    if (atEOL) {
+      int levelUse = levelCurrent;
+
+      if (foldAtElse && (levelMinCurrentElse < levelUse)) {
+        levelUse = levelMinCurrentElse;
+      }
+      if (foldAtBegin && (levelMinCurrentBegin < levelUse)) {
+        levelUse = levelMinCurrentBegin;
+      }
+      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);
+      }
+      //Platform::DebugPrintf("Line[%04d] ---------------------------------------------------- Level[%x]\n", lineCurrent+1, levelCurrent);
+      lineCurrent++;
+      levelCurrent = levelNext;
+      //levelMinCurrent = levelCurrent;
+      levelMinCurrentElse = levelCurrent;
+      levelMinCurrentBegin = levelCurrent;
+      visibleChars = 0;
+    }
+    /***************************************/
+    if (!isspacechar(ch)) visibleChars++;
+  }
+
+  /***************************************/
+//  Platform::DebugPrintf("Line[%04d] ---------------------------------------------------- Level[%x]\n", lineCurrent+1, levelCurrent);
+}
+
+//=============================================================================
+static void FoldVHDLDoc(unsigned int startPos, int length, int initStyle, WordList *[],
+                       Accessor &styler) {
+  FoldNoBoxVHDLDoc(startPos, length, initStyle, styler);
+}
+
+//=============================================================================
+static const char * const VHDLWordLists[] = {
+            "Keywords",
+            "Operators",
+            "Attributes",
+            "Standard Functions",
+            "Standard Packages",
+            "Standard Types",
+            "User Words",
+            0,
+        };
+
+
+LexerModule lmVHDL(SCLEX_VHDL, ColouriseVHDLDoc, "vhdl", FoldVHDLDoc, VHDLWordLists);
+
+
+// Keyword:
+//    access after alias all architecture array assert attribute begin block body buffer bus case component 
+//    configuration constant disconnect downto else elsif end entity exit file for function generate generic 
+//    group guarded if impure in inertial inout is label library linkage literal loop map new next null of 
+//    on open others out package port postponed procedure process pure range record register reject report 
+//    return select severity shared signal subtype then to transport type unaffected units until use variable 
+//    wait when while with
+//
+// Operators:
+//    abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor
+//
+// Attributes:
+//    left right low high ascending image value pos val succ pred leftof rightof base range reverse_range 
+//    length delayed stable quiet transaction event active last_event last_active last_value driving 
+//    driving_value simple_name path_name instance_name
+//
+// Std Functions:
+//    now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector 
+//    to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left 
+//    rotate_right resize to_integer to_unsigned to_signed std_match to_01
+//
+// Std Packages:
+//    std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed 
+//    std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives 
+//    vital_timing
+//
+// Std Types:
+//    boolean bit character severity_level integer real time delay_length natural positive string bit_vector 
+//    file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic 
+//    std_logic_vector X01 X01Z UX01 UX01Z unsigned signed
+//
+

Modified: trunk/scintilla/Makefile.am
===================================================================
--- trunk/scintilla/Makefile.am	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/scintilla/Makefile.am	2006-11-13 22:11:19 UTC (rev 991)
@@ -24,7 +24,8 @@
 LexPython.cxx \
 LexRuby.cxx \
 LexSQL.cxx \
-LexTCL.cxx
+LexTCL.cxx \
+LexVHDL.cxx
 
 SRCS= \
 CallTip.cxx \

Modified: trunk/scintilla/makefile.win32
===================================================================
--- trunk/scintilla/makefile.win32	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/scintilla/makefile.win32	2006-11-13 22:11:19 UTC (rev 991)
@@ -61,7 +61,7 @@
 #**LEXOBJS=\\\n\(\*.o \)
 LEXOBJS=\
 LexBash.o LexAsm.o LexCSS.o LexConf.o LexCPP.o LexCrontab.o LexHTML.o LexOthers.o LexPascal.o \
-LexPerl.o LexPython.o LexSQL.o LexCaml.o LexOMS.o LexTCL.o LexRuby.o LexFortran.o
+LexPerl.o LexPython.o LexSQL.o LexCaml.o LexOMS.o LexTCL.o LexRuby.o LexFortran.o LexVHDL.o
 #--Autogenerated -- end of automatically generated section
 
 all: $(COMPLIB)

Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/src/filetypes.c	2006-11-13 22:11:19 UTC (rev 991)
@@ -64,7 +64,8 @@
 	FILETYPE_UID_FORTRAN,	// 22
 	FILETYPE_UID_DIFF,		// 23
 	FILETYPE_UID_FERITE,	// 24
-	FILETYPE_UID_HTML		// 25
+	FILETYPE_UID_HTML,		// 25
+	FILETYPE_UID_VHDL		// 26
 };
 
 
@@ -106,6 +107,7 @@
 		case FILETYPE_UID_DIFF:		return filetypes[GEANY_FILETYPES_DIFF];
 		case FILETYPE_UID_FERITE:	return filetypes[GEANY_FILETYPES_FERITE];
 		case FILETYPE_UID_HTML:		return filetypes[GEANY_FILETYPES_HTML];
+		case FILETYPE_UID_VHDL:		return filetypes[GEANY_FILETYPES_VHDL];
 		default: 					return NULL;
 	}
 }
@@ -604,6 +606,26 @@
 	filetypes_init_build_programs(filetypes[GEANY_FILETYPES_OMS]);
 	filetypes_create_menu_item(filetype_menu, filetypes[GEANY_FILETYPES_OMS]->title, filetypes[GEANY_FILETYPES_OMS]);
 
+#define VHDL
+	filetypes[GEANY_FILETYPES_VHDL] = g_new0(filetype, 1);
+	filetypes[GEANY_FILETYPES_VHDL]->id = GEANY_FILETYPES_VHDL;
+	filetypes[GEANY_FILETYPES_VHDL]->uid = FILETYPE_UID_VHDL;
+	filetypes[GEANY_FILETYPES_VHDL]->item = NULL;
+	filetypes[GEANY_FILETYPES_VHDL]->lang = 21;
+	filetypes[GEANY_FILETYPES_VHDL]->name = g_strdup("VHDL");
+	filetypes[GEANY_FILETYPES_VHDL]->has_tags = TRUE;
+	filetypes[GEANY_FILETYPES_VHDL]->title = g_strdup(_("VHDL source file"));
+	filetypes[GEANY_FILETYPES_VHDL]->extension = g_strdup("vhd");
+	filetypes[GEANY_FILETYPES_VHDL]->pattern = g_new0(gchar*, 3);
+	filetypes[GEANY_FILETYPES_VHDL]->pattern[0] = g_strdup("*.vhd");
+	filetypes[GEANY_FILETYPES_VHDL]->pattern[1] = g_strdup("*.vhdl");
+	filetypes[GEANY_FILETYPES_VHDL]->pattern[2] = NULL;
+	filetypes[GEANY_FILETYPES_VHDL]->style_func_ptr = styleset_vhdl;
+	filetypes[GEANY_FILETYPES_VHDL]->comment_open = g_strdup("--");
+	filetypes[GEANY_FILETYPES_VHDL]->comment_close = NULL;
+	filetypes_init_build_programs(filetypes[GEANY_FILETYPES_VHDL]);
+	filetypes_create_menu_item(filetype_menu, filetypes[GEANY_FILETYPES_VHDL]->title, filetypes[GEANY_FILETYPES_VHDL]);
+
 #define DIFF
 	filetypes[GEANY_FILETYPES_DIFF] = g_new0(filetype, 1);
 	filetypes[GEANY_FILETYPES_DIFF]->id = GEANY_FILETYPES_DIFF;

Modified: trunk/src/filetypes.h
===================================================================
--- trunk/src/filetypes.h	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/src/filetypes.h	2006-11-13 22:11:19 UTC (rev 991)
@@ -57,6 +57,7 @@
 	GEANY_FILETYPES_SQL,
 	GEANY_FILETYPES_LATEX,
 	GEANY_FILETYPES_OMS,
+	GEANY_FILETYPES_VHDL,
 	GEANY_FILETYPES_DIFF,
 	GEANY_FILETYPES_CONF,
 	GEANY_FILETYPES_ALL,	// must be last filetype

Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/src/highlighting.c	2006-11-13 22:11:19 UTC (rev 991)
@@ -2702,3 +2702,106 @@
 	// is used for local structs and typedefs
 	set_sci_style(sci, SCE_C_GLOBALCLASS, GEANY_FILETYPES_FERITE, 18);
 }
+
+
+static void styleset_vhdl_init(void)
+{
+	GKeyFile *config = g_key_file_new();
+	GKeyFile *config_home = g_key_file_new();
+
+	load_keyfiles(config, config_home, GEANY_FILETYPES_VHDL);
+
+	new_style_array(GEANY_FILETYPES_VHDL, 15);
+
+	get_keyfile_hex(config, config_home, "styling", "default", "0x000000", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[0]);
+	get_keyfile_hex(config, config_home, "styling", "comment", "0xd00000", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[1]);
+	get_keyfile_hex(config, config_home, "styling", "comment_line_bang", "0x3f5fbf", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[2]);
+	get_keyfile_hex(config, config_home, "styling", "number", "0x007f00", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[3]);
+	get_keyfile_hex(config, config_home, "styling", "string", "0xff901e", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[4]);
+	get_keyfile_hex(config, config_home, "styling", "operator", "0x301010", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[5]);
+	get_keyfile_hex(config, config_home, "styling", "identifier", "0x000000", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[6]);
+	get_keyfile_hex(config, config_home, "styling", "stringeol", "0x000000", "0xe0c0e0", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[7]);
+	get_keyfile_hex(config, config_home, "styling", "keyword", "0x001a7f", "0xffffff", "true", &style_sets[GEANY_FILETYPES_VHDL].styling[8]);
+	get_keyfile_hex(config, config_home, "styling", "stdoperator", "0x007f7f", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[9]);
+	get_keyfile_hex(config, config_home, "styling", "attribute", "0x804020", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[10]);
+	get_keyfile_hex(config, config_home, "styling", "stdfunction", "0x808020", "0xffffff", "true", &style_sets[GEANY_FILETYPES_VHDL].styling[11]);
+	get_keyfile_hex(config, config_home, "styling", "stdpackage", "0x208020", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[12]);
+	get_keyfile_hex(config, config_home, "styling", "stdtype", "0x208080", "0xffffff", "false", &style_sets[GEANY_FILETYPES_VHDL].styling[13]);
+	get_keyfile_hex(config, config_home, "styling", "userword", "0x804020", "0xffffff", "true", &style_sets[GEANY_FILETYPES_VHDL].styling[14]);
+
+	style_sets[GEANY_FILETYPES_VHDL].keywords = g_new(gchar*, 8);
+	get_keyfile_keywords(config, config_home, "keywords", "keywords", GEANY_FILETYPES_VHDL, 0,
+			"access after alias all architecture array assert attribute begin block \
+			 body buffer bus case component configuration constant disconnect downto else elsif \
+			 end entity exit file for function generate generic group guarded if impure in inertial \
+			 inout is label library linkage literal loop map new next null of on open others out \
+			 package port postponed procedure process pure range record register reject report \
+			 return select severity shared signal subtype then to transport type unaffected units \
+			 until use variable wait when while with");
+	get_keyfile_keywords(config, config_home, "keywords", "operators", GEANY_FILETYPES_VHDL, 1,
+			"abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor");
+	get_keyfile_keywords(config, config_home, "keywords", "attributes", GEANY_FILETYPES_VHDL, 2,
+			"left right low high ascending image value pos val succ pred leftof rightof base range \
+			 reverse_range length delayed stable quiet transaction event active last_event last_active \
+			 last_value driving driving_value simple_name path_name instance_name");
+	get_keyfile_keywords(config, config_home, "keywords", "std_functions", GEANY_FILETYPES_VHDL, 3,
+			"now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic \
+			 to_stdlogicvector to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge \
+			 is_x shift_left shift_right rotate_left rotate_right resize to_integer to_unsigned \
+			 to_signed std_match to_01");
+	get_keyfile_keywords(config, config_home, "keywords", "std_packages", GEANY_FILETYPES_VHDL, 4,
+			"std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc \
+			 std_logic_signed std_logic_textio std_logic_unsigned numeric_bit numeric_std \
+			 math_complex math_real vital_primitives vital_timing");
+	get_keyfile_keywords(config, config_home, "keywords", "std_types", GEANY_FILETYPES_VHDL, 5,
+			"boolean bit character severity_level integer real time delay_length natural positive \
+			 string bit_vector file_open_kind file_open_status line text side width std_ulogic \
+			 std_ulogic_vector std_logic std_logic_vector X01 X01Z UX01 UX01Z unsigned signed");
+	get_keyfile_keywords(config, config_home, "keywords", "userwords", GEANY_FILETYPES_VHDL, 6, "");
+	style_sets[GEANY_FILETYPES_VHDL].keywords[7] = NULL;
+
+	get_keyfile_wordchars(config, config_home, GEANY_WORDCHARS,
+		&style_sets[GEANY_FILETYPES_VHDL].wordchars);
+	filetypes_get_config(config, config_home, GEANY_FILETYPES_VHDL);
+
+	g_key_file_free(config);
+	g_key_file_free(config_home);
+}
+
+
+void styleset_vhdl(ScintillaObject *sci)
+{
+	styleset_common(sci, 5);
+	if (style_sets[GEANY_FILETYPES_VHDL].styling == NULL) styleset_vhdl_init();
+
+	SSM(sci, SCI_SETWORDCHARS, 0, (sptr_t) style_sets[GEANY_FILETYPES_VHDL].wordchars);
+	SSM(sci, SCI_AUTOCSETMAXHEIGHT, app->autocompletion_max_height, 0);
+
+	SSM(sci, SCI_SETLEXER, SCLEX_VHDL, 0);
+
+	SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t) style_sets[GEANY_FILETYPES_VHDL].keywords[0]);
+	SSM(sci, SCI_SETKEYWORDS, 1, (sptr_t) style_sets[GEANY_FILETYPES_VHDL].keywords[1]);
+	SSM(sci, SCI_SETKEYWORDS, 2, (sptr_t) style_sets[GEANY_FILETYPES_VHDL].keywords[2]);
+	SSM(sci, SCI_SETKEYWORDS, 3, (sptr_t) style_sets[GEANY_FILETYPES_VHDL].keywords[3]);
+	SSM(sci, SCI_SETKEYWORDS, 4, (sptr_t) style_sets[GEANY_FILETYPES_VHDL].keywords[4]);
+	SSM(sci, SCI_SETKEYWORDS, 5, (sptr_t) style_sets[GEANY_FILETYPES_VHDL].keywords[5]);
+	SSM(sci, SCI_SETKEYWORDS, 6, (sptr_t) style_sets[GEANY_FILETYPES_VHDL].keywords[6]);
+
+	set_sci_style(sci, STYLE_DEFAULT, GEANY_FILETYPES_VHDL, 0);
+	set_sci_style(sci, SCE_VHDL_DEFAULT, GEANY_FILETYPES_VHDL, 0);
+	set_sci_style(sci, SCE_VHDL_COMMENT, GEANY_FILETYPES_VHDL, 1);
+	set_sci_style(sci, SCE_VHDL_COMMENTLINEBANG, GEANY_FILETYPES_VHDL, 2);
+	set_sci_style(sci, SCE_VHDL_NUMBER, GEANY_FILETYPES_VHDL, 3);
+	set_sci_style(sci, SCE_VHDL_STRING, GEANY_FILETYPES_VHDL, 4);
+	set_sci_style(sci, SCE_VHDL_OPERATOR, GEANY_FILETYPES_VHDL, 5);
+	set_sci_style(sci, SCE_VHDL_IDENTIFIER, GEANY_FILETYPES_VHDL, 6);
+	set_sci_style(sci, SCE_VHDL_STRINGEOL, GEANY_FILETYPES_VHDL, 7);
+	set_sci_style(sci, SCE_VHDL_KEYWORD, GEANY_FILETYPES_VHDL, 8);
+	set_sci_style(sci, SCE_VHDL_STDOPERATOR, GEANY_FILETYPES_VHDL, 9);
+	set_sci_style(sci, SCE_VHDL_ATTRIBUTE, GEANY_FILETYPES_VHDL, 10);
+	set_sci_style(sci, SCE_VHDL_STDFUNCTION, GEANY_FILETYPES_VHDL, 11);
+	set_sci_style(sci, SCE_VHDL_STDPACKAGE, GEANY_FILETYPES_VHDL, 12);
+	set_sci_style(sci, SCE_VHDL_STDTYPE, GEANY_FILETYPES_VHDL, 13);
+	set_sci_style(sci, SCE_VHDL_USERWORD, GEANY_FILETYPES_VHDL, 14);
+}
+

Modified: trunk/src/highlighting.h
===================================================================
--- trunk/src/highlighting.h	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/src/highlighting.h	2006-11-13 22:11:19 UTC (rev 991)
@@ -88,4 +88,6 @@
 
 void styleset_ferite(ScintillaObject *sci);
 
+void styleset_vhdl(ScintillaObject *sci);
+
 #endif

Modified: trunk/src/treeviews.c
===================================================================
--- trunk/src/treeviews.c	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/src/treeviews.c	2006-11-13 22:11:19 UTC (rev 991)
@@ -235,6 +235,27 @@
 			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_other), 0, _("Other"), -1);
 			break;
 		}
+		case GEANY_FILETYPES_VHDL:
+		{
+			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_function), NULL);
+			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_function), 0, _("Functions"), -1);
+/*			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_class), NULL);
+			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_class), 0, _("Constants"), -1);
+			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_member), NULL);
+			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_member), 0, _("Members"), -1);
+			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_macro), NULL);
+			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_macro), 0, _("Macros"), -1);
+*/			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_variable), NULL);
+			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_variable), 0, _("Variables"), -1);
+/*			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_namespace), NULL);
+			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_namespace), 0, _("Namespaces"), -1);
+			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_struct), NULL);
+			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_struct), 0, _("Signals"), -1);
+			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_other), NULL);
+			gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_other), 0, _("Other"), -1);
+*/
+			break;
+		}
 		default:
 		{
 			gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_function), NULL);

Modified: trunk/tagmanager/Makefile.am
===================================================================
--- trunk/tagmanager/Makefile.am	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/tagmanager/Makefile.am	2006-11-13 22:11:19 UTC (rev 991)
@@ -44,6 +44,7 @@
 	regex.c\
 	tcl.c\
 	sh.c\
+	vhdl.c\
 	ctags.c\
 	entry.c\
 	get.c\

Modified: trunk/tagmanager/makefile.win32
===================================================================
--- trunk/tagmanager/makefile.win32	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/tagmanager/makefile.win32	2006-11-13 22:11:19 UTC (rev 991)
@@ -32,7 +32,7 @@
 clean:
 	-$(RM) deps.mak *.o $(COMPLIB)
 
-$(COMPLIB): args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o diff.o \
+$(COMPLIB): args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o diff.o vhdl.o \
 python.o regex.o sh.o ctags.o entry.o get.o keyword.o options.o parse.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 \

Modified: trunk/tagmanager/parsers.h
===================================================================
--- trunk/tagmanager/parsers.h	2006-11-13 16:47:26 UTC (rev 990)
+++ trunk/tagmanager/parsers.h	2006-11-13 22:11:19 UTC (rev 991)
@@ -35,7 +35,8 @@
     DParser, \
     FortranParser, \
     FeriteParser, \
-    DiffParser
+    DiffParser, \
+    VhdlParser
 
 /*
 langType of each parser
@@ -60,6 +61,7 @@
 18	FortranParser
 19	FeriteParser
 20	DiffParser
+21	VhdlParser
 */
 #endif	/* _PARSERS_H */
 

Added: trunk/tagmanager/vhdl.c
===================================================================
--- trunk/tagmanager/vhdl.c	                        (rev 0)
+++ trunk/tagmanager/vhdl.c	2006-11-13 22:11:19 UTC (rev 991)
@@ -0,0 +1,297 @@
+/*
+*   $Id: vhdl.c,v 1.0 2005/11/05
+*
+*   Copyright (c) 2005, Klaus Dannecker
+*
+*   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 Vhdl HDL
+*   (Hardware Description Language).
+*
+*/
+
+/*
+ *   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"
+
+/*
+ *   DATA DECLARATIONS
+ */
+typedef enum eException { ExceptionNone, ExceptionEOF } exception_t;
+
+typedef enum {
+    K_UNDEFINED = -1,
+    K_CONSTANT,
+    K_TYPE,
+    K_VARIABLE,
+    K_ATRIBUTE,
+    K_SIGNAL,
+    K_FUNCTION,
+    K_PROCEDURE,
+    K_COMPONENT,
+    K_PACKAGE,
+    K_PROCESS,
+    K_ENTITY,
+    K_ARCHITECTURE,
+    K_PORT
+} vhdlKind;
+
+typedef struct {
+    const char *keyword;
+    vhdlKind kind;
+} keywordAssoc;
+
+/*
+ *   DATA DEFINITIONS
+ */
+static int Ungetc;
+static int Lang_vhdl;
+static jmp_buf Exception;
+static vString* Name=NULL;
+static vString* Lastname=NULL;
+static vString* Keyword=NULL;
+static vString* TagName=NULL;
+
+static kindOption VhdlKinds [] = {
+ { TRUE, 'c', "constant",     "constants" },
+ { TRUE, 't', "type",         "types" },
+ { TRUE, 'v', "variable",     "variables" },
+ { TRUE, 'a', "atribute",     "atributes" },
+ { TRUE, 's', "signal",       "signals" },
+ { TRUE, 'f', "function",     "functions" },
+ { TRUE, 'p', "procedure",    "procedure" },
+ { TRUE, 'k', "component",    "components" },
+ { TRUE, 'l', "package",      "packages" },
+ { TRUE, 'm', "process",      "process" },
+ { TRUE, 'n', "entity",       "entity" },
+ { TRUE, 'o', "architecture", "architecture" },
+ { TRUE, 'u', "port",         "ports" }
+};
+
+static keywordAssoc VhdlKeywordTable [] = {
+    { "variable",     K_VARIABLE },
+    { "constant",     K_CONSTANT },
+    { "variable",     K_VARIABLE },
+    { "type",         K_TYPE },
+    { "subtype",      K_TYPE },
+    { "signal",       K_SIGNAL },
+    { "function",     K_FUNCTION },
+    { "procedure",    K_PROCEDURE },
+    { "component",    K_COMPONENT },
+    { "package",      K_PACKAGE },
+    { "process",      K_PROCESS },
+    { "entity",       K_ENTITY },
+    { "architecture", K_ARCHITECTURE },
+    { "inout",        K_PORT },
+    { "in",           K_PORT },
+    { "out",          K_PORT }
+};
+
+
+/*
+ *   FUNCTION DEFINITIONS
+ */
+
+static void initialize (const langType language)
+{
+    size_t i;
+    const size_t count = sizeof (VhdlKeywordTable) /
+			 sizeof (VhdlKeywordTable [0]);
+    Lang_vhdl = language;
+    for (i = 0  ;  i < count  ;  ++i)
+    {
+		const keywordAssoc* const p = &VhdlKeywordTable [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
+			Ungetc = c2;
+	}
+    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 (c==' ')
+	c = vGetc ();
+    return c;
+}
+
+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 vhdlKind kind, int c)
+{
+    Assert (isIdentifierCharacter (c));
+	if (isIdentifierCharacter (c))
+	{
+		readIdentifier (TagName, c);
+		makeSimpleTag (TagName, VhdlKinds, kind);
+		vUngetc (c);
+	}
+}
+
+static void findTag (vString *const name)
+{
+	int c = '\0';
+	vhdlKind kind;
+    vStringCopyToLower (Keyword, name);
+    kind = (vhdlKind)lookupKeyword (vStringValue (Keyword), Lang_vhdl);
+    if (kind == K_UNDEFINED)
+	{
+		c = skipWhite (vGetc ());
+		vStringCopyS(Lastname,vStringValue(name));
+			if (c == ':')
+			{
+				c = skipWhite (vGetc ());
+				if (isIdentifierCharacter (c))
+				{
+					readIdentifier (name, c);
+					vStringCopyToLower (Keyword, name);
+					lookupKeyword (vStringValue (Keyword), Lang_vhdl);
+					kind = (vhdlKind)lookupKeyword (vStringValue (Keyword), Lang_vhdl);
+					if (kind == K_PROCESS || kind == K_PORT)
+					{
+						makeSimpleTag (Lastname, VhdlKinds, kind);
+					}
+				}
+			} else {
+				vUngetc (c);
+			}
+	}
+	else
+	{
+		if (kind == K_SIGNAL) {
+			while (c!=':') {
+				c = skipWhite (vGetc ());
+				if (c==',')
+					c = vGetc ();
+				if (isIdentifierCharacter (c))
+					tagNameList (kind, c);
+				else
+					break;
+				c = vGetc ();
+			}
+		}
+		else if (kind == K_PROCESS) {
+			vStringCopyS(TagName,"unnamed");
+			makeSimpleTag (TagName, VhdlKinds, kind);
+		} else {
+			c = skipWhite (vGetc ());
+			if (c=='\"')
+				c = vGetc ();
+			if (isIdentifierCharacter (c))
+				tagNameList (kind, c);
+		}
+	}
+}
+
+static void findVhdlTags (void)
+{
+    volatile boolean newStatement = TRUE;
+    volatile int c = '\0';
+    exception_t exception = (exception_t) setjmp (Exception);
+	Name = vStringNew ();
+    Lastname = vStringNew ();
+    Keyword = vStringNew ();
+    TagName = vStringNew ();
+
+    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);
+    vStringDelete (Lastname);
+    vStringDelete (Keyword);
+    vStringDelete (TagName);
+}
+
+extern parserDefinition* VhdlParser (void)
+{
+    static const char *const extensions [] = { "vhdl", "vhd", NULL };
+    parserDefinition* def = parserNew ("Vhdl");
+    def->kinds      = VhdlKinds;
+    def->kindCount  = KIND_COUNT (VhdlKinds);
+    def->extensions = extensions;
+    def->parser     = findVhdlTags;
+    def->initialize = initialize;
+    return def;
+}
+
+/* vi:set tabstop=8 shiftwidth=4: */


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