summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaurav Jain <gaurav@gauravjain.org>2014-05-16 00:46:12 -0400
committerGaurav Jain <gaurav@gauravjain.org>2014-05-16 00:46:12 -0400
commit8c0535b22a34ec89214840a8a87930d07f4ca150 (patch)
tree55945f2d5eb2b814644217af63569e4422b65c7b
parente321d839b5e470643002ac35af6a95aa16464618 (diff)
downloadpygments-8c0535b22a34ec89214840a8a87930d07f4ca150.tar.gz
Use unistring list to enable support for unicode leading character in Haskell
-rw-r--r--pygments/lexers/functional.py23
-rw-r--r--tests/examplefiles/example.hs10
2 files changed, 22 insertions, 11 deletions
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py
index 46450e0f..5affd25f 100644
--- a/pygments/lexers/functional.py
+++ b/pygments/lexers/functional.py
@@ -14,6 +14,7 @@ import re
from pygments.lexer import Lexer, RegexLexer, bygroups, include, do_insertions
from pygments.token import Text, Comment, Operator, Keyword, Name, \
String, Number, Punctuation, Literal, Generic, Error
+from pygments import unistring as uni
__all__ = ['RacketLexer', 'SchemeLexer', 'CommonLispLexer', 'HaskellLexer',
'AgdaLexer', 'LiterateHaskellLexer', 'LiterateAgdaLexer',
@@ -928,9 +929,9 @@ class HaskellLexer(RegexLexer):
(r'\bmodule\b', Keyword.Reserved, 'module'),
(r'\berror\b', Name.Exception),
(r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
- (r'^[_a-z][\w\']*', Name.Function),
- (r"'?[_a-z][\w']*", Name),
- (r"('')?[A-Z][\w\']*", Keyword.Type),
+ (r'^[_' + uni.Ll + r'][\w\']*', Name.Function),
+ (r"'?[_" + uni.Ll + r"'][\w']*", Name),
+ (r"('')?[" + uni.Lu + r"][\w\']*", Keyword.Type),
# Operators
(r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
(r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
@@ -958,27 +959,27 @@ class HaskellLexer(RegexLexer):
(r'\)', Punctuation, '#pop'),
(r'qualified\b', Keyword),
# import X as Y
- (r'([A-Z][\w.]*)(\s+)(as)(\s+)([A-Z][\w.]*)',
+ (r'([' + uni.Lu + r'][\w.]*)(\s+)(as)(\s+)([' + uni.Lu + r'][\w.]*)',
bygroups(Name.Namespace, Text, Keyword, Text, Name), '#pop'),
# import X hiding (functions)
- (r'([A-Z][\w.]*)(\s+)(hiding)(\s+)(\()',
+ (r'([' + uni.Lu + r'][\w.]*)(\s+)(hiding)(\s+)(\()',
bygroups(Name.Namespace, Text, Keyword, Text, Punctuation), 'funclist'),
# import X (functions)
- (r'([A-Z][\w.]*)(\s+)(\()',
+ (r'([' + uni.Lu + r'][\w.]*)(\s+)(\()',
bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
# import X
(r'[\w.]+', Name.Namespace, '#pop'),
],
'module': [
(r'\s+', Text),
- (r'([A-Z][\w.]*)(\s+)(\()',
+ (r'([' + uni.Lu + r'][\w.]*)(\s+)(\()',
bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
- (r'[A-Z][\w.]*', Name.Namespace, '#pop'),
+ (r'[' + uni.Lu + r'][\w.]*', Name.Namespace, '#pop'),
],
'funclist': [
(r'\s+', Text),
- (r'[A-Z]\w*', Keyword.Type),
- (r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
+ (r'[' + uni.Lu + r']\w*', Keyword.Type),
+ (r'(_[\w\']+|[' + uni.Ll + r'][\w\']*)', Name.Function),
(r'--(?![!#$%&*+./<=>?@\^|_~:\\]).*?$', Comment.Single),
(r'{-', Comment.Multiline, 'comment'),
(r',', Punctuation),
@@ -1009,7 +1010,7 @@ class HaskellLexer(RegexLexer):
],
'escape': [
(r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
- (r'\^[][A-Z@\^_]', String.Escape, '#pop'),
+ (r'\^[][' + uni.Lu + r'@\^_]', String.Escape, '#pop'),
('|'.join(ascii), String.Escape, '#pop'),
(r'o[0-7]+', String.Escape, '#pop'),
(r'x[\da-fA-F]+', String.Escape, '#pop'),
diff --git a/tests/examplefiles/example.hs b/tests/examplefiles/example.hs
index 58e44042..9efd3364 100644
--- a/tests/examplefiles/example.hs
+++ b/tests/examplefiles/example.hs
@@ -1,3 +1,5 @@
+module ĈrazyThings where
+
import "base" Data.Char
import "base" Data.Char (isControl, isSpace)
import "base" Data.Char (isControl, --isSpace)
@@ -15,3 +17,11 @@ main :: IO ()
main = putStrLn "hello world"
gádd x y = x + y
+ádd x y = x + y
+
+
+data ĈrazyThings =
+ Ĉar |
+ House |
+ Peár
+ deriving (Show, Eq)