Search code examples
dslparsechaskell

How would you apply Parsec to generate code from a DSL?


I've read Chapter 16 of Real World Haskell on Parsec . The examples in this chapter show how to use Parsec to extract data structures out of strings.

I'm wondering how one would go about applying Parsec to create an imperative-style DSL, one that would take input written in a DSL and translate it into Haskell, SQL, or Ruby code that can be executed.

I'm sorry if this is a general question, but any leads or examples would be appreciated.


Solution

  • For help in parsing a minimal language, take a look at the Expr module.

    The Write a Scheme tutorial also demonstrates going from parsing to evaluating a language, via Parsec: http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours