| Summary: |
Improve parsing of implicit products like 2 x |
| Product: |
LibreOffice
|
Reporter: |
Frédéric Wang <fred.wang> |
| Component: |
Formula Editor | Assignee: |
Not Assigned <libreoffice-bugs> |
| Status: |
NEW
---
|
QA Contact: |
|
| Severity: |
normal
|
|
|
| Priority: |
medium
|
|
|
| Version: |
4.2.0.0.alpha0+ Master | |
|
| Hardware: |
All | |
|
| OS: |
All | |
|
| See Also: |
https://bugs.freedesktop.org/show_bug.cgi?id=65765
|
| Whiteboard: |
|
|
i915 platform:
|
|
i915 features:
|
|
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.
For example Math currently parses expressions like this: "a + 2 b" => "{a + 2} b" instead of "a + {2 b}" "x + 3 y^2" => "{x + 3} y^2" instead of "x + 3 y^2" I tried to fix that in bug 66081, but I suspect it would be a bit more complicated than what I initially thought, so I'm moving it as a separate bug. Currently, the grammar used by starmath/source/parse.cxx is (approximately) as follows: Expression = Relation ([relation token] Relation)+ Relation = Sum ([sum token] Sum) + Sum = Product ([product token] Product)+ Product = Power ([power token] Power)+ Power = Term ([sub/sup script tokens] Term)+ Term = ['{' token] Expression ['}' token] | [text token] | [symbol token] | Matrix | Binom | ... other terms ... Binom = ['binom' token] Sum Sum Matrix = ... ... = other rules The parsing can be done linearly and stops when an unexpected token is read. What we'd like in order to fix this bug is to define Product = Power (([power token] Power)+ | Power+) so that an explicit [power token] like "*" is not needed to write a product i.e. we can write "a b" instead of "a * b". Unfortunately, after some attempts this breaks some unit tests. For example the naive parsing of "binom a b" could become Term => binom Sum Sum => binom Product Sum => binom (Power)+ Sum => binom (Term)+ Sum => binom a b Sum => binom a b Product => binom a b (Power)+ => binom a b (Term)+ => failure! rather than the expected Term => binom Sum Sum => binom Term Term => binom a b The grammar can probably be modified to avoid some of the issues but I suspect a general solution will require to use techniques like those of parsers generated by GNU bison (https://en.wikipedia.org/wiki/GNU_bison).