Abstract
Domain-Specific Languages (DSLs) are often classified into external and internal DSLs. An external DSL is a stand-alone language with its own parser. An internal DSL is an extension of an existing programming language, the host language, offering the user of the DSL domain-specific constructs as well as the constructs of the host language, thus providing a richer language than the DSL itself. In this paper we report on experiences implementing external as well as internal formal modeling DSLs with the Scala programming language, known in particular for its support for defining DSLs. The modeling languages include monitoring logics, a testing language, and a general purpose SysML inspired modeling language. We present a systematic overview of advantages and disadvantages of each option.
Part of the work was supported by the Japanese Society for the Promotion of Science (kaken-hi grants 23240003 and 26280019), and by NSF Grant CCF-0926190. Part of the work was carried out at Jet Propulsion Laboratory, California Institute of Technology, under a contract with the National Aeronautics and Space Administration.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
- 2.
A case class in Scala is like a class with the additional properties that it supports pattern matching over objects of the class, that the new keyword is not needed to create objects of the class, and equality is pre-defined based on the arguments.
- 3.
A trait in Scala is a module concept closely related to the notion of an abstract class, as for example found in Java. Traits, however, differ by allowing a more flexible way of composition called mixin composition, an alternative to multiple inheritance.
- 4.
The apply method in Scala has special interpretation: if an object O defines a such, it can be applied to a list of arguments using function application syntax: O(...), equivalent to calling the apply method: O.apply(...).
References
ANTLR: http://www.antlr.org
Artho, C.V., Biere, A., Hagiya, M., Platon, E., Seidl, M., Tanabe, Y., Yamamoto, M.: Modbat: A model-based API tester for event-driven systems. In: Bertacco, V., Legay, A. (eds.) HVC 2013. LNCS, vol. 8244, pp. 112–128. Springer, Heidelberg (2013)
Barringer, H., Groce, A., Havelund, K., Smith, M.: Formal analysis of log files. J. Aerosp. Comput. Inf. Commun. 7(11), 365–390 (2010)
Barringer, H., Havelund, K.: TraceContract: A scala DSL for trace analysis. In: Butler, M., Schulte, W. (eds.) FM 2011. LNCS, vol. 6664, pp. 57–72. Springer, Heidelberg (2011)
Barringer, H., Havelund, K., Kurklu, E., Morris, R.: Checking flight rules with TraceContract: Application of a Scala DSL for trace analysis. In: Scala Days 2011. Stanford University, California (2011)
Bodden, E.: MOPBox: A library approach to runtime verification. In: Khurshid, S., Sen, K. (eds.) RV 2011. LNCS, vol. 7186, pp. 365–369. Springer, Heidelberg (2012)
Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., Yergeau, F.: Extensible markup language (XML). World Wide Web Consortium Recommendation REC-xml-19980210 (1998)
Bruneton, E., Lenglet, R., Coupaye, T.: ASM: a code manipulation tool to implement adaptable systems. In: Adaptable and Extensible Component Systems, Grenoble, France (2002)
Forgy, C.: Rete: A fast algorithm for the many pattern/many object pattern match problem. Artif. Intell. 19, 17–37 (1982)
Fowler, M., Parsons, R.: Domain-Specific Languages. Addison-Wesley, Boston (2010)
Fusco, M.: Hammurabi–a Scala rule engine. In: Scala Days 2011. Stanford University, California (2011)
Gansner, E., North, S.: An open graph visualization system and its applications to software engineering. Softw. Pract. Exper. 30(11), 1203–1233 (2000)
GLL combinators: https://github.com/djspiewak/gll-combinators
Havelund, K.: Data automata in Scala. In: Leucker, M., Wang, J. (eds.) Proceedings of 8th International Symposium on Theoretical Aspects of Software Engineering (TASE 2014), Changsha, China. IEEE Computer Society Press (2014)
Havelund, K.: Monitoring with data automata. In: Margaria, T., Steffen, B. (eds.) ISoLA 2014, Part II. LNCS, vol. 8803, pp. 254–273. Springer, Heidelberg (2014)
Havelund, K.: Rule-based runtime verification revisited. Softw. Tools Technol. Transf. (STTT) 17(2), 143–170 (2015)
Havelund, K., Joshi, R.: Experience with rule-based analysis of spacecraft logs. In: Artho, C., Ölveczky, P.C. (eds.) FTSCS 2014. CCIS, vol. 476, pp. 1–16. Springer, Heidelberg (2015)
Hoare, C.: Communicating sequential processes. Commun. ACM 26(1), 100–106 (1983)
Jakob, F.: SugarScala: Syntactic extensibility for Scala. Master’s thesis, Technische Universität Darmstadt (2014)
Link, J., Fröhlich, P.: Unit Testing in Java: How Tests Drive the Code. Morgan Kaufmann Publishers Inc., Sebastopol (2003)
Mernik, M., Heering, J., Sloane, A.: When and how to develop domain-specific languages. ACM Comput. Surv. 37(4), 316–344 (2005)
Odersky, M., Spoon, L., Venners, B.: Programming in Scala: A Comprehensive Step-by-step Guide, 2nd edn. Artima Inc., USA (2010)
Parboiled: https://github.com/sirthias/parboiled2
Parser combinators: https://github.com/scala/scala-parser-combinators
Rompf, T., Amin, N., Moors, A., Haller, P., Odersky, M.: Scala-virtualized: linguistic reuse for deep embeddings. High. Order Symbolic Comput. 25, 1–43 (2013)
Scala: http://www.scala-lang.org
ScalaBison: https://github.com/djspiewak/scala-bison
Scala macros: http://scalamacros.org
Stolz, V., Huch, F.: Runtime verification of concurrent Haskell programs. In: Proceedings of the 4th International Workshop on Runtime Verification (RV 2004), ENTCS, vol. 113, pp. 201–216. Elsevier (2005)
Venners, B.: ScalaTest (2014). http://www.scalatest.org
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2015 Springer International Publishing Switzerland
About this paper
Cite this paper
Artho, C., Havelund, K., Kumar, R., Yamagata, Y. (2015). Domain-Specific Languages with Scala. In: Butler, M., Conchon, S., Zaïdi, F. (eds) Formal Methods and Software Engineering. ICFEM 2015. Lecture Notes in Computer Science(), vol 9407. Springer, Cham. https://doi.org/10.1007/978-3-319-25423-4_1
Download citation
DOI: https://doi.org/10.1007/978-3-319-25423-4_1
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-25422-7
Online ISBN: 978-3-319-25423-4
eBook Packages: Computer ScienceComputer Science (R0)