aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj4
-rw-r--r--doc/ScintillaHistory.html6
-rw-r--r--gtk/deps.mak5
-rw-r--r--include/SciLexer.h9
-rw-r--r--include/Scintilla.iface11
-rw-r--r--lexers/LexMaxima.cxx214
-rw-r--r--src/Catalogue.cxx1
-rw-r--r--win32/deps.mak5
-rw-r--r--win32/scintilla.mak3
9 files changed, 258 insertions, 0 deletions
diff --git a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
index d39be0700..0c7865954 100644
--- a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
+++ b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
@@ -227,6 +227,7 @@
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
F437405F9F32C7DEFCA38C11 /* LexIndent.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */; };
+ 3D994BD7A5EAC4FA5B3CFBDF /* LexMaxima.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 29B042978C1F93EF42F9E4AB /* LexMaxima.cxx */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -457,6 +458,7 @@
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* Scintilla.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Scintilla.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D2F7E79907B2D74100F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
+ 29B042978C1F93EF42F9E4AB /* LexMaxima.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexMaxima.cxx; path = ../../lexers/LexMaxima.cxx; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -611,6 +613,7 @@
28B647091B54C0720009DC49 /* LexMake.cxx */,
114B6EE411FA7526004FB6AB /* LexMarkdown.cxx */,
114B6EE511FA7526004FB6AB /* LexMatlab.cxx */,
+ 29B042978C1F93EF42F9E4AB /* LexMaxima.cxx */,
114B6EE611FA7526004FB6AB /* LexMetapost.cxx */,
114B6EE711FA7526004FB6AB /* LexMMIXAL.cxx */,
11BB124C12FF9C1300F6BCF7 /* LexModula.cxx */,
@@ -1112,6 +1115,7 @@
1160E0381803651C00BCEBCB /* LexRust.cxx in Sources */,
11FF3FE21810EB3900E13F13 /* LexDMAP.cxx in Sources */,
F437405F9F32C7DEFCA38C11 /* LexIndent.cxx in Sources */,
+ 3D994BD7A5EAC4FA5B3CFBDF /* LexMaxima.cxx in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 85beb83f3..4605c993b 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -521,6 +521,8 @@
<td>Tobias Kühne</td>
<td>Dimitar Radev</td>
<td>Liang Bai</td>
+ </tr><tr>
+ <td>Gunter Königsmann</td>
</tr>
</table>
<p>
@@ -540,6 +542,10 @@
Released 12 February 2018.
</li>
<li>
+ Lexer added for the Maxima computer algebra language.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1210/">Feature #1210.</a>
+ </li>
+ <li>
Fix hang in Lua lexer when lexing a label upto the terminating "::".
<a href="http://sourceforge.net/p/scintilla/bugs/1999/">Bug #1999</a>.
</li>
diff --git a/gtk/deps.mak b/gtk/deps.mak
index a5540180d..a472b5151 100644
--- a/gtk/deps.mak
+++ b/gtk/deps.mak
@@ -480,6 +480,11 @@ LexMatlab.o: ../lexers/LexMatlab.cxx ../include/ILexer.h \
../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \
../lexlib/StyleContext.h ../lexlib/CharacterSet.h \
../lexlib/LexerModule.h
+LexMaxima.o: ../lexers/LexMaxima.cxx ../include/ILexer.h \
+ ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \
+ ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \
+ ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \
+ ../lexlib/LexerModule.h
LexMetapost.o: ../lexers/LexMetapost.cxx ../include/ILexer.h \
../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \
../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \
diff --git a/include/SciLexer.h b/include/SciLexer.h
index cc5139e93..aa5e7876c 100644
--- a/include/SciLexer.h
+++ b/include/SciLexer.h
@@ -135,6 +135,7 @@
#define SCLEX_JSON 120
#define SCLEX_EDIFACT 121
#define SCLEX_INDENT 122
+#define SCLEX_MAXIMA 123
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
@@ -672,6 +673,14 @@
#define SCE_MATLAB_OPERATOR 6
#define SCE_MATLAB_IDENTIFIER 7
#define SCE_MATLAB_DOUBLEQUOTESTRING 8
+#define SCE_MAXIMA_OPERATOR 0
+#define SCE_MAXIMA_COMMANDENDING 1
+#define SCE_MAXIMA_COMMENT 2
+#define SCE_MAXIMA_NUMBER 3
+#define SCE_MAXIMA_STRING 4
+#define SCE_MAXIMA_COMMAND 5
+#define SCE_MAXIMA_VARIABLE 6
+#define SCE_MAXIMA_UNKNOWN 7
#define SCE_SCRIPTOL_DEFAULT 0
#define SCE_SCRIPTOL_WHITE 1
#define SCE_SCRIPTOL_COMMENTLINE 2
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index d68314eda..51c3f2e81 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -2921,6 +2921,7 @@ val SCLEX_TEHEX=119
val SCLEX_JSON=120
val SCLEX_EDIFACT=121
val SCLEX_INDENT=122
+val SCLEX_MAXIMA=123
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -3540,6 +3541,16 @@ val SCE_MATLAB_STRING=5
val SCE_MATLAB_OPERATOR=6
val SCE_MATLAB_IDENTIFIER=7
val SCE_MATLAB_DOUBLEQUOTESTRING=8
+# Lexical states for SCLEX_MAXIMA
+lex Maxima=SCLEX_MAXIMA SCE_MAXIMA_
+val SCE_MAXIMA_OPERATOR=0
+val SCE_MAXIMA_COMMANDENDING=1
+val SCE_MAXIMA_COMMENT=2
+val SCE_MAXIMA_NUMBER=3
+val SCE_MAXIMA_STRING=4
+val SCE_MAXIMA_COMMAND=5
+val SCE_MAXIMA_VARIABLE=6
+val SCE_MAXIMA_UNKNOWN=7
# Lexical states for SCLEX_SCRIPTOL
lex Sol=SCLEX_SCRIPTOL SCE_SCRIPTOL_
val SCE_SCRIPTOL_DEFAULT=0
diff --git a/lexers/LexMaxima.cxx b/lexers/LexMaxima.cxx
new file mode 100644
index 000000000..4dcfa5208
--- /dev/null
+++ b/lexers/LexMaxima.cxx
@@ -0,0 +1,214 @@
+// Scintilla source code edit control
+/** @file LexMaxima.cxx
+ ** Lexer for Maxima (http://maxima.sourceforge.net).
+ ** Written by Gunter Königsmann based on the lisp lexer by Alexey Yutkin and Neil Hodgson .
+ **/
+// Copyright 2018 by Gunter Königsmann <wxMaxima@physikbuch.de>
+// 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 "WordList.h"
+#include "LexAccessor.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "CharacterSet.h"
+#include "LexerModule.h"
+using namespace Scintilla;
+
+static inline bool isMaximaoperator(char ch) {
+ return (ch == '\'' || ch == '`' || ch == '(' ||
+ ch == ')' || ch == '[' || ch == ']' ||
+ ch == '{' || ch == '}' || ch == '!' ||
+ ch == '*' || ch == '/' || ch == '^' ||
+ ch == ',' || ch == ':' || ch == '+' ||
+ ch == '-');
+}
+
+static void ColouriseMaximaDoc(Sci_PositionU startPos, Sci_Position length, int,
+ WordList *[],
+ Accessor &styler) {
+
+ styler.StartAt(startPos);
+
+ char chNext = styler[startPos];
+ Sci_PositionU lengthDoc = startPos + length;
+ styler.StartSegment(startPos);
+ for (Sci_PositionU i = startPos; i < lengthDoc; i++) {
+ char ch = styler.SafeGetCharAt(i);
+ chNext = styler.SafeGetCharAt(i + 1);
+
+ if (styler.IsLeadByte(ch))
+ continue;
+
+ // Handle comments.
+ // Comments start with /* and end with */
+ if((ch == '/') && (chNext == '*'))
+ {
+ i++;i++;
+
+ chNext = styler.SafeGetCharAt(i);
+ for (; i < lengthDoc; i++)
+ {
+ ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ if((ch == '*') && (chNext == '/'))
+ {
+ i++;
+ i++;
+ break;
+ }
+ }
+ if(i > lengthDoc)
+ i = lengthDoc;
+ i--;
+ styler.ColourTo(i, SCE_MAXIMA_COMMENT);
+ continue;
+ }
+
+ // Handle Operators
+ if(isMaximaoperator(ch))
+ {
+ styler.ColourTo(i, SCE_MAXIMA_OPERATOR);
+ continue;
+ }
+
+ // Handle command endings.
+ if((ch == '$') || (ch == ';'))
+ {
+ styler.ColourTo(i, SCE_MAXIMA_COMMANDENDING);
+ continue;
+ }
+
+ // Handle numbers. Numbers always begin with a digit.
+ if(IsASCII(ch) && isdigit(ch))
+ {
+ i++;
+ for (; i < lengthDoc; i++)
+ {
+ ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+
+ if(ch == '.')
+ continue;
+
+ // A "e" or similar can be followed by a "+" or a "-"
+ if(((ch == 'e') || (ch == 'b') || (ch == 'g') || (ch == 'f')) &&
+ ((chNext == '+') || (chNext == '-')))
+ {
+ i++;
+ chNext = styler.SafeGetCharAt(i + 1);
+ continue;
+ }
+
+ if(!IsASCII(ch) || !(isdigit(ch) || islower(ch) || isupper(ch)))
+ {
+ i--;
+ break;
+ }
+ }
+ styler.ColourTo(i, SCE_MAXIMA_NUMBER);
+ continue;
+ }
+
+ // Handle strings
+ if(ch == '\"')
+ {
+ i++;
+ for (; i < lengthDoc; i++)
+ {
+ ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ if(ch == '\\')
+ i++;
+ else
+ {
+ if(ch == '\"')
+ break;
+ }
+ }
+ styler.ColourTo(i, SCE_MAXIMA_STRING);
+ continue;
+ }
+
+ // Handle keywords. Maxima treats Non-ASCII chars as ordinary letters.
+ if(((!IsASCII(ch))) || isalpha(ch))
+ {
+ char cmd[100];
+ int cmdidx = 0;
+ memset(cmd,0,100);
+ cmd[cmdidx++] = ch;
+ i++;
+ for (; i < lengthDoc; i++)
+ {
+ ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ if(ch == '\\')
+ {
+ if(cmdidx < 99)
+ cmd[cmdidx++] = ch;
+ i++;
+ if(cmdidx < 99)
+ cmd[cmdidx++] = ch;
+ continue;
+ }
+ if(isMaximaoperator(ch) || ((IsASCII(ch) && !isalpha(ch) && !isdigit(ch))))
+ {
+ i--;
+ break;
+ }
+ if(cmdidx < 99)
+ cmd[cmdidx++] = ch;
+ }
+
+ // A few known keywords
+ if(
+ (strncmp(cmd,"if",99) == 0) ||
+ (strncmp(cmd,"then",99) == 0) ||
+ (strncmp(cmd,"else",99) == 0) ||
+ (strncmp(cmd,"thru",99) == 0) ||
+ (strncmp(cmd,"for",99) == 0) ||
+ (strncmp(cmd,"while",99) == 0) ||
+ (strncmp(cmd,"do",99) == 0)
+ )
+ {
+ styler.ColourTo(i, SCE_MAXIMA_COMMAND);
+ chNext = styler.SafeGetCharAt(i + 1);
+ continue;
+ }
+
+ // All other keywords are functions if they are followed
+ // by an opening parenthesis
+ char nextNonwhitespace = ' ';
+ for (Sci_PositionU o = i + 1; o < lengthDoc; o++)
+ {
+ nextNonwhitespace = styler.SafeGetCharAt(o);
+ if(!IsASCII(ch) || !isspacechar(nextNonwhitespace))
+ break;
+ }
+ if(nextNonwhitespace == '(')
+ {
+ styler.ColourTo(i, SCE_MAXIMA_COMMAND);
+ }
+ else
+ {
+ styler.ColourTo(i, SCE_MAXIMA_VARIABLE);
+ }
+ chNext = styler.SafeGetCharAt(i + 1);
+ continue;
+ }
+
+ styler.ColourTo(i-1, SCE_MAXIMA_UNKNOWN);
+ }
+}
+
+LexerModule lmMaxima(SCLEX_MAXIMA, ColouriseMaximaDoc, "maxima", 0, 0);
diff --git a/src/Catalogue.cxx b/src/Catalogue.cxx
index 0cbf0db61..4da096d81 100644
--- a/src/Catalogue.cxx
+++ b/src/Catalogue.cxx
@@ -134,6 +134,7 @@ int Scintilla_LinkLexers() {
LINK_LEXER(lmMake);
LINK_LEXER(lmMarkdown);
LINK_LEXER(lmMatlab);
+ LINK_LEXER(lmMaxima);
LINK_LEXER(lmMETAPOST);
LINK_LEXER(lmMMIXAL);
LINK_LEXER(lmModula);
diff --git a/win32/deps.mak b/win32/deps.mak
index 4b0dff17e..547406db9 100644
--- a/win32/deps.mak
+++ b/win32/deps.mak
@@ -449,6 +449,11 @@ LexMatlab.o: ../lexers/LexMatlab.cxx ../include/ILexer.h \
../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \
../lexlib/StyleContext.h ../lexlib/CharacterSet.h \
../lexlib/LexerModule.h
+LexMaxima.o: ../lexers/LexMaxima.cxx ../include/ILexer.h \
+ ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \
+ ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \
+ ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \
+ ../lexlib/LexerModule.h
LexMetapost.o: ../lexers/LexMetapost.cxx ../include/ILexer.h \
../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \
../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \
diff --git a/win32/scintilla.mak b/win32/scintilla.mak
index 8cdb0f958..38755602d 100644
--- a/win32/scintilla.mak
+++ b/win32/scintilla.mak
@@ -167,6 +167,7 @@ LEXOBJS=\
$(DIR_O)\LexMake.obj \
$(DIR_O)\LexMarkdown.obj \
$(DIR_O)\LexMatlab.obj \
+ $(DIR_O)\LexMaxima.obj \
$(DIR_O)\LexMetapost.obj \
$(DIR_O)\LexMMIXAL.obj \
$(DIR_O)\LexModula.obj \
@@ -623,6 +624,8 @@ $(DIR_O)\LexMarkdown.obj: ..\lexers\LexMarkdown.cxx $(LEX_HEADERS)
$(DIR_O)\LexMatlab.obj: ..\lexers\LexMatlab.cxx $(LEX_HEADERS)
+$(DIR_O)\LexMaxima.obj: ..\lexers\LexMaxima.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexMetapost.obj: ..\lexers\LexMetapost.cxx $(LEX_HEADERS)
$(DIR_O)\LexMMIXAL.obj: ..\lexers\LexMMIXAL.cxx $(LEX_HEADERS)