Browse Source

Add ES6 SingleLineHTMLOpenComment support ("<!--").

pull/1435/head
Michael Drake 8 years ago
parent
commit
77c0e6dd0e
  1. 16
      src-input/duk_lexer.c

16
src-input/duk_lexer.c

@ -1256,7 +1256,21 @@ void duk_lexer_parse_js_input_element(duk_lexer_ctx *lex_ctx,
advtok = DUK__ADVTOK(1, DUK_TOK_COMMA);
break;
case DUK_ASC_LANGLE: /* '<' */
if (DUK__L1() == DUK_ASC_LANGLE && DUK__L2() == DUK_ASC_EQUALS) {
if (DUK__L1() == DUK_ASC_EXCLAMATION && DUK__L2() == DUK_ASC_MINUS && DUK__L3() == DUK_ASC_MINUS) {
/*
* ES6: B.1.3, handle "<!--" SingleLineHTMLOpenComment
*/
/* DUK__ADVANCECHARS(lex_ctx, 4) would be correct here, but it is unnecessary */
for (;;) {
x = DUK__L0();
if (x < 0 || duk_unicode_is_line_terminator(x)) {
break;
}
DUK__ADVANCECHARS(lex_ctx, 1);
}
goto restart; /* line terminator will be handled on next round */
} else if (DUK__L1() == DUK_ASC_LANGLE && DUK__L2() == DUK_ASC_EQUALS) {
advtok = DUK__ADVTOK(3, DUK_TOK_ALSHIFT_EQ);
} else if (DUK__L1() == DUK_ASC_EQUALS) {
advtok = DUK__ADVTOK(2, DUK_TOK_LE);

Loading…
Cancel
Save