summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2017-02-26 14:18:44 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2017-02-26 15:46:01 +0200
commitcae1a71255221d5eec27c0c47c4aaf94293f8d59 (patch)
tree417ab6931d4820072c4e2b0414b1c1c18a7771dd /compiler/parser
parenta0b4a2ac5015e9accd4fb71290a68ce1a1d3d630 (diff)
downloadhaskell-cae1a71255221d5eec27c0c47c4aaf94293f8d59.tar.gz
Bring in unicode variants of API Annotations for HsBracket
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/ApiAnnotation.hs18
-rw-r--r--compiler/parser/Parser.y18
2 files changed, 24 insertions, 12 deletions
diff --git a/compiler/parser/ApiAnnotation.hs b/compiler/parser/ApiAnnotation.hs
index 77db0f18d6..34787b3399 100644
--- a/compiler/parser/ApiAnnotation.hs
+++ b/compiler/parser/ApiAnnotation.hs
@@ -201,7 +201,11 @@ data AnnKeywordId
| AnnCase -- ^ case or lambda case
| AnnClass
| AnnClose -- ^ '\#)' or '\#-}' etc
+ | AnnCloseB -- ^ '|)'
+ | AnnCloseBU -- ^ '|)', unicode variant
| AnnCloseC -- ^ '}'
+ | AnnCloseQ -- ^ '|]'
+ | AnnCloseQU -- ^ '|]', unicode variant
| AnnCloseP -- ^ ')'
| AnnCloseS -- ^ ']'
| AnnColon
@@ -244,12 +248,16 @@ data AnnKeywordId
| AnnNewtype
| AnnName -- ^ where a name loses its location in the AST, this carries it
| AnnOf
- | AnnOpen -- ^ '(\#' or '{-\# LANGUAGE' etc
+ | AnnOpen -- ^ '(\#' or '{-\# LANGUAGE' etc
+ | AnnOpenB -- ^ '(|'
+ | AnnOpenBU -- ^ '(|', unicode variant
| AnnOpenC -- ^ '{'
| AnnOpenE -- ^ '[e|' or '[e||'
+ | AnnOpenEQ -- ^ '[|'
+ | AnnOpenEQU -- ^ '[|', unicode variant
| AnnOpenP -- ^ '('
- | AnnOpenPE -- ^ '$('
- | AnnOpenPTE -- ^ '$$('
+ | AnnOpenPE -- ^ '$('
+ | AnnOpenPTE -- ^ '$$('
| AnnOpenS -- ^ '['
| AnnPackageName
| AnnPattern
@@ -336,6 +344,10 @@ unicodeAnn Annlarrowtail = AnnlarrowtailU
unicodeAnn Annrarrowtail = AnnrarrowtailU
unicodeAnn AnnLarrowtail = AnnLarrowtailU
unicodeAnn AnnRarrowtail = AnnRarrowtailU
+unicodeAnn AnnOpenB = AnnOpenBU
+unicodeAnn AnnCloseB = AnnCloseBU
+unicodeAnn AnnOpenEQ = AnnOpenEQU
+unicodeAnn AnnCloseQ = AnnCloseQU
unicodeAnn ann = ann
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index c6a8e48c77..721559f166 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -2522,21 +2522,22 @@ aexp2 :: { LHsExpr RdrName }
| TH_TY_QUOTE tyvar {% ams (sLL $1 $> $ HsBracket (VarBr False (unLoc $2))) [mj AnnThTyQuote $1,mj AnnName $2] }
| TH_TY_QUOTE gtycon {% ams (sLL $1 $> $ HsBracket (VarBr False (unLoc $2))) [mj AnnThTyQuote $1,mj AnnName $2] }
| '[|' exp '|]' {% ams (sLL $1 $> $ HsBracket (ExpBr $2))
- (if (hasE $1) then [mj AnnOpenE $1,mc $3] else [mo $1,mc $3]) }
+ (if (hasE $1) then [mj AnnOpenE $1, mu AnnCloseQ $3]
+ else [mu AnnOpenEQ $1,mu AnnCloseQ $3]) }
| '[||' exp '||]' {% ams (sLL $1 $> $ HsBracket (TExpBr $2))
(if (hasE $1) then [mj AnnOpenE $1,mc $3] else [mo $1,mc $3]) }
- | '[t|' ctype '|]' {% ams (sLL $1 $> $ HsBracket (TypBr $2)) [mo $1,mc $3] }
+ | '[t|' ctype '|]' {% ams (sLL $1 $> $ HsBracket (TypBr $2)) [mo $1,mu AnnCloseQ $3] }
| '[p|' infixexp '|]' {% checkPattern empty $2 >>= \p ->
ams (sLL $1 $> $ HsBracket (PatBr p))
- [mo $1,mc $3] }
+ [mo $1,mu AnnCloseQ $3] }
| '[d|' cvtopbody '|]' {% ams (sLL $1 $> $ HsBracket (DecBrL (snd $2)))
- (mo $1:mc $3:fst $2) }
+ (mo $1:mu AnnCloseQ $3:fst $2) }
| quasiquote { sL1 $1 (HsSpliceE (unLoc $1)) }
-- arrow notation extension
| '(|' aexp2 cmdargs '|)' {% ams (sLL $1 $> $ HsArrForm $2
Nothing (reverse $3))
- [mo $1,mc $4] }
+ [mu AnnOpenB $1,mu AnnCloseB $4] }
splice_exp :: { LHsExpr RdrName }
: TH_ID_SPLICE {% ams (sL1 $1 $ mkHsSpliceE NoParens
@@ -3457,7 +3458,6 @@ isUnicode (L _ (ITdarrow iu)) = iu == UnicodeSyntax
isUnicode (L _ (ITdcolon iu)) = iu == UnicodeSyntax
isUnicode (L _ (ITlarrow iu)) = iu == UnicodeSyntax
isUnicode (L _ (ITrarrow iu)) = iu == UnicodeSyntax
-isUnicode (L _ (ITrarrow iu)) = iu == UnicodeSyntax
isUnicode (L _ (ITlarrowtail iu)) = iu == UnicodeSyntax
isUnicode (L _ (ITrarrowtail iu)) = iu == UnicodeSyntax
isUnicode (L _ (ITLarrowtail iu)) = iu == UnicodeSyntax
@@ -3469,9 +3469,9 @@ isUnicode (L _ (ITcloseQuote iu)) = iu == UnicodeSyntax
isUnicode _ = False
hasE :: Located Token -> Bool
-hasE (L _ (ITopenExpQuote HasE _)) = True
-hasE (L _ (ITopenTExpQuote HasE)) = True
-hasE _ = False
+hasE (L _ (ITopenExpQuote HasE _)) = True
+hasE (L _ (ITopenTExpQuote HasE)) = True
+hasE _ = False
getSCC :: Located Token -> P FastString
getSCC lt = do let s = getSTRING lt