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?)
That's not a valid lexer grammar. The input
if
is now ambiguous -- it can lex as either a keyword or a QuasiMiddle. The input
3+`
will now lex as QuasiEnd, which may or may not be what you want.
Waldemar
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss