Inferring scope through syntactic sugar

Many languages use syntactic sugar to define parts of their surface language in terms of a smaller core. Thus some properties of the surface language, like its scoping rules, are not immediately evident. Nevertheless, IDEs, refactorers, and other tools that traffic in source code depend on these rules to present information to users and to soundly perform their operations. In this paper, we show how to lift scoping rules defined on a core language to rules on the surface, a process of scope inference. In the process we introduce a new representation of binding structure---scope as a preorder---and present a theoretical advance: proving that a desugaring system preserves α-equivalence even though scoping rules have been provided only for the core language. We have also implemented the system presented in this paper.

[1]  Shriram Krishnamurthi,et al.  Resugaring: lifting evaluation sequences through syntactic sugar , 2014, PLDI.

[2]  Enno Ohlebusch,et al.  Term Rewriting Systems , 2002 .

[3]  François Pottier An Overview of Calphaml , 2006, Electron. Notes Theor. Comput. Sci..

[4]  Sebastian Erdweg,et al.  Capture-Avoiding and Hygienic Program Transformations , 2014, ECOOP.

[5]  Michael D. Adams Towards the Essence of Hygiene , 2015, POPL.

[6]  Samson Abramsky,et al.  Handbook of logic in computer science. , 1992 .

[7]  Shriram Krishnamurthi,et al.  Hygienic resugaring of compositional desugaring , 2015, ICFP.

[8]  Mitchell Wand,et al.  A Theory of Hygienic Macros , 2008, ESOP.

[9]  Matthias Felleisen,et al.  Hygienic macro expansion , 1986, LFP '86.

[10]  Matthias Felleisen,et al.  DrScheme: a programming environment for Scheme , 2002, J. Funct. Program..

[11]  Mitchell Wand,et al.  Romeo , 2014, Journal of Functional Programming.

[12]  David Fisher,et al.  Static analysis for syntax objects , 2006, ICFP '06.

[13]  Stephanie Weirich,et al.  Binders unbound , 2011, ICFP.

[14]  D. H. Bartley,et al.  Revised4 report on the algorithmic language scheme , 1991, LIPO.

[15]  ErdwegSebastian,et al.  Modular and automated type-soundness verification for language extensions , 2013 .

[16]  Donald E. Knuth,et al.  Semantics of context-free languages , 1968, Mathematical systems theory.

[17]  Tom Ridge,et al.  Ott: Effective tool support for the working semanticist , 2010, J. Funct. Program..

[18]  Eelco Visser,et al.  Declarative Name Binding and Scope Rules , 2012, SLE.

[19]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[20]  Matthew Flatt Binding as sets of scopes , 2016, POPL.

[21]  Tom Ridge,et al.  Ott: effective tool support for the working semanticist , 2007, ICFP '07.

[22]  Eelco Visser,et al.  A Theory of Name Resolution , 2015, ESOP.