summaryrefslogtreecommitdiffstats
path: root/scintilla/lexers/LexHaskell.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'scintilla/lexers/LexHaskell.cxx')
-rw-r--r--scintilla/lexers/LexHaskell.cxx41
1 files changed, 19 insertions, 22 deletions
diff --git a/scintilla/lexers/LexHaskell.cxx b/scintilla/lexers/LexHaskell.cxx
index c4b1361..65fc5fe 100644
--- a/scintilla/lexers/LexHaskell.cxx
+++ b/scintilla/lexers/LexHaskell.cxx
@@ -40,40 +40,37 @@
#include "CharacterSet.h"
#include "LexerModule.h"
#include "OptionSet.h"
+#include "CharacterCategory.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
-static int u_iswalpha(int);
-static int u_iswalnum(int);
-static int u_iswupper(int);
-static int u_IsHaskellSymbol(int);
+// See https://github.com/ghc/ghc/blob/master/compiler/parser/Lexer.x#L1682
+// Note, letter modifiers are prohibited.
-// #define HASKELL_UNICODE
-
-#ifndef HASKELL_UNICODE
-
-// Stubs
-
-static int u_iswalpha(int) {
- return 0;
+static int u_iswupper (int ch) {
+ CharacterCategory c = CategoriseCharacter(ch);
+ return c == ccLu || c == ccLt;
}
-static int u_iswalnum(int) {
- return 0;
+static int u_iswalpha (int ch) {
+ CharacterCategory c = CategoriseCharacter(ch);
+ return c == ccLl || c == ccLu || c == ccLt || c == ccLo;
}
-static int u_iswupper(int) {
- return 0;
+static int u_iswalnum (int ch) {
+ CharacterCategory c = CategoriseCharacter(ch);
+ return c == ccLl || c == ccLu || c == ccLt || c == ccLo
+ || c == ccNd || c == ccNo;
}
-static int u_IsHaskellSymbol(int) {
- return 0;
+static int u_IsHaskellSymbol(int ch) {
+ CharacterCategory c = CategoriseCharacter(ch);
+ return c == ccPc || c == ccPd || c == ccPo
+ || c == ccSm || c == ccSc || c == ccSk || c == ccSo;
}
-#endif
-
static inline bool IsHaskellLetter(const int ch) {
if (IsASCII(ch)) {
return (ch >= 'a' && ch <= 'z')
@@ -597,7 +594,8 @@ void SCI_METHOD LexerHaskell::Lex(unsigned int startPos, int length, int initSty
hs.lmode = LITERATE_BIRD;
}
// Preprocessor
- else if (sc.atLineStart && sc.ch == '#' && options.cpp) {
+ else if (sc.atLineStart && sc.ch == '#' && options.cpp
+ && (!options.stylingWithinPreprocessor || sc.state == SCE_HA_DEFAULT)) {
sc.SetState(SCE_HA_PREPROCESSOR);
sc.Forward();
}
@@ -960,7 +958,6 @@ void SCI_METHOD LexerHaskell::Lex(unsigned int startPos, int length, int initSty
sc.Forward();
}
}
- styler.SetLineState(lineCurrent, hs.ToLineState());
sc.Complete();
}