Oriel — AI & technology worth noticing, every day.

Some problems of recursive descent parsers

Web page · https://eli.thegreenplace.net/2009/03/14/some-problems-of-recursive-descent-parsers

First seen by Oriel on .

AI summary

The article identifies associativity and efficiency problems in recursive descent expression parsers, fixing the former with EBNF loops and recommending a hybrid parser when performance matters.

  • Right-recursive BNF evaluates chains right-to-left, causing `5 - 1 - 2` to produce 6 instead of the left-associative result 2.
  • EBNF repetition enables iterative parsing of addition and subtraction, accumulating terms left-to-right while retaining an LL(1) grammar.
  • Right recursion remains appropriate for exponentiation, allowing `2^3^2` to group as `2^(3^2)`.
  • Operator precedence requires nested rules; parsing the single token `42` invokes expr, term, power, and factor, creating inefficiency.
  • For performance-critical applications, the article suggests combining recursive descent for general syntax with a specialized infix-expression parsing algorithm.

#recursive descent #parsing #ebnf #operator precedence

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.

  • Lobsters: 4, latest observation ; +3 over observed period since

Comments

Comment count reported by the source.

  • Lobsters: 0, latest observation ; 0 over observed period since

Aliases

SourceExternal IDURL
Lobstersksmkzyhttps://eli.thegreenplace.net/2009/03/14/some-problems-of-recursive-descent-parsers Read discussion