Abstract
Embedded Domain Specific Languages make language design and implementation easier, because lexical and syntactical analysis and part of the semantic checks can be completed by the compiler of the host language.
On the other hand, by the nature of embedding, EDSL compilers have to work with a syntax tree that stores no information about the source file processed and the location of the program entities within the source file. This makes it hard to produce user-friendly error messages and connect the generated target code with the source code for debugging and profiling purposes.
This lecture note presents this problem in detail and shows possible solutions. The first, lightweight solution uses macro preprocessing. The second one is based on syntax tree transformations to add missing source-related information. This is more powerful, but also more heavyweight. The last technique avoids the problem by turning the embedded language implementation to a standalone one (with own parser) after the experimental phase of the language development process: It turns out that most of the embedded implementation can be reused in the standalone one.
Supported by EITKIC 12-1-2012-0001.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
In this project we have been using Subversion.
- 2.
Note that this project was entirely implemented in Haskell, which allows much more concise code than the mainstream imperative, object oriented languages.
- 3.
We have been using the Parsec parser combinator library [12] of Haskell. Using context free grammars instead would have resulted in similar code size.
- 4.
“Wadler’s Law: The emotional intensity of debate on a language feature increases as one moves down the following scale: Semantics, Syntax, Lexical syntax, Comments.” (Philiph Wadler in the Haskell mailing list, February 1992, see [18].).
References
cpphs: Haskell implementation of the C preprocessor. http://projects.haskell.org/cpphs/
Axelsson, E., Claessen, K., Dévai, G., Horváth, Z., Keijzer, K., Lyckegård, B., Persson, A., Sheeran, M., Svenningsson, J., Vajdax, A.: Feldspar: a domain specific language for digital signal processing algorithms. In: 2010 8th IEEE/ACM International Conference on Formal Methods and Models for Codesign (MEMOCODE), pp. 169–178. IEEE (2010)
Bierhoff, K., Liongosari, E.S., Swaminathan, K.S.: Incremental development of a domain-specific language that supports multiple application styles. In: OOPSLA 6th Workshop on Domain Specific Modeling, pp. 67–78 (2006)
Bravenboer, M., de Groot, R., Visser, E.: MetaBorg in action: examples of domain-specific language embedding and assimilation using stratego/XT. In: Lämmel, R., Saraiva, J., Visser, J. (eds.) GTTSE 2005. LNCS, vol. 4143, pp. 297–311. Springer, Heidelberg (2006)
Bravenboer, M., Visser, E.: Concrete syntax for objects: domain-specific language embedding and assimilation without restrictions. SIGPLAN Not. 39(10), 365–383 (2004)
Cleenewerck, T.: Component-based DSL development. In: Pfenning, F., Macko, M. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 245–264. Springer, Heidelberg (2003)
Dévai, G.: Embedding a proof system in haskell. In: Horváth, Z., Plasmeijer, R., Zsók, V. (eds.) CEFP 2009. LNCS, vol. 6299, pp. 354–371. Springer, Heidelberg (2010)
Dévai, G., Tejfel, M., Gera, Z., Páli, G., Gyula Nagy, Horváth, Z., Axelsson, E., Sheeran, M., Vajda, A., Lyckegård, B., et al.: Efficient code generation from the high-level domain-specific language feldspar for dsps. In: ODES-8: 8th Workshop on Optimizations for DSP and Embedded Systems (2010)
Dévai, G., Tejfel, M., Leskó, D.: Embedding and parsing combined for efficient language design (accepted for publication at icsoft-ea) (2013)
Elliott, C., Finne, S., De Moor, O.: Compiling embedded languages. J. Funct. Program. 13(3), 455–481 (2003)
Hudak, P.: Building domain-specific embedded languages. ACM Comput. Surv. 28(4es), 196 (1996)
Leijen, D., Meijer, E.: Parsec: direct style monadic parser combinators for the real world. Electron. Notes Theor. Comput. Sci. 41(1) (2001)
Miller, H., Burmako, E., Haller, P.: Reflection. http://docs.scala-lang.org/overviews/reflection/overview.html
Spinellis, D.: Notable design patterns for domain-specific languages. J. Syst. Softw. 56(1), 91–99 (2001)
Svensson, J.: Obsidian source code repository. https://github.com/svenssonjoel/Obsidian
Svensson, J., Sheeran, M., Claessen, K.: Obsidian: a domain specific embedded language for parallel programming of graphics processors. In: Scholz, S.-B., Chitil, O. (eds.) IFL 2008. LNCS, vol. 5836, pp. 156–173. Springer, Heidelberg (2011)
Tratt, L.: Domain specific language implementation via compile-time meta-programming. ACM Trans. Program. Lang. Syst. (TOPLAS) 30(6), 31 (2008)
Wadler, P.: Wadler’s “Law” on language design. Haskell mailing list (1992). http://code.haskell.org/~dons/haskell-1990-2000/msg00737.html
Wile, D.: Lessons learned from real dsl experiments. Sci. Comput. Program. 51(3), 265–290 (2004)
Zdun, U.: A dsl toolkit for deferring architectural decisions in dsl-based software design. Inf. Softw. Technol. 52(7), 733–748 (2010)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2015 Springer International Publishing Switzerland
About this chapter
Cite this chapter
Dévai, G., Leskó, D., Tejfel, M. (2015). The EDSL’s Struggle for Their Sources. In: Zsók, V., Horváth, Z., Csató, L. (eds) Central European Functional Programming School. CEFP 2013. Lecture Notes in Computer Science(), vol 8606. Springer, Cham. https://doi.org/10.1007/978-3-319-15940-9_7
Download citation
DOI: https://doi.org/10.1007/978-3-319-15940-9_7
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-15939-3
Online ISBN: 978-3-319-15940-9
eBook Packages: Computer ScienceComputer Science (R0)