4 ms·
You lose in versatility, then you can't add user-defined operators, which is pretty easy with a Pratt parser.
by kryptiskt 6mo ago
You lose in versatility, then you can't add user-defined operators, which is pretty easy with a Pratt parser.
- wavemode 6mo agoYou can have user-defined operators with plain old recursive descent. Consider if you had functions called parse_user_ops_precedence_1, parse_user_ops_precedence_2, etc. These would simply take a table of user-defined operators as an argument (or reference some shared/global state), and participate in the same recursive callstack as all your other parsing functions.