On Thu, Feb 2, 2012 at 11:27 AM, Waldemar Horwat <[email protected]>wrote:
> On 02/02/2012 11:03 AM, Mark S. Miller wrote: > > On Thu, Feb 2, 2012 at 5:09 AM, Douglas Crockford > <[email protected]<mailto: >> [email protected]>**> wrote: >> >> On 11:59 AM, Waldemar Horwat wrote: >> >> On 02/01/2012 11:35 AM, Allen Wirfs-Brock wrote: >> Here's one which I couldn't express in a lexer grammar: How to >> restart >> the quasi after an included expression is over. >> >> >> If quasis are not nested, then the lexical rule is really simple: Just >> match the `s, and within the literal, match the {}s. >> >> I would prefer to keep it simple, unless there is a compelling >> requirement to provide nesting. If we do the simple version now, we could >> allow the nested case in the future. >> >> >> When we came up with this "simplification", I thought I could live with >> it. Now, having tried to write some examples within these restrictions, I >> find it unusable. >> >> I think we're overestimating the parsing difficulty. I'll let Mike speak >> for the real plan. But I'd like to explain what I do in E, so that we can >> see that none of this need be complicated. It does involve an interaction >> between the parsing and lexing levels, but much less complex than you may >> expect, and comparable (IMO less) than the existing unclean interaction >> that JS already has: >> >> Lexing grammar has four new token types. >> >> QuasiOnly :: >> >> ` QuasiChar* ` >> >> QuasiOpen :: >> >> ` QuasiChar* $ >> >> QuasiMiddle :: >> >> QuasiChar* >> >> QuasiEnd :: >> >> QuasiChar ` >> > (presumably you forgot a * in QuasiEnd?) > y. I also messed up one more thing: QuasiMiddle :: QuasiChar* $ Sorry for the confusion. > That's not a valid lexer grammar. I didn't explain well enough. QuasiMiddle and QuasiEnd apply only after a quasiHole, and they apply immediately after a quasiHole. That's the complexity I was referring to: it introduces yet another lexing context, and the determination about whether we're in that lexing context demands counting curlies -- which a regular expression can't do. > The input > > if > > is now ambiguous -- it can lex as either a keyword or a QuasiMiddle. If it occurs immediately after a quasiHole, then it is a QuasiMiddle or QuasiEnd, depending on whether it is terminated by a $ or `. (See correction above). > The input > > 3+` > > will now lex as QuasiEnd, which may or may not be what you want. Only if after a quasiHole. > > > Waldemar > -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

