aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2002-02-16 05:10:09 +0000
committernyamatongwe <unknown>2002-02-16 05:10:09 +0000
commit59976e3209d8985ebe8d7c9f361bc70c2c7152b3 (patch)
tree9f0f4a5e953557fec2690b428316b0103463a7f3
parentccb04a0ae11feb2bece52b19584765074b7e3980 (diff)
downloadscintilla-mirror-59976e3209d8985ebe8d7c9f361bc70c2c7152b3.tar.gz
New lexer for Matlab contributed by José Fonseca.
-rw-r--r--gtk/deps.mak233
-rw-r--r--gtk/makefile2
-rw-r--r--gtk/scintilla.mak3
-rw-r--r--include/SciLexer.h9
-rw-r--r--include/Scintilla.iface10
-rw-r--r--src/KeyWords.cxx2
-rw-r--r--src/LexMatlab.cxx168
-rw-r--r--vcbuild/SciLexer.dsp4
-rw-r--r--win32/deps.mak10
-rw-r--r--win32/makefile2
-rw-r--r--win32/scintilla.mak3
11 files changed, 326 insertions, 120 deletions
diff --git a/gtk/deps.mak b/gtk/deps.mak
index f7494d6af..c45483833 100644
--- a/gtk/deps.mak
+++ b/gtk/deps.mak
@@ -1,114 +1,119 @@
-PlatGTK.o: PlatGTK.cxx ../include/Platform.h ../include/Scintilla.h \
- ../include/ScintillaWidget.h
-ScintillaGTK.o: ScintillaGTK.cxx ../include/Platform.h \
- ../include/Scintilla.h ../include/ScintillaWidget.h \
- ../include/SciLexer.h ../include/PropSet.h ../include/SString.h \
- ../include/Accessor.h ../include/KeyWords.h ../src/ContractionState.h \
- ../src/SVector.h ../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h \
- ../src/Indicator.h ../src/LineMarker.h ../src/Style.h \
- ../src/AutoComplete.h ../src/ViewStyle.h ../src/Document.h \
- ../src/Editor.h ../src/ScintillaBase.h
-AutoComplete.o: ../src/AutoComplete.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../src/AutoComplete.h
-CallTip.o: ../src/CallTip.cxx ../include/Platform.h \
- ../include/Scintilla.h ../src/CallTip.h
-CellBuffer.o: ../src/CellBuffer.cxx ../include/Platform.h \
- ../include/Scintilla.h ../src/SVector.h ../src/CellBuffer.h
-ContractionState.o: ../src/ContractionState.cxx ../include/Platform.h \
- ../src/ContractionState.h
-DocumentAccessor.o: ../src/DocumentAccessor.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../src/SVector.h \
- ../include/Accessor.h ../src/DocumentAccessor.h ../src/CellBuffer.h \
- ../include/Scintilla.h ../src/Document.h
-Document.o: ../src/Document.cxx ../include/Platform.h \
- ../include/Scintilla.h ../src/SVector.h ../src/CellBuffer.h \
- ../src/Document.h ../src/RESearch.h
-Editor.o: ../src/Editor.cxx ../include/Platform.h ../include/Scintilla.h \
- ../src/ContractionState.h ../src/SVector.h ../src/CellBuffer.h \
- ../src/KeyMap.h ../src/Indicator.h ../src/LineMarker.h ../src/Style.h \
- ../src/ViewStyle.h ../src/Document.h ../src/Editor.h
-Indicator.o: ../src/Indicator.cxx ../include/Platform.h \
- ../include/Scintilla.h ../src/Indicator.h
-KeyMap.o: ../src/KeyMap.cxx ../include/Platform.h ../include/Scintilla.h \
- ../src/KeyMap.h
-KeyWords.o: ../src/KeyWords.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
-LexAda.o: ../src/LexAda.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexAVE.o: ../src/LexAVE.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexBullant.o: ../src/LexBullant.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
-LexConf.o: ../src/LexConf.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexCPP.o: ../src/LexCPP.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../src/StyleContext.h \
- ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
-LexCrontab.o: ../src/LexCrontab.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
-LexEiffel.o: ../src/LexEiffel.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../src/StyleContext.h ../include/KeyWords.h ../include/Scintilla.h \
- ../include/SciLexer.h
-LexHTML.o: ../src/LexHTML.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexLisp.o: ../src/LexLisp.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexLua.o: ../src/LexLua.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexOthers.o: ../src/LexOthers.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
-LexPascal.o: ../src/LexPascal.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
-LexPerl.o: ../src/LexPerl.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexPython.o: ../src/LexPython.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../src/StyleContext.h ../include/KeyWords.h ../include/Scintilla.h \
- ../include/SciLexer.h
-LexRuby.o: ../src/LexRuby.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexSQL.o: ../src/LexSQL.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LexVB.o: ../src/LexVB.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
-LineMarker.o: ../src/LineMarker.cxx ../include/Platform.h \
- ../include/Scintilla.h ../src/LineMarker.h
-PropSet.o: ../src/PropSet.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h
-RESearch.o: ../src/RESearch.cxx ../src/RESearch.h
-ScintillaBase.o: ../src/ScintillaBase.cxx ../include/Platform.h \
- ../include/Scintilla.h ../include/PropSet.h ../include/SString.h \
- ../include/SciLexer.h ../include/Accessor.h ../src/DocumentAccessor.h \
- ../include/KeyWords.h ../src/ContractionState.h ../src/SVector.h \
- ../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h ../src/Indicator.h \
- ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \
- ../src/AutoComplete.h ../src/Document.h ../src/Editor.h \
- ../src/ScintillaBase.h
-StyleContext.o: ../src/StyleContext.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../src/StyleContext.h
-Style.o: ../src/Style.cxx ../include/Platform.h ../include/Scintilla.h \
- ../src/Style.h
-UniConversion.o: ../src/UniConversion.cxx ../src/UniConversion.h
-ViewStyle.o: ../src/ViewStyle.cxx ../include/Platform.h \
- ../include/Scintilla.h ../src/Indicator.h ../src/LineMarker.h \
- ../src/Style.h ../src/ViewStyle.h
-WindowAccessor.o: ../src/WindowAccessor.cxx ../include/Platform.h \
- ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
- ../include/WindowAccessor.h ../include/Scintilla.h
+PlatGTK.o: PlatGTK.cxx ../include/Platform.h ../include/Scintilla.h \
+ ../include/ScintillaWidget.h
+AutoComplete.o: ../src/AutoComplete.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../src/AutoComplete.h
+CallTip.o: ../src/CallTip.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../src/CallTip.h
+CellBuffer.o: ../src/CellBuffer.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../src/SVector.h ../src/CellBuffer.h
+ContractionState.o: ../src/ContractionState.cxx ../include/Platform.h \
+ ../src/ContractionState.h
+Document.o: ../src/Document.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../src/SVector.h ../src/CellBuffer.h \
+ ../src/Document.h ../src/RESearch.h
+DocumentAccessor.o: ../src/DocumentAccessor.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../src/SVector.h \
+ ../include/Accessor.h ../src/DocumentAccessor.h ../src/CellBuffer.h \
+ ../include/Scintilla.h ../src/Document.h
+Editor.o: ../src/Editor.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../src/ContractionState.h ../src/SVector.h \
+ ../src/CellBuffer.h ../src/KeyMap.h ../src/Indicator.h \
+ ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \
+ ../src/Document.h ../src/Editor.h
+Indicator.o: ../src/Indicator.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../src/Indicator.h
+KeyMap.o: ../src/KeyMap.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../src/KeyMap.h
+KeyWords.o: ../src/KeyWords.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexAda.o: ../src/LexAda.cxx ../include/Platform.h ../include/PropSet.h \
+ ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
+ ../include/Scintilla.h ../include/SciLexer.h
+LexAVE.o: ../src/LexAVE.cxx ../include/Platform.h ../include/PropSet.h \
+ ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
+ ../include/Scintilla.h ../include/SciLexer.h
+LexBaan.o: ../src/LexBaan.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../src/StyleContext.h ../include/KeyWords.h ../include/Scintilla.h \
+ ../include/SciLexer.h
+LexBullant.o: ../src/LexBullant.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexConf.o: ../src/LexConf.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexCPP.o: ../src/LexCPP.cxx ../include/Platform.h ../include/PropSet.h \
+ ../include/SString.h ../include/Accessor.h ../src/StyleContext.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexCrontab.o: ../src/LexCrontab.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexEiffel.o: ../src/LexEiffel.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../src/StyleContext.h ../include/KeyWords.h ../include/Scintilla.h \
+ ../include/SciLexer.h
+LexHTML.o: ../src/LexHTML.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../src/StyleContext.h ../include/KeyWords.h ../include/Scintilla.h \
+ ../include/SciLexer.h
+LexLisp.o: ../src/LexLisp.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexLua.o: ../src/LexLua.cxx ../include/Platform.h ../include/PropSet.h \
+ ../include/SString.h ../include/Accessor.h ../src/StyleContext.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexMatlab.o: ../src/LexMatlab.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../src/StyleContext.h ../include/KeyWords.h ../include/Scintilla.h \
+ ../include/SciLexer.h
+LexOthers.o: ../src/LexOthers.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexPascal.o: ../src/LexPascal.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexPerl.o: ../src/LexPerl.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexPython.o: ../src/LexPython.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../src/StyleContext.h ../include/KeyWords.h ../include/Scintilla.h \
+ ../include/SciLexer.h
+LexRuby.o: ../src/LexRuby.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexSQL.o: ../src/LexSQL.cxx ../include/Platform.h ../include/PropSet.h \
+ ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
+ ../include/Scintilla.h ../include/SciLexer.h
+LexVB.o: ../src/LexVB.cxx ../include/Platform.h ../include/PropSet.h \
+ ../include/SString.h ../include/Accessor.h ../src/StyleContext.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LineMarker.o: ../src/LineMarker.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../src/LineMarker.h
+ListLexers.o: ../src/ListLexers.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+PropSet.o: ../src/PropSet.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h
+RESearch.o: ../src/RESearch.cxx ../src/RESearch.h
+ScintillaBase.o: ../src/ScintillaBase.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../include/PropSet.h ../include/SString.h \
+ ../include/SciLexer.h ../include/Accessor.h ../src/DocumentAccessor.h \
+ ../include/KeyWords.h ../src/ContractionState.h ../src/SVector.h \
+ ../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h \
+ ../src/Indicator.h ../src/LineMarker.h ../src/Style.h \
+ ../src/ViewStyle.h ../src/AutoComplete.h ../src/Document.h \
+ ../src/Editor.h ../src/ScintillaBase.h
+Style.o: ../src/Style.cxx ../include/Platform.h ../include/Scintilla.h \
+ ../src/Style.h
+StyleContext.o: ../src/StyleContext.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../src/StyleContext.h
+UniConversion.o: ../src/UniConversion.cxx ../src/UniConversion.h
+ViewStyle.o: ../src/ViewStyle.cxx ../include/Platform.h \
+ ../include/Scintilla.h ../src/Indicator.h ../src/LineMarker.h \
+ ../src/Style.h ../src/ViewStyle.h
+WindowAccessor.o: ../src/WindowAccessor.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../include/WindowAccessor.h ../include/Scintilla.h
diff --git a/gtk/makefile b/gtk/makefile
index 15dec4564..5038c8dbd 100644
--- a/gtk/makefile
+++ b/gtk/makefile
@@ -33,7 +33,7 @@ endif
$(CC) `gtk-config --cflags` $(CXXFLAGS) -c $<
LEXOBJS=LexAda.o LexAVE.o LexBaan.o LexBullant.o LexConf.o LexCPP.o \
- LexCrontab.o LexEiffel.o LexHTML.o LexLisp.o LexLua.o LexOthers.o \
+ LexCrontab.o LexEiffel.o LexHTML.o LexLisp.o LexLua.o LexMatlab.o LexOthers.o \
LexPascal.o LexPerl.o LexPython.o LexRuby.o LexSQL.o LexVB.o
# The LEXOBJS have to be treated specially as the functions in them are not called from external code
diff --git a/gtk/scintilla.mak b/gtk/scintilla.mak
index d224ee9bf..d50267e00 100644
--- a/gtk/scintilla.mak
+++ b/gtk/scintilla.mak
@@ -127,6 +127,7 @@ LEXOBJS=\
$(DIR_O)\LexHTML.obj \
$(DIR_O)\LexLisp.obj \
$(DIR_O)\LexLua.obj \
+ $(DIR_O)\LexMatlab.obj \
$(DIR_O)\LexOthers.obj \
$(DIR_O)\LexPascal.obj \
$(DIR_O)\LexPerl.obj \
@@ -257,6 +258,8 @@ $(DIR_O)\LexLisp.obj: ..\src\LexLisp.cxx $(LEX_HEADERS)
$(DIR_O)\LexLua.obj: ..\src\LexLua.cxx $(LEX_HEADERS)
+$(DIR_O)\LexMatlab.obj: ..\src\LexMatlab.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexOthers.obj: ..\src\LexOthers.cxx $(LEX_HEADERS)
$(DIR_O)\LexPascal.obj: ..\src\LexPascal.cxx $(LEX_HEADERS)
diff --git a/include/SciLexer.h b/include/SciLexer.h
index d87af9faa..fb77a702e 100644
--- a/include/SciLexer.h
+++ b/include/SciLexer.h
@@ -46,6 +46,7 @@
#define SCLEX_ASP 29
#define SCLEX_PHP 30
#define SCLEX_BAAN 31
+#define SCLEX_MATLAB 32
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
@@ -349,6 +350,14 @@
#define SCE_NNCRONTAB_STRING 8
#define SCE_NNCRONTAB_ENVIRONMENT 9
#define SCE_NNCRONTAB_IDENTIFIER 10
+#define SCE_MATLAB_DEFAULT 0
+#define SCE_MATLAB_COMMENT 1
+#define SCE_MATLAB_COMMAND 2
+#define SCE_MATLAB_NUMBER 3
+#define SCE_MATLAB_KEYWORD 4
+#define SCE_MATLAB_STRING 5
+#define SCE_MATLAB_OPERATOR 6
+#define SCE_MATLAB_IDENTIFIER 7
//--Autogenerated -- end of section automatically generated from Scintilla.iface
#endif
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 0a2bcd569..f791482af 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1335,6 +1335,7 @@ val SCLEX_VBSCRIPT=28
val SCLEX_ASP=29
val SCLEX_PHP=30
val SCLEX_BAAN=31
+val SCLEX_MATLAB=32
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -1669,6 +1670,15 @@ val SCE_NNCRONTAB_NUMBER=7
val SCE_NNCRONTAB_STRING=8
val SCE_NNCRONTAB_ENVIRONMENT=9
val SCE_NNCRONTAB_IDENTIFIER=10
+# Lexical states for SCLEX_MATLAB
+val SCE_MATLAB_DEFAULT=0
+val SCE_MATLAB_COMMENT=1
+val SCE_MATLAB_COMMAND=2
+val SCE_MATLAB_NUMBER=3
+val SCE_MATLAB_KEYWORD=4
+val SCE_MATLAB_STRING=5
+val SCE_MATLAB_OPERATOR=6
+val SCE_MATLAB_IDENTIFIER=7
# Events
diff --git a/src/KeyWords.cxx b/src/KeyWords.cxx
index 7c182ad11..bc55e988b 100644
--- a/src/KeyWords.cxx
+++ b/src/KeyWords.cxx
@@ -129,6 +129,7 @@ int Scintilla_LinkLexers() {
extern LexerModule lmLISP;
extern LexerModule lmLua;
extern LexerModule lmMake;
+ extern LexerModule lmMatlab;
extern LexerModule lmPascal;
extern LexerModule lmPerl;
extern LexerModule lmProps;
@@ -153,6 +154,7 @@ int Scintilla_LinkLexers() {
&& &lmProps
&& &lmErrorList
&& &lmMake
+ && &lmMatlab
&& &lmBatch
&& &lmPerl
&& &lmPython
diff --git a/src/LexMatlab.cxx b/src/LexMatlab.cxx
new file mode 100644
index 000000000..5ba0069a5
--- /dev/null
+++ b/src/LexMatlab.cxx
@@ -0,0 +1,168 @@
+// Scintilla source code edit control
+/** @file LexMatlab.cxx
+ ** Lexer for Matlab.
+ ** Written by José Fonseca
+ **/
+// Copyright 1998-2001 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 "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+static bool IsMatlabComment(Accessor &styler, int pos, int len) {
+ return len>0 && (styler[pos]=='%' || styler[pos]=='!') ;
+}
+
+static inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle,
+ WordList *keywordlists[], Accessor &styler) {
+
+ WordList &keywords = *keywordlists[0];
+
+ styler.StartAt(startPos);
+
+ bool transpose = false;
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ for (; sc.More(); sc.Forward()) {
+
+ if (sc.state == SCE_MATLAB_OPERATOR) {
+ if (sc.chPrev == '.') {
+ if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') {
+ transpose = false;
+ } else if (sc.ch == '\'') {
+ transpose = true;
+ } else {
+ sc.SetState(SCE_MATLAB_DEFAULT);
+ transpose = false;
+ }
+ } else {
+ sc.SetState(SCE_MATLAB_DEFAULT);
+ transpose = false;
+ }
+ sc.SetState(SCE_MATLAB_DEFAULT);
+ transpose = false;
+ } else if (sc.state == SCE_MATLAB_KEYWORD) {
+ if (!isalnum(sc.ch) && sc.ch != '_') {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywords.InList(s)) {
+ sc.SetState(SCE_MATLAB_DEFAULT);
+ transpose = false;
+ } else {
+ sc.ChangeState(SCE_MATLAB_IDENTIFIER);
+ sc.SetState(SCE_MATLAB_DEFAULT);
+ transpose = true;
+ }
+ }
+ } else if (sc.state == SCE_MATLAB_NUMBER) {
+ if (!isdigit(sc.ch) && sc.ch != '.'
+ && !(sc.ch == 'e' || sc.ch == 'E')
+ && !((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E'))) {
+ sc.SetState(SCE_MATLAB_DEFAULT);
+ transpose = true;
+ }
+ } else if (sc.state == SCE_MATLAB_STRING) {
+ // Matlab doubles quotes to preserve them, so just end this string
+ // state now as a following quote will start again
+ if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_MATLAB_DEFAULT);
+ }
+ } else if (sc.state == SCE_MATLAB_COMMENT || sc.state == SCE_MATLAB_COMMAND) {
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_MATLAB_DEFAULT);
+ transpose = false;
+ }
+ }
+
+ if (sc.state == SCE_MATLAB_DEFAULT) {
+ if (sc.ch == '%') {
+ sc.SetState(SCE_MATLAB_COMMENT);
+ } else if (sc.ch == '!') {
+ sc.SetState(SCE_MATLAB_COMMAND);
+ } else if (sc.ch == '\'') {
+ if (transpose) {
+ sc.SetState(SCE_MATLAB_OPERATOR);
+ } else {
+ sc.SetState(SCE_MATLAB_STRING);
+ }
+ } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) {
+ sc.SetState(SCE_MATLAB_NUMBER);
+ } else if (isalpha(sc.ch)) {
+ sc.SetState(SCE_MATLAB_KEYWORD);
+ } else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '\\') {
+ if (sc.ch == ')' || sc.ch == ']') {
+ transpose = true;
+ }
+ sc.SetState(SCE_MATLAB_OPERATOR);
+ } else {
+ transpose = false;
+ }
+ }
+ }
+ sc.Complete();
+}
+
+static void FoldMatlabDoc(unsigned int startPos, int length, int,
+ WordList *[], Accessor &styler) {
+ int endPos = startPos + length;
+
+ // Backtrack to previous line in case need to fix its fold status
+ int lineCurrent = styler.GetLine(startPos);
+ if (startPos > 0) {
+ if (lineCurrent > 0) {
+ lineCurrent--;
+ startPos = styler.LineStart(lineCurrent);
+ }
+ }
+ int spaceFlags = 0;
+ int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsMatlabComment);
+ char chNext = styler[startPos];
+ for (int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+
+ if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) {
+ int lev = indentCurrent;
+ int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsMatlabComment);
+ if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
+ // Only non whitespace lines can be headers
+ if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ } else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
+ // Line after is blank so check the next - maybe should continue further?
+ int spaceFlags2 = 0;
+ int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsMatlabComment);
+ if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ }
+ }
+ }
+ indentCurrent = indentNext;
+ styler.SetLevel(lineCurrent, lev);
+ lineCurrent++;
+ }
+ }
+}
+
+LexerModule lmMatlab(SCLEX_MATLAB, ColouriseMatlabDoc, "matlab", FoldMatlabDoc);
diff --git a/vcbuild/SciLexer.dsp b/vcbuild/SciLexer.dsp
index 94ddf58ff..39dc57e70 100644
--- a/vcbuild/SciLexer.dsp
+++ b/vcbuild/SciLexer.dsp
@@ -178,6 +178,10 @@ SOURCE=..\src\LexLua.cxx
# End Source File
# Begin Source File
+SOURCE=..\src\LexMatlab.cxx
+# End Source File
+# Begin Source File
+
SOURCE=..\src\LexOthers.cxx
# End Source File
# Begin Source File
diff --git a/win32/deps.mak b/win32/deps.mak
index 8f13f2a93..618428e14 100644
--- a/win32/deps.mak
+++ b/win32/deps.mak
@@ -71,8 +71,12 @@ LexLisp.o: ../src/LexLisp.cxx ../include/Platform.h \
../include/PropSet.h ../include/SString.h ../include/Accessor.h \
../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
LexLua.o: ../src/LexLua.cxx ../include/Platform.h ../include/PropSet.h \
- ../include/SString.h ../include/Accessor.h ../include/KeyWords.h \
- ../include/Scintilla.h ../include/SciLexer.h
+ ../include/SString.h ../include/Accessor.h ../src/StyleContext.h \
+ ../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
+LexMatlab.o: ../src/LexMatlab.cxx ../include/Platform.h \
+ ../include/PropSet.h ../include/SString.h ../include/Accessor.h \
+ ../src/StyleContext.h ../include/KeyWords.h ../include/Scintilla.h \
+ ../include/SciLexer.h
LexOthers.o: ../src/LexOthers.cxx ../include/Platform.h \
../include/PropSet.h ../include/SString.h ../include/Accessor.h \
../include/KeyWords.h ../include/Scintilla.h ../include/SciLexer.h
@@ -122,5 +126,3 @@ ViewStyle.o: ../src/ViewStyle.cxx ../include/Platform.h \
WindowAccessor.o: ../src/WindowAccessor.cxx ../include/Platform.h \
../include/PropSet.h ../include/SString.h ../include/Accessor.h \
../include/WindowAccessor.h ../include/Scintilla.h
-xContractionState.o: ../src/xContractionState.cxx \
- ../include/Platform.h ../src/ContractionState.h
diff --git a/win32/makefile b/win32/makefile
index 72c9ebca7..54a071a75 100644
--- a/win32/makefile
+++ b/win32/makefile
@@ -39,7 +39,7 @@ deps:
LEXOBJS=LexAda.o LexAVE.o LexBaan.o LexBullant.o LexConf.o \
LexCPP.o LexCrontab.o LexEiffel.o LexHTML.o \
- LexLisp.o LexLua.o LexOthers.o LexPascal.o LexPerl.o \
+ LexLisp.o LexLua.o LexMatlab.o LexOthers.o LexPascal.o LexPerl.o \
LexPython.o LexRuby.o LexSQL.o LexVB.o
SOBJS = ScintillaWin.o ScintillaBase.o Editor.o Document.o \
diff --git a/win32/scintilla.mak b/win32/scintilla.mak
index fe5652bc9..9fac9a7c8 100644
--- a/win32/scintilla.mak
+++ b/win32/scintilla.mak
@@ -116,6 +116,7 @@ LEXOBJS=\
$(DIR_O)\LexHTML.obj \
$(DIR_O)\LexLisp.obj \
$(DIR_O)\LexLua.obj \
+ $(DIR_O)\LexMatlab.obj \
$(DIR_O)\LexOthers.obj \
$(DIR_O)\LexPascal.obj \
$(DIR_O)\LexPerl.obj \
@@ -249,6 +250,8 @@ $(DIR_O)\LexLisp.obj: ..\src\LexLisp.cxx $(LEX_HEADERS)
$(DIR_O)\LexLua.obj: ..\src\LexLua.cxx $(LEX_HEADERS)
+$(DIR_O)\LexMatlab.obj: ..\src\LexMatlab.cxx $(LEX_HEADERS)
+
$(DIR_O)\LexOthers.obj: ..\src\LexOthers.cxx $(LEX_HEADERS)
$(DIR_O)\LexPascal.obj: ..\src\LexPascal.cxx $(LEX_HEADERS)