DSLs - Domain Specific Embedded Languages Beta Draft - Do...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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...
View Full Document

This note was uploaded on 08/08/2011 for the course CS 101 taught by Professor Jitenderkumarchhabra during the Summer '11 term at National Institute of Technology, Calicut.

Page1 / 56

DSLs - Domain Specific Embedded Languages Beta Draft - Do...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online