{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

DSLs - Domain Specific Embedded Languages Domain Specic...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Domain Specific Embedded Languages Beta Draft - Do not distribute © 2001, By Randall Hyde Page 1003 Domain Specifi c Embedded Languages Chapter Nine 9.1 Chapter Overview HLA s compile time language w as designed with one purpose in mind: to gi v e the HLA user the ability to change the syntax of the language in a user -defi ned manner . The compile-time language is actually so po werful that it lets you implement the syntax of other languages (not just an assembly language) within an HLA source fi le. This chapter discusses ho w to tak e this feature to an e xtreme and implement your o wn "mini-languages" within the HLA language. 9.2 Introduction to DSELs in HLA One of the most interesting features of the HLA language is its ability to support Domain Specifi c Embedded Langua g es (or DSELs, for short, which you pronounce "D-cells"). A domain specifi c language is a language designed with a specifi c purpose in mind. Applications written in an appropriate domains spe - cifi c language (DSL) are often much shorter and much easier to write than that same application written in a general purpose language (lik e C/C++, Ja v a, or P ascal). Unfortunately , writing a compiler for a DSL is con - siderable w ork. Since most DSLs are so specifi c that fe w programs are e v er written in them, it is generally cost-prohibiti v e to create a DSL for a gi v en application. This economic f act has led to the popularity of domain specifi c embedded languages. The dif ference between a DSL and a DSEL is the f act that you don’ t write a ne w compiler for DSEL; instead, you pro vide some tools for use by an e xisting language translator to let the user e xtend the language as necessary for the specifi c application. This allo ws the language designer to use the features of the e xisting (i.e., embedding ) language without ha ving to write the translator for these features in the DSEL. The HLA language incorporates lots of features that let you e xtend the lan - guage to handle your o wn particular needs. This section discusses ho w to use these features to e xtend HLA as you choose. As you probably suspect by no w , the HLA compile-time language is the principle tool at your disposal for creating DSELs. HLA s multi-part macros let you easily create high le v el language-lik e control struc - tures. If you need some ne w control structure that HLA does not directly support, it’ s generally an easy task to write a macro to implement that control structure. If you need something special, something that HLA s multi-part macros w on’ t directly support, then you can write code in the HLA compile-time language to pro - cess portions of your source fi le as though the y were simply string data. By using the compile-time string handling functions you can process the source code in just about an y w ay you can imagine. While man y such techniques are well be yond the scope of this te xt, it’ s reassuring to kno w that HLA can handle just about an ything you w ant to do, e v en once you become an adv
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern