Skip to content

Commit 2363b56

Browse files
Martoon-00sheaf
authored andcommitted
Improve custom quasi-quotation parsing
Problem: currently parsing `[int||Text|]` fails with the current Haskell grammar. This happens, because we parse the beginning in a greedy way, and so parse `[int||` as beginning of typed quasi-quoter. Thus end must be `||]` respectively, but we never meet it. Solution: custom quoters are never typed, and GHC (tried with 8.10.7 version) interprets `[int||Abc||]` as a mere quoter with `|Abc|` body. So here we adjust the pattern for custom quoters to be never typed.
1 parent 6d878dd commit 2363b56

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Add support for Alex and Happy ([#97](https://github.com/JustusAdam/language-haskell/issues/97)), thanks to [@matthewess](https://github.com/matthewess).
44
- Default to .hs when saving files ([#197](https://github.com/JustusAdam/language-haskell/issues/197)), thanks to [@noughtmare](https://github.com/noughtmare).
5+
- Fix highlighting for custom quasi quoters with immediate `|`
6+
([#203](https://github.com/JustusAdam/language-haskell/issues/203)).
57

68
## 3.4.0 - 25.02.2021
79

syntaxes/haskell.YAML-tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,15 +1755,15 @@ repository:
17551755
(?!'\|') # Don't parse ['|'...] as a quasi quotation
17561756
((?:[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*\.)*) # Optional qualifier
17571757
((?:[^\s\p{S}\p{P}]|['_])*) # Quasi-quoter
1758-
(\|(?:\|(?!\]))?)
1758+
(\|)
17591759
beginCaptures:
17601760
'1': {name: keyword.operator.quasi-quotation.begin.haskell}
17611761
'2': {name: keyword.operator.prefix.double-dollar.haskell}
17621762
'3': {name: keyword.operator.prefix.dollar.haskell}
17631763
'4': {name: entity.name.namespace.haskell}
17641764
'5': {name: entity.name.quasi-quoter.haskell}
17651765
'6': {name: keyword.operator.quasi-quotation.begin.haskell}
1766-
end: '\6\]'
1766+
end: '\|\]'
17671767
endCaptures:
17681768
'0': {name: keyword.operator.quasi-quotation.end.haskell}
17691769
name: "meta.quasi-quotation.haskell meta.embedded.block.$5"

test/tests/QuasiQuotes.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.quasi-quotation.haskell
4141

4242

43+
[i|| A |]
44+
-- ^ ^ keyword.operator.quasi-quotation.begin.haskell
45+
-- ^ entity.name.quasi-quoter.haskell
46+
-- ^^^^ meta.quasi-quotation.haskell meta.embedded.block.i
47+
-- ^^ keyword.operator.quasi-quotation.end.haskell
48+
-- ^^^^^^^^^ meta.quasi-quotation.haskell
49+
4350
[$html|
4451
-- ^ ^ keyword.operator.quasi-quotation.begin.haskell
4552
-- ^^^^ entity.name.quasi-quoter.haskell

0 commit comments

Comments
 (0)