Adopt Mathematica way to translate even erroneous commands
BUG: 420671
cfeck | |
davidhurka |
Adopt Mathematica way to translate even erroneous commands
BUG: 420671
Create Cartesian plot with 'f(x)=x+', 'f(x)=x*', 'f(x)=x/', 'f(x)=x^'
No Linters Available |
No Unit Test Coverage |
Buildable 26339 | |
Build 26357: arc lint + arc unit |
Thanks for working on this. While this is an improvement, this solution is not what I had in mind. I think if the user enters a syntactically invalid expression, it should be recognized as syntax error.
My bug was titled “KmPlot plots another function instead”. With this fix, the function is usually more close to what the user wanted, but it is still not the entered function. I don’t think there is any way to fix a mathematic expression.
Wouldn’t it be possible to check whether there are trailing binary operators, and then append something that reliably causes a syntax error in Mathematica?
I think that it breaks the whole concept of the current parser. For example, the input "sfgs" is marked as an error, but when you type "sin" (without an argument) it's Ok. The whole parser should be rewritten in the LabPlot2 style to make such things possible.
The problem is that the original author wanted input errors to be visible while typing.
If you check the expression after hitting Enter, you can detect more errors.
That makes sense. It actually works, so it works.
If you check the expression after hitting Enter, you can detect more errors.
That also already works. When you do not match an ( with a ), the expression is not accepted at Enter.
Currently I understand it that some parser function inside KmPlot parses the expression to a token stream, which is then passed to Mathematica. The parser requires matching brackets, so it could also require right arguments for binary operators, couldn’t it?
To me as a user it looks like the parser works in general, and it is fairly complex code, so I think we don’t need to replace it with a new parser. I don’t know the parser of LabPlot2. If it could be a drop-in replacement, hmm...
It appears that binary expressions are matched in heir0() to heir5() functions. Their logical structure is too complicated to understand it quickly, but I think one of these doesn’t monitor which operator makes sense now.
No, sorry for misguiding. I meant that the Mathematica/Wolfram Alpha parser can produce any possible result from user input, not that we use Wolfram Mathematica.
Probably, this "fuzzy" parsing and trying to build everything you might input attracts me in KmPlot the most. Just tried to build "f(x)=cos /2". ;)