Matt Might's MC Lexer is one example of a currying based DSL:
<
http://matt.might.net/articles/lexing-and-syntax-highlighting-in-javascript/
>
For example, to emulate what Lex provides:
// *state* (*regex*) (*action*) ;
<INIT> [_A-Za-z]+ { return(ID) ; }
<INIT> [0-9]+ { return(NUM) ; }
in JavaScript you'd do:
INIT (/[_A-Za-z]+/) (function () { return ID ; }) ;
INIT (/[0-9]+/) (function () { return NUM ; }) ;
or more modernly:
INIT (/[_A-Za-z]+/) (() => ID );
INIT (/[0-9]+/) (() => NUM ) ;
On Sat, Jan 13, 2018 at 8:31 PM, Isiah Meadows <[email protected]>
wrote:
>
> On Sat, Jan 13, 2018 at 9:54 AM, Claude Pache <[email protected]>
> wrote:
> >
> > [...]
> >
> > I think that the BC incompatibility issue is more than just a risk. I
> recall
> > (but I couldn’t find it) that someone gave the example of some library
> that
> > reads better when used as:
> >
> > ```js
> > foo
> > (bar)
> > (baz)
> > ```
>
> Do you have any ideas where I could look to potentially find it? I've
> never seen *that* kind of DSL before, and that's an interesting use
> case I haven't considered.
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss