Commit cae1a712 authored by Alan Zimmerman's avatar Alan Zimmerman

Bring in unicode variants of API Annotations for HsBracket

parent a0b4a2ac
......@@ -556,8 +556,8 @@ data HsExpr id
-- MetaHaskell Extensions
-- | - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen',
-- 'ApiAnnotation.AnnOpen','ApiAnnotation.AnnClose',
-- 'ApiAnnotation.AnnClose'
-- 'ApiAnnotation.AnnOpenE','ApiAnnotation.AnnOpenEQ',
-- 'ApiAnnotation.AnnClose','ApiAnnotation.AnnCloseQ'
-- For details on above see note [Api annotations] in ApiAnnotation
| HsBracket (HsBracket id)
......@@ -620,8 +620,8 @@ data HsExpr id
Bool -- True => right-to-left (f -< arg)
-- False => left-to-right (arg >- f)
-- | - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen' @'(|'@,
-- 'ApiAnnotation.AnnClose' @'|)'@
-- | - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpenB' @'(|'@,
-- 'ApiAnnotation.AnnCloseB' @'|)'@
-- For details on above see note [Api annotations] in ApiAnnotation
| HsArrForm -- Command formation, (| e cmd1 .. cmdn |)
......@@ -1160,8 +1160,8 @@ data HsCmd id
Bool -- True => right-to-left (f -< arg)
-- False => left-to-right (arg >- f)
-- | - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen' @'(|'@,
-- 'ApiAnnotation.AnnClose' @'|)'@
-- | - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpenB' @'(|'@,
-- 'ApiAnnotation.AnnCloseB' @'|)'@
-- For details on above see note [Api annotations] in ApiAnnotation
| HsCmdArrForm -- Command formation, (| e cmd1 .. cmdn |)
......
......@@ -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
......
......@@ -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
......
......@@ -9,12 +9,12 @@
((Test10276.hs:6:1-14,AnnEqual), [Test10276.hs:6:4]),
((Test10276.hs:6:1-14,AnnFunId), [Test10276.hs:6:1-2]),
((Test10276.hs:6:1-14,AnnSemi), [Test10276.hs:7:1]),
((Test10276.hs:6:6-14,AnnClose), [Test10276.hs:6:13-14]),
((Test10276.hs:6:6-14,AnnOpen), [Test10276.hs:6:6-7]),
((Test10276.hs:6:6-14,AnnCloseQ), [Test10276.hs:6:13-14]),
((Test10276.hs:6:6-14,AnnOpenEQ), [Test10276.hs:6:6-7]),
((Test10276.hs:7:1-15,AnnEqual), [Test10276.hs:7:4]),
((Test10276.hs:7:1-15,AnnFunId), [Test10276.hs:7:1-2]),
((Test10276.hs:7:1-15,AnnSemi), [Test10276.hs:9:1]),
((Test10276.hs:7:6-15,AnnClose), [Test10276.hs:7:14-15]),
((Test10276.hs:7:6-15,AnnCloseQ), [Test10276.hs:7:14-15]),
((Test10276.hs:7:6-15,AnnOpenE), [Test10276.hs:7:6-8]),
((Test10276.hs:(9,1)-(11,74),AnnClass), [Test10276.hs:9:1-5]),
((Test10276.hs:(9,1)-(11,74),AnnSemi), [Test10276.hs:13:1]),
......
......@@ -60,7 +60,7 @@
((Test10399.hs:17:48-68,AnnRarrow), [Test10399.hs:17:50-51]),
((Test10399.hs:17:66-68,AnnCloseS), [Test10399.hs:17:68]),
((Test10399.hs:17:66-68,AnnOpenS), [Test10399.hs:17:66]),
((Test10399.hs:19:1-25,AnnClose), [Test10399.hs:19:24-25]),
((Test10399.hs:19:1-25,AnnCloseQ), [Test10399.hs:19:24-25]),
((Test10399.hs:19:1-25,AnnOpen), [Test10399.hs:19:1-3]),
((Test10399.hs:19:1-25,AnnSemi), [Test10399.hs:21:1]),
((Test10399.hs:19:20-22,AnnThIdSplice), [Test10399.hs:19:20-22]),
......@@ -69,7 +69,7 @@
((Test10399.hs:21:1-21,AnnSemi), [Test10399.hs:22:1]),
((Test10399.hs:21:5-17,AnnCloseP), [Test10399.hs:21:17]),
((Test10399.hs:21:5-17,AnnOpenPE), [Test10399.hs:21:5-6]),
((Test10399.hs:21:8-15,AnnClose), [Test10399.hs:21:14-15]),
((Test10399.hs:21:8-15,AnnCloseQ), [Test10399.hs:21:14-15]),
((Test10399.hs:21:8-15,AnnOpen), [Test10399.hs:21:8-10]),
((<no location info>,AnnEofPos), [Test10399.hs:22:1])
]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment