diff options
author | nyamatongwe <devnull@localhost> | 2001-02-27 01:12:47 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2001-02-27 01:12:47 +0000 |
commit | 092d0572b39dea08d13c8a5c0f17fdbec2d99cd0 (patch) | |
tree | 22b082b24bb31300a43cef5b26c824a7fcda3f32 /src/LexConf.cxx | |
parent | e25dda1fdca3e282f7aaf4bf5cd5068031aad57d (diff) | |
download | scintilla-mirror-092d0572b39dea08d13c8a5c0f17fdbec2d99cd0.tar.gz |
Patch from Philippe to regularise comments.
Diffstat (limited to 'src/LexConf.cxx')
-rw-r--r-- | src/LexConf.cxx | 86 |
1 files changed, 42 insertions, 44 deletions
diff --git a/src/LexConf.cxx b/src/LexConf.cxx index f3578428e..6ffcd1d71 100644 --- a/src/LexConf.cxx +++ b/src/LexConf.cxx @@ -1,21 +1,19 @@ -// SciTE - Scintilla based Text Editor +// Scintilla source code edit control +/** @file LexConf.cxx + ** Lexer for Apache Configuration Files. + ** + ** First working version contributed by Ahmad Zawawi <zeus_go64@hotmail.com> on October 28, 2000. + ** i created this lexer because i needed something pretty when dealing + ** when Apache Configuration files... + **/ // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> -// -// NAME -// LexConf.cxx - lexer for Apache Configuration Files -// AUTHOR -// first working version contributed by Ahmad Zawawi <zeus_go64@hotmail.com> on October 28, 2000 -// DESCRIPTION -// i created this lexer because i needed something pretty when dealing -// when Apache Configuration files... -// - - -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <stdio.h> -#include <stdarg.h> +// 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" @@ -25,27 +23,27 @@ #include "Scintilla.h" #include "SciLexer.h" -static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) +static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_CONF_DEFAULT; char chNext = styler[startPos]; int lengthDoc = startPos + length; // create a buffer large enough to take the largest chunk... - char *buffer = new char[length]; + char *buffer = new char[length]; int bufferCount = 0; // this assumes that we have 2 keyword list in conf.properties WordList &directives = *keywordLists[0]; WordList ¶ms = *keywordLists[1]; - + // go through all provided text segment // using the hand-written state machine shown below - styler.StartAt(startPos); - styler.StartSegment(startPos); + styler.StartAt(startPos); + styler.StartSegment(startPos); for (int i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); - + if (styler.IsLeadByte(ch)) { chNext = styler.SafeGetCharAt(i + 2); i++; @@ -64,7 +62,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k } else if( ch == '.' /*|| ch == '/'*/) { // signals the start of a file... state = SCE_CONF_EXTENSION; - styler.ColourTo(i,SCE_CONF_EXTENSION); + styler.ColourTo(i,SCE_CONF_EXTENSION); } else if( ch == '"') { state = SCE_CONF_STRING; styler.ColourTo(i,SCE_CONF_STRING); @@ -74,14 +72,14 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k // simple case... styler.ColourTo(i,SCE_CONF_OPERATOR); } else if( isalpha(ch) ) { - // signals the start of an identifier + // signals the start of an identifier bufferCount = 0; buffer[bufferCount++] = static_cast<char>(tolower(ch)); state = SCE_CONF_IDENTIFIER; } else if( isdigit(ch) ) { // signals the start of a number bufferCount = 0; - buffer[bufferCount++] = ch; + buffer[bufferCount++] = ch; //styler.ColourTo(i,SCE_CONF_NUMBER); state = SCE_CONF_NUMBER; } else { @@ -89,7 +87,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k styler.ColourTo(i,SCE_CONF_DEFAULT); } break; - + case SCE_CONF_COMMENT: // if we find a newline here, // we simply go to default state @@ -105,9 +103,9 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k // if we find a non-alphanumeric char, // we simply go to default state // else we're still dealing with an extension... - if( isalnum(ch) || (ch == '_') || - (ch == '-') || (ch == '$') || - (ch == '/') || (ch == '.') || (ch == '*') ) + if( isalnum(ch) || (ch == '_') || + (ch == '-') || (ch == '$') || + (ch == '/') || (ch == '.') || (ch == '*') ) { styler.ColourTo(i,SCE_CONF_EXTENSION); } else { @@ -115,16 +113,16 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k chNext = styler[i--]; } break; - + case SCE_CONF_STRING: // if we find the end of a string char, we simply go to default state // else we're still dealing with an string... if( (ch == '"' && styler.SafeGetCharAt(i-1)!='\\') || (ch == '\n') || (ch == '\r') ) { state = SCE_CONF_DEFAULT; - } - styler.ColourTo(i,SCE_CONF_STRING); + } + styler.ColourTo(i,SCE_CONF_STRING); break; - + case SCE_CONF_IDENTIFIER: // stay in CONF_IDENTIFIER state until we find a non-alphanumeric if( isalnum(ch) || (ch == '_') || (ch == '-') || (ch == '/') || (ch == '$') || (ch == '.') || (ch == '*')) { @@ -132,8 +130,8 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k } else { state = SCE_CONF_DEFAULT; buffer[bufferCount] = '\0'; - - // check if the buffer contains a keyword, and highlight it if it is a keyword... + + // check if the buffer contains a keyword, and highlight it if it is a keyword... if(directives.InList(buffer)) { styler.ColourTo(i-1,SCE_CONF_DIRECTIVE ); } else if(params.InList(buffer)) { @@ -143,21 +141,21 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k } else { styler.ColourTo(i-1,SCE_CONF_DEFAULT); } - + // push back the faulty character chNext = styler[i--]; - + } break; - + case SCE_CONF_NUMBER: // stay in CONF_NUMBER state until we find a non-numeric if( isdigit(ch) || ch == '.') { buffer[bufferCount++] = ch; } else { state = SCE_CONF_DEFAULT; - buffer[bufferCount] = '\0'; - + buffer[bufferCount] = '\0'; + // Colourize here... if( strchr(buffer,'.') ) { // it is an IP address... @@ -166,13 +164,13 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k // normal number styler.ColourTo(i-1,SCE_CONF_NUMBER); } - + // push back a character chNext = styler[i--]; } break; - - } + + } } } |