Skip to content

Commit

Permalink
Backport fixes from upstream
Browse files Browse the repository at this point in the history
These are fixes by Vasya-Chajko from
douglascrockford/TDOP#2
and
douglascrockford/TDOP#3
  • Loading branch information
cscott committed Feb 12, 2020
1 parent 1f7b8c5 commit 6304989
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ define(["text!parse.js", "tokenize"], function make_parse(parse_source, tokenize
advance(); advance(";");
}
this.second = statements();
scope.pop();
advance("}");
this.arity = "function";
scope.pop();
return this;
});

Expand Down Expand Up @@ -513,8 +513,8 @@ define(["text!parse.js", "tokenize"], function make_parse(parse_source, tokenize
// here: { var x; ... } -> (function() { var x; ... })();
//new_scope();//XXX
var a = statements();
advance("}");
//scope.pop();//XXX
advance("}");
// CSA: make block structure (scope) explicit in the parse tree
return [ { value: "block", arity: "statement", first: a } ];
});
Expand Down Expand Up @@ -603,6 +603,7 @@ define(["text!parse.js", "tokenize"], function make_parse(parse_source, tokenize
DEBUG = debug;
tokens = tokenize(source, '=<>!+-*&|/%^', '=<>&|');
token_nr = 0;
scope = null;
new_scope();
if (top_level) {
top_level = tokenize(top_level);
Expand Down Expand Up @@ -630,6 +631,7 @@ define(["text!parse.js", "tokenize"], function make_parse(parse_source, tokenize
if (state) {
scope = state.scope;
} else {
scope = null;
new_scope();
if (top_level) {
top_level = tokenize(top_level);
Expand Down

0 comments on commit 6304989

Please sign in to comment.