From 154254a66aebb4cf40616c0a80c1b57c5560d3c8 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 3 Apr 2002 01:58:48 +0000 Subject: Patch from Brian Quinlan to include metdata about keyword lists within lexers. --- src/KeyWords.cxx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/KeyWords.cxx') diff --git a/src/KeyWords.cxx b/src/KeyWords.cxx index d1eddef5f..e75fc9d01 100644 --- a/src/KeyWords.cxx +++ b/src/KeyWords.cxx @@ -23,10 +23,12 @@ const LexerModule *LexerModule::base = 0; int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1; LexerModule::LexerModule(int language_, LexerFunction fnLexer_, - const char *languageName_, LexerFunction fnFolder_) : + const char *languageName_, LexerFunction fnFolder_, + const char * const wordListDescriptions_[]) : language(language_), fnLexer(fnLexer_), fnFolder(fnFolder_), + wordListDescriptions(wordListDescriptions_), languageName(languageName_) { next = base; base = this; @@ -36,6 +38,31 @@ LexerModule::LexerModule(int language_, LexerFunction fnLexer_, } } +int LexerModule::GetNumWordLists() const { + if (wordListDescriptions == NULL) { + return -1; + } else { + int numWordLists = 0; + + while (wordListDescriptions[numWordLists]) { + ++numWordLists; + } + + return numWordLists; + } +} + +const char * LexerModule::GetWordListDescription(int index) const { + static const char *emptyStr = ""; + + PLATFORM_ASSERT(index < GetNumWordLists()); + if (index >= GetNumWordLists()) { + return emptyStr; + } else { + return wordListDescriptions[index]; + } +} + const LexerModule *LexerModule::Find(int language) { const LexerModule *lm = base; while (lm) { -- cgit v1.2.3