[commit: ghc] master: Lexer: support consecutive references to Haddock chunks (#10398) (d784bde)

git at git.haskell.org git at git.haskell.org
Thu Jul 23 12:54:56 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/d784bdeb62a6b11831c5235a97449ff2a86dcc52/ghc

>---------------------------------------------------------------

commit d784bdeb62a6b11831c5235a97449ff2a86dcc52
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Thu Jul 23 11:40:37 2015 +0200

    Lexer: support consecutive references to Haddock chunks (#10398)
    
    Reviewers: austin, bgamari, Fuuzetsu
    
    Reviewed By: bgamari
    
    Subscribers: thomie, bgamari
    
    Differential Revision: https://phabricator.haskell.org/D1025
    
    GHC Trac Issues: #10398


>---------------------------------------------------------------

d784bdeb62a6b11831c5235a97449ff2a86dcc52
 compiler/parser/Lexer.x                            |  2 +-
 .../haddock/should_compile_flag_haddock/T10398.hs  | 25 ++++++++++++++++++++++
 .../should_compile_flag_haddock/T10398.stderr      | 13 +++++++++++
 .../haddock/should_compile_flag_haddock/all.T      |  1 +
 4 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index a9293da..7dce81c 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -1012,7 +1012,7 @@ withLexedDocType lexDocComment = do
   case prevChar buf ' ' of
     '|' -> lexDocComment input ITdocCommentNext False
     '^' -> lexDocComment input ITdocCommentPrev False
-    '$' -> lexDocComment input ITdocCommentNamed False
+    '$' -> lexDocComment input ITdocCommentNamed True
     '*' -> lexDocSection 1 input
     '#' -> lexDocComment input ITdocOptionsOld False
     _ -> panic "withLexedDocType: Bad doc type"
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/T10398.hs b/testsuite/tests/haddock/should_compile_flag_haddock/T10398.hs
new file mode 100644
index 0000000..bbd498c
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/T10398.hs
@@ -0,0 +1,25 @@
+module Foo
+(
+  -- The reference to chunk2 should show up in the -ddump-parsed output.
+  -- $chunk1
+  -- $chunk2
+  foo,
+  -- $chunk3
+  bar
+)
+where
+
+{- $chunk1
+This is chunk 1.
+-}
+
+{- $chunk2
+This is chunk 2.
+-}
+
+{- $chunk3
+This is chunk 3.
+-}
+
+foo = 3
+bar = 7
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/T10398.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/T10398.stderr
new file mode 100644
index 0000000..4a51fcd
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/T10398.stderr
@@ -0,0 +1,13 @@
+
+==================== Parser ====================
+module Foo (
+        <IEDocNamed: chunk1>, <IEDocNamed: chunk2>, foo,
+        <IEDocNamed: chunk3>, bar
+    ) where
+<document comment>
+<document comment>
+<document comment>
+foo = 3
+bar = 7
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/all.T b/testsuite/tests/haddock/should_compile_flag_haddock/all.T
index 61b6c6c..d803e9d 100644
--- a/testsuite/tests/haddock/should_compile_flag_haddock/all.T
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/all.T
@@ -31,3 +31,4 @@ test('haddockA030', normal, compile, ['-haddock -ddump-parsed'])
 test('haddockA031', normal, compile, ['-haddock -ddump-parsed -XExistentialQuantification'])
 test('haddockA032', normal, compile, ['-haddock -ddump-parsed'])
 test('haddockA033', normal, compile, ['-haddock -ddump-parsed'])
+test('T10398', normal, compile, ['-haddock -ddump-parsed'])



More information about the ghc-commits mailing list