Skip to content

Commit

Permalink
Cosmetic: make markdown parser a bit nicer to read and switch out (++…
Browse files Browse the repository at this point in the history
…"") for id to avoid an extra copy
  • Loading branch information
process-bot committed Apr 1, 2014
1 parent 861a91d commit 32fb518
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions compiler/Parse/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,17 @@ anyUntilPos pos = go
False -> (:) <$> anyChar <*> go

markdown :: ([a] -> IParser (String, [a])) -> IParser (String, [a])
markdown interpolation = try (string "[markdown|") >> closeMarkdown (++ "") []
markdown interpolation =
do try (string "[markdown|")
closeMarkdown id []
where
closeMarkdown md stuff =
closeMarkdown markdownBuilder stuff =
choice [ do try (string "|]")
return (md "", stuff)
, (\(m,s) -> closeMarkdown (md . (m ++)) s) =<< interpolation stuff
return (markdownBuilder "", stuff)
, do (markdown,stuff') <- interpolation stuff
closeMarkdown (markdownBuilder . (markdown++)) stuff'
, do c <- anyChar
closeMarkdown (md . ([c]++)) stuff
closeMarkdown (markdownBuilder . (c:)) stuff
]

glShader :: IParser (String, Literal.GLShaderTipe)
Expand Down

0 comments on commit 32fb518

Please sign in to comment.