In Parsec, is there a way to prevent lexeme from consuming newlines?

前端 未结 4 1996
生来不讨喜
生来不讨喜 2021-02-13 12:36

All of the parsers in Text.Parsec.Token politely use lexeme to eat whitespace after a token. Unfortunately for me, whitespace includes new lines, whic

4条回答
  •  旧时难觅i
    2021-02-13 13:08

    Although the other answers about it not being possible are correct, I would like to point out that the char parsers are not using a lexeme parser.
    I use parsec to analyse some html mustache templates. Whitespaces are important in that analysis. What I did was to simply parse the ">" and "}}" strings with Text.Parsec.Char.string.
    Since I am interested in whitespaces between tags and not inside them I can still use the reserved operators to parse "<" and "{{" etc., because the lexeme parser only consumes trailing whitespace.

提交回复
热议问题