ASI edits

Michael Haufe tno at thenewobjective.com
Sun Jan 14 21:46:11 UTC 2018


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 <isiahmeadows at gmail.com>
wrote:

>
> On Sat, Jan 13, 2018 at 9:54 AM, Claude Pache <claude.pache at gmail.com>
> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180114/3e98f6cb/attachment.html>


More information about the es-discuss mailing list