<div dir="ltr"><div><div><div>Hi,<br><br></div>Some links to OTP stdlib modules which you might find useful:<br><br><a href="http://www.erlang.org/doc/man/erl_parse.html">http://www.erlang.org/doc/man/erl_parse.html</a><br>
<a href="http://www.erlang.org/doc/man/erl_scan.html">http://www.erlang.org/doc/man/erl_scan.html</a><br><a href="http://www.erlang.org/doc/man/erl_eval.html">http://www.erlang.org/doc/man/erl_eval.html</a><br><a href="http://erlang.org/doc/man/erl_syntax.html">http://erlang.org/doc/man/erl_syntax.html</a><br>
<br></div>Cheers,<br></div>Gustav<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 8, 2013 at 9:59 AM, Christopher Foley <span dir="ltr"><<a href="mailto:ccfoley@gmail.com" target="_blank">ccfoley@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
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.<br>
<br>
Sample DSL syntax; {createhandler, "TestHandler", {handles, [ {x,
{action, printToScreen}}, {y, {action, writeToStorage}} ]} }<br>
<br>
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.<br>
<br>
The steps I see are as follows:<br>
<ol>
<li>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?<br>
</li>
<li>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?</li>
<li>Once I have the code combined into one entity(representing a
module), then I can presumably use the compile module.</li>
</ol>
<p>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.<br>
</p>
<p>Chris.</p>
</div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>