18

I have a course in which the proffesor has asked us to create a DSL for a our final project. He presented us in the first courses xText with Eclipse. This being a new course, I am still a bit fuzzy on what Domain Specific Languages means.

This is my current understanding: a domain specific language is a language that is created for specific problems in software development. Examples of DSL's are PHP, SQL, JavaScript and on the opposite are languages like Java , C# , C++ , Ruby etc.

Please feel free to correct me if I am wrong.

What I would like to know: is there is any tool for .NET/Visual Studio that is similar to Xtext, that allows me to define a grammar and be allowed to generate a programming language based on that with an activity diagram?

2
  • 6
    PHP and Javascript are not really DSL's. A DSL is a language that addresses a particular problem domain, like medical services. SQL is a DSL because it is specific to the problem domain of working with relational data sets. See en.wikipedia.org/wiki/Domain-specific_language for more information. Oct 15, 2012 at 19:29
  • Nemerle maybe ?
    – cnd
    Oct 16, 2012 at 9:01

5 Answers 5

11

The easiest way to go is a fluent interface. This requires no tools at all, and gives you great IntelliSense support, but you still have to write things in a .NET-kinda way, such as

 Mix.Paint(Color.Green).With.Paint(Color.Red);

Alternatively, you can write beautiful DSLs in Boo. There is an entire book on that subject.

1
10

You can try ANTLR (or ANother Tool for Language Recognition) a parser generator that is among others available for dotnet. In the community you can find definitions for sql, c# and many other languages.

According to google there is also ide support:

1
  • Update: ANTLR4 only emits Java, while ANTLR3 still supports C#, but it won't see any major update. Jan 26, 2015 at 22:17
3

Your first question - what is a domain specific language... because this is too big to fit in a comment.

A domain specific language is a language that is designed to work within a particular problem domain. For example, within the Unreal engine (used for first person shooters), there is a domain specific language called UnrealScript that allows one to modify the behavior of the Unreal engine. This language is designed for solving general problems but rather is constrained to its specific domain. Redcode (for corewars) would be another domain specific language. The language within Context Free Art is specific to its domain.

The idea is that with a domain specific language, one could create a DSL that closely maps the problem at hand. At this point, it is easier to program in the DLS than it is to program in a general language even with the added libraries to handle the problem domain.


As for your second question - the tools in C#... I don't know C# and thus don't know the tools that well. That said, back when I was taking a compiler class in college two of the tools that were used (and I have since used) are lex and yacc. Over at Stack Overflow... Lex/Yacc for C#?

2

There is a Visualization and Modeling SDK for Visual Studio which supports Text Templating (T4 templates) and Domain-Specific Languages.

http://msdn.microsoft.com/en-us/library/dd820703.aspx

1

This site may be interesting for you: http://nemerle.org . It's language for .net platform with rich metaprogramming features. More recently, the project is under the wing of the JetBrains: http://blogs.jetbrains.com/dotnet/2012/06/jetbrains-and-nemerle/ .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.