aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2008-10-22 07:25:28 +0000
committernyamatongwe <unknown>2008-10-22 07:25:28 +0000
commitdd79dcebb055358345a97c1c4482a8a5143b48b5 (patch)
tree400aecaa85e0260c58f8c3465cf1a3994155abe4
parent76402e71b6bb122be4a5f57495f1eaefa822c7e8 (diff)
downloadscintilla-mirror-dd79dcebb055358345a97c1c4482a8a5143b48b5.tar.gz
Addition of lexers for TAL, TACL, and COBOL from ozlooper. FR #2127406
-rw-r--r--gtk/makefile17
-rw-r--r--gtk/scintilla.mak9
-rw-r--r--include/SciLexer.h3
-rw-r--r--include/Scintilla.iface3
-rw-r--r--macosx/makefile17
-rw-r--r--src/KeyWords.cxx3
-rw-r--r--src/LexCOBOL.cxx364
-rw-r--r--src/LexTACL.cxx393
-rw-r--r--src/LexTAL.cxx392
-rw-r--r--vcbuild/SciLexer.dsp12
-rw-r--r--win32/makefile17
-rw-r--r--win32/scintilla.mak9
-rw-r--r--win32/scintilla_vc6.mak9
13 files changed, 1224 insertions, 24 deletions
diff --git a/gtk/makefile b/gtk/makefile
index 775335616..142ae7ce4 100644
--- a/gtk/makefile
+++ b/gtk/makefile
@@ -65,14 +65,15 @@ endif
LEXOBJS=\
LexAbaqus.o LexAda.o LexAPDL.o LexAsm.o LexAsn1.o LexASY.o LexAU3.o LexAVE.o \
LexBaan.o LexBash.o LexBasic.o LexBullant.o LexCaml.o LexCLW.o LexCmake.o \
-LexConf.o LexCPP.o LexCrontab.o LexCsound.o LexCSS.o LexD.o LexEiffel.o \
-LexErlang.o LexEScript.o LexFlagship.o LexForth.o LexFortran.o LexGAP.o \
-LexGui4Cli.o LexHaskell.o LexHTML.o LexInno.o LexKix.o LexLisp.o LexLout.o \
-LexLua.o LexMagik.o LexMatlab.o LexMetapost.o LexMMIXAL.o LexMPT.o LexMSSQL.o \
-LexMySQL.o LexNsis.o LexOpal.o LexOthers.o LexPascal.o LexPB.o LexPerl.o \
-LexPLM.o LexPOV.o LexPowerShell.o LexProgress.o LexPS.o LexPython.o LexR.o \
-LexRebol.o LexRuby.o LexScriptol.o LexSmalltalk.o LexSpecman.o LexSpice.o \
-LexSQL.o LexTADS3.o LexTCL.o LexTeX.o LexVB.o LexVerilog.o LexVHDL.o LexYAML.o
+LexCOBOL.o LexConf.o LexCPP.o LexCrontab.o LexCsound.o LexCSS.o LexD.o \
+LexEiffel.o LexErlang.o LexEScript.o LexFlagship.o LexForth.o LexFortran.o \
+LexGAP.o LexGui4Cli.o LexHaskell.o LexHTML.o LexInno.o LexKix.o LexLisp.o \
+LexLout.o LexLua.o LexMagik.o LexMatlab.o LexMetapost.o LexMMIXAL.o LexMPT.o \
+LexMSSQL.o LexMySQL.o LexNsis.o LexOpal.o LexOthers.o LexPascal.o LexPB.o \
+LexPerl.o LexPLM.o LexPOV.o LexPowerShell.o LexProgress.o LexPS.o LexPython.o \
+LexR.o LexRebol.o LexRuby.o LexScriptol.o LexSmalltalk.o LexSpecman.o \
+LexSpice.o LexSQL.o LexTACL.o LexTADS3.o LexTAL.o LexTCL.o LexTeX.o LexVB.o \
+LexVerilog.o LexVHDL.o LexYAML.o
#--Autogenerated -- end of automatically generated section
all: $(COMPLIB)
diff --git a/gtk/scintilla.mak b/gtk/scintilla.mak
index e60e411d2..3a010fd2b 100644
--- a/gtk/scintilla.mak
+++ b/gtk/scintilla.mak
@@ -158,6 +158,7 @@ LEXOBJS=\
$(DIR_O)\LexCaml.obj \
$(DIR_O)\LexCLW.obj \
$(DIR_O)\LexCmake.obj \
+ $(DIR_O)\LexCOBOL.obj \
$(DIR_O)\LexConf.obj \
$(DIR_O)\LexCPP.obj \
$(DIR_O)\LexCrontab.obj \
@@ -206,7 +207,9 @@ LEXOBJS=\
$(DIR_O)\LexSpecman.obj \
$(DIR_O)\LexSpice.obj \
$(DIR_O)\LexSQL.obj \
+ $(DIR_O)\LexTACL.obj \
$(DIR_O)\LexTADS3.obj \
+ $(DIR_O)\LexTAL.obj \
$(DIR_O)\LexTCL.obj \
$(DIR_O)\LexTeX.obj \
$(DIR_O)\LexVB.obj \
@@ -385,6 +388,8 @@ $(DIR_O)\LexCLW.obj: ..\src\LexCLW.cxx $(LEX_HEADERS)
$(DIR_O)\LexCmake.obj: ..\src\LexCmake.cxx $(LEX_HEADERS)
+$(DIR_O)\LexCOBOL.obj: ..\src\LexCOBOL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexConf.obj: ..\src\LexConf.cxx $(LEX_HEADERS)
$(DIR_O)\LexCPP.obj: ..\src\LexCPP.cxx $(LEX_HEADERS)
@@ -481,8 +486,12 @@ $(DIR_O)\LexSpice.obj: ..\src\LexSpice.cxx $(LEX_HEADERS)
$(DIR_O)\LexSQL.obj: ..\src\LexSQL.cxx $(LEX_HEADERS)
+$(DIR_O)\LexTACL.obj: ..\src\LexTACL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexTADS3.obj: ..\src\LexTADS3.cxx $(LEX_HEADERS)
+$(DIR_O)\LexTAL.obj: ..\src\LexTAL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexTCL.obj: ..\src\LexTCL.cxx $(LEX_HEADERS)
$(DIR_O)\LexTeX.obj: ..\src\LexTeX.cxx $(LEX_HEADERS)
diff --git a/include/SciLexer.h b/include/SciLexer.h
index defd72cfa..cc19f684d 100644
--- a/include/SciLexer.h
+++ b/include/SciLexer.h
@@ -103,6 +103,9 @@
#define SCLEX_POWERSHELL 88
#define SCLEX_MYSQL 89
#define SCLEX_PO 90
+#define SCLEX_TAL 91
+#define SCLEX_COBOL 92
+#define SCLEX_TACL 93
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 35daa6420..1d4612a65 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -2009,6 +2009,9 @@ val SCLEX_MAGIK=87
val SCLEX_POWERSHELL=88
val SCLEX_MYSQL=89
val SCLEX_PO=90
+val SCLEX_TAL=91
+val SCLEX_COBOL=92
+val SCLEX_TACL=93
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
diff --git a/macosx/makefile b/macosx/makefile
index 5cd58b91e..bafef84b9 100644
--- a/macosx/makefile
+++ b/macosx/makefile
@@ -65,14 +65,15 @@ endif
LEXOBJS=\
LexAbaqus.o LexAda.o LexAPDL.o LexAsm.o LexAsn1.o LexASY.o LexAU3.o LexAVE.o \
LexBaan.o LexBash.o LexBasic.o LexBullant.o LexCaml.o LexCLW.o LexCmake.o \
-LexConf.o LexCPP.o LexCrontab.o LexCsound.o LexCSS.o LexD.o LexEiffel.o \
-LexErlang.o LexEScript.o LexFlagship.o LexForth.o LexFortran.o LexGAP.o \
-LexGui4Cli.o LexHaskell.o LexHTML.o LexInno.o LexKix.o LexLisp.o LexLout.o \
-LexLua.o LexMagik.o LexMatlab.o LexMetapost.o LexMMIXAL.o LexMPT.o LexMSSQL.o \
-LexMySQL.o LexNsis.o LexOpal.o LexOthers.o LexPascal.o LexPB.o LexPerl.o \
-LexPLM.o LexPOV.o LexPowerShell.o LexProgress.o LexPS.o LexPython.o LexR.o \
-LexRebol.o LexRuby.o LexScriptol.o LexSmalltalk.o LexSpecman.o LexSpice.o \
-LexSQL.o LexTADS3.o LexTCL.o LexTeX.o LexVB.o LexVerilog.o LexVHDL.o LexYAML.o
+LexCOBOL.o LexConf.o LexCPP.o LexCrontab.o LexCsound.o LexCSS.o LexD.o \
+LexEiffel.o LexErlang.o LexEScript.o LexFlagship.o LexForth.o LexFortran.o \
+LexGAP.o LexGui4Cli.o LexHaskell.o LexHTML.o LexInno.o LexKix.o LexLisp.o \
+LexLout.o LexLua.o LexMagik.o LexMatlab.o LexMetapost.o LexMMIXAL.o LexMPT.o \
+LexMSSQL.o LexMySQL.o LexNsis.o LexOpal.o LexOthers.o LexPascal.o LexPB.o \
+LexPerl.o LexPLM.o LexPOV.o LexPowerShell.o LexProgress.o LexPS.o LexPython.o \
+LexR.o LexRebol.o LexRuby.o LexScriptol.o LexSmalltalk.o LexSpecman.o \
+LexSpice.o LexSQL.o LexTACL.o LexTADS3.o LexTAL.o LexTCL.o LexTeX.o LexVB.o \
+LexVerilog.o LexVHDL.o LexYAML.o
#--Autogenerated -- end of automatically generated section
# The LEXOBJS have to be treated specially as the functions in them are not called from external code
diff --git a/src/KeyWords.cxx b/src/KeyWords.cxx
index b38e515a0..4907571cf 100644
--- a/src/KeyWords.cxx
+++ b/src/KeyWords.cxx
@@ -159,6 +159,7 @@ int Scintilla_LinkLexers() {
LINK_LEXER(lmClw);
LINK_LEXER(lmClwNoCase);
LINK_LEXER(lmCmake);
+ LINK_LEXER(lmCOBOL);
LINK_LEXER(lmConf);
LINK_LEXER(lmCPP);
LINK_LEXER(lmCPPNoCase);
@@ -221,7 +222,9 @@ int Scintilla_LinkLexers() {
LINK_LEXER(lmSpecman);
LINK_LEXER(lmSpice);
LINK_LEXER(lmSQL);
+ LINK_LEXER(lmTACL);
LINK_LEXER(lmTADS3);
+ LINK_LEXER(lmTAL);
LINK_LEXER(lmTCL);
LINK_LEXER(lmTeX);
LINK_LEXER(lmVB);
diff --git a/src/LexCOBOL.cxx b/src/LexCOBOL.cxx
new file mode 100644
index 000000000..4ad8e9fc1
--- /dev/null
+++ b/src/LexCOBOL.cxx
@@ -0,0 +1,364 @@
+// Scintilla source code edit control
+/** @file LexCOBOL.cxx
+ ** Lexer for COBOL
+ ** Based on LexPascal.cxx
+ ** Written by Laurent le Tynevez
+ ** Updated by Simon Steele <s.steele@pnotepad.org> September 2002
+ ** Updated by Mathias Rauen <scite@madshi.net> May 2003 (Delphi adjustments)
+ ** Updated by Rod Falck, Aug 2006 Converted to COBOL
+ **/
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+#include "StyleContext.h"
+
+#define IN_DIVISION 0x01
+#define IN_DECLARATIVES 0x02
+#define IN_SECTION 0x04
+#define IN_PARAGRAPH 0x08
+#define IN_FLAGS 0xF
+#define NOT_HEADER 0x10
+
+inline bool isCOBOLoperator(char ch)
+ {
+ return isoperator(ch);
+ }
+
+inline bool isCOBOLwordchar(char ch)
+ {
+ return isascii(ch) && (isalnum(ch) || ch == '-');
+
+ }
+
+inline bool isCOBOLwordstart(char ch)
+ {
+ return isascii(ch) && isalnum(ch);
+ }
+
+static int CountBits(int nBits)
+ {
+ int count = 0;
+ for (int i = 0; i < 32; ++i)
+ {
+ count += nBits & 1;
+ nBits >>= 1;
+ }
+ return count;
+ }
+
+static void getRange(unsigned int start,
+ unsigned int end,
+ Accessor &styler,
+ char *s,
+ unsigned int len) {
+ unsigned int i = 0;
+ while ((i < end - start + 1) && (i < len-1)) {
+ s[i] = static_cast<char>(tolower(styler[start + i]));
+ i++;
+ }
+ s[i] = '\0';
+}
+
+static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr) {
+ styler.ColourTo(end, attr);
+}
+
+
+static int classifyWordCOBOL(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, int nContainment, bool *bAarea) {
+ int ret = 0;
+
+ WordList& a_keywords = *keywordlists[0];
+ WordList& b_keywords = *keywordlists[1];
+ WordList& c_keywords = *keywordlists[2];
+
+ char s[100];
+ getRange(start, end, styler, s, sizeof(s));
+
+ char chAttr = SCE_C_IDENTIFIER;
+ if (isdigit(s[0]) || (s[0] == '.')) {
+ chAttr = SCE_C_NUMBER;
+ char *p = s + 1;
+ while (*p) {
+ if (!isdigit(*p) && isCOBOLwordchar(*p)) {
+ chAttr = SCE_C_IDENTIFIER;
+ break;
+ }
+ ++p;
+ }
+ }
+ else {
+ if (a_keywords.InList(s)) {
+ chAttr = SCE_C_WORD;
+ }
+ else if (b_keywords.InList(s)) {
+ chAttr = SCE_C_WORD2;
+ }
+ else if (c_keywords.InList(s)) {
+ chAttr = SCE_C_UUID;
+ }
+ }
+ if (*bAarea) {
+ if (strcmp(s, "division") == 0) {
+ ret = IN_DIVISION;
+ // we've determined the containment, anything else is just ignored for those purposes
+ *bAarea = false;
+ } else if (strcmp(s, "declaratives") == 0) {
+ ret = IN_DIVISION | IN_DECLARATIVES;
+ if (nContainment & IN_DECLARATIVES)
+ ret |= NOT_HEADER | IN_SECTION;
+ // we've determined the containment, anything else is just ignored for those purposes
+ *bAarea = false;
+ } else if (strcmp(s, "section") == 0) {
+ ret = (nContainment &~ IN_PARAGRAPH) | IN_SECTION;
+ // we've determined the containment, anything else is just ignored for those purposes
+ *bAarea = false;
+ } else if (strcmp(s, "end") == 0 && (nContainment & IN_DECLARATIVES)) {
+ ret = IN_DIVISION | IN_DECLARATIVES | IN_SECTION | NOT_HEADER;
+ } else {
+ ret = nContainment | IN_PARAGRAPH;
+ }
+ }
+ ColourTo(styler, end, chAttr);
+ return ret;
+}
+
+static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+
+ styler.StartAt(startPos);
+
+ int state = initStyle;
+ if (state == SCE_C_CHARACTER) // Does not leak onto next line
+ state = SCE_C_DEFAULT;
+ char chPrev = ' ';
+ char chNext = styler[startPos];
+ unsigned int lengthDoc = startPos + length;
+
+ int nContainment;
+
+ int currentLine = styler.GetLine(startPos);
+ if (currentLine > 0) {
+ styler.SetLineState(currentLine, styler.GetLineState(currentLine-1));
+ nContainment = styler.GetLineState(currentLine);
+ nContainment &= ~NOT_HEADER;
+ } else {
+ styler.SetLineState(currentLine, 0);
+ nContainment = 0;
+ }
+
+ styler.StartSegment(startPos);
+ bool bNewLine = true;
+ bool bAarea = !isspacechar(chNext);
+ int column = 0;
+ for (unsigned int i = startPos; i < lengthDoc; i++) {
+ char ch = chNext;
+
+ chNext = styler.SafeGetCharAt(i + 1);
+
+ ++column;
+
+ if (bNewLine) {
+ column = 0;
+ }
+ if (column <= 1 && !bAarea) {
+ bAarea = !isspacechar(ch);
+ }
+ bool bSetNewLine = false;
+ if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
+ // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
+ // Avoid triggering two times on Dos/Win
+ // End of line
+ if (state == SCE_C_CHARACTER) {
+ ColourTo(styler, i, state);
+ state = SCE_C_DEFAULT;
+ }
+ styler.SetLineState(currentLine, nContainment);
+ currentLine++;
+ bSetNewLine = true;
+ if (nContainment & NOT_HEADER)
+ nContainment &= ~(NOT_HEADER | IN_DECLARATIVES | IN_SECTION);
+ }
+
+ if (styler.IsLeadByte(ch)) {
+ chNext = styler.SafeGetCharAt(i + 2);
+ chPrev = ' ';
+ i += 1;
+ continue;
+ }
+
+ if (state == SCE_C_DEFAULT) {
+ if (isCOBOLwordstart(ch) || (ch == '$' && isalpha(chNext))) {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_IDENTIFIER;
+ } else if (column == 0 && ch == '*' && chNext != '*') {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_COMMENTLINE;
+ } else if (column == 0 && ch == '/' && chNext != '*') {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_COMMENTLINE;
+ } else if (column == 0 && ch == '*' && chNext == '*') {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_COMMENTDOC;
+ } else if (column == 0 && ch == '/' && chNext == '*') {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_COMMENTDOC;
+ } else if (ch == '"') {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_STRING;
+ } else if (ch == '\'') {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_CHARACTER;
+ } else if (ch == '?' && column == 0) {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_PREPROCESSOR;
+ } else if (isCOBOLoperator(ch)) {
+ ColourTo(styler, i-1, state);
+ ColourTo(styler, i, SCE_C_OPERATOR);
+ }
+ } else if (state == SCE_C_IDENTIFIER) {
+ if (!isCOBOLwordchar(ch)) {
+ int lStateChange = classifyWordCOBOL(styler.GetStartSegment(), i - 1, keywordlists, styler, nContainment, &bAarea);
+
+ if(lStateChange != 0) {
+ styler.SetLineState(currentLine, lStateChange);
+ nContainment = lStateChange;
+ }
+
+ state = SCE_C_DEFAULT;
+ chNext = styler.SafeGetCharAt(i + 1);
+ if (ch == '"') {
+ state = SCE_C_STRING;
+ } else if (ch == '\'') {
+ state = SCE_C_CHARACTER;
+ } else if (isCOBOLoperator(ch)) {
+ ColourTo(styler, i, SCE_C_OPERATOR);
+ }
+ }
+ } else {
+ if (state == SCE_C_PREPROCESSOR) {
+ if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_COMMENT) {
+ if (ch == '\r' || ch == '\n') {
+ ColourTo(styler, i, state);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_COMMENTDOC) {
+ if (ch == '\r' || ch == '\n') {
+ if (((i > styler.GetStartSegment() + 2) || (
+ (initStyle == SCE_C_COMMENTDOC) &&
+ (styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
+ ColourTo(styler, i, state);
+ state = SCE_C_DEFAULT;
+ }
+ }
+ } else if (state == SCE_C_COMMENTLINE) {
+ if (ch == '\r' || ch == '\n') {
+ ColourTo(styler, i-1, state);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_STRING) {
+ if (ch == '"') {
+ ColourTo(styler, i, state);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_CHARACTER) {
+ if (ch == '\'') {
+ ColourTo(styler, i, state);
+ state = SCE_C_DEFAULT;
+ }
+ }
+ }
+ chPrev = ch;
+ bNewLine = bSetNewLine;
+ if (bNewLine)
+ {
+ bAarea = false;
+ }
+ }
+ ColourTo(styler, lengthDoc - 1, state);
+}
+
+static void FoldCOBOLDoc(unsigned int startPos, int length, int, WordList *[],
+ Accessor &styler) {
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ unsigned int endPos = startPos + length;
+ int visibleChars = 0;
+ int lineCurrent = styler.GetLine(startPos);
+ int levelPrev = lineCurrent > 0 ? styler.LevelAt(lineCurrent - 1) & SC_FOLDLEVELNUMBERMASK : 0xFFF;
+ char chNext = styler[startPos];
+
+ bool bNewLine = true;
+ bool bAarea = !isspacechar(chNext);
+ int column = 0;
+ bool bComment = false;
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ ++column;
+
+ if (bNewLine) {
+ column = 0;
+ bComment = (ch == '*' || ch == '/' || ch == '?');
+ }
+ if (column <= 1 && !bAarea) {
+ bAarea = !isspacechar(ch);
+ }
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+ if (atEOL) {
+ int nContainment = styler.GetLineState(lineCurrent);
+ int lev = CountBits(nContainment & IN_FLAGS) | SC_FOLDLEVELBASE;
+ if (bAarea && !bComment)
+ --lev;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((bAarea) && (visibleChars > 0) && !(nContainment & NOT_HEADER) && !bComment)
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ }
+ if ((lev & SC_FOLDLEVELNUMBERMASK) <= (levelPrev & SC_FOLDLEVELNUMBERMASK)) {
+ // this level is at the same level or less than the previous line
+ // therefore these is nothing for the previous header to collapse, so remove the header
+ styler.SetLevel(lineCurrent - 1, levelPrev & ~SC_FOLDLEVELHEADERFLAG);
+ }
+ levelPrev = lev;
+ visibleChars = 0;
+ bAarea = false;
+ bNewLine = true;
+ lineCurrent++;
+ } else {
+ bNewLine = false;
+ }
+
+
+ if (!isspacechar(ch))
+ visibleChars++;
+ }
+
+ // Fill in the real level of the next line, keeping the current flags as they will be filled in later
+ int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
+ styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+}
+
+static const char * const COBOLWordListDesc[] = {
+ "A Keywords",
+ "B Keywords",
+ "Extended Keywords",
+ 0
+};
+
+LexerModule lmCOBOL(SCLEX_COBOL, ColouriseCOBOLDoc, "COBOL", FoldCOBOLDoc, COBOLWordListDesc);
diff --git a/src/LexTACL.cxx b/src/LexTACL.cxx
new file mode 100644
index 000000000..9259e770c
--- /dev/null
+++ b/src/LexTACL.cxx
@@ -0,0 +1,393 @@
+// Scintilla source code edit control
+/** @file LexTAL.cxx
+ ** Lexer for TAL
+ ** Based on LexPascal.cxx
+ ** Written by Laurent le Tynevez
+ ** Updated by Simon Steele <s.steele@pnotepad.org> September 2002
+ ** Updated by Mathias Rauen <scite@madshi.net> May 2003 (Delphi adjustments)
+ ** Updated by Rod Falck, Aug 2006 Converted to TACL
+ **/
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+#include "StyleContext.h"
+
+inline bool isTACLoperator(char ch)
+ {
+ return ch == '\'' || isoperator(ch);
+ }
+
+inline bool isTACLwordchar(char ch)
+ {
+ return ch == '#' || ch == '^' || ch == '|' || ch == '_' || iswordchar(ch);
+ }
+
+inline bool isTACLwordstart(char ch)
+ {
+ return ch == '#' || ch == '|' || ch == '_' || iswordstart(ch);
+ }
+
+static void getRange(unsigned int start,
+ unsigned int end,
+ Accessor &styler,
+ char *s,
+ unsigned int len) {
+ unsigned int i = 0;
+ while ((i < end - start + 1) && (i < len-1)) {
+ s[i] = static_cast<char>(tolower(styler[start + i]));
+ i++;
+ }
+ s[i] = '\0';
+}
+
+static bool IsStreamCommentStyle(int style) {
+ return style == SCE_C_COMMENT ||
+ style == SCE_C_COMMENTDOC ||
+ style == SCE_C_COMMENTDOCKEYWORD ||
+ style == SCE_C_COMMENTDOCKEYWORDERROR;
+}
+
+static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr, bool bInAsm) {
+ if ((bInAsm) && (attr == SCE_C_OPERATOR || attr == SCE_C_NUMBER || attr == SCE_C_DEFAULT || attr == SCE_C_WORD || attr == SCE_C_IDENTIFIER)) {
+ styler.ColourTo(end, SCE_C_REGEX);
+ } else
+ styler.ColourTo(end, attr);
+}
+
+// returns 1 if the item starts a class definition, and -1 if the word is "end", and 2 if the word is "asm"
+static int classifyWordTACL(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, bool bInAsm) {
+ int ret = 0;
+
+ WordList& keywords = *keywordlists[0];
+ WordList& builtins = *keywordlists[1];
+ WordList& commands = *keywordlists[2];
+
+ char s[100];
+ getRange(start, end, styler, s, sizeof(s));
+
+ char chAttr = SCE_C_IDENTIFIER;
+ if (isdigit(s[0]) || (s[0] == '.')) {
+ chAttr = SCE_C_NUMBER;
+ }
+ else {
+ if (s[0] == '#' || keywords.InList(s)) {
+ chAttr = SCE_C_WORD;
+
+ if (strcmp(s, "asm") == 0) {
+ ret = 2;
+ }
+ else if (strcmp(s, "end") == 0) {
+ ret = -1;
+ }
+ }
+ else if (s[0] == '|' || builtins.InList(s)) {
+ chAttr = SCE_C_WORD2;
+ }
+ else if (commands.InList(s)) {
+ chAttr = SCE_C_UUID;
+ }
+ else if (strcmp(s, "comment") == 0) {
+ chAttr = SCE_C_COMMENTLINE;
+ ret = 3;
+ }
+ }
+ ColourTo(styler, end, chAttr, (bInAsm && ret != -1));
+ return ret;
+}
+
+static int classifyFoldPointTACL(const char* s) {
+ int lev = 0;
+ if (s[0] == '[')
+ lev=1;
+ else if (s[0] == ']')
+ lev=-1;
+ return lev;
+}
+
+static void ColouriseTACLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+
+ styler.StartAt(startPos);
+
+ int state = initStyle;
+ if (state == SCE_C_CHARACTER) // Does not leak onto next line
+ state = SCE_C_DEFAULT;
+ char chPrev = ' ';
+ char chNext = styler[startPos];
+ unsigned int lengthDoc = startPos + length;
+
+ bool bInClassDefinition;
+
+ int currentLine = styler.GetLine(startPos);
+ if (currentLine > 0) {
+ styler.SetLineState(currentLine, styler.GetLineState(currentLine-1));
+ bInClassDefinition = (styler.GetLineState(currentLine) == 1);
+ } else {
+ styler.SetLineState(currentLine, 0);
+ bInClassDefinition = false;
+ }
+
+ bool bInAsm = (state == SCE_C_REGEX);
+ if (bInAsm)
+ state = SCE_C_DEFAULT;
+
+ styler.StartSegment(startPos);
+ int visibleChars = 0;
+ unsigned int i;
+ for (i = startPos; i < lengthDoc; i++) {
+ char ch = chNext;
+
+ chNext = styler.SafeGetCharAt(i + 1);
+
+ if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
+ // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
+ // Avoid triggering two times on Dos/Win
+ // End of line
+ if (state == SCE_C_CHARACTER) {
+ ColourTo(styler, i, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ visibleChars = 0;
+ currentLine++;
+ styler.SetLineState(currentLine, (bInClassDefinition ? 1 : 0));
+ }
+
+ if (styler.IsLeadByte(ch)) {
+ chNext = styler.SafeGetCharAt(i + 2);
+ chPrev = ' ';
+ i += 1;
+ continue;
+ }
+
+ if (state == SCE_C_DEFAULT) {
+ if (isTACLwordstart(ch)) {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_IDENTIFIER;
+ } else if (ch == '{') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_COMMENT;
+ } else if (ch == '{' && chNext == '*') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_COMMENTDOC;
+ } else if (ch == '=' && chNext == '=') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_COMMENTLINE;
+ } else if (ch == '"') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_STRING;
+ } else if (ch == '?' && visibleChars == 0) {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_PREPROCESSOR;
+ } else if (isTACLoperator(ch)) {
+ ColourTo(styler, i-1, state, bInAsm);
+ ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
+ }
+ } else if (state == SCE_C_IDENTIFIER) {
+ if (!isTACLwordchar(ch)) {
+ int lStateChange = classifyWordTACL(styler.GetStartSegment(), i - 1, keywordlists, styler, bInAsm);
+
+ if(lStateChange == 1) {
+ styler.SetLineState(currentLine, 1);
+ bInClassDefinition = true;
+ } else if(lStateChange == 2) {
+ bInAsm = true;
+ } else if(lStateChange == -1) {
+ styler.SetLineState(currentLine, 0);
+ bInClassDefinition = false;
+ bInAsm = false;
+ }
+
+ if (lStateChange == 3) {
+ state = SCE_C_COMMENTLINE;
+ }
+ else {
+ state = SCE_C_DEFAULT;
+ chNext = styler.SafeGetCharAt(i + 1);
+ if (ch == '{') {
+ state = SCE_C_COMMENT;
+ } else if (ch == '{' && chNext == '*') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_COMMENTDOC;
+ } else if (ch == '=' && chNext == '=') {
+ state = SCE_C_COMMENTLINE;
+ } else if (ch == '"') {
+ state = SCE_C_STRING;
+ } else if (isTACLoperator(ch)) {
+ ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
+ }
+ }
+ }
+ } else {
+ if (state == SCE_C_PREPROCESSOR) {
+ if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_COMMENT) {
+ if (ch == '}' || (ch == '\r' || ch == '\n') ) {
+ ColourTo(styler, i, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_COMMENTDOC) {
+ if (ch == '}' || (ch == '\r' || ch == '\n')) {
+ if (((i > styler.GetStartSegment() + 2) || (
+ (initStyle == SCE_C_COMMENTDOC) &&
+ (styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
+ ColourTo(styler, i, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ }
+ } else if (state == SCE_C_COMMENTLINE) {
+ if (ch == '\r' || ch == '\n') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_STRING) {
+ if (ch == '"' || ch == '\r' || ch == '\n') {
+ ColourTo(styler, i, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ }
+ }
+ if (!isspacechar(ch))
+ visibleChars++;
+ chPrev = ch;
+ }
+
+ // Process to end of document
+ if (state == SCE_C_IDENTIFIER) {
+ classifyWordTACL(styler.GetStartSegment(), i - 1, keywordlists, styler, bInAsm);
+ }
+ else
+ ColourTo(styler, lengthDoc - 1, state, bInAsm);
+}
+
+static void FoldTACLDoc(unsigned int startPos, int length, int initStyle, WordList *[],
+ Accessor &styler) {
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ unsigned int endPos = startPos + length;
+ int visibleChars = 0;
+ int lineCurrent = styler.GetLine(startPos);
+ int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
+ int levelCurrent = levelPrev;
+ char chNext = styler[startPos];
+ int styleNext = styler.StyleAt(startPos);
+ int style = initStyle;
+ bool section = false;
+
+ int lastStart = 0;
+
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ int stylePrev = style;
+ style = styleNext;
+ styleNext = styler.StyleAt(i + 1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+ if (stylePrev == SCE_C_DEFAULT && (style == SCE_C_WORD || style == SCE_C_PREPROCESSOR))
+ {
+ // Store last word start point.
+ lastStart = i;
+ }
+
+ if (stylePrev == SCE_C_WORD || stylePrev == SCE_C_PREPROCESSOR) {
+ if(isTACLwordchar(ch) && !isTACLwordchar(chNext)) {
+ char s[100];
+ getRange(lastStart, i, styler, s, sizeof(s));
+ if (stylePrev == SCE_C_PREPROCESSOR && strcmp(s, "?section") == 0)
+ {
+ section = true;
+ levelCurrent = 1;
+ levelPrev = 0;
+ }
+ else if (stylePrev == SCE_C_WORD)
+ levelCurrent += classifyFoldPointTACL(s);
+ }
+ }
+
+ if (style == SCE_C_OPERATOR) {
+ if (ch == '[') {
+ levelCurrent++;
+ } else if (ch == ']') {
+ levelCurrent--;
+ }
+ }
+ if (foldComment && (style == SCE_C_COMMENTLINE)) {
+ if ((ch == '/') && (chNext == '/')) {
+ char chNext2 = styler.SafeGetCharAt(i + 2);
+ if (chNext2 == '{') {
+ levelCurrent++;
+ } else if (chNext2 == '}') {
+ levelCurrent--;
+ }
+ }
+ }
+
+ if (foldPreprocessor && (style == SCE_C_PREPROCESSOR)) {
+ if (ch == '{' && chNext == '$') {
+ unsigned int j=i+2; // skip {$
+ while ((j<endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
+ j++;
+ }
+ if (styler.Match(j, "region") || styler.Match(j, "if")) {
+ levelCurrent++;
+ } else if (styler.Match(j, "end")) {
+ levelCurrent--;
+ }
+ }
+ }
+
+ if (foldComment && IsStreamCommentStyle(style)) {
+ if (!IsStreamCommentStyle(stylePrev)) {
+ levelCurrent++;
+ } else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
+ // Comments don't end at end of line and the next character may be unstyled.
+ levelCurrent--;
+ }
+ }
+ if (atEOL) {
+ int lev = levelPrev | SC_FOLDLEVELBASE;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((levelCurrent > levelPrev || section) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ }
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
+ section = false;
+ }
+
+ if (!isspacechar(ch))
+ visibleChars++;
+ }
+
+ // Fill in the real level of the next line, keeping the current flags as they will be filled in later
+ int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
+ styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+}
+
+static const char * const TACLWordListDesc[] = {
+ "Builtins",
+ "Labels",
+ "Commands",
+ 0
+};
+
+LexerModule lmTACL(SCLEX_TACL, ColouriseTACLDoc, "TACL", FoldTACLDoc, TACLWordListDesc);
diff --git a/src/LexTAL.cxx b/src/LexTAL.cxx
new file mode 100644
index 000000000..a856dc5f6
--- /dev/null
+++ b/src/LexTAL.cxx
@@ -0,0 +1,392 @@
+// Scintilla source code edit control
+/** @file LexTAL.cxx
+ ** Lexer for TAL
+ ** Based on LexPascal.cxx
+ ** Written by Laurent le Tynevez
+ ** Updated by Simon Steele <s.steele@pnotepad.org> September 2002
+ ** Updated by Mathias Rauen <scite@madshi.net> May 2003 (Delphi adjustments)
+ ** Updated by Rod Falck, Aug 2006 Converted to TAL
+ **/
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+#include "StyleContext.h"
+
+inline bool isTALoperator(char ch)
+ {
+ return ch == '\'' || ch == '@' || ch == '#' || isoperator(ch);
+ }
+
+inline bool isTALwordchar(char ch)
+ {
+ return ch == '$' || ch == '^' || iswordchar(ch);
+ }
+
+inline bool isTALwordstart(char ch)
+ {
+ return ch == '$' || ch == '^' || iswordstart(ch);
+ }
+
+static void getRange(unsigned int start,
+ unsigned int end,
+ Accessor &styler,
+ char *s,
+ unsigned int len) {
+ unsigned int i = 0;
+ while ((i < end - start + 1) && (i < len-1)) {
+ s[i] = static_cast<char>(tolower(styler[start + i]));
+ i++;
+ }
+ s[i] = '\0';
+}
+
+static bool IsStreamCommentStyle(int style) {
+ return style == SCE_C_COMMENT ||
+ style == SCE_C_COMMENTDOC ||
+ style == SCE_C_COMMENTDOCKEYWORD ||
+ style == SCE_C_COMMENTDOCKEYWORDERROR;
+}
+
+static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr, bool bInAsm) {
+ if ((bInAsm) && (attr == SCE_C_OPERATOR || attr == SCE_C_NUMBER || attr == SCE_C_DEFAULT || attr == SCE_C_WORD || attr == SCE_C_IDENTIFIER)) {
+ styler.ColourTo(end, SCE_C_REGEX);
+ } else
+ styler.ColourTo(end, attr);
+}
+
+// returns 1 if the item starts a class definition, and -1 if the word is "end", and 2 if the word is "asm"
+static int classifyWordTAL(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, bool bInAsm) {
+ int ret = 0;
+
+ WordList& keywords = *keywordlists[0];
+ WordList& builtins = *keywordlists[1];
+ WordList& nonreserved_keywords = *keywordlists[2];
+
+ char s[100];
+ getRange(start, end, styler, s, sizeof(s));
+
+ char chAttr = SCE_C_IDENTIFIER;
+ if (isdigit(s[0]) || (s[0] == '.')) {
+ chAttr = SCE_C_NUMBER;
+ }
+ else {
+ if (keywords.InList(s)) {
+ chAttr = SCE_C_WORD;
+
+ if (strcmp(s, "asm") == 0) {
+ ret = 2;
+ }
+ else if (strcmp(s, "end") == 0) {
+ ret = -1;
+ }
+ }
+ else if (s[0] == '$' || builtins.InList(s)) {
+ chAttr = SCE_C_WORD2;
+ }
+ else if (nonreserved_keywords.InList(s)) {
+ chAttr = SCE_C_UUID;
+ }
+ }
+ ColourTo(styler, end, chAttr, (bInAsm && ret != -1));
+ return ret;
+}
+
+static int classifyFoldPointTAL(const char* s) {
+ int lev = 0;
+ if (!(isdigit(s[0]) || (s[0] == '.'))) {
+ if (strcmp(s, "begin") == 0 ||
+ strcmp(s, "block") == 0) {
+ lev=1;
+ } else if (strcmp(s, "end") == 0) {
+ lev=-1;
+ }
+ }
+ return lev;
+}
+
+static void ColouriseTALDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+
+ styler.StartAt(startPos);
+
+ int state = initStyle;
+ if (state == SCE_C_CHARACTER) // Does not leak onto next line
+ state = SCE_C_DEFAULT;
+ char chPrev = ' ';
+ char chNext = styler[startPos];
+ unsigned int lengthDoc = startPos + length;
+
+ bool bInClassDefinition;
+
+ int currentLine = styler.GetLine(startPos);
+ if (currentLine > 0) {
+ styler.SetLineState(currentLine, styler.GetLineState(currentLine-1));
+ bInClassDefinition = (styler.GetLineState(currentLine) == 1);
+ } else {
+ styler.SetLineState(currentLine, 0);
+ bInClassDefinition = false;
+ }
+
+ bool bInAsm = (state == SCE_C_REGEX);
+ if (bInAsm)
+ state = SCE_C_DEFAULT;
+
+ styler.StartSegment(startPos);
+ int visibleChars = 0;
+ for (unsigned int i = startPos; i < lengthDoc; i++) {
+ char ch = chNext;
+
+ chNext = styler.SafeGetCharAt(i + 1);
+
+ if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
+ // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
+ // Avoid triggering two times on Dos/Win
+ // End of line
+ if (state == SCE_C_CHARACTER) {
+ ColourTo(styler, i, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ visibleChars = 0;
+ currentLine++;
+ styler.SetLineState(currentLine, (bInClassDefinition ? 1 : 0));
+ }
+
+ if (styler.IsLeadByte(ch)) {
+ chNext = styler.SafeGetCharAt(i + 2);
+ chPrev = ' ';
+ i += 1;
+ continue;
+ }
+
+ if (state == SCE_C_DEFAULT) {
+ if (isTALwordstart(ch)) {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_IDENTIFIER;
+ } else if (ch == '!' && chNext != '*') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_COMMENT;
+ } else if (ch == '!' && chNext == '*') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_COMMENTDOC;
+ } else if (ch == '-' && chNext == '-') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_COMMENTLINE;
+ } else if (ch == '"') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_STRING;
+ } else if (ch == '?' && visibleChars == 0) {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_PREPROCESSOR;
+ } else if (isTALoperator(ch)) {
+ ColourTo(styler, i-1, state, bInAsm);
+ ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
+ }
+ } else if (state == SCE_C_IDENTIFIER) {
+ if (!isTALwordchar(ch)) {
+ int lStateChange = classifyWordTAL(styler.GetStartSegment(), i - 1, keywordlists, styler, bInAsm);
+
+ if(lStateChange == 1) {
+ styler.SetLineState(currentLine, 1);
+ bInClassDefinition = true;
+ } else if(lStateChange == 2) {
+ bInAsm = true;
+ } else if(lStateChange == -1) {
+ styler.SetLineState(currentLine, 0);
+ bInClassDefinition = false;
+ bInAsm = false;
+ }
+
+ state = SCE_C_DEFAULT;
+ chNext = styler.SafeGetCharAt(i + 1);
+ if (ch == '!' && chNext != '*') {
+ state = SCE_C_COMMENT;
+ } else if (ch == '!' && chNext == '*') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_COMMENTDOC;
+ } else if (ch == '-' && chNext == '-') {
+ state = SCE_C_COMMENTLINE;
+ } else if (ch == '"') {
+ state = SCE_C_STRING;
+ } else if (isTALoperator(ch)) {
+ ColourTo(styler, i, SCE_C_OPERATOR, bInAsm);
+ }
+ }
+ } else {
+ if (state == SCE_C_PREPROCESSOR) {
+ if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_COMMENT) {
+ if (ch == '!' || (ch == '\r' || ch == '\n') ) {
+ ColourTo(styler, i, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_COMMENTDOC) {
+ if (ch == '!' || (ch == '\r' || ch == '\n')) {
+ if (((i > styler.GetStartSegment() + 2) || (
+ (initStyle == SCE_C_COMMENTDOC) &&
+ (styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
+ ColourTo(styler, i, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ }
+ } else if (state == SCE_C_COMMENTLINE) {
+ if (ch == '\r' || ch == '\n') {
+ ColourTo(styler, i-1, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ } else if (state == SCE_C_STRING) {
+ if (ch == '"') {
+ ColourTo(styler, i, state, bInAsm);
+ state = SCE_C_DEFAULT;
+ }
+ }
+ }
+ if (!isspacechar(ch))
+ visibleChars++;
+ chPrev = ch;
+ }
+ ColourTo(styler, lengthDoc - 1, state, bInAsm);
+}
+
+static void FoldTALDoc(unsigned int startPos, int length, int initStyle, WordList *[],
+ Accessor &styler) {
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ unsigned int endPos = startPos + length;
+ int visibleChars = 0;
+ int lineCurrent = styler.GetLine(startPos);
+ int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
+ int levelCurrent = levelPrev;
+ char chNext = styler[startPos];
+ int styleNext = styler.StyleAt(startPos);
+ int style = initStyle;
+ bool was_end = false;
+ bool section = false;
+
+ int lastStart = 0;
+
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ int stylePrev = style;
+ style = styleNext;
+ styleNext = styler.StyleAt(i + 1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+ if (stylePrev == SCE_C_DEFAULT && (style == SCE_C_WORD || style == SCE_C_UUID || style == SCE_C_PREPROCESSOR))
+ {
+ // Store last word start point.
+ lastStart = i;
+ }
+
+ if (stylePrev == SCE_C_WORD || style == SCE_C_UUID || stylePrev == SCE_C_PREPROCESSOR) {
+ if(isTALwordchar(ch) && !isTALwordchar(chNext)) {
+ char s[100];
+ getRange(lastStart, i, styler, s, sizeof(s));
+ if (stylePrev == SCE_C_PREPROCESSOR && strcmp(s, "?section") == 0)
+ {
+ section = true;
+ levelCurrent = 1;
+ levelPrev = 0;
+ }
+ else if (stylePrev == SCE_C_WORD || stylePrev == SCE_C_UUID)
+ {
+ if (strcmp(s, "block") == 0)
+ {
+ // block keyword is ignored immediately after end keyword
+ if (!was_end)
+ levelCurrent++;
+ }
+ else
+ levelCurrent += classifyFoldPointTAL(s);
+ if (strcmp(s, "end") == 0)
+ {
+ was_end = true;
+ }
+ else
+ {
+ was_end = false;
+ }
+ }
+ }
+ }
+
+ if (foldComment && (style == SCE_C_COMMENTLINE)) {
+ if ((ch == '/') && (chNext == '/')) {
+ char chNext2 = styler.SafeGetCharAt(i + 2);
+ if (chNext2 == '{') {
+ levelCurrent++;
+ } else if (chNext2 == '}') {
+ levelCurrent--;
+ }
+ }
+ }
+
+ if (foldPreprocessor && (style == SCE_C_PREPROCESSOR)) {
+ if (ch == '{' && chNext == '$') {
+ unsigned int j=i+2; // skip {$
+ while ((j<endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
+ j++;
+ }
+ if (styler.Match(j, "region") || styler.Match(j, "if")) {
+ levelCurrent++;
+ } else if (styler.Match(j, "end")) {
+ levelCurrent--;
+ }
+ }
+ }
+
+ if (foldComment && IsStreamCommentStyle(style)) {
+ if (!IsStreamCommentStyle(stylePrev)) {
+ levelCurrent++;
+ } else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
+ // Comments don't end at end of line and the next character may be unstyled.
+ levelCurrent--;
+ }
+ }
+
+ if (atEOL) {
+ int lev = levelPrev | SC_FOLDLEVELBASE;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((levelCurrent > levelPrev || section) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ }
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
+ section = false;
+ }
+
+ if (!isspacechar(ch))
+ visibleChars++;
+ }
+
+ // Fill in the real level of the next line, keeping the current flags as they will be filled in later
+ int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
+ styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+}
+
+static const char * const TALWordListDesc[] = {
+ "Keywords",
+ "Builtins",
+ 0
+};
+
+LexerModule lmTAL(SCLEX_TAL, ColouriseTALDoc, "TAL", FoldTALDoc, TALWordListDesc);
diff --git a/vcbuild/SciLexer.dsp b/vcbuild/SciLexer.dsp
index 13f88b5eb..a0c109edb 100644
--- a/vcbuild/SciLexer.dsp
+++ b/vcbuild/SciLexer.dsp
@@ -206,6 +206,10 @@ SOURCE=..\src\LexCmake.cxx
# End Source File
# Begin Source File
+SOURCE=..\src\LexCOBOL.cxx
+# End Source File
+# Begin Source File
+
SOURCE=..\src\LexConf.cxx
# End Source File
# Begin Source File
@@ -402,6 +406,14 @@ SOURCE=..\src\LexTADS3.cxx
# End Source File
# Begin Source File
+SOURCE=..\src\LexTACL.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\LexTAL.cxx
+# End Source File
+# Begin Source File
+
SOURCE=..\src\LexTCL.cxx
# End Source File
# Begin Source File
diff --git a/win32/makefile b/win32/makefile
index c99e02d50..02e9037b2 100644
--- a/win32/makefile
+++ b/win32/makefile
@@ -53,14 +53,15 @@ deps:
LEXOBJS=\
LexAbaqus.o LexAda.o LexAPDL.o LexAsm.o LexAsn1.o LexASY.o LexAU3.o LexAVE.o \
LexBaan.o LexBash.o LexBasic.o LexBullant.o LexCaml.o LexCLW.o LexCmake.o \
-LexConf.o LexCPP.o LexCrontab.o LexCsound.o LexCSS.o LexD.o LexEiffel.o \
-LexErlang.o LexEScript.o LexFlagship.o LexForth.o LexFortran.o LexGAP.o \
-LexGui4Cli.o LexHaskell.o LexHTML.o LexInno.o LexKix.o LexLisp.o LexLout.o \
-LexLua.o LexMagik.o LexMatlab.o LexMetapost.o LexMMIXAL.o LexMPT.o LexMSSQL.o \
-LexMySQL.o LexNsis.o LexOpal.o LexOthers.o LexPascal.o LexPB.o LexPerl.o \
-LexPLM.o LexPOV.o LexPowerShell.o LexProgress.o LexPS.o LexPython.o LexR.o \
-LexRebol.o LexRuby.o LexScriptol.o LexSmalltalk.o LexSpecman.o LexSpice.o \
-LexSQL.o LexTADS3.o LexTCL.o LexTeX.o LexVB.o LexVerilog.o LexVHDL.o LexYAML.o
+LexCOBOL.o LexConf.o LexCPP.o LexCrontab.o LexCsound.o LexCSS.o LexD.o \
+LexEiffel.o LexErlang.o LexEScript.o LexFlagship.o LexForth.o LexFortran.o \
+LexGAP.o LexGui4Cli.o LexHaskell.o LexHTML.o LexInno.o LexKix.o LexLisp.o \
+LexLout.o LexLua.o LexMagik.o LexMatlab.o LexMetapost.o LexMMIXAL.o LexMPT.o \
+LexMSSQL.o LexMySQL.o LexNsis.o LexOpal.o LexOthers.o LexPascal.o LexPB.o \
+LexPerl.o LexPLM.o LexPOV.o LexPowerShell.o LexProgress.o LexPS.o LexPython.o \
+LexR.o LexRebol.o LexRuby.o LexScriptol.o LexSmalltalk.o LexSpecman.o \
+LexSpice.o LexSQL.o LexTACL.o LexTADS3.o LexTAL.o LexTCL.o LexTeX.o LexVB.o \
+LexVerilog.o LexVHDL.o LexYAML.o
#--Autogenerated -- end of automatically generated section
SOBJS = ScintillaWin.o ScintillaBase.o Editor.o CharClassify.o Decoration.o \
diff --git a/win32/scintilla.mak b/win32/scintilla.mak
index 46c2aa032..86371ae9c 100644
--- a/win32/scintilla.mak
+++ b/win32/scintilla.mak
@@ -128,6 +128,7 @@ LEXOBJS=\
$(DIR_O)\LexCaml.obj \
$(DIR_O)\LexCLW.obj \
$(DIR_O)\LexCmake.obj \
+ $(DIR_O)\LexCOBOL.obj \
$(DIR_O)\LexConf.obj \
$(DIR_O)\LexCPP.obj \
$(DIR_O)\LexCrontab.obj \
@@ -176,7 +177,9 @@ LEXOBJS=\
$(DIR_O)\LexSpecman.obj \
$(DIR_O)\LexSpice.obj \
$(DIR_O)\LexSQL.obj \
+ $(DIR_O)\LexTACL.obj \
$(DIR_O)\LexTADS3.obj \
+ $(DIR_O)\LexTAL.obj \
$(DIR_O)\LexTCL.obj \
$(DIR_O)\LexTeX.obj \
$(DIR_O)\LexVB.obj \
@@ -336,6 +339,8 @@ $(DIR_O)\LexCLW.obj: ..\src\LexCLW.cxx $(LEX_HEADERS)
$(DIR_O)\LexCmake.obj: ..\src\LexCmake.cxx $(LEX_HEADERS)
+$(DIR_O)\LexCOBOL.obj: ..\src\LexCOBOL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexConf.obj: ..\src\LexConf.cxx $(LEX_HEADERS)
$(DIR_O)\LexCPP.obj: ..\src\LexCPP.cxx $(LEX_HEADERS)
@@ -432,8 +437,12 @@ $(DIR_O)\LexSpice.obj: ..\src\LexSpice.cxx $(LEX_HEADERS)
$(DIR_O)\LexSQL.obj: ..\src\LexSQL.cxx $(LEX_HEADERS)
+$(DIR_O)\LexTACL.obj: ..\src\LexTACL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexTADS3.obj: ..\src\LexTADS3.cxx $(LEX_HEADERS)
+$(DIR_O)\LexTAL.obj: ..\src\LexTAL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexTCL.obj: ..\src\LexTCL.cxx $(LEX_HEADERS)
$(DIR_O)\LexTeX.obj: ..\src\LexTeX.cxx $(LEX_HEADERS)
diff --git a/win32/scintilla_vc6.mak b/win32/scintilla_vc6.mak
index 566452ad7..5cb93d6b7 100644
--- a/win32/scintilla_vc6.mak
+++ b/win32/scintilla_vc6.mak
@@ -130,6 +130,7 @@ LEXOBJS=\
$(DIR_O)\LexCaml.obj \
$(DIR_O)\LexCLW.obj \
$(DIR_O)\LexCmake.obj \
+ $(DIR_O)\LexCOBOL.obj \
$(DIR_O)\LexConf.obj \
$(DIR_O)\LexCPP.obj \
$(DIR_O)\LexCrontab.obj \
@@ -178,7 +179,9 @@ LEXOBJS=\
$(DIR_O)\LexSpecman.obj \
$(DIR_O)\LexSpice.obj \
$(DIR_O)\LexSQL.obj \
+ $(DIR_O)\LexTACL.obj \
$(DIR_O)\LexTADS3.obj \
+ $(DIR_O)\LexTAL.obj \
$(DIR_O)\LexTCL.obj \
$(DIR_O)\LexTeX.obj \
$(DIR_O)\LexVB.obj \
@@ -338,6 +341,8 @@ $(DIR_O)\LexCLW.obj: ..\src\LexCLW.cxx $(LEX_HEADERS)
$(DIR_O)\LexCmake.obj: ..\src\LexCmake.cxx $(LEX_HEADERS)
+$(DIR_O)\LexCOBOL.obj: ..\src\LexCOBOL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexConf.obj: ..\src\LexConf.cxx $(LEX_HEADERS)
$(DIR_O)\LexCPP.obj: ..\src\LexCPP.cxx $(LEX_HEADERS)
@@ -434,8 +439,12 @@ $(DIR_O)\LexSpice.obj: ..\src\LexSpice.cxx $(LEX_HEADERS)
$(DIR_O)\LexSQL.obj: ..\src\LexSQL.cxx $(LEX_HEADERS)
+$(DIR_O)\LexTACL.obj: ..\src\LexTACL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexTADS3.obj: ..\src\LexTADS3.cxx $(LEX_HEADERS)
+$(DIR_O)\LexTAL.obj: ..\src\LexTAL.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexTCL.obj: ..\src\LexTCL.cxx $(LEX_HEADERS)
$(DIR_O)\LexTeX.obj: ..\src\LexTeX.cxx $(LEX_HEADERS)