augustt198 / latex2sympy

Parse LaTeX math expressions
MIT License
386 stars 162 forks source link

Multiple \\int, \\sum, or \\prod statements #13

Open ledjohnny opened 8 years ago

ledjohnny commented 8 years ago

It seems that adding multiple expressions for \\int,\\sum, or \\prod together will cause an error to occur. For instance: process_sympy("\\int_{-3}^{4} \\frac{1}{x}dx+\\int_{1.5}^{2} \\ln(x)dx") Throws:

UnboundLocalError: local variable 'int_var' referenced before assignment

In PS.g4, I found a way to allow summing multiple integrals. Change: | FUNC_INT (subexpr supexpr | supexpr subexpr)? (additive? DIFFERENTIAL | frac | additive)

To: | FUNC_INT (subexpr supexpr | supexpr subexpr)? (additive? DIFFERENTIAL)

Unfortunately, this doesn't allow differentials to be in fractional form. For example: \\int_{3}^{5} dx/x

Thanks for your time, John

augustt198 commented 8 years ago

Yeah parsing those is a real pain. The problem is that people expect something like \int a + b dx to be handled by the parser, when really \int (a + x) dx would be the correct notation (and would be very easy to parse).

This forces us to capture multiple terms inside the integral, which can lead to the next integral being captured as well.

I think it's likely that to handle this the parse tree will have to be modified after antlr is finished.