|
|
@ -8,6 +8,7 @@ function hex( ch ) {
|
|
|
|
|
|
|
|
|
|
|
|
// JavaScript code generation helpers.
|
|
|
|
// JavaScript code generation helpers.
|
|
|
|
const js = {
|
|
|
|
const js = {
|
|
|
|
|
|
|
|
|
|
|
|
stringEscape( s ) {
|
|
|
|
stringEscape( s ) {
|
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string
|
|
|
|
// ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string
|
|
|
@ -56,7 +57,64 @@ const js = {
|
|
|
|
.replace( /[\u0100-\u0FFF]/g, ch => "\\u0" + hex( ch ) )
|
|
|
|
.replace( /[\u0100-\u0FFF]/g, ch => "\\u0" + hex( ch ) )
|
|
|
|
.replace( /[\u1000-\uFFFF]/g, ch => "\\u" + hex( ch ) );
|
|
|
|
.replace( /[\u1000-\uFFFF]/g, ch => "\\u" + hex( ch ) );
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This is a list of reserved words for ESMA-262, 5th ed., 7.6.1 (strict mode)
|
|
|
|
|
|
|
|
reservedWords: [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Keyword
|
|
|
|
|
|
|
|
"break",
|
|
|
|
|
|
|
|
"case",
|
|
|
|
|
|
|
|
"catch",
|
|
|
|
|
|
|
|
"continue",
|
|
|
|
|
|
|
|
"debugger",
|
|
|
|
|
|
|
|
"default",
|
|
|
|
|
|
|
|
"delete",
|
|
|
|
|
|
|
|
"do",
|
|
|
|
|
|
|
|
"else",
|
|
|
|
|
|
|
|
"finally",
|
|
|
|
|
|
|
|
"for",
|
|
|
|
|
|
|
|
"function",
|
|
|
|
|
|
|
|
"if",
|
|
|
|
|
|
|
|
"in",
|
|
|
|
|
|
|
|
"instanceof",
|
|
|
|
|
|
|
|
"new",
|
|
|
|
|
|
|
|
"return",
|
|
|
|
|
|
|
|
"switch",
|
|
|
|
|
|
|
|
"this",
|
|
|
|
|
|
|
|
"throw",
|
|
|
|
|
|
|
|
"try",
|
|
|
|
|
|
|
|
"typeof",
|
|
|
|
|
|
|
|
"var",
|
|
|
|
|
|
|
|
"void",
|
|
|
|
|
|
|
|
"while",
|
|
|
|
|
|
|
|
"with",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FutureReservedWord
|
|
|
|
|
|
|
|
"class",
|
|
|
|
|
|
|
|
"const",
|
|
|
|
|
|
|
|
"enum",
|
|
|
|
|
|
|
|
"export",
|
|
|
|
|
|
|
|
"extends",
|
|
|
|
|
|
|
|
"implements",
|
|
|
|
|
|
|
|
"import",
|
|
|
|
|
|
|
|
"interface",
|
|
|
|
|
|
|
|
"let",
|
|
|
|
|
|
|
|
"package",
|
|
|
|
|
|
|
|
"private",
|
|
|
|
|
|
|
|
"protected",
|
|
|
|
|
|
|
|
"public",
|
|
|
|
|
|
|
|
"static",
|
|
|
|
|
|
|
|
"super",
|
|
|
|
|
|
|
|
"yield",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Literal
|
|
|
|
|
|
|
|
"false",
|
|
|
|
|
|
|
|
"null",
|
|
|
|
|
|
|
|
"true",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = js;
|
|
|
|
module.exports = js;
|
|
|
|