FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix Haskell lexer: handle escape sequences in character literals by mvanhorn · Pull Request #3069 · pygments/pygments · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .output  (2) .py  (1) .txt  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 2 additions & 1 deletion pygments/lexers/haskell.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class HaskellLexer(RegexLexer):
(r'\bmodule\b', Keyword.Reserved, 'module'),
(r'\berror\b', Name.Exception),
(r'\b({})(?!\')\b'.format('|'.join(reserved)), Keyword.Reserved),
(r"'[^\\]'", String.Char), # this has to come before the TH quote
(r"'[^\\]'", String.Char), # character literal
(r"'\\.'", String.Char), # escape character literal (e.g. '\n')
(r'^[_' + uni.Ll + r'][\w\']*', Name.Function),
(r"'?[_" + uni.Ll + r"][\w']*", Name),
(r"('')?[" + uni.Lu + r"][\w\']*", Keyword.Type),
Expand Down
4 changes: 1 addition & 3 deletions tests/examplefiles/haskell/example.hs.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions tests/examplefiles/lhs/Sudoku.lhs.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions tests/snippets/haskell/test_char_escape_literals.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---input---
'\n'
'\t'
'\\'
'a'

---tokens---
"'\\n'" Literal.String.Char
'\n' Text.Whitespace

"'\\t'" Literal.String.Char
'\n' Text.Whitespace

"'\\\\'" Literal.String.Char
'\n' Text.Whitespace

"'a'" Literal.String.Char
'\n' Text.Whitespace
Loading

Back | FazBrowse Home | New Git URL