[erlang-questions] Writing a DSL in ERlang

Gustav Simonsson <>
Fri Feb 8 10:54:40 CET 2013


Hi,

Some links to OTP stdlib modules which you might find useful:

http://www.erlang.org/doc/man/erl_parse.html
http://www.erlang.org/doc/man/erl_scan.html
http://www.erlang.org/doc/man/erl_eval.html
http://erlang.org/doc/man/erl_syntax.html

Cheers,
Gustav


On Fri, Feb 8, 2013 at 9:59 AM, Christopher Foley <> wrote:

>  Hi,
>
> I'm am interested in creating an external DSL with Erlang and what are the
> steps involved. So very basically I want to convert some English like
> language into running erlang code. My goal is to build up a full erlang
> source file relative to the dsl file I have as input. I don't necessarily
> need to print out the source file to the file system, holding it in memory
> is sufficient and allowing its execution.
>
> Sample DSL syntax; {createhandler, "TestHandler", {handles, [ {x, {action,
> printToScreen}}, {y, {action, writeToStorage}} ]} }
>
> So from above I want to create a gen_event handler with a handle_event
> function which pattern matches on 'x' and 'y' and performs the actions
> defined. I have used this to just show what I would like to do, what I'm
> interested in is the steps and approaches to doing this.
>
> The steps I see are as follows:
>
>    1. Parse the dsl text file, create different tokens. I presume that I
>    have to write my own parser as its dependent on the structure of the dsl
>    language itself?
>     2. Match these tokens to chunks of erlang code, is this correct? What
>    is best approach here; create a 'fun' for each chunk of code. How would I
>    then simply put these funs together to represent the overall module?
>    3. Once I have the code combined into one entity(representing a
>    module), then I can presumably use the compile module.
>
> I am only coming back to writing erlang (ten years since I coded in
> erlang), so apologies if questions are fairly basic. Any info appreciated.
>
> Chris.
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130208/ec3be34b/attachment.html>


More information about the erlang-questions mailing list