| | |
| | | |
| | | "use strict"; |
| | | |
| | | var KEYWORDS = "break case catch class const continue debugger default delete do else extends finally for function if in instanceof let new return switch throw try typeof var void while with"; |
| | | var KEYWORDS = "break case catch class const continue debugger default delete do else extends finally for function if in instanceof new return switch throw try typeof var void while with"; |
| | | var KEYWORDS_ATOM = "false null true"; |
| | | var RESERVED_WORDS = [ |
| | | "abstract async await boolean byte char double enum export final float goto implements import int interface long native package private protected public short static super synchronized this throws transient volatile yield", |
| | | "abstract async await boolean byte char double enum export final float goto implements import int interface let long native package private protected public short static super synchronized this throws transient volatile yield", |
| | | KEYWORDS_ATOM, |
| | | KEYWORDS, |
| | | ].join(" "); |
| | |
| | | read_template : with_eof_error("Unterminated template literal", function(strings) { |
| | | var s = ""; |
| | | for (;;) { |
| | | var ch = next(true, true); |
| | | var ch = read(); |
| | | switch (ch) { |
| | | case "\\": |
| | | ch += next(true, true); |
| | | ch += read(); |
| | | break; |
| | | case "`": |
| | | strings.push(s); |
| | |
| | | } |
| | | } |
| | | s += ch; |
| | | } |
| | | |
| | | function read() { |
| | | var ch = next(true, true); |
| | | return ch == "\r" ? "\n" : ch; |
| | | } |
| | | }), |
| | | }; |
| | |
| | | next(); |
| | | return import_(); |
| | | } |
| | | break; |
| | | case "let": |
| | | if (is_vardefs()) { |
| | | next(); |
| | | var node = let_(); |
| | | semicolon(); |
| | | return node; |
| | | } |
| | | break; |
| | | case "yield": |
| | | if (S.in_generator) return simple_statement(); |
| | | break; |
| | |
| | | case "if": |
| | | next(); |
| | | return if_(); |
| | | |
| | | case "let": |
| | | next(); |
| | | var node = let_(); |
| | | semicolon(); |
| | | return node; |
| | | |
| | | case "return": |
| | | if (S.in_function == 0 && !options.bare_returns) |
| | |
| | | } |
| | | |
| | | function for_() { |
| | | var await = is("name", "await") && next(); |
| | | var await_token = is("name", "await") && next(); |
| | | expect("("); |
| | | var init = null; |
| | | if (await || !is("punc", ";")) { |
| | | if (await_token || !is("punc", ";")) { |
| | | init = is("keyword", "const") |
| | | ? (next(), const_(true)) |
| | | : is("keyword", "let") |
| | | : is("name", "let") && is_vardefs() |
| | | ? (next(), let_(true)) |
| | | : is("keyword", "var") |
| | | ? (next(), var_(true)) |
| | | : expression(true); |
| | | var ctor; |
| | | if (await) { |
| | | if (await_token) { |
| | | expect_token("name", "of"); |
| | | ctor = AST_ForAwaitOf; |
| | | } else if (is("operator", "in")) { |
| | |
| | | } |
| | | if (node instanceof AST_SymbolFunarg) return node; |
| | | if (node instanceof AST_SymbolRef) return new AST_SymbolFunarg(node); |
| | | if (node instanceof AST_Yield) return new AST_SymbolFunarg({ |
| | | start: node.start, |
| | | name: "yield", |
| | | end: node.end, |
| | | }); |
| | | token_error(node.start, "Invalid arrow parameter"); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | var export_decl = embed_tokens(function() { |
| | | if (is("name", "async")) { |
| | | if (is("name")) switch (S.token.value) { |
| | | case "async": |
| | | next(); |
| | | expect_token("keyword", "function"); |
| | | if (!is("operator", "*")) return function_(AST_AsyncDefun); |
| | | next(); |
| | | return function_(AST_AsyncGeneratorDefun); |
| | | case "let": |
| | | next(); |
| | | var node = let_(); |
| | | semicolon(); |
| | | return node; |
| | | } else if (is("keyword")) switch (S.token.value) { |
| | | case "class": |
| | | next(); |
| | |
| | | if (!is("operator", "*")) return function_(AST_Defun); |
| | | next(); |
| | | return function_(AST_GeneratorDefun); |
| | | case "let": |
| | | next(); |
| | | var node = let_(); |
| | | semicolon(); |
| | | return node; |
| | | case "var": |
| | | next(); |
| | | var node = var_(); |
| | |
| | | next(); |
| | | } |
| | | return a; |
| | | } |
| | | |
| | | function is_vardefs() { |
| | | var token = peek(); |
| | | return is_token(token, "name") || is_token(token, "punc", "[") || is_token(token, "punc", "{"); |
| | | } |
| | | |
| | | var const_ = function(no_in) { |
| | |
| | | } |
| | | |
| | | function strict_verify_symbol(sym) { |
| | | if (sym.name == "arguments" || sym.name == "eval") |
| | | if (sym.name == "arguments" || sym.name == "eval" || sym.name == "let") |
| | | token_error(sym.start, "Unexpected " + sym.name + " in strict mode"); |
| | | } |
| | | |
| | |
| | | var comments = start.comments_before; |
| | | var i = HOP(start, "comments_before_length") ? start.comments_before_length : comments.length; |
| | | while (--i >= 0) { |
| | | var match = /[@#]__PURE__/.exec(comments[i].value); |
| | | if (match) { |
| | | expr.pure = match[0]; |
| | | if (/[@#]__PURE__/.test(comments[i].value)) { |
| | | expr.pure = true; |
| | | break; |
| | | } |
| | | } |