Thanks, Brandon! How did you know that?

I changed them to "#1" and "#2" and now it works[1].

But before making that change, why would "a # b ## c # d" evaluate, even though "a ## b" would not?


[1] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/tree/master/howto/megaparsec
The corrected file is called "experim.hs"; the old one, uncorrected, is called "experim.buggy.hs".

On Sun, Oct 23, 2016 at 2:03 PM, Brandon Allbery <allbery.b@gmail.com> wrote:

On Sun, Oct 23, 2016 at 4:15 PM, Jeffrey Brown <jeffbrown.the@gmail.com> wrote:
      [ [ InfixN # symbol "#" *> pure (Pair) ]
      , [ InfixN # symbol "##" *> pure (Pair) ]
      ]

Combinator parsers can't rearrange themselves to do longest token matching. So the ## operator will take the first case, match against `symbol "#"` and aOperator will succeed; the the next token match will hit the unconsumed "#" and fail. If you place "##" first then it will match "##" but not "#", which would the match the second rule.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net



--
Jeff Brown | Jeffrey Benjamin Brown
Website   |   Facebook   |   LinkedIn(I often miss messages here)   |   Github