Don't allow escaped surrogated identifiers + introduce ascii_identifiers

Don't use 2 characters for surrogates in identifiers because there is
support for the \u{} syntax when escaped identifiers were introduced.

Also catch eof errors while reading identifier names

Introduce ascii_identifiers:

By setting ascii_identifiers to undefined (default value),
ascii_identifiers will print identifiers using the same setting as
ascii_only within the limits of the ecmascript 6 grammar.

ascii_identifiers accept true and false, allowing identifiers to be
printed under different settings than strings with the ascii_only setting.
This commit is contained in:
Anthony Van de Gejuchte
2016-07-22 17:33:24 +02:00
committed by Richard van Velzen
parent 110a1ac885
commit 27d3669800
5 changed files with 73 additions and 9 deletions

View File

@@ -551,7 +551,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
return next_token;
});
function read_name() {
var read_name = with_eof_error("SyntaxError: Unterminated identifier name", function() {
var name = "", ch, escaped = false, hex;
var read_escaped_identifier_char = function() {
escaped = true;
@@ -593,7 +593,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
parse_error("SyntaxError: Escaped characters are not allowed in keywords");
}
return name;
};
});
var read_regexp = with_eof_error("SyntaxError: Unterminated regular expression", function(regexp){
var prev_backslash = false, ch, in_class = false;