The document discusses domain-specific languages (DSLs) and how the Xtext framework can be used to define and implement DSLs. It provides an example grammar for a simple DSL for modeling datatypes and entities. Xtext allows defining the grammar which is then used to generate a metamodel, parser, and other artifacts needed for the DSL.
3. Domain-Specific Language (DSL)
A DSL is a formal, processable language
targeting at a specific viewpoint or
aspect of a software system.
Wednesday, March 25, 2009
4. Domain-Specific Language (DSL)
A DSL is a formal, processable language
targeting at a specific viewpoint or
aspect of a software system.
It’s semantics, flexibility and notation is
designed in order to support working
with that viewpoint as good as possible.
Wednesday, March 25, 2009
5. Why DSLs?
• higher abstractions
• avoid redundancy
• separation of concerns
• use domain concepts
(Ubiquitous Language)
Wednesday, March 25, 2009
45. Based on
the grammar and Ecore models,
Xtext provides you with sensible
default implementations.
licensed by http://www.wordle.net/
Wednesday, March 25, 2009
62. Dependency Injection
with Google fGuice
‣No dependency to concrete implementation
Wednesday, March 25, 2009
63. Dependency Injection
with Google fGuice
‣No dependency to concrete implementation
‣No explicit construction
Wednesday, March 25, 2009
64. Dependency Injection
with Google fGuice
‣No dependency to concrete implementation
‣No explicit construction
‣Easy testing
Wednesday, March 25, 2009
65. Dependency Injection
with Google fGuice
‣No dependency to concrete implementation
‣No explicit construction
‣Easy testing
‣Easy composition
Wednesday, March 25, 2009
66. Configuration of
Components in Xtext
AbstractDeclarativeModule
DefaultRuntimeModule DefaultUIModule
From Xtext
Your Project
GeneratedRuntimeModule GeneratedUIModule
RuntimeModule UIModule
Wednesday, March 25, 2009
67. Configuration of
Components in Xtext
/**
* used to register components to be used within the IDE.
*/
public class DomainmodelUiModule
extends GeneratedDomainmodelUiModule {
@Override
public Class<? extends ILabelProvider> bindILabelProvider() {
return MySpecialLabelProvider.class;
}
}
Wednesday, March 25, 2009
68. and Equinox
Injector is created during Bundle.start(...)
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
INSTANCE = this;
injector = Guice.createInjector(
new DomainmodelRuntimeModule(),
new DomainmodelUiModule());
}
Wednesday, March 25, 2009
69. and Equinox
ExecutableExtensions are created via
IExecutableExtensionFactory
<extension
point=quot;org.eclipse.emf.ecore.extension_parserquot;>
<parser class=quot;my.pack.DomainmodelExecutableExtensionFactory:
org.eclipse.xtext.resource.XtextResourceFactoryquot;
type=quot;dmodelquot;>
</parser>
</extension>
Wednesday, March 25, 2009
70. Composable
Code Generator
‣ generator is composed of “fragments”
Wednesday, March 25, 2009
71. Composable
Code Generator
‣ generator is composed of “fragments”
‣ fragments can contribute to:
Wednesday, March 25, 2009
72. Composable
Code Generator
‣ generator is composed of “fragments”
‣ fragments can contribute to:
‣ Manifest.MF
Wednesday, March 25, 2009
73. Composable
Code Generator
‣ generator is composed of “fragments”
‣ fragments can contribute to:
‣ Manifest.MF
‣ plugin.xml
Wednesday, March 25, 2009
74. Composable
Code Generator
‣ generator is composed of “fragments”
‣ fragments can contribute to:
‣ Manifest.MF
‣ plugin.xml
‣ Guice modules
Wednesday, March 25, 2009
75. Composable
Code Generator
‣ generator is composed of “fragments”
‣ fragments can contribute to:
‣ Manifest.MF
‣ plugin.xml
‣ Guice modules
‣ Add your own fragments
Wednesday, March 25, 2009