DSL简介

 Overview of Domain-Specific Languag...

------------------------------MSDN路径 

 


 

DSL,直译过来就是“特定领域语言”,c++、C#是面向对象的,而DSL是面向问题域的。

  •  DSL可以做什么?         

用DSL,你可以定义自己的modeling language,例如你可以创建新的DSL来描述用户界面,商业进程,数据库,信息流等等,并用这种DSL来generate code

By using Domain-Specific Language Tools, you can design graphical languages and generate code and other text output from the domain-specific languages.

  • DSL如何generate code           

用DSL,你负责创建面向顾客的graphical designer(包含你自己的概念,就是说想法是顾客的,实现的概念定义是你的),这些designergenerate被用来产生种种的models;你负责创建custom text templates来使用这些models。

即顾客使用(models and templates),generate source code and other files

  • DSL Tools包括什么?DSL是由DSL Tools产生的(Hmm,妖是由妖他吗生的
    • A project wizard that creates a fully configured solution. In this solution, you can define a domain model (designer + text output generator). If you run a completed solution from inside Visual Studio, a test solution opens in a separate instance of Visual Studio so that you can test the designer and the text output generator.(靠,就是说编译后的Experimental Hive
    • A graphical designer for defining and editing domain models.
    • Designer definitions in XML. The code for implementing designers is generated from these definitions so that you can define a graphical designer hosted in Visual Studio without manually writing any code.(Designer就是XML,XML就是Designer
    • A set of code generators, which take a domain model definition and a designer definition as input and produce code that implements both of the components as output. The code generators also validate the domain model and the designer definition, and they raise errors and warnings accordingly.
    • A framework for defining text output generators. These template-based generators take data (models) that use a domain model as input and generate text output that is based on the template. Parameters in the template are substituted by using the results of running a Visual C# script that is embedded in the template.

The following illustration provides a high-level overview of how you design, customize, test, and deploy a domain-specific language.

DSL overview process 

  • 四个模板

To design a language, you begin by using the Domain-Specific Language Designer Wizard. For your convenience, the wizard provides the following solution templates:(耳熟能详

    • Task Flow Diagrams

    • Class Diagrams

    • Minimal Language

    • Component Diagrams

  • 两个Projects

Running the wizard, a Visual Studio solution is created, contains the following projects:

    • Dsl

                           The Dsl project defines the domain-specific language and its editing and processing tools.

    • DslPackage

                           The DslPackage project determines how the language tools integrate with Visual Studio.

  • 如何改变DSL

           因为solution里几乎所有的代码都是由language definition files创建, 目前就是*.flt. 因此改变这个文件,就改变了Language

           那些text templates (typically called *.tt), 是用来创建代码的。*.tt读取language definition产生code。因此一旦改变了Language definition files,你应该 transform all templates. For more information, see How to: Run Text Templates and How to: Generate Code from Text Templates.

           In many cases, you create code or other artifacts from your domain-specific language. You can build text templates in the debugging project, which read the model and generate files from it.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值