To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/67b109aa-8d7a-4078-abee-50f376e3328d%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
I had already gone through that tutorial prior to writing the proposal. It was the only resource I found on Autolev. I think the guide book would be more useful as it is more elaborate and covers dynamics theory as well.
Nikhil
On Fri, May 18, 2018, at 1:32 AM, Nikhil Pappu wrote:
> Ondřej, Jason,
>
> I have written my first blog post <https://wp.me/p3Sr5x-2> discussing the
> project details and status.
> Can you please go over it and provide feedback?
I think overall it looks very good. It looks like you got a good handle of ANTLR4.
I noticed you are using a listener:
One thing to consider is whether to directly use the grammar from ANTLR, which is called a concrete syntax tree (CST), and construct a sympy expression of whatever you want out of it directly. That is what you do now I think.
The alternative is to first construct an abstract syntax tree (AST) from the CST. That way the AST will be the input to the rest of your "compiler", and it won't matter that we currently use ANTLR to construct it.
Later somebody can decide to write a hand parser, or some other tool. As long as it produces the AST, that's all that matters.
As it is currently, the CST depends on the exact rules as you write them in the ANTLR grammar, and everytime you change the rules, you have to rework your compiler. While if you use AST, then you only have to modify the code that converts the (modified) CST to AST, but that's it. The rest of the compiler uses AST, and so it doesn't need to change.
Python, for example, uses this approach. It parses Python code into an AST, and so they are free to change the parser any way they like ---- our SymPy code that uses the Python AST doesn't need to change.
e = 4*x**2 + 7*x*y + 21*x + 4*y**2 + 21*y
factor(e, x) in Autolev
e.factor(x) in SymPy
21*y + 4*y^2 + 4*x*(5.25 + x +1.75*y)
(7*y + 21)*x + 4*x**2 + 4*y**2 + 21*y