Monday, November 14, 2011

what is a DSL?

I saw Jimmy Bogard and Pedro Reys of Headspring speak on DSL (Domain Specific Languages) tonight at the Austin .NET User's Group. A domain specific language is "a computer programming language of limited expressiveness focused on a particular domain." My notes:
  1. An internal DSL is written in an everyday language, let's assume C#, and is a constraint about the language to restrict it to domain-specific needs. Fluent NHibernate is an example of an internal DSL.
  2. An external DSL takes the shape of parsing code external to an everyday language, let's assume C#, which would then take action based upon the interpreted inbound data. NAnt is a good example of this. On the surface and in the strictest sense, it's just XML, but the various variations of XML nodes and tags hold functional meaning beyond what would be encompassed in a strict XML interpretation. In the case of NAnt, the markup is parsed and the parsing agent makes sense of the markup. "Regular" NHibernate is an example of an external DSL.
    1. One may write code for parsing on his/her own in C#.
    2. One may use a lexer/parser instead such as:
      1. yacc
      2. ANTLR
      3. Irony
        1. In writing Irony code in C#, one writes code that defines a parser that will parse flat files.
        2. Irony Grammar Explorer is a tool that allows one to test one's parser by inputting would-be text and seeing how the text ends up as:
          1. parse tree
          2. AST (Abstract Syntax Tree)

No comments:

Post a Comment