decaffeinate-parser
Advanced tools
Comparing version 1.2.2 to 1.2.3
import * as CoffeeScript from 'coffee-script'; | ||
import binarySearch from 'binary-search'; | ||
import lex, { HERECOMMENT, COMMENT, NEWLINE } from 'coffee-lex'; | ||
import { inspect } from 'util'; | ||
import binarySearch from 'binary-search'; | ||
@@ -188,3 +188,2 @@ var babelHelpers = {}; | ||
babelHelpers.createClass(ParseContext, [{ | ||
@@ -294,3 +293,3 @@ key: 'getRange', | ||
var startToken = this.tokenAtIndex(index); | ||
var expectedEndTokenType = void 0; | ||
var expectedEndTokenType = undefined; | ||
switch (startToken.type) { | ||
@@ -561,3 +560,3 @@ case 'PARAM_START': | ||
while (p < string.length - quote.length) { | ||
var chr = void 0; | ||
var chr = undefined; | ||
switch (chr = string[p++]) { | ||
@@ -789,5 +788,5 @@ case '\\': | ||
last = lastBalancedIndex; | ||
var _lastLoc = mapper.invert(last); | ||
loc.last_line = _lastLoc.line; | ||
loc.last_column = _lastLoc.column; | ||
var lastLoc = mapper.invert(last); | ||
loc.last_line = lastLoc.line; | ||
loc.last_column = lastLoc.column; | ||
} | ||
@@ -867,6 +866,6 @@ } | ||
function mergeLocations(left, right) { | ||
var first_line = void 0; | ||
var first_column = void 0; | ||
var last_line = void 0; | ||
var last_column = void 0; | ||
var first_line = undefined; | ||
var first_column = undefined; | ||
var last_line = undefined; | ||
var last_column = undefined; | ||
@@ -961,4 +960,4 @@ if (left.first_line < right.first_line) { | ||
if (isImplicitObject) { | ||
var _lastChild = node.properties[node.properties.length - 1]; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild.locationData); | ||
var lastChild = node.properties[node.properties.length - 1]; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -970,5 +969,5 @@ break; | ||
{ | ||
var _lastChild2 = node.second; | ||
if (_lastChild2) { | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild2.locationData); | ||
var lastChild = node.second; | ||
if (lastChild) { | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -980,4 +979,4 @@ break; | ||
{ | ||
var _lastChild3 = node.value; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild3.locationData); | ||
var lastChild = node.value; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -988,4 +987,4 @@ } | ||
{ | ||
var _lastChild4 = node.array; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild4.locationData); | ||
var lastChild = node.array; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1006,5 +1005,5 @@ } | ||
if (isImplicitCall) { | ||
var _lastChild5 = node.args[node.args.length - 1] || node.variable; | ||
if (_lastChild5) { | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild5.locationData); | ||
var lastChild = node.args[node.args.length - 1] || node.variable; | ||
if (lastChild) { | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -1018,5 +1017,5 @@ } | ||
{ | ||
var _lastChild6 = node.expressions[node.expressions.length - 1]; | ||
if (_lastChild6) { | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild6.locationData); | ||
var lastChild = node.expressions[node.expressions.length - 1]; | ||
if (lastChild) { | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -1028,4 +1027,4 @@ break; | ||
{ | ||
var _lastChild7 = node.elseBody || node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild7.locationData); | ||
var lastChild = node.elseBody || node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1037,4 +1036,4 @@ } | ||
{ | ||
var _lastChild8 = node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild8.locationData); | ||
var lastChild = node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1046,4 +1045,4 @@ } | ||
if (!node.splat) { | ||
var _lastChild9 = node.value || node.name; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild9.locationData); | ||
var lastChild = node.value || node.name; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -1063,4 +1062,4 @@ break; | ||
{ | ||
var _lastChild10 = node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild10.locationData); | ||
var lastChild = node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1071,4 +1070,4 @@ } | ||
{ | ||
var _lastChild11 = node.otherwise || node.cases[node.cases.length - 1][1]; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild11.locationData); | ||
var lastChild = node.otherwise || node.cases[node.cases.length - 1][1]; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1079,4 +1078,4 @@ } | ||
{ | ||
var _lastChild12 = node.ensure || node.recovery || node.errorVariable || node.attempt; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild12.locationData); | ||
var lastChild = node.ensure || node.recovery || node.errorVariable || node.attempt; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1087,4 +1086,4 @@ } | ||
{ | ||
var _lastChild13 = node.parent; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild13.locationData); | ||
var lastChild = node.parent; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1379,4 +1378,4 @@ } | ||
block.inline = false; | ||
for (var _i = block.range[0] - 1; _i >= 0; _i--) { | ||
var char = source[_i]; | ||
for (var i = block.range[0] - 1; i >= 0; i--) { | ||
var char = source[i]; | ||
if (char === '\n') { | ||
@@ -1462,4 +1461,4 @@ break; | ||
expr.base.properties.forEach(function (property) { | ||
var key = void 0; | ||
var value = void 0; | ||
var key = undefined; | ||
var value = undefined; | ||
switch (type(property)) { | ||
@@ -1603,7 +1602,7 @@ case 'Value': | ||
if (loc) { | ||
var _start = mapper(loc.first_line, loc.first_column); | ||
var _end = mapper(loc.last_line, loc.last_column) + 1; | ||
var start = mapper(loc.first_line, loc.first_column); | ||
var end = mapper(loc.last_line, loc.last_column) + 1; | ||
result.line = loc.first_line + 1; | ||
result.column = loc.first_column + 1; | ||
result.range = [_start, _end]; | ||
result.range = [start, end]; | ||
} else { | ||
@@ -1614,6 +1613,6 @@ result.virtual = true; | ||
if (attrs.hasOwnProperty(key)) { | ||
var _value = attrs[key]; | ||
result[key] = _value; | ||
if (_value && result.range) { | ||
(Array.isArray(_value) ? _value : [_value]).forEach(function (node) { | ||
var value = attrs[key]; | ||
result[key] = value; | ||
if (value && result.range) { | ||
(Array.isArray(value) ? value : [value]).forEach(function (node) { | ||
if (node.range) { | ||
@@ -1907,3 +1906,3 @@ // Expand the range to contain all the children. | ||
function convertOperator(op) { | ||
var nodeType = void 0; | ||
var nodeType = undefined; | ||
@@ -1917,10 +1916,10 @@ if (op.second) { | ||
var _result2 = makeNode(nodeType, op.locationData, { | ||
var result = makeNode(nodeType, op.locationData, { | ||
left: convertNode(op.first, [].concat(babelHelpers.toConsumableArray(ancestors), [op])), | ||
right: convertNode(op.second, [].concat(babelHelpers.toConsumableArray(ancestors), [op])) | ||
}); | ||
if (_result2.type === 'InstanceofOp' || _result2.type === 'OfOp') { | ||
_result2.isNot = op.inverted === true; | ||
if (result.type === 'InstanceofOp' || result.type === 'OfOp') { | ||
result.isNot = op.inverted === true; | ||
} | ||
return _result2; | ||
return result; | ||
} else { | ||
@@ -1927,0 +1926,0 @@ switch (op.operator) { |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('coffee-script'), require('binary-search'), require('coffee-lex'), require('util')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'coffee-script', 'binary-search', 'coffee-lex', 'util'], factory) : | ||
(factory((global.decaffeinate = global.decaffeinate || {}, global.decaffeinate.parser = global.decaffeinate.parser || {}),global.CoffeeScript,global.binarySearch,global.lex,global.util)); | ||
}(this, function (exports,CoffeeScript,binarySearch,lex,util) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('coffee-script'), require('coffee-lex'), require('util'), require('binary-search')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'coffee-script', 'coffee-lex', 'util', 'binary-search'], factory) : | ||
(factory((global.decaffeinate = global.decaffeinate || {}, global.decaffeinate.parser = {}),global.CoffeeScript,global.lex,global.util,global.binarySearch)); | ||
}(this, function (exports,CoffeeScript,lex,util,binarySearch) { 'use strict'; | ||
var lex__default = 'default' in lex ? lex['default'] : lex; | ||
binarySearch = 'default' in binarySearch ? binarySearch['default'] : binarySearch; | ||
var lex__default = 'default' in lex ? lex['default'] : lex; | ||
@@ -192,3 +192,2 @@ var babelHelpers = {}; | ||
babelHelpers.createClass(ParseContext, [{ | ||
@@ -298,3 +297,3 @@ key: 'getRange', | ||
var startToken = this.tokenAtIndex(index); | ||
var expectedEndTokenType = void 0; | ||
var expectedEndTokenType = undefined; | ||
switch (startToken.type) { | ||
@@ -565,3 +564,3 @@ case 'PARAM_START': | ||
while (p < string.length - quote.length) { | ||
var chr = void 0; | ||
var chr = undefined; | ||
switch (chr = string[p++]) { | ||
@@ -793,5 +792,5 @@ case '\\': | ||
last = lastBalancedIndex; | ||
var _lastLoc = mapper.invert(last); | ||
loc.last_line = _lastLoc.line; | ||
loc.last_column = _lastLoc.column; | ||
var lastLoc = mapper.invert(last); | ||
loc.last_line = lastLoc.line; | ||
loc.last_column = lastLoc.column; | ||
} | ||
@@ -871,6 +870,6 @@ } | ||
function mergeLocations(left, right) { | ||
var first_line = void 0; | ||
var first_column = void 0; | ||
var last_line = void 0; | ||
var last_column = void 0; | ||
var first_line = undefined; | ||
var first_column = undefined; | ||
var last_line = undefined; | ||
var last_column = undefined; | ||
@@ -965,4 +964,4 @@ if (left.first_line < right.first_line) { | ||
if (isImplicitObject) { | ||
var _lastChild = node.properties[node.properties.length - 1]; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild.locationData); | ||
var lastChild = node.properties[node.properties.length - 1]; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -974,5 +973,5 @@ break; | ||
{ | ||
var _lastChild2 = node.second; | ||
if (_lastChild2) { | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild2.locationData); | ||
var lastChild = node.second; | ||
if (lastChild) { | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -984,4 +983,4 @@ break; | ||
{ | ||
var _lastChild3 = node.value; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild3.locationData); | ||
var lastChild = node.value; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -992,4 +991,4 @@ } | ||
{ | ||
var _lastChild4 = node.array; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild4.locationData); | ||
var lastChild = node.array; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1010,5 +1009,5 @@ } | ||
if (isImplicitCall) { | ||
var _lastChild5 = node.args[node.args.length - 1] || node.variable; | ||
if (_lastChild5) { | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild5.locationData); | ||
var lastChild = node.args[node.args.length - 1] || node.variable; | ||
if (lastChild) { | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -1022,5 +1021,5 @@ } | ||
{ | ||
var _lastChild6 = node.expressions[node.expressions.length - 1]; | ||
if (_lastChild6) { | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild6.locationData); | ||
var lastChild = node.expressions[node.expressions.length - 1]; | ||
if (lastChild) { | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -1032,4 +1031,4 @@ break; | ||
{ | ||
var _lastChild7 = node.elseBody || node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild7.locationData); | ||
var lastChild = node.elseBody || node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1041,4 +1040,4 @@ } | ||
{ | ||
var _lastChild8 = node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild8.locationData); | ||
var lastChild = node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1050,4 +1049,4 @@ } | ||
if (!node.splat) { | ||
var _lastChild9 = node.value || node.name; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild9.locationData); | ||
var lastChild = node.value || node.name; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
} | ||
@@ -1067,4 +1066,4 @@ break; | ||
{ | ||
var _lastChild10 = node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild10.locationData); | ||
var lastChild = node.body; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1075,4 +1074,4 @@ } | ||
{ | ||
var _lastChild11 = node.otherwise || node.cases[node.cases.length - 1][1]; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild11.locationData); | ||
var lastChild = node.otherwise || node.cases[node.cases.length - 1][1]; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1083,4 +1082,4 @@ } | ||
{ | ||
var _lastChild12 = node.ensure || node.recovery || node.errorVariable || node.attempt; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild12.locationData); | ||
var lastChild = node.ensure || node.recovery || node.errorVariable || node.attempt; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1091,4 +1090,4 @@ } | ||
{ | ||
var _lastChild13 = node.parent; | ||
node.locationData = locationWithLastPosition(node.locationData, _lastChild13.locationData); | ||
var lastChild = node.parent; | ||
node.locationData = locationWithLastPosition(node.locationData, lastChild.locationData); | ||
break; | ||
@@ -1383,4 +1382,4 @@ } | ||
block.inline = false; | ||
for (var _i = block.range[0] - 1; _i >= 0; _i--) { | ||
var char = source[_i]; | ||
for (var i = block.range[0] - 1; i >= 0; i--) { | ||
var char = source[i]; | ||
if (char === '\n') { | ||
@@ -1466,4 +1465,4 @@ break; | ||
expr.base.properties.forEach(function (property) { | ||
var key = void 0; | ||
var value = void 0; | ||
var key = undefined; | ||
var value = undefined; | ||
switch (type(property)) { | ||
@@ -1607,7 +1606,7 @@ case 'Value': | ||
if (loc) { | ||
var _start = mapper(loc.first_line, loc.first_column); | ||
var _end = mapper(loc.last_line, loc.last_column) + 1; | ||
var start = mapper(loc.first_line, loc.first_column); | ||
var end = mapper(loc.last_line, loc.last_column) + 1; | ||
result.line = loc.first_line + 1; | ||
result.column = loc.first_column + 1; | ||
result.range = [_start, _end]; | ||
result.range = [start, end]; | ||
} else { | ||
@@ -1618,6 +1617,6 @@ result.virtual = true; | ||
if (attrs.hasOwnProperty(key)) { | ||
var _value = attrs[key]; | ||
result[key] = _value; | ||
if (_value && result.range) { | ||
(Array.isArray(_value) ? _value : [_value]).forEach(function (node) { | ||
var value = attrs[key]; | ||
result[key] = value; | ||
if (value && result.range) { | ||
(Array.isArray(value) ? value : [value]).forEach(function (node) { | ||
if (node.range) { | ||
@@ -1911,3 +1910,3 @@ // Expand the range to contain all the children. | ||
function convertOperator(op) { | ||
var nodeType = void 0; | ||
var nodeType = undefined; | ||
@@ -1921,10 +1920,10 @@ if (op.second) { | ||
var _result2 = makeNode(nodeType, op.locationData, { | ||
var result = makeNode(nodeType, op.locationData, { | ||
left: convertNode(op.first, [].concat(babelHelpers.toConsumableArray(ancestors), [op])), | ||
right: convertNode(op.second, [].concat(babelHelpers.toConsumableArray(ancestors), [op])) | ||
}); | ||
if (_result2.type === 'InstanceofOp' || _result2.type === 'OfOp') { | ||
_result2.isNot = op.inverted === true; | ||
if (result.type === 'InstanceofOp' || result.type === 'OfOp') { | ||
result.isNot = op.inverted === true; | ||
} | ||
return _result2; | ||
return result; | ||
} else { | ||
@@ -1931,0 +1930,0 @@ switch (op.operator) { |
{ | ||
"name": "decaffeinate-parser", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "A better AST for CoffeeScript, inspired by CoffeeScriptRedux.", | ||
@@ -24,3 +24,3 @@ "main": "dist/decaffeinate-parser.umd.js", | ||
"binary-search": "^1.2.0", | ||
"coffee-lex": "^1.2.1", | ||
"coffee-lex": "^1.3.1", | ||
"coffee-script": "^1.10.0" | ||
@@ -27,0 +27,0 @@ }, |
125114
Updatedcoffee-lex@^1.3.1