Diff of /lexers/LexHaskell.cxx [4fbd4f] .. [e7960a]  Maximize  Restore

Switch to side-by-side view

--- a/lexers/LexHaskell.cxx
+++ b/lexers/LexHaskell.cxx
@@ -40,39 +40,36 @@
 #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);
-
-// #define HASKELL_UNICODE
-
-#ifndef HASKELL_UNICODE
-
-// Stubs
-
-static int u_iswalpha(int) {
-   return 0;
-}
-
-static int u_iswalnum(int) {
-   return 0;
-}
-
-static int u_iswupper(int) {
-   return 0;
-}
-
-static int u_IsHaskellSymbol(int) {
-   return 0;
-}
-
-#endif
+// See https://github.com/ghc/ghc/blob/master/compiler/parser/Lexer.x#L1682
+// Note, letter modifiers are prohibited.
+
+static int u_iswupper (int ch) {
+   CharacterCategory c = CategoriseCharacter(ch);
+   return c == ccLu || c == ccLt;
+}
+
+static int u_iswalpha (int ch) {
+   CharacterCategory c = CategoriseCharacter(ch);
+   return c == ccLl || c == ccLu || c == ccLt || c == ccLo;
+}
+
+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 ch) {
+   CharacterCategory c = CategoriseCharacter(ch);
+   return c == ccPc || c == ccPd || c == ccPo
+       || c == ccSm || c == ccSc || c == ccSk || c == ccSo;
+}
 
 static inline bool IsHaskellLetter(const int ch) {
    if (IsASCII(ch)) {

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks