<div dir="ltr"><div>Matt Might's MC Lexer is one example of a currying based DSL:<br><br><<a href="http://matt.might.net/articles/lexing-and-syntax-highlighting-in-javascript/">http://matt.might.net/articles/lexing-and-syntax-highlighting-in-javascript/</a>><br><br></div>For example, to emulate what Lex provides:<br><br>// <code><i>state</i> (<i>regex</i>) (<i>action</i>) ;</code><pre><INIT>   [_A-Za-z]+    { return(ID) ; }
<INIT>   [0-9]+        { return(NUM) ; } <br><br></pre><pre>in JavaScript you'd do:<br><br><span class="gmail-jsidentifier">INIT</span>    <span class="gmail-jspunctuation">(</span><span class="gmail-jsregexp">/[_A-Za-z]+/</span><span class="gmail-jspunctuation">)</span>    <span class="gmail-jspunctuation">(</span><span class="gmail-jskeyword">function</span> <span class="gmail-jspunctuation">(</span><span class="gmail-jspunctuation">)</span> <span class="gmail-jspunctuation">{</span> <span class="gmail-jskeyword">return</span> <span class="gmail-jsidentifier">ID</span> <span class="gmail-jspunctuation">;</span> <span class="gmail-jspunctuation">}</span><span class="gmail-jspunctuation">)</span> <span class="gmail-jspunctuation">;</span><br><span class="gmail-jsidentifier">INIT</span>    <span class="gmail-jspunctuation">(</span><span class="gmail-jsregexp">/[0-9]+/</span><span class="gmail-jspunctuation">)</span>        <span class="gmail-jspunctuation">(</span><span class="gmail-jskeyword">function</span> <span class="gmail-jspunctuation">(</span><span class="gmail-jspunctuation">)</span> <span class="gmail-jspunctuation">{</span> <span class="gmail-jskeyword">return</span> <span class="gmail-jsidentifier">NUM</span> <span class="gmail-jspunctuation">;</span> <span class="gmail-jspunctuation">}</span><span class="gmail-jspunctuation">)</span> <span class="gmail-jspunctuation">;</span></pre><div><div><div class="gmail_extra"><br></div><div class="gmail_extra">or more modernly:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><pre id="gmail-mclexer-rules-example" class="gmail-code-snippet"><span class="gmail-jsidentifier">INIT</span>    <span class="gmail-jspunctuation">(</span><span class="gmail-jsregexp">/[_A-Za-z]+/</span><span class="gmail-jspunctuation">)</span>    <span class="gmail-jspunctuation">(</span><span class="gmail-jspunctuation">(</span><span class="gmail-jspunctuation">) =></span> <span class="gmail-jsidentifier">ID</span><span class="gmail-jspunctuation"></span><span class="gmail-jspunctuation"> )</span><span class="gmail-jspunctuation">;</span><br><span class="gmail-jsidentifier">INIT</span>    <span class="gmail-jspunctuation">(</span><span class="gmail-jsregexp">/[0-9]+/</span><span class="gmail-jspunctuation">)</span>        <span class="gmail-jspunctuation">((</span><span class="gmail-jspunctuation"></span><span class="gmail-jspunctuation">) =></span> <span class="gmail-jsidentifier">NUM</span> <span class="gmail-jspunctuation"></span><span class="gmail-jspunctuation">)</span> <span class="gmail-jspunctuation">;</span></pre></div><div class="gmail_extra"><br></div><div class="gmail_extra"></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 13, 2018 at 8:31 PM, Isiah Meadows <span dir="ltr"><<a href="mailto:isiahmeadows@gmail.com" target="_blank">isiahmeadows@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On Sat, Jan 13, 2018 at 9:54 AM, Claude Pache <<a href="mailto:claude.pache@gmail.com">claude.pache@gmail.com</a>> wrote:<br>
><br>
> [...]<br>
><br>
> I think that the BC incompatibility issue is more than just a risk. I recall<br>
> (but I couldn’t find it) that someone gave the example of some library that<br>
> reads better when used as:<br>
><br>
> ```js<br>
> foo<br>
>   (bar)<br>
>   (baz)<br>
> ```<br>
<br>
Do you have any ideas where I could look to potentially find it? I've<br>
never seen *that* kind of DSL before, and that's an interesting use<br>
case I haven't considered.<br>
<br>
</blockquote></div><br></div></div></div></div>