On Sat, May 30, 2015 at 5:46 PM, Matt Oliveri <[email protected]> wrote:
> > What it looked like you were doing to handle this was define all the > things you want to be types as mutually recursive types. I was > building on that by showing how you can still factor out the fields > that are common to all legs of all types. > So first, many of these languages actually don't have a way to define mutually recursive types. One positive outcome of the present thread is that it has reminded me that BitC needs a means to do that. Second, merely factoring out the common fields isn't the goal here. The goal is to do that in such a way that we end up with a type that can describe the kind of AST that is typically associated with a context-free grammar. How about this: Pick a language of your choice. Show me how to declare the type of an AST node that satisfies the following properties: 1. The grammar is the expression grammar for four-function expression arithmetic plus negation plus assugnment. Note that negation is unary and assignment is NOT an expression. You don't have to worry about the parsing or precedence or the like. You only need to create a suitable AST. 2. Every AST node has a field of type "Location". This will serve as the non-variant part. 3. The structural correctness of the tree should be statically checked to the degree that this can be expressed. 4. It should be possible to write a single procedure taking an argument of type ASTNode and performing some form of recursive-descent pass on that node type. shap
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
