Convert m_ast to Haskell ADT #280
Replies: 2 comments 4 replies
-
I would not be willing to work on this :) Further, don't believe all the Haskell hype. But actually the m_ast is extremely strongly typed (for python), with strong guarantees and invariants. There is also a visitor function. For example: miss_hit/miss_hit_core/m_ast.py Lines 1996 to 2001 in f01fbf9 Notice the assertions that make sure the shape of the tree is correct. Also you get this visitor class: miss_hit/miss_hit_core/m_ast.py Lines 194 to 199 in f01fbf9
There are two visit functions, one that is called as we descend down the tree, and one that is called as we come back up. You can call the .visit function on any node, like so: self.visit(None, Text_Visitor(fd), "Root") For an example you can look at Text_Visitor, which is the tree ast printer. I strongly suggest you do not do what you're trying to attempt, it will not be worth it. But that's just my opinion, you're of course free to do what you want ;) |
Beta Was this translation helpful? Give feedback.
-
Also, any function that adds to the ast (e.g. adding a function to a class, etc.) makes sure the shape and any invariants are maintained. |
Beta Was this translation helpful? Give feedback.
-
Haskell makes it really easy to work on large compiler codebases and even perform type inference(via constraint solvers). I see miss_hit being a a frontend to such a tool. I'm trying to make an Visitor pass that can dump out a Haskell AST. But to do this, I need to define the right Haskell types. Doing this is not so easy since most of
m_ast
is untyped. Do you have any hints? Would you be willing to work on this?Here is what an ADT would look like for a C-language in Haskell, for example.
Beta Was this translation helpful? Give feedback.
All reactions