Merge pull request #2087 from loganfsmyth/lookahead-state-fix

Ensure that the original state is restored on lookahead - fixes #2086
This commit is contained in:
Sebastian McKenzie 2015-07-27 04:59:58 +01:00
commit 64e7164b55
4 changed files with 195 additions and 1 deletions

View File

@ -91,7 +91,8 @@ export default class Tokenizer {
// TODO
lookahead() {
var old = this.state.clone();
var old = this.state;
this.state = old.clone();
this.next();
var curr = this.state.clone();
this.state = old;

View File

@ -0,0 +1,3 @@
@decorate((arg) => null)
class Ex {
}

View File

@ -0,0 +1,185 @@
{
"type": "File",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 25,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"decorators": [
{
"type": "Decorator",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"expression": {
"type": "CallExpression",
"start": 1,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 24
}
},
"callee": {
"type": "Identifier",
"start": 1,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 9
}
},
"name": "decorate"
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"start": 10,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 23
}
},
"id": null,
"generator": false,
"expression": true,
"params": [
{
"type": "Identifier",
"start": 11,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 14
}
},
"name": "arg"
}
],
"body": {
"type": "Literal",
"start": 19,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 23
}
},
"value": null,
"rawValue": null,
"raw": "null"
}
}
]
}
}
],
"id": {
"type": "Identifier",
"start": 31,
"end": 33,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 8
}
},
"name": "Ex"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 34,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 3,
"column": 1
}
},
"body": []
}
}
]
}
}

View File

@ -0,0 +1,5 @@
{
"features": {
"es7.decorators": true
}
}