jonathf/matlab2cpp

Continue Long Statements on Multiple Lines

axplusbu opened this issue · 2 comments

Thanks for making this tool. Just a minor note: it appears that the following syntax is not supported:
www.mathworks.com/help/matlab/matlab_prog/continue-long-statements-on-multiple-lines.html

I have done some changes but I have not been able to fix them entirely. The first example in the link works. The problem is that there is no whitespace on the second line so that the second number is not picked up by the node tree creator (Builder).

This doesn't work at the moment
x = [1.23...
4.56];
but
x = [1.23...
(whitespace) 4.56];

works. I tried work around this by adding some whitespaces to the code loaded into the program and it worked for the case above, but a similar case (3x1, column vector):

x = [1.5
2.5
3.5]

have the same problem, but

x = [1.5
(whitespace) 2.5
(whitespace) 3.5]
works.

Instead of adding even more whitespaces, i think the problem can be solved more generally by changing /tree/misc.py on line 394 and 395. The problem with the two cases above is that there is no whitespace so identify.space_delimited returns false, so it looks for a list separated by , instead of whitespace. I made identify.space_delimited return true, but iterate.space_list only also returns the first value in the list. It is a bit complicated to see exactly what is going on in the two functions (and I did not write this code), so I am unsure if I can fix it without breaking something else. So it might take a while to solve this.

I think there is no problem if you use comma (,) instead of whitespace as number separator.

I have done some fixes and the examples in the link works for me. There could be some variations of continue long statements that don't work.