Debian Codegraph @

plugins/symbolbrowser/symbols/parsers/keyword.h

raw symbols SCIP
1 /***************************************************************************
2 A SymbolBrowser plugin for JuffEd editor.
3
4 Copyright: 2010 Aleksander Sokoloff <[email protected]>
5
6 Some of the code based on a ctags project http://ctags.sourceforge.net/
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License.
10 version 2 as published by the Free Software Foundation.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have rceived a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 ***************************************************************************/
21
22
23 #ifndef KEYWORD_H
24 #define KEYWORD_H
25
26 #include "../common.h"
27 #include "vstring.h"
28
29 #define HASH_EXPONENT 7 /* must be less than 17 */
30
31 class Keywords
32 {
33 public:
34 Keywords();
35 ~Keywords();
36
37 void addKeyword (const char *const string, Language language, int value);
38 int lookupKeyword (const char *const string, Language language);
39
40 #ifdef DEBUG
41 void printKeywordTable (void);
42 #endif
43 int analyzeToken (vString *const name, Language language);
44
45 private:
46 typedef struct sHashEntry {
47 struct sHashEntry *next;
48 const char *string;
49 Language language;
50 int value;
51 } hashEntry;
52
53 static const unsigned int TableSize = 1 << HASH_EXPONENT;
54 hashEntry **table;
55
56 hashEntry *getHashTableEntry (unsigned long hashedValue);
57 unsigned long hashValue (const char *const string);
58 hashEntry *newEntry(const char *const string, Language language, int value);
59 #ifdef DEBUG
60 void printEntry (const hashEntry *const entry);
61 unsigned int printBucket (const unsigned int i);
62 #endif
63
64 };
65
66 #endif // KEYWORD_H