|
definition: |
extractCurryCode :: Handle -> String -> IO [String]
extractCurryCode _ [] = return []
extractCurryCode hc (c:cs) = case c of
'\\' -> if take 9 cs == "runcurry{"
then let (s,ds) = break (=='}') (drop 9 cs)
in if null ds
then error ("UNCLOSED MACRO: " ++ c:take 50 cs ++ "...")
else do xs <- extractCurryCode hc (tail ds)
return (s:xs)
else extractCurryCode hc cs
'\n' -> if not (null cs) && head cs == '%'
then skipLine cs
else if take 17 cs == "\\begin{curryprog}"
then copyCurryCode hc (drop 17 cs) >>=
extractCurryCode hc
else extractCurryCode hc cs
_ -> extractCurryCode hc cs
where
skipLine [] = return []
skipLine (d:ds) = if d=='\n'
then extractCurryCode hc (d:ds)
else skipLine ds
|
|
demand: |
argument 2 |
|
deterministic: |
deterministic operation |
|
documentation: |
Extract \begin{curryprog}...\end{curryprog} and \runcurry{...} from a text.
The "{...}" must not contain any further curly brackets.
The extracted `curryprog` code is written to the handle.
|
|
failfree: |
<FAILING> |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,{[]}) |-> _ || (_,{:}) |-> _}
|
|
name: |
extractCurryCode |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
System.IO.Handle -> String -> Prelude.IO [String] |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |