"Malcolm" == Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk> writes:
Malcolm> Immanuel Litzroth <immanuell@enfocus.be> writes: >> I have a small question relating to literate haskell programs >> that use the \begin{code} \end{code} style. Am I correct to >> assume that \end{code} inside a string should be recognized as >> being inside a string. The report seems to say this, but the >> unlit that is distributed with ghc doesn't grok this. Has >> anyone written an Unlit module in Haskell? Malcolm> I have attached the Unlit.hs module from the nhc98 Malcolm> compiler, based on the original specification in the the Malcolm> Haskell 1.2 Report. Use the exported function unlit :: Malcolm> String -> String -> String whose first argument is the Malcolm> filename (for error messages), the second argument is the Malcolm> file content, and whose result is the un-literated file. thanks for your code. Perhaps I was not completely clear in my question: I specifically want to know if unliterating should include lexing so that it recognizes strings (comments) or if it can be a separate phase. The following compiles without problems in ghc. \begin{code} main :: IO () main = putStr " \end{code} " \begin{code} " \end{code} The report says Program code ends just before a subsequent line that begins \end{code} (ignoring string literals, of course). I was writing an unlit module to toy around with the Language.Haskell.* stuff when I started wondering about this. Immanuel -- *************************************************************************** It makes me uncomfortable to see An English spinster of the middle class Describe the amorous effects of `brass', Reveal so frankly and with such sobriety The economic basis of society. W.H. Auden -- Immanuel Litzroth Software Development Engineer Enfocus Software Kleindokkaai 3-5 B-9000 Gent Belgium Voice: +32 9 269 23 90 Fax : +32 9 269 16 91 Email: Immanuell@enfocus.be web : www.enfocus.be ***************************************************************************