multiComment

We intend to 'abuse' the multiComment parser page (Context: Whitespace) to Parse Wiki-Style Links.

multiComment : String -> String -> Nestable -> Parser ()

Parse multi-line comments. So if you wanted to parse Elm whitespace or JS whitespace, you could say:

elm : Parser () elm = loop 0 <| ifProgress <| oneOf [ lineComment "--" , multiComment "{-" "-}" Nestable , spaces ] js : Parser () js = loop 0 <| ifProgress <| oneOf [ lineComment "//" , multiComment "/*" "*/" NotNestable , chompWhile (\c -> c == ' ' || c == '\n' || c == '\r' || c == '\t') ] ifProgress : Parser a -> Int -> Parser (Step Int ()) ifProgress parser offset = succeed identity |. parser |= getOffset |> map (\newOffset -> if offset == newOffset then Done () else Loop newOffset)

Note: The fact that spaces comes last in the definition of elm is very important! It can succeed without consuming any characters, so if it were the first option, it would always succeed and bypass the others! (Same is true of chompWhile in js.) This possibility of success without consumption is also why wee need the ifProgress helper. It detects if there is no more whitespace to consume.