Re: [sympy] Re: Autolev Parser

2018-05-18 Thread Nikhil Pappu


On Friday, May 18, 2018 at 4:08:29 PM UTC+5:30, Ondřej Čertík wrote:
>
>
>
> On Fri, May 18, 2018, at 1:32 AM, Nikhil Pappu wrote: 
> > Ondřej, Jason, 
> > 
> > I have written my first blog post  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: 
>
 
I prefer using listeners over visitors. I feel it helps me to focus on the 
logic than on the tree traversal. 

>
> 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. 
>
 
Yes, I am using the CST approach.


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

 
I only have a basic idea of ASTs. I have never implemented them so I do not 
have any experience using them.
The ANTLR book showcased only the CST approach so I am much more 
comfortable with that.
I think ANTLR generates something in between a CST and an AST but it does 
have a lot of clutter compared to an AST. 
I was just looking at some examples of using ASTs with ANTLR in 
stackoverflow but most of the examples were quite trivial.
The conversion from CST to AST for the Autolev grammar wouldn't be so 
trivial if we want to obtain a transformation with minimal loss.
Also, I would need to change the parser code quite significantly to deal 
with the new tree. 


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. 


I'm not sure why someone would want to do that if we already have a working 
parser.
One might rather look towards changing the actual parser code itself in my 
opinion, whether to fix any issues or add new functionality.
 

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


That is an advantage but I don't think we would have to change the grammar 
all that much. I have tested the grammar on a lot of inputs and it seems to 
parse them just fine.
 

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

 
I think that the AST approach would be a much better one in the case of 
more complex languages like Python or C.
I think this is not as important in this case as Autolev is a much simpler 
language. 
At its heart it mainly only consists or declarations, assignments and 
commands which makes direct parsing using a CST convenient enough.

>
>
> > Also, when will you be available to discuss things? 
>
> I am available over email only the next week. 
>
> Ondrej 
>
> > 
> > -- 
> > 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+un...@googlegroups.com . 
> > To post to this group, send email to sy...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/sympy. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/sympy/bc81cd14-ad9b-4503-a639-aa6f673f4c51%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/d207a582-c67e-4219-8a6f-1d5c6a640ebe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Running tests on Windows

2018-05-18 Thread rahul g
Hi guys,

I'm not able to run the command 'bin/test' on windows. It gives an error 
'bin is not recognised as an internal or external command'. I've tried to 
cd into the bin directory and then run 'test' but to no avail. Is there any 
workaround to this issue. 

Thanks!

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/ab65796e-ea32-4fe8-9cb8-50c63e3c74a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Re: Autolev Parser

2018-05-18 Thread Ondřej Čertík


On Fri, May 18, 2018, at 1:32 AM, Nikhil Pappu wrote:
> Ondřej, Jason,
> 
> I have written my first blog post  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:

https://github.com/NikhilPappu/autolev-parser/blob/f6d110ff5a8cef3aea4f6357f343491572350393/myListener.py#L260

In my codes, I ended up using a visitor --- since I needed to visit every node 
anyway, and recursively construct the, in your case, sympy expression probably.

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.


> Also, when will you be available to discuss things?

I am available over email only the next week.

Ondrej

> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/bc81cd14-ad9b-4503-a639-aa6f673f4c51%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/1526639904.177921.1376625912.09CA91C7%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Re: Autolev Parser

2018-05-18 Thread Nikhil Pappu
Ondřej, Jason,

I have written my first blog post  discussing the 
project details and status.
Can you please go over it and provide feedback?
Also, when will you be available to discuss things?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/bc81cd14-ad9b-4503-a639-aa6f673f4c51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.