Abstract
This paper describes an extensible language framework, ableC, that allows programmers to import new, domain-specific, independently-developed language features into their programming language, in this case C. Most importantly, this framework ensures that the language extensions will automatically compose to form a working translator that does not terminate abnormally. This is possible due to two modular analyses that extension developers can apply to their language extension to check its composability. Specifically, these ensure that the composed concrete syntax specification is non-ambiguous and the composed attribute grammar specifying the semantics is well-defined. This assurance and the expressiveness of the supported extensions is a distinguishing characteristic of the approach.
The paper describes a number of techniques for specifying a host language, in this case C at the C11 standard, to make it more amenable to language extension. These include techniques that make additional extensions pass these modular analyses, refactorings of the host language to support a wider range of extensions, and the addition of semantic extension points to support, for example, operator overloading and non-local code transformations.
Supplemental Material
Available for Download
- S. R. Adams. 1993. Modular Grammars for Programming Language Prototyping. Ph.D. Dissertation. University of Southampton, Department of Elec. and Comp. Sci., UK.Google Scholar
- A.V. Aho, R. Sethi, and J.D. Ullman. 1986. Compilers – Principles, Techniques, and Tools. Addison-Wesley, Reading, MA.Google Scholar
- Emilie Balland, Paul Brauner, Radu Kopetz, Pierre-Etienne Moreau, and Antoine Reilles. 2007. Tom: Piggybacking rewriting on Java. In Proceedings of the International Conference on Rewriting Techniques and Applications (RTA ’07). Google Scholar
Cross Ref
- John Tang Boyland. 2005. Remote attribute grammars. J. ACM 52, 4 (2005), 627–687. Google Scholar
Digital Library
- Martin Bravenboer and Eelco Visser. 2004. Concrete syntax for objects: domain-specific language embedding and assimilation without restrictions. In Proceedings of the ACM Conference on Object Oriented Programming, Systems, Languages, and Systems (OOPSLA ’04). ACM, 365–383. Google Scholar
Digital Library
- Travis Carlson and Eric Van Wyk. 2017. Type qualifiers as composable language extensions. In Proceedings of the 2017 ACM SIGPLAN International Conference on Generative Programming: Concepts & Experience (GPCE ’17). ACM, New York, NY, USA. Google Scholar
Digital Library
- Russel Cox, Tom Bergany, Austin Clements, Frans Kaashoek, and Eddie Kohlery. 2008. Xoc, an Extension-Oriented Compiler for Systems Programming. In Proceedings of Architectural Support for Programming Languages and Operating Systems (ASPLOS). Google Scholar
Digital Library
- Lukas Diekmann and Laurence Tratt. 2014. Eco: A Language Composition Editor. Springer International Publishing, Cham, 82–101.Google Scholar
- Werner Dietl, Stephanie Dietzel, Michael D. Ernst, Kivanç Muşlu, and Todd W. Schiller. 2011. Building and Using Pluggable Type-checkers. In Proceedings of the 33rd International Conference on Software Engineering (ICSE ’11). ACM, New York, NY, USA, 681–690. Google Scholar
Digital Library
- Torbjörn Ekman and Görel Hedin. 2007a. The JastAdd extensible Java compiler. In Proceedings of the ACM Conference on Object Oriented Programming, Systems, Languages, and Systems (OOPSLA ’07). ACM, 1–18.Google Scholar
- Torbjörn Ekman and Görel Hedin. 2007b. The JastAdd system - modular extensible compiler construction. Science of Computer Programming 69 (December 2007), 14–26. Issue 1-3.Google Scholar
- Sebastian Erdweg, Tillmann Rendel, Christian Kastner, and Klaus Ostermann. 2011. SugarJ: Library-based Syntactic Language Extensibility. In Proceedings of the ACM Conference on Object Oriented Programming, Systems, Languages, and Systems (OOPSLA ’11). ACM, 391–406. Google Scholar
Digital Library
- Sebastian Erdweg, Tijs van der Storm, and Yi Dai. 2014. Capture-Avoiding and Hygienic Program Transformations. In Proceedings of the European Conference on Object Oriented Programming (ECOOP) (Lecture Notes in Computer Science), Vol. 8586. Springer, 489–514. Google Scholar
Digital Library
- R. Farrow, T. J. Marlowe, and D. M. Yellin. 1992. Composable attribute grammars. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 223–234. Google Scholar
Digital Library
- Matthew Flatt. 2010. Reference: Racket. Technical Report PLT-TR-2010-1. PLT Inc.Google Scholar
- Bryan Ford. 2004. Parsing expression grammars: a recognition-based syntactic foundation. In Proceedings of the Symposium on Principles of Programming Languages (POPL). ACM, 111–122. Google Scholar
Digital Library
- Jeffrey S. Foster, Manuel Fähndrich, and Alexander Aiken. 1999. A theory of type qualifiers. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’99). ACM. Google Scholar
Digital Library
- Jeffrey S. Foster, Tachio Terauchi, and Alex Aiken. 2002. Flow-Sensitive Type Qualifiers. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’02). Berlin, Germany, 1–12. Google Scholar
Digital Library
- Matteo Frigo, Charles E. Leiserson, and Keith H. Randall. 1998. The implementation of the Cilk-5 multithreaded language. In Proceedings of Programming Language Design and Implementation (PLDI ’98). ACM, 212–223. Google Scholar
Digital Library
- H. Ganzinger. 1983. Increasing Modularity and Language-Independency in Automatically Generated Compilers. Science of Computer Programing 3, 3 (1983), 223–278. Google Scholar
Cross Ref
- Robert Grimm. 2006. Better extensibility through modular syntax. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI ’06). ACM Press, New York, NY, USA, 38–51. Google Scholar
Digital Library
- G. Hedin. 2000. Reference Attribute Grammars. Informatica 24, 3 (2000), 301–317.Google Scholar
- P. Hudak. 1996. Building Domain-Specific Embedded Languages. Comput. Surveys 28, 4es (1996).Google Scholar
- Ted Kaminski. 2017. Reliably Composable Language Extensions. Ph.D. Dissertation. University of Minnesota, Minneapolis, Minnesota, USA. Available at http://hdl.handle.net/11299/188954 .Google Scholar
- Ted Kaminski, Lucas Kramer, Travis Carlson, and Eric Van Wyk. 2017. Reliable and automatic composition of language extensions to C — Supplemental Material. Technical Report 17-009. University of Minnesota, Department of Computer Science and Engineering. Available at https://www.cs.umn.edu/research/technical_reports/view/17-009 .Google Scholar
- Ted Kaminski and Eric Van Wyk. 2011. Integrating attribute grammar and functional programming language features. In Proceedings of the 4th International Conference on Software Language Engineering (SLE ’11) (LNCS), Vol. 6940. Springer, 263–282.Google Scholar
- Ted Kaminski and Eric Van Wyk. 2012. Modular well-definedness analysis for attribute grammars. In Proceedings of the International Conference on Software Language Engineering (SLE) (LNCS), Vol. 7745. Springer, 352–371.Google Scholar
- Ted Kaminski and Eric Van Wyk. 2017. Ensuring Non-interference of Composable Language Extensions. In Proceedings of the 2017 ACM SIGPLAN International Conference on Software Language Engineering (SLE ’17). ACM, New York, NY, USA.Google Scholar
Digital Library
- U. Kastens and W. M. Waite. 1994. Modularity and reusability in attribute grammars. Acta Informatica 31 (1994), 601–627. Google Scholar
Digital Library
- Lennart C. L. Kats and Eelco Visser. 2010. The Spoofax Language Workbench. Rules for Declarative Specification of Languages and IDEs. In Proceedings of the ACM Conference on Object Oriented Programming, Systems, Languages, and Systems (OOPSLA). ACM.Google Scholar
- Paul Klint, Tijs van der Storm, and Jurgen Vinju. 2009. RASCAL: a Domain Specific Language for Source Code Analysis and Manipulation. In Proceedings of Source Code Analysis and Manipulation (SCAM). Google Scholar
Digital Library
- D. E. Knuth. 1968. Semantics of Context-free Languages. Mathematical Systems Theory 2, 2 (1968), 127–145. Corrections in 5(1971) pp. 95–96.Google Scholar
Cross Ref
- Eugene Kohlbecker, Daniel P. Friedman, Matthias Felleisen, and Bruce Duba. 1986. Hygienic macro expansion. In Proceedings of the 1986 ACM conference on LISP and Functional Programming. ACM Press, 151–161. Google Scholar
Digital Library
- Florian Lorenzen and Sebastian Erdweg. 2016. Sound Type-dependent Syntactic Language Extension. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2016). ACM, New York, NY, USA, 204–216. Google Scholar
Digital Library
- Yogesh Mali and Eric Van Wyk. 2011. Building Extensible Specifications and Implementations of Promela with AbleP. In Proceedings of the International SPIN Workshop on Model Checking of Software (LNCS), Vol. 6823. Springer, 108–125. Google Scholar
Cross Ref
- Pierre-Etienne Moreau, Christophe Ringeissen, and Marian Vittek. 2003. A Pattern Matching Compiler for Multiple Target Languages. In Proceedings of the 12th International Conference on Compiler Construction (LNCS), Vol. 2622. Springer, 61–76.Google Scholar
- G. C. Necula, S. McPeak, S. P. Rahul, and W. Weimer. 2002. Cil: Intermediate Language and Tools for Analysis and Transformation of C Programs. In Proceedings of the 11th International Conference on Compiler Construction (Lecture Notes in Computer Science), Vol. 2304. Springer-Verlag, 213–228.Google Scholar
- Nathaniel Nystrom, Michael R. Clarkson, and Andrew C. Myer. 2003. Polyglot: An extensible compiler framework for Java. In Proceedings of the 12th International Conference on Compiler Construction (LNCS), Vol. 2622. Springer, 138–152. Google Scholar
Cross Ref
- Cyrus Omar. 2017. Reasonably Programmable Syntax. Ph.D. Dissertation. Carnegie Mellon University, Pittsburgh, USA.Google Scholar
- Cyrus Omar, Benjamin Chung, Darya Kurilova, Alex Potanin, and Jonathan Aldrich. 2013. Type-Directed, WhitespaceDelimited Parsing for Embedded DSLs. In Proceedings of the First Workshop on the Globalization of Domain Specific Languages (GlobalDSL ’13). ACM, New York, NY, USA, 8–11. Google Scholar
Digital Library
- Cyrus Omar, Darya Kurilova, Ligia Nistor, Benjamin Chung, Alex Potanin, and Jonathan Aldrich. 2014. Safely Composable Type-Specific Languages. In Proceedings of the European Conference on Object Oriented Programming (ECOOP ’14), Richard Jones (Ed.). Lecture Notes in Computer Science, Vol. 8586. Springer, 105–130. Google Scholar
Digital Library
- Dan Quinlan. 2000. ROSE: Compiler Support for Object-Oriented Frameworks. Parallel Processing Letters 10, 02n03 (2000), 215–226.Google Scholar
Cross Ref
- Jonathan Ragan-Kelley, Andrew Adams, Sylvain Paris, Marc Levoy, Saman Amarasinghe, and Frédo Durand. 2012. Decoupling Algorithms from Schedules for Easy Optimization of Image Processing Pipelines. ACM Transactions on Graphics 31, 4, Article 32 (July 2012), 12 pages.Google Scholar
Digital Library
- Tillmann Rendel, Jonathan Immanuel Brachthäuser, and Klaus Ostermann. 2014. From object algebras to attribute grammars. In ACM SIGPLAN Notices, Vol. 49. ACM, 377–395. Google Scholar
Digital Library
- Nico Ritschel and Sebastian Erdweg. 2015. Modular Capture Avoidance for Program Transformations. In Proceedings of the 2015 ACM SIGPLAN Conference on Software Language Engineering (SLE ’15). ACM, New York, NY, USA, 59–70.Google Scholar
Digital Library
- Tiark Rompf and Martin Odersky. 2010. Lightweight Modular Staging: A pragmatic approach to runtime code generation and compiled DSLs. In Proceedings of the ACM SIGPLAN 2010 Conference on Generative Programming and Component Engineering (GPCE ’10). ACM, New York, NY, USA, 127–136. Google Scholar
Digital Library
- Joao Saraiva and Doaitse Swierstra. 1999. Generic Attribute Grammars. In 2nd Workshop on Attribute Grammars and their Applications. 185–204.Google Scholar
- August Schwerdfeger. 2010. Context-Aware Scanning and Determinism-Preserving Grammar Composition, in Theory and Practice. Ph.D. Dissertation. University of Minnesota, Department of Computer Science and Engineering, Minneapolis, Minnesota, USA. Available at http://purl.umn.edu/95605 .Google Scholar
- August Schwerdfeger and Eric Van Wyk. 2009. Verifiable Composition of Deterministic Grammars. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI ’09). ACM, 199–210. Google Scholar
Digital Library
- August Schwerdfeger and Eric Van Wyk. 2010. Verifiable Parse Table Composition for Deterministic Parsing. In Proceedings of the 2nd International Conference on Software Language Engineering (LNCS), Vol. 5969. Springer, 184–203. Google Scholar
Digital Library
- Umesh Shankar, Kunal Talwar, Jeffrey S. Foster, and David Wagner. 2001. Detecting Format String Vulnerabilities with Type Qualifiers. In Proceedings of the 10th USENIX Security Symposium. Washington, D.C., 201–218.Google Scholar
- Charles Simonyi, Magnus Christerson, and Shane Clifford. 2006. Intentional software. SIGPLAN Notices 41, 10 (2006), 451–464. Google Scholar
Digital Library
- Anthony M. Sloane. 2011. Lightweight language processing in Kiama. In Proceedings of the 3rd summer school on Generative and Transformational Techniques in Software Engineering III (GTTSE ’09) (LNCS), Vol. 6491. Springer, 408–425. Google Scholar
Cross Ref
- Eric Van Wyk, Derek Bodin, Jimin Gao, and Lijesh Krishnan. 2010. Silver: an Extensible Attribute Grammar System. Science of Computer Programming 75, 1–2 (January 2010), 39–54.Google Scholar
Digital Library
- E. Van Wyk, O. de Moor, K. Backhouse, and P. Kwiatkowski. 2002. Forwarding in Attribute Grammars for Modular Language Design. In Proceedings of the 11th Conference on Compiler Construction (CC) (LNCS), Vol. 2304. Springer-Verlag, 128–142. Google Scholar
Cross Ref
- Eric Van Wyk, Lijesh Krishnan, August Schwerdfeger, and Derek Bodin. 2007. Attribute Grammar-based Language Extensions for Java. In Proceedings of the European Conference on Object Oriented Programming (ECOOP) (LNCS), Vol. 4609. Springer, 575–599. Google Scholar
Cross Ref
- Eric Van Wyk and August Schwerdfeger. 2007. Context-Aware Scanning for Parsing Extensible Languages. In Proceedings of the International Conference on Generative Programming and Component Engineering (GPCE ’07). ACM, 63–72. Google Scholar
Digital Library
- Eelco Visser. 2001. Stratego: A Language for Program Transformation based on Rewriting Strategies. System Description of Stratego 0.5. In Rewriting Techniques and Applications (RTA’01) (Lecture Notes in Computer Science), A. Middeldorp (Ed.), Vol. 2051. Springer-Verlag, 357–361. Google Scholar
Cross Ref
- Markus Voelter. 2011. Language and IDE development, modularization and composition with MPS. In Proceedings of the Generative and Transformational Techniques in Software Engineering (GTTSE ’11) (LNCS), Vol. 7680. Springer, 383–430. Google Scholar
Cross Ref
- Markus Voelter, Daniel Ratiu, Bernhard Schaetz, and Bernd Kolb. 2012. Mbeddr: An Extensible C-based Programming Language and IDE for Embedded Systems. In Proceedings of the 3rd Annual Conference on Systems, Programming, and Applications: Software for Humanity (SPLASH Wavefront ’12). ACM, New York, NY, USA, 121–140.Google Scholar
Digital Library
- H. Vogt, S. D. Swierstra, and M. F. Kuiper. 1989. Higher-order Attribute Grammars. In Proceedings of ACM Conference on Programming Language Design and Implementation (PLDI). ACM, 131–145. Google Scholar
Digital Library
- Phil Wadler. 1998. The expression problem. (December 1998). Discussion on the Java-Genericity mailing list, available at http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt .Google Scholar
- Yanlin Wang and Bruno C. d. S. Oliveira. 2016. The Expression Problem, Trivially!. In Proceedings of the 15th International Conference on Modularity (MODULARITY ’16). ACM, New York, NY, USA, 37–41. Google Scholar
Digital Library
- D. Weise and R. Crew. 1993. Programmable Syntax Macros. ACM SIGPLAN Notices 28, 6 (1993). Google Scholar
Digital Library
- Matthias Zenger and Martin Odersky. 2005. Independently extensible solutions to the expression problem. In Proceedings of the Workshop on Foundations of Object-Oriented Languages, FOOL ’12.Google Scholar
Index Terms
Reliable and automatic composition of language extensions to C: the ableC extensible language framework
Recommendations
Layout-sensitive language extensibility with SugarHaskell
Haskell '12: Proceedings of the 2012 Haskell SymposiumProgrammers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...
Layout-sensitive language extensibility with SugarHaskell
Haskell '12Programmers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...
Verifiable composition of deterministic grammars
PLDI '09There is an increasing interest in extensible languages,
(domain-specific) language extensions, and mechanisms for their specification and implementation. One challenge is to develop tools that allow non-expert programmers to add an eclectic set of ...






Comments