{
  "id": 17646166,
  "title": "Pratt parsing is a black box",
  "url": "https://urgent.news/2026/11/01/pratt-parsing-is-a-black-box",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-01T17:41:53.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://vinipsmaker.github.io/blog/article/pratt-parsing-is-a-black-box/"
  },
  "original_language": "en",
  "account": "Most Pratt parsing tutorials spend a lot of time explaining Pratt's algorithm without covering the important properties that actually matter. However, it's essential to understand the mindset behind Pratt parsing. Douglas Crockford, in his 2013 GOTO conference talk, highlighted that Pratt reduces parsing, a complicated task, to a simple question: \"What do we expect to see to the left of a token?\"\n\nPratt parsing simplifies the process by registering semantic actions to terminals (nuds and leds) instead of production rules, used in traditional parsing techniques. This departure from traditional methods has several advantages. For instance, it eliminates the need to worry about left-recursion problems, which are a challenge in traditional parsing techniques like LL(k). Since the semantic action is triggered by the consumed token, left-recursion is not an issue.\n\nAdditionally, the parsing engine doesn't need to backtrack or test alternatives, leading to a faster and more memory-efficient parsing process. Semantic actions in Pratt parsing run exactly once, allowing side-effects without the need to rollback to a previous state. This property enables name reservation/release on lexical scope through a shared context object, used in the author's compiler.\n\nPratt parsing also allows the semantic action to look arbitrarily far ahead, enabling the use of PEG parsers or layered Pratt parsers within actions. While Pratt eats only one token at a time, the nuds and leds can consume multiple tokens in a single round, unlocking the power of parser combinators. This makes grammar ambiguities become table collisions, reducing the time spent on simpler ambiguity cases. Combining multiple parsers with Pratt also allows for grammar amalgamation, though grammar designers still need to work on avoiding ambiguities.",
  "summary": null,
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}