3 ms·
TDOP and Pratt are exactly the same thing, Vaughan Pratt is the inventor, Top Down Operator Precedence is the name he gave to the algorithm. And TDOP never "rec
by masklinn 11y ago
TDOP and Pratt are exactly the same thing, Vaughan Pratt is the inventor, Top Down Operator Precedence is the name he gave to the algorithm. And TDOP never "recurses or loops" (the precedence tells it whether it should stop looping). Part of the interest is how object-oriented it is, the main parsing loop ("expression" in the Crockford article) just tells a token "parse yourself as prefix" or "parse yourself as infix preceded by (AST)"
- abecedarius 11y agoThey're the same algorithm expressed in different styles: structured for precedence climbing, and as you say OO or 'data driven' for Pratt. https://github.com/darius/sketchbook/blob/master/parsing/precedence_climbing.py#L29 https://github.com/darius/sketchbook/blob/master/parsing/pre... https://github.com/darius/sketchbook/blob/master/parsing/pratt.py#L13 https://github.com/darius/sketchbook/blob/master/parsing/pra...