I think this could take the same approach as Dart in dealing with embedded expressions - http://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/compiler/java/com/google/dart/compiler/parser/DartScanner.java?r=1805#898
Basically, the scanner returns token sequences like: "foo" => STRING(foo) "foo $bar baz" => STRING_SEGMENT(foo ) STRING_EMBED_EXPR_START IDENTIFIER(bar) STRING_EMBED_EXPR_END which the parser then handles normally, with rules like: string-expression : STRING | string-interpolation ; string-interpolation : ( STRING_SEGMENT? embedded-exp? )* STRING_LAST_SEGMENT ; // a simplification embedded-exp : STRING_EMBED_EXP_START expression STRING_EMBED_EXP_END ; I don't know if this would cause ambiguities in the JS grammar, or if it would have other issues applying it to quasis in JS, but it keeps a clean separation between the scanner and parser (it does require some additional state in the scanner, since these can be nested). -- John A. Tamplin Software Engineer (GWT), Google
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

