diff options
Diffstat (limited to 'scintilla/lexers')
-rw-r--r-- | scintilla/lexers/LexAsm.cxx | 146 | ||||
-rw-r--r-- | scintilla/lexers/LexBasic.cxx | 314 | ||||
-rw-r--r-- | scintilla/lexers/LexModula.cxx | 746 | ||||
-rw-r--r-- | scintilla/lexers/LexOthers.cxx | 4 |
4 files changed, 1077 insertions, 133 deletions
diff --git a/scintilla/lexers/LexAsm.cxx b/scintilla/lexers/LexAsm.cxx index 0d5bc58..ef6c89a 100644 --- a/scintilla/lexers/LexAsm.cxx +++ b/scintilla/lexers/LexAsm.cxx @@ -4,16 +4,24 @@ ** Written by The Black Horus
** Enhancements and NASM stuff by Kein-Hong Man, 2003-10
** SCE_ASM_COMMENTBLOCK and SCE_ASM_CHARACTER are for future GNU as colouring
+ ** Converted to lexer object by "Udo Lechner" <dlchnr(at)gmx(dot)net>
**/
// Copyright 1998-2003 by Neil Hodgson <neilh@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 <assert.h>
-#include <ctype.h>
+
+#ifdef _MSC_VER
+#pragma warning(disable: 4786)
+#endif
+
+#include <string>
+#include <map>
#include "ILexer.h"
#include "Scintilla.h"
@@ -25,6 +33,7 @@ #include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
+#include "OptionSet.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
@@ -53,15 +62,119 @@ static inline bool IsAsmOperator(const int ch) { return false;
}
-static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
- Accessor &styler) {
+// An individual named option for use in an OptionSet
+
+// Options used for LexerAsm
+struct OptionsAsm {
+ OptionsAsm() {
+ }
+};
+
+static const char * const asmWordListDesc[] = {
+ "CPU instructions",
+ "FPU instructions",
+ "Registers",
+ "Directives",
+ "Directive operands",
+ "Extended instructions",
+ 0
+};
+
+struct OptionSetAsm : public OptionSet<OptionsAsm> {
+ OptionSetAsm() {
+ DefineWordListSets(asmWordListDesc);
+ }
+};
+
+class LexerAsm : public ILexer {
+ WordList cpuInstruction;
+ WordList mathInstruction;
+ WordList registers;
+ WordList directive;
+ WordList directiveOperand;
+ WordList extInstruction;
+ OptionsAsm options;
+ OptionSetAsm osAsm;
+public:
+ LexerAsm() {
+ }
+ ~LexerAsm() {
+ }
+ void SCI_METHOD Release() {
+ delete this;
+ }
+ int SCI_METHOD Version() const {
+ return lvOriginal;
+ }
+ const char * SCI_METHOD PropertyNames() {
+ return osAsm.PropertyNames();
+ }
+ int SCI_METHOD PropertyType(const char *name) {
+ return osAsm.PropertyType(name);
+ }
+ const char * SCI_METHOD DescribeProperty(const char *name) {
+ return osAsm.DescribeProperty(name);
+ }
+ int SCI_METHOD PropertySet(const char *key, const char *val);
+ const char * SCI_METHOD DescribeWordListSets() {
+ return osAsm.DescribeWordListSets();
+ }
+ int SCI_METHOD WordListSet(int n, const char *wl);
+ void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
+ void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
+
+ void * SCI_METHOD PrivateCall(int, void *) {
+ return 0;
+ }
+
+ static ILexer *LexerFactoryAsm() {
+ return new LexerAsm();
+ }
+};
+
+int SCI_METHOD LexerAsm::PropertySet(const char *key, const char *val) {
+ if (osAsm.PropertySet(&options, key, val)) {
+ return 0;
+ }
+ return -1;
+}
+
+int SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) {
+ WordList *wordListN = 0;
+ switch (n) {
+ case 0:
+ wordListN = &cpuInstruction;
+ break;
+ case 1:
+ wordListN = &mathInstruction;
+ break;
+ case 2:
+ wordListN = ®isters;
+ break;
+ case 3:
+ wordListN = &directive;
+ break;
+ case 4:
+ wordListN = &directiveOperand;
+ break;
+ case 5:
+ wordListN = &extInstruction;
+ break;
+ }
+ int firstModification = -1;
+ if (wordListN) {
+ WordList wlNew;
+ wlNew.Set(wl);
+ if (*wordListN != wlNew) {
+ wordListN->Set(wl);
+ firstModification = 0;
+ }
+ }
+ return firstModification;
+}
- WordList &cpuInstruction = *keywordlists[0];
- WordList &mathInstruction = *keywordlists[1];
- WordList ®isters = *keywordlists[2];
- WordList &directive = *keywordlists[3];
- WordList &directiveOperand = *keywordlists[4];
- WordList &extInstruction = *keywordlists[5];
+void SCI_METHOD LexerAsm::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
+ LexAccessor styler(pAccess);
// Do not leak onto next line
if (initStyle == SCE_ASM_STRINGEOL)
@@ -169,15 +282,10 @@ static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, Wo sc.Complete();
}
-static const char * const asmWordListDesc[] = {
- "CPU instructions",
- "FPU instructions",
- "Registers",
- "Directives",
- "Directive operands",
- "Extended instructions",
- 0
-};
+void SCI_METHOD LexerAsm::Fold(unsigned int /* startPos */, int /* length */, int /* initStyle */, IDocument* /* pAccess */) {
+
+ return;
+}
-LexerModule lmAsm(SCLEX_ASM, ColouriseAsmDoc, "asm", 0, asmWordListDesc);
+LexerModule lmAsm(SCLEX_ASM, LexerAsm::LexerFactoryAsm, "asm", asmWordListDesc);
diff --git a/scintilla/lexers/LexBasic.cxx b/scintilla/lexers/LexBasic.cxx index 62d1373..eeaa8d6 100644 --- a/scintilla/lexers/LexBasic.cxx +++ b/scintilla/lexers/LexBasic.cxx @@ -1,6 +1,7 @@ // Scintilla source code edit control
/** @file LexBasic.cxx
** Lexer for BlitzBasic and PureBasic.
+ ** Converted to lexer object by "Udo Lechner" <dlchnr(at)gmx(dot)net>
**/
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
@@ -22,6 +23,13 @@ #include <stdarg.h>
#include <assert.h>
+#ifdef _MSC_VER
+#pragma warning(disable: 4786)
+#endif
+
+#include <string>
+#include <map>
+
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
@@ -32,6 +40,7 @@ #include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
+#include "OptionSet.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
@@ -88,8 +97,186 @@ static int LowerCase(int c) return c;
}
-static void ColouriseBasicDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler, char comment_char) {
+static int CheckBlitzFoldPoint(char const *token, int &level) {
+ if (!strcmp(token, "function") ||
+ !strcmp(token, "type")) {
+ level |= SC_FOLDLEVELHEADERFLAG;
+ return 1;
+ }
+ if (!strcmp(token, "end function") ||
+ !strcmp(token, "end type")) {
+ return -1;
+ }
+ return 0;
+}
+
+static int CheckPureFoldPoint(char const *token, int &level) {
+ if (!strcmp(token, "procedure") ||
+ !strcmp(token, "enumeration") ||
+ !strcmp(token, "interface") ||
+ !strcmp(token, "structure")) {
+ level |= SC_FOLDLEVELHEADERFLAG;
+ return 1;
+ }
+ if (!strcmp(token, "endprocedure") ||
+ !strcmp(token, "endenumeration") ||
+ !strcmp(token, "endinterface") ||
+ !strcmp(token, "endstructure")) {
+ return -1;
+ }
+ return 0;
+}
+
+static int CheckFreeFoldPoint(char const *token, int &level) {
+ if (!strcmp(token, "function") ||
+ !strcmp(token, "sub") ||
+ !strcmp(token, "type")) {
+ level |= SC_FOLDLEVELHEADERFLAG;
+ return 1;
+ }
+ if (!strcmp(token, "end function") ||
+ !strcmp(token, "end sub") ||
+ !strcmp(token, "end type")) {
+ return -1;
+ }
+ return 0;
+}
+
+// An individual named option for use in an OptionSet
+
+// Options used for LexerBasic
+struct OptionsBasic {
+ bool fold;
+ bool foldCompact;
+ OptionsBasic() {
+ fold = false;
+ foldCompact = true;
+ }
+};
+
+static const char * const blitzbasicWordListDesc[] = {
+ "BlitzBasic Keywords",
+ "user1",
+ "user2",
+ "user3",
+ 0
+};
+
+static const char * const purebasicWordListDesc[] = {
+ "PureBasic Keywords",
+ "PureBasic PreProcessor Keywords",
+ "user defined 1",
+ "user defined 2",
+ 0
+};
+
+static const char * const freebasicWordListDesc[] = {
+ "FreeBasic Keywords",
+ "FreeBasic PreProcessor Keywords",
+ "user defined 1",
+ "user defined 2",
+ 0
+};
+
+struct OptionSetBasic : public OptionSet<OptionsBasic> {
+ OptionSetBasic(const char * const wordListDescriptions[]) {
+ DefineProperty("fold", &OptionsBasic::fold);
+
+ DefineProperty("fold.compact", &OptionsBasic::foldCompact);
+
+ DefineWordListSets(wordListDescriptions);
+ }
+};
+
+class LexerBasic : public ILexer {
+ char comment_char;
+ int (*CheckFoldPoint)(char const *, int &);
+ WordList keywordlists[4];
+ OptionsBasic options;
+ OptionSetBasic osBasic;
+public:
+ LexerBasic(char comment_char_, int (*CheckFoldPoint_)(char const *, int &), const char * const wordListDescriptions[]) :
+ comment_char(comment_char_),
+ CheckFoldPoint(CheckFoldPoint_),
+ osBasic(wordListDescriptions) {
+ }
+ ~LexerBasic() {
+ }
+ void SCI_METHOD Release() {
+ delete this;
+ }
+ int SCI_METHOD Version() const {
+ return lvOriginal;
+ }
+ const char * SCI_METHOD PropertyNames() {
+ return osBasic.PropertyNames();
+ }
+ int SCI_METHOD PropertyType(const char *name) {
+ return osBasic.PropertyType(name);
+ }
+ const char * SCI_METHOD DescribeProperty(const char *name) {
+ return osBasic.DescribeProperty(name);
+ }
+ int SCI_METHOD PropertySet(const char *key, const char *val);
+ const char * SCI_METHOD DescribeWordListSets() {
+ return osBasic.DescribeWordListSets();
+ }
+ int SCI_METHOD WordListSet(int n, const char *wl);
+ void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
+ void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
+
+ void * SCI_METHOD PrivateCall(int, void *) {
+ return 0;
+ }
+ static ILexer *LexerFactoryBlitzBasic() {
+ return new LexerBasic(';', CheckBlitzFoldPoint, blitzbasicWordListDesc);
+ }
+ static ILexer *LexerFactoryPureBasic() {
+ return new LexerBasic(';', CheckPureFoldPoint, purebasicWordListDesc);
+ }
+ static ILexer *LexerFactoryFreeBasic() {
+ return new LexerBasic('\'', CheckFreeFoldPoint, freebasicWordListDesc);
+ }
+};
+
+int SCI_METHOD LexerBasic::PropertySet(const char *key, const char *val) {
+ if (osBasic.PropertySet(&options, key, val)) {
+ return 0;
+ }
+ return -1;
+}
+
+int SCI_METHOD LexerBasic::WordListSet(int n, const char *wl) {
+ WordList *wordListN = 0;
+ switch (n) {
+ case 0:
+ wordListN = &keywordlists[0];
+ break;
+ case 1:
+ wordListN = &keywordlists[1];
+ break;
+ case 2:
+ wordListN = &keywordlists[2];
+ break;
+ case 3:
+ wordListN = &keywordlists[3];
+ break;
+ }
+ int firstModification = -1;
+ if (wordListN) {
+ WordList wlNew;
+ wlNew.Set(wl);
+ if (*wordListN != wlNew) {
+ wordListN->Set(wl);
+ firstModification = 0;
+ }
+ }
+ return firstModification;
+}
+
+void SCI_METHOD LexerBasic::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
+ LexAccessor styler(pAccess);
+
bool wasfirst = true, isfirst = true; // true if first token in a line
styler.StartAt(startPos);
@@ -113,7 +300,7 @@ static void ColouriseBasicDoc(unsigned int startPos, int length, int initStyle, };
sc.GetCurrentLowered(s, sizeof(s));
for (int i = 0; i < 4; i++) {
- if (keywordlists[i]->InList(s)) {
+ if (keywordlists[i].InList(s)) {
sc.ChangeState(kstates[i]);
}
}
@@ -204,64 +391,25 @@ static void ColouriseBasicDoc(unsigned int startPos, int length, int initStyle, sc.Complete();
}
-static int CheckBlitzFoldPoint(char const *token, int &level) {
- if (!strcmp(token, "function") ||
- !strcmp(token, "type")) {
- level |= SC_FOLDLEVELHEADERFLAG;
- return 1;
- }
- if (!strcmp(token, "end function") ||
- !strcmp(token, "end type")) {
- return -1;
- }
- return 0;
-}
-static int CheckPureFoldPoint(char const *token, int &level) {
- if (!strcmp(token, "procedure") ||
- !strcmp(token, "enumeration") ||
- !strcmp(token, "interface") ||
- !strcmp(token, "structure")) {
- level |= SC_FOLDLEVELHEADERFLAG;
- return 1;
- }
- if (!strcmp(token, "endprocedure") ||
- !strcmp(token, "endenumeration") ||
- !strcmp(token, "endinterface") ||
- !strcmp(token, "endstructure")) {
- return -1;
- }
- return 0;
-}
+void SCI_METHOD LexerBasic::Fold(unsigned int startPos, int length, int /* initStyle */, IDocument *pAccess) {
-static int CheckFreeFoldPoint(char const *token, int &level) {
- if (!strcmp(token, "function") ||
- !strcmp(token, "sub") ||
- !strcmp(token, "type")) {
- level |= SC_FOLDLEVELHEADERFLAG;
- return 1;
- }
- if (!strcmp(token, "end function") ||
- !strcmp(token, "end sub") ||
- !strcmp(token, "end type")) {
- return -1;
- }
- return 0;
-}
+ if (!options.fold)
+ return;
+
+
+ LexAccessor styler(pAccess);
-static void FoldBasicDoc(unsigned int startPos, int length,
- Accessor &styler, int (*CheckFoldPoint)(char const *, int &)) {
int line = styler.GetLine(startPos);
int level = styler.LevelAt(line);
int go = 0, done = 0;
int endPos = startPos + length;
char word[256];
int wordlen = 0;
- int i;
- bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+
// Scan for tokens at the start of the line (they may include
// whitespace, for tokens like "End Function"
- for (i = startPos; i < endPos; i++) {
+ for (int i = startPos; i < endPos; i++) {
int c = styler.SafeGetCharAt(i);
if (!done && !go) {
if (wordlen) { // are we scanning a token already?
@@ -294,7 +442,7 @@ static void FoldBasicDoc(unsigned int startPos, int length, }
}
if (c == '\n') { // line end
- if (!done && wordlen == 0 && foldCompact) // line was only space
+ if (!done && wordlen == 0 && options.foldCompact) // line was only space
level |= SC_FOLDLEVELWHITEFLAG;
if (level != styler.LevelAt(line))
styler.SetLevel(line, level);
@@ -310,66 +458,8 @@ static void FoldBasicDoc(unsigned int startPos, int length, }
}
-static void ColouriseBlitzBasicDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
- ColouriseBasicDoc(startPos, length, initStyle, keywordlists, styler, ';');
-}
-
-static void ColourisePureBasicDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
- ColouriseBasicDoc(startPos, length, initStyle, keywordlists, styler, ';');
-}
-
-static void ColouriseFreeBasicDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
- ColouriseBasicDoc(startPos, length, initStyle, keywordlists, styler, '\'');
-}
-
-static void FoldBlitzBasicDoc(unsigned int startPos, int length, int,
- WordList *[], Accessor &styler) {
- FoldBasicDoc(startPos, length, styler, CheckBlitzFoldPoint);
-}
-
-static void FoldPureBasicDoc(unsigned int startPos, int length, int,
- WordList *[], Accessor &styler) {
- FoldBasicDoc(startPos, length, styler, CheckPureFoldPoint);
-}
-
-static void FoldFreeBasicDoc(unsigned int startPos, int length, int,
- WordList *[], Accessor &styler) {
- FoldBasicDoc(startPos, length, styler, CheckFreeFoldPoint);
-}
-
-static const char * const blitzbasicWordListDesc[] = {
- "BlitzBasic Keywords",
- "user1",
- "user2",
- "user3",
- 0
-};
-
-static const char * const purebasicWordListDesc[] = {
- "PureBasic Keywords",
- "PureBasic PreProcessor Keywords",
- "user defined 1",
- "user defined 2",
- 0
-};
-
-static const char * const freebasicWordListDesc[] = {
- "FreeBasic Keywords",
- "FreeBasic PreProcessor Keywords",
- "user defined 1",
- "user defined 2",
- 0
-};
-
-LexerModule lmBlitzBasic(SCLEX_BLITZBASIC, ColouriseBlitzBasicDoc, "blitzbasic",
- FoldBlitzBasicDoc, blitzbasicWordListDesc);
-
-LexerModule lmPureBasic(SCLEX_PUREBASIC, ColourisePureBasicDoc, "purebasic",
- FoldPureBasicDoc, purebasicWordListDesc);
+LexerModule lmBlitzBasic(SCLEX_BLITZBASIC, LexerBasic::LexerFactoryBlitzBasic, "blitzbasic", blitzbasicWordListDesc);
-LexerModule lmFreeBasic(SCLEX_FREEBASIC, ColouriseFreeBasicDoc, "freebasic",
- FoldFreeBasicDoc, freebasicWordListDesc);
+LexerModule lmPureBasic(SCLEX_PUREBASIC, LexerBasic::LexerFactoryPureBasic, "purebasic", purebasicWordListDesc);
+LexerModule lmFreeBasic(SCLEX_FREEBASIC, LexerBasic::LexerFactoryFreeBasic, "freebasic", freebasicWordListDesc);
diff --git a/scintilla/lexers/LexModula.cxx b/scintilla/lexers/LexModula.cxx new file mode 100644 index 0000000..eccfd0e --- /dev/null +++ b/scintilla/lexers/LexModula.cxx @@ -0,0 +1,746 @@ +// -*- coding: utf-8 -*-
+// Scintilla source code edit control
+/**
+ * @file LexModula.cxx
+ * @author Dariusz "DKnoto" KnociĊski
+ * @date 2011/02/03
+ * @brief Lexer for Modula-2/3 documents.
+ */
+// The License.txt file describes the conditions under which this software may
+// be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <ctype.h>
+
+#include "ILexer.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#include "PropSetSimple.h"
+#include "WordList.h"
+#include "LexAccessor.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "CharacterSet.h"
+#include "LexerModule.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+#ifdef DEBUG_LEX_MODULA
+#define DEBUG_STATE( p, c )\
+ fprintf( stderr, "Unknown state: currentPos = %d, char = '%c'\n", p, c );
+#else
+#define DEBUG_STATE( p, c )
+#endif
+
+static inline bool IsDigitOfBase( unsigned ch, unsigned base ) {
+ if( ch < '0' || ch > 'f' ) return false;
+ if( base <= 10 ) {
+ if( ch >= ( '0' + base ) ) return false;
+ } else {
+ if( ch > '9' ) {
+ unsigned nb = base - 10;
+ if( ( ch < 'A' ) || ( ch >= ( 'A' + nb ) ) ) {
+ if( ( ch < 'a' ) || ( ch >= ( 'a' + nb ) ) ) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+static inline unsigned IsOperator( StyleContext & sc, WordList & op ) {
+ int i;
+ char s[3];
+
+ s[0] = sc.ch;
+ s[1] = sc.chNext;
+ s[2] = 0;
+ for( i = 0; i < op.len; i++ ) {
+ if( ( strlen( op.words[i] ) == 2 ) &&
+ ( s[0] == op.words[i][0] && s[1] == op.words[i][1] ) ) {
+ return 2;
+ }
+ }
+ s[1] = 0;
+ for( i = 0; i < op.len; i++ ) {
+ if( ( strlen( op.words[i] ) == 1 ) &&
+ ( s[0] == op.words[i][0] ) ) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static inline bool IsEOL( Accessor &styler, unsigned curPos ) {
+ unsigned ch = styler.SafeGetCharAt( curPos );
+ if( ( ch == '\r' && styler.SafeGetCharAt( curPos + 1 ) == '\n' ) ||
+ ( ch == '\n' ) ) {
+ return true;
+ }
+ return false;
+}
+
+static inline bool checkStatement(
+ Accessor &styler,
+ int &curPos,
+ const char *stt, bool spaceAfter = true ) {
+ int len = strlen( stt );
+ int i;
+ for( i = 0; i < len; i++ ) {
+ if( styler.SafeGetCharAt( curPos + i ) != stt[i] ) {
+ return false;
+ }
+ }
+ if( spaceAfter ) {
+ if( ! isspace( styler.SafeGetCharAt( curPos + i ) ) ) {
+ return false;
+ }
+ }
+ curPos += ( len - 1 );
+ return true;
+}
+
+static inline bool checkEndSemicolon(
+ Accessor &styler,
+ int &curPos, int endPos )
+{
+ const char *stt = "END";
+ int len = strlen( stt );
+ int i;
+ for( i = 0; i < len; i++ ) {
+ if( styler.SafeGetCharAt( curPos + i ) != stt[i] ) {
+ return false;
+ }
+ }
+ while( isspace( styler.SafeGetCharAt( curPos + i ) ) ) {
+ i++;
+ if( ( curPos + i ) >= endPos ) return false;
+ }
+ if( styler.SafeGetCharAt( curPos + i ) != ';' ) {
+ return false;
+ }
+ curPos += ( i - 1 );
+ return true;
+}
+
+static inline bool checkKeyIdentOper(
+
+ Accessor &styler,
+ int &curPos, int endPos,
+ const char *stt, const char etk ) {
+ int newPos = curPos;
+ if( ! checkStatement( styler, newPos, stt ) )
+ return false;
+ newPos++;
+ if( newPos >= endPos )
+ return false;
+ if( ! isspace( styler.SafeGetCharAt( newPos ) ) )
+ return false;
+ newPos++;
+ if( newPos >= endPos )
+ return false;
+ while( isspace( styler.SafeGetCharAt( newPos ) ) ) {
+ newPos++;
+ if( newPos >= endPos )
+ return false;
+ }
+ if( ! isalpha( styler.SafeGetCharAt( newPos ) ) )
+ return false;
+ newPos++;
+ if( newPos >= endPos )
+ return false;
+ char ch;
+ ch = styler.SafeGetCharAt( newPos );
+ while( isalpha( ch ) || isdigit( ch ) || ch == '_' ) {
+ newPos++;
+ if( newPos >= endPos ) return false;
+ ch = styler.SafeGetCharAt( newPos );
+ }
+ while( isspace( styler.SafeGetCharAt( newPos ) ) ) {
+ newPos++;
+ if( newPos >= endPos ) return false;
+ }
+ if( styler.SafeGetCharAt( newPos ) != etk )
+ return false;
+ curPos = newPos;
+ return true;
+}
+
+static void FoldModulaDoc( unsigned int startPos,
+ int length,
+ int , WordList *[],
+ Accessor &styler)
+{
+ int curLine = styler.GetLine(startPos);
+ int curLevel = SC_FOLDLEVELBASE;
+ int endPos = startPos + length;
+ if( curLine > 0 )
+ curLevel = styler.LevelAt( curLine - 1 ) >> 16;
+ int curPos = startPos;
+ int style = styler.StyleAt( curPos );
+ int visChars = 0;
+ int nextLevel = curLevel;
+
+ while( curPos < endPos ) {
+ if( ! isspace( styler.SafeGetCharAt( curPos ) ) ) visChars++;
+
+ switch( style ) {
+ case SCE_MODULA_COMMENT:
+ if( checkStatement( styler, curPos, "(*" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "*)" ) )
+ nextLevel--;
+ break;
+
+ case SCE_MODULA_DOXYCOMM:
+ if( checkStatement( styler, curPos, "(**", false ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "*)" ) )
+ nextLevel--;
+ break;
+
+ case SCE_MODULA_KEYWORD:
+ if( checkStatement( styler, curPos, "IF" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "BEGIN" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "TRY" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "LOOP" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "FOR" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "WHILE" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "REPEAT" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "UNTIL" ) )
+ nextLevel--;
+ else
+ if( checkStatement( styler, curPos, "WITH" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "CASE" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "TYPECASE" ) )
+ nextLevel++;
+ else
+ if( checkStatement( styler, curPos, "LOCK" ) )
+ nextLevel++;
+ else
+ if( checkKeyIdentOper( styler, curPos, endPos, "PROCEDURE", '(' ) )
+ nextLevel++;
+ else
+ if( checkKeyIdentOper( styler, curPos, endPos, "END", ';' ) ) {
+ int cln = curLine;
+ int clv_old = curLevel;
+ int pos;
+ char ch;
+ bool found;
+ int clv_new;
+ while( cln > 0 ) {
+ clv_new = styler.LevelAt( cln - 1 ) >> 16;
+ if( clv_new < clv_old ) {
+ nextLevel--;
+ pos = styler.LineStart( cln );
+ found = false;
+ while( ( ch = styler.SafeGetCharAt( pos ) ) != '\n' ) {
+ if( ch == 'P' ) {
+ if( styler.StyleAt(pos) == SCE_MODULA_KEYWORD ) {
+ if( checkKeyIdentOper( styler, pos, endPos,
+ "PROCEDURE", '(' ) ) {
+ found = true;
+ break;
+ }
+ }
+ }
+ pos++;
+ }
+ clv_old = clv_new;
+ }
+ cln--;
+ }
+ }
+ else
+ if( checkKeyIdentOper( styler, curPos, endPos, "END", '.' ) )
+ nextLevel--;
+ else
+ if( checkEndSemicolon( styler, curPos, endPos ) )
+ nextLevel--;
+ else {
+ while( styler.StyleAt( curPos + 1 ) == SCE_MODULA_KEYWORD )
+ curPos++;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( IsEOL( styler, curPos ) || ( curPos == endPos - 1 ) ) {
+ int efectiveLevel = curLevel | nextLevel << 16;
+ if( visChars == 0 )
+ efectiveLevel |= SC_FOLDLEVELWHITEFLAG;
+ if( curLevel < nextLevel )
+ efectiveLevel |= SC_FOLDLEVELHEADERFLAG;
+ if( efectiveLevel != styler.LevelAt(curLine) ) {
+ styler.SetLevel(curLine, efectiveLevel );
+ }
+ curLine++;
+ curLevel = nextLevel;
+ if( IsEOL( styler, curPos ) && ( curPos == endPos - 1 ) ) {
+ styler.SetLevel( curLine, ( curLevel | curLevel << 16)
+ | SC_FOLDLEVELWHITEFLAG);
+ }
+ visChars = 0;
+ }
+ curPos++;
+ style = styler.StyleAt( curPos );
+ }
+}
+
+static inline bool skipWhiteSpaces( StyleContext & sc ) {
+ while( isspace( sc.ch ) ) {
+ sc.SetState( SCE_MODULA_DEFAULT );
+ if( sc.More() )
+ sc.Forward();
+ else
+ return false;
+ }
+ return true;
+}
+
+static void ColouriseModulaDoc( unsigned int startPos,
+ int length,
+ int initStyle,
+ WordList *wl[],
+ Accessor &styler ) {
+ WordList& keyWords = *wl[0];
+ WordList& reservedWords = *wl[1];
+ WordList& operators = *wl[2];
+ WordList& pragmaWords = *wl[3];
+ WordList& escapeCodes = *wl[4];
+ WordList& doxyKeys = *wl[5];
+
+ const int BUFLEN = 128;
+
+ char buf[BUFLEN];
+ int i, kl;
+
+ int charPos = 0;
+
+ StyleContext sc( startPos, length, initStyle, styler );
+
+ while( sc.More() ) {
+ switch( sc.state ) {
+ case SCE_MODULA_DEFAULT:
+ if( ! skipWhiteSpaces( sc ) ) break;
+
+ if( sc.ch == '(' && sc.chNext == '*' ) {
+ if( sc.GetRelative(2) == '*' ) {
+ sc.SetState( SCE_MODULA_DOXYCOMM );
+ sc.Forward();
+ } else {
+ sc.SetState( SCE_MODULA_COMMENT );
+ }
+ sc.Forward();
+ }
+ else
+ if( isalpha( sc.ch ) ) {
+ if( isupper( sc.ch ) && isupper( sc.chNext ) ) {
+ for( i = 0; i < BUFLEN - 1; i++ ) {
+ buf[i] = sc.GetRelative(i);
+ if( !isalpha( buf[i] ) && !(buf[i] == '_') )
+ break;
+ }
+ kl = i;
+ buf[kl] = 0;
+
+ if( keyWords.InList( buf ) ) {
+ sc.SetState( SCE_MODULA_KEYWORD );
+ sc.Forward( kl );
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ }
+ else
+ if( reservedWords.InList( buf ) ) {
+ sc.SetState( SCE_MODULA_RESERVED );
+ sc.Forward( kl );
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ } else {
+ /** check procedure identifier */
+ }
+ } else {
+ for( i = 0; i < BUFLEN - 1; i++ ) {
+ buf[i] = sc.GetRelative(i);
+ if( !isalpha( buf[i] ) &&
+ !isdigit( buf[i] ) &&
+ !(buf[i] == '_') )
+ break;
+ }
+ kl = i;
+ buf[kl] = 0;
+
+ sc.SetState( SCE_MODULA_DEFAULT );
+ sc.Forward( kl );
+ continue;
+ }
+ }
+ else
+ if( isdigit( sc.ch ) ) {
+ sc.SetState( SCE_MODULA_NUMBER );
+ continue;
+ }
+ else
+ if( sc.ch == '\"' ) {
+ sc.SetState( SCE_MODULA_STRING );
+ }
+ else
+ if( sc.ch == '\'' ) {
+ charPos = sc.currentPos;
+ sc.SetState( SCE_MODULA_CHAR );
+ }
+ else
+ if( sc.ch == '<' && sc.chNext == '*' ) {
+ sc.SetState( SCE_MODULA_PRAGMA );
+ sc.Forward();
+ } else {
+ unsigned len = IsOperator( sc, operators );
+ if( len > 0 ) {
+ sc.SetState( SCE_MODULA_OPERATOR );
+ sc.Forward( len );
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ } else {
+ DEBUG_STATE( sc.currentPos, sc.ch );
+ }
+ }
+ break;
+
+ case SCE_MODULA_COMMENT:
+ if( sc.ch == '*' && sc.chNext == ')' ) {
+ sc.Forward( 2 );
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ }
+ break;
+
+ case SCE_MODULA_DOXYCOMM:
+ switch( sc.ch ) {
+ case '*':
+ if( sc.chNext == ')' ) {
+ sc.Forward( 2 );
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ }
+ break;
+
+ case '@':
+ if( islower( sc.chNext ) ) {
+ for( i = 0; i < BUFLEN - 1; i++ ) {
+ buf[i] = sc.GetRelative(i+1);
+ if( isspace( buf[i] ) ) break;
+ }
+ buf[i] = 0;
+ kl = i;
+
+ if( doxyKeys.InList( buf ) ) {
+ sc.SetState( SCE_MODULA_DOXYKEY );
+ sc.Forward( kl + 1 );
+ sc.SetState( SCE_MODULA_DOXYCOMM );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case SCE_MODULA_NUMBER:
+ {
+ buf[0] = sc.ch;
+ for( i = 1; i < BUFLEN - 1; i++ ) {
+ buf[i] = sc.GetRelative(i);
+ if( ! isdigit( buf[i] ) )
+ break;
+ }
+ kl = i;
+ buf[kl] = 0;
+
+ switch( sc.GetRelative(kl) ) {
+ case '_':
+ {
+ int base = atoi( buf );
+ if( base < 2 || base > 16 ) {
+ sc.SetState( SCE_MODULA_BADSTR );
+ } else {
+ int imax;
+
+ kl++;
+ for( i = 0; i < BUFLEN - 1; i++ ) {
+ buf[i] = sc.GetRelative(kl+i);
+ if( ! IsDigitOfBase( buf[i], 16 ) ) {
+ break;
+ }
+ }
+ imax = i;
+ for( i = 0; i < imax; i++ ) {
+ if( ! IsDigitOfBase( buf[i], base ) ) {
+ sc.SetState( SCE_MODULA_BADSTR );
+ break;
+ }
+ }
+ kl += imax;
+ }
+ sc.SetState( SCE_MODULA_BASENUM );
+ for( i = 0; i < kl; i++ ) {
+ sc.Forward();
+ }
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ }
+ break;
+
+ case '.':
+ if( sc.GetRelative(kl+1) == '.' ) {
+ kl--;
+ for( i = 0; i < kl; i++ ) {
+ sc.Forward();
+ }
+ sc.Forward();
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ } else {
+ bool doNext = false;
+
+ kl++;
+
+ buf[0] = sc.GetRelative(kl);
+ if( isdigit( buf[0] ) ) {
+ for( i = 0;; i++ ) {
+ if( !isdigit(sc.GetRelative(kl+i)) )
+ break;
+ }
+ kl += i;
+ buf[0] = sc.GetRelative(kl);
+
+ switch( buf[0] )
+ {
+ case 'E':
+ case 'e':
+ case 'D':
+ case 'd':
+ case 'X':
+ case 'x':
+ kl++;
+ buf[0] = sc.GetRelative(kl);
+ if( buf[0] == '-' || buf[0] == '+' ) {
+ kl++;
+ }
+ buf[0] = sc.GetRelative(kl);
+ if( isdigit( buf[0] ) ) {
+ for( i = 0;; i++ ) {
+ if( !isdigit(sc.GetRelative(kl+i)) ) {
+ buf[0] = sc.GetRelative(kl+i);
+ break;
+ }
+ }
+ kl += i;
+ doNext = true;
+ } else {
+ sc.SetState( SCE_MODULA_BADSTR );
+ }
+ break;
+
+ default:
+ doNext = true;
+ break;
+ }
+ } else {
+ sc.SetState( SCE_MODULA_BADSTR );
+ }
+
+ if( doNext ) {
+ if( ! isspace( buf[0] ) &&
+ buf[0] != ')' &&
+ buf[0] != '>' &&
+ buf[0] != '<' &&
+ buf[0] != '=' &&
+ buf[0] != '#' &&
+ buf[0] != '+' &&
+ buf[0] != '-' &&
+ buf[0] != '*' &&
+ buf[0] != '/' &&
+ buf[0] != ',' &&
+ buf[0] != ';'
+ ) {
+ sc.SetState( SCE_MODULA_BADSTR );
+ } else {
+ kl--;
+ }
+ }
+ }
+ sc.SetState( SCE_MODULA_FLOAT );
+ for( i = 0; i < kl; i++ ) {
+ sc.Forward();
+ }
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ break;
+
+ default:
+ for( i = 0; i < kl; i++ ) {
+ sc.Forward();
+ }
+ break;
+ }
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ }
+ break;
+
+ case SCE_MODULA_STRING:
+ if( sc.ch == '\"' ) {
+ sc.Forward();
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ } else {
+ if( sc.ch == '\\' ) {
+ i = 1;
+ if( IsDigitOfBase( sc.chNext, 8 ) ) {
+ for( i = 1; i < BUFLEN - 1; i++ ) {
+ if( ! IsDigitOfBase(sc.GetRelative(i+1), 8 ) )
+ break;
+ }
+ if( i == 3 ) {
+ sc.SetState( SCE_MODULA_STRSPEC );
+ } else {
+ sc.SetState( SCE_MODULA_BADSTR );
+ }
+ } else {
+ buf[0] = sc.chNext;
+ buf[1] = 0;
+
+ if( escapeCodes.InList( buf ) ) {
+ sc.SetState( SCE_MODULA_STRSPEC );
+ } else {
+ sc.SetState( SCE_MODULA_BADSTR );
+ }
+ }
+ sc.Forward(i+1);
+ sc.SetState( SCE_MODULA_STRING );
+ continue;
+ }
+ }
+ break;
+
+ case SCE_MODULA_CHAR:
+ if( sc.ch == '\'' ) {
+ sc.Forward();
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ }
+ else
+ if( ( sc.currentPos - charPos ) == 1 ) {
+ if( sc.ch == '\\' ) {
+ i = 1;
+ if( IsDigitOfBase( sc.chNext, 8 ) ) {
+ for( i = 1; i < BUFLEN - 1; i++ ) {
+ if( ! IsDigitOfBase(sc.GetRelative(i+1), 8 ) )
+ break;
+ }
+ if( i == 3 ) {
+ sc.SetState( SCE_MODULA_CHARSPEC );
+ } else {
+ sc.SetState( SCE_MODULA_BADSTR );
+ }
+ } else {
+ buf[0] = sc.chNext;
+ buf[1] = 0;
+
+ if( escapeCodes.InList( buf ) ) {
+ sc.SetState( SCE_MODULA_CHARSPEC );
+ } else {
+ sc.SetState( SCE_MODULA_BADSTR );
+ }
+ }
+ sc.Forward(i+1);
+ sc.SetState( SCE_MODULA_CHAR );
+ continue;
+ }
+ } else {
+ sc.SetState( SCE_MODULA_BADSTR );
+ sc.Forward();
+ sc.SetState( SCE_MODULA_CHAR );
+ continue;
+ }
+ break;
+
+ case SCE_MODULA_PRAGMA:
+ if( sc.ch == '*' && sc.chNext == '>' ) {
+ sc.Forward();
+ sc.Forward();
+ sc.SetState( SCE_MODULA_DEFAULT );
+ continue;
+ }
+ else
+ if( isupper( sc.ch ) && isupper( sc.chNext ) ) {
+ buf[0] = sc.ch;
+ buf[1] = sc.chNext;
+ for( i = 2; i < BUFLEN - 1; i++ ) {
+ buf[i] = sc.GetRelative(i);
+ if( !isupper( buf[i] ) )
+ break;
+ }
+ kl = i;
+ buf[kl] = 0;
+ if( pragmaWords.InList( buf ) ) {
+ sc.SetState( SCE_MODULA_PRGKEY );
+ sc.Forward( kl );
+ sc.SetState( SCE_MODULA_PRAGMA );
+ continue;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ sc.Forward();
+ }
+ sc.Complete();
+}
+
+static const char *const modulaWordListDesc[] =
+{
+ "Keywords",
+ "ReservedKeywords",
+ "Operators",
+ "PragmaKeyswords",
+ "EscapeCodes",
+ "DoxygeneKeywords",
+ 0
+};
+
+LexerModule lmModula( SCLEX_MODULA, ColouriseModulaDoc, "modula", FoldModulaDoc,
+ modulaWordListDesc);
diff --git a/scintilla/lexers/LexOthers.cxx b/scintilla/lexers/LexOthers.cxx index bcc9733..b2e3b2b 100644 --- a/scintilla/lexers/LexOthers.cxx +++ b/scintilla/lexers/LexOthers.cxx @@ -929,8 +929,8 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin // Command or return status
return SCE_ERR_CMD;
} else if (lineBuffer[0] == '<') {
- // Diff removal, but not interested. Trapped to avoid hitting CTAG cases.
- return SCE_ERR_DEFAULT;
+ // Diff removal.
+ return SCE_ERR_DIFF_DELETION;
} else if (lineBuffer[0] == '!') {
return SCE_ERR_DIFF_CHANGED;
} else if (lineBuffer[0] == '+') {
|