Download it now!
Bug 66200 - Improve parsing of implicit products like 2 x
Summary: Improve parsing of implicit products like 2 x
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
(earliest affected) Master
Hardware: All All
: medium normal
Assignee: Not Assigned
Depends on:
Blocks: Formula-Editor
  Show dependency treegraph
Reported: 2013-06-26 09:25 UTC by Frédéric Wang
Modified: 2019-06-10 10:06 UTC (History)
0 users

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Frédéric Wang 2013-06-26 09:25:16 UTC
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

=> 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

=> 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 (
Comment 1 Jorendc 2013-06-26 11:05:28 UTC
I think I don't have to say this again :-), but you already prove you are an expert in this domain. Feel free to mark your own bugs as NEW without any QA interaction. Except you would like to have a review/second opinion test etc. :)

Kind regards,
Comment 2 QA Administrators 2015-03-16 23:39:55 UTC Comment hidden (obsolete)
Comment 3 tommy27 2016-04-16 07:26:28 UTC Comment hidden (obsolete)
Comment 4 QA Administrators 2017-05-22 13:22:26 UTC
** Please read this message in its entirety before responding **

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present on a currently supported version of LibreOffice 
(5.2.7 or 5.3.3

If the bug is present, please leave a comment that includes the version of LibreOffice and 
your operating system, and any changes you see in the bug behavior
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave 
a short comment that includes your version of LibreOffice and Operating System

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)

If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3)

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to "inherited from OOo";
4b. If the bug was not present in 3.3 - add "regression" to keyword

Feel free to come ask questions or to say hello in our QA chat:

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team