|
|
|
|
|
by unanimous
1645 days ago
|
|
SpeedCrunch looks very promising, and I've used it a lot in the past. I'm sad to see that they still haven't released the order of operations bug fix [0] they made in 2017. SpeedCrunch does some operations in an order most people wouldn't expect. For example, SpeedCrunch says 1/2(-9.8) = -0.05102040816326530612 [0] - https://bitbucket.org/heldercorreia/speedcrunch/commits/ac49... |
|
In a CFG this is easy enough to express. Here's an untested and at any rate incomplete CFG demonstrating the technique:
But typical parser generators don't give you an easy way to provide a useful error message there.That version of the grammar, btw, avoids left recursion, so it ought to work as a PEG, but at the cost of the wrong associativity for "/" and "-". You either need to use left recursion or restructure the syntax tree afterwards.