logoalt Hacker News

xigoiyesterday at 7:43 PM1 replyview on HN

Under what circumstances does PEG not work?


Replies

bmn__yesterday at 11:23 PM

Many. I don't have enough room on HN to show a representative sample of the shortcomings. Read the relevant literature or converse with an LLM to learn more.

Typical example, ported from <https://news.ycombinator.com/item?id=16600224>:

    (pp
      (peg/match
        '(capture
          '{
            :main (* :B)
            :B (+
              (* :A "x" "y")
              :C)
            :A (+
              true
              (* "x" "z"))
            :C (+
              (* :C "w")
              "v")})
        "xzxy"))
This almost trivial grammar works without any problem in known good parsers. If you want to try out grammars in the wild in Janet, it is nearly guaranteed that they are complex enough for peg to shit itself.
show 1 reply