... |
... |
@@ -273,7 +273,7 @@ $tab { warnTab } |
273
|
273
|
-- set.
|
274
|
274
|
|
275
|
275
|
"{-" / { isNormalComment } { nested_comment }
|
276
|
|
-"/*" / { ifExtension GhcCppBit } { nested_comment }
|
|
276
|
+-- "/*" / { ifExtension GhcCppBit } { nested_comment }
|
277
|
277
|
|
278
|
278
|
-- Single-line comments are a bit tricky. Haskell 98 says that two or
|
279
|
279
|
-- more dashes followed by a symbol should be parsed as a varsym, so we
|
... |
... |
@@ -1587,6 +1587,16 @@ nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLe |
1587
|
1587
|
dropTrailingDec "-}" = ""
|
1588
|
1588
|
dropTrailingDec (x:xs) = x:dropTrailingDec xs
|
1589
|
1589
|
|
|
1590
|
+-- TODO:AZ delete this
|
|
1591
|
+nested_cpp_comment :: Action p
|
|
1592
|
+nested_cpp_comment span buf len _buf2 = {-# SCC "nested_comment" #-} do
|
|
1593
|
+ l <- getLastLocIncludingComments
|
|
1594
|
+ let endComment input (L _ comment) = commentEnd lexToken input (Nothing, ITblockComment comment l) buf span
|
|
1595
|
+ input <- getInput
|
|
1596
|
+ -- Include decorator in comment
|
|
1597
|
+ let start_decorator = reverse $ lexemeToString buf len
|
|
1598
|
+ nested_cpp_comment_logic endComment start_decorator input span
|
|
1599
|
+
|
1590
|
1600
|
{-# INLINE nested_comment_logic #-}
|
1591
|
1601
|
-- | Includes the trailing '-}' decorators
|
1592
|
1602
|
-- drop the last two elements with the callback if you don't want them to be included
|
... |
... |
@@ -1597,6 +1607,41 @@ nested_comment_logic |
1597
|
1607
|
-> PsSpan
|
1598
|
1608
|
-> P p (PsLocated Token)
|
1599
|
1609
|
nested_comment_logic endComment commentAcc input span = go commentAcc (1::Int) input
|
|
1610
|
+ where
|
|
1611
|
+ go commentAcc 0 input@(AI end_loc _) = do
|
|
1612
|
+ let comment = reverse commentAcc
|
|
1613
|
+ cspan = mkSrcSpanPs $ mkPsSpan (psSpanStart span) end_loc
|
|
1614
|
+ lcomment = L cspan comment
|
|
1615
|
+ endComment input lcomment
|
|
1616
|
+ go commentAcc n input = ghcCppSet >>= \ghcCppSet -> case alexGetChar' input of
|
|
1617
|
+ Nothing -> errBrace input (psRealSpan span)
|
|
1618
|
+ Just ('-',input) -> case alexGetChar' input of
|
|
1619
|
+ Nothing -> errBrace input (psRealSpan span)
|
|
1620
|
+ Just ('\125',input) -> go ('\125':'-':commentAcc) (n-1) input -- '}'
|
|
1621
|
+ Just (_,_) -> go ('-':commentAcc) n input
|
|
1622
|
+ Just ('\123',input) -> case alexGetChar' input of -- '{' char
|
|
1623
|
+ Nothing -> errBrace input (psRealSpan span)
|
|
1624
|
+ Just ('-',input) -> go ('-':'\123':commentAcc) (n+1) input
|
|
1625
|
+ Just (_,_) -> go ('\123':commentAcc) n input
|
|
1626
|
+ -- See Note [Nested comment line pragmas]
|
|
1627
|
+ Just ('\n',input) -> case alexGetChar' input of
|
|
1628
|
+ Nothing -> errBrace input (psRealSpan span)
|
|
1629
|
+ Just ('#',_) -> do (parsedAcc,input) <- parseNestedPragma input
|
|
1630
|
+ go (parsedAcc ++ '\n':commentAcc) n input
|
|
1631
|
+ Just (_,_) -> go ('\n':commentAcc) n input
|
|
1632
|
+ Just (c,input) -> go (c:commentAcc) n input
|
|
1633
|
+
|
|
1634
|
+-- TODO:AZ delete this
|
|
1635
|
+{-# INLINE nested_cpp_comment_logic #-}
|
|
1636
|
+-- | Includes the trailing '*/' decorators
|
|
1637
|
+-- drop the last two elements with the callback if you don't want them to be included
|
|
1638
|
+nested_cpp_comment_logic
|
|
1639
|
+ :: (AlexInput -> Located String -> P p (PsLocated Token)) -- ^ Continuation that gets the rest of the input and the lexed comment
|
|
1640
|
+ -> String -- ^ starting value for accumulator (reversed) - When we want to include a decorator '/*' in the comment
|
|
1641
|
+ -> AlexInput
|
|
1642
|
+ -> PsSpan
|
|
1643
|
+ -> P p (PsLocated Token)
|
|
1644
|
+nested_cpp_comment_logic endComment commentAcc input span = go commentAcc (1::Int) input
|
1600
|
1645
|
where
|
1601
|
1646
|
go commentAcc 0 input@(AI end_loc _) = do
|
1602
|
1647
|
let comment = reverse commentAcc
|
... |
... |
@@ -1629,6 +1674,7 @@ nested_comment_logic endComment commentAcc input span = go commentAcc (1::Int) i |
1629
|
1674
|
Just (_,_) -> go ('\n':commentAcc) n input
|
1630
|
1675
|
(_, Just (c,input)) -> go (c:commentAcc) n input
|
1631
|
1676
|
|
|
1677
|
+
|
1632
|
1678
|
ghcCppSet :: P p Bool
|
1633
|
1679
|
ghcCppSet = do
|
1634
|
1680
|
exts <- getExts
|