Correct parsing of chains of < and <=
See original GitHub issueParsing a chain of comparison operators, such as 1 <= x < 10
is a quite natural thing for humans to do. However, how to best represent this doesn’t seem quite as clear cut to me. Which of the <=
and <
signs comes first? Or should we somehow encode that they’re at the same level? Or…?
For the record, this is what the compute-engine currently does. It’s a bit inconsistent.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Right way to parse chain of various binary functions with ...
there is no standard way to implement "importance" of an operation: for example a + b = b + a should be parsed...
Read more >A Guide To Parsing: Algorithms And Terminology
A complete parser is usually composed of two parts: a lexer, also known as scanner or tokenizer, and the proper parser. The parser...
Read more >Constituency Parsing - Stanford University
CKY with neural methods to choose a single correct parse by syntactic disambigua- ... B by a chain of one or more unit...
Read more >Parsing: a timeline -- V3.1 - GitHub Pages
Recursive descent, without help, cannot parse RIGHT-OP. As of 1961, parsing theory has not developed well enough to state why in a precise...
Read more >Parsing and PCFGs - Brown CS
Most importantly, there is no agreement on the correct grammar even for a well-studied language like English. For example, what's the structure ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, that could work as well.
BTW,
["Less"]
is a valid MathJSON expression: it’s the partial application of theLess
function to no arguments (["Less", 0]
is the partial application of theLess
function)I realized that Mathematica has the same problem. So clearly, it would make sense to check what they’re doing.
The following piece of code
(Source: https://mathematica.stackexchange.com/a/152438 )
returns
Which seems like a rather reasonable way of doing it in the compute engine. I guess functions would have to be wrapped in brackets or something, so that they can be distinguished from variables.
["Inequality", 1, ["Less"], "x", ["LessEqual"], "k"]
And here is their relevant documentation https://reference.wolfram.com/language/ref/FullForm.html and https://reference.wolfram.com/language/ref/TreeForm.html