summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorJosh Price <joshprice247+git@gmail.com>2016-03-23 16:19:01 +0100
committerBen Gamari <ben@smart-cactus.org>2016-03-24 10:53:27 +0100
commit03a1bb4d010f94bed233ca261bf44e00c7bd9878 (patch)
tree890d30986fc232bc3715d3a39ec5aea73b430755 /compiler
parent2708c22b8c8a415446d963575c0396a038b43a93 (diff)
downloadhaskell-03a1bb4d010f94bed233ca261bf44e00c7bd9878.tar.gz
Add unicode syntax for banana brackets
Summary: Add "⦇" and "⦈" as unicode alternatives for "(|" and "|)" respectively. This must be implemented differently than other unicode additions because ⦇" and "⦈" are interpretted as a $unigraphic rather than a $unisymbol. Test Plan: validate Reviewers: goldfire, bgamari, austin Reviewed By: bgamari, austin Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D2012 GHC Trac Issues: #10162
Diffstat (limited to 'compiler')
-rw-r--r--compiler/parser/Lexer.x21
-rw-r--r--compiler/parser/Parser.y4
2 files changed, 19 insertions, 6 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index 650b302b54..4eb8fd35a2 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -395,8 +395,17 @@ $tab { warnTab }
<0> {
"(|" / { ifExtension arrowsEnabled `alexAndPred` notFollowedBySymbol }
- { special IToparenbar }
- "|)" / { ifExtension arrowsEnabled } { special ITcparenbar }
+ { special (IToparenbar NormalSyntax) }
+ "|)" / { ifExtension arrowsEnabled } { special (ITcparenbar NormalSyntax) }
+
+ $unigraphic -- ⦇
+ / { ifCurrentChar '⦇' `alexAndPred`
+ ifExtension (\i -> unicodeSyntaxEnabled i && arrowsEnabled i) }
+ { special (IToparenbar UnicodeSyntax) }
+ $unigraphic -- ⦈
+ / { ifCurrentChar '⦈' `alexAndPred`
+ ifExtension (\i -> unicodeSyntaxEnabled i && arrowsEnabled i) }
+ { special (ITcparenbar UnicodeSyntax) }
}
<0> {
@@ -704,8 +713,8 @@ data Token
-- Arrow notation extension
| ITproc
| ITrec
- | IToparenbar -- (|
- | ITcparenbar -- |)
+ | IToparenbar IsUnicodeSyntax -- (|
+ | ITcparenbar IsUnicodeSyntax -- |)
| ITlarrowtail IsUnicodeSyntax -- -<
| ITrarrowtail IsUnicodeSyntax -- >-
| ITLarrowtail IsUnicodeSyntax -- -<<
@@ -942,6 +951,10 @@ followedByDigit :: AlexAccPred ExtsBitmap
followedByDigit _ _ _ (AI _ buf)
= afterOptionalSpace buf (\b -> nextCharIs b (`elem` ['0'..'9']))
+ifCurrentChar :: Char -> AlexAccPred ExtsBitmap
+ifCurrentChar char _ (AI _ buf) _ _
+ = nextCharIs buf (== char)
+
-- We must reject doc comments as being ordinary comments everywhere.
-- In some cases the doc comment will be selected as the lexeme due to
-- maximal munch, but not always, because the nested comment rule is
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index a640bcb849..0b11b04a5e 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -427,8 +427,8 @@ output it generates.
')' { L _ ITcparen }
'(#' { L _ IToubxparen }
'#)' { L _ ITcubxparen }
- '(|' { L _ IToparenbar }
- '|)' { L _ ITcparenbar }
+ '(|' { L _ (IToparenbar _) }
+ '|)' { L _ (ITcparenbar _) }
';' { L _ ITsemi }
',' { L _ ITcomma }
'`' { L _ ITbackquote }