From 3e36fa6f3ea27bb64ce42bdd1a5b50b52dc6bb04 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 13 Apr 2001 04:55:04 +0000 Subject: Start of new lexer infrastructure. Lexers can have a fold function as well as a lexer function. They can be identified by string name as well as an integer ID and may ask to be automatically assigned that ID. --- include/KeyWords.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'include/KeyWords.h') diff --git a/include/KeyWords.h b/include/KeyWords.h index d589d1228..43de26fe6 100644 --- a/include/KeyWords.h +++ b/include/KeyWords.h @@ -9,17 +9,30 @@ typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyl WordList *keywordlists[], Accessor &styler); /** + * A LexerModule is responsible for lexing and folding a particular language. + * The class maintains a list of LexerModules which can be searched to find a + * module appropriate to a particular language. */ class LexerModule { - static LexerModule *base; LexerModule *next; int language; - LexerFunction fn; + const char *languageName; + LexerFunction fnLexer; + LexerFunction fnFolder; + + static LexerModule *base; + static int nextLanguage; public: - LexerModule(int language_, LexerFunction fn_); - static void Colourise(unsigned int startPos, int lengthDoc, int initStyle, - int language, WordList *keywordlists[], Accessor &styler); + LexerModule(int language_, LexerFunction fnLexer_, + const char *languageName_=0, LexerFunction fnFolder_=0); + int GetLanguage() { return language; } + void Lex(unsigned int startPos, int lengthDoc, int initStyle, + WordList *keywordlists[], Accessor &styler); + void Fold(unsigned int startPos, int lengthDoc, int initStyle, + WordList *keywordlists[], Accessor &styler); + static LexerModule *Find(int language); + static LexerModule *Find(const char *languageName); }; /** -- cgit v1.2.3