Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 242300 Details for
Bug 432956
[esprima] Program beginning with invalid Variable Declaration should parse
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
fix
esprima++.patch (text/plain), 511.86 KB, created by
Michael Rennie
on 2014-04-24 16:56:39 EDT
(
hide
)
Description:
fix
Filename:
MIME Type:
Creator:
Michael Rennie
Created:
2014-04-24 16:56:39 EDT
Size:
511.86 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js b/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js >index 6244bd2..cedc541 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js >@@ -1,12 +1,7 @@ > /* >- >- Original copyright is below. This is version git tag: 310927be9f. >- Further modifications: >- Author: Andy Clement (VMware) - recovery support >- >- >- Original copyright: >- >+ Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com> >+ Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com> >+ Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be> > Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com> > Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be> > Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl> >@@ -37,31 +32,48 @@ > */ > > /*jslint bitwise:true plusplus:true */ >-/*global esprima:true, exports:true, >-throwError: true, createLiteral: true, generateStatement: true, >+/*global esprima:true, define:true, exports:true, window: true, >+createLocationMarker: true, >+throwError: true, generateStatement: true, peek: true, > parseAssignmentExpression: true, parseBlock: true, >-expectCloseBracketWrapThrow: true, parseExpression: true, >+expectConditionCloseBracketWrapThrow: true, parseExpression: true, > parseFunctionDeclaration: true, parseFunctionExpression: true, > parseFunctionSourceElements: true, parseVariableIdentifier: true, > parseLeftHandSideExpression: true, >+parseUnaryExpression: true, > parseStatement: true, parseSourceElement: true */ > >-(function (exports) { >+(function (root, factory) { >+ 'use strict'; >+ >+ // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, >+ // Rhino, and plain browser loading. >+ if (typeof define === 'function' && define.amd) { >+ define(['exports'], factory); >+ } else if (typeof exports !== 'undefined') { >+ factory(exports); >+ } else { >+ factory((root.esprima = {})); >+ } >+}(this, function (exports) { > 'use strict'; > > var Token, > TokenName, >+ FnExprTokens, > Syntax, > PropertyKind, > Messages, > Regex, >+ SyntaxTreeDelegate, > source, > strict, > index, > lineNumber, > lineStart, > length, >- buffer, >+ delegate, >+ lookahead, > state, > extra; > >@@ -73,7 +85,8 @@ > NullLiteral: 5, > NumericLiteral: 6, > Punctuator: 7, >- StringLiteral: 8 >+ StringLiteral: 8, >+ RegularExpression: 9 > }; > > TokenName = {}; >@@ -85,6 +98,18 @@ > TokenName[Token.NumericLiteral] = 'Numeric'; > TokenName[Token.Punctuator] = 'Punctuator'; > TokenName[Token.StringLiteral] = 'String'; >+ TokenName[Token.RegularExpression] = 'RegularExpression'; >+ >+ // A function following one of those tokens is an expression. >+ FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', >+ 'return', 'case', 'delete', 'throw', 'void', >+ // assignment operators >+ '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', >+ '&=', '|=', '^=', ',', >+ // binary/unary operators >+ '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', >+ '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', >+ '<=', '<', '>', '!=', '!==']; > > Syntax = { > AssignmentExpression: 'AssignmentExpression', >@@ -148,6 +173,7 @@ > UnterminatedRegExp: 'Invalid regular expression: missing /', > InvalidLHSInAssignment: 'Invalid left-hand side in assignment', > InvalidLHSInForIn: 'Invalid left-hand side in for-in', >+ MultipleDefaultsInSwitch: 'More than one default clause in switch statement', > NoCatchOrFinally: 'Missing catch or finally after try', > UnknownLabel: 'Undefined label \'%0\'', > Redeclaration: '%0 \'%1\' has already been declared', >@@ -168,13 +194,15 @@ > StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', > StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', > StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', >- StrictReservedWord: 'Use of future reserved word in strict mode' >+ StrictReservedWord: 'Use of future reserved word in strict mode', >+ //mrennie https://bugs.eclipse.org/bugs/show_bug.cgi?id=432956 >+ MissingToken: 'Missing expected \'%0\'' > }; > > // See also tools/generate-unicode-regex.py. > Regex = { >- NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'), >- NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]') >+ NonAsciiIdentifierStart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]'), >+ NonAsciiIdentifierPart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]') > }; > > // Ensure the condition is true, otherwise throw an error. >@@ -188,18 +216,8 @@ > } > } > >- function sliceSource(from, to) { >- return source.slice(from, to); >- } >- >- if (typeof 'esprima'[0] === 'undefined') { >- sliceSource = function sliceArraySource(from, to) { >- return source.slice(from, to).join(''); >- }; >- } >- > function isDecimalDigit(ch) { >- return '0123456789'.indexOf(ch) >= 0; >+ return (ch >= 48 && ch <= 57); // 0..9 > } > > function isHexDigit(ch) { >@@ -214,39 +232,39 @@ > // 7.2 White Space > > function isWhiteSpace(ch) { >- return (ch === ' ') || (ch === '\u0009') || (ch === '\u000B') || >- (ch === '\u000C') || (ch === '\u00A0') || >- (ch.charCodeAt(0) >= 0x1680 && >- '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(ch) >= 0); >+ return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || >+ (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0); > } > > // 7.3 Line Terminators > > function isLineTerminator(ch) { >- return (ch === '\n' || ch === '\r' || ch === '\u2028' || ch === '\u2029'); >+ return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); > } > > // 7.6 Identifier Names and Identifiers > > function isIdentifierStart(ch) { >- return (ch === '$') || (ch === '_') || (ch === '\\') || >- (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || >- ((ch.charCodeAt(0) >= 0x80) && Regex.NonAsciiIdentifierStart.test(ch)); >+ return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) >+ (ch >= 65 && ch <= 90) || // A..Z >+ (ch >= 97 && ch <= 122) || // a..z >+ (ch === 92) || // \ (backslash) >+ ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); > } > > function isIdentifierPart(ch) { >- return (ch === '$') || (ch === '_') || (ch === '\\') || >- (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || >- ((ch >= '0') && (ch <= '9')) || >- ((ch.charCodeAt(0) >= 0x80) && Regex.NonAsciiIdentifierPart.test(ch)); >+ return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) >+ (ch >= 65 && ch <= 90) || // A..Z >+ (ch >= 97 && ch <= 122) || // a..z >+ (ch >= 48 && ch <= 57) || // 0..9 >+ (ch === 92) || // \ (backslash) >+ ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); > } > > // 7.6.1.2 Future Reserved Words > > function isFutureReservedWord(id) { > switch (id) { >- >- // Future reserved words. > case 'class': > case 'enum': > case 'export': >@@ -254,15 +272,13 @@ > case 'import': > case 'super': > return true; >+ default: >+ return false; > } >- >- return false; > } > > function isStrictModeReservedWord(id) { > switch (id) { >- >- // Strict Mode reserved words. > case 'implements': > case 'interface': > case 'package': >@@ -273,9 +289,9 @@ > case 'yield': > case 'let': > return true; >+ default: >+ return false; > } >- >- return false; > } > > function isRestrictedWord(id) { >@@ -285,167 +301,221 @@ > // 7.6.1.1 Keywords > > function isKeyword(id) { >- var keyword = false; >- switch (id.length) { >- case 2: >- keyword = (id === 'if') || (id === 'in') || (id === 'do'); >- break; >- case 3: >- keyword = (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); >- break; >- case 4: >- keyword = (id === 'this') || (id === 'else') || (id === 'case') || (id === 'void') || (id === 'with'); >- break; >- case 5: >- keyword = (id === 'while') || (id === 'break') || (id === 'catch') || (id === 'throw'); >- break; >- case 6: >- keyword = (id === 'return') || (id === 'typeof') || (id === 'delete') || (id === 'switch'); >- break; >- case 7: >- keyword = (id === 'default') || (id === 'finally'); >- break; >- case 8: >- keyword = (id === 'function') || (id === 'continue') || (id === 'debugger'); >- break; >- case 10: >- keyword = (id === 'instanceof'); >- break; >- } >- >- if (keyword) { >- return true; >- } >- >- switch (id) { >- // Future reserved words. >- // 'const' is specialized as Keyword in V8. >- case 'const': >- return true; >- >- // For compatiblity to SpiderMonkey and ES.next >- case 'yield': >- case 'let': >- return true; >- } >- > if (strict && isStrictModeReservedWord(id)) { > return true; > } > >- return isFutureReservedWord(id); >- } >+ // 'const' is specialized as Keyword in V8. >+ // 'yield' and 'let' are for compatiblity with SpiderMonkey and ES.next. >+ // Some others are from future reserved words. > >- // Return the next character and move forward. >- >- function nextChar() { >- return source[index++]; >- } >- >- >- function isNewlineOrSemicolon(ch) { >- return ch===';' || ch==='\n'; >- } >- >- /** >- * rewind the lex position to the most recent newline or semicolon. If that turns out >- * to be the same position as the most recent parsing of a statement was attempted at, >- * don't rewind (because it will fail in the same way). If it turns out to be the same >- * position as where we last rewound to, don't do it. Clears the buffer and sets the >- * index in order to continue lexing from the new position. >- */ >- function rewind() { >- var idx = index; >- while (idx>0 && !isNewlineOrSemicolon(source[idx])) { >- idx--; >- } >- if (idx<=extra.statementStart) { >- return; >- } >- var doRewind = false; >- if (extra.lastRewindLocation) { >- doRewind = true; >- } else { >- var v = extra.lastRewindLocation; >- if (v!==idx) { >- doRewind=true; >- } >- } >- if (doRewind) { >- index = idx; >- buffer = null; >- extra.lastRewindLocation = index; >+ switch (id.length) { >+ case 2: >+ return (id === 'if') || (id === 'in') || (id === 'do'); >+ case 3: >+ return (id === 'var') || (id === 'for') || (id === 'new') || >+ (id === 'try') || (id === 'let'); >+ case 4: >+ return (id === 'this') || (id === 'else') || (id === 'case') || >+ (id === 'void') || (id === 'with') || (id === 'enum'); >+ case 5: >+ return (id === 'while') || (id === 'break') || (id === 'catch') || >+ (id === 'throw') || (id === 'const') || (id === 'yield') || >+ (id === 'class') || (id === 'super'); >+ case 6: >+ return (id === 'return') || (id === 'typeof') || (id === 'delete') || >+ (id === 'switch') || (id === 'export') || (id === 'import'); >+ case 7: >+ return (id === 'default') || (id === 'finally') || (id === 'extends'); >+ case 8: >+ return (id === 'function') || (id === 'continue') || (id === 'debugger'); >+ case 10: >+ return (id === 'instanceof'); >+ default: >+ return false; > } > } > > // 7.4 Comments > >- function skipComment() { >- var ch, blockComment, lineComment; >+ function addComment(type, value, start, end, loc) { >+ var comment, attacher; > >- blockComment = false; >- lineComment = false; >+ assert(typeof start === 'number', 'Comment must have valid position'); >+ >+ // Because the way the actual token is scanned, often the comments >+ // (if any) are skipped twice during the lexical analysis. >+ // Thus, we need to skip adding a comment if the comment array already >+ // handled it. >+ if (state.lastCommentStart >= start) { >+ return; >+ } >+ state.lastCommentStart = start; >+ >+ comment = { >+ type: type, >+ value: value >+ }; >+ if (extra.range) { >+ comment.range = [start, end]; >+ } >+ if (extra.loc) { >+ comment.loc = loc; >+ } >+ extra.comments.push(comment); >+ >+ if (extra.attachComment) { >+ attacher = { >+ comment: comment, >+ leading: null, >+ trailing: null, >+ range: [start, end] >+ }; >+ extra.pendingComments.push(attacher); >+ } >+ } >+ >+ function skipSingleLineComment() { >+ var start, loc, ch, comment; >+ >+ start = index - 2; >+ loc = { >+ start: { >+ line: lineNumber, >+ column: index - lineStart - 2 >+ } >+ }; > > while (index < length) { >- ch = source[index]; >- >- if (lineComment) { >- ch = nextChar(); >- if (isLineTerminator(ch)) { >- lineComment = false; >- if (ch === '\r' && source[index] === '\n') { >- ++index; >- } >- ++lineNumber; >- lineStart = index; >+ ch = source.charCodeAt(index); >+ ++index; >+ if (isLineTerminator(ch)) { >+ if (extra.comments) { >+ comment = source.slice(start + 2, index - 1); >+ loc.end = { >+ line: lineNumber, >+ column: index - lineStart - 1 >+ }; >+ addComment('Line', comment, start, index - 1, loc); > } >- } else if (blockComment) { >- if (isLineTerminator(ch)) { >- if (ch === '\r' && source[index + 1] === '\n') { >- ++index; >- } >- ++lineNumber; >- ++index; >- lineStart = index; >- if (index >= length) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } else { >- ch = nextChar(); >- if (index >= length) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- if (ch === '*') { >- ch = source[index]; >- if (ch === '/') { >- ++index; >- blockComment = false; >- } >- } >- } >- } else if (ch === '/') { >- ch = source[index + 1]; >- if (ch === '/') { >- index += 2; >- lineComment = true; >- } else if (ch === '*') { >- index += 2; >- blockComment = true; >- if (index >= length) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } else { >- break; >- } >- } else if (isWhiteSpace(ch)) { >- ++index; >- } else if (isLineTerminator(ch)) { >- ++index; >- if (ch === '\r' && source[index] === '\n') { >+ if (ch === 13 && source.charCodeAt(index) === 10) { > ++index; > } > ++lineNumber; > lineStart = index; >+ return; >+ } >+ } >+ >+ if (extra.comments) { >+ comment = source.slice(start + 2, index); >+ loc.end = { >+ line: lineNumber, >+ column: index - lineStart >+ }; >+ addComment('Line', comment, start, index, loc); >+ } >+ } >+ >+ function skipMultiLineComment() { >+ var start, loc, ch, comment; >+ >+ if (extra.comments) { >+ start = index - 2; >+ loc = { >+ start: { >+ line: lineNumber, >+ column: index - lineStart - 2 >+ } >+ }; >+ } >+ >+ while (index < length) { >+ ch = source.charCodeAt(index); >+ if (isLineTerminator(ch)) { >+ if (ch === 13 && source.charCodeAt(index + 1) === 10) { >+ ++index; >+ } >+ ++lineNumber; >+ ++index; >+ lineStart = index; >+ if (index >= length) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >+ } >+ } else if (ch === 42) { >+ // Block comment ends with '*/' (char #42, char #47). >+ if (source.charCodeAt(index + 1) === 47) { >+ ++index; >+ ++index; >+ if (extra.comments) { >+ comment = source.slice(start + 2, index - 2); >+ loc.end = { >+ line: lineNumber, >+ column: index - lineStart >+ }; >+ addComment('Block', comment, start, index, loc); >+ } >+ return; >+ } >+ ++index; >+ } else { >+ ++index; >+ } >+ } >+ >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >+ } >+ >+ function skipComment() { >+ var ch, start; >+ >+ start = (index === 0); >+ while (index < length) { >+ ch = source.charCodeAt(index); >+ >+ if (isWhiteSpace(ch)) { >+ ++index; >+ } else if (isLineTerminator(ch)) { >+ ++index; >+ if (ch === 13 && source.charCodeAt(index) === 10) { >+ ++index; >+ } >+ ++lineNumber; >+ lineStart = index; >+ start = true; >+ } else if (ch === 47) { // 47 is '/' >+ ch = source.charCodeAt(index + 1); >+ if (ch === 47) { >+ ++index; >+ ++index; >+ skipSingleLineComment(); >+ start = true; >+ } else if (ch === 42) { // 42 is '*' >+ ++index; >+ ++index; >+ skipMultiLineComment(); >+ } else { >+ break; >+ } >+ } else if (start && ch === 45) { // 45 is '-' >+ // 62 is '>' >+ if ((source.charCodeAt(index + 1) === 45) && (source.charCodeAt(index + 2) === 62)) { >+ // '-->' is a single-line comment >+ index += 3; >+ skipSingleLineComment(); >+ } else { >+ break; >+ } >+ } else if (ch === 60) { // 60 is '<' >+ if (source.slice(index + 1, index + 4) === '!--') { >+ ++index; // `<` >+ ++index; // `!` >+ ++index; // `-` >+ ++index; // `-` >+ skipSingleLineComment(); >+ } else { >+ break; >+ } > } else { > break; > } >@@ -458,7 +528,7 @@ > len = (prefix === 'u') ? 4 : 2; > for (i = 0; i < len; ++i) { > if (index < length && isHexDigit(source[index])) { >- ch = nextChar(); >+ ch = source[index++]; > code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); > } else { > return ''; >@@ -467,111 +537,96 @@ > return String.fromCharCode(code); > } > >- function scanIdentifier() { >- var ch, start, id, restore; >+ function getEscapedIdentifier() { >+ var ch, id; > >- ch = source[index]; >- if (!isIdentifierStart(ch)) { >- return; >- } >+ ch = source.charCodeAt(index++); >+ id = String.fromCharCode(ch); > >- start = index; >- if (ch === '\\') { >- ++index; >- if (source[index] !== 'u') { >- return; >+ // '\u' (char #92, char #117) denotes an escaped character. >+ if (ch === 92) { >+ if (source.charCodeAt(index) !== 117) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); > } > ++index; >- restore = index; > ch = scanHexEscape('u'); >- if (ch) { >- if (ch === '\\' || !isIdentifierStart(ch)) { >- return; >- } >- id = ch; >- } else { >- index = restore; >- id = 'u'; >+ if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); > } >- } else { >- id = nextChar(); >+ id = ch; > } > > while (index < length) { >- ch = source[index]; >+ ch = source.charCodeAt(index); > if (!isIdentifierPart(ch)) { > break; > } >- if (ch === '\\') { >- ++index; >- if (source[index] !== 'u') { >- return; >+ ++index; >+ id += String.fromCharCode(ch); >+ >+ // '\u' (char #92, char #117) denotes an escaped character. >+ if (ch === 92) { >+ id = id.substr(0, id.length - 1); >+ if (source.charCodeAt(index) !== 117) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); > } > ++index; >- restore = index; > ch = scanHexEscape('u'); >- if (ch) { >- if (ch === '\\' || !isIdentifierPart(ch)) { >- return; >- } >- id += ch; >- } else { >- index = restore; >- id += 'u'; >+ if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); > } >- } else { >- id += nextChar(); >+ id += ch; > } > } >+ >+ return id; >+ } >+ >+ function getIdentifier() { >+ var start, ch; >+ >+ start = index++; >+ while (index < length) { >+ ch = source.charCodeAt(index); >+ if (ch === 92) { >+ // Blackslash (char #92) marks Unicode escape sequence. >+ index = start; >+ return getEscapedIdentifier(); >+ } >+ if (isIdentifierPart(ch)) { >+ ++index; >+ } else { >+ break; >+ } >+ } >+ >+ return source.slice(start, index); >+ } >+ >+ function scanIdentifier() { >+ var start, id, type; >+ >+ start = index; >+ >+ // Backslash (char #92) starts an escaped character. >+ id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier(); > > // There is no keyword or literal with only one character. > // Thus, it must be an identifier. > if (id.length === 1) { >- return { >- type: Token.Identifier, >- value: id, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- if (isKeyword(id)) { >- return { >- type: Token.Keyword, >- value: id, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- // 7.8.1 Null Literals >- >- if (id === 'null') { >- return { >- type: Token.NullLiteral, >- value: id, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- // 7.8.2 Boolean Literals >- >- if (id === 'true' || id === 'false') { >- return { >- type: Token.BooleanLiteral, >- value: id, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >+ type = Token.Identifier; >+ } else if (isKeyword(id)) { >+ type = Token.Keyword; >+ } else if (id === 'null') { >+ type = Token.NullLiteral; >+ } else if (id === 'true' || id === 'false') { >+ type = Token.BooleanLiteral; >+ } else { >+ type = Token.Identifier; > } > > return { >- type: Token.Identifier, >+ type: type, > value: id, > lineNumber: lineNumber, > lineStart: lineStart, >@@ -579,55 +634,99 @@ > }; > } > >+ > // 7.7 Punctuators > > function scanPunctuator() { > var start = index, >+ code = source.charCodeAt(index), >+ code2, > ch1 = source[index], > ch2, > ch3, > ch4; > >+ switch (code) { >+ > // Check for most common single-character punctuators. >- >- if (ch1 === ';' || ch1 === '{' || ch1 === '}') { >+ case 46: // . dot >+ case 40: // ( open bracket >+ case 41: // ) close bracket >+ case 59: // ; semicolon >+ case 44: // , comma >+ case 123: // { open curly brace >+ case 125: // } close curly brace >+ case 91: // [ >+ case 93: // ] >+ case 58: // : >+ case 63: // ? >+ case 126: // ~ > ++index; >+ if (extra.tokenize) { >+ if (code === 40) { >+ extra.openParenToken = extra.tokens.length; >+ } else if (code === 123) { >+ extra.openCurlyToken = extra.tokens.length; >+ } >+ } > return { > type: Token.Punctuator, >- value: ch1, >+ value: String.fromCharCode(code), > lineNumber: lineNumber, > lineStart: lineStart, > range: [start, index] > }; >- } > >- if (ch1 === ',' || ch1 === '(' || ch1 === ')') { >- ++index; >- return { >- type: Token.Punctuator, >- value: ch1, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >+ default: >+ code2 = source.charCodeAt(index + 1); > >- // Dot (.) can also start a floating-point number, hence the need >- // to check the next character. >+ // '=' (char #61) marks an assignment or comparison operator. >+ if (code2 === 61) { >+ switch (code) { >+ case 37: // % >+ case 38: // & >+ case 42: // *: >+ case 43: // + >+ case 45: // - >+ case 47: // / >+ case 60: // < >+ case 62: // > >+ case 94: // ^ >+ case 124: // | >+ index += 2; >+ return { >+ type: Token.Punctuator, >+ value: String.fromCharCode(code) + String.fromCharCode(code2), >+ lineNumber: lineNumber, >+ lineStart: lineStart, >+ range: [start, index] >+ }; > >- ch2 = source[index + 1]; >- if (ch1 === '.' && !isDecimalDigit(ch2)) { >- return { >- type: Token.Punctuator, >- value: nextChar(), >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >+ case 33: // ! >+ case 61: // = >+ index += 2; >+ >+ // !== and === >+ if (source.charCodeAt(index) === 61) { >+ ++index; >+ } >+ return { >+ type: Token.Punctuator, >+ value: source.slice(start, index), >+ lineNumber: lineNumber, >+ lineStart: lineStart, >+ range: [start, index] >+ }; >+ default: >+ break; >+ } >+ } >+ break; > } > > // Peek more characters. > >+ ch2 = source[index + 1]; > ch3 = source[index + 2]; > ch4 = source[index + 3]; > >@@ -647,28 +746,6 @@ > } > > // 3-character punctuators: === !== >>> <<= >>= >- >- if (ch1 === '=' && ch2 === '=' && ch3 === '=') { >- index += 3; >- return { >- type: Token.Punctuator, >- value: '===', >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- if (ch1 === '!' && ch2 === '=' && ch3 === '=') { >- index += 3; >- return { >- type: Token.Punctuator, >- value: '!==', >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } > > if (ch1 === '>' && ch2 === '>' && ch3 === '>') { > index += 3; >@@ -703,178 +780,147 @@ > }; > } > >- // 2-character punctuators: <= >= == != ++ -- << >> && || >- // += -= *= %= &= |= ^= /= >- >- if (ch2 === '=') { >- if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { >- index += 2; >- return { >- type: Token.Punctuator, >- value: ch1 + ch2, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- } >+ // Other 2-character punctuators: ++ -- << >> && || > > if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0)) { >- if ('+-<>&|'.indexOf(ch2) >= 0) { >- index += 2; >- return { >- type: Token.Punctuator, >- value: ch1 + ch2, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- } >- >- // The remaining 1-character punctuators. >- >- if ('[]<>+-*%&|^!~?:=/'.indexOf(ch1) >= 0) { >+ index += 2; > return { > type: Token.Punctuator, >- value: nextChar(), >+ value: ch1 + ch2, > lineNumber: lineNumber, > lineStart: lineStart, > range: [start, index] > }; > } >+ >+ if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { >+ ++index; >+ return { >+ type: Token.Punctuator, >+ value: ch1, >+ lineNumber: lineNumber, >+ lineStart: lineStart, >+ range: [start, index] >+ }; >+ } >+ >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); > } > > // 7.8.3 Numeric Literals >+ >+ function scanHexLiteral(start) { >+ var number = ''; >+ >+ while (index < length) { >+ if (!isHexDigit(source[index])) { >+ break; >+ } >+ number += source[index++]; >+ } >+ >+ if (number.length === 0) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >+ } >+ >+ if (isIdentifierStart(source.charCodeAt(index))) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >+ } >+ >+ return { >+ type: Token.NumericLiteral, >+ value: parseInt('0x' + number, 16), >+ lineNumber: lineNumber, >+ lineStart: lineStart, >+ range: [start, index] >+ }; >+ } >+ >+ function scanOctalLiteral(start) { >+ var number = '0' + source[index++]; >+ while (index < length) { >+ if (!isOctalDigit(source[index])) { >+ break; >+ } >+ number += source[index++]; >+ } >+ >+ if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >+ } >+ >+ return { >+ type: Token.NumericLiteral, >+ value: parseInt(number, 8), >+ octal: true, >+ lineNumber: lineNumber, >+ lineStart: lineStart, >+ range: [start, index] >+ }; >+ } > > function scanNumericLiteral() { > var number, start, ch; > > ch = source[index]; >- assert(isDecimalDigit(ch) || (ch === '.'), >+ assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), > 'Numeric literal must start with a decimal digit or a decimal point'); > > start = index; > number = ''; > if (ch !== '.') { >- number = nextChar(); >+ number = source[index++]; > ch = source[index]; > > // Hex number starts with '0x'. > // Octal number starts with '0'. > if (number === '0') { > if (ch === 'x' || ch === 'X') { >- number += nextChar(); >- while (index < length) { >- ch = source[index]; >- if (!isHexDigit(ch)) { >- break; >- } >- number += nextChar(); >- } >- >- if (number.length <= 2) { >- // only 0x >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- >- if (index < length) { >- ch = source[index]; >- if (isIdentifierStart(ch)) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } >- return { >- type: Token.NumericLiteral, >- value: parseInt(number, 16), >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } else if (isOctalDigit(ch)) { >- number += nextChar(); >- while (index < length) { >- ch = source[index]; >- if (!isOctalDigit(ch)) { >- break; >- } >- number += nextChar(); >- } >- >- if (index < length) { >- ch = source[index]; >- if (isIdentifierStart(ch) || isDecimalDigit(ch)) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } >- return { >- type: Token.NumericLiteral, >- value: parseInt(number, 8), >- octal: true, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >+ ++index; >+ return scanHexLiteral(start); >+ } >+ if (isOctalDigit(ch)) { >+ return scanOctalLiteral(start); > } > > // decimal number starts with '0' such as '09' is illegal. >- if (isDecimalDigit(ch)) { >+ if (ch && isDecimalDigit(ch.charCodeAt(0))) { > throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); > } > } > >- while (index < length) { >- ch = source[index]; >- if (!isDecimalDigit(ch)) { >- break; >- } >- number += nextChar(); >+ while (isDecimalDigit(source.charCodeAt(index))) { >+ number += source[index++]; > } >+ ch = source[index]; > } > > if (ch === '.') { >- number += nextChar(); >- while (index < length) { >- ch = source[index]; >- if (!isDecimalDigit(ch)) { >- break; >- } >- number += nextChar(); >+ number += source[index++]; >+ while (isDecimalDigit(source.charCodeAt(index))) { >+ number += source[index++]; > } >+ ch = source[index]; > } > > if (ch === 'e' || ch === 'E') { >- number += nextChar(); >+ number += source[index++]; > > ch = source[index]; > if (ch === '+' || ch === '-') { >- number += nextChar(); >+ number += source[index++]; > } >- >- ch = source[index]; >- if (isDecimalDigit(ch)) { >- number += nextChar(); >- while (index < length) { >- ch = source[index]; >- if (!isDecimalDigit(ch)) { >- break; >- } >- number += nextChar(); >+ if (isDecimalDigit(source.charCodeAt(index))) { >+ while (isDecimalDigit(source.charCodeAt(index))) { >+ number += source[index++]; > } > } else { >- ch = 'character ' + ch; >- if (index >= length) { >- ch = '<end>'; >- } > throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); > } > } > >- if (index < length) { >- ch = source[index]; >- if (isIdentifierStart(ch)) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >+ if (isIdentifierStart(source.charCodeAt(index))) { >+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); > } > > return { >@@ -899,14 +945,14 @@ > ++index; > > while (index < length) { >- ch = nextChar(); >+ ch = source[index++]; > > if (ch === quote) { > quote = ''; > break; > } else if (ch === '\\') { >- ch = nextChar(); >- if (!isLineTerminator(ch)) { >+ ch = source[index++]; >+ if (!ch || !isLineTerminator(ch.charCodeAt(0))) { > switch (ch) { > case 'n': > str += '\n'; >@@ -935,7 +981,7 @@ > str += '\f'; > break; > case 'v': >- str += '\v'; >+ str += '\x0B'; > break; > > default: >@@ -949,14 +995,14 @@ > > if (index < length && isOctalDigit(source[index])) { > octal = true; >- code = code * 8 + '01234567'.indexOf(nextChar()); >+ code = code * 8 + '01234567'.indexOf(source[index++]); > > // 3 digits are only allowed when string starts > // with 0, 1, 2, 3 > if ('0123'.indexOf(ch) >= 0 && > index < length && > isOctalDigit(source[index])) { >- code = code * 8 + '01234567'.indexOf(nextChar()); >+ code = code * 8 + '01234567'.indexOf(source[index++]); > } > } > str += String.fromCharCode(code); >@@ -971,7 +1017,7 @@ > ++index; > } > } >- } else if (isLineTerminator(ch)) { >+ } else if (isLineTerminator(ch.charCodeAt(0))) { > break; > } else { > str += ch; >@@ -993,45 +1039,43 @@ > } > > function scanRegExp() { >- var str = '', ch, start, pattern, flags, value, classMarker = false, restore; >+ var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false; > >- buffer = null; >+ lookahead = null; > skipComment(); > > start = index; > ch = source[index]; > assert(ch === '/', 'Regular expression literal must start with a slash'); >- str = nextChar(); >+ str = source[index++]; > > while (index < length) { >- ch = nextChar(); >+ ch = source[index++]; > str += ch; >- if (classMarker) { >+ if (ch === '\\') { >+ ch = source[index++]; >+ // ECMA-262 7.8.5 >+ if (isLineTerminator(ch.charCodeAt(0))) { >+ throwError({}, Messages.UnterminatedRegExp); >+ } >+ str += ch; >+ } else if (isLineTerminator(ch.charCodeAt(0))) { >+ throwError({}, Messages.UnterminatedRegExp); >+ } else if (classMarker) { > if (ch === ']') { > classMarker = false; > } > } else { >- if (ch === '\\') { >- ch = nextChar(); >- // ECMA-262 7.8.5 >- if (isLineTerminator(ch)) { >- throwError({}, Messages.UnterminatedRegExp); >- } >- str += ch; >- } >- else if (ch === '/') { >+ if (ch === '/') { >+ terminated = true; > break; >- } >- else if (ch === '[') { >+ } else if (ch === '[') { > classMarker = true; >- } >- else if (isLineTerminator(ch)) { >- throwError({}, Messages.UnterminatedRegExp); > } > } > } > >- if (str.length === 1) { >+ if (!terminated) { > throwError({}, Messages.UnterminatedRegExp); > } > >@@ -1041,7 +1085,7 @@ > flags = ''; > while (index < length) { > ch = source[index]; >- if (!isIdentifierPart(ch)) { >+ if (!isIdentifierPart(ch.charCodeAt(0))) { > break; > } > >@@ -1054,8 +1098,7 @@ > ch = scanHexEscape('u'); > if (ch) { > flags += ch; >- str += '\\u'; >- for (; restore < index; ++restore) { >+ for (str += '\\u'; restore < index; ++restore) { > str += source[restore]; > } > } else { >@@ -1078,11 +1121,63 @@ > throwError({}, Messages.InvalidRegExp); > } > >+ >+ >+ if (extra.tokenize) { >+ return { >+ type: Token.RegularExpression, >+ value: value, >+ lineNumber: lineNumber, >+ lineStart: lineStart, >+ range: [start, index] >+ }; >+ } > return { > literal: str, > value: value, > range: [start, index] > }; >+ } >+ >+ function collectRegex() { >+ var pos, loc, regex, token; >+ >+ skipComment(); >+ >+ pos = index; >+ loc = { >+ start: { >+ line: lineNumber, >+ column: index - lineStart >+ } >+ }; >+ >+ regex = scanRegExp(); >+ loc.end = { >+ line: lineNumber, >+ column: index - lineStart >+ }; >+ >+ if (!extra.tokenize) { >+ // Pop the previous token, which is likely '/' or '/=' >+ if (extra.tokens.length > 0) { >+ token = extra.tokens[extra.tokens.length - 1]; >+ if (token.range[0] === pos && token.type === 'Punctuator') { >+ if (token.value === '/' || token.value === '/=') { >+ extra.tokens.pop(); >+ } >+ } >+ } >+ >+ extra.tokens.push({ >+ type: 'RegularExpression', >+ value: regex.literal, >+ range: [pos, index], >+ loc: loc >+ }); >+ } >+ >+ return regex; > } > > function isIdentifierName(token) { >@@ -1092,8 +1187,68 @@ > token.type === Token.NullLiteral; > } > >+ function advanceSlash() { >+ var prevToken, >+ checkToken; >+ // Using the following algorithm: >+ // https://github.com/mozilla/sweet.js/wiki/design >+ prevToken = extra.tokens[extra.tokens.length - 1]; >+ if (!prevToken) { >+ // Nothing before that: it cannot be a division. >+ return collectRegex(); >+ } >+ if (prevToken.type === 'Punctuator') { >+ if (prevToken.value === ')') { >+ checkToken = extra.tokens[extra.openParenToken - 1]; >+ if (checkToken && >+ checkToken.type === 'Keyword' && >+ (checkToken.value === 'if' || >+ checkToken.value === 'while' || >+ checkToken.value === 'for' || >+ checkToken.value === 'with')) { >+ return collectRegex(); >+ } >+ return scanPunctuator(); >+ } >+ if (prevToken.value === '}') { >+ // Dividing a function by anything makes little sense, >+ // but we have to check for that. >+ if (extra.tokens[extra.openCurlyToken - 3] && >+ extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') { >+ // Anonymous function. >+ checkToken = extra.tokens[extra.openCurlyToken - 4]; >+ if (!checkToken) { >+ return scanPunctuator(); >+ } >+ } else if (extra.tokens[extra.openCurlyToken - 4] && >+ extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') { >+ // Named function. >+ checkToken = extra.tokens[extra.openCurlyToken - 5]; >+ if (!checkToken) { >+ return collectRegex(); >+ } >+ } else { >+ return scanPunctuator(); >+ } >+ // checkToken determines whether the function is >+ // a declaration or an expression. >+ if (FnExprTokens.indexOf(checkToken.value) >= 0) { >+ // It is an expression. >+ return scanPunctuator(); >+ } >+ // It is a declaration. >+ return collectRegex(); >+ } >+ return collectRegex(); >+ } >+ if (prevToken.type === 'Keyword') { >+ return collectRegex(); >+ } >+ return scanPunctuator(); >+ } >+ > function advance() { >- var ch, token; >+ var ch; > > skipComment(); > >@@ -1106,62 +1261,532 @@ > }; > } > >- token = scanPunctuator(); >- if (typeof token !== 'undefined') { >- return token; >+ ch = source.charCodeAt(index); >+ >+ // Very common: ( and ) and ; >+ if (ch === 40 || ch === 41 || ch === 58) { >+ return scanPunctuator(); > } > >- ch = source[index]; >- >- if (ch === '\'' || ch === '"') { >+ // String literal starts with single quote (#39) or double quote (#34). >+ if (ch === 39 || ch === 34) { > return scanStringLiteral(); > } > >- if (ch === '.' || isDecimalDigit(ch)) { >+ if (isIdentifierStart(ch)) { >+ return scanIdentifier(); >+ } >+ >+ // Dot (.) char #46 can also start a floating-point number, hence the need >+ // to check the next character. >+ if (ch === 46) { >+ if (isDecimalDigit(source.charCodeAt(index + 1))) { >+ return scanNumericLiteral(); >+ } >+ return scanPunctuator(); >+ } >+ >+ if (isDecimalDigit(ch)) { > return scanNumericLiteral(); > } > >- token = scanIdentifier(); >- if (typeof token !== 'undefined') { >- return token; >+ // Slash (/) char #47 can also start a regex. >+ if (extra.tokenize && ch === 47) { >+ return advanceSlash(); > } > >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >+ return scanPunctuator(); >+ } >+ >+ function collectToken() { >+ var start, loc, token, range, value; >+ >+ skipComment(); >+ start = index; >+ loc = { >+ start: { >+ line: lineNumber, >+ column: index - lineStart >+ } >+ }; >+ >+ token = advance(); >+ loc.end = { >+ line: lineNumber, >+ column: index - lineStart >+ }; >+ >+ if (token.type !== Token.EOF) { >+ range = [token.range[0], token.range[1]]; >+ value = source.slice(token.range[0], token.range[1]); >+ extra.tokens.push({ >+ type: TokenName[token.type], >+ value: value, >+ range: range, >+ loc: loc >+ }); >+ } >+ >+ return token; > } > > function lex() { > var token; > >- if (buffer) { >- index = buffer.range[1]; >- lineNumber = buffer.lineNumber; >- lineStart = buffer.lineStart; >- token = buffer; >- buffer = null; >- return token; >- } >+ token = lookahead; >+ index = token.range[1]; >+ lineNumber = token.lineNumber; >+ lineStart = token.lineStart; > >- buffer = null; >- return advance(); >+ lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); >+ >+ index = token.range[1]; >+ lineNumber = token.lineNumber; >+ lineStart = token.lineStart; >+ >+ return token; > } > >- function lookahead() { >+ function peek() { > var pos, line, start; >- >- if (buffer !== null) { >- return buffer; >- } > > pos = index; > line = lineNumber; > start = lineStart; >- buffer = advance(); >+ lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); > index = pos; > lineNumber = line; > lineStart = start; >- >- return buffer; > } >+ >+ SyntaxTreeDelegate = { >+ >+ name: 'SyntaxTree', >+ >+ markStart: function () { >+ if (extra.loc) { >+ state.markerStack.push(index - lineStart); >+ state.markerStack.push(lineNumber); >+ } >+ if (extra.range) { >+ state.markerStack.push(index); >+ } >+ }, >+ >+ processComment: function (node) { >+ var i, attacher, pos, len, candidate; >+ >+ if (typeof node.type === 'undefined' || node.type === Syntax.Program) { >+ return; >+ } >+ >+ // Check for possible additional trailing comments. >+ peek(); >+ >+ for (i = 0; i < extra.pendingComments.length; ++i) { >+ attacher = extra.pendingComments[i]; >+ if (node.range[0] >= attacher.comment.range[1]) { >+ candidate = attacher.leading; >+ if (candidate) { >+ pos = candidate.range[0]; >+ len = candidate.range[1] - pos; >+ if (node.range[0] <= pos && (node.range[1] - node.range[0] >= len)) { >+ attacher.leading = node; >+ } >+ } else { >+ attacher.leading = node; >+ } >+ } >+ if (node.range[1] <= attacher.comment.range[0]) { >+ candidate = attacher.trailing; >+ if (candidate) { >+ pos = candidate.range[0]; >+ len = candidate.range[1] - pos; >+ if (node.range[0] <= pos && (node.range[1] - node.range[0] >= len)) { >+ attacher.trailing = node; >+ } >+ } else { >+ attacher.trailing = node; >+ } >+ } >+ } >+ }, >+ >+ markEnd: function (node) { >+ if (extra.range) { >+ node.range = [state.markerStack.pop(), index]; >+ } >+ if (extra.loc) { >+ node.loc = { >+ start: { >+ line: state.markerStack.pop(), >+ column: state.markerStack.pop() >+ }, >+ end: { >+ line: lineNumber, >+ column: index - lineStart >+ } >+ }; >+ this.postProcess(node); >+ } >+ if (extra.attachComment) { >+ this.processComment(node); >+ } >+ return node; >+ }, >+ >+ markEndIf: function (node) { >+ // mamacdon: in tolerant mode, node passed to the delegate may be null >+ if (!node || node.range || node.loc) { >+ if (extra.loc) { >+ state.markerStack.pop(); >+ state.markerStack.pop(); >+ } >+ if (extra.range) { >+ state.markerStack.pop(); >+ } >+ } else { >+ this.markEnd(node); >+ } >+ return node; >+ }, >+ >+ postProcess: function (node) { >+ if (extra.source) { >+ node.loc.source = extra.source; >+ } >+ return node; >+ }, >+ >+ createArrayExpression: function (elements) { >+ return { >+ type: Syntax.ArrayExpression, >+ elements: elements >+ }; >+ }, >+ >+ createAssignmentExpression: function (operator, left, right) { >+ return { >+ type: Syntax.AssignmentExpression, >+ operator: operator, >+ left: left, >+ right: right >+ }; >+ }, >+ >+ createBinaryExpression: function (operator, left, right) { >+ var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : >+ Syntax.BinaryExpression; >+ return { >+ type: type, >+ operator: operator, >+ left: left, >+ right: right >+ }; >+ }, >+ >+ createBlockStatement: function (body) { >+ return { >+ type: Syntax.BlockStatement, >+ body: body >+ }; >+ }, >+ >+ createBreakStatement: function (label) { >+ return { >+ type: Syntax.BreakStatement, >+ label: label >+ }; >+ }, >+ >+ createCallExpression: function (callee, args) { >+ return { >+ type: Syntax.CallExpression, >+ callee: callee, >+ 'arguments': args >+ }; >+ }, >+ >+ createCatchClause: function (param, body) { >+ return { >+ type: Syntax.CatchClause, >+ param: param, >+ body: body >+ }; >+ }, >+ >+ createConditionalExpression: function (test, consequent, alternate) { >+ return { >+ type: Syntax.ConditionalExpression, >+ test: test, >+ consequent: consequent, >+ alternate: alternate >+ }; >+ }, >+ >+ createContinueStatement: function (label) { >+ return { >+ type: Syntax.ContinueStatement, >+ label: label >+ }; >+ }, >+ >+ createDebuggerStatement: function () { >+ return { >+ type: Syntax.DebuggerStatement >+ }; >+ }, >+ >+ createDoWhileStatement: function (body, test) { >+ return { >+ type: Syntax.DoWhileStatement, >+ body: body, >+ test: test >+ }; >+ }, >+ >+ createEmptyStatement: function () { >+ return { >+ type: Syntax.EmptyStatement >+ }; >+ }, >+ >+ createExpressionStatement: function (expression) { >+ return { >+ type: Syntax.ExpressionStatement, >+ expression: expression >+ }; >+ }, >+ >+ createForStatement: function (init, test, update, body) { >+ return { >+ type: Syntax.ForStatement, >+ init: init, >+ test: test, >+ update: update, >+ body: body >+ }; >+ }, >+ >+ createForInStatement: function (left, right, body) { >+ return { >+ type: Syntax.ForInStatement, >+ left: left, >+ right: right, >+ body: body, >+ each: false >+ }; >+ }, >+ >+ createFunctionDeclaration: function (id, params, defaults, body) { >+ return { >+ type: Syntax.FunctionDeclaration, >+ id: id, >+ params: params, >+ defaults: defaults, >+ body: body, >+ rest: null, >+ generator: false, >+ expression: false >+ }; >+ }, >+ >+ createFunctionExpression: function (id, params, defaults, body) { >+ return { >+ type: Syntax.FunctionExpression, >+ id: id, >+ params: params, >+ defaults: defaults, >+ body: body, >+ rest: null, >+ generator: false, >+ expression: false >+ }; >+ }, >+ >+ createIdentifier: function (name) { >+ return { >+ type: Syntax.Identifier, >+ name: name >+ }; >+ }, >+ >+ createIfStatement: function (test, consequent, alternate) { >+ return { >+ type: Syntax.IfStatement, >+ test: test, >+ consequent: consequent, >+ alternate: alternate >+ }; >+ }, >+ >+ createLabeledStatement: function (label, body) { >+ return { >+ type: Syntax.LabeledStatement, >+ label: label, >+ body: body >+ }; >+ }, >+ >+ createLiteral: function (token) { >+ return { >+ type: Syntax.Literal, >+ value: token.value, >+ raw: source.slice(token.range[0], token.range[1]) >+ }; >+ }, >+ >+ createMemberExpression: function (accessor, object, property) { >+ return { >+ type: Syntax.MemberExpression, >+ computed: accessor === '[', >+ object: object, >+ property: property >+ }; >+ }, >+ >+ createNewExpression: function (callee, args) { >+ return { >+ type: Syntax.NewExpression, >+ callee: callee, >+ 'arguments': args >+ }; >+ }, >+ >+ createObjectExpression: function (properties) { >+ return { >+ type: Syntax.ObjectExpression, >+ properties: properties >+ }; >+ }, >+ >+ createPostfixExpression: function (operator, argument) { >+ return { >+ type: Syntax.UpdateExpression, >+ operator: operator, >+ argument: argument, >+ prefix: false >+ }; >+ }, >+ >+ createProgram: function (body) { >+ return { >+ type: Syntax.Program, >+ body: body >+ }; >+ }, >+ >+ createProperty: function (kind, key, value) { >+ return { >+ type: Syntax.Property, >+ key: key, >+ value: value, >+ kind: kind >+ }; >+ }, >+ >+ createReturnStatement: function (argument) { >+ return { >+ type: Syntax.ReturnStatement, >+ argument: argument >+ }; >+ }, >+ >+ createSequenceExpression: function (expressions) { >+ return { >+ type: Syntax.SequenceExpression, >+ expressions: expressions >+ }; >+ }, >+ >+ createSwitchCase: function (test, consequent) { >+ return { >+ type: Syntax.SwitchCase, >+ test: test, >+ consequent: consequent >+ }; >+ }, >+ >+ createSwitchStatement: function (discriminant, cases) { >+ return { >+ type: Syntax.SwitchStatement, >+ discriminant: discriminant, >+ cases: cases >+ }; >+ }, >+ >+ createThisExpression: function () { >+ return { >+ type: Syntax.ThisExpression >+ }; >+ }, >+ >+ createThrowStatement: function (argument) { >+ return { >+ type: Syntax.ThrowStatement, >+ argument: argument >+ }; >+ }, >+ >+ createTryStatement: function (block, guardedHandlers, handlers, finalizer) { >+ return { >+ type: Syntax.TryStatement, >+ block: block, >+ guardedHandlers: guardedHandlers, >+ handlers: handlers, >+ finalizer: finalizer >+ }; >+ }, >+ >+ createUnaryExpression: function (operator, argument) { >+ if (operator === '++' || operator === '--') { >+ return { >+ type: Syntax.UpdateExpression, >+ operator: operator, >+ argument: argument, >+ prefix: true >+ }; >+ } >+ return { >+ type: Syntax.UnaryExpression, >+ operator: operator, >+ argument: argument, >+ prefix: true >+ }; >+ }, >+ >+ createVariableDeclaration: function (declarations, kind) { >+ return { >+ type: Syntax.VariableDeclaration, >+ declarations: declarations, >+ kind: kind >+ }; >+ }, >+ >+ createVariableDeclarator: function (id, init) { >+ return { >+ type: Syntax.VariableDeclarator, >+ id: id, >+ init: init >+ }; >+ }, >+ >+ createWhileStatement: function (test, body) { >+ return { >+ type: Syntax.WhileStatement, >+ test: test, >+ body: body >+ }; >+ }, >+ >+ createWithStatement: function (object, body) { >+ return { >+ type: Syntax.WithStatement, >+ object: object, >+ body: body >+ }; >+ } >+ }; > > // Return true if there is a line terminator before the next token. > >@@ -1188,13 +1813,16 @@ > msg = messageFormat.replace( > /%(\d)/g, > function (whole, index) { >- return args[index] || ''; >+ assert(index < args.length, 'Message reference must be in range'); >+ return args[index]; > } > ); > > if (typeof token.lineNumber === 'number') { > error = new Error('Line ' + token.lineNumber + ': ' + msg); > error.index = token.range[0]; >+ // mamacdon a09739e >+ // mamacdon @ 1.0.0 esprima.js:1198 > error.end = token.range[1]; > error.token = token.value; > error.lineNumber = token.lineNumber; >@@ -1206,11 +1834,12 @@ > error.column = index - lineStart + 1; > } > >+ error.description = msg; > throw error; > } > >+ // mamacdon: in tolerant mode, records the error and returns undefined. If non tolerant, throws. > function throwErrorTolerant() { >- var error; > try { > throwError.apply(null, arguments); > } catch (e) { >@@ -1222,12 +1851,9 @@ > } > } > >- > // Throw an exception because of the token. > > function throwUnexpected(token) { >- var s; >- > if (token.type === Token.EOF) { > throwError(token, Messages.UnexpectedEOS); > } >@@ -1248,7 +1874,7 @@ > if (isFutureReservedWord(token.value)) { > throwError(token, Messages.UnexpectedReserved); > } else if (strict && isStrictModeReservedWord(token.value)) { >- throwError(token, Messages.StrictReservedWord); >+ throwErrorTolerant(token, Messages.StrictReservedWord); > } > throwError(token, Messages.UnexpectedToken, token.value); > } >@@ -1280,26 +1906,24 @@ > // Return true if the next token matches the specified punctuator. > > function match(value) { >- var token = lookahead(); >- return token.type === Token.Punctuator && token.value === value; >+ return lookahead.type === Token.Punctuator && lookahead.value === value; > } > > // Return true if the next token matches the specified keyword > > function matchKeyword(keyword) { >- var token = lookahead(); >- return token.type === Token.Keyword && token.value === keyword; >+ return lookahead.type === Token.Keyword && lookahead.value === keyword; > } > > // Return true if the next token is an assignment operator > > function matchAssign() { >- var token = lookahead(), >- op = token.value; >+ var op; > >- if (token.type !== Token.Punctuator) { >+ if (lookahead.type !== Token.Punctuator) { > return false; > } >+ op = lookahead.value; > return op === '=' || > op === '*=' || > op === '/=' || >@@ -1315,10 +1939,10 @@ > } > > function consumeSemicolon() { >- var token, line; >+ var line; > >- // Catch the very common case first. >- if (source[index] === ';') { >+ // Catch the very common case first: immediately a semicolon (char #59). >+ if (source.charCodeAt(index) === 59) { > lex(); > return; > } >@@ -1334,44 +1958,32 @@ > return; > } > >- token = lookahead(); >- if (token.type !== Token.EOF && !match('}')) { >- if (extra.errors) { >- rewind(); >+ if (lookahead.type !== Token.EOF && !match('}')) { >+ var badToken = lookahead; >+ if (extra.errors) { >+ rewind(); // mutates lookahead > } >- throwUnexpected(token); >+ throwUnexpected(badToken); > } >- return; > } > > // Return true if provided expression is LeftHandSideExpression > > function isLeftHandSide(expr) { >- switch (expr.type) { >- case 'AssignmentExpression': >- case 'BinaryExpression': >- case 'ConditionalExpression': >- case 'LogicalExpression': >- case 'SequenceExpression': >- case 'UnaryExpression': >- case 'UpdateExpression': >- return false; >- } >- return true; >+ return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; > } > > // 11.1.4 Array Initialiser > > function parseArrayInitialiser() { >- var elements = [], >- undef; >+ var elements = []; > > expect('['); > > while (!match(']')) { > if (match(',')) { > lex(); >- elements.push(undef); >+ elements.push(null); > } else { > elements.push(parseAssignmentExpression()); > >@@ -1383,10 +1995,7 @@ > > expect(']'); > >- return { >- type: Syntax.ArrayExpression, >- elements: elements >- }; >+ return delegate.createArrayExpression(elements); > } > > // 11.1.5 Object Initialiser >@@ -1395,43 +2004,42 @@ > var previousStrict, body; > > previousStrict = strict; >+ skipComment(); >+ delegate.markStart(); > body = parseFunctionSourceElements(); > if (first && strict && isRestrictedWord(param[0].name)) { >- throwError(first, Messages.StrictParamName); >+ throwErrorTolerant(first, Messages.StrictParamName); > } > strict = previousStrict; >- >- return { >- type: Syntax.FunctionExpression, >- id: null, >- params: param, >- body: body >- }; >+ return delegate.markEnd(delegate.createFunctionExpression(null, param, [], body)); > } > > function parseObjectPropertyKey() { >- var token = lex(); >+ var token; >+ >+ skipComment(); >+ delegate.markStart(); >+ token = lex(); > > // Note: This function is called only from parseObjectProperty(), where > // EOF and Punctuator tokens are already filtered out. > > if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { > if (strict && token.octal) { >- throwError(token, Messages.StrictOctalLiteral); >+ throwErrorTolerant(token, Messages.StrictOctalLiteral); > } >- return createLiteral(token); >+ return delegate.markEnd(delegate.createLiteral(token)); > } > >- return { >- type: Syntax.Identifier, >- name: token.value >- }; >+ return delegate.markEnd(delegate.createIdentifier(token.value)); > } > > function parseObjectProperty() { >- var token, key, id, param; >+ var token, key, id, value, param; > >- token = lookahead(); >+ token = lookahead; >+ skipComment(); >+ delegate.markStart(); > > if (token.type === Token.Identifier) { > >@@ -1443,182 +2051,198 @@ > key = parseObjectPropertyKey(); > expect('('); > expect(')'); >- return { >- type: Syntax.Property, >- key: key, >- value: parsePropertyFunction([]), >- kind: 'get' >- }; >- } else if (token.value === 'set' && !match(':')) { >+ value = parsePropertyFunction([]); >+ return delegate.markEnd(delegate.createProperty('get', key, value)); >+ } >+ if (token.value === 'set' && !match(':')) { > key = parseObjectPropertyKey(); > expect('('); >- token = lookahead(); >+ token = lookahead; > if (token.type !== Token.Identifier) { >- throwUnexpected(lex()); >+ expect(')'); >+ throwErrorTolerant(token, Messages.UnexpectedToken, token.value); >+ value = parsePropertyFunction([]); >+ } else { >+ param = [ parseVariableIdentifier() ]; >+ expect(')'); >+ value = parsePropertyFunction(param, token); > } >- param = [ parseVariableIdentifier() ]; >- expect(')'); >- return { >- type: Syntax.Property, >- key: key, >- value: parsePropertyFunction(param, token), >- kind: 'set' >- }; >- } else { >- expect(':'); >- return { >- type: Syntax.Property, >- key: id, >- value: parseAssignmentExpression(), >- kind: 'init' >- }; >+ return delegate.markEnd(delegate.createProperty('set', key, value)); > } >- } else if (token.type === Token.EOF || token.type === Token.Punctuator) { >+ //mrennie https://bugs.eclipse.org/bugs/show_bug.cgi?id=432956 >+ var prev = token; >+ token = advance(); >+ if(token.value === ':') { >+ token = lex(); // eat the ':' so the assignment parsing starts on the correct index >+ try { >+ value = parseAssignmentExpression(); >+ return delegate.markEnd(delegate.createProperty('init', id, value)); >+ } catch(e) { >+ //process the exception >+ return null; >+ } >+ } else if(token.type === Token.Punctuator && token.value === '}') { >+ throwErrorTolerant(prev, Messages.UnexpectedToken, prev.value); >+ return null; >+ } else { >+ throwErrorTolerant(prev, Messages.UnexpectedToken, prev.value); >+ if(token.type === Token.Identifier) { >+ //if the next token is an identifer, start over >+ return null; >+ } >+ while(token.type !== Token.EOF) { >+ if(token.type === Token.Punctuator && (token.value === ',' || token.value === '}')) { >+ //entering a prop, not complete, return null >+ return null; >+ } else { >+ token = lex(); // the token if we skipped it >+ } >+ token = advance(); >+ } >+ } >+ return null; >+ } >+ if (token.type === Token.EOF || token.type === Token.Punctuator) { > throwUnexpected(token); > } else { > key = parseObjectPropertyKey(); > expect(':'); >- return { >- type: Syntax.Property, >- key: key, >- value: parseAssignmentExpression(), >- kind: 'init' >- }; >+ value = parseAssignmentExpression(); >+ return delegate.markEnd(delegate.createProperty('init', key, value)); > } > } > > function parseObjectInitialiser() { >- var token, properties = [], property, name, kind, map = {}, toString = String; >+ var properties = [], property, name, key, kind, map = {}, toString = String; > > expect('{'); > > while (!match('}')) { > property = parseObjectProperty(); >- >+ //mrennie https://bugs.eclipse.org/bugs/show_bug.cgi?id=432956 >+ if(!property) { >+ continue; >+ } > if (property.key.type === Syntax.Identifier) { > name = property.key.name; > } else { > name = toString(property.key.value); > } > kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; >- if (Object.prototype.hasOwnProperty.call(map, name)) { >- if (map[name] === PropertyKind.Data) { >+ >+ key = '$' + name; >+ if (Object.prototype.hasOwnProperty.call(map, key)) { >+ if (map[key] === PropertyKind.Data) { > if (strict && kind === PropertyKind.Data) { > throwErrorTolerant({}, Messages.StrictDuplicateProperty); > } else if (kind !== PropertyKind.Data) { >- throwError({}, Messages.AccessorDataProperty); >+ throwErrorTolerant({}, Messages.AccessorDataProperty); > } > } else { > if (kind === PropertyKind.Data) { >- throwError({}, Messages.AccessorDataProperty); >- } else if (map[name] & kind) { >- throwError({}, Messages.AccessorGetSet); >+ throwErrorTolerant({}, Messages.AccessorDataProperty); >+ } else if (map[key] & kind) { >+ throwErrorTolerant({}, Messages.AccessorGetSet); > } > } >- map[name] |= kind; >+ map[key] |= kind; > } else { >- map[name] = kind; >+ map[key] = kind; > } > > properties.push(property); > > if (!match('}')) { >- expect(','); >+ //mrennie https://bugs.eclipse.org/bugs/show_bug.cgi?id=432956 >+ var token = lookahead; >+ if(token.type !== Token.Punctuator && token.value !== ',') { >+ if(extra.tokens && extra.tokens.length > 0) { >+ token = extra.tokens[extra.tokens.length-1]; >+ } >+ throwErrorTolerant(token, Messages.MissingToken, ','); >+ } else { >+ lex(); >+ } > } > } > > expect('}'); > >- return { >- type: Syntax.ObjectExpression, >- properties: properties >- }; >+ return delegate.createObjectExpression(properties); > } >+ >+ // 11.1.6 The Grouping Operator >+ >+ function parseGroupExpression() { >+ var expr; >+ >+ expect('('); >+ >+ expr = parseExpression(); >+ >+ expect(')'); >+ >+ return expr; >+ } >+ > > // 11.1 Primary Expressions > > function parsePrimaryExpression() { >- var expr, >- token = lookahead(), >- type = token.type; >- >- if (type === Token.Identifier) { >- return { >- type: Syntax.Identifier, >- name: lex().value >- }; >- } >- >- if (type === Token.StringLiteral || type === Token.NumericLiteral) { >- if (strict && token.octal) { >- throwErrorTolerant(token, Messages.StrictOctalLiteral); >- } >- return createLiteral(lex()); >- } >- >- if (type === Token.Keyword) { >- if (matchKeyword('this')) { >- lex(); >- return { >- type: Syntax.ThisExpression >- }; >- } >- >- if (matchKeyword('function')) { >- return parseFunctionExpression(); >- } >- } >- >- if (type === Token.BooleanLiteral) { >- lex(); >- token.value = (token.value === 'true'); >- return createLiteral(token); >- } >- >- if (type === Token.NullLiteral) { >- lex(); >- token.value = null; >- return createLiteral(token); >- } >- >- if (match('[')) { >- return parseArrayInitialiser(); >- } >- >- if (match('{')) { >- return parseObjectInitialiser(); >- } >+ var type, token, expr; > > if (match('(')) { >- lex(); >- state.lastParenthesized = expr = parseExpression(); >- expect(')'); >- return expr; >+ return parseGroupExpression(); > } > >- if (match('/') || match('/=')) { >- return createLiteral(scanRegExp()); >+ type = lookahead.type; >+ delegate.markStart(); >+ >+ if (type === Token.Identifier) { >+ expr = delegate.createIdentifier(lex().value); >+ } else if (type === Token.StringLiteral || type === Token.NumericLiteral) { >+ if (strict && lookahead.octal) { >+ throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); >+ } >+ expr = delegate.createLiteral(lex()); >+ } else if (type === Token.Keyword) { >+ if (matchKeyword('this')) { >+ lex(); >+ expr = delegate.createThisExpression(); >+ } else if (matchKeyword('function')) { >+ expr = parseFunctionExpression(); >+ } >+ } else if (type === Token.BooleanLiteral) { >+ token = lex(); >+ token.value = (token.value === 'true'); >+ expr = delegate.createLiteral(token); >+ } else if (type === Token.NullLiteral) { >+ token = lex(); >+ token.value = null; >+ expr = delegate.createLiteral(token); >+ } else if (match('[')) { >+ expr = parseArrayInitialiser(); >+ } else if (match('{')) { >+ expr = parseObjectInitialiser(); >+ } else if (match('/') || match('/=')) { >+ if (typeof extra.tokens !== 'undefined') { >+ expr = delegate.createLiteral(collectRegex()); >+ } else { >+ expr = delegate.createLiteral(scanRegExp()); >+ } >+ peek(); >+ } >+ >+ if (expr) { >+ return delegate.markEnd(expr); > } > > return throwUnexpected(lex()); > } > >- /** >- * add the error if not already reported. >- */ >- function pushError(error) { >- var len = extra.errors.length; >- for (var e=0; e < len; e++) { >- var existingError = extra.errors[e]; >- if (existingError.index === error.index && existingError.message === error.message) { >- return; // do not add duplicate >- } >- } >- extra.errors.push(error); >- } >- > // 11.2 Left-Hand-Side Expressions > >+ // mamacdon 1420b19 > function parseArguments() { > var args = []; > >@@ -1657,13 +2281,1818 @@ > > return args; > } >+ >+ function parseNonComputedProperty() { >+ var token; >+ >+ if (lookahead.lineNumber !== lineNumber) { >+ // Token giving our identifier name lies on the following line, so go there before marking start >+ index = lookahead.lineStart; >+ } >+ delegate.markStart(); >+ token = lex(); >+ >+ if (!isIdentifierName(token)) { >+ if (extra.errors) { >+ attemptRecoveryNonComputedProperty(token); >+ } >+ throwUnexpected(token); >+ // return null; // unecessary >+ } >+ >+ return delegate.markEnd(delegate.createIdentifier(token.value)); >+ } >+ >+ function parseNonComputedMember() { >+ expect('.'); >+ >+ return parseNonComputedProperty(); >+ } >+ >+ function parseComputedMember() { >+ var expr; >+ >+ expect('['); >+ >+ expr = parseExpression(); >+ >+ expect(']'); >+ >+ return expr; >+ } >+ >+ function parseNewExpression() { >+ var callee, args; >+ >+ delegate.markStart(); >+ expectKeyword('new'); >+ callee = parseLeftHandSideExpression(); >+ args = match('(') ? parseArguments() : []; >+ >+ return delegate.markEnd(delegate.createNewExpression(callee, args)); >+ } >+ >+ function parseLeftHandSideExpressionAllowCall() { >+ var marker, previousAllowIn, expr, args, property; >+ >+ marker = createLocationMarker(); >+ >+ previousAllowIn = state.allowIn; >+ state.allowIn = true; >+ expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); >+ state.allowIn = previousAllowIn; >+ >+ while (match('.') || match('[') || match('(')) { >+ if (match('(')) { >+ args = parseArguments(); >+ expr = delegate.createCallExpression(expr, args); >+ } else if (match('[')) { >+ property = parseComputedMember(); >+ expr = delegate.createMemberExpression('[', expr, property); >+ } else { >+ property = parseNonComputedMember(); >+ expr = delegate.createMemberExpression('.', expr, property); >+ } >+ if (marker) { >+ marker.end(); >+ marker.apply(expr); >+ } >+ } >+ >+ return expr; >+ } >+ >+ function parseLeftHandSideExpression() { >+ var marker, previousAllowIn, expr, property; >+ >+ marker = createLocationMarker(); >+ >+ previousAllowIn = state.allowIn; >+ expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); >+ state.allowIn = previousAllowIn; >+ >+ while (match('.') || match('[')) { >+ if (match('[')) { >+ property = parseComputedMember(); >+ expr = delegate.createMemberExpression('[', expr, property); >+ } else { >+ property = parseNonComputedMember(); >+ expr = delegate.createMemberExpression('.', expr, property); >+ } >+ if (marker) { >+ marker.end(); >+ marker.apply(expr); >+ } >+ } >+ >+ return expr; >+ } >+ >+ // 11.3 Postfix Expressions >+ >+ function parsePostfixExpression() { >+ var expr, token; >+ >+ delegate.markStart(); >+ expr = parseLeftHandSideExpressionAllowCall(); >+ >+ if (lookahead.type === Token.Punctuator) { >+ if ((match('++') || match('--')) && !peekLineTerminator()) { >+ // 11.3.1, 11.3.2 >+ if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { >+ throwErrorTolerant({}, Messages.StrictLHSPostfix); >+ } >+ >+ if (!isLeftHandSide(expr)) { >+ throwErrorTolerant({}, Messages.InvalidLHSInAssignment); >+ } >+ >+ token = lex(); >+ expr = delegate.createPostfixExpression(token.value, expr); >+ } >+ } >+ >+ return delegate.markEndIf(expr); >+ } >+ >+ // 11.4 Unary Operators >+ >+ function parseUnaryExpression() { >+ var token, expr; >+ >+ delegate.markStart(); >+ >+ if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { >+ expr = parsePostfixExpression(); >+ } else if (match('++') || match('--')) { >+ token = lex(); >+ expr = parseUnaryExpression(); >+ // 11.4.4, 11.4.5 >+ if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { >+ throwErrorTolerant({}, Messages.StrictLHSPrefix); >+ } >+ >+ if (!isLeftHandSide(expr)) { >+ throwErrorTolerant({}, Messages.InvalidLHSInAssignment); >+ } >+ >+ expr = delegate.createUnaryExpression(token.value, expr); >+ } else if (match('+') || match('-') || match('~') || match('!')) { >+ token = lex(); >+ expr = parseUnaryExpression(); >+ expr = delegate.createUnaryExpression(token.value, expr); >+ } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { >+ token = lex(); >+ expr = parseUnaryExpression(); >+ expr = delegate.createUnaryExpression(token.value, expr); >+ if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { >+ throwErrorTolerant({}, Messages.StrictDelete); >+ } >+ } else { >+ expr = parsePostfixExpression(); >+ } >+ >+ return delegate.markEndIf(expr); >+ } >+ >+ function binaryPrecedence(token, allowIn) { >+ var prec = 0; >+ >+ if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { >+ return 0; >+ } >+ >+ switch (token.value) { >+ case '||': >+ prec = 1; >+ break; >+ >+ case '&&': >+ prec = 2; >+ break; >+ >+ case '|': >+ prec = 3; >+ break; >+ >+ case '^': >+ prec = 4; >+ break; >+ >+ case '&': >+ prec = 5; >+ break; >+ >+ case '==': >+ case '!=': >+ case '===': >+ case '!==': >+ prec = 6; >+ break; >+ >+ case '<': >+ case '>': >+ case '<=': >+ case '>=': >+ case 'instanceof': >+ prec = 7; >+ break; >+ >+ case 'in': >+ prec = allowIn ? 7 : 0; >+ break; >+ >+ case '<<': >+ case '>>': >+ case '>>>': >+ prec = 8; >+ break; >+ >+ case '+': >+ case '-': >+ prec = 9; >+ break; >+ >+ case '*': >+ case '/': >+ case '%': >+ prec = 11; >+ break; >+ >+ default: >+ break; >+ } >+ >+ return prec; >+ } >+ >+ // 11.5 Multiplicative Operators >+ // 11.6 Additive Operators >+ // 11.7 Bitwise Shift Operators >+ // 11.8 Relational Operators >+ // 11.9 Equality Operators >+ // 11.10 Binary Bitwise Operators >+ // 11.11 Binary Logical Operators >+ >+ function parseBinaryExpression() { >+ var marker, markers, expr, token, prec, stack, right, operator, left, i; >+ >+ marker = createLocationMarker(); >+ left = parseUnaryExpression(); >+ >+ token = lookahead; >+ prec = binaryPrecedence(token, state.allowIn); >+ if (prec === 0) { >+ return left; >+ } >+ token.prec = prec; >+ lex(); >+ >+ markers = [marker, createLocationMarker()]; >+ right = parseUnaryExpression(); >+ >+ stack = [left, token, right]; >+ >+ while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) { >+ >+ // Reduce: make a binary expression from the three topmost entries. >+ while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { >+ right = stack.pop(); >+ operator = stack.pop().value; >+ left = stack.pop(); >+ expr = delegate.createBinaryExpression(operator, left, right); >+ markers.pop(); >+ marker = markers.pop(); >+ if (marker) { >+ marker.end(); >+ marker.apply(expr); >+ } >+ stack.push(expr); >+ markers.push(marker); >+ } >+ >+ // Shift. >+ token = lex(); >+ token.prec = prec; >+ stack.push(token); >+ markers.push(createLocationMarker()); >+ expr = parseUnaryExpression(); >+ stack.push(expr); >+ } >+ >+ // Final reduce to clean-up the stack. >+ i = stack.length - 1; >+ expr = stack[i]; >+ markers.pop(); >+ while (i > 1) { >+ expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr); >+ i -= 2; >+ marker = markers.pop(); >+ if (marker) { >+ marker.end(); >+ marker.apply(expr); >+ } >+ } >+ >+ return expr; >+ } >+ >+ >+ // 11.12 Conditional Operator >+ >+ function parseConditionalExpression() { >+ var expr, previousAllowIn, consequent, alternate; >+ >+ delegate.markStart(); >+ expr = parseBinaryExpression(); >+ >+ if (match('?')) { >+ lex(); >+ previousAllowIn = state.allowIn; >+ state.allowIn = true; >+ consequent = parseAssignmentExpression(); >+ state.allowIn = previousAllowIn; >+ expect(':'); >+ alternate = parseAssignmentExpression(); >+ >+ expr = delegate.markEnd(delegate.createConditionalExpression(expr, consequent, alternate)); >+ } else { >+ delegate.markEnd({}); >+ } >+ >+ return expr; >+ } >+ >+ // 11.13 Assignment Operators >+ >+ function parseAssignmentExpression() { >+ var token, left, right, node; >+ >+ token = lookahead; >+ delegate.markStart(); >+ node = left = parseConditionalExpression(); >+ >+ if (matchAssign()) { >+ // LeftHandSideExpression >+ if (!isLeftHandSide(left)) { >+ throwErrorTolerant({}, Messages.InvalidLHSInAssignment); >+ } >+ >+ // 11.13.1 >+ if (strict && left.type === Syntax.Identifier && isRestrictedWord(left.name)) { >+ throwErrorTolerant(token, Messages.StrictLHSAssignment); >+ } >+ >+ token = lex(); >+ right = parseAssignmentExpression(); >+ node = delegate.createAssignmentExpression(token.value, left, right); >+ } >+ >+ return delegate.markEndIf(node); >+ } >+ >+ // 11.14 Comma Operator >+ >+ function parseExpression() { >+ var expr; >+ >+ delegate.markStart(); >+ expr = parseAssignmentExpression(); >+ >+ if (match(',')) { >+ expr = delegate.createSequenceExpression([ expr ]); >+ >+ while (index < length) { >+ if (!match(',')) { >+ break; >+ } >+ lex(); >+ expr.expressions.push(parseAssignmentExpression()); >+ } >+ } >+ >+ return delegate.markEndIf(expr); >+ } >+ >+ // 12.1 Block >+ >+ function parseStatementList() { >+ var list = [], >+ statement; >+ >+ while (index < length) { >+ if (match('}')) { >+ break; >+ } >+ statement = parseSourceElement(); >+ if (typeof statement === 'undefined') { >+ break; >+ } >+ list.push(statement); >+ } >+ >+ return list; >+ } >+ >+ function parseBlock() { >+ var block; >+ >+ skipComment(); >+ delegate.markStart(); >+ expect('{'); >+ >+ block = parseStatementList(); >+ >+ // mamacdon 853a9865 >+ // @ 1.0.0 esprima.js:2204 >+ //expect('}'); >+ expectConditionCloseBracketWrapThrow(); >+ >+ return delegate.markEnd(delegate.createBlockStatement(block)); >+ } >+ >+ // 12.2 Variable Statement >+ >+ function parseVariableIdentifier() { >+ var token; >+ >+ skipComment(); >+ delegate.markStart(); >+ token = lex(); >+ >+ if (token.type !== Token.Identifier) { >+ throwUnexpected(token); >+ } >+ >+ return delegate.markEnd(delegate.createIdentifier(token.value)); >+ } >+ >+ function parseVariableDeclaration(kind) { >+ var init = null, id; >+ >+ skipComment(); >+ delegate.markStart(); >+ id = parseVariableIdentifier(); >+ >+ // 12.2.1 >+ if (strict && isRestrictedWord(id.name)) { >+ throwErrorTolerant({}, Messages.StrictVarName); >+ } >+ >+ if (kind === 'const') { >+ expect('='); >+ init = parseAssignmentExpression(); >+ } else if (match('=')) { >+ lex(); >+ init = parseAssignmentExpression(); >+ } >+ >+ return delegate.markEnd(delegate.createVariableDeclarator(id, init)); >+ } >+ >+ function parseVariableDeclarationList(kind) { >+ var list = []; >+ >+ do { >+ list.push(parseVariableDeclaration(kind)); >+ if (!match(',')) { >+ break; >+ } >+ lex(); >+ } while (index < length); >+ >+ return list; >+ } >+ >+ function parseVariableStatement() { >+ var declarations; >+ >+ expectKeyword('var'); >+ >+ declarations = parseVariableDeclarationList(); >+ >+ consumeSemicolon(); >+ >+ return delegate.createVariableDeclaration(declarations, 'var'); >+ } >+ >+ // kind may be `const` or `let` >+ // Both are experimental and not in the specification yet. >+ // see http://wiki.ecmascript.org/doku.php?id=harmony:const >+ // and http://wiki.ecmascript.org/doku.php?id=harmony:let >+ function parseConstLetDeclaration(kind) { >+ var declarations; >+ >+ skipComment(); >+ delegate.markStart(); >+ >+ expectKeyword(kind); >+ >+ declarations = parseVariableDeclarationList(kind); >+ >+ consumeSemicolon(); >+ >+ return delegate.markEnd(delegate.createVariableDeclaration(declarations, kind)); >+ } >+ >+ // 12.3 Empty Statement >+ >+ function parseEmptyStatement() { >+ expect(';'); >+ return delegate.createEmptyStatement(); >+ } >+ >+ // 12.4 Expression Statement >+ >+ function parseExpressionStatement() { >+ var expr = parseExpression(); >+ consumeSemicolon(); >+ return delegate.createExpressionStatement(expr); >+ } >+ >+ // 12.5 If statement >+ >+ function parseIfStatement() { >+ >+ var test, consequent, alternate; >+ >+ expectKeyword('if'); >+ >+ expect('('); >+ >+ test = parseExpression(); >+ >+ // mamacdon 853a9865 >+ //expect(')'); >+ expectConditionCloseParenWrapThrow(); >+ >+ consequent = parseStatement(); >+ // mamacdon 853a9865: required because of the check in wrapTracking that returns nothing if node is undefined >+ // TODO: delegate handles tracking now, check if this test is still needed >+ if (!consequent) { >+ consequent = null; >+ } >+ if (matchKeyword('else')) { >+ lex(); >+ alternate = parseStatement(); >+ } else { >+ alternate = null; >+ } >+ >+ return delegate.createIfStatement(test, consequent, alternate); >+ } >+ >+ // 12.6 Iteration Statements >+ >+ function parseDoWhileStatement() { >+ var body, test, oldInIteration; >+ >+ expectKeyword('do'); >+ >+ oldInIteration = state.inIteration; >+ state.inIteration = true; >+ >+ body = parseStatement(); >+ >+ state.inIteration = oldInIteration; >+ >+ expectKeyword('while'); >+ >+ expect('('); >+ >+ test = parseExpression(); >+ >+ expect(')'); >+ >+ if (match(';')) { >+ lex(); >+ } >+ >+ return delegate.createDoWhileStatement(body, test); >+ } >+ >+ function parseWhileStatement() { >+ var test, body, oldInIteration; >+ >+ expectKeyword('while'); >+ >+ expect('('); >+ >+ test = parseExpression(); >+ >+ // mamacdon 853a9865 >+ //expect(')'); >+ expectConditionCloseParenWrapThrow(); >+ >+ oldInIteration = state.inIteration; >+ state.inIteration = true; >+ >+ body = parseStatement(); >+ >+ state.inIteration = oldInIteration; >+ >+ return delegate.createWhileStatement(test, body); >+ } >+ >+ function parseForVariableDeclaration() { >+ var token, declarations; >+ >+ delegate.markStart(); >+ token = lex(); >+ declarations = parseVariableDeclarationList(); >+ >+ return delegate.markEnd(delegate.createVariableDeclaration(declarations, token.value)); >+ } >+ >+ function parseForStatement() { >+ var init, test, update, left, right, body, oldInIteration; >+ >+ init = test = update = null; >+ >+ expectKeyword('for'); >+ >+ expect('('); >+ >+ if (match(';')) { >+ lex(); >+ } else { >+ if (matchKeyword('var') || matchKeyword('let')) { >+ state.allowIn = false; >+ init = parseForVariableDeclaration(); >+ state.allowIn = true; >+ >+ if (init.declarations.length === 1 && matchKeyword('in')) { >+ lex(); >+ left = init; >+ right = parseExpression(); >+ init = null; >+ } >+ } else { >+ state.allowIn = false; >+ init = parseExpression(); >+ state.allowIn = true; >+ >+ if (matchKeyword('in')) { >+ // LeftHandSideExpression >+ if (!isLeftHandSide(init)) { >+ throwErrorTolerant({}, Messages.InvalidLHSInForIn); >+ } >+ >+ lex(); >+ left = init; >+ right = parseExpression(); >+ init = null; >+ } >+ } >+ >+ if (typeof left === 'undefined') { >+ expect(';'); >+ } >+ } >+ >+ if (typeof left === 'undefined') { >+ >+ if (!match(';')) { >+ test = parseExpression(); >+ } >+ expect(';'); >+ >+ if (!match(')')) { >+ update = parseExpression(); >+ } >+ } >+ >+ // mamacdon 853a9865 >+ //expect(')'); >+ expectConditionCloseParenWrapThrow(); >+ >+ oldInIteration = state.inIteration; >+ state.inIteration = true; >+ >+ body = parseStatement(); >+ >+ state.inIteration = oldInIteration; >+ >+ return (typeof left === 'undefined') ? >+ delegate.createForStatement(init, test, update, body) : >+ delegate.createForInStatement(left, right, body); >+ } >+ >+ // 12.7 The continue statement >+ >+ function parseContinueStatement() { >+ var label = null, key; >+ >+ expectKeyword('continue'); >+ >+ // Optimize the most common form: 'continue;'. >+ if (source.charCodeAt(index) === 59) { >+ lex(); >+ >+ if (!state.inIteration) { >+ throwError({}, Messages.IllegalContinue); >+ } >+ >+ return delegate.createContinueStatement(null); >+ } >+ >+ if (peekLineTerminator()) { >+ if (!state.inIteration) { >+ throwError({}, Messages.IllegalContinue); >+ } >+ >+ return delegate.createContinueStatement(null); >+ } >+ >+ if (lookahead.type === Token.Identifier) { >+ label = parseVariableIdentifier(); >+ >+ key = '$' + label.name; >+ if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { >+ throwError({}, Messages.UnknownLabel, label.name); >+ } >+ } >+ >+ consumeSemicolon(); >+ >+ if (label === null && !state.inIteration) { >+ throwError({}, Messages.IllegalContinue); >+ } >+ >+ return delegate.createContinueStatement(label); >+ } >+ >+ // 12.8 The break statement >+ >+ function parseBreakStatement() { >+ var label = null, key; >+ >+ expectKeyword('break'); >+ >+ // Catch the very common case first: immediately a semicolon (char #59). >+ if (source.charCodeAt(index) === 59) { >+ lex(); >+ >+ if (!(state.inIteration || state.inSwitch)) { >+ throwError({}, Messages.IllegalBreak); >+ } >+ >+ return delegate.createBreakStatement(null); >+ } >+ >+ if (peekLineTerminator()) { >+ if (!(state.inIteration || state.inSwitch)) { >+ throwError({}, Messages.IllegalBreak); >+ } >+ >+ return delegate.createBreakStatement(null); >+ } >+ >+ if (lookahead.type === Token.Identifier) { >+ label = parseVariableIdentifier(); >+ >+ key = '$' + label.name; >+ if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { >+ throwError({}, Messages.UnknownLabel, label.name); >+ } >+ } >+ >+ consumeSemicolon(); >+ >+ if (label === null && !(state.inIteration || state.inSwitch)) { >+ throwError({}, Messages.IllegalBreak); >+ } >+ >+ return delegate.createBreakStatement(label); >+ } >+ >+ // 12.9 The return statement >+ >+ function parseReturnStatement() { >+ var argument = null; >+ >+ expectKeyword('return'); >+ >+ if (!state.inFunctionBody) { >+ throwErrorTolerant({}, Messages.IllegalReturn); >+ } >+ >+ // 'return' followed by a space and an identifier is very common. >+ if (source.charCodeAt(index) === 32) { >+ if (isIdentifierStart(source.charCodeAt(index + 1))) { >+ argument = parseExpression(); >+ consumeSemicolon(); >+ return delegate.createReturnStatement(argument); >+ } >+ } >+ >+ if (peekLineTerminator()) { >+ return delegate.createReturnStatement(null); >+ } >+ >+ if (!match(';')) { >+ if (!match('}') && lookahead.type !== Token.EOF) { >+ argument = parseExpression(); >+ } >+ } >+ >+ consumeSemicolon(); >+ >+ return delegate.createReturnStatement(argument); >+ } >+ >+ // 12.10 The with statement >+ >+ function parseWithStatement() { >+ var object, body; >+ >+ if (strict) { >+ throwErrorTolerant({}, Messages.StrictModeWith); >+ } >+ >+ expectKeyword('with'); >+ >+ expect('('); >+ >+ object = parseExpression(); >+ >+ expect(')'); >+ >+ body = parseStatement(); >+ >+ return delegate.createWithStatement(object, body); >+ } >+ >+ // 12.10 The swith statement >+ >+ function parseSwitchCase() { >+ var test, >+ consequent = [], >+ statement; >+ >+ skipComment(); >+ delegate.markStart(); >+ if (matchKeyword('default')) { >+ lex(); >+ test = null; >+ } else { >+ expectKeyword('case'); >+ test = parseExpression(); >+ } >+ expect(':'); >+ >+ while (index < length) { >+ if (match('}') || matchKeyword('default') || matchKeyword('case')) { >+ break; >+ } >+ statement = parseStatement(); >+ consequent.push(statement); >+ } >+ >+ return delegate.markEnd(delegate.createSwitchCase(test, consequent)); >+ } >+ >+ function parseSwitchStatement() { >+ var discriminant, cases, clause, oldInSwitch, defaultFound; >+ >+ expectKeyword('switch'); >+ >+ expect('('); >+ >+ discriminant = parseExpression(); >+ >+ expect(')'); >+ >+ expect('{'); >+ >+ cases = []; >+ >+ if (match('}')) { >+ lex(); >+ return delegate.createSwitchStatement(discriminant, cases); >+ } >+ >+ oldInSwitch = state.inSwitch; >+ state.inSwitch = true; >+ defaultFound = false; >+ >+ while (index < length) { >+ if (match('}')) { >+ break; >+ } >+ clause = parseSwitchCase(); >+ if (clause.test === null) { >+ if (defaultFound) { >+ throwError({}, Messages.MultipleDefaultsInSwitch); >+ } >+ defaultFound = true; >+ } >+ cases.push(clause); >+ } >+ >+ state.inSwitch = oldInSwitch; >+ >+ expect('}'); >+ >+ return delegate.createSwitchStatement(discriminant, cases); >+ } >+ >+ // 12.13 The throw statement >+ >+ function parseThrowStatement() { >+ var argument; >+ >+ expectKeyword('throw'); >+ >+ if (peekLineTerminator()) { >+ throwError({}, Messages.NewlineAfterThrow); >+ } >+ >+ argument = parseExpression(); >+ >+ consumeSemicolon(); >+ >+ return delegate.createThrowStatement(argument); >+ } >+ >+ // 12.14 The try statement >+ >+ function parseCatchClause() { >+ var param, body; >+ >+ skipComment(); >+ delegate.markStart(); >+ expectKeyword('catch'); >+ >+ expect('('); >+ if (match(')')) { >+ throwUnexpected(lookahead); >+ } >+ >+ param = parseVariableIdentifier(); >+ // 12.14.1 >+ if (strict && isRestrictedWord(param.name)) { >+ throwErrorTolerant({}, Messages.StrictCatchVariable); >+ } >+ >+ expect(')'); >+ body = parseBlock(); >+ return delegate.markEnd(delegate.createCatchClause(param, body)); >+ } >+ >+ function parseTryStatement() { >+ var block, handlers = [], finalizer = null; >+ >+ expectKeyword('try'); >+ >+ block = parseBlock(); >+ >+ if (matchKeyword('catch')) { >+ handlers.push(parseCatchClause()); >+ } >+ >+ if (matchKeyword('finally')) { >+ lex(); >+ finalizer = parseBlock(); >+ } >+ >+ if (handlers.length === 0 && !finalizer) { >+ throwError({}, Messages.NoCatchOrFinally); >+ } >+ >+ return delegate.createTryStatement(block, [], handlers, finalizer); >+ } >+ >+ // 12.15 The debugger statement >+ >+ function parseDebuggerStatement() { >+ expectKeyword('debugger'); >+ >+ consumeSemicolon(); >+ >+ return delegate.createDebuggerStatement(); >+ } >+ >+ // 12 Statements >+ >+ function parseStatement() { >+ var type = lookahead.type, >+ expr, >+ labeledBody, >+ key; >+ >+ if (type === Token.EOF) { >+ throwUnexpected(lookahead); >+ } >+ >+ skipComment(); >+ delegate.markStart(); >+ >+ if (type === Token.Punctuator) { >+ switch (lookahead.value) { >+ case ';': >+ return delegate.markEnd(parseEmptyStatement()); >+ case '{': >+ return delegate.markEnd(parseBlock()); >+ case '(': >+ return delegate.markEnd(parseExpressionStatement()); >+ default: >+ break; >+ } >+ } >+ >+ if (type === Token.Keyword) { >+ switch (lookahead.value) { >+ case 'break': >+ return delegate.markEnd(parseBreakStatement()); >+ case 'continue': >+ return delegate.markEnd(parseContinueStatement()); >+ case 'debugger': >+ return delegate.markEnd(parseDebuggerStatement()); >+ case 'do': >+ return delegate.markEnd(parseDoWhileStatement()); >+ case 'for': >+ return delegate.markEnd(parseForStatement()); >+ case 'function': >+ return delegate.markEnd(parseFunctionDeclaration()); >+ case 'if': >+ return delegate.markEnd(parseIfStatement()); >+ case 'return': >+ return delegate.markEnd(parseReturnStatement()); >+ case 'switch': >+ return delegate.markEnd(parseSwitchStatement()); >+ case 'throw': >+ return delegate.markEnd(parseThrowStatement()); >+ case 'try': >+ return delegate.markEnd(parseTryStatement()); >+ case 'var': >+ return delegate.markEnd(parseVariableStatement()); >+ case 'while': >+ return delegate.markEnd(parseWhileStatement()); >+ case 'with': >+ return delegate.markEnd(parseWithStatement()); >+ default: >+ break; >+ } >+ } >+ >+ expr = parseExpression(); >+ >+ // 12.12 Labelled Statements >+ if (expr && (expr.type === Syntax.Identifier) && match(':')) { // mamacdon 1420b19 >+ lex(); >+ >+ key = '$' + expr.name; >+ if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) { >+ throwError({}, Messages.Redeclaration, 'Label', expr.name); >+ } >+ >+ state.labelSet[key] = true; >+ labeledBody = parseStatement(); >+ delete state.labelSet[key]; >+ return delegate.markEnd(delegate.createLabeledStatement(expr, labeledBody)); >+ } >+ >+ consumeSemicolon(); >+ >+ return delegate.markEnd(delegate.createExpressionStatement(expr)); >+ } >+ >+ // 13 Function Definition >+ >+ function parseFunctionSourceElements() { >+ var sourceElement, sourceElements = [], token, directive, firstRestricted, >+ oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody; >+ >+ skipComment(); >+ delegate.markStart(); >+ expect('{'); >+ >+ while (index < length) { >+ if (lookahead.type !== Token.StringLiteral) { >+ break; >+ } >+ token = lookahead; >+ >+ sourceElement = parseSourceElement(); >+ sourceElements.push(sourceElement); >+ if (sourceElement.expression.type !== Syntax.Literal) { >+ // this is not directive >+ break; >+ } >+ directive = source.slice(token.range[0] + 1, token.range[1] - 1); >+ if (directive === 'use strict') { >+ strict = true; >+ if (firstRestricted) { >+ throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); >+ } >+ } else { >+ if (!firstRestricted && token.octal) { >+ firstRestricted = token; >+ } >+ } >+ } >+ >+ oldLabelSet = state.labelSet; >+ oldInIteration = state.inIteration; >+ oldInSwitch = state.inSwitch; >+ oldInFunctionBody = state.inFunctionBody; >+ >+ state.labelSet = {}; >+ state.inIteration = false; >+ state.inSwitch = false; >+ state.inFunctionBody = true; >+ >+ while (index < length) { >+ if (match('}')) { >+ break; >+ } >+ sourceElement = parseSourceElement(); >+ if (typeof sourceElement === 'undefined') { >+ break; >+ } >+ sourceElements.push(sourceElement); >+ } >+ >+ // mamacdon 853a986 >+ //expect('}'); >+ expectConditionCloseBracketWrapThrow(); >+ >+ state.labelSet = oldLabelSet; >+ state.inIteration = oldInIteration; >+ state.inSwitch = oldInSwitch; >+ state.inFunctionBody = oldInFunctionBody; >+ >+ return delegate.markEnd(delegate.createBlockStatement(sourceElements)); >+ } >+ >+ function parseParams(firstRestricted) { >+ var param, params = [], token, stricted, paramSet, key, message; >+ expect('('); >+ >+ if (!match(')')) { >+ paramSet = {}; >+ while (index < length) { >+ token = lookahead; >+ param = parseVariableIdentifier(); >+ key = '$' + token.value; >+ if (strict) { >+ if (isRestrictedWord(token.value)) { >+ stricted = token; >+ message = Messages.StrictParamName; >+ } >+ if (Object.prototype.hasOwnProperty.call(paramSet, key)) { >+ stricted = token; >+ message = Messages.StrictParamDupe; >+ } >+ } else if (!firstRestricted) { >+ if (isRestrictedWord(token.value)) { >+ firstRestricted = token; >+ message = Messages.StrictParamName; >+ } else if (isStrictModeReservedWord(token.value)) { >+ firstRestricted = token; >+ message = Messages.StrictReservedWord; >+ } else if (Object.prototype.hasOwnProperty.call(paramSet, key)) { >+ firstRestricted = token; >+ message = Messages.StrictParamDupe; >+ } >+ } >+ params.push(param); >+ paramSet[key] = true; >+ if (match(')')) { >+ break; >+ } >+ expect(','); >+ } >+ } >+ >+ expect(')'); >+ >+ return { >+ params: params, >+ stricted: stricted, >+ firstRestricted: firstRestricted, >+ message: message >+ }; >+ } >+ >+ function parseFunctionDeclaration() { >+ var id, params = [], body, token, stricted, tmp, firstRestricted, message, previousStrict; >+ >+ skipComment(); >+ delegate.markStart(); >+ >+ expectKeyword('function'); >+ token = lookahead; >+ id = parseVariableIdentifier(); >+ if (strict) { >+ if (isRestrictedWord(token.value)) { >+ throwErrorTolerant(token, Messages.StrictFunctionName); >+ } >+ } else { >+ if (isRestrictedWord(token.value)) { >+ firstRestricted = token; >+ message = Messages.StrictFunctionName; >+ } else if (isStrictModeReservedWord(token.value)) { >+ firstRestricted = token; >+ message = Messages.StrictReservedWord; >+ } >+ } >+ >+ tmp = parseParams(firstRestricted); >+ params = tmp.params; >+ stricted = tmp.stricted; >+ firstRestricted = tmp.firstRestricted; >+ if (tmp.message) { >+ message = tmp.message; >+ } >+ >+ previousStrict = strict; >+ body = parseFunctionSourceElements(); >+ if (strict && firstRestricted) { >+ throwError(firstRestricted, message); >+ } >+ if (strict && stricted) { >+ throwErrorTolerant(stricted, message); >+ } >+ strict = previousStrict; >+ >+ return delegate.markEnd(delegate.createFunctionDeclaration(id, params, [], body)); >+ } >+ >+ function parseFunctionExpression() { >+ var token, id = null, stricted, firstRestricted, message, tmp, params = [], body, previousStrict; >+ >+ delegate.markStart(); >+ expectKeyword('function'); >+ >+ if (!match('(')) { >+ token = lookahead; >+ id = parseVariableIdentifier(); >+ if (strict) { >+ if (isRestrictedWord(token.value)) { >+ throwErrorTolerant(token, Messages.StrictFunctionName); >+ } >+ } else { >+ if (isRestrictedWord(token.value)) { >+ firstRestricted = token; >+ message = Messages.StrictFunctionName; >+ } else if (isStrictModeReservedWord(token.value)) { >+ firstRestricted = token; >+ message = Messages.StrictReservedWord; >+ } >+ } >+ } >+ >+ tmp = parseParams(firstRestricted); >+ params = tmp.params; >+ stricted = tmp.stricted; >+ firstRestricted = tmp.firstRestricted; >+ if (tmp.message) { >+ message = tmp.message; >+ } >+ >+ previousStrict = strict; >+ body = parseFunctionSourceElements(); >+ if (strict && firstRestricted) { >+ throwError(firstRestricted, message); >+ } >+ if (strict && stricted) { >+ throwErrorTolerant(stricted, message); >+ } >+ strict = previousStrict; >+ >+ return delegate.markEnd(delegate.createFunctionExpression(id, params, [], body)); >+ } >+ >+ // 14 Program >+ >+ function parseSourceElement() { >+ if (lookahead.type === Token.Keyword) { >+ switch (lookahead.value) { >+ case 'const': >+ case 'let': >+ return parseConstLetDeclaration(lookahead.value); >+ case 'function': >+ return parseFunctionDeclaration(); >+ default: >+ return parseStatement(); >+ } >+ } >+ >+ if (lookahead.type !== Token.EOF) { >+ return parseStatement(); >+ } >+ } >+ >+ function parseSourceElements() { >+ var sourceElement, sourceElements = [], token, directive, firstRestricted; >+ >+ while (index < length) { >+ token = lookahead; >+ if (token.type !== Token.StringLiteral) { >+ break; >+ } >+ >+ sourceElement = parseSourceElement(); >+ sourceElements.push(sourceElement); >+ if (sourceElement.expression.type !== Syntax.Literal) { >+ // this is not directive >+ break; >+ } >+ directive = source.slice(token.range[0] + 1, token.range[1] - 1); >+ if (directive === 'use strict') { >+ strict = true; >+ if (firstRestricted) { >+ throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); >+ } >+ } else { >+ if (!firstRestricted && token.octal) { >+ firstRestricted = token; >+ } >+ } >+ } >+ >+ while (index < length) { >+ sourceElement = parseSourceElement(); >+ if (typeof sourceElement === 'undefined') { >+ break; >+ } >+ sourceElements.push(sourceElement); >+ } >+ return sourceElements; >+ } >+ >+ function parseProgram() { >+ var body; >+ >+ skipComment(); >+ delegate.markStart(); >+ strict = false; >+ peek(); >+ body = parseSourceElements(); >+ return delegate.markEnd(delegate.createProgram(body)); >+ } >+ >+ function attachComments() { >+ var i, attacher, comment, leading, trailing; >+ >+ for (i = 0; i < extra.pendingComments.length; ++i) { >+ attacher = extra.pendingComments[i]; >+ comment = attacher.comment; >+ leading = attacher.leading; >+ if (leading) { >+ if (typeof leading.leadingComments === 'undefined') { >+ leading.leadingComments = []; >+ } >+ leading.leadingComments.push(attacher.comment); >+ } >+ trailing = attacher.trailing; >+ if (trailing) { >+ if (typeof trailing.trailingComments === 'undefined') { >+ trailing.trailingComments = []; >+ } >+ trailing.trailingComments.push(attacher.comment); >+ } >+ } >+ extra.pendingComments = []; >+ } >+ >+ function filterTokenLocation() { >+ var i, entry, token, tokens = []; >+ >+ for (i = 0; i < extra.tokens.length; ++i) { >+ entry = extra.tokens[i]; >+ token = { >+ type: entry.type, >+ value: entry.value >+ }; >+ if (extra.range) { >+ token.range = entry.range; >+ } >+ if (extra.loc) { >+ token.loc = entry.loc; >+ } >+ tokens.push(token); >+ } >+ >+ extra.tokens = tokens; >+ } >+ >+ function LocationMarker() { >+ this.marker = [index, lineNumber, index - lineStart, 0, 0, 0]; >+ } >+ >+ LocationMarker.prototype = { >+ constructor: LocationMarker, >+ >+ end: function () { >+ this.marker[3] = index; >+ this.marker[4] = lineNumber; >+ this.marker[5] = index - lineStart; >+ }, >+ >+ apply: function (node) { >+ if (extra.range) { >+ node.range = [this.marker[0], this.marker[3]]; >+ } >+ if (extra.loc) { >+ node.loc = { >+ start: { >+ line: this.marker[1], >+ column: this.marker[2] >+ }, >+ end: { >+ line: this.marker[4], >+ column: this.marker[5] >+ } >+ }; >+ node = delegate.postProcess(node); >+ } >+ if (extra.attachComment) { >+ delegate.processComment(node); >+ } >+ } >+ }; >+ >+ function createLocationMarker() { >+ if (!extra.loc && !extra.range) { >+ return null; >+ } >+ >+ skipComment(); >+ >+ return new LocationMarker(); >+ } >+ >+ function tokenize(code, options) { >+ var toString, >+ token, >+ tokens; >+ >+ toString = String; >+ if (typeof code !== 'string' && !(code instanceof String)) { >+ code = toString(code); >+ } >+ >+ delegate = SyntaxTreeDelegate; >+ source = code; >+ index = 0; >+ lineNumber = (source.length > 0) ? 1 : 0; >+ lineStart = 0; >+ length = source.length; >+ lookahead = null; >+ state = { >+ allowIn: true, >+ labelSet: {}, >+ inFunctionBody: false, >+ inIteration: false, >+ inSwitch: false, >+ lastCommentStart: -1 >+ }; >+ >+ extra = {}; >+ >+ // Options matching. >+ options = options || {}; >+ >+ // Of course we collect tokens here. >+ options.tokens = true; >+ extra.tokens = []; >+ extra.tokenize = true; >+ // The following two fields are necessary to compute the Regex tokens. >+ extra.openParenToken = -1; >+ extra.openCurlyToken = -1; >+ >+ extra.range = (typeof options.range === 'boolean') && options.range; >+ extra.loc = (typeof options.loc === 'boolean') && options.loc; >+ >+ if (typeof options.comment === 'boolean' && options.comment) { >+ extra.comments = []; >+ } >+ if (typeof options.tolerant === 'boolean' && options.tolerant) { >+ extra.errors = []; >+ } >+ >+ if (length > 0) { >+ if (typeof source[0] === 'undefined') { >+ // Try first to convert to a string. This is good as fast path >+ // for old IE which understands string indexing for string >+ // literals only and not for string object. >+ if (code instanceof String) { >+ source = code.valueOf(); >+ } >+ } >+ } >+ >+ try { >+ peek(); >+ if (lookahead.type === Token.EOF) { >+ return extra.tokens; >+ } >+ >+ token = lex(); >+ while (lookahead.type !== Token.EOF) { >+ try { >+ token = lex(); >+ } catch (lexError) { >+ token = lookahead; >+ if (extra.errors) { >+ extra.errors.push(lexError); >+ // We have to break on the first error >+ // to avoid infinite loops. >+ break; >+ } else { >+ throw lexError; >+ } >+ } >+ } >+ >+ filterTokenLocation(); >+ tokens = extra.tokens; >+ if (typeof extra.comments !== 'undefined') { >+ tokens.comments = extra.comments; >+ } >+ if (typeof extra.errors !== 'undefined') { >+ tokens.errors = extra.errors; >+ } >+ } catch (e) { >+ throw e; >+ } finally { >+ extra = {}; >+ } >+ return tokens; >+ } >+ >+ function parse(code, options) { >+ var program, toString; >+ >+ toString = String; >+ if (typeof code !== 'string' && !(code instanceof String)) { >+ code = toString(code); >+ } >+ >+ delegate = SyntaxTreeDelegate; >+ source = code; >+ index = 0; >+ lineNumber = (source.length > 0) ? 1 : 0; >+ lineStart = 0; >+ length = source.length; >+ lookahead = null; >+ state = { >+ allowIn: true, >+ labelSet: {}, >+ inFunctionBody: false, >+ inIteration: false, >+ inSwitch: false, >+ lastCommentStart: -1, >+ markerStack: [] >+ }; >+ >+ extra = {}; >+ if (typeof options !== 'undefined') { >+ extra.range = (typeof options.range === 'boolean') && options.range; >+ extra.loc = (typeof options.loc === 'boolean') && options.loc; >+ extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; >+ >+ if (extra.loc && options.source !== null && options.source !== undefined) { >+ extra.source = toString(options.source); >+ } >+ >+ if (typeof options.tokens === 'boolean' && options.tokens) { >+ extra.tokens = []; >+ } >+ if (typeof options.comment === 'boolean' && options.comment) { >+ extra.comments = []; >+ } >+ if (typeof options.tolerant === 'boolean' && options.tolerant) { >+ extra.errors = []; >+ >+ // mamacdon patch >+ extra.parseStatement = parseStatement; >+ extra.parseExpression = parseExpression; >+ extra.parseNonComputedProperty = parseNonComputedProperty; >+ extra.consumeSemicolon = consumeSemicolon; >+ >+ parseStatement = wrapThrowParseStatement(parseStatement); // Note special case >+ parseExpression = wrapThrow(parseExpression); >+ // this enables 'foo.<EOF>' to return something >+ parseNonComputedProperty = wrapThrow(parseNonComputedProperty); >+ consumeSemicolon = wrapThrow(consumeSemicolon); >+ } >+ if (extra.attachComment) { >+ extra.range = true; >+ extra.pendingComments = []; >+ extra.comments = []; >+ } >+ } >+ >+ if (length > 0) { >+ if (typeof source[0] === 'undefined') { >+ // Try first to convert to a string. This is good as fast path >+ // for old IE which understands string indexing for string >+ // literals only and not for string object. >+ if (code instanceof String) { >+ source = code.valueOf(); >+ } >+ } >+ } >+ >+ try { >+ program = parseProgram(); >+ if (typeof extra.comments !== 'undefined') { >+ program.comments = extra.comments; >+ } >+ if (typeof extra.tokens !== 'undefined') { >+ filterTokenLocation(); >+ program.tokens = extra.tokens; >+ } >+ if (typeof extra.errors !== 'undefined') { >+ program.errors = extra.errors; >+ } >+ if (extra.attachComment) { >+ attachComments(); >+ } >+ } catch (e) { >+ throw e; >+ } finally { >+ // mamacdon unpatch >+ parseStatement = extra.parseStatement; >+ parseExpression = extra.parseExpression; >+ parseNonComputedProperty = extra.parseNonComputedProperty; >+ consumeSemicolon = extra.consumeSemicolon; >+ >+ extra = {}; >+ } >+ >+ return program; >+ } >+ >+ /** >+ * @name expectConditionCloseBracketWrapThrow >+ * @description Gracefully handles a missing '}' if the mode is set to tolerant >+ * @function >+ * @private >+ * @since 5.0 >+ */ >+ function expectConditionCloseBracketWrapThrow() { >+ if (extra.errors) { >+ // continue parsing even with missing close >+ // brace. This gives a better AST for the >+ // block, as information about >+ // the parsed statements remain >+ try { >+ expect('}'); >+ } catch (e) { >+ pushError(e); >+ } >+ } else { >+ expect('}'); >+ } >+ } >+ >+ /** >+ * @name expectConditionCloseParenWrapThrow >+ * @description For statements like if, while, for, etc. check for the ')' on the condition. If >+ * it is not present, catch the error, and backtrack if we see a '{' instead (to continue parsing the block) >+ * @function >+ * @private >+ * @throws The original error from trying to consume the ')' char if not in tolerant mode >+ * @since 5.0 >+ */ >+ function expectConditionCloseParenWrapThrow() { >+ // needs generalizing to a 'expect A but don't consume if you hit B or C' >+ try { >+ expect(')'); >+ } catch (e) { >+ if (extra.errors) { >+ pushError(e); >+ // If a { was hit instead of a ) then don't consume it, let us assume a ')' was >+ // missed and the consequent block is OK >+ if (source[e.index] === '{') { >+ index=e.index; >+ lookahead = null; >+ // activating this block will mean the following statement is parsed as a consequent / body. >+ // without it the statement is considered not at all part of the enclosing statement at all >+ //} else { >+ // rewind(); >+ } >+ } else { >+ throw e; >+ } >+ } >+ } >+ // mamacdon 1420b19 >+ // @ 1.0.0 esprima.js:1609 >+ /** >+ * @name pushError >+ * @description Add the error if not already reported. >+ * @function >+ * @private >+ * @param {Object} error The error object to push >+ * @since 5.0 >+ */ >+ function pushError(error) { >+ var len = extra.errors.length; >+ for (var e=0; e < len; e++) { >+ var existingError = extra.errors[e]; >+ if (existingError.index === error.index && existingError.message === error.message) { >+ return; // do not add duplicate >+ } >+ } >+ extra.errors.push(error); >+ } > >- // TODO refactor >+ //Recovery >+ function wrapThrow(parseFunction) { >+ return function () { >+ try { >+ var initialHeight = state.markerStack.length; >+ return parseFunction.apply(null, arguments); >+ } catch (e) { >+ pushError(e); >+ // Clean up un-popped end markers from failed parse >+ while (state.markerStack.length > initialHeight) >+ delegate.markEndIf(null); >+ return null; >+ } >+ }; >+ } >+ >+ function wrapThrowParseStatement(parseFunction) { >+ return function () { >+ extra.statementStart = index; // record where attempting to parse statement from >+ try { >+ return parseFunction.apply(null, arguments); >+ } catch (e) { >+ pushError(e); >+// return null; // why is this commented out >+ } >+ }; >+ } >+ > /** >- * From a position 'idx' in the source this function moves back through the source until >+ * @name isNewlineOrSemicolon >+ * @description If the given char is the new line char or a semicolon char >+ * @function >+ * @private >+ * @param {String} ch The character to check >+ * @returns {Boolean} <code>true</code> if the char is a new line or semicolon <code>false</code> otherwise >+ * @since 5.0 >+ */ >+ function isNewlineOrSemicolon(ch) { >+ return ch===';' || ch==='\n'; >+ } >+ >+ /** >+ * @name rewind >+ * @descripton Rewind the lex position to the most recent newline or semicolon. If that turns out >+ * to be the same position as the most recent parsing of a statement was attempted at, >+ * don't rewind (because it will fail in the same way). If it turns out to be the same >+ * position as where we last rewound to, don't do it. Clears the buffer and sets the >+ * index in order to continue lexing from the new position. >+ * @function >+ * @private >+ * @since 5.0 >+ */ >+ function rewind() { >+ var idx = index; >+ while (idx>0 && !isNewlineOrSemicolon(source[idx])) { >+ idx--; >+ } >+ if (idx<=extra.statementStart) { >+ return; >+ } >+ var doRewind = false; >+ if (extra.lastRewindLocation) { >+ doRewind = true; >+ } else { >+ var v = extra.lastRewindLocation; >+ if (v!==idx) { >+ doRewind=true; >+ } >+ } >+ if (doRewind) { >+ index = idx; >+ peek(); // recalculate lookahead >+ extra.lastRewindLocation = index; >+ } >+ } >+ >+ // mamacdon 1420b19 >+ // @ 1.0.0 esprima.js:1661 >+ // TODO refactor >+ /** >+ * @name rewindToInterestingChar >+ * @description From a position 'idx' in the source this function moves back through the source until > * it finds a non-whitespace (including newlines) character. It will jump over block comments. > * Returns an object with properties: index - the index it rewound to. lineChange - boolean indicating > * if a line was crossed during rewind. >+ * @function >+ * @private >+ * @param {Number} idx The index to rewind to >+ * @returns {Object} Returns the object with the index and line change to rewind to >+ * @since 5.0 > */ > function rewindToInterestingChar(idx) { > var done = false; >@@ -1708,12 +4137,17 @@ > } > > /** >- * When a problem occurs in parseNonComputedProperty, attempt to reposition >+ * @name attemptRecoveryNonComputedProperty >+ * @description When a problem occurs in parseNonComputedProperty, attempt to reposition > * the lexer to continue processing. > * Example: '(foo.)' we will hit the ')' instead of discovering a property and consuming the ')' > * will cause the parse of the paretheses to fail, so 'unconsume' it. > * Basically rewind by one token if punctuation (type 7) is hit and the char before it was > * a dot. This will enable the enclosing parse rule to consume the punctuation. >+ * @function >+ * @private >+ * @param {String} token The token to try and recover from >+ * @since 5.0 > */ > function attemptRecoveryNonComputedProperty(token) { > if (token.value && token.type===Token.Punctuator) { >@@ -1727,2073 +4161,16 @@ > // do not recover in this case > } else if (ch==='.') { > index = idx+1; >- buffer=null; >+// lookahead=null; >+ peek(); // recalculate lookahead > } > } > } > >+ // Sync with *.json manifests. >+ exports.version = '1.1.0-dev'; > >- function parseNonComputedProperty() { >- var token = lex(); >- >- if (!isIdentifierName(token)) { >- if (extra.errors) { >- attemptRecoveryNonComputedProperty(token); >- } >- throwUnexpected(token); >- } >- >- return { >- type: Syntax.Identifier, >- name: token.value >- }; >- } >- >- function parseNonComputedMember(object) { >- return { >- type: Syntax.MemberExpression, >- computed: false, >- object: object, >- property: parseNonComputedProperty() >- }; >- } >- >- function parseComputedMember(object) { >- var property, expr; >- >- expect('['); >- property = parseExpression(); >- expr = { >- type: Syntax.MemberExpression, >- computed: true, >- object: object, >- property: property >- }; >- expect(']'); >- return expr; >- } >- >- function parseCallMember(object) { >- return { >- type: Syntax.CallExpression, >- callee: object, >- 'arguments': parseArguments() >- }; >- } >- >- function parseNewExpression() { >- var expr; >- >- expectKeyword('new'); >- >- expr = { >- type: Syntax.NewExpression, >- callee: parseLeftHandSideExpression(), >- 'arguments': [] >- }; >- >- if (match('(')) { >- expr['arguments'] = parseArguments(); >- } >- >- return expr; >- } >- >- function parseLeftHandSideExpressionAllowCall() { >- var useNew, expr; >- >- useNew = matchKeyword('new'); >- expr = useNew ? parseNewExpression() : parsePrimaryExpression(); >- >- while (index < length) { >- if (match('.')) { >- lex(); >- expr = parseNonComputedMember(expr); >- } else if (match('[')) { >- expr = parseComputedMember(expr); >- } else if (match('(')) { >- expr = parseCallMember(expr); >- } else { >- break; >- } >- } >- >- return expr; >- } >- >- function parseLeftHandSideExpression() { >- var useNew, expr; >- >- useNew = matchKeyword('new'); >- expr = useNew ? parseNewExpression() : parsePrimaryExpression(); >- >- while (index < length) { >- if (match('.')) { >- lex(); >- expr = parseNonComputedMember(expr); >- } else if (match('[')) { >- expr = parseComputedMember(expr); >- } else { >- break; >- } >- } >- >- return expr; >- } >- >- // 11.3 Postfix Expressions >- >- function parsePostfixExpression() { >- var expr = parseLeftHandSideExpressionAllowCall(); >- >- if ((match('++') || match('--')) && !peekLineTerminator()) { >- // 11.3.1, 11.3.2 >- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { >- throwError({}, Messages.StrictLHSPostfix); >- } >- expr = { >- type: Syntax.UpdateExpression, >- operator: lex().value, >- argument: expr, >- prefix: false >- }; >- } >- >- return expr; >- } >- >- // 11.4 Unary Operators >- >- function parseUnaryExpression() { >- var token, expr; >- >- if (match('++') || match('--')) { >- token = lex(); >- expr = parseUnaryExpression(); >- // 11.4.4, 11.4.5 >- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { >- throwError({}, Messages.StrictLHSPrefix); >- } >- expr = { >- type: Syntax.UpdateExpression, >- operator: token.value, >- argument: expr, >- prefix: true >- }; >- return expr; >- } >- >- if (match('+') || match('-') || match('~') || match('!')) { >- expr = { >- type: Syntax.UnaryExpression, >- operator: lex().value, >- argument: parseUnaryExpression() >- }; >- return expr; >- } >- >- if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { >- expr = { >- type: Syntax.UnaryExpression, >- operator: lex().value, >- argument: parseUnaryExpression() >- }; >- if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { >- throwErrorTolerant({}, Messages.StrictDelete); >- } >- return expr; >- } >- >- return parsePostfixExpression(); >- } >- >- // 11.5 Multiplicative Operators >- >- function parseMultiplicativeExpression() { >- var expr = parseUnaryExpression(); >- >- while (match('*') || match('/') || match('%')) { >- expr = { >- type: Syntax.BinaryExpression, >- operator: lex().value, >- left: expr, >- right: parseUnaryExpression() >- }; >- } >- >- return expr; >- } >- >- // 11.6 Additive Operators >- >- function parseAdditiveExpression() { >- var expr = parseMultiplicativeExpression(); >- >- while (match('+') || match('-')) { >- expr = { >- type: Syntax.BinaryExpression, >- operator: lex().value, >- left: expr, >- right: parseMultiplicativeExpression() >- }; >- } >- >- return expr; >- } >- >- // 11.7 Bitwise Shift Operators >- >- function parseShiftExpression() { >- var expr = parseAdditiveExpression(); >- >- while (match('<<') || match('>>') || match('>>>')) { >- expr = { >- type: Syntax.BinaryExpression, >- operator: lex().value, >- left: expr, >- right: parseAdditiveExpression() >- }; >- } >- >- return expr; >- } >- // 11.8 Relational Operators >- >- function parseRelationalExpression() { >- var expr, previousAllowIn; >- >- previousAllowIn = state.allowIn; >- state.allowIn = true; >- expr = parseShiftExpression(); >- state.allowIn = previousAllowIn; >- >- if (match('<') || match('>') || match('<=') || match('>=')) { >- expr = { >- type: Syntax.BinaryExpression, >- operator: lex().value, >- left: expr, >- right: parseRelationalExpression() >- }; >- } else if (state.allowIn && matchKeyword('in')) { >- lex(); >- expr = { >- type: Syntax.BinaryExpression, >- operator: 'in', >- left: expr, >- right: parseRelationalExpression() >- }; >- } else if (matchKeyword('instanceof')) { >- lex(); >- expr = { >- type: Syntax.BinaryExpression, >- operator: 'instanceof', >- left: expr, >- right: parseRelationalExpression() >- }; >- } >- >- return expr; >- } >- >- // 11.9 Equality Operators >- >- function parseEqualityExpression() { >- var expr = parseRelationalExpression(); >- >- while (match('==') || match('!=') || match('===') || match('!==')) { >- expr = { >- type: Syntax.BinaryExpression, >- operator: lex().value, >- left: expr, >- right: parseRelationalExpression() >- }; >- } >- >- return expr; >- } >- >- // 11.10 Binary Bitwise Operators >- >- function parseBitwiseANDExpression() { >- var expr = parseEqualityExpression(); >- >- while (match('&')) { >- lex(); >- expr = { >- type: Syntax.BinaryExpression, >- operator: '&', >- left: expr, >- right: parseEqualityExpression() >- }; >- } >- >- return expr; >- } >- >- function parseBitwiseORExpression() { >- var expr = parseBitwiseANDExpression(); >- >- while (match('|')) { >- lex(); >- expr = { >- type: Syntax.BinaryExpression, >- operator: '|', >- left: expr, >- right: parseBitwiseANDExpression() >- }; >- } >- >- return expr; >- } >- >- function parseBitwiseXORExpression() { >- var expr = parseBitwiseORExpression(); >- >- while (match('^')) { >- lex(); >- expr = { >- type: Syntax.BinaryExpression, >- operator: '^', >- left: expr, >- right: parseBitwiseORExpression() >- }; >- } >- >- return expr; >- } >- >- // 11.11 Binary Logical Operators >- >- function parseLogicalANDExpression() { >- var expr = parseBitwiseXORExpression(); >- >- while (match('&&')) { >- lex(); >- expr = { >- type: Syntax.LogicalExpression, >- operator: '&&', >- left: expr, >- right: parseBitwiseXORExpression() >- }; >- } >- >- return expr; >- } >- >- function parseLogicalORExpression() { >- var expr = parseLogicalANDExpression(); >- >- while (match('||')) { >- lex(); >- expr = { >- type: Syntax.LogicalExpression, >- operator: '||', >- left: expr, >- right: parseLogicalANDExpression() >- }; >- } >- >- return expr; >- } >- >- // 11.12 Conditional Operator >- >- function parseConditionalExpression() { >- var expr, previousAllowIn, consequent; >- >- expr = parseLogicalORExpression(); >- >- if (match('?')) { >- lex(); >- previousAllowIn = state.allowIn; >- state.allowIn = true; >- consequent = parseAssignmentExpression(); >- state.allowIn = previousAllowIn; >- expect(':'); >- >- expr = { >- type: Syntax.ConditionalExpression, >- test: expr, >- consequent: consequent, >- alternate: parseAssignmentExpression() >- }; >- } >- >- return expr; >- } >- >- // 11.13 Assignment Operators >- >- function parseAssignmentExpression() { >- var expr; >- >- expr = parseConditionalExpression(); >- >- if (matchAssign()) { >- // LeftHandSideExpression >- if (state.lastParenthesized !== expr && !isLeftHandSide(expr)) { >- throwError({}, Messages.InvalidLHSInAssignment); >- } >- >- // 11.13.1 >- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { >- throwError({}, Messages.StrictLHSAssignment); >- } >- >- expr = { >- type: Syntax.AssignmentExpression, >- operator: lex().value, >- left: expr, >- right: parseAssignmentExpression() >- }; >- } >- >- return expr; >- } >- >- // 11.14 Comma Operator >- >- function parseExpression() { >- var expr = parseAssignmentExpression(); >- >- if (match(',')) { >- expr = { >- type: Syntax.SequenceExpression, >- expressions: [ expr ] >- }; >- >- while (index < length) { >- if (!match(',')) { >- break; >- } >- lex(); >- expr.expressions.push(parseAssignmentExpression()); >- } >- >- } >- return expr; >- } >- >- // 12.1 Block >- >- function parseStatementList() { >- var list = [], >- statement; >- >- while (index < length) { >- if (match('}')) { >- break; >- } >- statement = parseSourceElement(); >- if (typeof statement === 'undefined') { >- break; >- } >- list.push(statement); >- } >- >- return list; >- } >- >- function parseBlock() { >- var block; >- >- expect('{'); >- >- block = parseStatementList(); >- >- //expect('}'); >- expectCloseBracketWrapThrow(); >- >- return { >- type: Syntax.BlockStatement, >- body: block >- }; >- } >- >- // 12.2 Variable Statement >- >- function parseVariableIdentifier() { >- var token = lex(); >- >- if (token.type !== Token.Identifier) { >- throwUnexpected(token); >- } >- >- return { >- type: Syntax.Identifier, >- name: token.value >- }; >- } >- >- function parseVariableDeclaration(kind) { >- var id = parseVariableIdentifier(), >- init = null; >- >- // 12.2.1 >- if (strict && isRestrictedWord(id.name)) { >- throwErrorTolerant({}, Messages.StrictVarName); >- } >- >- if (kind === 'const') { >- expect('='); >- init = parseAssignmentExpression(); >- } else if (match('=')) { >- lex(); >- init = parseAssignmentExpression(); >- } >- >- return { >- type: Syntax.VariableDeclarator, >- id: id, >- init: init >- }; >- } >- >- function parseVariableDeclarationList(kind) { >- var list = []; >- >- while (index < length) { >- list.push(parseVariableDeclaration(kind)); >- if (!match(',')) { >- break; >- } >- lex(); >- } >- >- return list; >- } >- >- function parseVariableStatement() { >- var declarations; >- >- expectKeyword('var'); >- >- declarations = parseVariableDeclarationList(); >- >- consumeSemicolon(); >- >- return { >- type: Syntax.VariableDeclaration, >- declarations: declarations, >- kind: 'var' >- }; >- } >- >- // kind may be `const` or `let` >- // Both are experimental and not in the specification yet. >- // see http://wiki.ecmascript.org/doku.php?id=harmony:const >- // and http://wiki.ecmascript.org/doku.php?id=harmony:let >- function parseConstLetDeclaration(kind) { >- var declarations; >- >- expectKeyword(kind); >- >- declarations = parseVariableDeclarationList(kind); >- >- consumeSemicolon(); >- >- return { >- type: Syntax.VariableDeclaration, >- declarations: declarations, >- kind: kind >- }; >- } >- >- // 12.3 Empty Statement >- >- function parseEmptyStatement() { >- expect(';'); >- >- return { >- type: Syntax.EmptyStatement >- }; >- } >- >- // 12.4 Expression Statement >- >- function parseExpressionStatement() { >- var expr = parseExpression(); >- >- consumeSemicolon(); >- >- return { >- type: Syntax.ExpressionStatement, >- expression: expr >- }; >- } >- >- /** >- * for statements like if, while, for, etc. >- * Check for the ')' on the condition. If >- * it is not present, catch the error, and backtrack >- * if we see a '{' instead (to continue parsing the block) >- */ >- function expectConditionCloseParenWrapThrow() { >- // needs generalizing to a 'expect A but don't consume if you hit B or C' >- try { >- expect(')'); >- } catch (e) { >- if (extra.errors) { >- pushError(e); >- // If a { was hit instead of a ) then don't consume it, let us assume a ')' was >- // missed and the consequent block is OK >- if (source[e.index] === '{') { >- index=e.index; >- buffer=null; >- // activating this block will mean the following statement is parsed as a consequent / body. >- // without it the statement is considered not at all part of the enclosing statement at all >- // } else { >- // rewind(); >- } >- } else { >- throw e; >- } >- } >- >- } >- // 12.5 If statement >- >- function parseIfStatement() { >- var test, consequent, alternate; >- >- expectKeyword('if'); >- >- expect('('); >- >- test = parseExpression(); >- >- expectConditionCloseParenWrapThrow(); >- >- consequent = parseStatement(); >- // required because of the check in wrapTracking that returns nothing if node is undefined >- if (!consequent) { >- consequent = null; >- } >- >- if (matchKeyword('else')) { >- lex(); >- alternate = parseStatement(); >- } else { >- alternate = null; >- } >- >- return { >- type: Syntax.IfStatement, >- test: test, >- consequent: consequent, >- alternate: alternate >- }; >- } >- >- // 12.6 Iteration Statements >- >- function parseDoWhileStatement() { >- var body, test, oldInIteration; >- >- expectKeyword('do'); >- >- oldInIteration = state.inIteration; >- state.inIteration = true; >- >- body = parseStatement(); >- >- state.inIteration = oldInIteration; >- >- expectKeyword('while'); >- >- expect('('); >- >- test = parseExpression(); >- >- expect(')'); >- >- if (match(';')) { >- lex(); >- } >- >- return { >- type: Syntax.DoWhileStatement, >- body: body, >- test: test >- }; >- } >- >- function parseWhileStatement() { >- var test, body, oldInIteration; >- >- expectKeyword('while'); >- >- expect('('); >- >- test = parseExpression(); >- >- expectConditionCloseParenWrapThrow(); >- >- oldInIteration = state.inIteration; >- state.inIteration = true; >- >- body = parseStatement(); >- >- state.inIteration = oldInIteration; >- >- return { >- type: Syntax.WhileStatement, >- test: test, >- body: body >- }; >- } >- >- function parseForVariableDeclaration() { >- var token = lex(); >- >- return { >- type: Syntax.VariableDeclaration, >- declarations: parseVariableDeclarationList(), >- kind: token.value >- }; >- } >- >- function parseForStatement() { >- var init, test, update, left, right, body, oldInIteration; >- >- init = test = update = null; >- >- expectKeyword('for'); >- >- expect('('); >- >- if (match(';')) { >- lex(); >- } else { >- if (matchKeyword('var') || matchKeyword('let')) { >- state.allowIn = false; >- init = parseForVariableDeclaration(); >- state.allowIn = true; >- >- if (init.declarations.length === 1 && matchKeyword('in')) { >- lex(); >- left = init; >- right = parseExpression(); >- init = null; >- } >- } else { >- state.allowIn = false; >- init = parseExpression(); >- state.allowIn = true; >- >- if (matchKeyword('in')) { >- // LeftHandSideExpression >- if (matchKeyword('in') && (state.lastParenthesized !== init && !isLeftHandSide(init))) { >- throwError({}, Messages.InvalidLHSInForIn); >- } >- lex(); >- left = init; >- right = parseExpression(); >- init = null; >- } >- } >- >- if (typeof left === 'undefined') { >- expect(';'); >- } >- } >- >- if (typeof left === 'undefined') { >- >- if (!match(';')) { >- test = parseExpression(); >- } >- expect(';'); >- >- if (!match(')')) { >- update = parseExpression(); >- } >- } >- >-// expect(')'); >- expectConditionCloseParenWrapThrow(); >- >- oldInIteration = state.inIteration; >- state.inIteration = true; >- >- body = parseStatement(); >- >- state.inIteration = oldInIteration; >- >- if (typeof left === 'undefined') { >- return { >- type: Syntax.ForStatement, >- init: init, >- test: test, >- update: update, >- body: body >- }; >- } >- >- return { >- type: Syntax.ForInStatement, >- left: left, >- right: right, >- body: body, >- each: false >- }; >- } >- >- // 12.7 The continue statement >- >- function parseContinueStatement() { >- var token, label = null; >- >- expectKeyword('continue'); >- >- // Optimize the most common form: 'continue;'. >- if (source[index] === ';') { >- lex(); >- >- if (!state.inIteration) { >- throwError({}, Messages.IllegalContinue); >- } >- >- return { >- type: Syntax.ContinueStatement, >- label: null >- }; >- } >- >- if (peekLineTerminator()) { >- if (!state.inIteration) { >- throwError({}, Messages.IllegalContinue); >- } >- >- return { >- type: Syntax.ContinueStatement, >- label: null >- }; >- } >- >- token = lookahead(); >- if (token.type === Token.Identifier) { >- label = parseVariableIdentifier(); >- >- if (!Object.prototype.hasOwnProperty.call(state.labelSet, label.name)) { >- throwError({}, Messages.UnknownLabel, label.name); >- } >- } >- >- consumeSemicolon(); >- >- if (label === null && !state.inIteration) { >- throwError({}, Messages.IllegalContinue); >- } >- >- return { >- type: Syntax.ContinueStatement, >- label: label >- }; >- } >- >- // 12.8 The break statement >- >- function parseBreakStatement() { >- var token, label = null; >- >- expectKeyword('break'); >- >- // Optimize the most common form: 'break;'. >- if (source[index] === ';') { >- lex(); >- >- if (!(state.inIteration || state.inSwitch)) { >- throwError({}, Messages.IllegalBreak); >- } >- >- return { >- type: Syntax.BreakStatement, >- label: null >- }; >- } >- >- if (peekLineTerminator()) { >- if (!(state.inIteration || state.inSwitch)) { >- throwError({}, Messages.IllegalBreak); >- } >- >- return { >- type: Syntax.BreakStatement, >- label: null >- }; >- } >- >- token = lookahead(); >- if (token.type === Token.Identifier) { >- label = parseVariableIdentifier(); >- >- if (!Object.prototype.hasOwnProperty.call(state.labelSet, label.name)) { >- throwError({}, Messages.UnknownLabel, label.name); >- } >- } >- >- consumeSemicolon(); >- >- if (label === null && !(state.inIteration || state.inSwitch)) { >- throwError({}, Messages.IllegalBreak); >- } >- >- return { >- type: Syntax.BreakStatement, >- label: label >- }; >- } >- >- // 12.9 The return statement >- >- function parseReturnStatement() { >- var token, argument = null; >- >- expectKeyword('return'); >- >- if (!state.inFunctionBody) { >- throwErrorTolerant({}, Messages.IllegalReturn); >- } >- >- // 'return' followed by a space and an identifier is very common. >- if (source[index] === ' ') { >- if (isIdentifierStart(source[index + 1])) { >- argument = parseExpression(); >- consumeSemicolon(); >- return { >- type: Syntax.ReturnStatement, >- argument: argument >- }; >- } >- } >- >- if (peekLineTerminator()) { >- return { >- type: Syntax.ReturnStatement, >- argument: null >- }; >- } >- >- if (!match(';')) { >- token = lookahead(); >- if (!match('}') && token.type !== Token.EOF) { >- argument = parseExpression(); >- } >- } >- >- consumeSemicolon(); >- >- return { >- type: Syntax.ReturnStatement, >- argument: argument >- }; >- } >- >- // 12.10 The with statement >- >- function parseWithStatement() { >- var object, body; >- >- if (strict) { >- throwErrorTolerant({}, Messages.StrictModeWith); >- } >- >- expectKeyword('with'); >- >- expect('('); >- >- object = parseExpression(); >- >- expect(')'); >- >- body = parseStatement(); >- >- return { >- type: Syntax.WithStatement, >- object: object, >- body: body >- }; >- } >- >- // 12.10 The swith statement >- >- function parseSwitchCase() { >- var test, >- consequent = [], >- statement; >- >- if (matchKeyword('default')) { >- lex(); >- test = null; >- } else { >- expectKeyword('case'); >- test = parseExpression(); >- } >- expect(':'); >- >- while (index < length) { >- if (match('}') || matchKeyword('default') || matchKeyword('case')) { >- break; >- } >- statement = parseStatement(); >- if (typeof statement === 'undefined') { >- break; >- } >- consequent.push(statement); >- } >- >- return { >- type: Syntax.SwitchCase, >- test: test, >- consequent: consequent >- }; >- } >- >- function parseSwitchStatement() { >- var discriminant, cases, oldInSwitch; >- >- expectKeyword('switch'); >- >- expect('('); >- >- discriminant = parseExpression(); >- >- expect(')'); >- >- expect('{'); >- >- if (match('}')) { >- lex(); >- return { >- type: Syntax.SwitchStatement, >- discriminant: discriminant >- }; >- } >- >- cases = []; >- >- oldInSwitch = state.inSwitch; >- state.inSwitch = true; >- >- while (index < length) { >- if (match('}')) { >- break; >- } >- cases.push(parseSwitchCase()); >- } >- >- state.inSwitch = oldInSwitch; >- >- expect('}'); >- >- return { >- type: Syntax.SwitchStatement, >- discriminant: discriminant, >- cases: cases >- }; >- } >- >- // 12.13 The throw statement >- >- function parseThrowStatement() { >- var argument; >- >- expectKeyword('throw'); >- >- if (peekLineTerminator()) { >- throwError({}, Messages.NewlineAfterThrow); >- } >- >- argument = parseExpression(); >- >- consumeSemicolon(); >- >- return { >- type: Syntax.ThrowStatement, >- argument: argument >- }; >- } >- >- // 12.14 The try statement >- >- function parseCatchClause() { >- var param; >- >- expectKeyword('catch'); >- >- expect('('); >- if (!match(')')) { >- param = parseExpression(); >- // 12.14.1 >- if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) { >- throwErrorTolerant({}, Messages.StrictCatchVariable); >- } >- } >- expect(')'); >- >- return { >- type: Syntax.CatchClause, >- param: param, >- guard: null, >- body: parseBlock() >- }; >- } >- >- function parseTryStatement() { >- var block, handlers = [], finalizer = null; >- >- expectKeyword('try'); >- >- block = parseBlock(); >- >- if (matchKeyword('catch')) { >- handlers.push(parseCatchClause()); >- } >- >- if (matchKeyword('finally')) { >- lex(); >- finalizer = parseBlock(); >- } >- >- if (handlers.length === 0 && !finalizer) { >- throwError({}, Messages.NoCatchOrFinally); >- } >- >- return { >- type: Syntax.TryStatement, >- block: block, >- handlers: handlers, >- finalizer: finalizer >- }; >- } >- >- // 12.15 The debugger statement >- >- function parseDebuggerStatement() { >- expectKeyword('debugger'); >- >- consumeSemicolon(); >- >- return { >- type: Syntax.DebuggerStatement >- }; >- } >- >- // 12 Statements >- >- function parseStatement() { >- var token = lookahead(), >- expr, >- labeledBody; >- >- if (token.type === Token.EOF) { >- throwUnexpected(token); >- } >- >- if (token.type === Token.Punctuator) { >- switch (token.value) { >- case ';': >- return parseEmptyStatement(); >- case '{': >- return parseBlock(); >- case '(': >- return parseExpressionStatement(); >- default: >- break; >- } >- } >- >- if (token.type === Token.Keyword) { >- switch (token.value) { >- case 'break': >- return parseBreakStatement(); >- case 'continue': >- return parseContinueStatement(); >- case 'debugger': >- return parseDebuggerStatement(); >- case 'do': >- return parseDoWhileStatement(); >- case 'for': >- return parseForStatement(); >- case 'function': >- return parseFunctionDeclaration(); >- case 'if': >- return parseIfStatement(); >- case 'return': >- return parseReturnStatement(); >- case 'switch': >- return parseSwitchStatement(); >- case 'throw': >- return parseThrowStatement(); >- case 'try': >- return parseTryStatement(); >- case 'var': >- return parseVariableStatement(); >- case 'while': >- return parseWhileStatement(); >- case 'with': >- return parseWithStatement(); >- default: >- break; >- } >- } >- >- expr = parseExpression(); >- >- // 12.12 Labelled Statements >- if (expr && (expr.type === Syntax.Identifier) && match(':')) { >- lex(); >- >- if (Object.prototype.hasOwnProperty.call(state.labelSet, expr.name)) { >- throwError({}, Messages.Redeclaration, 'Label', expr.name); >- } >- >- state.labelSet[expr.name] = true; >- labeledBody = parseStatement(); >- delete state.labelSet[expr.name]; >- >- return { >- type: Syntax.LabeledStatement, >- label: expr, >- body: labeledBody >- }; >- } >- >- consumeSemicolon(); >- >- >- return { >- type: Syntax.ExpressionStatement, >- expression: expr >- }; >- } >- >- // 13 Function Definition >- function expectCloseBracketWrapThrow() { >- if (extra.errors) { >- // continue parsing even with missing close >- // brace. This gives a better AST for the >- // block, as information about >- // the parsed statements remain >- try { >- expect('}'); >- } catch (e) { >- pushError(e); >- } >- } else { >- expect('}'); >- } >- } >- >- function parseFunctionSourceElements() { >- var sourceElement, sourceElements = [], token, directive, firstRestricted, >- oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody; >- >- expect('{'); >- >- while (index < length) { >- token = lookahead(); >- if (token.type !== Token.StringLiteral) { >- break; >- } >- >- sourceElement = parseSourceElement(); >- sourceElements.push(sourceElement); >- if (sourceElement.expression.type !== Syntax.Literal) { >- // this is not directive >- break; >- } >- directive = sliceSource(token.range[0] + 1, token.range[1] - 1); >- if (directive === 'use strict') { >- strict = true; >- if (firstRestricted) { >- throwError(firstRestricted, Messages.StrictOctalLiteral); >- } >- } else { >- if (!firstRestricted && token.octal) { >- firstRestricted = token; >- } >- } >- } >- >- oldLabelSet = state.labelSet; >- oldInIteration = state.inIteration; >- oldInSwitch = state.inSwitch; >- oldInFunctionBody = state.inFunctionBody; >- >- state.labelSet = {}; >- state.inIteration = false; >- state.inSwitch = false; >- state.inFunctionBody = true; >- >- while (index < length) { >- if (match('}')) { >- break; >- } >- sourceElement = parseSourceElement(); >- if (typeof sourceElement === 'undefined') { >- break; >- } >- sourceElements.push(sourceElement); >- } >- >- expectCloseBracketWrapThrow(); >- >- state.labelSet = oldLabelSet; >- state.inIteration = oldInIteration; >- state.inSwitch = oldInSwitch; >- state.inFunctionBody = oldInFunctionBody; >- >- return { >- type: Syntax.BlockStatement, >- body: sourceElements >- }; >- } >- >- function parseFunctionDeclaration() { >- var id, param, params = [], body, token, firstRestricted, message, previousStrict, paramSet; >- >- expectKeyword('function'); >- token = lookahead(); >- id = parseVariableIdentifier(); >- if (strict) { >- if (isRestrictedWord(token.value)) { >- throwError(token, Messages.StrictFunctionName); >- } >- } else { >- if (isRestrictedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictFunctionName; >- } else if (isStrictModeReservedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictReservedWord; >- } >- } >- >- expect('('); >- >- if (!match(')')) { >- paramSet = {}; >- while (index < length) { >- token = lookahead(); >- param = parseVariableIdentifier(); >- if (strict) { >- if (isRestrictedWord(token.value)) { >- throwError(token, Messages.StrictParamName); >- } >- if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { >- throwError(token, Messages.StrictParamDupe); >- } >- } else if (!firstRestricted) { >- if (isRestrictedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictParamName; >- } else if (isStrictModeReservedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictReservedWord; >- } else if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { >- firstRestricted = token; >- message = Messages.StrictParamDupe; >- } >- } >- params.push(param); >- paramSet[param.name] = true; >- if (match(')')) { >- break; >- } >- expect(','); >- } >- } >- >- expect(')'); >- >- previousStrict = strict; >- body = parseFunctionSourceElements(); >- if (strict && firstRestricted) { >- throwError(firstRestricted, message); >- } >- strict = previousStrict; >- >- return { >- type: Syntax.FunctionDeclaration, >- id: id, >- params: params, >- body: body >- }; >- } >- >- function parseFunctionExpression() { >- var token, id = null, firstRestricted, message, param, params = [], body, previousStrict, paramSet; >- >- expectKeyword('function'); >- >- if (!match('(')) { >- token = lookahead(); >- id = parseVariableIdentifier(); >- if (strict) { >- if (isRestrictedWord(token.value)) { >- throwError(token, Messages.StrictFunctionName); >- } >- } else { >- if (isRestrictedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictFunctionName; >- } else if (isStrictModeReservedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictReservedWord; >- } >- } >- } >- >- expect('('); >- >- if (!match(')')) { >- paramSet = {}; >- while (index < length) { >- token = lookahead(); >- param = parseVariableIdentifier(); >- if (strict) { >- if (isRestrictedWord(token.value)) { >- throwError(token, Messages.StrictParamName); >- } >- if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { >- throwError(token, Messages.StrictParamDupe); >- } >- } else if (!firstRestricted) { >- if (isRestrictedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictParamName; >- } else if (isStrictModeReservedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictReservedWord; >- } else if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { >- firstRestricted = token; >- message = Messages.StrictParamDupe; >- } >- } >- params.push(param); >- paramSet[param.name] = true; >- if (match(')')) { >- break; >- } >- expect(','); >- } >- } >- >- expect(')'); >- >- previousStrict = strict; >- body = parseFunctionSourceElements(); >- if (strict && firstRestricted) { >- throwError(firstRestricted, message); >- } >- strict = previousStrict; >- >- return { >- type: Syntax.FunctionExpression, >- id: id, >- params: params, >- body: body >- }; >- } >- >- // 14 Program >- >- function parseSourceElement() { >- var token = lookahead(); >- >- if (token.type === Token.Keyword) { >- switch (token.value) { >- case 'const': >- case 'let': >- return parseConstLetDeclaration(token.value); >- case 'function': >- return parseFunctionDeclaration(); >- default: >- return parseStatement(); >- } >- } >- >- if (token.type !== Token.EOF) { >- return parseStatement(); >- } >- } >- >- function parseSourceElements() { >- var sourceElement, sourceElements = [], token, directive, firstRestricted; >- >- while (index < length) { >- token = lookahead(); >- if (token.type !== Token.StringLiteral) { >- break; >- } >- >- sourceElement = parseSourceElement(); >- sourceElements.push(sourceElement); >- if (sourceElement.expression.type !== Syntax.Literal) { >- // this is not directive >- break; >- } >- directive = sliceSource(token.range[0] + 1, token.range[1] - 1); >- if (directive === 'use strict') { >- strict = true; >- if (firstRestricted) { >- throwError(firstRestricted, Messages.StrictOctalLiteral); >- } >- } else { >- if (!firstRestricted && token.octal) { >- firstRestricted = token; >- } >- } >- } >- >- while (index < length) { >- sourceElement = parseSourceElement(); >- if (typeof sourceElement === 'undefined') { >- break; >- } >- sourceElements.push(sourceElement); >- } >- return sourceElements; >- } >- >- function parseProgram() { >- var program; >- strict = false; >- program = { >- type: Syntax.Program, >- body: parseSourceElements() >- }; >- return program; >- } >- >- // The following functions are needed only when the option to preserve >- // the comments is active. >- >- function addComment(start, end, type, value) { >- assert(typeof start === 'number', 'Comment must have valid position'); >- >- // Because the way the actual token is scanned, often the comments >- // (if any) are skipped twice during the lexical analysis. >- // Thus, we need to skip adding a comment if the comment array already >- // handled it. >- if (extra.comments.length > 0) { >- if (extra.comments[extra.comments.length - 1].range[1] > start) { >- return; >- } >- } >- >- extra.comments.push({ >- range: [start, end], >- type: type, >- value: value >- }); >- } >- >- function scanComment() { >- var comment, ch, start, blockComment, lineComment; >- >- comment = ''; >- blockComment = false; >- lineComment = false; >- >- while (index < length) { >- ch = source[index]; >- >- if (lineComment) { >- ch = nextChar(); >- if (index >= length) { >- lineComment = false; >- comment += ch; >- addComment(start, index, 'Line', comment); >- } else if (isLineTerminator(ch)) { >- lineComment = false; >- addComment(start, index, 'Line', comment); >- if (ch === '\r' && source[index] === '\n') { >- ++index; >- } >- ++lineNumber; >- lineStart = index; >- comment = ''; >- } else { >- comment += ch; >- } >- } else if (blockComment) { >- if (isLineTerminator(ch)) { >- if (ch === '\r' && source[index + 1] === '\n') { >- ++index; >- comment += '\r\n'; >- } else { >- comment += ch; >- } >- ++lineNumber; >- ++index; >- lineStart = index; >- if (index >= length) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } else { >- ch = nextChar(); >- if (index >= length) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- comment += ch; >- if (ch === '*') { >- ch = source[index]; >- if (ch === '/') { >- comment = comment.substr(0, comment.length - 1); >- blockComment = false; >- ++index; >- addComment(start, index, 'Block', comment); >- comment = ''; >- } >- } >- } >- } else if (ch === '/') { >- ch = source[index + 1]; >- if (ch === '/') { >- start = index; >- index += 2; >- lineComment = true; >- } else if (ch === '*') { >- start = index; >- index += 2; >- blockComment = true; >- if (index >= length) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } else { >- break; >- } >- } else if (isWhiteSpace(ch)) { >- ++index; >- } else if (isLineTerminator(ch)) { >- ++index; >- if (ch === '\r' && source[index] === '\n') { >- ++index; >- } >- ++lineNumber; >- lineStart = index; >- } else { >- break; >- } >- } >- } >- >- function collectToken() { >- var token = extra.advance(), >- range, >- value; >- >- if (token.type !== Token.EOF) { >- range = [token.range[0], token.range[1]]; >- value = sliceSource(token.range[0], token.range[1]); >- extra.tokens.push({ >- type: TokenName[token.type], >- value: value, >- range: range >- }); >- } >- >- return token; >- } >- >- function collectRegex() { >- var pos, regex, token; >- >- skipComment(); >- >- pos = index; >- regex = extra.scanRegExp(); >- >- // Pop the previous token, which is likely '/' or '/=' >- if (extra.tokens.length > 0) { >- token = extra.tokens[extra.tokens.length - 1]; >- if (token.range[0] === pos && token.type === 'Punctuator') { >- if (token.value === '/' || token.value === '/=') { >- extra.tokens.pop(); >- } >- } >- } >- >- extra.tokens.push({ >- type: 'RegularExpression', >- value: regex.literal, >- range: [pos, index] >- }); >- >- return regex; >- } >- >- function createLiteral(token) { >- return { >- type: Syntax.Literal, >- value: token.value >- }; >- } >- >- function createRawLiteral(token) { >- return { >- type: Syntax.Literal, >- value: token.value, >- raw: sliceSource(token.range[0], token.range[1]) >- }; >- } >- >- function wrapTrackingFunction(range, loc) { >- >- return function (parseFunction) { >- >- function isBinary(node) { >- return node.type === Syntax.LogicalExpression || >- node.type === Syntax.BinaryExpression; >- } >- >- function visit(node) { >- if (isBinary(node.left)) { >- visit(node.left); >- } >- if (isBinary(node.right)) { >- visit(node.right); >- } >- >- if (range && typeof node.range === 'undefined') { >- node.range = [node.left.range[0], node.right.range[1]]; >- } >- if (loc && typeof node.loc === 'undefined') { >- node.loc = { >- start: node.left.loc.start, >- end: node.right.loc.end >- }; >- } >- } >- >- return function () { >- var node, rangeInfo, locInfo; >- >- skipComment(); >- rangeInfo = [index, 0]; >- locInfo = { >- start: { >- line: lineNumber, >- column: index - lineStart >- } >- }; >- >- node = parseFunction.apply(null, arguments); >- if (typeof node !== 'undefined') { >- >- if (range) { >- rangeInfo[1] = index; >- node.range = rangeInfo; >- } >- >- if (loc) { >- locInfo.end = { >- line: lineNumber, >- column: index - lineStart >- }; >- node.loc = locInfo; >- } >- >- if (isBinary(node)) { >- visit(node); >- } >- >- if (node.type === Syntax.MemberExpression) { >- if (typeof node.object.range !== 'undefined') { >- node.range[0] = node.object.range[0]; >- } >- if (typeof node.object.loc !== 'undefined') { >- node.loc.start = node.object.loc.start; >- } >- } >- return node; >- } >- }; >- >- }; >- } >- >- function patch() { >- >- var wrapTracking; >- >- function wrapThrow(parseFunction) { >- return function () { >- try { >- return parseFunction.apply(null, arguments); >- } catch (e) { >- pushError(e); >- return null; >- } >- }; >- } >- >- function wrapThrowParseStatement(parseFunction) { >- return function () { >- extra.statementStart = index; // record where attempting to parse statement from >- try { >- return parseFunction.apply(null, arguments); >- } catch (e) { >- pushError(e); >-// return null; >- } >- }; >- } >- >- if (extra.comments) { >- extra.skipComment = skipComment; >- skipComment = scanComment; >- } >- >- if (extra.raw) { >- extra.createLiteral = createLiteral; >- createLiteral = createRawLiteral; >- } >- >- if (extra.range || extra.loc || extra.errors) { >- >- wrapTracking = wrapTrackingFunction(extra.range, extra.loc); >- >- extra.parseAdditiveExpression = parseAdditiveExpression; >- extra.parseAssignmentExpression = parseAssignmentExpression; >- extra.parseBitwiseANDExpression = parseBitwiseANDExpression; >- extra.parseBitwiseORExpression = parseBitwiseORExpression; >- extra.parseBitwiseXORExpression = parseBitwiseXORExpression; >- extra.parseBlock = parseBlock; >- extra.parseFunctionSourceElements = parseFunctionSourceElements; >- extra.parseCallMember = parseCallMember; >- extra.parseCatchClause = parseCatchClause; >- extra.parseComputedMember = parseComputedMember; >- extra.parseConditionalExpression = parseConditionalExpression; >- extra.parseConstLetDeclaration = parseConstLetDeclaration; >- extra.parseEqualityExpression = parseEqualityExpression; >- extra.parseExpression = parseExpression; >- extra.parseForVariableDeclaration = parseForVariableDeclaration; >- extra.parseFunctionDeclaration = parseFunctionDeclaration; >- extra.parseFunctionExpression = parseFunctionExpression; >- extra.parseLogicalANDExpression = parseLogicalANDExpression; >- extra.parseLogicalORExpression = parseLogicalORExpression; >- extra.parseMultiplicativeExpression = parseMultiplicativeExpression; >- extra.parseNewExpression = parseNewExpression; >- extra.parseNonComputedMember = parseNonComputedMember; >- extra.parseNonComputedProperty = parseNonComputedProperty; >- extra.parseObjectProperty = parseObjectProperty; >- extra.parseObjectPropertyKey = parseObjectPropertyKey; >- extra.parsePostfixExpression = parsePostfixExpression; >- extra.parsePrimaryExpression = parsePrimaryExpression; >- extra.parseProgram = parseProgram; >- extra.parsePropertyFunction = parsePropertyFunction; >- extra.parseRelationalExpression = parseRelationalExpression; >- extra.parseStatement = parseStatement; >- extra.parseShiftExpression = parseShiftExpression; >- extra.parseSwitchCase = parseSwitchCase; >- extra.parseUnaryExpression = parseUnaryExpression; >- extra.parseVariableDeclaration = parseVariableDeclaration; >- extra.parseVariableIdentifier = parseVariableIdentifier; >- extra.consumeSemicolon = consumeSemicolon; >- >- parseAdditiveExpression = wrapTracking(extra.parseAdditiveExpression); >- parseAssignmentExpression = wrapTracking(extra.parseAssignmentExpression); >- parseBitwiseANDExpression = wrapTracking(extra.parseBitwiseANDExpression); >- parseBitwiseORExpression = wrapTracking(extra.parseBitwiseORExpression); >- parseBitwiseXORExpression = wrapTracking(extra.parseBitwiseXORExpression); >- parseBlock = wrapTracking(extra.parseBlock); >- parseFunctionSourceElements = wrapTracking(extra.parseFunctionSourceElements); >- parseCallMember = wrapTracking(extra.parseCallMember); >- parseCatchClause = wrapTracking(extra.parseCatchClause); >- parseComputedMember = wrapTracking(extra.parseComputedMember); >- parseConditionalExpression = wrapTracking(extra.parseConditionalExpression); >- parseConstLetDeclaration = wrapTracking(extra.parseConstLetDeclaration); >- parseEqualityExpression = wrapTracking(extra.parseEqualityExpression); >- parseExpression = wrapTracking(extra.parseExpression); >- parseForVariableDeclaration = wrapTracking(extra.parseForVariableDeclaration); >- parseFunctionDeclaration = wrapTracking(extra.parseFunctionDeclaration); >- parseFunctionExpression = wrapTracking(extra.parseFunctionExpression); >- parseLogicalANDExpression = wrapTracking(extra.parseLogicalANDExpression); >- parseLogicalORExpression = wrapTracking(extra.parseLogicalORExpression); >- parseMultiplicativeExpression = wrapTracking(extra.parseMultiplicativeExpression); >- parseNewExpression = wrapTracking(extra.parseNewExpression); >- parseNonComputedMember = wrapTracking(extra.parseNonComputedMember); >- parseNonComputedProperty = wrapTracking(extra.parseNonComputedProperty); >- parseObjectProperty = wrapTracking(extra.parseObjectProperty); >- parseObjectPropertyKey = wrapTracking(extra.parseObjectPropertyKey); >- parsePostfixExpression = wrapTracking(extra.parsePostfixExpression); >- parsePrimaryExpression = wrapTracking(extra.parsePrimaryExpression); >- parseProgram = wrapTracking(extra.parseProgram); >- parsePropertyFunction = wrapTracking(extra.parsePropertyFunction); >- parseRelationalExpression = wrapTracking(extra.parseRelationalExpression); >- parseStatement = wrapTracking(extra.parseStatement); >- parseShiftExpression = wrapTracking(extra.parseShiftExpression); >- parseSwitchCase = wrapTracking(extra.parseSwitchCase); >- parseUnaryExpression = wrapTracking(extra.parseUnaryExpression); >- parseVariableDeclaration = wrapTracking(extra.parseVariableDeclaration); >- parseVariableIdentifier = wrapTracking(extra.parseVariableIdentifier); >- } >- >- if (extra.errors) { >- parseStatement = wrapThrowParseStatement(parseStatement); >- parseExpression = wrapThrow(parseExpression); >- // this enables 'foo.<EOF>' to return something >- parseNonComputedProperty = wrapThrow(parseNonComputedProperty); >- consumeSemicolon = wrapThrow(consumeSemicolon); >- } >- >- if (typeof extra.tokens !== 'undefined') { >- extra.advance = advance; >- extra.scanRegExp = scanRegExp; >- >- advance = collectToken; >- scanRegExp = collectRegex; >- } >- } >- >- function unpatch() { >- if (typeof extra.skipComment === 'function') { >- skipComment = extra.skipComment; >- } >- >- if (extra.raw) { >- createLiteral = extra.createLiteral; >- } >- >- if (extra.range || extra.loc || extra.errors) { >- parseAdditiveExpression = extra.parseAdditiveExpression; >- parseAssignmentExpression = extra.parseAssignmentExpression; >- parseBitwiseANDExpression = extra.parseBitwiseANDExpression; >- parseBitwiseORExpression = extra.parseBitwiseORExpression; >- parseBitwiseXORExpression = extra.parseBitwiseXORExpression; >- parseBlock = extra.parseBlock; >- parseFunctionSourceElements = extra.parseFunctionSourceElements; >- parseCallMember = extra.parseCallMember; >- parseCatchClause = extra.parseCatchClause; >- parseComputedMember = extra.parseComputedMember; >- parseConditionalExpression = extra.parseConditionalExpression; >- parseConstLetDeclaration = extra.parseConstLetDeclaration; >- parseEqualityExpression = extra.parseEqualityExpression; >- parseExpression = extra.parseExpression; >- parseForVariableDeclaration = extra.parseForVariableDeclaration; >- parseFunctionDeclaration = extra.parseFunctionDeclaration; >- parseFunctionExpression = extra.parseFunctionExpression; >- parseLogicalANDExpression = extra.parseLogicalANDExpression; >- parseLogicalORExpression = extra.parseLogicalORExpression; >- parseMultiplicativeExpression = extra.parseMultiplicativeExpression; >- parseNewExpression = extra.parseNewExpression; >- parseNonComputedMember = extra.parseNonComputedMember; >- parseNonComputedProperty = extra.parseNonComputedProperty; >- parseObjectProperty = extra.parseObjectProperty; >- parseObjectPropertyKey = extra.parseObjectPropertyKey; >- parsePrimaryExpression = extra.parsePrimaryExpression; >- parsePostfixExpression = extra.parsePostfixExpression; >- parseProgram = extra.parseProgram; >- parsePropertyFunction = extra.parsePropertyFunction; >- parseRelationalExpression = extra.parseRelationalExpression; >- parseStatement = extra.parseStatement; >- parseShiftExpression = extra.parseShiftExpression; >- parseSwitchCase = extra.parseSwitchCase; >- parseUnaryExpression = extra.parseUnaryExpression; >- parseVariableDeclaration = extra.parseVariableDeclaration; >- parseVariableIdentifier = extra.parseVariableIdentifier; >- consumeSemicolon = extra.consumeSemicolon; >- } >- >- if (typeof extra.scanRegExp === 'function') { >- advance = extra.advance; >- scanRegExp = extra.scanRegExp; >- } >- } >- >- function stringToArray(str) { >- var length = str.length, >- result = [], >- i; >- for (i = 0; i < length; ++i) { >- result[i] = str.charAt(i); >- } >- return result; >- } >- >- function parse(code, options) { >- var program, toString; >- >- toString = String; >- if (typeof code !== 'string' && !(code instanceof String)) { >- code = toString(code); >- } >- >- source = code; >- index = 0; >- lineNumber = (source.length > 0) ? 1 : 0; >- lineStart = 0; >- length = source.length; >- buffer = null; >- state = { >- allowIn: true, >- labelSet: {}, >- lastParenthesized: null, >- inFunctionBody: false, >- inIteration: false, >- inSwitch: false >- }; >- >- extra = {}; >- if (typeof options !== 'undefined') { >- extra.range = (typeof options.range === 'boolean') && options.range; >- extra.loc = (typeof options.loc === 'boolean') && options.loc; >- extra.raw = (typeof options.raw === 'boolean') && options.raw; >- if (typeof options.tokens === 'boolean' && options.tokens) { >- extra.tokens = []; >- } >- if (typeof options.comment === 'boolean' && options.comment) { >- extra.comments = []; >- } >- if (typeof options.tolerant === 'boolean' && options.tolerant) { >- extra.errors = []; >- } >- } >- >- if (length > 0) { >- if (typeof source[0] === 'undefined') { >- // Try first to convert to a string. This is good as fast path >- // for old IE which understands string indexing for string >- // literals only and not for string object. >- if (code instanceof String) { >- source = code.valueOf(); >- } >- >- // Force accessing the characters via an array. >- if (typeof source[0] === 'undefined') { >- source = stringToArray(code); >- } >- } >- } >- >- patch(); >- try { >- program = parseProgram(); >- if (typeof extra.comments !== 'undefined') { >- program.comments = extra.comments; >- } >- if (typeof extra.tokens !== 'undefined') { >- program.tokens = extra.tokens; >- } >- if (typeof extra.errors !== 'undefined') { >- program.errors = extra.errors; >- } >- } catch (e) { >- throw e; >- } finally { >- unpatch(); >- extra = {}; >- } >- >- return program; >- } >- >- // Sync with package.json. >- exports.version = '1.0.0-dev'; >+ exports.tokenize = tokenize; > > exports.parse = parse; > >@@ -3818,5 +4195,5 @@ > return types; > }()); > >-}(typeof exports === 'undefined' ? (esprima = {}) : exports)); >+})); > /* vim: set sw=4 ts=4 et tw=80 : */ >diff --git a/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima_tolerant.js b/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima_tolerant.js >deleted file mode 100644 >index cd3b7ea..0000000 >--- a/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima_tolerant.js >+++ /dev/null >@@ -1,4156 +0,0 @@ >-/* >- Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com> >- Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com> >- Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be> >- Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com> >- Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be> >- Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl> >- Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com> >- Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com> >- Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com> >- Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com> >- >- Redistribution and use in source and binary forms, with or without >- modification, are permitted provided that the following conditions are met: >- >- * Redistributions of source code must retain the above copyright >- notice, this list of conditions and the following disclaimer. >- * Redistributions in binary form must reproduce the above copyright >- notice, this list of conditions and the following disclaimer in the >- documentation and/or other materials provided with the distribution. >- >- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" >- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE >- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY >- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >-*/ >- >-/*jslint bitwise:true plusplus:true */ >-/*global esprima:true, define:true, exports:true, window: true, >-createLocationMarker: true, >-throwError: true, generateStatement: true, peek: true, >-parseAssignmentExpression: true, parseBlock: true, >-expectConditionCloseBracketWrapThrow: true, parseExpression: true, >-parseFunctionDeclaration: true, parseFunctionExpression: true, >-parseFunctionSourceElements: true, parseVariableIdentifier: true, >-parseLeftHandSideExpression: true, >-parseUnaryExpression: true, >-parseStatement: true, parseSourceElement: true */ >- >-(function (root, factory) { >- 'use strict'; >- >- // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, >- // Rhino, and plain browser loading. >- if (typeof define === 'function' && define.amd) { >- define(['exports'], factory); >- } else if (typeof exports !== 'undefined') { >- factory(exports); >- } else { >- factory((root.esprima = {})); >- } >-}(this, function (exports) { >- 'use strict'; >- >- var Token, >- TokenName, >- FnExprTokens, >- Syntax, >- PropertyKind, >- Messages, >- Regex, >- SyntaxTreeDelegate, >- source, >- strict, >- index, >- lineNumber, >- lineStart, >- length, >- delegate, >- lookahead, >- state, >- extra; >- >- Token = { >- BooleanLiteral: 1, >- EOF: 2, >- Identifier: 3, >- Keyword: 4, >- NullLiteral: 5, >- NumericLiteral: 6, >- Punctuator: 7, >- StringLiteral: 8, >- RegularExpression: 9 >- }; >- >- TokenName = {}; >- TokenName[Token.BooleanLiteral] = 'Boolean'; >- TokenName[Token.EOF] = '<end>'; >- TokenName[Token.Identifier] = 'Identifier'; >- TokenName[Token.Keyword] = 'Keyword'; >- TokenName[Token.NullLiteral] = 'Null'; >- TokenName[Token.NumericLiteral] = 'Numeric'; >- TokenName[Token.Punctuator] = 'Punctuator'; >- TokenName[Token.StringLiteral] = 'String'; >- TokenName[Token.RegularExpression] = 'RegularExpression'; >- >- // A function following one of those tokens is an expression. >- FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', >- 'return', 'case', 'delete', 'throw', 'void', >- // assignment operators >- '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', >- '&=', '|=', '^=', ',', >- // binary/unary operators >- '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', >- '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', >- '<=', '<', '>', '!=', '!==']; >- >- Syntax = { >- AssignmentExpression: 'AssignmentExpression', >- ArrayExpression: 'ArrayExpression', >- BlockStatement: 'BlockStatement', >- BinaryExpression: 'BinaryExpression', >- BreakStatement: 'BreakStatement', >- CallExpression: 'CallExpression', >- CatchClause: 'CatchClause', >- ConditionalExpression: 'ConditionalExpression', >- ContinueStatement: 'ContinueStatement', >- DoWhileStatement: 'DoWhileStatement', >- DebuggerStatement: 'DebuggerStatement', >- EmptyStatement: 'EmptyStatement', >- ExpressionStatement: 'ExpressionStatement', >- ForStatement: 'ForStatement', >- ForInStatement: 'ForInStatement', >- FunctionDeclaration: 'FunctionDeclaration', >- FunctionExpression: 'FunctionExpression', >- Identifier: 'Identifier', >- IfStatement: 'IfStatement', >- Literal: 'Literal', >- LabeledStatement: 'LabeledStatement', >- LogicalExpression: 'LogicalExpression', >- MemberExpression: 'MemberExpression', >- NewExpression: 'NewExpression', >- ObjectExpression: 'ObjectExpression', >- Program: 'Program', >- Property: 'Property', >- ReturnStatement: 'ReturnStatement', >- SequenceExpression: 'SequenceExpression', >- SwitchStatement: 'SwitchStatement', >- SwitchCase: 'SwitchCase', >- ThisExpression: 'ThisExpression', >- ThrowStatement: 'ThrowStatement', >- TryStatement: 'TryStatement', >- UnaryExpression: 'UnaryExpression', >- UpdateExpression: 'UpdateExpression', >- VariableDeclaration: 'VariableDeclaration', >- VariableDeclarator: 'VariableDeclarator', >- WhileStatement: 'WhileStatement', >- WithStatement: 'WithStatement' >- }; >- >- PropertyKind = { >- Data: 1, >- Get: 2, >- Set: 4 >- }; >- >- // Error messages should be identical to V8. >- Messages = { >- UnexpectedToken: 'Unexpected token %0', >- UnexpectedNumber: 'Unexpected number', >- UnexpectedString: 'Unexpected string', >- UnexpectedIdentifier: 'Unexpected identifier', >- UnexpectedReserved: 'Unexpected reserved word', >- UnexpectedEOS: 'Unexpected end of input', >- NewlineAfterThrow: 'Illegal newline after throw', >- InvalidRegExp: 'Invalid regular expression', >- UnterminatedRegExp: 'Invalid regular expression: missing /', >- InvalidLHSInAssignment: 'Invalid left-hand side in assignment', >- InvalidLHSInForIn: 'Invalid left-hand side in for-in', >- MultipleDefaultsInSwitch: 'More than one default clause in switch statement', >- NoCatchOrFinally: 'Missing catch or finally after try', >- UnknownLabel: 'Undefined label \'%0\'', >- Redeclaration: '%0 \'%1\' has already been declared', >- IllegalContinue: 'Illegal continue statement', >- IllegalBreak: 'Illegal break statement', >- IllegalReturn: 'Illegal return statement', >- StrictModeWith: 'Strict mode code may not include a with statement', >- StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', >- StrictVarName: 'Variable name may not be eval or arguments in strict mode', >- StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', >- StrictParamDupe: 'Strict mode function may not have duplicate parameter names', >- StrictFunctionName: 'Function name may not be eval or arguments in strict mode', >- StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', >- StrictDelete: 'Delete of an unqualified identifier in strict mode.', >- StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode', >- AccessorDataProperty: 'Object literal may not have data and accessor property with the same name', >- AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name', >- StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', >- StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', >- StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', >- StrictReservedWord: 'Use of future reserved word in strict mode' >- }; >- >- // See also tools/generate-unicode-regex.py. >- Regex = { >- NonAsciiIdentifierStart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]'), >- NonAsciiIdentifierPart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]') >- }; >- >- // Ensure the condition is true, otherwise throw an error. >- // This is only to have a better contract semantic, i.e. another safety net >- // to catch a logic error. The condition shall be fulfilled in normal case. >- // Do NOT use this to enforce a certain condition on any user input. >- >- function assert(condition, message) { >- if (!condition) { >- throw new Error('ASSERT: ' + message); >- } >- } >- >- function isDecimalDigit(ch) { >- return (ch >= 48 && ch <= 57); // 0..9 >- } >- >- function isHexDigit(ch) { >- return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; >- } >- >- function isOctalDigit(ch) { >- return '01234567'.indexOf(ch) >= 0; >- } >- >- >- // 7.2 White Space >- >- function isWhiteSpace(ch) { >- return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || >- (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0); >- } >- >- // 7.3 Line Terminators >- >- function isLineTerminator(ch) { >- return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); >- } >- >- // 7.6 Identifier Names and Identifiers >- >- function isIdentifierStart(ch) { >- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) >- (ch >= 65 && ch <= 90) || // A..Z >- (ch >= 97 && ch <= 122) || // a..z >- (ch === 92) || // \ (backslash) >- ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); >- } >- >- function isIdentifierPart(ch) { >- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) >- (ch >= 65 && ch <= 90) || // A..Z >- (ch >= 97 && ch <= 122) || // a..z >- (ch >= 48 && ch <= 57) || // 0..9 >- (ch === 92) || // \ (backslash) >- ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); >- } >- >- // 7.6.1.2 Future Reserved Words >- >- function isFutureReservedWord(id) { >- switch (id) { >- case 'class': >- case 'enum': >- case 'export': >- case 'extends': >- case 'import': >- case 'super': >- return true; >- default: >- return false; >- } >- } >- >- function isStrictModeReservedWord(id) { >- switch (id) { >- case 'implements': >- case 'interface': >- case 'package': >- case 'private': >- case 'protected': >- case 'public': >- case 'static': >- case 'yield': >- case 'let': >- return true; >- default: >- return false; >- } >- } >- >- function isRestrictedWord(id) { >- return id === 'eval' || id === 'arguments'; >- } >- >- // 7.6.1.1 Keywords >- >- function isKeyword(id) { >- if (strict && isStrictModeReservedWord(id)) { >- return true; >- } >- >- // 'const' is specialized as Keyword in V8. >- // 'yield' and 'let' are for compatiblity with SpiderMonkey and ES.next. >- // Some others are from future reserved words. >- >- switch (id.length) { >- case 2: >- return (id === 'if') || (id === 'in') || (id === 'do'); >- case 3: >- return (id === 'var') || (id === 'for') || (id === 'new') || >- (id === 'try') || (id === 'let'); >- case 4: >- return (id === 'this') || (id === 'else') || (id === 'case') || >- (id === 'void') || (id === 'with') || (id === 'enum'); >- case 5: >- return (id === 'while') || (id === 'break') || (id === 'catch') || >- (id === 'throw') || (id === 'const') || (id === 'yield') || >- (id === 'class') || (id === 'super'); >- case 6: >- return (id === 'return') || (id === 'typeof') || (id === 'delete') || >- (id === 'switch') || (id === 'export') || (id === 'import'); >- case 7: >- return (id === 'default') || (id === 'finally') || (id === 'extends'); >- case 8: >- return (id === 'function') || (id === 'continue') || (id === 'debugger'); >- case 10: >- return (id === 'instanceof'); >- default: >- return false; >- } >- } >- >- // 7.4 Comments >- >- function addComment(type, value, start, end, loc) { >- var comment, attacher; >- >- assert(typeof start === 'number', 'Comment must have valid position'); >- >- // Because the way the actual token is scanned, often the comments >- // (if any) are skipped twice during the lexical analysis. >- // Thus, we need to skip adding a comment if the comment array already >- // handled it. >- if (state.lastCommentStart >= start) { >- return; >- } >- state.lastCommentStart = start; >- >- comment = { >- type: type, >- value: value >- }; >- if (extra.range) { >- comment.range = [start, end]; >- } >- if (extra.loc) { >- comment.loc = loc; >- } >- extra.comments.push(comment); >- >- if (extra.attachComment) { >- attacher = { >- comment: comment, >- leading: null, >- trailing: null, >- range: [start, end] >- }; >- extra.pendingComments.push(attacher); >- } >- } >- >- function skipSingleLineComment() { >- var start, loc, ch, comment; >- >- start = index - 2; >- loc = { >- start: { >- line: lineNumber, >- column: index - lineStart - 2 >- } >- }; >- >- while (index < length) { >- ch = source.charCodeAt(index); >- ++index; >- if (isLineTerminator(ch)) { >- if (extra.comments) { >- comment = source.slice(start + 2, index - 1); >- loc.end = { >- line: lineNumber, >- column: index - lineStart - 1 >- }; >- addComment('Line', comment, start, index - 1, loc); >- } >- if (ch === 13 && source.charCodeAt(index) === 10) { >- ++index; >- } >- ++lineNumber; >- lineStart = index; >- return; >- } >- } >- >- if (extra.comments) { >- comment = source.slice(start + 2, index); >- loc.end = { >- line: lineNumber, >- column: index - lineStart >- }; >- addComment('Line', comment, start, index, loc); >- } >- } >- >- function skipMultiLineComment() { >- var start, loc, ch, comment; >- >- if (extra.comments) { >- start = index - 2; >- loc = { >- start: { >- line: lineNumber, >- column: index - lineStart - 2 >- } >- }; >- } >- >- while (index < length) { >- ch = source.charCodeAt(index); >- if (isLineTerminator(ch)) { >- if (ch === 13 && source.charCodeAt(index + 1) === 10) { >- ++index; >- } >- ++lineNumber; >- ++index; >- lineStart = index; >- if (index >= length) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } else if (ch === 42) { >- // Block comment ends with '*/' (char #42, char #47). >- if (source.charCodeAt(index + 1) === 47) { >- ++index; >- ++index; >- if (extra.comments) { >- comment = source.slice(start + 2, index - 2); >- loc.end = { >- line: lineNumber, >- column: index - lineStart >- }; >- addComment('Block', comment, start, index, loc); >- } >- return; >- } >- ++index; >- } else { >- ++index; >- } >- } >- >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- >- function skipComment() { >- var ch, start; >- >- start = (index === 0); >- while (index < length) { >- ch = source.charCodeAt(index); >- >- if (isWhiteSpace(ch)) { >- ++index; >- } else if (isLineTerminator(ch)) { >- ++index; >- if (ch === 13 && source.charCodeAt(index) === 10) { >- ++index; >- } >- ++lineNumber; >- lineStart = index; >- start = true; >- } else if (ch === 47) { // 47 is '/' >- ch = source.charCodeAt(index + 1); >- if (ch === 47) { >- ++index; >- ++index; >- skipSingleLineComment(); >- start = true; >- } else if (ch === 42) { // 42 is '*' >- ++index; >- ++index; >- skipMultiLineComment(); >- } else { >- break; >- } >- } else if (start && ch === 45) { // 45 is '-' >- // 62 is '>' >- if ((source.charCodeAt(index + 1) === 45) && (source.charCodeAt(index + 2) === 62)) { >- // '-->' is a single-line comment >- index += 3; >- skipSingleLineComment(); >- } else { >- break; >- } >- } else if (ch === 60) { // 60 is '<' >- if (source.slice(index + 1, index + 4) === '!--') { >- ++index; // `<` >- ++index; // `!` >- ++index; // `-` >- ++index; // `-` >- skipSingleLineComment(); >- } else { >- break; >- } >- } else { >- break; >- } >- } >- } >- >- function scanHexEscape(prefix) { >- var i, len, ch, code = 0; >- >- len = (prefix === 'u') ? 4 : 2; >- for (i = 0; i < len; ++i) { >- if (index < length && isHexDigit(source[index])) { >- ch = source[index++]; >- code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); >- } else { >- return ''; >- } >- } >- return String.fromCharCode(code); >- } >- >- function getEscapedIdentifier() { >- var ch, id; >- >- ch = source.charCodeAt(index++); >- id = String.fromCharCode(ch); >- >- // '\u' (char #92, char #117) denotes an escaped character. >- if (ch === 92) { >- if (source.charCodeAt(index) !== 117) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- ++index; >- ch = scanHexEscape('u'); >- if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- id = ch; >- } >- >- while (index < length) { >- ch = source.charCodeAt(index); >- if (!isIdentifierPart(ch)) { >- break; >- } >- ++index; >- id += String.fromCharCode(ch); >- >- // '\u' (char #92, char #117) denotes an escaped character. >- if (ch === 92) { >- id = id.substr(0, id.length - 1); >- if (source.charCodeAt(index) !== 117) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- ++index; >- ch = scanHexEscape('u'); >- if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- id += ch; >- } >- } >- >- return id; >- } >- >- function getIdentifier() { >- var start, ch; >- >- start = index++; >- while (index < length) { >- ch = source.charCodeAt(index); >- if (ch === 92) { >- // Blackslash (char #92) marks Unicode escape sequence. >- index = start; >- return getEscapedIdentifier(); >- } >- if (isIdentifierPart(ch)) { >- ++index; >- } else { >- break; >- } >- } >- >- return source.slice(start, index); >- } >- >- function scanIdentifier() { >- var start, id, type; >- >- start = index; >- >- // Backslash (char #92) starts an escaped character. >- id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier(); >- >- // There is no keyword or literal with only one character. >- // Thus, it must be an identifier. >- if (id.length === 1) { >- type = Token.Identifier; >- } else if (isKeyword(id)) { >- type = Token.Keyword; >- } else if (id === 'null') { >- type = Token.NullLiteral; >- } else if (id === 'true' || id === 'false') { >- type = Token.BooleanLiteral; >- } else { >- type = Token.Identifier; >- } >- >- return { >- type: type, >- value: id, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- >- // 7.7 Punctuators >- >- function scanPunctuator() { >- var start = index, >- code = source.charCodeAt(index), >- code2, >- ch1 = source[index], >- ch2, >- ch3, >- ch4; >- >- switch (code) { >- >- // Check for most common single-character punctuators. >- case 46: // . dot >- case 40: // ( open bracket >- case 41: // ) close bracket >- case 59: // ; semicolon >- case 44: // , comma >- case 123: // { open curly brace >- case 125: // } close curly brace >- case 91: // [ >- case 93: // ] >- case 58: // : >- case 63: // ? >- case 126: // ~ >- ++index; >- if (extra.tokenize) { >- if (code === 40) { >- extra.openParenToken = extra.tokens.length; >- } else if (code === 123) { >- extra.openCurlyToken = extra.tokens.length; >- } >- } >- return { >- type: Token.Punctuator, >- value: String.fromCharCode(code), >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- >- default: >- code2 = source.charCodeAt(index + 1); >- >- // '=' (char #61) marks an assignment or comparison operator. >- if (code2 === 61) { >- switch (code) { >- case 37: // % >- case 38: // & >- case 42: // *: >- case 43: // + >- case 45: // - >- case 47: // / >- case 60: // < >- case 62: // > >- case 94: // ^ >- case 124: // | >- index += 2; >- return { >- type: Token.Punctuator, >- value: String.fromCharCode(code) + String.fromCharCode(code2), >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- >- case 33: // ! >- case 61: // = >- index += 2; >- >- // !== and === >- if (source.charCodeAt(index) === 61) { >- ++index; >- } >- return { >- type: Token.Punctuator, >- value: source.slice(start, index), >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- default: >- break; >- } >- } >- break; >- } >- >- // Peek more characters. >- >- ch2 = source[index + 1]; >- ch3 = source[index + 2]; >- ch4 = source[index + 3]; >- >- // 4-character punctuator: >>>= >- >- if (ch1 === '>' && ch2 === '>' && ch3 === '>') { >- if (ch4 === '=') { >- index += 4; >- return { >- type: Token.Punctuator, >- value: '>>>=', >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- } >- >- // 3-character punctuators: === !== >>> <<= >>= >- >- if (ch1 === '>' && ch2 === '>' && ch3 === '>') { >- index += 3; >- return { >- type: Token.Punctuator, >- value: '>>>', >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- if (ch1 === '<' && ch2 === '<' && ch3 === '=') { >- index += 3; >- return { >- type: Token.Punctuator, >- value: '<<=', >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- if (ch1 === '>' && ch2 === '>' && ch3 === '=') { >- index += 3; >- return { >- type: Token.Punctuator, >- value: '>>=', >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- // Other 2-character punctuators: ++ -- << >> && || >- >- if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0)) { >- index += 2; >- return { >- type: Token.Punctuator, >- value: ch1 + ch2, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { >- ++index; >- return { >- type: Token.Punctuator, >- value: ch1, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- >- // 7.8.3 Numeric Literals >- >- function scanHexLiteral(start) { >- var number = ''; >- >- while (index < length) { >- if (!isHexDigit(source[index])) { >- break; >- } >- number += source[index++]; >- } >- >- if (number.length === 0) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- >- if (isIdentifierStart(source.charCodeAt(index))) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- >- return { >- type: Token.NumericLiteral, >- value: parseInt('0x' + number, 16), >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- function scanOctalLiteral(start) { >- var number = '0' + source[index++]; >- while (index < length) { >- if (!isOctalDigit(source[index])) { >- break; >- } >- number += source[index++]; >- } >- >- if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- >- return { >- type: Token.NumericLiteral, >- value: parseInt(number, 8), >- octal: true, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- function scanNumericLiteral() { >- var number, start, ch; >- >- ch = source[index]; >- assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), >- 'Numeric literal must start with a decimal digit or a decimal point'); >- >- start = index; >- number = ''; >- if (ch !== '.') { >- number = source[index++]; >- ch = source[index]; >- >- // Hex number starts with '0x'. >- // Octal number starts with '0'. >- if (number === '0') { >- if (ch === 'x' || ch === 'X') { >- ++index; >- return scanHexLiteral(start); >- } >- if (isOctalDigit(ch)) { >- return scanOctalLiteral(start); >- } >- >- // decimal number starts with '0' such as '09' is illegal. >- if (ch && isDecimalDigit(ch.charCodeAt(0))) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } >- >- while (isDecimalDigit(source.charCodeAt(index))) { >- number += source[index++]; >- } >- ch = source[index]; >- } >- >- if (ch === '.') { >- number += source[index++]; >- while (isDecimalDigit(source.charCodeAt(index))) { >- number += source[index++]; >- } >- ch = source[index]; >- } >- >- if (ch === 'e' || ch === 'E') { >- number += source[index++]; >- >- ch = source[index]; >- if (ch === '+' || ch === '-') { >- number += source[index++]; >- } >- if (isDecimalDigit(source.charCodeAt(index))) { >- while (isDecimalDigit(source.charCodeAt(index))) { >- number += source[index++]; >- } >- } else { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- } >- >- if (isIdentifierStart(source.charCodeAt(index))) { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- >- return { >- type: Token.NumericLiteral, >- value: parseFloat(number), >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- // 7.8.4 String Literals >- >- function scanStringLiteral() { >- var str = '', quote, start, ch, code, unescaped, restore, octal = false; >- >- quote = source[index]; >- assert((quote === '\'' || quote === '"'), >- 'String literal must starts with a quote'); >- >- start = index; >- ++index; >- >- while (index < length) { >- ch = source[index++]; >- >- if (ch === quote) { >- quote = ''; >- break; >- } else if (ch === '\\') { >- ch = source[index++]; >- if (!ch || !isLineTerminator(ch.charCodeAt(0))) { >- switch (ch) { >- case 'n': >- str += '\n'; >- break; >- case 'r': >- str += '\r'; >- break; >- case 't': >- str += '\t'; >- break; >- case 'u': >- case 'x': >- restore = index; >- unescaped = scanHexEscape(ch); >- if (unescaped) { >- str += unescaped; >- } else { >- index = restore; >- str += ch; >- } >- break; >- case 'b': >- str += '\b'; >- break; >- case 'f': >- str += '\f'; >- break; >- case 'v': >- str += '\x0B'; >- break; >- >- default: >- if (isOctalDigit(ch)) { >- code = '01234567'.indexOf(ch); >- >- // \0 is not octal escape sequence >- if (code !== 0) { >- octal = true; >- } >- >- if (index < length && isOctalDigit(source[index])) { >- octal = true; >- code = code * 8 + '01234567'.indexOf(source[index++]); >- >- // 3 digits are only allowed when string starts >- // with 0, 1, 2, 3 >- if ('0123'.indexOf(ch) >= 0 && >- index < length && >- isOctalDigit(source[index])) { >- code = code * 8 + '01234567'.indexOf(source[index++]); >- } >- } >- str += String.fromCharCode(code); >- } else { >- str += ch; >- } >- break; >- } >- } else { >- ++lineNumber; >- if (ch === '\r' && source[index] === '\n') { >- ++index; >- } >- } >- } else if (isLineTerminator(ch.charCodeAt(0))) { >- break; >- } else { >- str += ch; >- } >- } >- >- if (quote !== '') { >- throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); >- } >- >- return { >- type: Token.StringLiteral, >- value: str, >- octal: octal, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- >- function scanRegExp() { >- var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false; >- >- lookahead = null; >- skipComment(); >- >- start = index; >- ch = source[index]; >- assert(ch === '/', 'Regular expression literal must start with a slash'); >- str = source[index++]; >- >- while (index < length) { >- ch = source[index++]; >- str += ch; >- if (ch === '\\') { >- ch = source[index++]; >- // ECMA-262 7.8.5 >- if (isLineTerminator(ch.charCodeAt(0))) { >- throwError({}, Messages.UnterminatedRegExp); >- } >- str += ch; >- } else if (isLineTerminator(ch.charCodeAt(0))) { >- throwError({}, Messages.UnterminatedRegExp); >- } else if (classMarker) { >- if (ch === ']') { >- classMarker = false; >- } >- } else { >- if (ch === '/') { >- terminated = true; >- break; >- } else if (ch === '[') { >- classMarker = true; >- } >- } >- } >- >- if (!terminated) { >- throwError({}, Messages.UnterminatedRegExp); >- } >- >- // Exclude leading and trailing slash. >- pattern = str.substr(1, str.length - 2); >- >- flags = ''; >- while (index < length) { >- ch = source[index]; >- if (!isIdentifierPart(ch.charCodeAt(0))) { >- break; >- } >- >- ++index; >- if (ch === '\\' && index < length) { >- ch = source[index]; >- if (ch === 'u') { >- ++index; >- restore = index; >- ch = scanHexEscape('u'); >- if (ch) { >- flags += ch; >- for (str += '\\u'; restore < index; ++restore) { >- str += source[restore]; >- } >- } else { >- index = restore; >- flags += 'u'; >- str += '\\u'; >- } >- } else { >- str += '\\'; >- } >- } else { >- flags += ch; >- str += ch; >- } >- } >- >- try { >- value = new RegExp(pattern, flags); >- } catch (e) { >- throwError({}, Messages.InvalidRegExp); >- } >- >- >- >- if (extra.tokenize) { >- return { >- type: Token.RegularExpression, >- value: value, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [start, index] >- }; >- } >- return { >- literal: str, >- value: value, >- range: [start, index] >- }; >- } >- >- function collectRegex() { >- var pos, loc, regex, token; >- >- skipComment(); >- >- pos = index; >- loc = { >- start: { >- line: lineNumber, >- column: index - lineStart >- } >- }; >- >- regex = scanRegExp(); >- loc.end = { >- line: lineNumber, >- column: index - lineStart >- }; >- >- if (!extra.tokenize) { >- // Pop the previous token, which is likely '/' or '/=' >- if (extra.tokens.length > 0) { >- token = extra.tokens[extra.tokens.length - 1]; >- if (token.range[0] === pos && token.type === 'Punctuator') { >- if (token.value === '/' || token.value === '/=') { >- extra.tokens.pop(); >- } >- } >- } >- >- extra.tokens.push({ >- type: 'RegularExpression', >- value: regex.literal, >- range: [pos, index], >- loc: loc >- }); >- } >- >- return regex; >- } >- >- function isIdentifierName(token) { >- return token.type === Token.Identifier || >- token.type === Token.Keyword || >- token.type === Token.BooleanLiteral || >- token.type === Token.NullLiteral; >- } >- >- function advanceSlash() { >- var prevToken, >- checkToken; >- // Using the following algorithm: >- // https://github.com/mozilla/sweet.js/wiki/design >- prevToken = extra.tokens[extra.tokens.length - 1]; >- if (!prevToken) { >- // Nothing before that: it cannot be a division. >- return collectRegex(); >- } >- if (prevToken.type === 'Punctuator') { >- if (prevToken.value === ')') { >- checkToken = extra.tokens[extra.openParenToken - 1]; >- if (checkToken && >- checkToken.type === 'Keyword' && >- (checkToken.value === 'if' || >- checkToken.value === 'while' || >- checkToken.value === 'for' || >- checkToken.value === 'with')) { >- return collectRegex(); >- } >- return scanPunctuator(); >- } >- if (prevToken.value === '}') { >- // Dividing a function by anything makes little sense, >- // but we have to check for that. >- if (extra.tokens[extra.openCurlyToken - 3] && >- extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') { >- // Anonymous function. >- checkToken = extra.tokens[extra.openCurlyToken - 4]; >- if (!checkToken) { >- return scanPunctuator(); >- } >- } else if (extra.tokens[extra.openCurlyToken - 4] && >- extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') { >- // Named function. >- checkToken = extra.tokens[extra.openCurlyToken - 5]; >- if (!checkToken) { >- return collectRegex(); >- } >- } else { >- return scanPunctuator(); >- } >- // checkToken determines whether the function is >- // a declaration or an expression. >- if (FnExprTokens.indexOf(checkToken.value) >= 0) { >- // It is an expression. >- return scanPunctuator(); >- } >- // It is a declaration. >- return collectRegex(); >- } >- return collectRegex(); >- } >- if (prevToken.type === 'Keyword') { >- return collectRegex(); >- } >- return scanPunctuator(); >- } >- >- function advance() { >- var ch; >- >- skipComment(); >- >- if (index >= length) { >- return { >- type: Token.EOF, >- lineNumber: lineNumber, >- lineStart: lineStart, >- range: [index, index] >- }; >- } >- >- ch = source.charCodeAt(index); >- >- // Very common: ( and ) and ; >- if (ch === 40 || ch === 41 || ch === 58) { >- return scanPunctuator(); >- } >- >- // String literal starts with single quote (#39) or double quote (#34). >- if (ch === 39 || ch === 34) { >- return scanStringLiteral(); >- } >- >- if (isIdentifierStart(ch)) { >- return scanIdentifier(); >- } >- >- // Dot (.) char #46 can also start a floating-point number, hence the need >- // to check the next character. >- if (ch === 46) { >- if (isDecimalDigit(source.charCodeAt(index + 1))) { >- return scanNumericLiteral(); >- } >- return scanPunctuator(); >- } >- >- if (isDecimalDigit(ch)) { >- return scanNumericLiteral(); >- } >- >- // Slash (/) char #47 can also start a regex. >- if (extra.tokenize && ch === 47) { >- return advanceSlash(); >- } >- >- return scanPunctuator(); >- } >- >- function collectToken() { >- var start, loc, token, range, value; >- >- skipComment(); >- start = index; >- loc = { >- start: { >- line: lineNumber, >- column: index - lineStart >- } >- }; >- >- token = advance(); >- loc.end = { >- line: lineNumber, >- column: index - lineStart >- }; >- >- if (token.type !== Token.EOF) { >- range = [token.range[0], token.range[1]]; >- value = source.slice(token.range[0], token.range[1]); >- extra.tokens.push({ >- type: TokenName[token.type], >- value: value, >- range: range, >- loc: loc >- }); >- } >- >- return token; >- } >- >- function lex() { >- var token; >- >- token = lookahead; >- index = token.range[1]; >- lineNumber = token.lineNumber; >- lineStart = token.lineStart; >- >- lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); >- >- index = token.range[1]; >- lineNumber = token.lineNumber; >- lineStart = token.lineStart; >- >- return token; >- } >- >- function peek() { >- var pos, line, start; >- >- pos = index; >- line = lineNumber; >- start = lineStart; >- lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); >- index = pos; >- lineNumber = line; >- lineStart = start; >- } >- >- SyntaxTreeDelegate = { >- >- name: 'SyntaxTree', >- >- markStart: function () { >- if (extra.loc) { >- state.markerStack.push(index - lineStart); >- state.markerStack.push(lineNumber); >- } >- if (extra.range) { >- state.markerStack.push(index); >- } >- }, >- >- processComment: function (node) { >- var i, attacher, pos, len, candidate; >- >- if (typeof node.type === 'undefined' || node.type === Syntax.Program) { >- return; >- } >- >- // Check for possible additional trailing comments. >- peek(); >- >- for (i = 0; i < extra.pendingComments.length; ++i) { >- attacher = extra.pendingComments[i]; >- if (node.range[0] >= attacher.comment.range[1]) { >- candidate = attacher.leading; >- if (candidate) { >- pos = candidate.range[0]; >- len = candidate.range[1] - pos; >- if (node.range[0] <= pos && (node.range[1] - node.range[0] >= len)) { >- attacher.leading = node; >- } >- } else { >- attacher.leading = node; >- } >- } >- if (node.range[1] <= attacher.comment.range[0]) { >- candidate = attacher.trailing; >- if (candidate) { >- pos = candidate.range[0]; >- len = candidate.range[1] - pos; >- if (node.range[0] <= pos && (node.range[1] - node.range[0] >= len)) { >- attacher.trailing = node; >- } >- } else { >- attacher.trailing = node; >- } >- } >- } >- }, >- >- markEnd: function (node) { >- if (extra.range) { >- node.range = [state.markerStack.pop(), index]; >- } >- if (extra.loc) { >- node.loc = { >- start: { >- line: state.markerStack.pop(), >- column: state.markerStack.pop() >- }, >- end: { >- line: lineNumber, >- column: index - lineStart >- } >- }; >- this.postProcess(node); >- } >- if (extra.attachComment) { >- this.processComment(node); >- } >- return node; >- }, >- >- markEndIf: function (node) { >- // mamacdon: in tolerant mode, node passed to the delegate may be null >- if (!node || node.range || node.loc) { >- if (extra.loc) { >- state.markerStack.pop(); >- state.markerStack.pop(); >- } >- if (extra.range) { >- state.markerStack.pop(); >- } >- } else { >- this.markEnd(node); >- } >- return node; >- }, >- >- postProcess: function (node) { >- if (extra.source) { >- node.loc.source = extra.source; >- } >- return node; >- }, >- >- createArrayExpression: function (elements) { >- return { >- type: Syntax.ArrayExpression, >- elements: elements >- }; >- }, >- >- createAssignmentExpression: function (operator, left, right) { >- return { >- type: Syntax.AssignmentExpression, >- operator: operator, >- left: left, >- right: right >- }; >- }, >- >- createBinaryExpression: function (operator, left, right) { >- var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : >- Syntax.BinaryExpression; >- return { >- type: type, >- operator: operator, >- left: left, >- right: right >- }; >- }, >- >- createBlockStatement: function (body) { >- return { >- type: Syntax.BlockStatement, >- body: body >- }; >- }, >- >- createBreakStatement: function (label) { >- return { >- type: Syntax.BreakStatement, >- label: label >- }; >- }, >- >- createCallExpression: function (callee, args) { >- return { >- type: Syntax.CallExpression, >- callee: callee, >- 'arguments': args >- }; >- }, >- >- createCatchClause: function (param, body) { >- return { >- type: Syntax.CatchClause, >- param: param, >- body: body >- }; >- }, >- >- createConditionalExpression: function (test, consequent, alternate) { >- return { >- type: Syntax.ConditionalExpression, >- test: test, >- consequent: consequent, >- alternate: alternate >- }; >- }, >- >- createContinueStatement: function (label) { >- return { >- type: Syntax.ContinueStatement, >- label: label >- }; >- }, >- >- createDebuggerStatement: function () { >- return { >- type: Syntax.DebuggerStatement >- }; >- }, >- >- createDoWhileStatement: function (body, test) { >- return { >- type: Syntax.DoWhileStatement, >- body: body, >- test: test >- }; >- }, >- >- createEmptyStatement: function () { >- return { >- type: Syntax.EmptyStatement >- }; >- }, >- >- createExpressionStatement: function (expression) { >- return { >- type: Syntax.ExpressionStatement, >- expression: expression >- }; >- }, >- >- createForStatement: function (init, test, update, body) { >- return { >- type: Syntax.ForStatement, >- init: init, >- test: test, >- update: update, >- body: body >- }; >- }, >- >- createForInStatement: function (left, right, body) { >- return { >- type: Syntax.ForInStatement, >- left: left, >- right: right, >- body: body, >- each: false >- }; >- }, >- >- createFunctionDeclaration: function (id, params, defaults, body) { >- return { >- type: Syntax.FunctionDeclaration, >- id: id, >- params: params, >- defaults: defaults, >- body: body, >- rest: null, >- generator: false, >- expression: false >- }; >- }, >- >- createFunctionExpression: function (id, params, defaults, body) { >- return { >- type: Syntax.FunctionExpression, >- id: id, >- params: params, >- defaults: defaults, >- body: body, >- rest: null, >- generator: false, >- expression: false >- }; >- }, >- >- createIdentifier: function (name) { >- return { >- type: Syntax.Identifier, >- name: name >- }; >- }, >- >- createIfStatement: function (test, consequent, alternate) { >- return { >- type: Syntax.IfStatement, >- test: test, >- consequent: consequent, >- alternate: alternate >- }; >- }, >- >- createLabeledStatement: function (label, body) { >- return { >- type: Syntax.LabeledStatement, >- label: label, >- body: body >- }; >- }, >- >- createLiteral: function (token) { >- return { >- type: Syntax.Literal, >- value: token.value, >- raw: source.slice(token.range[0], token.range[1]) >- }; >- }, >- >- createMemberExpression: function (accessor, object, property) { >- return { >- type: Syntax.MemberExpression, >- computed: accessor === '[', >- object: object, >- property: property >- }; >- }, >- >- createNewExpression: function (callee, args) { >- return { >- type: Syntax.NewExpression, >- callee: callee, >- 'arguments': args >- }; >- }, >- >- createObjectExpression: function (properties) { >- return { >- type: Syntax.ObjectExpression, >- properties: properties >- }; >- }, >- >- createPostfixExpression: function (operator, argument) { >- return { >- type: Syntax.UpdateExpression, >- operator: operator, >- argument: argument, >- prefix: false >- }; >- }, >- >- createProgram: function (body) { >- return { >- type: Syntax.Program, >- body: body >- }; >- }, >- >- createProperty: function (kind, key, value) { >- return { >- type: Syntax.Property, >- key: key, >- value: value, >- kind: kind >- }; >- }, >- >- createReturnStatement: function (argument) { >- return { >- type: Syntax.ReturnStatement, >- argument: argument >- }; >- }, >- >- createSequenceExpression: function (expressions) { >- return { >- type: Syntax.SequenceExpression, >- expressions: expressions >- }; >- }, >- >- createSwitchCase: function (test, consequent) { >- return { >- type: Syntax.SwitchCase, >- test: test, >- consequent: consequent >- }; >- }, >- >- createSwitchStatement: function (discriminant, cases) { >- return { >- type: Syntax.SwitchStatement, >- discriminant: discriminant, >- cases: cases >- }; >- }, >- >- createThisExpression: function () { >- return { >- type: Syntax.ThisExpression >- }; >- }, >- >- createThrowStatement: function (argument) { >- return { >- type: Syntax.ThrowStatement, >- argument: argument >- }; >- }, >- >- createTryStatement: function (block, guardedHandlers, handlers, finalizer) { >- return { >- type: Syntax.TryStatement, >- block: block, >- guardedHandlers: guardedHandlers, >- handlers: handlers, >- finalizer: finalizer >- }; >- }, >- >- createUnaryExpression: function (operator, argument) { >- if (operator === '++' || operator === '--') { >- return { >- type: Syntax.UpdateExpression, >- operator: operator, >- argument: argument, >- prefix: true >- }; >- } >- return { >- type: Syntax.UnaryExpression, >- operator: operator, >- argument: argument, >- prefix: true >- }; >- }, >- >- createVariableDeclaration: function (declarations, kind) { >- return { >- type: Syntax.VariableDeclaration, >- declarations: declarations, >- kind: kind >- }; >- }, >- >- createVariableDeclarator: function (id, init) { >- return { >- type: Syntax.VariableDeclarator, >- id: id, >- init: init >- }; >- }, >- >- createWhileStatement: function (test, body) { >- return { >- type: Syntax.WhileStatement, >- test: test, >- body: body >- }; >- }, >- >- createWithStatement: function (object, body) { >- return { >- type: Syntax.WithStatement, >- object: object, >- body: body >- }; >- } >- }; >- >- // Return true if there is a line terminator before the next token. >- >- function peekLineTerminator() { >- var pos, line, start, found; >- >- pos = index; >- line = lineNumber; >- start = lineStart; >- skipComment(); >- found = lineNumber !== line; >- index = pos; >- lineNumber = line; >- lineStart = start; >- >- return found; >- } >- >- // Throw an exception >- >- function throwError(token, messageFormat) { >- var error, >- args = Array.prototype.slice.call(arguments, 2), >- msg = messageFormat.replace( >- /%(\d)/g, >- function (whole, index) { >- assert(index < args.length, 'Message reference must be in range'); >- return args[index]; >- } >- ); >- >- if (typeof token.lineNumber === 'number') { >- error = new Error('Line ' + token.lineNumber + ': ' + msg); >- error.index = token.range[0]; >- // mamacdon a09739e >- // mamacdon @ 1.0.0 esprima.js:1198 >- error.end = token.range[1]; >- error.token = token.value; >- error.lineNumber = token.lineNumber; >- error.column = token.range[0] - lineStart + 1; >- } else { >- error = new Error('Line ' + lineNumber + ': ' + msg); >- error.index = index; >- error.lineNumber = lineNumber; >- error.column = index - lineStart + 1; >- } >- >- error.description = msg; >- throw error; >- } >- >- // mamacdon: in tolerant mode, records the error and returns undefined. If non tolerant, throws. >- function throwErrorTolerant() { >- try { >- throwError.apply(null, arguments); >- } catch (e) { >- if (extra.errors) { >- extra.errors.push(e); >- } else { >- throw e; >- } >- } >- } >- >- // Throw an exception because of the token. >- >- function throwUnexpected(token) { >- if (token.type === Token.EOF) { >- throwError(token, Messages.UnexpectedEOS); >- } >- >- if (token.type === Token.NumericLiteral) { >- throwError(token, Messages.UnexpectedNumber); >- } >- >- if (token.type === Token.StringLiteral) { >- throwError(token, Messages.UnexpectedString); >- } >- >- if (token.type === Token.Identifier) { >- throwError(token, Messages.UnexpectedIdentifier); >- } >- >- if (token.type === Token.Keyword) { >- if (isFutureReservedWord(token.value)) { >- throwError(token, Messages.UnexpectedReserved); >- } else if (strict && isStrictModeReservedWord(token.value)) { >- throwErrorTolerant(token, Messages.StrictReservedWord); >- } >- throwError(token, Messages.UnexpectedToken, token.value); >- } >- >- // BooleanLiteral, NullLiteral, or Punctuator. >- throwError(token, Messages.UnexpectedToken, token.value); >- } >- >- // Expect the next token to match the specified punctuator. >- // If not, an exception will be thrown. >- >- function expect(value) { >- var token = lex(); >- if (token.type !== Token.Punctuator || token.value !== value) { >- throwUnexpected(token); >- } >- } >- >- // Expect the next token to match the specified keyword. >- // If not, an exception will be thrown. >- >- function expectKeyword(keyword) { >- var token = lex(); >- if (token.type !== Token.Keyword || token.value !== keyword) { >- throwUnexpected(token); >- } >- } >- >- // Return true if the next token matches the specified punctuator. >- >- function match(value) { >- return lookahead.type === Token.Punctuator && lookahead.value === value; >- } >- >- // Return true if the next token matches the specified keyword >- >- function matchKeyword(keyword) { >- return lookahead.type === Token.Keyword && lookahead.value === keyword; >- } >- >- // Return true if the next token is an assignment operator >- >- function matchAssign() { >- var op; >- >- if (lookahead.type !== Token.Punctuator) { >- return false; >- } >- op = lookahead.value; >- return op === '=' || >- op === '*=' || >- op === '/=' || >- op === '%=' || >- op === '+=' || >- op === '-=' || >- op === '<<=' || >- op === '>>=' || >- op === '>>>=' || >- op === '&=' || >- op === '^=' || >- op === '|='; >- } >- >- function consumeSemicolon() { >- var line; >- >- // Catch the very common case first: immediately a semicolon (char #59). >- if (source.charCodeAt(index) === 59) { >- lex(); >- return; >- } >- >- line = lineNumber; >- skipComment(); >- if (lineNumber !== line) { >- return; >- } >- >- if (match(';')) { >- lex(); >- return; >- } >- >- if (lookahead.type !== Token.EOF && !match('}')) { >- var badToken = lookahead; >- if (extra.errors) { >- rewind(); // mutates lookahead >- } >- throwUnexpected(badToken); >- } >- } >- >- // Return true if provided expression is LeftHandSideExpression >- >- function isLeftHandSide(expr) { >- return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; >- } >- >- // 11.1.4 Array Initialiser >- >- function parseArrayInitialiser() { >- var elements = []; >- >- expect('['); >- >- while (!match(']')) { >- if (match(',')) { >- lex(); >- elements.push(null); >- } else { >- elements.push(parseAssignmentExpression()); >- >- if (!match(']')) { >- expect(','); >- } >- } >- } >- >- expect(']'); >- >- return delegate.createArrayExpression(elements); >- } >- >- // 11.1.5 Object Initialiser >- >- function parsePropertyFunction(param, first) { >- var previousStrict, body; >- >- previousStrict = strict; >- skipComment(); >- delegate.markStart(); >- body = parseFunctionSourceElements(); >- if (first && strict && isRestrictedWord(param[0].name)) { >- throwErrorTolerant(first, Messages.StrictParamName); >- } >- strict = previousStrict; >- return delegate.markEnd(delegate.createFunctionExpression(null, param, [], body)); >- } >- >- function parseObjectPropertyKey() { >- var token; >- >- skipComment(); >- delegate.markStart(); >- token = lex(); >- >- // Note: This function is called only from parseObjectProperty(), where >- // EOF and Punctuator tokens are already filtered out. >- >- if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { >- if (strict && token.octal) { >- throwErrorTolerant(token, Messages.StrictOctalLiteral); >- } >- return delegate.markEnd(delegate.createLiteral(token)); >- } >- >- return delegate.markEnd(delegate.createIdentifier(token.value)); >- } >- >- function parseObjectProperty() { >- var token, key, id, value, param; >- >- token = lookahead; >- skipComment(); >- delegate.markStart(); >- >- if (token.type === Token.Identifier) { >- >- id = parseObjectPropertyKey(); >- >- // Property Assignment: Getter and Setter. >- >- if (token.value === 'get' && !match(':')) { >- key = parseObjectPropertyKey(); >- expect('('); >- expect(')'); >- value = parsePropertyFunction([]); >- return delegate.markEnd(delegate.createProperty('get', key, value)); >- } >- if (token.value === 'set' && !match(':')) { >- key = parseObjectPropertyKey(); >- expect('('); >- token = lookahead; >- if (token.type !== Token.Identifier) { >- expect(')'); >- throwErrorTolerant(token, Messages.UnexpectedToken, token.value); >- value = parsePropertyFunction([]); >- } else { >- param = [ parseVariableIdentifier() ]; >- expect(')'); >- value = parsePropertyFunction(param, token); >- } >- return delegate.markEnd(delegate.createProperty('set', key, value)); >- } >- expect(':'); >- value = parseAssignmentExpression(); >- return delegate.markEnd(delegate.createProperty('init', id, value)); >- } >- if (token.type === Token.EOF || token.type === Token.Punctuator) { >- throwUnexpected(token); >- } else { >- key = parseObjectPropertyKey(); >- expect(':'); >- value = parseAssignmentExpression(); >- return delegate.markEnd(delegate.createProperty('init', key, value)); >- } >- } >- >- function parseObjectInitialiser() { >- var properties = [], property, name, key, kind, map = {}, toString = String; >- >- expect('{'); >- >- while (!match('}')) { >- property = parseObjectProperty(); >- >- if (property.key.type === Syntax.Identifier) { >- name = property.key.name; >- } else { >- name = toString(property.key.value); >- } >- kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; >- >- key = '$' + name; >- if (Object.prototype.hasOwnProperty.call(map, key)) { >- if (map[key] === PropertyKind.Data) { >- if (strict && kind === PropertyKind.Data) { >- throwErrorTolerant({}, Messages.StrictDuplicateProperty); >- } else if (kind !== PropertyKind.Data) { >- throwErrorTolerant({}, Messages.AccessorDataProperty); >- } >- } else { >- if (kind === PropertyKind.Data) { >- throwErrorTolerant({}, Messages.AccessorDataProperty); >- } else if (map[key] & kind) { >- throwErrorTolerant({}, Messages.AccessorGetSet); >- } >- } >- map[key] |= kind; >- } else { >- map[key] = kind; >- } >- >- properties.push(property); >- >- if (!match('}')) { >- expect(','); >- } >- } >- >- expect('}'); >- >- return delegate.createObjectExpression(properties); >- } >- >- // 11.1.6 The Grouping Operator >- >- function parseGroupExpression() { >- var expr; >- >- expect('('); >- >- expr = parseExpression(); >- >- expect(')'); >- >- return expr; >- } >- >- >- // 11.1 Primary Expressions >- >- function parsePrimaryExpression() { >- var type, token, expr; >- >- if (match('(')) { >- return parseGroupExpression(); >- } >- >- type = lookahead.type; >- delegate.markStart(); >- >- if (type === Token.Identifier) { >- expr = delegate.createIdentifier(lex().value); >- } else if (type === Token.StringLiteral || type === Token.NumericLiteral) { >- if (strict && lookahead.octal) { >- throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); >- } >- expr = delegate.createLiteral(lex()); >- } else if (type === Token.Keyword) { >- if (matchKeyword('this')) { >- lex(); >- expr = delegate.createThisExpression(); >- } else if (matchKeyword('function')) { >- expr = parseFunctionExpression(); >- } >- } else if (type === Token.BooleanLiteral) { >- token = lex(); >- token.value = (token.value === 'true'); >- expr = delegate.createLiteral(token); >- } else if (type === Token.NullLiteral) { >- token = lex(); >- token.value = null; >- expr = delegate.createLiteral(token); >- } else if (match('[')) { >- expr = parseArrayInitialiser(); >- } else if (match('{')) { >- expr = parseObjectInitialiser(); >- } else if (match('/') || match('/=')) { >- if (typeof extra.tokens !== 'undefined') { >- expr = delegate.createLiteral(collectRegex()); >- } else { >- expr = delegate.createLiteral(scanRegExp()); >- } >- peek(); >- } >- >- if (expr) { >- return delegate.markEnd(expr); >- } >- >- return throwUnexpected(lex()); >- } >- >- // 11.2 Left-Hand-Side Expressions >- >- // mamacdon 1420b19 >- function parseArguments() { >- var args = []; >- >- expect('('); >- >- if (!match(')')) { >- while (index < length) { >- args.push(parseAssignmentExpression()); >- if (match(')')) { >- break; >- } >- try { >- expect(','); >- } catch (e) { >- if (extra.errors) { >- // pretend the argument list is done >- pushError(e); >- break; >- } else { >- throw e; >- } >- } >- } >- } >- >- try { >- expect(')'); >- } catch (e) { >- if (extra.errors) { >- // soldier on... >- pushError(e); >- } else { >- throw e; >- } >- } >- >- return args; >- } >- >- function parseNonComputedProperty() { >- var token; >- >- if (lookahead.lineNumber !== lineNumber) { >- // Token giving our identifier name lies on the following line, so go there before marking start >- index = lookahead.lineStart; >- } >- delegate.markStart(); >- token = lex(); >- >- if (!isIdentifierName(token)) { >- if (extra.errors) { >- attemptRecoveryNonComputedProperty(token); >- } >- throwUnexpected(token); >- // return null; // unecessary >- } >- >- return delegate.markEnd(delegate.createIdentifier(token.value)); >- } >- >- function parseNonComputedMember() { >- expect('.'); >- >- return parseNonComputedProperty(); >- } >- >- function parseComputedMember() { >- var expr; >- >- expect('['); >- >- expr = parseExpression(); >- >- expect(']'); >- >- return expr; >- } >- >- function parseNewExpression() { >- var callee, args; >- >- delegate.markStart(); >- expectKeyword('new'); >- callee = parseLeftHandSideExpression(); >- args = match('(') ? parseArguments() : []; >- >- return delegate.markEnd(delegate.createNewExpression(callee, args)); >- } >- >- function parseLeftHandSideExpressionAllowCall() { >- var marker, previousAllowIn, expr, args, property; >- >- marker = createLocationMarker(); >- >- previousAllowIn = state.allowIn; >- state.allowIn = true; >- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); >- state.allowIn = previousAllowIn; >- >- while (match('.') || match('[') || match('(')) { >- if (match('(')) { >- args = parseArguments(); >- expr = delegate.createCallExpression(expr, args); >- } else if (match('[')) { >- property = parseComputedMember(); >- expr = delegate.createMemberExpression('[', expr, property); >- } else { >- property = parseNonComputedMember(); >- expr = delegate.createMemberExpression('.', expr, property); >- } >- if (marker) { >- marker.end(); >- marker.apply(expr); >- } >- } >- >- return expr; >- } >- >- function parseLeftHandSideExpression() { >- var marker, previousAllowIn, expr, property; >- >- marker = createLocationMarker(); >- >- previousAllowIn = state.allowIn; >- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); >- state.allowIn = previousAllowIn; >- >- while (match('.') || match('[')) { >- if (match('[')) { >- property = parseComputedMember(); >- expr = delegate.createMemberExpression('[', expr, property); >- } else { >- property = parseNonComputedMember(); >- expr = delegate.createMemberExpression('.', expr, property); >- } >- if (marker) { >- marker.end(); >- marker.apply(expr); >- } >- } >- >- return expr; >- } >- >- // 11.3 Postfix Expressions >- >- function parsePostfixExpression() { >- var expr, token; >- >- delegate.markStart(); >- expr = parseLeftHandSideExpressionAllowCall(); >- >- if (lookahead.type === Token.Punctuator) { >- if ((match('++') || match('--')) && !peekLineTerminator()) { >- // 11.3.1, 11.3.2 >- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { >- throwErrorTolerant({}, Messages.StrictLHSPostfix); >- } >- >- if (!isLeftHandSide(expr)) { >- throwErrorTolerant({}, Messages.InvalidLHSInAssignment); >- } >- >- token = lex(); >- expr = delegate.createPostfixExpression(token.value, expr); >- } >- } >- >- return delegate.markEndIf(expr); >- } >- >- // 11.4 Unary Operators >- >- function parseUnaryExpression() { >- var token, expr; >- >- delegate.markStart(); >- >- if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { >- expr = parsePostfixExpression(); >- } else if (match('++') || match('--')) { >- token = lex(); >- expr = parseUnaryExpression(); >- // 11.4.4, 11.4.5 >- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { >- throwErrorTolerant({}, Messages.StrictLHSPrefix); >- } >- >- if (!isLeftHandSide(expr)) { >- throwErrorTolerant({}, Messages.InvalidLHSInAssignment); >- } >- >- expr = delegate.createUnaryExpression(token.value, expr); >- } else if (match('+') || match('-') || match('~') || match('!')) { >- token = lex(); >- expr = parseUnaryExpression(); >- expr = delegate.createUnaryExpression(token.value, expr); >- } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { >- token = lex(); >- expr = parseUnaryExpression(); >- expr = delegate.createUnaryExpression(token.value, expr); >- if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { >- throwErrorTolerant({}, Messages.StrictDelete); >- } >- } else { >- expr = parsePostfixExpression(); >- } >- >- return delegate.markEndIf(expr); >- } >- >- function binaryPrecedence(token, allowIn) { >- var prec = 0; >- >- if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { >- return 0; >- } >- >- switch (token.value) { >- case '||': >- prec = 1; >- break; >- >- case '&&': >- prec = 2; >- break; >- >- case '|': >- prec = 3; >- break; >- >- case '^': >- prec = 4; >- break; >- >- case '&': >- prec = 5; >- break; >- >- case '==': >- case '!=': >- case '===': >- case '!==': >- prec = 6; >- break; >- >- case '<': >- case '>': >- case '<=': >- case '>=': >- case 'instanceof': >- prec = 7; >- break; >- >- case 'in': >- prec = allowIn ? 7 : 0; >- break; >- >- case '<<': >- case '>>': >- case '>>>': >- prec = 8; >- break; >- >- case '+': >- case '-': >- prec = 9; >- break; >- >- case '*': >- case '/': >- case '%': >- prec = 11; >- break; >- >- default: >- break; >- } >- >- return prec; >- } >- >- // 11.5 Multiplicative Operators >- // 11.6 Additive Operators >- // 11.7 Bitwise Shift Operators >- // 11.8 Relational Operators >- // 11.9 Equality Operators >- // 11.10 Binary Bitwise Operators >- // 11.11 Binary Logical Operators >- >- function parseBinaryExpression() { >- var marker, markers, expr, token, prec, stack, right, operator, left, i; >- >- marker = createLocationMarker(); >- left = parseUnaryExpression(); >- >- token = lookahead; >- prec = binaryPrecedence(token, state.allowIn); >- if (prec === 0) { >- return left; >- } >- token.prec = prec; >- lex(); >- >- markers = [marker, createLocationMarker()]; >- right = parseUnaryExpression(); >- >- stack = [left, token, right]; >- >- while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) { >- >- // Reduce: make a binary expression from the three topmost entries. >- while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { >- right = stack.pop(); >- operator = stack.pop().value; >- left = stack.pop(); >- expr = delegate.createBinaryExpression(operator, left, right); >- markers.pop(); >- marker = markers.pop(); >- if (marker) { >- marker.end(); >- marker.apply(expr); >- } >- stack.push(expr); >- markers.push(marker); >- } >- >- // Shift. >- token = lex(); >- token.prec = prec; >- stack.push(token); >- markers.push(createLocationMarker()); >- expr = parseUnaryExpression(); >- stack.push(expr); >- } >- >- // Final reduce to clean-up the stack. >- i = stack.length - 1; >- expr = stack[i]; >- markers.pop(); >- while (i > 1) { >- expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr); >- i -= 2; >- marker = markers.pop(); >- if (marker) { >- marker.end(); >- marker.apply(expr); >- } >- } >- >- return expr; >- } >- >- >- // 11.12 Conditional Operator >- >- function parseConditionalExpression() { >- var expr, previousAllowIn, consequent, alternate; >- >- delegate.markStart(); >- expr = parseBinaryExpression(); >- >- if (match('?')) { >- lex(); >- previousAllowIn = state.allowIn; >- state.allowIn = true; >- consequent = parseAssignmentExpression(); >- state.allowIn = previousAllowIn; >- expect(':'); >- alternate = parseAssignmentExpression(); >- >- expr = delegate.markEnd(delegate.createConditionalExpression(expr, consequent, alternate)); >- } else { >- delegate.markEnd({}); >- } >- >- return expr; >- } >- >- // 11.13 Assignment Operators >- >- function parseAssignmentExpression() { >- var token, left, right, node; >- >- token = lookahead; >- delegate.markStart(); >- node = left = parseConditionalExpression(); >- >- if (matchAssign()) { >- // LeftHandSideExpression >- if (!isLeftHandSide(left)) { >- throwErrorTolerant({}, Messages.InvalidLHSInAssignment); >- } >- >- // 11.13.1 >- if (strict && left.type === Syntax.Identifier && isRestrictedWord(left.name)) { >- throwErrorTolerant(token, Messages.StrictLHSAssignment); >- } >- >- token = lex(); >- right = parseAssignmentExpression(); >- node = delegate.createAssignmentExpression(token.value, left, right); >- } >- >- return delegate.markEndIf(node); >- } >- >- // 11.14 Comma Operator >- >- function parseExpression() { >- var expr; >- >- delegate.markStart(); >- expr = parseAssignmentExpression(); >- >- if (match(',')) { >- expr = delegate.createSequenceExpression([ expr ]); >- >- while (index < length) { >- if (!match(',')) { >- break; >- } >- lex(); >- expr.expressions.push(parseAssignmentExpression()); >- } >- } >- >- return delegate.markEndIf(expr); >- } >- >- // 12.1 Block >- >- function parseStatementList() { >- var list = [], >- statement; >- >- while (index < length) { >- if (match('}')) { >- break; >- } >- statement = parseSourceElement(); >- if (typeof statement === 'undefined') { >- break; >- } >- list.push(statement); >- } >- >- return list; >- } >- >- function parseBlock() { >- var block; >- >- skipComment(); >- delegate.markStart(); >- expect('{'); >- >- block = parseStatementList(); >- >- // mamacdon 853a9865 >- // @ 1.0.0 esprima.js:2204 >- //expect('}'); >- expectConditionCloseBracketWrapThrow(); >- >- return delegate.markEnd(delegate.createBlockStatement(block)); >- } >- >- // 12.2 Variable Statement >- >- function parseVariableIdentifier() { >- var token; >- >- skipComment(); >- delegate.markStart(); >- token = lex(); >- >- if (token.type !== Token.Identifier) { >- throwUnexpected(token); >- } >- >- return delegate.markEnd(delegate.createIdentifier(token.value)); >- } >- >- function parseVariableDeclaration(kind) { >- var init = null, id; >- >- skipComment(); >- delegate.markStart(); >- id = parseVariableIdentifier(); >- >- // 12.2.1 >- if (strict && isRestrictedWord(id.name)) { >- throwErrorTolerant({}, Messages.StrictVarName); >- } >- >- if (kind === 'const') { >- expect('='); >- init = parseAssignmentExpression(); >- } else if (match('=')) { >- lex(); >- init = parseAssignmentExpression(); >- } >- >- return delegate.markEnd(delegate.createVariableDeclarator(id, init)); >- } >- >- function parseVariableDeclarationList(kind) { >- var list = []; >- >- do { >- list.push(parseVariableDeclaration(kind)); >- if (!match(',')) { >- break; >- } >- lex(); >- } while (index < length); >- >- return list; >- } >- >- function parseVariableStatement() { >- var declarations; >- >- expectKeyword('var'); >- >- declarations = parseVariableDeclarationList(); >- >- consumeSemicolon(); >- >- return delegate.createVariableDeclaration(declarations, 'var'); >- } >- >- // kind may be `const` or `let` >- // Both are experimental and not in the specification yet. >- // see http://wiki.ecmascript.org/doku.php?id=harmony:const >- // and http://wiki.ecmascript.org/doku.php?id=harmony:let >- function parseConstLetDeclaration(kind) { >- var declarations; >- >- skipComment(); >- delegate.markStart(); >- >- expectKeyword(kind); >- >- declarations = parseVariableDeclarationList(kind); >- >- consumeSemicolon(); >- >- return delegate.markEnd(delegate.createVariableDeclaration(declarations, kind)); >- } >- >- // 12.3 Empty Statement >- >- function parseEmptyStatement() { >- expect(';'); >- return delegate.createEmptyStatement(); >- } >- >- // 12.4 Expression Statement >- >- function parseExpressionStatement() { >- var expr = parseExpression(); >- consumeSemicolon(); >- return delegate.createExpressionStatement(expr); >- } >- >- // 12.5 If statement >- >- function parseIfStatement() { >- >- var test, consequent, alternate; >- >- expectKeyword('if'); >- >- expect('('); >- >- test = parseExpression(); >- >- // mamacdon 853a9865 >- //expect(')'); >- expectConditionCloseParenWrapThrow(); >- >- consequent = parseStatement(); >- // mamacdon 853a9865: required because of the check in wrapTracking that returns nothing if node is undefined >- // TODO: delegate handles tracking now, check if this test is still needed >- if (!consequent) { >- consequent = null; >- } >- if (matchKeyword('else')) { >- lex(); >- alternate = parseStatement(); >- } else { >- alternate = null; >- } >- >- return delegate.createIfStatement(test, consequent, alternate); >- } >- >- // 12.6 Iteration Statements >- >- function parseDoWhileStatement() { >- var body, test, oldInIteration; >- >- expectKeyword('do'); >- >- oldInIteration = state.inIteration; >- state.inIteration = true; >- >- body = parseStatement(); >- >- state.inIteration = oldInIteration; >- >- expectKeyword('while'); >- >- expect('('); >- >- test = parseExpression(); >- >- expect(')'); >- >- if (match(';')) { >- lex(); >- } >- >- return delegate.createDoWhileStatement(body, test); >- } >- >- function parseWhileStatement() { >- var test, body, oldInIteration; >- >- expectKeyword('while'); >- >- expect('('); >- >- test = parseExpression(); >- >- // mamacdon 853a9865 >- //expect(')'); >- expectConditionCloseParenWrapThrow(); >- >- oldInIteration = state.inIteration; >- state.inIteration = true; >- >- body = parseStatement(); >- >- state.inIteration = oldInIteration; >- >- return delegate.createWhileStatement(test, body); >- } >- >- function parseForVariableDeclaration() { >- var token, declarations; >- >- delegate.markStart(); >- token = lex(); >- declarations = parseVariableDeclarationList(); >- >- return delegate.markEnd(delegate.createVariableDeclaration(declarations, token.value)); >- } >- >- function parseForStatement() { >- var init, test, update, left, right, body, oldInIteration; >- >- init = test = update = null; >- >- expectKeyword('for'); >- >- expect('('); >- >- if (match(';')) { >- lex(); >- } else { >- if (matchKeyword('var') || matchKeyword('let')) { >- state.allowIn = false; >- init = parseForVariableDeclaration(); >- state.allowIn = true; >- >- if (init.declarations.length === 1 && matchKeyword('in')) { >- lex(); >- left = init; >- right = parseExpression(); >- init = null; >- } >- } else { >- state.allowIn = false; >- init = parseExpression(); >- state.allowIn = true; >- >- if (matchKeyword('in')) { >- // LeftHandSideExpression >- if (!isLeftHandSide(init)) { >- throwErrorTolerant({}, Messages.InvalidLHSInForIn); >- } >- >- lex(); >- left = init; >- right = parseExpression(); >- init = null; >- } >- } >- >- if (typeof left === 'undefined') { >- expect(';'); >- } >- } >- >- if (typeof left === 'undefined') { >- >- if (!match(';')) { >- test = parseExpression(); >- } >- expect(';'); >- >- if (!match(')')) { >- update = parseExpression(); >- } >- } >- >- // mamacdon 853a9865 >- //expect(')'); >- expectConditionCloseParenWrapThrow(); >- >- oldInIteration = state.inIteration; >- state.inIteration = true; >- >- body = parseStatement(); >- >- state.inIteration = oldInIteration; >- >- return (typeof left === 'undefined') ? >- delegate.createForStatement(init, test, update, body) : >- delegate.createForInStatement(left, right, body); >- } >- >- // 12.7 The continue statement >- >- function parseContinueStatement() { >- var label = null, key; >- >- expectKeyword('continue'); >- >- // Optimize the most common form: 'continue;'. >- if (source.charCodeAt(index) === 59) { >- lex(); >- >- if (!state.inIteration) { >- throwError({}, Messages.IllegalContinue); >- } >- >- return delegate.createContinueStatement(null); >- } >- >- if (peekLineTerminator()) { >- if (!state.inIteration) { >- throwError({}, Messages.IllegalContinue); >- } >- >- return delegate.createContinueStatement(null); >- } >- >- if (lookahead.type === Token.Identifier) { >- label = parseVariableIdentifier(); >- >- key = '$' + label.name; >- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { >- throwError({}, Messages.UnknownLabel, label.name); >- } >- } >- >- consumeSemicolon(); >- >- if (label === null && !state.inIteration) { >- throwError({}, Messages.IllegalContinue); >- } >- >- return delegate.createContinueStatement(label); >- } >- >- // 12.8 The break statement >- >- function parseBreakStatement() { >- var label = null, key; >- >- expectKeyword('break'); >- >- // Catch the very common case first: immediately a semicolon (char #59). >- if (source.charCodeAt(index) === 59) { >- lex(); >- >- if (!(state.inIteration || state.inSwitch)) { >- throwError({}, Messages.IllegalBreak); >- } >- >- return delegate.createBreakStatement(null); >- } >- >- if (peekLineTerminator()) { >- if (!(state.inIteration || state.inSwitch)) { >- throwError({}, Messages.IllegalBreak); >- } >- >- return delegate.createBreakStatement(null); >- } >- >- if (lookahead.type === Token.Identifier) { >- label = parseVariableIdentifier(); >- >- key = '$' + label.name; >- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { >- throwError({}, Messages.UnknownLabel, label.name); >- } >- } >- >- consumeSemicolon(); >- >- if (label === null && !(state.inIteration || state.inSwitch)) { >- throwError({}, Messages.IllegalBreak); >- } >- >- return delegate.createBreakStatement(label); >- } >- >- // 12.9 The return statement >- >- function parseReturnStatement() { >- var argument = null; >- >- expectKeyword('return'); >- >- if (!state.inFunctionBody) { >- throwErrorTolerant({}, Messages.IllegalReturn); >- } >- >- // 'return' followed by a space and an identifier is very common. >- if (source.charCodeAt(index) === 32) { >- if (isIdentifierStart(source.charCodeAt(index + 1))) { >- argument = parseExpression(); >- consumeSemicolon(); >- return delegate.createReturnStatement(argument); >- } >- } >- >- if (peekLineTerminator()) { >- return delegate.createReturnStatement(null); >- } >- >- if (!match(';')) { >- if (!match('}') && lookahead.type !== Token.EOF) { >- argument = parseExpression(); >- } >- } >- >- consumeSemicolon(); >- >- return delegate.createReturnStatement(argument); >- } >- >- // 12.10 The with statement >- >- function parseWithStatement() { >- var object, body; >- >- if (strict) { >- throwErrorTolerant({}, Messages.StrictModeWith); >- } >- >- expectKeyword('with'); >- >- expect('('); >- >- object = parseExpression(); >- >- expect(')'); >- >- body = parseStatement(); >- >- return delegate.createWithStatement(object, body); >- } >- >- // 12.10 The swith statement >- >- function parseSwitchCase() { >- var test, >- consequent = [], >- statement; >- >- skipComment(); >- delegate.markStart(); >- if (matchKeyword('default')) { >- lex(); >- test = null; >- } else { >- expectKeyword('case'); >- test = parseExpression(); >- } >- expect(':'); >- >- while (index < length) { >- if (match('}') || matchKeyword('default') || matchKeyword('case')) { >- break; >- } >- statement = parseStatement(); >- consequent.push(statement); >- } >- >- return delegate.markEnd(delegate.createSwitchCase(test, consequent)); >- } >- >- function parseSwitchStatement() { >- var discriminant, cases, clause, oldInSwitch, defaultFound; >- >- expectKeyword('switch'); >- >- expect('('); >- >- discriminant = parseExpression(); >- >- expect(')'); >- >- expect('{'); >- >- cases = []; >- >- if (match('}')) { >- lex(); >- return delegate.createSwitchStatement(discriminant, cases); >- } >- >- oldInSwitch = state.inSwitch; >- state.inSwitch = true; >- defaultFound = false; >- >- while (index < length) { >- if (match('}')) { >- break; >- } >- clause = parseSwitchCase(); >- if (clause.test === null) { >- if (defaultFound) { >- throwError({}, Messages.MultipleDefaultsInSwitch); >- } >- defaultFound = true; >- } >- cases.push(clause); >- } >- >- state.inSwitch = oldInSwitch; >- >- expect('}'); >- >- return delegate.createSwitchStatement(discriminant, cases); >- } >- >- // 12.13 The throw statement >- >- function parseThrowStatement() { >- var argument; >- >- expectKeyword('throw'); >- >- if (peekLineTerminator()) { >- throwError({}, Messages.NewlineAfterThrow); >- } >- >- argument = parseExpression(); >- >- consumeSemicolon(); >- >- return delegate.createThrowStatement(argument); >- } >- >- // 12.14 The try statement >- >- function parseCatchClause() { >- var param, body; >- >- skipComment(); >- delegate.markStart(); >- expectKeyword('catch'); >- >- expect('('); >- if (match(')')) { >- throwUnexpected(lookahead); >- } >- >- param = parseVariableIdentifier(); >- // 12.14.1 >- if (strict && isRestrictedWord(param.name)) { >- throwErrorTolerant({}, Messages.StrictCatchVariable); >- } >- >- expect(')'); >- body = parseBlock(); >- return delegate.markEnd(delegate.createCatchClause(param, body)); >- } >- >- function parseTryStatement() { >- var block, handlers = [], finalizer = null; >- >- expectKeyword('try'); >- >- block = parseBlock(); >- >- if (matchKeyword('catch')) { >- handlers.push(parseCatchClause()); >- } >- >- if (matchKeyword('finally')) { >- lex(); >- finalizer = parseBlock(); >- } >- >- if (handlers.length === 0 && !finalizer) { >- throwError({}, Messages.NoCatchOrFinally); >- } >- >- return delegate.createTryStatement(block, [], handlers, finalizer); >- } >- >- // 12.15 The debugger statement >- >- function parseDebuggerStatement() { >- expectKeyword('debugger'); >- >- consumeSemicolon(); >- >- return delegate.createDebuggerStatement(); >- } >- >- // 12 Statements >- >- function parseStatement() { >- var type = lookahead.type, >- expr, >- labeledBody, >- key; >- >- if (type === Token.EOF) { >- throwUnexpected(lookahead); >- } >- >- skipComment(); >- delegate.markStart(); >- >- if (type === Token.Punctuator) { >- switch (lookahead.value) { >- case ';': >- return delegate.markEnd(parseEmptyStatement()); >- case '{': >- return delegate.markEnd(parseBlock()); >- case '(': >- return delegate.markEnd(parseExpressionStatement()); >- default: >- break; >- } >- } >- >- if (type === Token.Keyword) { >- switch (lookahead.value) { >- case 'break': >- return delegate.markEnd(parseBreakStatement()); >- case 'continue': >- return delegate.markEnd(parseContinueStatement()); >- case 'debugger': >- return delegate.markEnd(parseDebuggerStatement()); >- case 'do': >- return delegate.markEnd(parseDoWhileStatement()); >- case 'for': >- return delegate.markEnd(parseForStatement()); >- case 'function': >- return delegate.markEnd(parseFunctionDeclaration()); >- case 'if': >- return delegate.markEnd(parseIfStatement()); >- case 'return': >- return delegate.markEnd(parseReturnStatement()); >- case 'switch': >- return delegate.markEnd(parseSwitchStatement()); >- case 'throw': >- return delegate.markEnd(parseThrowStatement()); >- case 'try': >- return delegate.markEnd(parseTryStatement()); >- case 'var': >- return delegate.markEnd(parseVariableStatement()); >- case 'while': >- return delegate.markEnd(parseWhileStatement()); >- case 'with': >- return delegate.markEnd(parseWithStatement()); >- default: >- break; >- } >- } >- >- expr = parseExpression(); >- >- // 12.12 Labelled Statements >- if (expr && (expr.type === Syntax.Identifier) && match(':')) { // mamacdon 1420b19 >- lex(); >- >- key = '$' + expr.name; >- if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) { >- throwError({}, Messages.Redeclaration, 'Label', expr.name); >- } >- >- state.labelSet[key] = true; >- labeledBody = parseStatement(); >- delete state.labelSet[key]; >- return delegate.markEnd(delegate.createLabeledStatement(expr, labeledBody)); >- } >- >- consumeSemicolon(); >- >- return delegate.markEnd(delegate.createExpressionStatement(expr)); >- } >- >- // 13 Function Definition >- >- function parseFunctionSourceElements() { >- var sourceElement, sourceElements = [], token, directive, firstRestricted, >- oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody; >- >- skipComment(); >- delegate.markStart(); >- expect('{'); >- >- while (index < length) { >- if (lookahead.type !== Token.StringLiteral) { >- break; >- } >- token = lookahead; >- >- sourceElement = parseSourceElement(); >- sourceElements.push(sourceElement); >- if (sourceElement.expression.type !== Syntax.Literal) { >- // this is not directive >- break; >- } >- directive = source.slice(token.range[0] + 1, token.range[1] - 1); >- if (directive === 'use strict') { >- strict = true; >- if (firstRestricted) { >- throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); >- } >- } else { >- if (!firstRestricted && token.octal) { >- firstRestricted = token; >- } >- } >- } >- >- oldLabelSet = state.labelSet; >- oldInIteration = state.inIteration; >- oldInSwitch = state.inSwitch; >- oldInFunctionBody = state.inFunctionBody; >- >- state.labelSet = {}; >- state.inIteration = false; >- state.inSwitch = false; >- state.inFunctionBody = true; >- >- while (index < length) { >- if (match('}')) { >- break; >- } >- sourceElement = parseSourceElement(); >- if (typeof sourceElement === 'undefined') { >- break; >- } >- sourceElements.push(sourceElement); >- } >- >- // mamacdon 853a986 >- //expect('}'); >- expectConditionCloseBracketWrapThrow(); >- >- state.labelSet = oldLabelSet; >- state.inIteration = oldInIteration; >- state.inSwitch = oldInSwitch; >- state.inFunctionBody = oldInFunctionBody; >- >- return delegate.markEnd(delegate.createBlockStatement(sourceElements)); >- } >- >- function parseParams(firstRestricted) { >- var param, params = [], token, stricted, paramSet, key, message; >- expect('('); >- >- if (!match(')')) { >- paramSet = {}; >- while (index < length) { >- token = lookahead; >- param = parseVariableIdentifier(); >- key = '$' + token.value; >- if (strict) { >- if (isRestrictedWord(token.value)) { >- stricted = token; >- message = Messages.StrictParamName; >- } >- if (Object.prototype.hasOwnProperty.call(paramSet, key)) { >- stricted = token; >- message = Messages.StrictParamDupe; >- } >- } else if (!firstRestricted) { >- if (isRestrictedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictParamName; >- } else if (isStrictModeReservedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictReservedWord; >- } else if (Object.prototype.hasOwnProperty.call(paramSet, key)) { >- firstRestricted = token; >- message = Messages.StrictParamDupe; >- } >- } >- params.push(param); >- paramSet[key] = true; >- if (match(')')) { >- break; >- } >- expect(','); >- } >- } >- >- expect(')'); >- >- return { >- params: params, >- stricted: stricted, >- firstRestricted: firstRestricted, >- message: message >- }; >- } >- >- function parseFunctionDeclaration() { >- var id, params = [], body, token, stricted, tmp, firstRestricted, message, previousStrict; >- >- skipComment(); >- delegate.markStart(); >- >- expectKeyword('function'); >- token = lookahead; >- id = parseVariableIdentifier(); >- if (strict) { >- if (isRestrictedWord(token.value)) { >- throwErrorTolerant(token, Messages.StrictFunctionName); >- } >- } else { >- if (isRestrictedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictFunctionName; >- } else if (isStrictModeReservedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictReservedWord; >- } >- } >- >- tmp = parseParams(firstRestricted); >- params = tmp.params; >- stricted = tmp.stricted; >- firstRestricted = tmp.firstRestricted; >- if (tmp.message) { >- message = tmp.message; >- } >- >- previousStrict = strict; >- body = parseFunctionSourceElements(); >- if (strict && firstRestricted) { >- throwError(firstRestricted, message); >- } >- if (strict && stricted) { >- throwErrorTolerant(stricted, message); >- } >- strict = previousStrict; >- >- return delegate.markEnd(delegate.createFunctionDeclaration(id, params, [], body)); >- } >- >- function parseFunctionExpression() { >- var token, id = null, stricted, firstRestricted, message, tmp, params = [], body, previousStrict; >- >- delegate.markStart(); >- expectKeyword('function'); >- >- if (!match('(')) { >- token = lookahead; >- id = parseVariableIdentifier(); >- if (strict) { >- if (isRestrictedWord(token.value)) { >- throwErrorTolerant(token, Messages.StrictFunctionName); >- } >- } else { >- if (isRestrictedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictFunctionName; >- } else if (isStrictModeReservedWord(token.value)) { >- firstRestricted = token; >- message = Messages.StrictReservedWord; >- } >- } >- } >- >- tmp = parseParams(firstRestricted); >- params = tmp.params; >- stricted = tmp.stricted; >- firstRestricted = tmp.firstRestricted; >- if (tmp.message) { >- message = tmp.message; >- } >- >- previousStrict = strict; >- body = parseFunctionSourceElements(); >- if (strict && firstRestricted) { >- throwError(firstRestricted, message); >- } >- if (strict && stricted) { >- throwErrorTolerant(stricted, message); >- } >- strict = previousStrict; >- >- return delegate.markEnd(delegate.createFunctionExpression(id, params, [], body)); >- } >- >- // 14 Program >- >- function parseSourceElement() { >- if (lookahead.type === Token.Keyword) { >- switch (lookahead.value) { >- case 'const': >- case 'let': >- return parseConstLetDeclaration(lookahead.value); >- case 'function': >- return parseFunctionDeclaration(); >- default: >- return parseStatement(); >- } >- } >- >- if (lookahead.type !== Token.EOF) { >- return parseStatement(); >- } >- } >- >- function parseSourceElements() { >- var sourceElement, sourceElements = [], token, directive, firstRestricted; >- >- while (index < length) { >- token = lookahead; >- if (token.type !== Token.StringLiteral) { >- break; >- } >- >- sourceElement = parseSourceElement(); >- sourceElements.push(sourceElement); >- if (sourceElement.expression.type !== Syntax.Literal) { >- // this is not directive >- break; >- } >- directive = source.slice(token.range[0] + 1, token.range[1] - 1); >- if (directive === 'use strict') { >- strict = true; >- if (firstRestricted) { >- throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); >- } >- } else { >- if (!firstRestricted && token.octal) { >- firstRestricted = token; >- } >- } >- } >- >- while (index < length) { >- sourceElement = parseSourceElement(); >- if (typeof sourceElement === 'undefined') { >- break; >- } >- sourceElements.push(sourceElement); >- } >- return sourceElements; >- } >- >- function parseProgram() { >- var body; >- >- skipComment(); >- delegate.markStart(); >- strict = false; >- peek(); >- body = parseSourceElements(); >- return delegate.markEnd(delegate.createProgram(body)); >- } >- >- function attachComments() { >- var i, attacher, comment, leading, trailing; >- >- for (i = 0; i < extra.pendingComments.length; ++i) { >- attacher = extra.pendingComments[i]; >- comment = attacher.comment; >- leading = attacher.leading; >- if (leading) { >- if (typeof leading.leadingComments === 'undefined') { >- leading.leadingComments = []; >- } >- leading.leadingComments.push(attacher.comment); >- } >- trailing = attacher.trailing; >- if (trailing) { >- if (typeof trailing.trailingComments === 'undefined') { >- trailing.trailingComments = []; >- } >- trailing.trailingComments.push(attacher.comment); >- } >- } >- extra.pendingComments = []; >- } >- >- function filterTokenLocation() { >- var i, entry, token, tokens = []; >- >- for (i = 0; i < extra.tokens.length; ++i) { >- entry = extra.tokens[i]; >- token = { >- type: entry.type, >- value: entry.value >- }; >- if (extra.range) { >- token.range = entry.range; >- } >- if (extra.loc) { >- token.loc = entry.loc; >- } >- tokens.push(token); >- } >- >- extra.tokens = tokens; >- } >- >- function LocationMarker() { >- this.marker = [index, lineNumber, index - lineStart, 0, 0, 0]; >- } >- >- LocationMarker.prototype = { >- constructor: LocationMarker, >- >- end: function () { >- this.marker[3] = index; >- this.marker[4] = lineNumber; >- this.marker[5] = index - lineStart; >- }, >- >- apply: function (node) { >- if (extra.range) { >- node.range = [this.marker[0], this.marker[3]]; >- } >- if (extra.loc) { >- node.loc = { >- start: { >- line: this.marker[1], >- column: this.marker[2] >- }, >- end: { >- line: this.marker[4], >- column: this.marker[5] >- } >- }; >- node = delegate.postProcess(node); >- } >- if (extra.attachComment) { >- delegate.processComment(node); >- } >- } >- }; >- >- function createLocationMarker() { >- if (!extra.loc && !extra.range) { >- return null; >- } >- >- skipComment(); >- >- return new LocationMarker(); >- } >- >- function tokenize(code, options) { >- var toString, >- token, >- tokens; >- >- toString = String; >- if (typeof code !== 'string' && !(code instanceof String)) { >- code = toString(code); >- } >- >- delegate = SyntaxTreeDelegate; >- source = code; >- index = 0; >- lineNumber = (source.length > 0) ? 1 : 0; >- lineStart = 0; >- length = source.length; >- lookahead = null; >- state = { >- allowIn: true, >- labelSet: {}, >- inFunctionBody: false, >- inIteration: false, >- inSwitch: false, >- lastCommentStart: -1 >- }; >- >- extra = {}; >- >- // Options matching. >- options = options || {}; >- >- // Of course we collect tokens here. >- options.tokens = true; >- extra.tokens = []; >- extra.tokenize = true; >- // The following two fields are necessary to compute the Regex tokens. >- extra.openParenToken = -1; >- extra.openCurlyToken = -1; >- >- extra.range = (typeof options.range === 'boolean') && options.range; >- extra.loc = (typeof options.loc === 'boolean') && options.loc; >- >- if (typeof options.comment === 'boolean' && options.comment) { >- extra.comments = []; >- } >- if (typeof options.tolerant === 'boolean' && options.tolerant) { >- extra.errors = []; >- } >- >- if (length > 0) { >- if (typeof source[0] === 'undefined') { >- // Try first to convert to a string. This is good as fast path >- // for old IE which understands string indexing for string >- // literals only and not for string object. >- if (code instanceof String) { >- source = code.valueOf(); >- } >- } >- } >- >- try { >- peek(); >- if (lookahead.type === Token.EOF) { >- return extra.tokens; >- } >- >- token = lex(); >- while (lookahead.type !== Token.EOF) { >- try { >- token = lex(); >- } catch (lexError) { >- token = lookahead; >- if (extra.errors) { >- extra.errors.push(lexError); >- // We have to break on the first error >- // to avoid infinite loops. >- break; >- } else { >- throw lexError; >- } >- } >- } >- >- filterTokenLocation(); >- tokens = extra.tokens; >- if (typeof extra.comments !== 'undefined') { >- tokens.comments = extra.comments; >- } >- if (typeof extra.errors !== 'undefined') { >- tokens.errors = extra.errors; >- } >- } catch (e) { >- throw e; >- } finally { >- extra = {}; >- } >- return tokens; >- } >- >- function parse(code, options) { >- var program, toString; >- >- toString = String; >- if (typeof code !== 'string' && !(code instanceof String)) { >- code = toString(code); >- } >- >- delegate = SyntaxTreeDelegate; >- source = code; >- index = 0; >- lineNumber = (source.length > 0) ? 1 : 0; >- lineStart = 0; >- length = source.length; >- lookahead = null; >- state = { >- allowIn: true, >- labelSet: {}, >- inFunctionBody: false, >- inIteration: false, >- inSwitch: false, >- lastCommentStart: -1, >- markerStack: [] >- }; >- >- extra = {}; >- if (typeof options !== 'undefined') { >- extra.range = (typeof options.range === 'boolean') && options.range; >- extra.loc = (typeof options.loc === 'boolean') && options.loc; >- extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; >- >- if (extra.loc && options.source !== null && options.source !== undefined) { >- extra.source = toString(options.source); >- } >- >- if (typeof options.tokens === 'boolean' && options.tokens) { >- extra.tokens = []; >- } >- if (typeof options.comment === 'boolean' && options.comment) { >- extra.comments = []; >- } >- if (typeof options.tolerant === 'boolean' && options.tolerant) { >- extra.errors = []; >- >- // mamacdon patch >- extra.parseStatement = parseStatement; >- extra.parseExpression = parseExpression; >- extra.parseNonComputedProperty = parseNonComputedProperty; >- extra.consumeSemicolon = consumeSemicolon; >- >- parseStatement = wrapThrowParseStatement(parseStatement); // Note special case >- parseExpression = wrapThrow(parseExpression); >- // this enables 'foo.<EOF>' to return something >- parseNonComputedProperty = wrapThrow(parseNonComputedProperty); >- consumeSemicolon = wrapThrow(consumeSemicolon); >- } >- if (extra.attachComment) { >- extra.range = true; >- extra.pendingComments = []; >- extra.comments = []; >- } >- } >- >- if (length > 0) { >- if (typeof source[0] === 'undefined') { >- // Try first to convert to a string. This is good as fast path >- // for old IE which understands string indexing for string >- // literals only and not for string object. >- if (code instanceof String) { >- source = code.valueOf(); >- } >- } >- } >- >- try { >- program = parseProgram(); >- if (typeof extra.comments !== 'undefined') { >- program.comments = extra.comments; >- } >- if (typeof extra.tokens !== 'undefined') { >- filterTokenLocation(); >- program.tokens = extra.tokens; >- } >- if (typeof extra.errors !== 'undefined') { >- program.errors = extra.errors; >- } >- if (extra.attachComment) { >- attachComments(); >- } >- } catch (e) { >- throw e; >- } finally { >- // mamacdon unpatch >- parseStatement = extra.parseStatement; >- parseExpression = extra.parseExpression; >- parseNonComputedProperty = extra.parseNonComputedProperty; >- consumeSemicolon = extra.consumeSemicolon; >- >- extra = {}; >- } >- >- return program; >- } >- >- /** >- * @name expectConditionCloseBracketWrapThrow >- * @description Gracefully handles a missing '}' if the mode is set to tolerant >- * @function >- * @private >- * @since 5.0 >- */ >- function expectConditionCloseBracketWrapThrow() { >- if (extra.errors) { >- // continue parsing even with missing close >- // brace. This gives a better AST for the >- // block, as information about >- // the parsed statements remain >- try { >- expect('}'); >- } catch (e) { >- pushError(e); >- } >- } else { >- expect('}'); >- } >- } >- >- /** >- * @name expectConditionCloseParenWrapThrow >- * @description For statements like if, while, for, etc. check for the ')' on the condition. If >- * it is not present, catch the error, and backtrack if we see a '{' instead (to continue parsing the block) >- * @function >- * @private >- * @throws The original error from trying to consume the ')' char if not in tolerant mode >- * @since 5.0 >- */ >- function expectConditionCloseParenWrapThrow() { >- // needs generalizing to a 'expect A but don't consume if you hit B or C' >- try { >- expect(')'); >- } catch (e) { >- if (extra.errors) { >- pushError(e); >- // If a { was hit instead of a ) then don't consume it, let us assume a ')' was >- // missed and the consequent block is OK >- if (source[e.index] === '{') { >- index=e.index; >- lookahead = null; >- // activating this block will mean the following statement is parsed as a consequent / body. >- // without it the statement is considered not at all part of the enclosing statement at all >- //} else { >- // rewind(); >- } >- } else { >- throw e; >- } >- } >- } >- // mamacdon 1420b19 >- // @ 1.0.0 esprima.js:1609 >- /** >- * @name pushError >- * @description Add the error if not already reported. >- * @function >- * @private >- * @param {Object} error The error object to push >- * @since 5.0 >- */ >- function pushError(error) { >- var len = extra.errors.length; >- for (var e=0; e < len; e++) { >- var existingError = extra.errors[e]; >- if (existingError.index === error.index && existingError.message === error.message) { >- return; // do not add duplicate >- } >- } >- extra.errors.push(error); >- } >- >- //Recovery >- function wrapThrow(parseFunction) { >- return function () { >- try { >- var initialHeight = state.markerStack.length; >- return parseFunction.apply(null, arguments); >- } catch (e) { >- pushError(e); >- // Clean up un-popped end markers from failed parse >- while (state.markerStack.length > initialHeight) >- delegate.markEndIf(null); >- return null; >- } >- }; >- } >- >- function wrapThrowParseStatement(parseFunction) { >- return function () { >- extra.statementStart = index; // record where attempting to parse statement from >- try { >- return parseFunction.apply(null, arguments); >- } catch (e) { >- pushError(e); >-// return null; // why is this commented out >- } >- }; >- } >- >- /** >- * @name isNewlineOrSemicolon >- * @description If the given char is the new line char or a semicolon char >- * @function >- * @private >- * @param {String} ch The character to check >- * @returns {Boolean} <code>true</code> if the char is a new line or semicolon <code>false</code> otherwise >- * @since 5.0 >- */ >- function isNewlineOrSemicolon(ch) { >- return ch===';' || ch==='\n'; >- } >- >- /** >- * @name rewind >- * @descripton Rewind the lex position to the most recent newline or semicolon. If that turns out >- * to be the same position as the most recent parsing of a statement was attempted at, >- * don't rewind (because it will fail in the same way). If it turns out to be the same >- * position as where we last rewound to, don't do it. Clears the buffer and sets the >- * index in order to continue lexing from the new position. >- * @function >- * @private >- * @since 5.0 >- */ >- function rewind() { >- var idx = index; >- while (idx>0 && !isNewlineOrSemicolon(source[idx])) { >- idx--; >- } >- if (idx<=extra.statementStart) { >- return; >- } >- var doRewind = false; >- if (extra.lastRewindLocation) { >- doRewind = true; >- } else { >- var v = extra.lastRewindLocation; >- if (v!==idx) { >- doRewind=true; >- } >- } >- if (doRewind) { >- index = idx; >- peek(); // recalculate lookahead >- extra.lastRewindLocation = index; >- } >- } >- >- // mamacdon 1420b19 >- // @ 1.0.0 esprima.js:1661 >- // TODO refactor >- /** >- * @name rewindToInterestingChar >- * @description From a position 'idx' in the source this function moves back through the source until >- * it finds a non-whitespace (including newlines) character. It will jump over block comments. >- * Returns an object with properties: index - the index it rewound to. lineChange - boolean indicating >- * if a line was crossed during rewind. >- * @function >- * @private >- * @param {Number} idx The index to rewind to >- * @returns {Object} Returns the object with the index and line change to rewind to >- * @since 5.0 >- */ >- function rewindToInterestingChar(idx) { >- var done = false; >- var lineChange=false; >- var ch; >- while (!done) { >- ch = source[idx]; >- if (ch==='/') { >- // possibly rewind over a block comment >- if (idx>2 && source[idx-1]==='*') { >- // it is, let's reverse over it >- idx = idx - 2; >- var skippedComment = false; >- while (!skippedComment) { >- ch = source[idx]; >- if (ch === '*') { >- if (idx>0 && source[idx-1]==='/') { >- skippedComment=true; >- } >- } else if (ch==='\n') { >- lineChange=true; >- } >- if (idx === 0) { >- skippedComment = true; // error scenario, hit front of array before finding /* >- } >- idx--; >- } >- } else { >- done=true; >- } >- } else >- if (ch==='\n') { >- lineChange=true; >- } else if (!isWhiteSpace(ch)) { >- done=true; >- } >- if (!done) { >- idx--; >- } >- } >- return {"index":idx,"lineChange":lineChange}; >- } >- >- /** >- * @name attemptRecoveryNonComputedProperty >- * @description When a problem occurs in parseNonComputedProperty, attempt to reposition >- * the lexer to continue processing. >- * Example: '(foo.)' we will hit the ')' instead of discovering a property and consuming the ')' >- * will cause the parse of the paretheses to fail, so 'unconsume' it. >- * Basically rewind by one token if punctuation (type 7) is hit and the char before it was >- * a dot. This will enable the enclosing parse rule to consume the punctuation. >- * @function >- * @private >- * @param {String} token The token to try and recover from >- * @since 5.0 >- */ >- function attemptRecoveryNonComputedProperty(token) { >- if (token.value && token.type===Token.Punctuator) { >- var rewindInfo = rewindToInterestingChar(index-token.value.length-1); >- var idx = rewindInfo.index; >- var ch= source[idx]; >- // Check if worth rewinding >- // Special case: >- // "foo.\n(foo())\n" - don't really want that to parse as "foo(foo())" >- if (ch==='.' && rewindInfo.lineChange && token.value==='(') { >- // do not recover in this case >- } else if (ch==='.') { >- index = idx+1; >-// lookahead=null; >- peek(); // recalculate lookahead >- } >- } >- } >- >- // Sync with *.json manifests. >- exports.version = '1.1.0-dev'; >- >- exports.tokenize = tokenize; >- >- exports.parse = parse; >- >- // Deep copy. >- exports.Syntax = (function () { >- var name, types = {}; >- >- if (typeof Object.create === 'function') { >- types = Object.create(null); >- } >- >- for (name in Syntax) { >- if (Syntax.hasOwnProperty(name)) { >- types[name] = Syntax[name]; >- } >- } >- >- if (typeof Object.freeze === 'function') { >- Object.freeze(types); >- } >- >- return types; >- }()); >- >-})); >-/* vim: set sw=4 ts=4 et tw=80 : */ >diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js >index 8f9a7bc..9dd6613 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js >@@ -9,13 +9,13 @@ > * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ >-/*global define esprima*/ >+/*global define */ > define([ > 'orion/Deferred', > 'orion/objects', > 'orion/serialize', >- 'esprima' //must stay at the end, does not export AMD module >-], function(Deferred, Objects, Serialize) { >+ 'esprima' >+], function(Deferred, Objects, Serialize, Esprima) { > /** > * @description Object of error types > * @since 5.0 >@@ -63,7 +63,7 @@ > */ > parse: function(text) { > try { >- var ast = esprima.parse(text, { >+ var ast = Esprima.parse(text, { > range: true, > tolerant: true, > comment: true, >diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/astManagerTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/astManagerTests.js >index 8c37eda..f1c7efd 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/astManagerTests.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/astManagerTests.js >@@ -102,7 +102,6 @@ > editorContext = result.editorContext, > mockEsprima = result.mockEsprima; > >- var d = new Deferred(); > return withMockEsprima(mockEsprima, function() { > var i = 0; > mockEsprima.parse = function() { >diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/demo.html b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/demo.html >deleted file mode 100644 >index 97bd2ba..0000000 >--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/demo.html >+++ /dev/null >@@ -1,72 +0,0 @@ >-<!DOCTYPE html> >-<html> >-<head> >- <script src="../../../requirejs/require.js"></script> >- <script> >- var useNewEsprima = window.location.hash === "#new"; >- >- /*jslint amd:true browser:true*/ >- require({ >- baseUrl: "../../", >- paths: { >- text: "requirejs/text", >- i18n: "requirejs/i18n", >- domReady: "requirejs/domReady", >- esprima: (useNewEsprima ? 'esprima/esprima_tolerant' : 'esprima/esprima'), >- estraverse: "estraverse/estraverse" >- } >- }); >- >- require(["estraverse", "esprima", "domReady!"], function(Estraverse, _esprima) { >- var esprima = typeof window.esprima !== "undefined" ? window.esprima : _esprima; >- >- var element = document.getElementById("source"); >- element.onchange = function() { >- var source = element.value.replace(/\\n/g, "\n"); >- document.getElementById("source2").value = source; >- >- var ast = esprima.parse(source, {comment:true, tokens:true, tolerant:true, range:true, raw:true}); >- var expected = []; >- Estraverse.traverse(ast, { >- enter: function(node) { >- var n = {}; >- n.type = node.type; >- if (node.name) >- n.name = node.name; >- if (node.kind) >- n.kind = node.kind; >- if (node.range) >- n.range = node.range; >- if (node.value) >- n.value = node.value; >- expected.push(n); >- } >- }); >- var result = { >- nodes: expected.slice(1) // omit Program >- }; >- document.getElementById("testData").textContent = JSON.stringify(result.nodes) >- .replace(/"(\w+)":/g, function(match, propName) { >- return propName + ":"; >- }); >- >- document.getElementById("ast").value = JSON.stringify(ast); >- }; >- }); >- >- </script> >-</head> >-<form> >- <p>Source code</p> >- <textarea id="source" rows=20 cols=100></textarea> >- >- <p>Normalized</p> >- <textarea id="source2" readonly rows=5, cols=100></textarea> >- >- <p>Test data</p> >- <textarea id="testData" rows=10 cols=150></textarea> >- >- <p>AST</p> >- <textarea id="ast" rows=30 cols=100></textarea> >-</form> >-</html> >\ No newline at end of file >diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.html b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.html >index 0fe0a6f..b9f9cbc 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.html >+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.html >@@ -28,7 +28,7 @@ > <body> > <h2>Esprima Tolerant Tests</h2> > <p> >- This suite tests the tolerant (recoverable) esprima parser >+ This suite tests the tolerant (recoverable) Esprima parser > </p> > </body> > </html> >\ No newline at end of file >diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js >index 5f73394..ee7d50c 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js >@@ -1,5 +1,5 @@ > /*jslint amd:true*/ >-/*global esprima:true*/ >+/*global esprima:true console */ > define([ > "chai/chai", > "esprima", >@@ -21,9 +21,85 @@ > tolerant: true, > comment: true, > tokens: true, >- raw: true >+ raw: true, >+ attachComments:true > }); > } >+ /** >+ * @description Write out the 'nodes', 'tokens' annd 'errors' arrays for a given AST. >+ * Add this code to the AST managers' getAST() function to produce the test data from a target workspace >+ * @param {Object} ast The AST >+ */ >+ function writeTestData(ast) { >+ var i = 0; >+ console.log('--- TEST OUTPUT ---'); >+ var expected = []; >+ Estraverse.traverse(ast, { >+ enter: function(node) { >+ if(node.type === 'Program') { >+ return; >+ } >+ var n = {}; >+ n.type = node.type; >+ if (node.name) { >+ n.name = node.name; >+ } >+ if (node.kind) { >+ n.kind = node.kind; >+ } >+ if (node.range) { >+ n.range = node.range; >+ } >+ if (node.value && typeof node.value !== 'object') { >+ n.value = node.value; >+ } >+ expected.push(n); >+ } >+ }); >+ var s = 'nodes: ['; >+ for(i = 0; i < expected.length; i++) { >+ s += JSON.stringify(expected[i]); >+ if(i < expected.length-1) { >+ s += ',\n\t\t'; >+ } >+ } >+ s += '],\ntokens: ['; >+ expected = []; >+ for(i = 0; i < ast.tokens.length; i++) { >+ var n = {}; >+ var token = ast.tokens[i]; >+ n.type = token.type; >+ n.range = token.range; >+ n.value = token.value; >+ expected.push(n); >+ } >+ for(i = 0; i < expected.length; i++) { >+ s += JSON.stringify(expected[i]); >+ if(i < expected.length-1) { >+ s += ',\n\t\t'; >+ } >+ } >+ s += '],\nerrors: ['; >+ expected = []; >+ for(i = 0; i < ast.errors.length; i++) { >+ var error = ast.errors[i]; >+ expected.push({ >+ lineNumber : error.lineNumber, >+ index : error.index, >+ message : error.message, >+ token : error.token >+ }); >+ } >+ for(i = 0; i < expected.length; i++) { >+ s += JSON.stringify(expected[i]); >+ if(i < expected.length-1) { >+ s += ',\n\t\t'; >+ } >+ } >+ s += ']'; >+ console.log(s); >+ } >+ > /* */ > function pf(str /*, args*/) { > var args = Array.prototype.slice.call(arguments, 1); >@@ -37,6 +113,7 @@ > * @description Run a test > */ > function runTest(name, data) { >+ assert(name !== null, "Each test must have a name"); > assert.ok(data.source); > var ast = parseFull(data.source); > >@@ -62,9 +139,9 @@ > assert(counter < expectedNodes.length, 'There are more nodes to visit: '+ JSON.stringify(node)); > var expected = expectedNodes[counter]; > assert.equal(node.type, expected.type, 'The node types differ'); >- assert(expected.range, 'The expected node has no range'); >- assert.equal(node.range[0], expected.range[0], 'The node starts differ'); >- assert.equal(node.range[1], expected.range[1], 'The node ends differ'); >+ assert(expected.range, 'The expected '+node.type+' node has no range'); >+ assert.equal(node.range[0], expected.range[0], 'The '+node.type+' node starts differ'); >+ assert.equal(node.range[1], expected.range[1], 'The '+node.type+' node ends differ'); > if (expected.name) { > assert.equal(node.name, expected.name, 'The names differ'); > } >@@ -85,7 +162,7 @@ > var expectedErrors = data.errors, actualErrors = ast.errors; > if (expectedErrors) { > expectedErrors = Array.isArray(expectedErrors) ? expectedErrors : [expectedErrors]; >- assert.equal(actualErrors.length, expectedErrors.length, "Correct number of errors"); >+ assert.equal(actualErrors.length, expectedErrors.length, "Incorrect number of errors"); > expectedErrors.forEach(function(expected, i) { > var actual = actualErrors[i]; > var formatStr = "Error #%s has correct %s"; >@@ -96,9 +173,9 @@ > assert.equal(actual.index, expected.index, pf(formatStr, i, "index")); > } > if (typeof expected.lineNumber === "number") { >- assert.equal(actual.lineNumber, expected.lineNumber, pf("Error %s has correct %s", i, "lineNumber")); >+ assert.equal(actual.lineNumber, expected.lineNumber, pf("Error %s has incorrect %s", i, "lineNumber")); > } >- assert.equal(actual.message.replace(/^Line [0-9]*: /, ""), expected.message, pf("Error %s has correct %s", i, "message")); >+ assert.equal(actual.message.replace(/^Line [0-9]*: /, ""), expected.message, pf("Error %s has incorrect %s", i, "message")); > }); > } > >@@ -263,99 +340,2765 @@ > /** > * > * Object property recovery tests >- * >+ * @since 6.0 > */ >- "obj prop recovery1": { >+ "obj prop ident recovery - ident only": { > source: "var f = {\na\n};", >- errors: [], >- nodes: [{type:'VariableDelcaration', value:'f', range:[0, 14]}, {type:'VariableDeclarator'}, {type:'ObjectExpression', range:[8, 14]}], >- tokens: [{type:'Keyword', value:'var'}, {type:'Identifier', value:'f'}, {type:'Operand', value:'='}, {type:'Punctuator', value:'{'}, {type:'Identifier', value:'a'}, {type:'Punctuator', value:'}'}, {type:'Punctuator', value:';'}] >+ errors: [{ index: 10, lineNumber: 2, message: "Unexpected token a" }], >+ nodes: [{type:'VariableDeclaration', id:'f', range:[4, 14]}, >+ {type:'VariableDeclarator', range: [7, 13]}, >+ {type:'Identifier', range: [4, 5]}, >+ {type:'ObjectExpression', range:[10, 13]}], >+ tokens: [{type:'Keyword', value:'var', range: [0, 3]}, >+ {type:'Identifier', value:'f', range: [4, 5]}, >+ {type:'Punctuator', value:'=', range: [6, 7]}, >+ {type:'Punctuator', value:'{', range: [8, 9]}, >+ {type:'Identifier', value:'a', range: [12, 13]}, >+ {type:'Punctuator', value:'}', range: [13, 14]}, >+ {type:'Punctuator', value:';', range: [14, 15]}] > }, >- "obj prop recovery2": { >- source: "var f = {\na:\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property*/] >- }, >- "obj prop recovery3": { >- source: "var f = {\na: b.\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property*/] >- }, >- "obj prop recovery4": { >- source: "var f = {\na: b/**/\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property*/] >- }, >- "obj prop recovery5": { >- source: "var f = {\na: b/**/\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property*/] >- }, >- "obj prop recovery6": { >- source: "var f = {\na.\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression*/] >- }, >- "obj prop recovery7": { >+ >+ "obj prop ident recovery - ident only with postamble": { > source: "var f = {\na/**/\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression*/] >+ errors: [{ index: 10, lineNumber: 2, message: "Unexpected token a" }], >+ nodes: [{type:'VariableDeclaration', id:'f', range:[4, 18]}, >+ {type:'VariableDeclarator', range: [7, 17]}, >+ {type:'Identifier', range: [4, 5]}, >+ {type:'ObjectExpression', range:[10, 17]}], >+ tokens: [{type:'Keyword', value:'var', range: [0, 3]}, >+ {type:'Identifier', value:'f', range: [4, 5]}, >+ {type:'Punctuator', value:'=', range: [6, 7]}, >+ {type:'Punctuator', value:'{', range: [8, 9]}, >+ {type:'Identifier', value:'a', range: [12, 13]}, >+ {type:'Punctuator', value:'}', range: [19, 20]}, >+ {type:'Punctuator', value:';', range: [20, 21]}] > }, >- "obj prop recovery8": { >- source: "var f = {\nz: function(){}\na: this.z\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property*/] >+ >+ "nested obj prop ident recovery - nested ident only": { >+ source: "var f = {one: {a}};", >+ errors: [{ index: 15, lineNumber: 1, message: "Unexpected token a" }], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,19]}, >+ {"type":"VariableDeclarator","range":[7,18]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,18]}, >+ {"type":"Property","kind":"init","range":[13,17]}, >+ {"type":"Identifier","name":"one","range":[9,12]}, >+ {"type":"ObjectExpression","range":[15,17]}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"one"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[14,15],"value":"{"}, >+ {"type":"Identifier","range":[15,16],"value":"a"}, >+ {"type":"Punctuator","range":[16,17],"value":"}"}, >+ {"type":"Punctuator","range":[17,18],"value":"}"}, >+ {"type":"Punctuator","range":[18,19],"value":";"}] > }, >- "obj prop recovery9": { >- source: "var f = {\nz: function(){}\na: this.z(\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property*/] >+ >+ "obj prop ident recovery - successive 1": { >+ source: "var f = {a b:1};", >+ errors: [{ index: 9, lineNumber: 1, message: "Unexpected token a" }], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,16]}, >+ {"type":"VariableDeclarator","range":[7,15]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,15]}, >+ {"type":"Property","kind":"init","range":[12,14]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"Literal","range":[13,14],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Numeric","range":[13,14],"value":"1"}, >+ {"type":"Punctuator","range":[14,15],"value":"}"}, >+ {"type":"Punctuator","range":[15,16],"value":";"}] > }, >- "obj prop recovery10": { >- source: "var f = {\nz: function(){}\na: this.z(this.)\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property*/] >+ >+ "obj prop ident recovery - successive 2": { >+ source: "var f = {a b:1,c:2};", >+ errors: [{ index: 9, lineNumber: 1, message: "Unexpected token a" }], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,20]}, >+ {"type":"VariableDeclarator","range":[7,19]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,19]}, >+ {"type":"Property","kind":"init","range":[12,14]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"Literal","range":[13,14],"value":1}, >+ {"type":"Property","kind":"init","range":[15,18]}, >+ {"type":"Identifier","name":"c","range":[15,16]}, >+ {"type":"Literal","range":[17,18],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Numeric","range":[13,14],"value":"1"}, >+ {"type":"Punctuator","range":[14,15],"value":","}, >+ {"type":"Identifier","range":[15,16],"value":"c"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[17,18],"value":"2"}, >+ {"type":"Punctuator","range":[18,19],"value":"}"}, >+ {"type":"Punctuator","range":[19,20],"value":";"}] > }, >- "obj prop recovery11": { >- source: "var f = {\na: {\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property*/] >+ >+ "obj prop ident recovery - successive 3": { >+ source: "var f = {b:1,a};", >+ errors: [{ index: 13, lineNumber: 1, message: "Unexpected token a" }], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,16]}, >+ {"type":"VariableDeclarator","range":[7,15]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[13,15]}, >+ {"type":"Property","kind":"init","range":[9,12]}, >+ {"type":"Identifier","name":"b","range":[9,10]}, >+ {"type":"Literal","range":[11,12],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"b"}, >+ {"type":"Punctuator","range":[10,11],"value":":"}, >+ {"type":"Numeric","range":[11,12],"value":"1"}, >+ {"type":"Punctuator","range":[12,13],"value":","}, >+ {"type":"Identifier","range":[13,14],"value":"a"}, >+ {"type":"Punctuator","range":[14,15],"value":"}"}, >+ {"type":"Punctuator","range":[15,16],"value":";"}] > }, >- "nested obj prop recovery1": { >- source: "var f = {\none: {\na}\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property -> ObjectExpression*/] >+ >+ "obj prop ident recovery - successive 4": { >+ source: "var f = {b:1,c:2,a};", >+ errors: [{ index: 17, lineNumber: 1, message: "Unexpected token a" }], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,20]}, >+ {"type":"VariableDeclarator","range":[7,19]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[17,19]}, >+ {"type":"Property","kind":"init","range":[9,12]}, >+ {"type":"Identifier","name":"b","range":[9,10]}, >+ {"type":"Literal","range":[11,12],"value":1}, >+ {"type":"Property","kind":"init","range":[13,16]}, >+ {"type":"Identifier","name":"c","range":[13,14]}, >+ {"type":"Literal","range":[15,16],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"b"}, >+ {"type":"Punctuator","range":[10,11],"value":":"}, >+ {"type":"Numeric","range":[11,12],"value":"1"}, >+ {"type":"Punctuator","range":[12,13],"value":","}, >+ {"type":"Identifier","range":[13,14],"value":"c"}, >+ {"type":"Punctuator","range":[14,15],"value":":"}, >+ {"type":"Numeric","range":[15,16],"value":"2"}, >+ {"type":"Punctuator","range":[16,17],"value":","}, >+ {"type":"Identifier","range":[17,18],"value":"a"}, >+ {"type":"Punctuator","range":[18,19],"value":"}"}, >+ {"type":"Punctuator","range":[19,20],"value":";"}] > }, >- "nested obj prop recovery2": { >- source: "var f = {\none: {\na:}\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property -> ObjectExpression -> Property*/] >+ >+ "obj prop ident recovery - successive 5": { >+ source: "var f = {b:1,a c:2};", >+ errors: [{ index: 13, lineNumber: 1, message: "Unexpected token a" }], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,20]}, >+ {"type":"VariableDeclarator","range":[7,19]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[13,19]}, >+ {"type":"Property","kind":"init","range":[9,12]}, >+ {"type":"Identifier","name":"b","range":[9,10]}, >+ {"type":"Literal","range":[11,12],"value":1}, >+ {"type":"Property","kind":"init","range":[16,18]}, >+ {"type":"Identifier","name":"c","range":[16,16]}, >+ {"type":"Literal","range":[17,18],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"b"}, >+ {"type":"Punctuator","range":[10,11],"value":":"}, >+ {"type":"Numeric","range":[11,12],"value":"1"}, >+ {"type":"Punctuator","range":[12,13],"value":","}, >+ {"type":"Identifier","range":[13,14],"value":"a"}, >+ {"type":"Identifier","range":[15,16],"value":"c"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[17,18],"value":"2"}, >+ {"type":"Punctuator","range":[18,19],"value":"}"}, >+ {"type":"Punctuator","range":[19,20],"value":";"}] > }, >- "nested obj prop recovery3": { >- source: "var f = {\none: {\na: d}\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property -> ObjectExpression -> Property*/] >+ >+ 'obj prop ident recovery - successive 6': { >+ source: 'var f = {one: {a b:1,c}};', >+ errors: [{"lineNumber":1,"index":15,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":21,"message":"Unexpected token c","token":"c"}], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,25]}, >+ {"type":"VariableDeclarator","range":[7,24]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[13,24]}, >+ {"type":"Property","kind":"init","range":[13,23]}, >+ {"type":"Identifier","name":"one","range":[9,12]}, >+ {"type":"ObjectExpression","range":[21,23]}, >+ {"type":"Property","kind":"init","range":[18,20]}, >+ {"type":"Identifier","name":"b","range":[18,18]}, >+ {"type":"Literal","range":[19,20],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"one"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[14,15],"value":"{"}, >+ {"type":"Identifier","range":[15,16],"value":"a"}, >+ {"type":"Identifier","range":[17,18],"value":"b"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[19,20],"value":"1"}, >+ {"type":"Punctuator","range":[20,21],"value":","}, >+ {"type":"Identifier","range":[21,22],"value":"c"}, >+ {"type":"Punctuator","range":[22,23],"value":"}"}, >+ {"type":"Punctuator","range":[23,24],"value":"}"}, >+ {"type":"Punctuator","range":[24,25],"value":";"}] > }, >- "nested obj prop recovery4": { >- source: "var f = {\none: {\na: d.}\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property -> ObjectExpression -> Property*/] >+ >+ 'obj prop ident recovery - successive 7': { >+ source: 'var f = {one: {a c b:1}};', >+ errors: [{"lineNumber":1,"index":15,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":17,"message":"Unexpected token c","token":"c"}], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,25]}, >+ {"type":"VariableDeclarator","range":[7,24]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[13,24]}, >+ {"type":"Property","kind":"init","range":[13,23]}, >+ {"type":"Identifier","name":"one","range":[9,12]}, >+ {"type":"ObjectExpression","range":[19,23]}, >+ {"type":"Property","kind":"init","range":[20,22]}, >+ {"type":"Identifier","name":"b","range":[20,20]}, >+ {"type":"Literal","range":[21,22],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"one"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[14,15],"value":"{"}, >+ {"type":"Identifier","range":[15,16],"value":"a"}, >+ {"type":"Identifier","range":[17,18],"value":"c"}, >+ {"type":"Identifier","range":[19,20],"value":"b"}, >+ {"type":"Punctuator","range":[20,21],"value":":"}, >+ {"type":"Numeric","range":[21,22],"value":"1"}, >+ {"type":"Punctuator","range":[22,23],"value":"}"}, >+ {"type":"Punctuator","range":[23,24],"value":"}"}, >+ {"type":"Punctuator","range":[24,25],"value":";"}] > }, >- "nested obj prop recovery5": { >- source: "var f = {\none: {\na: d(}\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property -> ObjectExpression -> Property*/] >+ >+ 'obj prop ident recovery - successive nested 1': { >+ source: 'var f = {one: {a b:1}};', >+ errors: [{"lineNumber":1,"index":15,"message":"Unexpected token a","token":"a"}], >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,23]}, >+ {"type":"VariableDeclarator","range":[7,22]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,22]}, >+ {"type":"Property","kind":"init","range":[13,21]}, >+ {"type":"Identifier","name":"one","range":[9,12]}, >+ {"type":"ObjectExpression","range":[15,21]}, >+ {"type":"Property","kind":"init","range":[18,20]}, >+ {"type":"Identifier","name":"b","range":[18,18]}, >+ {"type":"Literal","range":[19,20],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"one"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[14,15],"value":"{"}, >+ {"type":"Identifier","range":[15,16],"value":"a"}, >+ {"type":"Identifier","range":[17,18],"value":"b"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[19,20],"value":"1"}, >+ {"type":"Punctuator","range":[20,21],"value":"}"}, >+ {"type":"Punctuator","range":[21,22],"value":"}"}, >+ {"type":"Punctuator","range":[22,23],"value":";"}] > }, >- "nested obj prop recovery6": { >- source: "var f = {\none: {\na: {}\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property -> ObjectExpression -> Property*/] >+ >+ 'obj prop ident recovery - successive nested 2': { >+ source: 'var f = {one: {a b:1,c:2}};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,27]}, >+ {"type":"VariableDeclarator","range":[7,26]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,26]}, >+ {"type":"Property","kind":"init","range":[13,25]}, >+ {"type":"Identifier","name":"one","range":[9,12]}, >+ {"type":"ObjectExpression","range":[15,25]}, >+ {"type":"Property","kind":"init","range":[18,20]}, >+ {"type":"Identifier","name":"b","range":[18,18]}, >+ {"type":"Literal","range":[19,20],"value":1}, >+ {"type":"Property","kind":"init","range":[21,24]}, >+ {"type":"Identifier","name":"c","range":[21,22]}, >+ {"type":"Literal","range":[23,24],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"one"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[14,15],"value":"{"}, >+ {"type":"Identifier","range":[15,16],"value":"a"}, >+ {"type":"Identifier","range":[17,18],"value":"b"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[19,20],"value":"1"}, >+ {"type":"Punctuator","range":[20,21],"value":","}, >+ {"type":"Identifier","range":[21,22],"value":"c"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"Numeric","range":[23,24],"value":"2"}, >+ {"type":"Punctuator","range":[24,25],"value":"}"}, >+ {"type":"Punctuator","range":[25,26],"value":"}"}, >+ {"type":"Punctuator","range":[26,27],"value":";"}], >+ errors: [{"lineNumber":1,"index":15,"message":"Unexpected token a","token":"a"}] > }, >- "nested obj prop recovery7": { >- source: "var f = {\none: {\na: d(c.)\n};", >- errors: [], >- nodes: [/*VariableDelcaration -> VariableDeclarator -> ObjectExpression -> Property -> ObjectExpression -> Property*/] >- } >+ >+ 'obj prop ident recovery - successive nested 3': { >+ source: 'var f = {one: {b: 1,a c:2}};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,28]}, >+ {"type":"VariableDeclarator","range":[7,27]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,27]}, >+ {"type":"Property","kind":"init","range":[13,26]}, >+ {"type":"Identifier","name":"one","range":[9,12]}, >+ {"type":"ObjectExpression","range":[20,26]}, >+ {"type":"Property","kind":"init","range":[15,19]}, >+ {"type":"Identifier","name":"b","range":[15,16]}, >+ {"type":"Literal","range":[18,19],"value":1}, >+ {"type":"Property","kind":"init","range":[23,25]}, >+ {"type":"Identifier","name":"c","range":[23,23]}, >+ {"type":"Literal","range":[24,25],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"one"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[14,15],"value":"{"}, >+ {"type":"Identifier","range":[15,16],"value":"b"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[18,19],"value":"1"}, >+ {"type":"Punctuator","range":[19,20],"value":","}, >+ {"type":"Identifier","range":[20,21],"value":"a"}, >+ {"type":"Identifier","range":[22,23],"value":"c"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"2"}, >+ {"type":"Punctuator","range":[25,26],"value":"}"}, >+ {"type":"Punctuator","range":[26,27],"value":"}"}, >+ {"type":"Punctuator","range":[27,28],"value":";"}], >+ errors: [{"lineNumber":1,"index":20,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - successive nested 4': { >+ source: 'var f = {one: {b: 1,c:2,a }};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,29]}, >+ {"type":"VariableDeclarator","range":[7,28]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,28]}, >+ {"type":"Property","kind":"init","range":[13,27]}, >+ {"type":"Identifier","name":"one","range":[9,12]}, >+ {"type":"ObjectExpression","range":[24,27]}, >+ {"type":"Property","kind":"init","range":[15,19]}, >+ {"type":"Identifier","name":"b","range":[15,16]}, >+ {"type":"Literal","range":[18,19],"value":1}, >+ {"type":"Property","kind":"init","range":[20,23]}, >+ {"type":"Identifier","name":"c","range":[20,21]}, >+ {"type":"Literal","range":[22,23],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"one"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[14,15],"value":"{"}, >+ {"type":"Identifier","range":[15,16],"value":"b"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[18,19],"value":"1"}, >+ {"type":"Punctuator","range":[19,20],"value":","}, >+ {"type":"Identifier","range":[20,21],"value":"c"}, >+ {"type":"Punctuator","range":[21,22],"value":":"}, >+ {"type":"Numeric","range":[22,23],"value":"2"}, >+ {"type":"Punctuator","range":[23,24],"value":","}, >+ {"type":"Identifier","range":[24,25],"value":"a"}, >+ {"type":"Punctuator","range":[26,27],"value":"}"}, >+ {"type":"Punctuator","range":[27,28],"value":"}"}, >+ {"type":"Punctuator","range":[28,29],"value":";"}], >+ errors: [{"lineNumber":1,"index":24,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - successive nested 5': { >+ source: 'var f = {one: {d b: 1,c:2,a }};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,31]}, >+ {"type":"VariableDeclarator","range":[7,30]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[13,30]}, >+ {"type":"Property","kind":"init","range":[13,29]}, >+ {"type":"Identifier","name":"one","range":[9,12]}, >+ {"type":"ObjectExpression","range":[26,29]}, >+ {"type":"Property","kind":"init","range":[18,21]}, >+ {"type":"Identifier","name":"b","range":[18,18]}, >+ {"type":"Literal","range":[20,21],"value":1}, >+ {"type":"Property","kind":"init","range":[22,25]}, >+ {"type":"Identifier","name":"c","range":[22,23]}, >+ {"type":"Literal","range":[24,25],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"one"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[14,15],"value":"{"}, >+ {"type":"Identifier","range":[15,16],"value":"d"}, >+ {"type":"Identifier","range":[17,18],"value":"b"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Punctuator","range":[21,22],"value":","}, >+ {"type":"Identifier","range":[22,23],"value":"c"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"2"}, >+ {"type":"Punctuator","range":[25,26],"value":","}, >+ {"type":"Identifier","range":[26,27],"value":"a"}, >+ {"type":"Punctuator","range":[28,29],"value":"}"}, >+ {"type":"Punctuator","range":[29,30],"value":"}"}, >+ {"type":"Punctuator","range":[30,31],"value":";"}], >+ errors: [{"lineNumber":1,"index":15,"message":"Unexpected token d","token":"d"}, >+ {"lineNumber":1,"index":26,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - successive nested 6': { >+ source: 'var f = {two one: {d b: 1,c:2,a }};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,35]}, >+ {"type":"VariableDeclarator","range":[8,34]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[17,34]}, >+ {"type":"Property","kind":"init","range":[17,33]}, >+ {"type":"Identifier","name":"one","range":[16,16]}, >+ {"type":"ObjectExpression","range":[30,33]}, >+ {"type":"Property","kind":"init","range":[22,25]}, >+ {"type":"Identifier","name":"b","range":[22,22]}, >+ {"type":"Literal","range":[24,25],"value":1}, >+ {"type":"Property","kind":"init","range":[26,29]}, >+ {"type":"Identifier","name":"c","range":[26,27]}, >+ {"type":"Literal","range":[28,29],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"two"}, >+ {"type":"Identifier","range":[13,16],"value":"one"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Punctuator","range":[18,19],"value":"{"}, >+ {"type":"Identifier","range":[19,20],"value":"d"}, >+ {"type":"Identifier","range":[21,22],"value":"b"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"1"}, >+ {"type":"Punctuator","range":[25,26],"value":","}, >+ {"type":"Identifier","range":[26,27],"value":"c"}, >+ {"type":"Punctuator","range":[27,28],"value":":"}, >+ {"type":"Numeric","range":[28,29],"value":"2"}, >+ {"type":"Punctuator","range":[29,30],"value":","}, >+ {"type":"Identifier","range":[30,31],"value":"a"}, >+ {"type":"Punctuator","range":[32,33],"value":"}"}, >+ {"type":"Punctuator","range":[33,34],"value":"}"}, >+ {"type":"Punctuator","range":[34,35],"value":";"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token two","token":"two"}, >+ {"lineNumber":1,"index":19,"message":"Unexpected token d","token":"d"}, >+ {"lineNumber":1,"index":30,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - successive nested 7': { >+ source: 'var f = {two three one: {d b: 1,c:2,a }};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[8,41]}, >+ {"type":"VariableDeclarator","range":[8,40]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[23,40]}, >+ {"type":"Property","kind":"init","range":[23,39]}, >+ {"type":"Identifier","name":"one","range":[22,22]}, >+ {"type":"ObjectExpression","range":[36,39]}, >+ {"type":"Property","kind":"init","range":[28,31]}, >+ {"type":"Identifier","name":"b","range":[28,28]}, >+ {"type":"Literal","range":[30,31],"value":1}, >+ {"type":"Property","kind":"init","range":[32,35]}, >+ {"type":"Identifier","name":"c","range":[32,33]}, >+ {"type":"Literal","range":[34,35],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,12],"value":"two"}, >+ {"type":"Identifier","range":[13,18],"value":"three"}, >+ {"type":"Identifier","range":[19,22],"value":"one"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"Punctuator","range":[24,25],"value":"{"}, >+ {"type":"Identifier","range":[25,26],"value":"d"}, >+ {"type":"Identifier","range":[27,28],"value":"b"}, >+ {"type":"Punctuator","range":[28,29],"value":":"}, >+ {"type":"Numeric","range":[30,31],"value":"1"}, >+ {"type":"Punctuator","range":[31,32],"value":","}, >+ {"type":"Identifier","range":[32,33],"value":"c"}, >+ {"type":"Punctuator","range":[33,34],"value":":"}, >+ {"type":"Numeric","range":[34,35],"value":"2"}, >+ {"type":"Punctuator","range":[35,36],"value":","}, >+ {"type":"Identifier","range":[36,37],"value":"a"}, >+ {"type":"Punctuator","range":[38,39],"value":"}"}, >+ {"type":"Punctuator","range":[39,40],"value":"}"}, >+ {"type":"Punctuator","range":[40,41],"value":";"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token two","token":"two"}, >+ {"lineNumber":1,"index":13,"message":"Unexpected token three","token":"three"}, >+ {"lineNumber":1,"index":25,"message":"Unexpected token d","token":"d"}, >+ {"lineNumber":1,"index":36,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl 1': { >+ source: 'function f(){} f({a});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,22]}, >+ {"type":"CallExpression","range":[15,21]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[18,20]}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Punctuator","range":[19,20],"value":"}"}, >+ {"type":"Punctuator","range":[20,21],"value":")"}, >+ {"type":"Punctuator","range":[21,22],"value":";"}], >+ errors: [{"lineNumber":1,"index":18,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl 2': { >+ source: 'function f(){} f({a b:1});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,26]}, >+ {"type":"CallExpression","range":[15,25]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[18,24]}, >+ {"type":"Property","kind":"init","range":[21,23]}, >+ {"type":"Identifier","name":"b","range":[21,21]}, >+ {"type":"Literal","range":[22,23],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Identifier","range":[20,21],"value":"b"}, >+ {"type":"Punctuator","range":[21,22],"value":":"}, >+ {"type":"Numeric","range":[22,23],"value":"1"}, >+ {"type":"Punctuator","range":[23,24],"value":"}"}, >+ {"type":"Punctuator","range":[24,25],"value":")"}, >+ {"type":"Punctuator","range":[25,26],"value":";"}], >+ errors: [{"lineNumber":1,"index":18,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl 3': { >+ source: 'function f(){} f({a b:1,c:2});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,30]}, >+ {"type":"CallExpression","range":[15,29]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[18,28]}, >+ {"type":"Property","kind":"init","range":[21,23]}, >+ {"type":"Identifier","name":"b","range":[21,21]}, >+ {"type":"Literal","range":[22,23],"value":1}, >+ {"type":"Property","kind":"init","range":[24,27]}, >+ {"type":"Identifier","name":"c","range":[24,25]}, >+ {"type":"Literal","range":[26,27],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Identifier","range":[20,21],"value":"b"}, >+ {"type":"Punctuator","range":[21,22],"value":":"}, >+ {"type":"Numeric","range":[22,23],"value":"1"}, >+ {"type":"Punctuator","range":[23,24],"value":","}, >+ {"type":"Identifier","range":[24,25],"value":"c"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Numeric","range":[26,27],"value":"2"}, >+ {"type":"Punctuator","range":[27,28],"value":"}"}, >+ {"type":"Punctuator","range":[28,29],"value":")"}, >+ {"type":"Punctuator","range":[29,30],"value":";"}], >+ errors: [{"lineNumber":1,"index":18,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl 4': { >+ source: 'function f(){} f({b:1,a});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,26]}, >+ {"type":"CallExpression","range":[15,25]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[22,24]}, >+ {"type":"Property","kind":"init","range":[18,21]}, >+ {"type":"Identifier","name":"b","range":[18,19]}, >+ {"type":"Literal","range":[20,21],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"b"}, >+ {"type":"Punctuator","range":[19,20],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Punctuator","range":[21,22],"value":","}, >+ {"type":"Identifier","range":[22,23],"value":"a"}, >+ {"type":"Punctuator","range":[23,24],"value":"}"}, >+ {"type":"Punctuator","range":[24,25],"value":")"}, >+ {"type":"Punctuator","range":[25,26],"value":";"}], >+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl 5': { >+ source: 'function f(){} f({b:1,c:2,a});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,30]}, >+ {"type":"CallExpression","range":[15,29]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[26,28]}, >+ {"type":"Property","kind":"init","range":[18,21]}, >+ {"type":"Identifier","name":"b","range":[18,19]}, >+ {"type":"Literal","range":[20,21],"value":1}, >+ {"type":"Property","kind":"init","range":[22,25]}, >+ {"type":"Identifier","name":"c","range":[22,23]}, >+ {"type":"Literal","range":[24,25],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"b"}, >+ {"type":"Punctuator","range":[19,20],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Punctuator","range":[21,22],"value":","}, >+ {"type":"Identifier","range":[22,23],"value":"c"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"2"}, >+ {"type":"Punctuator","range":[25,26],"value":","}, >+ {"type":"Identifier","range":[26,27],"value":"a"}, >+ {"type":"Punctuator","range":[27,28],"value":"}"}, >+ {"type":"Punctuator","range":[28,29],"value":")"}, >+ {"type":"Punctuator","range":[29,30],"value":";"}], >+ errors: [{"lineNumber":1,"index":26,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl 6': { >+ source: 'function f(){} f({a b c:2});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,28]}, >+ {"type":"CallExpression","range":[15,27]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[22,26]}, >+ {"type":"Property","kind":"init","range":[23,25]}, >+ {"type":"Identifier","name":"c","range":[23,23]}, >+ {"type":"Literal","range":[24,25],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Identifier","range":[20,21],"value":"b"}, >+ {"type":"Identifier","range":[22,23],"value":"c"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"2"}, >+ {"type":"Punctuator","range":[25,26],"value":"}"}, >+ {"type":"Punctuator","range":[26,27],"value":")"}, >+ {"type":"Punctuator","range":[27,28],"value":";"}], >+ errors: [{"lineNumber":1,"index":18,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":20,"message":"Unexpected token b","token":"b"}] >+ }, >+ >+ 'obj prop ident recovery - func decl 7': { >+ source: 'function f(){} f({a b:1,c});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,28]}, >+ {"type":"CallExpression","range":[15,27]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[24,26]}, >+ {"type":"Property","kind":"init","range":[21,23]}, >+ {"type":"Identifier","name":"b","range":[21,21]}, >+ {"type":"Literal","range":[22,23],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Identifier","range":[20,21],"value":"b"}, >+ {"type":"Punctuator","range":[21,22],"value":":"}, >+ {"type":"Numeric","range":[22,23],"value":"1"}, >+ {"type":"Punctuator","range":[23,24],"value":","}, >+ {"type":"Identifier","range":[24,25],"value":"c"}, >+ {"type":"Punctuator","range":[25,26],"value":"}"}, >+ {"type":"Punctuator","range":[26,27],"value":")"}, >+ {"type":"Punctuator","range":[27,28],"value":";"}], >+ errors: [{"lineNumber":1,"index":18,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":24,"message":"Unexpected token c","token":"c"}] >+ }, >+ >+ 'obj prop ident recovery - func decl nested 1': { >+ source: 'function f(){} f({one: {a}});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,29]}, >+ {"type":"CallExpression","range":[15,28]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[18,27]}, >+ {"type":"Property","kind":"init","range":[22,26]}, >+ {"type":"Identifier","name":"one","range":[18,21]}, >+ {"type":"ObjectExpression","range":[24,26]}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,21],"value":"one"}, >+ {"type":"Punctuator","range":[21,22],"value":":"}, >+ {"type":"Punctuator","range":[23,24],"value":"{"}, >+ {"type":"Identifier","range":[24,25],"value":"a"}, >+ {"type":"Punctuator","range":[25,26],"value":"}"}, >+ {"type":"Punctuator","range":[26,27],"value":"}"}, >+ {"type":"Punctuator","range":[27,28],"value":")"}, >+ {"type":"Punctuator","range":[28,29],"value":";"}], >+ errors: [{"lineNumber":1,"index":24,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl nested 2': { >+ source: 'function f(){} f({one: {a b:1}});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,33]}, >+ {"type":"CallExpression","range":[15,32]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[18,31]}, >+ {"type":"Property","kind":"init","range":[22,30]}, >+ {"type":"Identifier","name":"one","range":[18,21]}, >+ {"type":"ObjectExpression","range":[24,30]}, >+ {"type":"Property","kind":"init","range":[27,29]}, >+ {"type":"Identifier","name":"b","range":[27,27]}, >+ {"type":"Literal","range":[28,29],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,21],"value":"one"}, >+ {"type":"Punctuator","range":[21,22],"value":":"}, >+ {"type":"Punctuator","range":[23,24],"value":"{"}, >+ {"type":"Identifier","range":[24,25],"value":"a"}, >+ {"type":"Identifier","range":[26,27],"value":"b"}, >+ {"type":"Punctuator","range":[27,28],"value":":"}, >+ {"type":"Numeric","range":[28,29],"value":"1"}, >+ {"type":"Punctuator","range":[29,30],"value":"}"}, >+ {"type":"Punctuator","range":[30,31],"value":"}"}, >+ {"type":"Punctuator","range":[31,32],"value":")"}, >+ {"type":"Punctuator","range":[32,33],"value":";"}], >+ errors: [{"lineNumber":1,"index":24,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl nested 3': { >+ source: 'function f(){} f({one: {a b:1,c:2}});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,37]}, >+ {"type":"CallExpression","range":[15,36]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[18,35]}, >+ {"type":"Property","kind":"init","range":[22,34]}, >+ {"type":"Identifier","name":"one","range":[18,21]}, >+ {"type":"ObjectExpression","range":[24,34]}, >+ {"type":"Property","kind":"init","range":[27,29]}, >+ {"type":"Identifier","name":"b","range":[27,27]}, >+ {"type":"Literal","range":[28,29],"value":1}, >+ {"type":"Property","kind":"init","range":[30,33]}, >+ {"type":"Identifier","name":"c","range":[30,31]}, >+ {"type":"Literal","range":[32,33],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,21],"value":"one"}, >+ {"type":"Punctuator","range":[21,22],"value":":"}, >+ {"type":"Punctuator","range":[23,24],"value":"{"}, >+ {"type":"Identifier","range":[24,25],"value":"a"}, >+ {"type":"Identifier","range":[26,27],"value":"b"}, >+ {"type":"Punctuator","range":[27,28],"value":":"}, >+ {"type":"Numeric","range":[28,29],"value":"1"}, >+ {"type":"Punctuator","range":[29,30],"value":","}, >+ {"type":"Identifier","range":[30,31],"value":"c"}, >+ {"type":"Punctuator","range":[31,32],"value":":"}, >+ {"type":"Numeric","range":[32,33],"value":"2"}, >+ {"type":"Punctuator","range":[33,34],"value":"}"}, >+ {"type":"Punctuator","range":[34,35],"value":"}"}, >+ {"type":"Punctuator","range":[35,36],"value":")"}, >+ {"type":"Punctuator","range":[36,37],"value":";"}], >+ errors: [{"lineNumber":1,"index":24,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl nested 4': { >+ source: 'function f(){} f({one: {a b c:2}});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,35]}, >+ {"type":"CallExpression","range":[15,34]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[22,33]}, >+ {"type":"Property","kind":"init","range":[22,32]}, >+ {"type":"Identifier","name":"one","range":[18,21]}, >+ {"type":"ObjectExpression","range":[28,32]}, >+ {"type":"Property","kind":"init","range":[29,31]}, >+ {"type":"Identifier","name":"c","range":[29,29]}, >+ {"type":"Literal","range":[30,31],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,21],"value":"one"}, >+ {"type":"Punctuator","range":[21,22],"value":":"}, >+ {"type":"Punctuator","range":[23,24],"value":"{"}, >+ {"type":"Identifier","range":[24,25],"value":"a"}, >+ {"type":"Identifier","range":[26,27],"value":"b"}, >+ {"type":"Identifier","range":[28,29],"value":"c"}, >+ {"type":"Punctuator","range":[29,30],"value":":"}, >+ {"type":"Numeric","range":[30,31],"value":"2"}, >+ {"type":"Punctuator","range":[31,32],"value":"}"}, >+ {"type":"Punctuator","range":[32,33],"value":"}"}, >+ {"type":"Punctuator","range":[33,34],"value":")"}, >+ {"type":"Punctuator","range":[34,35],"value":";"}], >+ errors: [{"lineNumber":1,"index":24,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":26,"message":"Unexpected token b","token":"b"}] >+ }, >+ >+ 'obj prop ident recovery - func decl nested 5': { >+ source: 'function f(){} f({two one: {a b:1}});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,37]}, >+ {"type":"CallExpression","range":[15,36]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[25,35]}, >+ {"type":"Property","kind":"init","range":[26,34]}, >+ {"type":"Identifier","name":"one","range":[25,25]}, >+ {"type":"ObjectExpression","range":[28,34]}, >+ {"type":"Property","kind":"init","range":[31,33]}, >+ {"type":"Identifier","name":"b","range":[31,31]}, >+ {"type":"Literal","range":[32,33],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,21],"value":"two"}, >+ {"type":"Identifier","range":[22,25],"value":"one"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Punctuator","range":[27,28],"value":"{"}, >+ {"type":"Identifier","range":[28,29],"value":"a"}, >+ {"type":"Identifier","range":[30,31],"value":"b"}, >+ {"type":"Punctuator","range":[31,32],"value":":"}, >+ {"type":"Numeric","range":[32,33],"value":"1"}, >+ {"type":"Punctuator","range":[33,34],"value":"}"}, >+ {"type":"Punctuator","range":[34,35],"value":"}"}, >+ {"type":"Punctuator","range":[35,36],"value":")"}, >+ {"type":"Punctuator","range":[36,37],"value":";"}], >+ errors: [{"lineNumber":1,"index":18,"message":"Unexpected token two","token":"two"}, >+ {"lineNumber":1,"index":28,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - func decl nested 6': { >+ source: 'function f(){} f({two one: {a b:1},three});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,43]}, >+ {"type":"CallExpression","range":[15,42]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[35,41]}, >+ {"type":"Property","kind":"init","range":[26,34]}, >+ {"type":"Identifier","name":"one","range":[25,25]}, >+ {"type":"ObjectExpression","range":[28,34]}, >+ {"type":"Property","kind":"init","range":[31,33]}, >+ {"type":"Identifier","name":"b","range":[31,31]}, >+ {"type":"Literal","range":[32,33],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,21],"value":"two"}, >+ {"type":"Identifier","range":[22,25],"value":"one"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Punctuator","range":[27,28],"value":"{"}, >+ {"type":"Identifier","range":[28,29],"value":"a"}, >+ {"type":"Identifier","range":[30,31],"value":"b"}, >+ {"type":"Punctuator","range":[31,32],"value":":"}, >+ {"type":"Numeric","range":[32,33],"value":"1"}, >+ {"type":"Punctuator","range":[33,34],"value":"}"}, >+ {"type":"Punctuator","range":[34,35],"value":","}, >+ {"type":"Identifier","range":[35,40],"value":"three"}, >+ {"type":"Punctuator","range":[40,41],"value":"}"}, >+ {"type":"Punctuator","range":[41,42],"value":")"}, >+ {"type":"Punctuator","range":[42,43],"value":";"}], >+ errors: [{"lineNumber":1,"index":18,"message":"Unexpected token two","token":"two"}, >+ {"lineNumber":1,"index":28,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":35,"message":"Unexpected token three","token":"three"}] >+ }, >+ >+ 'obj prop ident recovery - return 1': { >+ source: 'function f() {return {a};}', >+ nodes: [{"type":"FunctionDeclaration","range":[13,26]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[14,26]}, >+ {"type":"ReturnStatement","range":[20,25]}, >+ {"type":"ObjectExpression","range":[22,24]}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,23],"value":"a"}, >+ {"type":"Punctuator","range":[23,24],"value":"}"}, >+ {"type":"Punctuator","range":[24,25],"value":";"}, >+ {"type":"Punctuator","range":[25,26],"value":"}"}], >+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - return 2': { >+ source: 'function f() {return {a b:1};}', >+ nodes: [{"type":"FunctionDeclaration","range":[13,30]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[14,30]}, >+ {"type":"ReturnStatement","range":[20,29]}, >+ {"type":"ObjectExpression","range":[22,28]}, >+ {"type":"Property","kind":"init","range":[25,27]}, >+ {"type":"Identifier","name":"b","range":[25,25]}, >+ {"type":"Literal","range":[26,27],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,23],"value":"a"}, >+ {"type":"Identifier","range":[24,25],"value":"b"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Numeric","range":[26,27],"value":"1"}, >+ {"type":"Punctuator","range":[27,28],"value":"}"}, >+ {"type":"Punctuator","range":[28,29],"value":";"}, >+ {"type":"Punctuator","range":[29,30],"value":"}"}], >+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - return 3': { >+ source: 'function f() {return {b:1, a c:2};}', >+ nodes: [{"type":"FunctionDeclaration","range":[13,35]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[14,35]}, >+ {"type":"ReturnStatement","range":[20,34]}, >+ {"type":"ObjectExpression","range":[27,33]}, >+ {"type":"Property","kind":"init","range":[22,25]}, >+ {"type":"Identifier","name":"b","range":[22,23]}, >+ {"type":"Literal","range":[24,25],"value":1}, >+ {"type":"Property","kind":"init","range":[30,32]}, >+ {"type":"Identifier","name":"c","range":[30,30]}, >+ {"type":"Literal","range":[31,32],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,23],"value":"b"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"1"}, >+ {"type":"Punctuator","range":[25,26],"value":","}, >+ {"type":"Identifier","range":[27,28],"value":"a"}, >+ {"type":"Identifier","range":[29,30],"value":"c"}, >+ {"type":"Punctuator","range":[30,31],"value":":"}, >+ {"type":"Numeric","range":[31,32],"value":"2"}, >+ {"type":"Punctuator","range":[32,33],"value":"}"}, >+ {"type":"Punctuator","range":[33,34],"value":";"}, >+ {"type":"Punctuator","range":[34,35],"value":"}"}], >+ errors: [{"lineNumber":1,"index":27,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - return 4': { >+ source: 'function f() {return {b:1,a c};}', >+ nodes: [{"type":"FunctionDeclaration","range":[14,32]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[20,32]}, >+ {"type":"ReturnStatement","range":[20,31]}, >+ {"type":"ObjectExpression","range":[29,30]}, >+ {"type":"Property","kind":"init","range":[22,25]}, >+ {"type":"Identifier","name":"b","range":[22,23]}, >+ {"type":"Literal","range":[24,25],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,23],"value":"b"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"1"}, >+ {"type":"Punctuator","range":[25,26],"value":","}, >+ {"type":"Identifier","range":[26,27],"value":"a"}, >+ {"type":"Identifier","range":[28,29],"value":"c"}, >+ {"type":"Punctuator","range":[29,30],"value":"}"}, >+ {"type":"Punctuator","range":[30,31],"value":";"}, >+ {"type":"Punctuator","range":[31,32],"value":"}"}], >+ errors: [{"lineNumber":1,"index":26,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":28,"message":"Unexpected token c","token":"c"}] >+ }, >+ >+ 'obj prop ident recovery - return 5': { >+ source: 'function f() {return {a b:1,c};}', >+ nodes: [{"type":"FunctionDeclaration","range":[14,32]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[20,32]}, >+ {"type":"ReturnStatement","range":[20,31]}, >+ {"type":"ObjectExpression","range":[28,30]}, >+ {"type":"Property","kind":"init","range":[25,27]}, >+ {"type":"Identifier","name":"b","range":[25,25]}, >+ {"type":"Literal","range":[26,27],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,23],"value":"a"}, >+ {"type":"Identifier","range":[24,25],"value":"b"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Numeric","range":[26,27],"value":"1"}, >+ {"type":"Punctuator","range":[27,28],"value":","}, >+ {"type":"Identifier","range":[28,29],"value":"c"}, >+ {"type":"Punctuator","range":[29,30],"value":"}"}, >+ {"type":"Punctuator","range":[30,31],"value":";"}, >+ {"type":"Punctuator","range":[31,32],"value":"}"}], >+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":28,"message":"Unexpected token c","token":"c"}] >+ }, >+ >+ 'obj prop ident recovery - return nested 1': { >+ source: 'function f() {return {one:{a}};}', >+ nodes: [{"type":"FunctionDeclaration","range":[13,32]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[14,32]}, >+ {"type":"ReturnStatement","range":[20,31]}, >+ {"type":"ObjectExpression","range":[22,30]}, >+ {"type":"Property","kind":"init","range":[26,29]}, >+ {"type":"Identifier","name":"one","range":[22,25]}, >+ {"type":"ObjectExpression","range":[27,29]}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,25],"value":"one"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Punctuator","range":[26,27],"value":"{"}, >+ {"type":"Identifier","range":[27,28],"value":"a"}, >+ {"type":"Punctuator","range":[28,29],"value":"}"}, >+ {"type":"Punctuator","range":[29,30],"value":"}"}, >+ {"type":"Punctuator","range":[30,31],"value":";"}, >+ {"type":"Punctuator","range":[31,32],"value":"}"}], >+ errors: [{"lineNumber":1,"index":27,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - return nested 2': { >+ source: 'function f() {return {one:{a b:1}};}', >+ nodes: [{"type":"FunctionDeclaration","range":[13,36]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[14,36]}, >+ {"type":"ReturnStatement","range":[20,35]}, >+ {"type":"ObjectExpression","range":[22,34]}, >+ {"type":"Property","kind":"init","range":[26,33]}, >+ {"type":"Identifier","name":"one","range":[22,25]}, >+ {"type":"ObjectExpression","range":[27,33]}, >+ {"type":"Property","kind":"init","range":[30,32]}, >+ {"type":"Identifier","name":"b","range":[30,30]}, >+ {"type":"Literal","range":[31,32],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,25],"value":"one"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Punctuator","range":[26,27],"value":"{"}, >+ {"type":"Identifier","range":[27,28],"value":"a"}, >+ {"type":"Identifier","range":[29,30],"value":"b"}, >+ {"type":"Punctuator","range":[30,31],"value":":"}, >+ {"type":"Numeric","range":[31,32],"value":"1"}, >+ {"type":"Punctuator","range":[32,33],"value":"}"}, >+ {"type":"Punctuator","range":[33,34],"value":"}"}, >+ {"type":"Punctuator","range":[34,35],"value":";"}, >+ {"type":"Punctuator","range":[35,36],"value":"}"}], >+ errors: [{"lineNumber":1,"index":27,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - return nested 3': { >+ source: 'function f() {return {one:{b:1, a c:2}};}', >+ nodes: [{"type":"FunctionDeclaration","range":[13,41]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[14,41]}, >+ {"type":"ReturnStatement","range":[20,40]}, >+ {"type":"ObjectExpression","range":[22,39]}, >+ {"type":"Property","kind":"init","range":[26,38]}, >+ {"type":"Identifier","name":"one","range":[22,25]}, >+ {"type":"ObjectExpression","range":[32,38]}, >+ {"type":"Property","kind":"init","range":[27,30]}, >+ {"type":"Identifier","name":"b","range":[27,28]}, >+ {"type":"Literal","range":[29,30],"value":1}, >+ {"type":"Property","kind":"init","range":[35,37]}, >+ {"type":"Identifier","name":"c","range":[35,35]}, >+ {"type":"Literal","range":[36,37],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,25],"value":"one"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Punctuator","range":[26,27],"value":"{"}, >+ {"type":"Identifier","range":[27,28],"value":"b"}, >+ {"type":"Punctuator","range":[28,29],"value":":"}, >+ {"type":"Numeric","range":[29,30],"value":"1"}, >+ {"type":"Punctuator","range":[30,31],"value":","}, >+ {"type":"Identifier","range":[32,33],"value":"a"}, >+ {"type":"Identifier","range":[34,35],"value":"c"}, >+ {"type":"Punctuator","range":[35,36],"value":":"}, >+ {"type":"Numeric","range":[36,37],"value":"2"}, >+ {"type":"Punctuator","range":[37,38],"value":"}"}, >+ {"type":"Punctuator","range":[38,39],"value":"}"}, >+ {"type":"Punctuator","range":[39,40],"value":";"}, >+ {"type":"Punctuator","range":[40,41],"value":"}"}], >+ errors: [{"lineNumber":1,"index":32,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - return nested 4': { >+ source: 'function f() {return {one:{a b:1,c}};}', >+ nodes: [{"type":"FunctionDeclaration","range":[14,38]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[20,38]}, >+ {"type":"ReturnStatement","range":[20,37]}, >+ {"type":"ObjectExpression","range":[26,36]}, >+ {"type":"Property","kind":"init","range":[26,35]}, >+ {"type":"Identifier","name":"one","range":[22,25]}, >+ {"type":"ObjectExpression","range":[33,35]}, >+ {"type":"Property","kind":"init","range":[30,32]}, >+ {"type":"Identifier","name":"b","range":[30,30]}, >+ {"type":"Literal","range":[31,32],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,25],"value":"one"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Punctuator","range":[26,27],"value":"{"}, >+ {"type":"Identifier","range":[27,28],"value":"a"}, >+ {"type":"Identifier","range":[29,30],"value":"b"}, >+ {"type":"Punctuator","range":[30,31],"value":":"}, >+ {"type":"Numeric","range":[31,32],"value":"1"}, >+ {"type":"Punctuator","range":[32,33],"value":","}, >+ {"type":"Identifier","range":[33,34],"value":"c"}, >+ {"type":"Punctuator","range":[34,35],"value":"}"}, >+ {"type":"Punctuator","range":[35,36],"value":"}"}, >+ {"type":"Punctuator","range":[36,37],"value":";"}, >+ {"type":"Punctuator","range":[37,38],"value":"}"}], >+ errors: [{"lineNumber":1,"index":27,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":33,"message":"Unexpected token c","token":"c"}] >+ }, >+ 'obj prop ident recovery - return nested 5': { >+ source: 'function f() {return {two one:{a b:1,c}};}', >+ nodes: [{"type":"FunctionDeclaration","range":[20,42]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[20,42]}, >+ {"type":"ReturnStatement","range":[20,41]}, >+ {"type":"ObjectExpression","range":[30,40]}, >+ {"type":"Property","kind":"init","range":[30,39]}, >+ {"type":"Identifier","name":"one","range":[29,29]}, >+ {"type":"ObjectExpression","range":[37,39]}, >+ {"type":"Property","kind":"init","range":[34,36]}, >+ {"type":"Identifier","name":"b","range":[34,34]}, >+ {"type":"Literal","range":[35,36],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,25],"value":"two"}, >+ {"type":"Identifier","range":[26,29],"value":"one"}, >+ {"type":"Punctuator","range":[29,30],"value":":"}, >+ {"type":"Punctuator","range":[30,31],"value":"{"}, >+ {"type":"Identifier","range":[31,32],"value":"a"}, >+ {"type":"Identifier","range":[33,34],"value":"b"}, >+ {"type":"Punctuator","range":[34,35],"value":":"}, >+ {"type":"Numeric","range":[35,36],"value":"1"}, >+ {"type":"Punctuator","range":[36,37],"value":","}, >+ {"type":"Identifier","range":[37,38],"value":"c"}, >+ {"type":"Punctuator","range":[38,39],"value":"}"}, >+ {"type":"Punctuator","range":[39,40],"value":"}"}, >+ {"type":"Punctuator","range":[40,41],"value":";"}, >+ {"type":"Punctuator","range":[41,42],"value":"}"}], >+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token two","token":"two"}, >+ {"lineNumber":1,"index":31,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":37,"message":"Unexpected token c","token":"c"}] >+ }, >+ 'obj prop ident recovery - return nested 6': { >+ source: 'function f() {return {two one:{a b:1,c}, three};}', >+ nodes: [{"type":"FunctionDeclaration","range":[20,49]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[20,49]}, >+ {"type":"ReturnStatement","range":[21,48]}, >+ {"type":"ObjectExpression","range":[41,47]}, >+ {"type":"Property","kind":"init","range":[30,39]}, >+ {"type":"Identifier","name":"one","range":[29,29]}, >+ {"type":"ObjectExpression","range":[37,39]}, >+ {"type":"Property","kind":"init","range":[34,36]}, >+ {"type":"Identifier","name":"b","range":[34,34]}, >+ {"type":"Literal","range":[35,36],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,25],"value":"two"}, >+ {"type":"Identifier","range":[26,29],"value":"one"}, >+ {"type":"Punctuator","range":[29,30],"value":":"}, >+ {"type":"Punctuator","range":[30,31],"value":"{"}, >+ {"type":"Identifier","range":[31,32],"value":"a"}, >+ {"type":"Identifier","range":[33,34],"value":"b"}, >+ {"type":"Punctuator","range":[34,35],"value":":"}, >+ {"type":"Numeric","range":[35,36],"value":"1"}, >+ {"type":"Punctuator","range":[36,37],"value":","}, >+ {"type":"Identifier","range":[37,38],"value":"c"}, >+ {"type":"Punctuator","range":[38,39],"value":"}"}, >+ {"type":"Punctuator","range":[39,40],"value":","}, >+ {"type":"Identifier","range":[41,46],"value":"three"}, >+ {"type":"Punctuator","range":[46,47],"value":"}"}, >+ {"type":"Punctuator","range":[47,48],"value":";"}, >+ {"type":"Punctuator","range":[48,49],"value":"}"}], >+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token two","token":"two"}, >+ {"lineNumber":1,"index":31,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":37,"message":"Unexpected token c","token":"c"}, >+ {"lineNumber":1,"index":41,"message":"Unexpected token three","token":"three"}] >+ }, >+ >+ 'obj prop ident recovery - multi 1': { >+ source: 'function f() {return {two one:{a b:1,c}, three};}var v = {d:1, a};', >+ nodes: [{"type":"FunctionDeclaration","range":[20,49]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[20,49]}, >+ {"type":"ReturnStatement","range":[21,48]}, >+ {"type":"ObjectExpression","range":[41,47]}, >+ {"type":"Property","kind":"init","range":[30,39]}, >+ {"type":"Identifier","name":"one","range":[29,29]}, >+ {"type":"ObjectExpression","range":[37,39]}, >+ {"type":"Property","kind":"init","range":[34,36]}, >+ {"type":"Identifier","name":"b","range":[34,34]}, >+ {"type":"Literal","range":[35,36],"value":1}, >+ {"type":"VariableDeclaration","kind":"var","range":[53,66]}, >+ {"type":"VariableDeclarator","range":[56,65]}, >+ {"type":"Identifier","name":"v","range":[53,54]}, >+ {"type":"ObjectExpression","range":[63,65]}, >+ {"type":"Property","kind":"init","range":[58,61]}, >+ {"type":"Identifier","name":"d","range":[58,59]}, >+ {"type":"Literal","range":[60,61],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,25],"value":"two"}, >+ {"type":"Identifier","range":[26,29],"value":"one"}, >+ {"type":"Punctuator","range":[29,30],"value":":"}, >+ {"type":"Punctuator","range":[30,31],"value":"{"}, >+ {"type":"Identifier","range":[31,32],"value":"a"}, >+ {"type":"Identifier","range":[33,34],"value":"b"}, >+ {"type":"Punctuator","range":[34,35],"value":":"}, >+ {"type":"Numeric","range":[35,36],"value":"1"}, >+ {"type":"Punctuator","range":[36,37],"value":","}, >+ {"type":"Identifier","range":[37,38],"value":"c"}, >+ {"type":"Punctuator","range":[38,39],"value":"}"}, >+ {"type":"Punctuator","range":[39,40],"value":","}, >+ {"type":"Identifier","range":[41,46],"value":"three"}, >+ {"type":"Punctuator","range":[46,47],"value":"}"}, >+ {"type":"Punctuator","range":[47,48],"value":";"}, >+ {"type":"Punctuator","range":[48,49],"value":"}"}, >+ {"type":"Keyword","range":[49,52],"value":"var"}, >+ {"type":"Identifier","range":[53,54],"value":"v"}, >+ {"type":"Punctuator","range":[55,56],"value":"="}, >+ {"type":"Punctuator","range":[57,58],"value":"{"}, >+ {"type":"Identifier","range":[58,59],"value":"d"}, >+ {"type":"Punctuator","range":[59,60],"value":":"}, >+ {"type":"Numeric","range":[60,61],"value":"1"}, >+ {"type":"Punctuator","range":[61,62],"value":","}, >+ {"type":"Identifier","range":[63,64],"value":"a"}, >+ {"type":"Punctuator","range":[64,65],"value":"}"}, >+ {"type":"Punctuator","range":[65,66],"value":";"}], >+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token two","token":"two"}, >+ {"lineNumber":1,"index":31,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":37,"message":"Unexpected token c","token":"c"}, >+ {"lineNumber":1,"index":41,"message":"Unexpected token three","token":"three"}, >+ {"lineNumber":1,"index":63,"message":"Unexpected token a","token":"a"}] >+ }, >+ >+ 'obj prop ident recovery - multi 2': { >+ source: 'function f() {return {two one:{a b:1,c}, three};}var v = {d:1, a};f({aa bb:1, cc});', >+ nodes: [{"type":"FunctionDeclaration","range":[20,49]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[20,49]}, >+ {"type":"ReturnStatement","range":[21,48]}, >+ {"type":"ObjectExpression","range":[41,47]}, >+ {"type":"Property","kind":"init","range":[30,39]}, >+ {"type":"Identifier","name":"one","range":[29,29]}, >+ {"type":"ObjectExpression","range":[37,39]}, >+ {"type":"Property","kind":"init","range":[34,36]}, >+ {"type":"Identifier","name":"b","range":[34,34]}, >+ {"type":"Literal","range":[35,36],"value":1}, >+ {"type":"VariableDeclaration","kind":"var","range":[53,66]}, >+ {"type":"VariableDeclarator","range":[56,65]}, >+ {"type":"Identifier","name":"v","range":[53,54]}, >+ {"type":"ObjectExpression","range":[63,65]}, >+ {"type":"Property","kind":"init","range":[58,61]}, >+ {"type":"Identifier","name":"d","range":[58,59]}, >+ {"type":"Literal","range":[60,61],"value":1}, >+ {"type":"ExpressionStatement","range":[66,83]}, >+ {"type":"CallExpression","range":[66,82]}, >+ {"type":"Identifier","name":"f","range":[66,67]}, >+ {"type":"ObjectExpression","range":[78,81]}, >+ {"type":"Property","kind":"init","range":[74,76]}, >+ {"type":"Identifier","name":"bb","range":[74,74]}, >+ {"type":"Literal","range":[75,76],"value":1}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Keyword","range":[14,20],"value":"return"}, >+ {"type":"Punctuator","range":[21,22],"value":"{"}, >+ {"type":"Identifier","range":[22,25],"value":"two"}, >+ {"type":"Identifier","range":[26,29],"value":"one"}, >+ {"type":"Punctuator","range":[29,30],"value":":"}, >+ {"type":"Punctuator","range":[30,31],"value":"{"}, >+ {"type":"Identifier","range":[31,32],"value":"a"}, >+ {"type":"Identifier","range":[33,34],"value":"b"}, >+ {"type":"Punctuator","range":[34,35],"value":":"}, >+ {"type":"Numeric","range":[35,36],"value":"1"}, >+ {"type":"Punctuator","range":[36,37],"value":","}, >+ {"type":"Identifier","range":[37,38],"value":"c"}, >+ {"type":"Punctuator","range":[38,39],"value":"}"}, >+ {"type":"Punctuator","range":[39,40],"value":","}, >+ {"type":"Identifier","range":[41,46],"value":"three"}, >+ {"type":"Punctuator","range":[46,47],"value":"}"}, >+ {"type":"Punctuator","range":[47,48],"value":";"}, >+ {"type":"Punctuator","range":[48,49],"value":"}"}, >+ {"type":"Keyword","range":[49,52],"value":"var"}, >+ {"type":"Identifier","range":[53,54],"value":"v"}, >+ {"type":"Punctuator","range":[55,56],"value":"="}, >+ {"type":"Punctuator","range":[57,58],"value":"{"}, >+ {"type":"Identifier","range":[58,59],"value":"d"}, >+ {"type":"Punctuator","range":[59,60],"value":":"}, >+ {"type":"Numeric","range":[60,61],"value":"1"}, >+ {"type":"Punctuator","range":[61,62],"value":","}, >+ {"type":"Identifier","range":[63,64],"value":"a"}, >+ {"type":"Punctuator","range":[64,65],"value":"}"}, >+ {"type":"Punctuator","range":[65,66],"value":";"}, >+ {"type":"Identifier","range":[66,67],"value":"f"}, >+ {"type":"Punctuator","range":[67,68],"value":"("}, >+ {"type":"Punctuator","range":[68,69],"value":"{"}, >+ {"type":"Identifier","range":[69,71],"value":"aa"}, >+ {"type":"Identifier","range":[72,74],"value":"bb"}, >+ {"type":"Punctuator","range":[74,75],"value":":"}, >+ {"type":"Numeric","range":[75,76],"value":"1"}, >+ {"type":"Punctuator","range":[76,77],"value":","}, >+ {"type":"Identifier","range":[78,80],"value":"cc"}, >+ {"type":"Punctuator","range":[80,81],"value":"}"}, >+ {"type":"Punctuator","range":[81,82],"value":")"}, >+ {"type":"Punctuator","range":[82,83],"value":";"}], >+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token two","token":"two"}, >+ {"lineNumber":1,"index":31,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":37,"message":"Unexpected token c","token":"c"}, >+ {"lineNumber":1,"index":41,"message":"Unexpected token three","token":"three"}, >+ {"lineNumber":1,"index":63,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":69,"message":"Unexpected token aa","token":"aa"}, >+ {"lineNumber":1,"index":78,"message":"Unexpected token cc","token":"cc"}] >+ }, >+ >+ 'obj prop recovery - missing comma 1': { >+ source: 'var f = {a:1 b:2};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,18]}, >+ {"type":"VariableDeclarator","range":[4,17]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[8,17]}, >+ {"type":"Property","kind":"init","range":[9,12]}, >+ {"type":"Identifier","name":"a","range":[9,10]}, >+ {"type":"Literal","range":[11,12],"value":1}, >+ {"type":"Property","kind":"init","range":[13,16]}, >+ {"type":"Identifier","name":"b","range":[13,14]}, >+ {"type":"Literal","range":[15,16],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Punctuator","range":[10,11],"value":":"}, >+ {"type":"Numeric","range":[11,12],"value":"1"}, >+ {"type":"Identifier","range":[13,14],"value":"b"}, >+ {"type":"Punctuator","range":[14,15],"value":":"}, >+ {"type":"Numeric","range":[15,16],"value":"2"}, >+ {"type":"Punctuator","range":[16,17],"value":"}"}, >+ {"type":"Punctuator","range":[17,18],"value":";"}], >+ errors: [{"lineNumber":1,"index":12,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 2': { >+ source: 'var f = {a:1 b:2 c:3};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,22]}, >+ {"type":"VariableDeclarator","range":[4,21]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[8,21]}, >+ {"type":"Property","kind":"init","range":[9,12]}, >+ {"type":"Identifier","name":"a","range":[9,10]}, >+ {"type":"Literal","range":[11,12],"value":1}, >+ {"type":"Property","kind":"init","range":[13,16]}, >+ {"type":"Identifier","name":"b","range":[13,14]}, >+ {"type":"Literal","range":[15,16],"value":2}, >+ {"type":"Property","kind":"init","range":[17,20]}, >+ {"type":"Identifier","name":"c","range":[17,18]}, >+ {"type":"Literal","range":[19,20],"value":3}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Punctuator","range":[10,11],"value":":"}, >+ {"type":"Numeric","range":[11,12],"value":"1"}, >+ {"type":"Identifier","range":[13,14],"value":"b"}, >+ {"type":"Punctuator","range":[14,15],"value":":"}, >+ {"type":"Numeric","range":[15,16],"value":"2"}, >+ {"type":"Identifier","range":[17,18],"value":"c"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[19,20],"value":"3"}, >+ {"type":"Punctuator","range":[20,21],"value":"}"}, >+ {"type":"Punctuator","range":[21,22],"value":";"}], >+ errors: [{"lineNumber":1,"index":12,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":16,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 3': { >+ source: 'var f = {a:1 b:{aa:1 bb:2}};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,28]}, >+ {"type":"VariableDeclarator","range":[4,27]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[8,27]}, >+ {"type":"Property","kind":"init","range":[9,12]}, >+ {"type":"Identifier","name":"a","range":[9,10]}, >+ {"type":"Literal","range":[11,12],"value":1}, >+ {"type":"Property","kind":"init","range":[13,26]}, >+ {"type":"Identifier","name":"b","range":[13,14]}, >+ {"type":"ObjectExpression","range":[15,26]}, >+ {"type":"Property","kind":"init","range":[16,20]}, >+ {"type":"Identifier","name":"aa","range":[16,18]}, >+ {"type":"Literal","range":[19,20],"value":1}, >+ {"type":"Property","kind":"init","range":[21,25]}, >+ {"type":"Identifier","name":"bb","range":[21,23]}, >+ {"type":"Literal","range":[24,25],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Punctuator","range":[10,11],"value":":"}, >+ {"type":"Numeric","range":[11,12],"value":"1"}, >+ {"type":"Identifier","range":[13,14],"value":"b"}, >+ {"type":"Punctuator","range":[14,15],"value":":"}, >+ {"type":"Punctuator","range":[15,16],"value":"{"}, >+ {"type":"Identifier","range":[16,18],"value":"aa"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[19,20],"value":"1"}, >+ {"type":"Identifier","range":[21,23],"value":"bb"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"2"}, >+ {"type":"Punctuator","range":[25,26],"value":"}"}, >+ {"type":"Punctuator","range":[26,27],"value":"}"}, >+ {"type":"Punctuator","range":[27,28],"value":";"}], >+ errors: [{"lineNumber":1,"index":12,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":20,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 4': { >+ source: 'var f = {a:1, b:{aa:1 bb:2} c:4};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,33]}, >+ {"type":"VariableDeclarator","range":[4,32]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[8,32]}, >+ {"type":"Property","kind":"init","range":[9,12]}, >+ {"type":"Identifier","name":"a","range":[9,10]}, >+ {"type":"Literal","range":[11,12],"value":1}, >+ {"type":"Property","kind":"init","range":[14,27]}, >+ {"type":"Identifier","name":"b","range":[14,15]}, >+ {"type":"ObjectExpression","range":[16,27]}, >+ {"type":"Property","kind":"init","range":[17,21]}, >+ {"type":"Identifier","name":"aa","range":[17,19]}, >+ {"type":"Literal","range":[20,21],"value":1}, >+ {"type":"Property","kind":"init","range":[22,26]}, >+ {"type":"Identifier","name":"bb","range":[22,24]}, >+ {"type":"Literal","range":[25,26],"value":2}, >+ {"type":"Property","kind":"init","range":[28,31]}, >+ {"type":"Identifier","name":"c","range":[28,29]}, >+ {"type":"Literal","range":[30,31],"value":4}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Punctuator","range":[10,11],"value":":"}, >+ {"type":"Numeric","range":[11,12],"value":"1"}, >+ {"type":"Punctuator","range":[12,13],"value":","}, >+ {"type":"Identifier","range":[14,15],"value":"b"}, >+ {"type":"Punctuator","range":[15,16],"value":":"}, >+ {"type":"Punctuator","range":[16,17],"value":"{"}, >+ {"type":"Identifier","range":[17,19],"value":"aa"}, >+ {"type":"Punctuator","range":[19,20],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Identifier","range":[22,24],"value":"bb"}, >+ {"type":"Punctuator","range":[24,25],"value":":"}, >+ {"type":"Numeric","range":[25,26],"value":"2"}, >+ {"type":"Punctuator","range":[26,27],"value":"}"}, >+ {"type":"Identifier","range":[28,29],"value":"c"}, >+ {"type":"Punctuator","range":[29,30],"value":":"}, >+ {"type":"Numeric","range":[30,31],"value":"4"}, >+ {"type":"Punctuator","range":[31,32],"value":"}"}, >+ {"type":"Punctuator","range":[32,33],"value":";"}], >+ errors: [{"lineNumber":1,"index":21,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":27,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 5': { >+ source: 'var f = {a:1, b:{aa:1, bb:2 cc:4} c:4};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,39]}, >+ {"type":"VariableDeclarator","range":[4,38]}, >+ {"type":"Identifier","name":"f","range":[4,5]}, >+ {"type":"ObjectExpression","range":[8,38]}, >+ {"type":"Property","kind":"init","range":[9,12]}, >+ {"type":"Identifier","name":"a","range":[9,10]}, >+ {"type":"Literal","range":[11,12],"value":1}, >+ {"type":"Property","kind":"init","range":[14,33]}, >+ {"type":"Identifier","name":"b","range":[14,15]}, >+ {"type":"ObjectExpression","range":[16,33]}, >+ {"type":"Property","kind":"init","range":[17,21]}, >+ {"type":"Identifier","name":"aa","range":[17,19]}, >+ {"type":"Literal","range":[20,21],"value":1}, >+ {"type":"Property","kind":"init","range":[23,27]}, >+ {"type":"Identifier","name":"bb","range":[23,25]}, >+ {"type":"Literal","range":[26,27],"value":2}, >+ {"type":"Property","kind":"init","range":[28,32]}, >+ {"type":"Identifier","name":"cc","range":[28,30]}, >+ {"type":"Literal","range":[31,32],"value":4}, >+ {"type":"Property","kind":"init","range":[34,37]}, >+ {"type":"Identifier","name":"c","range":[34,35]}, >+ {"type":"Literal","range":[36,37],"value":4}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"f"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Punctuator","range":[10,11],"value":":"}, >+ {"type":"Numeric","range":[11,12],"value":"1"}, >+ {"type":"Punctuator","range":[12,13],"value":","}, >+ {"type":"Identifier","range":[14,15],"value":"b"}, >+ {"type":"Punctuator","range":[15,16],"value":":"}, >+ {"type":"Punctuator","range":[16,17],"value":"{"}, >+ {"type":"Identifier","range":[17,19],"value":"aa"}, >+ {"type":"Punctuator","range":[19,20],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Punctuator","range":[21,22],"value":","}, >+ {"type":"Identifier","range":[23,25],"value":"bb"}, >+ {"type":"Punctuator","range":[25,26],"value":":"}, >+ {"type":"Numeric","range":[26,27],"value":"2"}, >+ {"type":"Identifier","range":[28,30],"value":"cc"}, >+ {"type":"Punctuator","range":[30,31],"value":":"}, >+ {"type":"Numeric","range":[31,32],"value":"4"}, >+ {"type":"Punctuator","range":[32,33],"value":"}"}, >+ {"type":"Identifier","range":[34,35],"value":"c"}, >+ {"type":"Punctuator","range":[35,36],"value":":"}, >+ {"type":"Numeric","range":[36,37],"value":"4"}, >+ {"type":"Punctuator","range":[37,38],"value":"}"}, >+ {"type":"Punctuator","range":[38,39],"value":";"}], >+ errors: [{"lineNumber":1,"index":27,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":33,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 6': { >+ source: 'function f(){} f({a:1, b:{aa:1, bb:2 cc:4} c:4});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,49]}, >+ {"type":"CallExpression","range":[15,48]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[17,47]}, >+ {"type":"Property","kind":"init","range":[18,21]}, >+ {"type":"Identifier","name":"a","range":[18,19]}, >+ {"type":"Literal","range":[20,21],"value":1}, >+ {"type":"Property","kind":"init","range":[23,42]}, >+ {"type":"Identifier","name":"b","range":[23,24]}, >+ {"type":"ObjectExpression","range":[25,42]}, >+ {"type":"Property","kind":"init","range":[26,30]}, >+ {"type":"Identifier","name":"aa","range":[26,28]}, >+ {"type":"Literal","range":[29,30],"value":1}, >+ {"type":"Property","kind":"init","range":[32,36]}, >+ {"type":"Identifier","name":"bb","range":[32,34]}, >+ {"type":"Literal","range":[35,36],"value":2}, >+ {"type":"Property","kind":"init","range":[37,41]}, >+ {"type":"Identifier","name":"cc","range":[37,39]}, >+ {"type":"Literal","range":[40,41],"value":4}, >+ {"type":"Property","kind":"init","range":[43,46]}, >+ {"type":"Identifier","name":"c","range":[43,44]}, >+ {"type":"Literal","range":[45,46],"value":4}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Punctuator","range":[19,20],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Punctuator","range":[21,22],"value":","}, >+ {"type":"Identifier","range":[23,24],"value":"b"}, >+ {"type":"Punctuator","range":[24,25],"value":":"}, >+ {"type":"Punctuator","range":[25,26],"value":"{"}, >+ {"type":"Identifier","range":[26,28],"value":"aa"}, >+ {"type":"Punctuator","range":[28,29],"value":":"}, >+ {"type":"Numeric","range":[29,30],"value":"1"}, >+ {"type":"Punctuator","range":[30,31],"value":","}, >+ {"type":"Identifier","range":[32,34],"value":"bb"}, >+ {"type":"Punctuator","range":[34,35],"value":":"}, >+ {"type":"Numeric","range":[35,36],"value":"2"}, >+ {"type":"Identifier","range":[37,39],"value":"cc"}, >+ {"type":"Punctuator","range":[39,40],"value":":"}, >+ {"type":"Numeric","range":[40,41],"value":"4"}, >+ {"type":"Punctuator","range":[41,42],"value":"}"}, >+ {"type":"Identifier","range":[43,44],"value":"c"}, >+ {"type":"Punctuator","range":[44,45],"value":":"}, >+ {"type":"Numeric","range":[45,46],"value":"4"}, >+ {"type":"Punctuator","range":[46,47],"value":"}"}, >+ {"type":"Punctuator","range":[47,48],"value":")"}, >+ {"type":"Punctuator","range":[48,49],"value":";"}], >+ errors: [{"lineNumber":1,"index":36,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":42,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 7': { >+ source: 'function f(){} f({a:1 b:2});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,28]}, >+ {"type":"CallExpression","range":[15,27]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[17,26]}, >+ {"type":"Property","kind":"init","range":[18,21]}, >+ {"type":"Identifier","name":"a","range":[18,19]}, >+ {"type":"Literal","range":[20,21],"value":1}, >+ {"type":"Property","kind":"init","range":[22,25]}, >+ {"type":"Identifier","name":"b","range":[22,23]}, >+ {"type":"Literal","range":[24,25],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Punctuator","range":[19,20],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Identifier","range":[22,23],"value":"b"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Numeric","range":[24,25],"value":"2"}, >+ {"type":"Punctuator","range":[25,26],"value":"}"}, >+ {"type":"Punctuator","range":[26,27],"value":")"}, >+ {"type":"Punctuator","range":[27,28],"value":";"}], >+ errors: [{"lineNumber":1,"index":21,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 8': { >+ source: 'function f(){} f({a:1 b:{aa:1 bb:2}});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,38]}, >+ {"type":"CallExpression","range":[15,37]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[17,36]}, >+ {"type":"Property","kind":"init","range":[18,21]}, >+ {"type":"Identifier","name":"a","range":[18,19]}, >+ {"type":"Literal","range":[20,21],"value":1}, >+ {"type":"Property","kind":"init","range":[22,35]}, >+ {"type":"Identifier","name":"b","range":[22,23]}, >+ {"type":"ObjectExpression","range":[24,35]}, >+ {"type":"Property","kind":"init","range":[25,29]}, >+ {"type":"Identifier","name":"aa","range":[25,27]}, >+ {"type":"Literal","range":[28,29],"value":1}, >+ {"type":"Property","kind":"init","range":[30,34]}, >+ {"type":"Identifier","name":"bb","range":[30,32]}, >+ {"type":"Literal","range":[33,34],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Punctuator","range":[19,20],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Identifier","range":[22,23],"value":"b"}, >+ {"type":"Punctuator","range":[23,24],"value":":"}, >+ {"type":"Punctuator","range":[24,25],"value":"{"}, >+ {"type":"Identifier","range":[25,27],"value":"aa"}, >+ {"type":"Punctuator","range":[27,28],"value":":"}, >+ {"type":"Numeric","range":[28,29],"value":"1"}, >+ {"type":"Identifier","range":[30,32],"value":"bb"}, >+ {"type":"Punctuator","range":[32,33],"value":":"}, >+ {"type":"Numeric","range":[33,34],"value":"2"}, >+ {"type":"Punctuator","range":[34,35],"value":"}"}, >+ {"type":"Punctuator","range":[35,36],"value":"}"}, >+ {"type":"Punctuator","range":[36,37],"value":")"}, >+ {"type":"Punctuator","range":[37,38],"value":";"}], >+ errors: [{"lineNumber":1,"index":21,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":29,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 9': { >+ source: 'function f(){} f({a:1, b:{aa:1 bb:2} c:4});', >+ nodes: [{"type":"FunctionDeclaration","range":[0,14]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,14]}, >+ {"type":"ExpressionStatement","range":[15,43]}, >+ {"type":"CallExpression","range":[15,42]}, >+ {"type":"Identifier","name":"f","range":[15,16]}, >+ {"type":"ObjectExpression","range":[17,41]}, >+ {"type":"Property","kind":"init","range":[18,21]}, >+ {"type":"Identifier","name":"a","range":[18,19]}, >+ {"type":"Literal","range":[20,21],"value":1}, >+ {"type":"Property","kind":"init","range":[23,36]}, >+ {"type":"Identifier","name":"b","range":[23,24]}, >+ {"type":"ObjectExpression","range":[25,36]}, >+ {"type":"Property","kind":"init","range":[26,30]}, >+ {"type":"Identifier","name":"aa","range":[26,28]}, >+ {"type":"Literal","range":[29,30],"value":1}, >+ {"type":"Property","kind":"init","range":[31,35]}, >+ {"type":"Identifier","name":"bb","range":[31,33]}, >+ {"type":"Literal","range":[34,35],"value":2}, >+ {"type":"Property","kind":"init","range":[37,40]}, >+ {"type":"Identifier","name":"c","range":[37,38]}, >+ {"type":"Literal","range":[39,40],"value":4}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Punctuator","range":[13,14],"value":"}"}, >+ {"type":"Identifier","range":[15,16],"value":"f"}, >+ {"type":"Punctuator","range":[16,17],"value":"("}, >+ {"type":"Punctuator","range":[17,18],"value":"{"}, >+ {"type":"Identifier","range":[18,19],"value":"a"}, >+ {"type":"Punctuator","range":[19,20],"value":":"}, >+ {"type":"Numeric","range":[20,21],"value":"1"}, >+ {"type":"Punctuator","range":[21,22],"value":","}, >+ {"type":"Identifier","range":[23,24],"value":"b"}, >+ {"type":"Punctuator","range":[24,25],"value":":"}, >+ {"type":"Punctuator","range":[25,26],"value":"{"}, >+ {"type":"Identifier","range":[26,28],"value":"aa"}, >+ {"type":"Punctuator","range":[28,29],"value":":"}, >+ {"type":"Numeric","range":[29,30],"value":"1"}, >+ {"type":"Identifier","range":[31,33],"value":"bb"}, >+ {"type":"Punctuator","range":[33,34],"value":":"}, >+ {"type":"Numeric","range":[34,35],"value":"2"}, >+ {"type":"Punctuator","range":[35,36],"value":"}"}, >+ {"type":"Identifier","range":[37,38],"value":"c"}, >+ {"type":"Punctuator","range":[38,39],"value":":"}, >+ {"type":"Numeric","range":[39,40],"value":"4"}, >+ {"type":"Punctuator","range":[40,41],"value":"}"}, >+ {"type":"Punctuator","range":[41,42],"value":")"}, >+ {"type":"Punctuator","range":[42,43],"value":";"}], >+ errors: [{"lineNumber":1,"index":30,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":36,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 10': { >+ source: 'function f(){return {a:1 b:2};}', >+ nodes: [{"type":"FunctionDeclaration","range":[0,31]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,31]}, >+ {"type":"ReturnStatement","range":[13,30]}, >+ {"type":"ObjectExpression","range":[20,29]}, >+ {"type":"Property","kind":"init","range":[21,24]}, >+ {"type":"Identifier","name":"a","range":[21,22]}, >+ {"type":"Literal","range":[23,24],"value":1}, >+ {"type":"Property","kind":"init","range":[25,28]}, >+ {"type":"Identifier","name":"b","range":[25,26]}, >+ {"type":"Literal","range":[27,28],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Keyword","range":[13,19],"value":"return"}, >+ {"type":"Punctuator","range":[20,21],"value":"{"}, >+ {"type":"Identifier","range":[21,22],"value":"a"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"Numeric","range":[23,24],"value":"1"}, >+ {"type":"Identifier","range":[25,26],"value":"b"}, >+ {"type":"Punctuator","range":[26,27],"value":":"}, >+ {"type":"Numeric","range":[27,28],"value":"2"}, >+ {"type":"Punctuator","range":[28,29],"value":"}"}, >+ {"type":"Punctuator","range":[29,30],"value":";"}, >+ {"type":"Punctuator","range":[30,31],"value":"}"}], >+ errors: [{"lineNumber":1,"index":24,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 11': { >+ source: 'function f(){return {a:1 b:2 c:3};}', >+ nodes: [{"type":"FunctionDeclaration","range":[0,35]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,35]}, >+ {"type":"ReturnStatement","range":[13,34]}, >+ {"type":"ObjectExpression","range":[20,33]}, >+ {"type":"Property","kind":"init","range":[21,24]}, >+ {"type":"Identifier","name":"a","range":[21,22]}, >+ {"type":"Literal","range":[23,24],"value":1}, >+ {"type":"Property","kind":"init","range":[25,28]}, >+ {"type":"Identifier","name":"b","range":[25,26]}, >+ {"type":"Literal","range":[27,28],"value":2}, >+ {"type":"Property","kind":"init","range":[29,32]}, >+ {"type":"Identifier","name":"c","range":[29,30]}, >+ {"type":"Literal","range":[31,32],"value":3}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Keyword","range":[13,19],"value":"return"}, >+ {"type":"Punctuator","range":[20,21],"value":"{"}, >+ {"type":"Identifier","range":[21,22],"value":"a"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"Numeric","range":[23,24],"value":"1"}, >+ {"type":"Identifier","range":[25,26],"value":"b"}, >+ {"type":"Punctuator","range":[26,27],"value":":"}, >+ {"type":"Numeric","range":[27,28],"value":"2"}, >+ {"type":"Identifier","range":[29,30],"value":"c"}, >+ {"type":"Punctuator","range":[30,31],"value":":"}, >+ {"type":"Numeric","range":[31,32],"value":"3"}, >+ {"type":"Punctuator","range":[32,33],"value":"}"}, >+ {"type":"Punctuator","range":[33,34],"value":";"}, >+ {"type":"Punctuator","range":[34,35],"value":"}"}], >+ errors: [{"lineNumber":1,"index":24,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":28,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 12': { >+ source: 'function f(){return {a:1 b:{aa:1 bb:2}};}', >+ nodes: [{"type":"FunctionDeclaration","range":[0,41]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,41]}, >+ {"type":"ReturnStatement","range":[13,40]}, >+ {"type":"ObjectExpression","range":[20,39]}, >+ {"type":"Property","kind":"init","range":[21,24]}, >+ {"type":"Identifier","name":"a","range":[21,22]}, >+ {"type":"Literal","range":[23,24],"value":1}, >+ {"type":"Property","kind":"init","range":[25,38]}, >+ {"type":"Identifier","name":"b","range":[25,26]}, >+ {"type":"ObjectExpression","range":[27,38]}, >+ {"type":"Property","kind":"init","range":[28,32]}, >+ {"type":"Identifier","name":"aa","range":[28,30]}, >+ {"type":"Literal","range":[31,32],"value":1}, >+ {"type":"Property","kind":"init","range":[33,37]}, >+ {"type":"Identifier","name":"bb","range":[33,35]}, >+ {"type":"Literal","range":[36,37],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Keyword","range":[13,19],"value":"return"}, >+ {"type":"Punctuator","range":[20,21],"value":"{"}, >+ {"type":"Identifier","range":[21,22],"value":"a"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"Numeric","range":[23,24],"value":"1"}, >+ {"type":"Identifier","range":[25,26],"value":"b"}, >+ {"type":"Punctuator","range":[26,27],"value":":"}, >+ {"type":"Punctuator","range":[27,28],"value":"{"}, >+ {"type":"Identifier","range":[28,30],"value":"aa"}, >+ {"type":"Punctuator","range":[30,31],"value":":"}, >+ {"type":"Numeric","range":[31,32],"value":"1"}, >+ {"type":"Identifier","range":[33,35],"value":"bb"}, >+ {"type":"Punctuator","range":[35,36],"value":":"}, >+ {"type":"Numeric","range":[36,37],"value":"2"}, >+ {"type":"Punctuator","range":[37,38],"value":"}"}, >+ {"type":"Punctuator","range":[38,39],"value":"}"}, >+ {"type":"Punctuator","range":[39,40],"value":";"}, >+ {"type":"Punctuator","range":[40,41],"value":"}"}], >+ errors: [{"lineNumber":1,"index":24,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":32,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 13': { >+ source: 'function f(){return {a:1, b:{aa:1 bb:2} c:4};}', >+ nodes: [{"type":"FunctionDeclaration","range":[0,46]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,46]}, >+ {"type":"ReturnStatement","range":[13,45]}, >+ {"type":"ObjectExpression","range":[20,44]}, >+ {"type":"Property","kind":"init","range":[21,24]}, >+ {"type":"Identifier","name":"a","range":[21,22]}, >+ {"type":"Literal","range":[23,24],"value":1}, >+ {"type":"Property","kind":"init","range":[26,39]}, >+ {"type":"Identifier","name":"b","range":[26,27]}, >+ {"type":"ObjectExpression","range":[28,39]}, >+ {"type":"Property","kind":"init","range":[29,33]}, >+ {"type":"Identifier","name":"aa","range":[29,31]}, >+ {"type":"Literal","range":[32,33],"value":1}, >+ {"type":"Property","kind":"init","range":[34,38]}, >+ {"type":"Identifier","name":"bb","range":[34,36]}, >+ {"type":"Literal","range":[37,38],"value":2}, >+ {"type":"Property","kind":"init","range":[40,43]}, >+ {"type":"Identifier","name":"c","range":[40,41]}, >+ {"type":"Literal","range":[42,43],"value":4}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Keyword","range":[13,19],"value":"return"}, >+ {"type":"Punctuator","range":[20,21],"value":"{"}, >+ {"type":"Identifier","range":[21,22],"value":"a"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"Numeric","range":[23,24],"value":"1"}, >+ {"type":"Punctuator","range":[24,25],"value":","}, >+ {"type":"Identifier","range":[26,27],"value":"b"}, >+ {"type":"Punctuator","range":[27,28],"value":":"}, >+ {"type":"Punctuator","range":[28,29],"value":"{"}, >+ {"type":"Identifier","range":[29,31],"value":"aa"}, >+ {"type":"Punctuator","range":[31,32],"value":":"}, >+ {"type":"Numeric","range":[32,33],"value":"1"}, >+ {"type":"Identifier","range":[34,36],"value":"bb"}, >+ {"type":"Punctuator","range":[36,37],"value":":"}, >+ {"type":"Numeric","range":[37,38],"value":"2"}, >+ {"type":"Punctuator","range":[38,39],"value":"}"}, >+ {"type":"Identifier","range":[40,41],"value":"c"}, >+ {"type":"Punctuator","range":[41,42],"value":":"}, >+ {"type":"Numeric","range":[42,43],"value":"4"}, >+ {"type":"Punctuator","range":[43,44],"value":"}"}, >+ {"type":"Punctuator","range":[44,45],"value":";"}, >+ {"type":"Punctuator","range":[45,46],"value":"}"}], >+ errors: [{"lineNumber":1,"index":33,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":39,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - missing comma 14': { >+ source: 'function f(){return {a:1, b:{aa:1, bb:2 cc:4} c:4};', >+ nodes: [{"type":"FunctionDeclaration","range":[0,51]}, >+ {"type":"Identifier","name":"f","range":[9,10]}, >+ {"type":"BlockStatement","range":[12,51]}, >+ {"type":"ReturnStatement","range":[13,51]}, >+ {"type":"ObjectExpression","range":[20,50]}, >+ {"type":"Property","kind":"init","range":[21,24]}, >+ {"type":"Identifier","name":"a","range":[21,22]}, >+ {"type":"Literal","range":[23,24],"value":1}, >+ {"type":"Property","kind":"init","range":[26,45]}, >+ {"type":"Identifier","name":"b","range":[26,27]}, >+ {"type":"ObjectExpression","range":[28,45]}, >+ {"type":"Property","kind":"init","range":[29,33]}, >+ {"type":"Identifier","name":"aa","range":[29,31]}, >+ {"type":"Literal","range":[32,33],"value":1}, >+ {"type":"Property","kind":"init","range":[35,39]}, >+ {"type":"Identifier","name":"bb","range":[35,37]}, >+ {"type":"Literal","range":[38,39],"value":2}, >+ {"type":"Property","kind":"init","range":[40,44]}, >+ {"type":"Identifier","name":"cc","range":[40,42]}, >+ {"type":"Literal","range":[43,44],"value":4}, >+ {"type":"Property","kind":"init","range":[46,49]}, >+ {"type":"Identifier","name":"c","range":[46,47]}, >+ {"type":"Literal","range":[48,49],"value":4}], >+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"}, >+ {"type":"Identifier","range":[9,10],"value":"f"}, >+ {"type":"Punctuator","range":[10,11],"value":"("}, >+ {"type":"Punctuator","range":[11,12],"value":")"}, >+ {"type":"Punctuator","range":[12,13],"value":"{"}, >+ {"type":"Keyword","range":[13,19],"value":"return"}, >+ {"type":"Punctuator","range":[20,21],"value":"{"}, >+ {"type":"Identifier","range":[21,22],"value":"a"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"Numeric","range":[23,24],"value":"1"}, >+ {"type":"Punctuator","range":[24,25],"value":","}, >+ {"type":"Identifier","range":[26,27],"value":"b"}, >+ {"type":"Punctuator","range":[27,28],"value":":"}, >+ {"type":"Punctuator","range":[28,29],"value":"{"}, >+ {"type":"Identifier","range":[29,31],"value":"aa"}, >+ {"type":"Punctuator","range":[31,32],"value":":"}, >+ {"type":"Numeric","range":[32,33],"value":"1"}, >+ {"type":"Punctuator","range":[33,34],"value":","}, >+ {"type":"Identifier","range":[35,37],"value":"bb"}, >+ {"type":"Punctuator","range":[37,38],"value":":"}, >+ {"type":"Numeric","range":[38,39],"value":"2"}, >+ {"type":"Identifier","range":[40,42],"value":"cc"}, >+ {"type":"Punctuator","range":[42,43],"value":":"}, >+ {"type":"Numeric","range":[43,44],"value":"4"}, >+ {"type":"Punctuator","range":[44,45],"value":"}"}, >+ {"type":"Identifier","range":[46,47],"value":"c"}, >+ {"type":"Punctuator","range":[47,48],"value":":"}, >+ {"type":"Numeric","range":[48,49],"value":"4"}, >+ {"type":"Punctuator","range":[49,50],"value":"}"}, >+ {"type":"Punctuator","range":[50,51],"value":";"}], >+ errors: [{"lineNumber":1,"index":39,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":45,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":51,"message":"Unexpected end of input"}] >+ }, >+ >+ 'obj prop recovery - mixed 1': { >+ source: 'var v = {a b:1 c:2};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,20]}, >+ {"type":"VariableDeclarator","range":[7,19]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,19]}, >+ {"type":"Property","kind":"init","range":[12,14]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"Literal","range":[13,14],"value":1}, >+ {"type":"Property","kind":"init","range":[15,18]}, >+ {"type":"Identifier","name":"c","range":[15,16]}, >+ {"type":"Literal","range":[17,18],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Numeric","range":[13,14],"value":"1"}, >+ {"type":"Identifier","range":[15,16],"value":"c"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[17,18],"value":"2"}, >+ {"type":"Punctuator","range":[18,19],"value":"}"}, >+ {"type":"Punctuator","range":[19,20],"value":";"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":14,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - mixed 2': { >+ source: 'var v = {a b:1 d c:2};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,22]}, >+ {"type":"VariableDeclarator","range":[7,21]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[15,21]}, >+ {"type":"Property","kind":"init","range":[12,14]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"Literal","range":[13,14],"value":1}, >+ {"type":"Property","kind":"init","range":[18,20]}, >+ {"type":"Identifier","name":"c","range":[18,18]}, >+ {"type":"Literal","range":[19,20],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Numeric","range":[13,14],"value":"1"}, >+ {"type":"Identifier","range":[15,16],"value":"d"}, >+ {"type":"Identifier","range":[17,18],"value":"c"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[19,20],"value":"2"}, >+ {"type":"Punctuator","range":[20,21],"value":"}"}, >+ {"type":"Punctuator","range":[21,22],"value":";"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":14,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":15,"message":"Unexpected token d","token":"d"}] >+ }, >+ >+ 'obj prop recovery - mixed 3': { >+ source: 'var v = {a b:{cc:3, dd:\'hey\' e} c:2};', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,37]}, >+ {"type":"VariableDeclarator","range":[7,36]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[12,36]}, >+ {"type":"Property","kind":"init","range":[13,31]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"ObjectExpression","range":[29,31]}, >+ {"type":"Property","kind":"init","range":[14,18]}, >+ {"type":"Identifier","name":"cc","range":[14,16]}, >+ {"type":"Literal","range":[17,18],"value":3}, >+ {"type":"Property","kind":"init","range":[20,28]}, >+ {"type":"Identifier","name":"dd","range":[20,22]}, >+ {"type":"Literal","range":[23,28],"value":"hey"}, >+ {"type":"Property","kind":"init","range":[32,35]}, >+ {"type":"Identifier","name":"c","range":[32,33]}, >+ {"type":"Literal","range":[34,35],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Identifier","range":[14,16],"value":"cc"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[17,18],"value":"3"}, >+ {"type":"Punctuator","range":[18,19],"value":","}, >+ {"type":"Identifier","range":[20,22],"value":"dd"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"String","range":[23,28],"value":"'hey'"}, >+ {"type":"Identifier","range":[29,30],"value":"e"}, >+ {"type":"Punctuator","range":[30,31],"value":"}"}, >+ {"type":"Identifier","range":[32,33],"value":"c"}, >+ {"type":"Punctuator","range":[33,34],"value":":"}, >+ {"type":"Numeric","range":[34,35],"value":"2"}, >+ {"type":"Punctuator","range":[35,36],"value":"}"}, >+ {"type":"Punctuator","range":[36,37],"value":";"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":28,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":29,"message":"Unexpected token e","token":"e"}, >+ {"lineNumber":1,"index":31,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - mixed 4': { >+ source: 'var v = {a b:{cc:3, dd:\'hey\' e} c:2};function f() {return {a b:{cc:3, dd:\'hey\' e} c:2};}', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,37]}, >+ {"type":"VariableDeclarator","range":[7,36]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[12,36]}, >+ {"type":"Property","kind":"init","range":[13,31]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"ObjectExpression","range":[29,31]}, >+ {"type":"Property","kind":"init","range":[14,18]}, >+ {"type":"Identifier","name":"cc","range":[14,16]}, >+ {"type":"Literal","range":[17,18],"value":3}, >+ {"type":"Property","kind":"init","range":[20,28]}, >+ {"type":"Identifier","name":"dd","range":[20,22]}, >+ {"type":"Literal","range":[23,28],"value":"hey"}, >+ {"type":"Property","kind":"init","range":[32,35]}, >+ {"type":"Identifier","name":"c","range":[32,33]}, >+ {"type":"Literal","range":[34,35],"value":2}, >+ {"type":"FunctionDeclaration","range":[51,88]}, >+ {"type":"Identifier","name":"f","range":[46,47]}, >+ {"type":"BlockStatement","range":[57,88]}, >+ {"type":"ReturnStatement","range":[57,87]}, >+ {"type":"ObjectExpression","range":[62,86]}, >+ {"type":"Property","kind":"init","range":[63,81]}, >+ {"type":"Identifier","name":"b","range":[62,62]}, >+ {"type":"ObjectExpression","range":[79,81]}, >+ {"type":"Property","kind":"init","range":[64,68]}, >+ {"type":"Identifier","name":"cc","range":[64,66]}, >+ {"type":"Literal","range":[67,68],"value":3}, >+ {"type":"Property","kind":"init","range":[70,78]}, >+ {"type":"Identifier","name":"dd","range":[70,72]}, >+ {"type":"Literal","range":[73,78],"value":"hey"}, >+ {"type":"Property","kind":"init","range":[82,85]}, >+ {"type":"Identifier","name":"c","range":[82,83]}, >+ {"type":"Literal","range":[84,85],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Identifier","range":[14,16],"value":"cc"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[17,18],"value":"3"}, >+ {"type":"Punctuator","range":[18,19],"value":","}, >+ {"type":"Identifier","range":[20,22],"value":"dd"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"String","range":[23,28],"value":"'hey'"}, >+ {"type":"Identifier","range":[29,30],"value":"e"}, >+ {"type":"Punctuator","range":[30,31],"value":"}"}, >+ {"type":"Identifier","range":[32,33],"value":"c"}, >+ {"type":"Punctuator","range":[33,34],"value":":"}, >+ {"type":"Numeric","range":[34,35],"value":"2"}, >+ {"type":"Punctuator","range":[35,36],"value":"}"}, >+ {"type":"Punctuator","range":[36,37],"value":";"}, >+ {"type":"Keyword","range":[37,45],"value":"function"}, >+ {"type":"Identifier","range":[46,47],"value":"f"}, >+ {"type":"Punctuator","range":[47,48],"value":"("}, >+ {"type":"Punctuator","range":[48,49],"value":")"}, >+ {"type":"Punctuator","range":[50,51],"value":"{"}, >+ {"type":"Keyword","range":[51,57],"value":"return"}, >+ {"type":"Punctuator","range":[58,59],"value":"{"}, >+ {"type":"Identifier","range":[59,60],"value":"a"}, >+ {"type":"Identifier","range":[61,62],"value":"b"}, >+ {"type":"Punctuator","range":[62,63],"value":":"}, >+ {"type":"Punctuator","range":[63,64],"value":"{"}, >+ {"type":"Identifier","range":[64,66],"value":"cc"}, >+ {"type":"Punctuator","range":[66,67],"value":":"}, >+ {"type":"Numeric","range":[67,68],"value":"3"}, >+ {"type":"Punctuator","range":[68,69],"value":","}, >+ {"type":"Identifier","range":[70,72],"value":"dd"}, >+ {"type":"Punctuator","range":[72,73],"value":":"}, >+ {"type":"String","range":[73,78],"value":"'hey'"}, >+ {"type":"Identifier","range":[79,80],"value":"e"}, >+ {"type":"Punctuator","range":[80,81],"value":"}"}, >+ {"type":"Identifier","range":[82,83],"value":"c"}, >+ {"type":"Punctuator","range":[83,84],"value":":"}, >+ {"type":"Numeric","range":[84,85],"value":"2"}, >+ {"type":"Punctuator","range":[85,86],"value":"}"}, >+ {"type":"Punctuator","range":[86,87],"value":";"}, >+ {"type":"Punctuator","range":[87,88],"value":"}"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":28,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":29,"message":"Unexpected token e","token":"e"}, >+ {"lineNumber":1,"index":31,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":59,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":78,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":79,"message":"Unexpected token e","token":"e"}, >+ {"lineNumber":1,"index":81,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - mixed 5': { >+ source: 'var v = {a b:1 c:2};function f() {return {a b:1 c:2};}', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,20]}, >+ {"type":"VariableDeclarator","range":[7,19]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,19]}, >+ {"type":"Property","kind":"init","range":[12,14]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"Literal","range":[13,14],"value":1}, >+ {"type":"Property","kind":"init","range":[15,18]}, >+ {"type":"Identifier","name":"c","range":[15,16]}, >+ {"type":"Literal","range":[17,18],"value":2}, >+ {"type":"FunctionDeclaration","range":[33,54]}, >+ {"type":"Identifier","name":"f","range":[29,30]}, >+ {"type":"BlockStatement","range":[34,54]}, >+ {"type":"ReturnStatement","range":[40,53]}, >+ {"type":"ObjectExpression","range":[42,52]}, >+ {"type":"Property","kind":"init","range":[45,47]}, >+ {"type":"Identifier","name":"b","range":[45,45]}, >+ {"type":"Literal","range":[46,47],"value":1}, >+ {"type":"Property","kind":"init","range":[48,51]}, >+ {"type":"Identifier","name":"c","range":[48,49]}, >+ {"type":"Literal","range":[50,51],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Numeric","range":[13,14],"value":"1"}, >+ {"type":"Identifier","range":[15,16],"value":"c"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[17,18],"value":"2"}, >+ {"type":"Punctuator","range":[18,19],"value":"}"}, >+ {"type":"Punctuator","range":[19,20],"value":";"}, >+ {"type":"Keyword","range":[20,28],"value":"function"}, >+ {"type":"Identifier","range":[29,30],"value":"f"}, >+ {"type":"Punctuator","range":[30,31],"value":"("}, >+ {"type":"Punctuator","range":[31,32],"value":")"}, >+ {"type":"Punctuator","range":[33,34],"value":"{"}, >+ {"type":"Keyword","range":[34,40],"value":"return"}, >+ {"type":"Punctuator","range":[41,42],"value":"{"}, >+ {"type":"Identifier","range":[42,43],"value":"a"}, >+ {"type":"Identifier","range":[44,45],"value":"b"}, >+ {"type":"Punctuator","range":[45,46],"value":":"}, >+ {"type":"Numeric","range":[46,47],"value":"1"}, >+ {"type":"Identifier","range":[48,49],"value":"c"}, >+ {"type":"Punctuator","range":[49,50],"value":":"}, >+ {"type":"Numeric","range":[50,51],"value":"2"}, >+ {"type":"Punctuator","range":[51,52],"value":"}"}, >+ {"type":"Punctuator","range":[52,53],"value":";"}, >+ {"type":"Punctuator","range":[53,54],"value":"}"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":14,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":42,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":47,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - mixed 6': { >+ source: 'var v = {a b:1 d c:2};function f() {return {a b:1 d c:2};}', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,22]}, >+ {"type":"VariableDeclarator","range":[7,21]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[15,21]}, >+ {"type":"Property","kind":"init","range":[12,14]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"Literal","range":[13,14],"value":1}, >+ {"type":"Property","kind":"init","range":[18,20]}, >+ {"type":"Identifier","name":"c","range":[18,18]}, >+ {"type":"Literal","range":[19,20],"value":2}, >+ {"type":"FunctionDeclaration","range":[36,58]}, >+ {"type":"Identifier","name":"f","range":[31,32]}, >+ {"type":"BlockStatement","range":[42,58]}, >+ {"type":"ReturnStatement","range":[42,57]}, >+ {"type":"ObjectExpression","range":[50,56]}, >+ {"type":"Property","kind":"init","range":[47,49]}, >+ {"type":"Identifier","name":"b","range":[47,47]}, >+ {"type":"Literal","range":[48,49],"value":1}, >+ {"type":"Property","kind":"init","range":[53,55]}, >+ {"type":"Identifier","name":"c","range":[53,53]}, >+ {"type":"Literal","range":[54,55],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Numeric","range":[13,14],"value":"1"}, >+ {"type":"Identifier","range":[15,16],"value":"d"}, >+ {"type":"Identifier","range":[17,18],"value":"c"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[19,20],"value":"2"}, >+ {"type":"Punctuator","range":[20,21],"value":"}"}, >+ {"type":"Punctuator","range":[21,22],"value":";"}, >+ {"type":"Keyword","range":[22,30],"value":"function"}, >+ {"type":"Identifier","range":[31,32],"value":"f"}, >+ {"type":"Punctuator","range":[32,33],"value":"("}, >+ {"type":"Punctuator","range":[33,34],"value":")"}, >+ {"type":"Punctuator","range":[35,36],"value":"{"}, >+ {"type":"Keyword","range":[36,42],"value":"return"}, >+ {"type":"Punctuator","range":[43,44],"value":"{"}, >+ {"type":"Identifier","range":[44,45],"value":"a"}, >+ {"type":"Identifier","range":[46,47],"value":"b"}, >+ {"type":"Punctuator","range":[47,48],"value":":"}, >+ {"type":"Numeric","range":[48,49],"value":"1"}, >+ {"type":"Identifier","range":[50,51],"value":"d"}, >+ {"type":"Identifier","range":[52,53],"value":"c"}, >+ {"type":"Punctuator","range":[53,54],"value":":"}, >+ {"type":"Numeric","range":[54,55],"value":"2"}, >+ {"type":"Punctuator","range":[55,56],"value":"}"}, >+ {"type":"Punctuator","range":[56,57],"value":";"}, >+ {"type":"Punctuator","range":[57,58],"value":"}"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":14,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":15,"message":"Unexpected token d","token":"d"}, >+ {"lineNumber":1,"index":44,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":49,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":50,"message":"Unexpected token d","token":"d"}] >+ }, >+ >+ 'obj prop recovery - mixed 7': { >+ source: 'var v = {a b:1 c:2};function f() {return {a b:1 c:2};}f({a b:1 c:2});', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[4,20]}, >+ {"type":"VariableDeclarator","range":[7,19]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[9,19]}, >+ {"type":"Property","kind":"init","range":[12,14]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"Literal","range":[13,14],"value":1}, >+ {"type":"Property","kind":"init","range":[15,18]}, >+ {"type":"Identifier","name":"c","range":[15,16]}, >+ {"type":"Literal","range":[17,18],"value":2}, >+ {"type":"FunctionDeclaration","range":[33,54]}, >+ {"type":"Identifier","name":"f","range":[29,30]}, >+ {"type":"BlockStatement","range":[34,54]}, >+ {"type":"ReturnStatement","range":[40,53]}, >+ {"type":"ObjectExpression","range":[42,52]}, >+ {"type":"Property","kind":"init","range":[45,47]}, >+ {"type":"Identifier","name":"b","range":[45,45]}, >+ {"type":"Literal","range":[46,47],"value":1}, >+ {"type":"Property","kind":"init","range":[48,51]}, >+ {"type":"Identifier","name":"c","range":[48,49]}, >+ {"type":"Literal","range":[50,51],"value":2}, >+ {"type":"ExpressionStatement","range":[54,69]}, >+ {"type":"CallExpression","range":[54,68]}, >+ {"type":"Identifier","name":"f","range":[54,55]}, >+ {"type":"ObjectExpression","range":[57,67]}, >+ {"type":"Property","kind":"init","range":[60,62]}, >+ {"type":"Identifier","name":"b","range":[60,60]}, >+ {"type":"Literal","range":[61,62],"value":1}, >+ {"type":"Property","kind":"init","range":[63,66]}, >+ {"type":"Identifier","name":"c","range":[63,64]}, >+ {"type":"Literal","range":[65,66],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Numeric","range":[13,14],"value":"1"}, >+ {"type":"Identifier","range":[15,16],"value":"c"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[17,18],"value":"2"}, >+ {"type":"Punctuator","range":[18,19],"value":"}"}, >+ {"type":"Punctuator","range":[19,20],"value":";"}, >+ {"type":"Keyword","range":[20,28],"value":"function"}, >+ {"type":"Identifier","range":[29,30],"value":"f"}, >+ {"type":"Punctuator","range":[30,31],"value":"("}, >+ {"type":"Punctuator","range":[31,32],"value":")"}, >+ {"type":"Punctuator","range":[33,34],"value":"{"}, >+ {"type":"Keyword","range":[34,40],"value":"return"}, >+ {"type":"Punctuator","range":[41,42],"value":"{"}, >+ {"type":"Identifier","range":[42,43],"value":"a"}, >+ {"type":"Identifier","range":[44,45],"value":"b"}, >+ {"type":"Punctuator","range":[45,46],"value":":"}, >+ {"type":"Numeric","range":[46,47],"value":"1"}, >+ {"type":"Identifier","range":[48,49],"value":"c"}, >+ {"type":"Punctuator","range":[49,50],"value":":"}, >+ {"type":"Numeric","range":[50,51],"value":"2"}, >+ {"type":"Punctuator","range":[51,52],"value":"}"}, >+ {"type":"Punctuator","range":[52,53],"value":";"}, >+ {"type":"Punctuator","range":[53,54],"value":"}"}, >+ {"type":"Identifier","range":[54,55],"value":"f"}, >+ {"type":"Punctuator","range":[55,56],"value":"("}, >+ {"type":"Punctuator","range":[56,57],"value":"{"}, >+ {"type":"Identifier","range":[57,58],"value":"a"}, >+ {"type":"Identifier","range":[59,60],"value":"b"}, >+ {"type":"Punctuator","range":[60,61],"value":":"}, >+ {"type":"Numeric","range":[61,62],"value":"1"}, >+ {"type":"Identifier","range":[63,64],"value":"c"}, >+ {"type":"Punctuator","range":[64,65],"value":":"}, >+ {"type":"Numeric","range":[65,66],"value":"2"}, >+ {"type":"Punctuator","range":[66,67],"value":"}"}, >+ {"type":"Punctuator","range":[67,68],"value":")"}, >+ {"type":"Punctuator","range":[68,69],"value":";"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":14,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":42,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":47,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":57,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":62,"message":"Missing expected ','"}] >+ }, >+ >+ 'obj prop recovery - mixed 8': { >+ source: 'var v = {a b:1 d c:2};function f() {return {a b:1 d c:2};}f({a b:1 d c:2});', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,22]}, >+ {"type":"VariableDeclarator","range":[7,21]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[15,21]}, >+ {"type":"Property","kind":"init","range":[12,14]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"Literal","range":[13,14],"value":1}, >+ {"type":"Property","kind":"init","range":[18,20]}, >+ {"type":"Identifier","name":"c","range":[18,18]}, >+ {"type":"Literal","range":[19,20],"value":2}, >+ {"type":"FunctionDeclaration","range":[36,58]}, >+ {"type":"Identifier","name":"f","range":[31,32]}, >+ {"type":"BlockStatement","range":[42,58]}, >+ {"type":"ReturnStatement","range":[42,57]}, >+ {"type":"ObjectExpression","range":[50,56]}, >+ {"type":"Property","kind":"init","range":[47,49]}, >+ {"type":"Identifier","name":"b","range":[47,47]}, >+ {"type":"Literal","range":[48,49],"value":1}, >+ {"type":"Property","kind":"init","range":[53,55]}, >+ {"type":"Identifier","name":"c","range":[53,53]}, >+ {"type":"Literal","range":[54,55],"value":2}, >+ {"type":"ExpressionStatement","range":[58,75]}, >+ {"type":"CallExpression","range":[58,74]}, >+ {"type":"Identifier","name":"f","range":[58,59]}, >+ {"type":"ObjectExpression","range":[67,73]}, >+ {"type":"Property","kind":"init","range":[64,66]}, >+ {"type":"Identifier","name":"b","range":[64,64]}, >+ {"type":"Literal","range":[65,66],"value":1}, >+ {"type":"Property","kind":"init","range":[70,72]}, >+ {"type":"Identifier","name":"c","range":[70,70]}, >+ {"type":"Literal","range":[71,72],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Numeric","range":[13,14],"value":"1"}, >+ {"type":"Identifier","range":[15,16],"value":"d"}, >+ {"type":"Identifier","range":[17,18],"value":"c"}, >+ {"type":"Punctuator","range":[18,19],"value":":"}, >+ {"type":"Numeric","range":[19,20],"value":"2"}, >+ {"type":"Punctuator","range":[20,21],"value":"}"}, >+ {"type":"Punctuator","range":[21,22],"value":";"}, >+ {"type":"Keyword","range":[22,30],"value":"function"}, >+ {"type":"Identifier","range":[31,32],"value":"f"}, >+ {"type":"Punctuator","range":[32,33],"value":"("}, >+ {"type":"Punctuator","range":[33,34],"value":")"}, >+ {"type":"Punctuator","range":[35,36],"value":"{"}, >+ {"type":"Keyword","range":[36,42],"value":"return"}, >+ {"type":"Punctuator","range":[43,44],"value":"{"}, >+ {"type":"Identifier","range":[44,45],"value":"a"}, >+ {"type":"Identifier","range":[46,47],"value":"b"}, >+ {"type":"Punctuator","range":[47,48],"value":":"}, >+ {"type":"Numeric","range":[48,49],"value":"1"}, >+ {"type":"Identifier","range":[50,51],"value":"d"}, >+ {"type":"Identifier","range":[52,53],"value":"c"}, >+ {"type":"Punctuator","range":[53,54],"value":":"}, >+ {"type":"Numeric","range":[54,55],"value":"2"}, >+ {"type":"Punctuator","range":[55,56],"value":"}"}, >+ {"type":"Punctuator","range":[56,57],"value":";"}, >+ {"type":"Punctuator","range":[57,58],"value":"}"}, >+ {"type":"Identifier","range":[58,59],"value":"f"}, >+ {"type":"Punctuator","range":[59,60],"value":"("}, >+ {"type":"Punctuator","range":[60,61],"value":"{"}, >+ {"type":"Identifier","range":[61,62],"value":"a"}, >+ {"type":"Identifier","range":[63,64],"value":"b"}, >+ {"type":"Punctuator","range":[64,65],"value":":"}, >+ {"type":"Numeric","range":[65,66],"value":"1"}, >+ {"type":"Identifier","range":[67,68],"value":"d"}, >+ {"type":"Identifier","range":[69,70],"value":"c"}, >+ {"type":"Punctuator","range":[70,71],"value":":"}, >+ {"type":"Numeric","range":[71,72],"value":"2"}, >+ {"type":"Punctuator","range":[72,73],"value":"}"}, >+ {"type":"Punctuator","range":[73,74],"value":")"}, >+ {"type":"Punctuator","range":[74,75],"value":";"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":14,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":15,"message":"Unexpected token d","token":"d"}, >+ {"lineNumber":1,"index":44,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":49,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":50,"message":"Unexpected token d","token":"d"}, >+ {"lineNumber":1,"index":61,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":66,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":67,"message":"Unexpected token d","token":"d"}] >+ }, >+ >+ 'obj prop recovery - mixed 9': { >+ source: 'var v = {a b:{cc:3, dd:\'hey\' e} c:2};function f() {return {a b:{cc:3, dd:\'hey\' e} c:2};}f({a b:{cc:3, dd:\'hey\' e} c:2});', >+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[7,37]}, >+ {"type":"VariableDeclarator","range":[7,36]}, >+ {"type":"Identifier","name":"v","range":[4,5]}, >+ {"type":"ObjectExpression","range":[12,36]}, >+ {"type":"Property","kind":"init","range":[13,31]}, >+ {"type":"Identifier","name":"b","range":[12,12]}, >+ {"type":"ObjectExpression","range":[29,31]}, >+ {"type":"Property","kind":"init","range":[14,18]}, >+ {"type":"Identifier","name":"cc","range":[14,16]}, >+ {"type":"Literal","range":[17,18],"value":3}, >+ {"type":"Property","kind":"init","range":[20,28]}, >+ {"type":"Identifier","name":"dd","range":[20,22]}, >+ {"type":"Literal","range":[23,28],"value":"hey"}, >+ {"type":"Property","kind":"init","range":[32,35]}, >+ {"type":"Identifier","name":"c","range":[32,33]}, >+ {"type":"Literal","range":[34,35],"value":2}, >+ {"type":"FunctionDeclaration","range":[51,88]}, >+ {"type":"Identifier","name":"f","range":[46,47]}, >+ {"type":"BlockStatement","range":[57,88]}, >+ {"type":"ReturnStatement","range":[57,87]}, >+ {"type":"ObjectExpression","range":[62,86]}, >+ {"type":"Property","kind":"init","range":[63,81]}, >+ {"type":"Identifier","name":"b","range":[62,62]}, >+ {"type":"ObjectExpression","range":[79,81]}, >+ {"type":"Property","kind":"init","range":[64,68]}, >+ {"type":"Identifier","name":"cc","range":[64,66]}, >+ {"type":"Literal","range":[67,68],"value":3}, >+ {"type":"Property","kind":"init","range":[70,78]}, >+ {"type":"Identifier","name":"dd","range":[70,72]}, >+ {"type":"Literal","range":[73,78],"value":"hey"}, >+ {"type":"Property","kind":"init","range":[82,85]}, >+ {"type":"Identifier","name":"c","range":[82,83]}, >+ {"type":"Literal","range":[84,85],"value":2}, >+ {"type":"ExpressionStatement","range":[88,120]}, >+ {"type":"CallExpression","range":[88,119]}, >+ {"type":"Identifier","name":"f","range":[88,89]}, >+ {"type":"ObjectExpression","range":[94,118]}, >+ {"type":"Property","kind":"init","range":[95,113]}, >+ {"type":"Identifier","name":"b","range":[94,94]}, >+ {"type":"ObjectExpression","range":[111,113]}, >+ {"type":"Property","kind":"init","range":[96,100]}, >+ {"type":"Identifier","name":"cc","range":[96,98]}, >+ {"type":"Literal","range":[99,100],"value":3}, >+ {"type":"Property","kind":"init","range":[102,110]}, >+ {"type":"Identifier","name":"dd","range":[102,104]}, >+ {"type":"Literal","range":[105,110],"value":"hey"}, >+ {"type":"Property","kind":"init","range":[114,117]}, >+ {"type":"Identifier","name":"c","range":[114,115]}, >+ {"type":"Literal","range":[116,117],"value":2}], >+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"}, >+ {"type":"Identifier","range":[4,5],"value":"v"}, >+ {"type":"Punctuator","range":[6,7],"value":"="}, >+ {"type":"Punctuator","range":[8,9],"value":"{"}, >+ {"type":"Identifier","range":[9,10],"value":"a"}, >+ {"type":"Identifier","range":[11,12],"value":"b"}, >+ {"type":"Punctuator","range":[12,13],"value":":"}, >+ {"type":"Punctuator","range":[13,14],"value":"{"}, >+ {"type":"Identifier","range":[14,16],"value":"cc"}, >+ {"type":"Punctuator","range":[16,17],"value":":"}, >+ {"type":"Numeric","range":[17,18],"value":"3"}, >+ {"type":"Punctuator","range":[18,19],"value":","}, >+ {"type":"Identifier","range":[20,22],"value":"dd"}, >+ {"type":"Punctuator","range":[22,23],"value":":"}, >+ {"type":"String","range":[23,28],"value":"'hey'"}, >+ {"type":"Identifier","range":[29,30],"value":"e"}, >+ {"type":"Punctuator","range":[30,31],"value":"}"}, >+ {"type":"Identifier","range":[32,33],"value":"c"}, >+ {"type":"Punctuator","range":[33,34],"value":":"}, >+ {"type":"Numeric","range":[34,35],"value":"2"}, >+ {"type":"Punctuator","range":[35,36],"value":"}"}, >+ {"type":"Punctuator","range":[36,37],"value":";"}, >+ {"type":"Keyword","range":[37,45],"value":"function"}, >+ {"type":"Identifier","range":[46,47],"value":"f"}, >+ {"type":"Punctuator","range":[47,48],"value":"("}, >+ {"type":"Punctuator","range":[48,49],"value":")"}, >+ {"type":"Punctuator","range":[50,51],"value":"{"}, >+ {"type":"Keyword","range":[51,57],"value":"return"}, >+ {"type":"Punctuator","range":[58,59],"value":"{"}, >+ {"type":"Identifier","range":[59,60],"value":"a"}, >+ {"type":"Identifier","range":[61,62],"value":"b"}, >+ {"type":"Punctuator","range":[62,63],"value":":"}, >+ {"type":"Punctuator","range":[63,64],"value":"{"}, >+ {"type":"Identifier","range":[64,66],"value":"cc"}, >+ {"type":"Punctuator","range":[66,67],"value":":"}, >+ {"type":"Numeric","range":[67,68],"value":"3"}, >+ {"type":"Punctuator","range":[68,69],"value":","}, >+ {"type":"Identifier","range":[70,72],"value":"dd"}, >+ {"type":"Punctuator","range":[72,73],"value":":"}, >+ {"type":"String","range":[73,78],"value":"'hey'"}, >+ {"type":"Identifier","range":[79,80],"value":"e"}, >+ {"type":"Punctuator","range":[80,81],"value":"}"}, >+ {"type":"Identifier","range":[82,83],"value":"c"}, >+ {"type":"Punctuator","range":[83,84],"value":":"}, >+ {"type":"Numeric","range":[84,85],"value":"2"}, >+ {"type":"Punctuator","range":[85,86],"value":"}"}, >+ {"type":"Punctuator","range":[86,87],"value":";"}, >+ {"type":"Punctuator","range":[87,88],"value":"}"}, >+ {"type":"Identifier","range":[88,89],"value":"f"}, >+ {"type":"Punctuator","range":[89,90],"value":"("}, >+ {"type":"Punctuator","range":[90,91],"value":"{"}, >+ {"type":"Identifier","range":[91,92],"value":"a"}, >+ {"type":"Identifier","range":[93,94],"value":"b"}, >+ {"type":"Punctuator","range":[94,95],"value":":"}, >+ {"type":"Punctuator","range":[95,96],"value":"{"}, >+ {"type":"Identifier","range":[96,98],"value":"cc"}, >+ {"type":"Punctuator","range":[98,99],"value":":"}, >+ {"type":"Numeric","range":[99,100],"value":"3"}, >+ {"type":"Punctuator","range":[100,101],"value":","}, >+ {"type":"Identifier","range":[102,104],"value":"dd"}, >+ {"type":"Punctuator","range":[104,105],"value":":"}, >+ {"type":"String","range":[105,110],"value":"'hey'"}, >+ {"type":"Identifier","range":[111,112],"value":"e"}, >+ {"type":"Punctuator","range":[112,113],"value":"}"}, >+ {"type":"Identifier","range":[114,115],"value":"c"}, >+ {"type":"Punctuator","range":[115,116],"value":":"}, >+ {"type":"Numeric","range":[116,117],"value":"2"}, >+ {"type":"Punctuator","range":[117,118],"value":"}"}, >+ {"type":"Punctuator","range":[118,119],"value":")"}, >+ {"type":"Punctuator","range":[119,120],"value":";"}], >+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":28,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":29,"message":"Unexpected token e","token":"e"}, >+ {"lineNumber":1,"index":31,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":59,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":78,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":79,"message":"Unexpected token e","token":"e"}, >+ {"lineNumber":1,"index":81,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":91,"message":"Unexpected token a","token":"a"}, >+ {"lineNumber":1,"index":110,"message":"Missing expected ','"}, >+ {"lineNumber":1,"index":111,"message":"Unexpected token e","token":"e"}, >+ {"lineNumber":1,"index":113,"message":"Missing expected ','"}] >+ }, > }; > Object.keys(testData).forEach(function(name) { > tests["test " + name] = runTest.bind(tests, name, testData[name]); >diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js >index 5fa8be0..2dac2cd 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js >@@ -400,7 +400,7 @@ > var text = "var function f1() {"; > return astManager.getAST(setUp(text)).then(function(ast) { > try { >- var token = Finder.findToken(18, ast.tokens); >+ var token = Finder.findToken(7, ast.tokens); > if(!token) { > assert.fail("Should have found a token"); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 432956
: 242300