import {Parser} from "./state"

const pp = Parser.prototype

var STATE_KEYS = [
  "lastTokStartLoc",
  "lastTokEndLoc",
  "lastTokStart",
  "lastTokEnd",
  "lineStart",
  "startLoc",
  "endLoc",
  "start",
  "pos",
  "end",
  "type",
  "value"
];

pp.getState = function () {
  var state = {}
  for (var i = 0; i < STATE_KEYS.length; i++) {
    var key = STATE_KEYS[i]
    state[key] = this[key]
  }
  return state
};

pp.lookahead = function() {
  var old = this.getState();
  this.isLookahead = true
  this.next()
  this.isLookahead = false
  var curr = this.getState();
  for (var key in old) this[key] = old[key];
  return curr;
};

@@ -236,16 +236,80 @@
  %22value%22
+,%0A  %22exprAllowed%22,%0A  %22potentialArrowAt%22,%0A  %22currLine%22,%0A  %22input%22
 %0A%5D;%0A%0App.
@@ -457,16 +457,55 @@
 ey%5D%0A  %7D%0A
+  state.context = this.context.slice()%0A
   return

fix acorn hacky lookahead with token contexts - fixes #1349