diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2015-04-14 07:32:52 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-04-14 07:33:33 -0500 |
commit | 5fded20c51ae61770f909351c851aaca3d3e331c (patch) | |
tree | 551fbd5a22221a2bdeabe474c9da8bbd70f14104 /compiler/parser | |
parent | 8dc294487fdaf102349c373c7db4796693573310 (diff) | |
download | haskell-5fded20c51ae61770f909351c851aaca3d3e331c.tar.gz |
ApiAnnotations : lexer discards comment close in nested comment
When parsing a nested comment, such as
{-
{- nested comment -}
{-# nested pragma #-}
-}
The lexer returns the comment annotation as
{-
{- nested comment
{-# nested pragma #
-}
Restore the missing comment end markers in the annotation.
Reviewed By: austin
Differential Revision: https://phabricator.haskell.org/D829
GHC Trac Issues: #10277
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/Lexer.x | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index e451b5ffea..1be724526f 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -970,7 +970,7 @@ lineCommentToken span buf len = do nested_comment :: P (RealLocated Token) -> Action nested_comment cont span buf len = do input <- getInput - go (reverse $ drop 2 $ lexemeToString buf len) (1::Int) input + go (reverse $ lexemeToString buf len) (1::Int) input where go commentAcc 0 input = do setInput input @@ -982,9 +982,9 @@ nested_comment cont span buf len = do Nothing -> errBrace input span Just ('-',input) -> case alexGetChar' input of Nothing -> errBrace input span - Just ('\125',input) -> go commentAcc (n-1) input + Just ('\125',input) -> go ('\125':'-':commentAcc) (n-1) input -- '}' Just (_,_) -> go ('-':commentAcc) n input - Just ('\123',input) -> case alexGetChar' input of + Just ('\123',input) -> case alexGetChar' input of -- '{' char Nothing -> errBrace input span Just ('-',input) -> go ('-':'\123':commentAcc) (n+1) input Just (_,_) -> go ('\123':commentAcc) n input |