Re:Mochi – Dynamically-typed language for functional and act...
by CGamesPlay on Sunday December 14, 2014 @09:03PM
(#8750378)
> You can generate the Python code off from the AST, but it dosnt always imply the resulting Python code is runable.
I believe this is incorrect. Can you show an example of a valid abstract syntax tree that could not be represented in the grammar of the original language?
Re:Mochi – Dynamically-typed language for functional and act...
by breuleux on Sunday December 14, 2014 @09:51PM
(#8750481)
I know that variable names in Python's AST can be any string, so for instance you could declare and use a variable named "+a-b$ $$?", even though that's not valid Python code. That's pretty minor, though, so I'm curious if there's anything more significant.
Re:Mochi – Dynamically-typed language for functional and act...
by Foxboron on Monday December 15, 2014 @12:42AM
(#8750823)
We got this very "problem" in Hy. AST allows for several characters as Names, where python does not.
A great example is with gensym, here we will make an ast.Name node with a prefix ":", if you run astor over this, you produce AST containing that very character. What happens if you try run this Python code? Syntax error. There is also a few other cases i can't think off right now.
Coffeescript is a transpiler. It converts its own code directly into javascript code. This project converts its code to AST, not Python code itself. You can generate the Python code off from the AST, but it dosnt always imply the resulting Python code is runable.