Oriel — AI & technology worth noticing, every day.

Writing about pratt parsing so I remember it

Web page · https://unix.dog/~yosh/blog/2026-10-25_pratt-parsing.html

First seen by Oriel on .

AI summary

This article explains Pratt parsing as a recursive transformation of shunting yard, demonstrating C implementations and extensibility for parentheses and additional operators.

  • Shunting yard uses an operator stack and binding powers to emit postfix notation, but increasingly complex constructs make the approach harder to extend.
  • Pratt parsing replaces the explicit operator stack with recursive calls that carry left binding power and return when operators bind less tightly.
  • Prefix tokens are handled as “nuds,” while infix and postfix operators are handled as “leds” within the expression parser.
  • Parentheses require a prefix branch and subroutine, while operator rules can combine binding powers with dedicated prefix and postfix handlers.
  • The article’s structured example extends the grammar with unary +, -, and postfix ! for a more maintainable codebase form.

#pratt parsing #shunting yard #c #parsing

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Points

Score reported by the source.

  • Hacker News: 84, latest observation ; +80 over observed period since
  • Lobsters: 31, latest observation ; +29 over observed period since

Comments

Comment count reported by the source.

  • Hacker News: 7, latest observation ; +7 over observed period since
  • Lobsters: 13, latest observation ; +13 over observed period since

Aliases

SourceExternal IDURL
Hacker News50255177https://www.unix.dog/~yosh/blog/2026-10-25_pratt-parsing.html Read discussion
Lobstersmu3xcdhttps://www.unix.dog/~yosh/blog/2026-10-25_pratt-parsing.html Read discussion