Scheduling the Construction and Interrogation of Scope Graphs Using Attribute Grammars
Abstract
Recognizing that name binding is often done in an ad-hoc manner, Visser and his colleagues introduced scope graphs as a uniform representation of a program's static binding structure along with a generic means for interrogating that representation to resolve name references to their declarations. A challenge arises in scheduling the construction and querying actions so that a name resolution is not performed before all requisite information for that resolution is added to the scope graph. Visser et al. introduced a notion of weakly critical edges to constrain the order in which name resolution queries are performed to a correct one, but this has been found to be somewhat restrictive.
Visser et al. also introduced Statix, a constraint solving language for scope graph-based name resolution. We show that specifications written in an annotated version of Statix can be translated into reference attribute grammars, and that the order in which equations are solved under demand driven evaluation provides a valid order for solving constraints in Statix. This formalizes what has been folklore in the attribute grammar community for some time, that scope graphs are naturally specified in reference attributes grammars.