melt-umn / silver

An attribute grammar-based programming language for composable language extensions
http://melt.cs.umn.edu/silver/
GNU Lesser General Public License v3.0
58 stars 7 forks source link

flowtype specifications for collection production attributes #238

Open tedinski opened 6 years ago

tedinski commented 6 years ago
production attribute foo :: [Type] with ++ flowtype { inh };

Would be nice. The blocker for implementing such things was simply that we can't raise good error messages if the defining equations exceed the specified flow type.

The root of the problem is pretty much that we only have a decent mechanism for setting a minimum flow type for production attributes, because we don't track them the same way we do other flow information. They're just nodes in the graph. We can come back and see edges in that graph, but essentially have no idea where they came from.

But maybe we can live with that?

tedinski commented 5 years ago

I think this is more easily doable than I originally though.

If we introduce a new localSpecificationFlowDef, we can:

  1. Add it to the phantom flow graph as a minimum flow type easily enough. (Actually wait, the phantom won't work, this would have to be to the ordinary flow graph for the production. That should be okay.)
  2. Change the logic for flow errors to use a localSpecificationFlowDef if it exists, or otherwise use the expanded graph from the equation node in the production graph as the maximum.
  3. When checking for exceeds errors, expand the RHS instead of expanding the LHS node, so we're looking at each individual contribution's specific flow contributions. This should allow us to accurately identify the <- that exceeds the flow type.

So I don't think this will be as hard as I originally thought. Unless I've just forgotten something.