Upload
lukas-renggli
View
1.654
Download
0
Embed Size (px)
DESCRIPTION
As domain-specific modeling begins to attract widespread acceptance, pressure is increasing for the development of new domain-specific languages. Unfortunately these DSLs typically conflict with the grammar of the host language, making it difficult to compose hybrid code except at the level of strings; few mechanisms (if any) exist to control the scope of usage of multiple DSLs; and, most seriously, existing host language tools are typically unaware of the DSL extensions, thus hampering the development process. Language boxes address these issues by offering a simple, modular mechanism to encapsulate (i) compositional changes to the host language, (ii) transformations to address various concerns such as compilation and syntax highlighting, and (iii) scoping rules to control visibility of fine-grained language extensions. We describe the design and implementation of language boxes, and show with the help of several examples how modular extensions can be introduced to a host language and environment.
Citation preview
Language BoxesBending the Host Language
with Modular Language Changes
Lukas Renggli, Marcus Denker, Oscar Nierstrasz
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
§
§§
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
§
§§
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Host Environment
Host Environment
Tool Infrastructure
Editor
Compiler
Debugger
Syntax
Language 1
Language 2
Editor
Compiler
Debugger
Syntax
Language 1
Language 2
Editor
Compiler
Debugger
Syntax
Language 1
Language 2
Editor
Compiler
Debugger
Syntax
Language 1
Language 2
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Host Environment
Tool Infrastructure
Host Environment
Tool Infrastructure
Language Boxes
Language BoxModel
LanguageChange
LanguageConcern
LanguageScope
LanguageBox
*
*
*
*
IV + VII = XI
LanguageChange
LanguageConcern
LanguageScope
LanguageBox
*
*
*
*
Language Change
Insert FRAGMENT(before|after) PRODUCTION
as (choice|sequence|replacement)
Language Change
Insert RomanNumberbefore NumberLiteral
as a choice.
Language Change
Literal: BooleanLiteral
NilLiteral
NumberLiteral
StringLiteral
ArrayLiteral
NumberLiteral: IntegerLiteral
FloatLiteral
Language Change
'I' .. 'M'RomanNumber:
Language Change
Literal: BooleanLiteral
NilLiteral
NumberLiteral'
StringLiteral
ArrayLiteral
NumberLiteral': RomanNumber
NumberLiteral
Language Change
1st Class Grammar
Scannerless, Packrat
Language Concern
Production Action
Language Concern
Compiler
aToken value romanToArabic lift
Highlighting
aToken -> Color gray
Language Concern
Custom Actions
Language Concern
Language Scope
Active?
Language Scope
System
Language Scope
Packages
Language Scope
Classes
Language Scope
Methods
LanguageChange
LanguageConcern
LanguageScope
*
*
*
*
LanguageBox
Conflicts
LanguageBox 1
LanguageBox 2
LanguageBox 3
LanguageBox 4
LanguageBox 1
LanguageBox 2
LanguageBox 3
LanguageBox 4
LanguageBox 3
LanguageBox 3
LanguageBox 1
LanguageBox 2
LanguageBox 4
LanguageBox 3
LanguageBox 1
LanguageBox 2
LanguageBox 4
HostGrammar
LanguageBox 3
LanguageBox 1
LanguageBox 2
LanguageBox 4
HostGrammar
LanguageBox 3
LanguageBox 1
LanguageBox 2
LanguageBox 4
HostGrammar
LanguageBox 3
LanguageBox 1
LanguageBox 2
LanguageBox 4
HostGrammar'
HostGrammar'
might consist
of unused parts
HostGrammar'
might beambiguousmight consist
of unused parts
HostGrammar'
PackratParser
SELECT * FROM users
SELECT * FROM users<SQL: >
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
scg.unibe.ch/research/helvetia