support let (#4227)

This commit is contained in:
Alex Lam S.L
2020-10-19 01:32:39 +01:00
committed by GitHub
parent 6c7226c10e
commit 96bf7fceab
10 changed files with 1186 additions and 152 deletions

View File

@@ -44,7 +44,7 @@
"use strict";
var KEYWORDS = "break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var void while with";
var KEYWORDS = "break case catch const continue debugger default delete do else finally for function if in instanceof let new return switch throw try typeof var void while with";
var KEYWORDS_ATOM = "false null true";
var RESERVED_WORDS = [
"abstract boolean byte char class double enum export extends final float goto implements import int interface let long native package private protected public short static super synchronized this throws transient volatile yield",
@@ -880,6 +880,12 @@ function parse($TEXT, options) {
next();
return if_();
case "let":
next();
var node = let_();
semicolon();
return node;
case "return":
if (S.in_function == 0 && !options.bare_returns)
croak("'return' outside of function");
@@ -1202,6 +1208,14 @@ function parse($TEXT, options) {
});
};
var let_ = function(no_in) {
return new AST_Let({
start : prev(),
definitions : vardefs(AST_SymbolLet, no_in),
end : prev()
});
};
var var_ = function(no_in) {
return new AST_Var({
start : prev(),