| ▲ | priceishere 4 hours ago | |
An even simpler way imo, is explicit functions instead of a precedence table, then the code pretty much has the same structure as EBNF. Need to parse * before +? Begin at add, have it call parse_mul for its left and right sides, and so on.
Then just add more functions as you climb up the precedence levels. | ||
| ▲ | kryptiskt 4 hours ago | parent [-] | |
You lose in versatility, then you can't add user-defined operators, which is pretty easy with a Pratt parser. | ||