‹ BackHN Continuity

Thread

Parsing Expression Grammar vs. Regexes: Building Org Parser in Lisp, Export HTML

126 points · 20 comments · jjba23

  1. le-mark · · focus · HN ↗
    “Org” in this context is emacs org mode. Seems odd in this day and age that anyone would see hierarchical text format and think “regex”!
    1. cbarrick · · focus · HN ↗
      Indeed. Regexes are _regular_, which is non hierarchical by definition.

      The two are useful for different layers of abstraction: regex is for lexing and PEG is for parsing.

      Speaking of the Chomsky hierarchy, last I checked, it is still unproven whether or not PEGs can parse all context free languages. Intuitively, they're _probably_ weaker than CFGs, but no one has yet provided a counter example.

      1. sparkie · · focus · HN ↗
        PEGs aren't contained within the context-free languages, so it's not really intuitive that they're weaker, particularly as nobody has yet come up with a context-free language that a PEG cannot parse. They're capable of parsing things context-free grammars cannot.
        1. earleybird · · focus · HN ↗
          Ordered choice may cause a PEG parser to fail where a CFG parser would recognize the string.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.