36 lines
2.2 KiB
JavaScript
36 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
exports.__esModule = true;
|
|
exports.default = liner;
|
|
function liner(tokens) {
|
|
var line = [];
|
|
var result = [line];
|
|
var brackets = 0;
|
|
for (var _iterator = tokens, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
|
var _ref;
|
|
|
|
if (_isArray) {
|
|
if (_i >= _iterator.length) break;
|
|
_ref = _iterator[_i++];
|
|
} else {
|
|
_i = _iterator.next();
|
|
if (_i.done) break;
|
|
_ref = _i.value;
|
|
}
|
|
|
|
var token = _ref;
|
|
|
|
line.push(token);
|
|
if (token[0] === '(') {
|
|
brackets += 1;
|
|
} else if (token[0] === ')') {
|
|
brackets -= 1;
|
|
} else if (token[0] === 'newline' && brackets === 0) {
|
|
line = [];
|
|
result.push(line);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
module.exports = exports['default'];
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxpbmVyLmVzNiJdLCJuYW1lcyI6WyJsaW5lciIsInRva2VucyIsImxpbmUiLCJyZXN1bHQiLCJicmFja2V0cyIsInRva2VuIiwicHVzaCJdLCJtYXBwaW5ncyI6Ijs7O2tCQUF3QkEsSztBQUFULFNBQVNBLEtBQVQsQ0FBZ0JDLE1BQWhCLEVBQXdCO0FBQ3JDLE1BQUlDLE9BQU8sRUFBWDtBQUNBLE1BQUlDLFNBQVMsQ0FBQ0QsSUFBRCxDQUFiO0FBQ0EsTUFBSUUsV0FBVyxDQUFmO0FBQ0EsdUJBQWtCSCxNQUFsQixrSEFBMEI7QUFBQTs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBOztBQUFBLFFBQWpCSSxLQUFpQjs7QUFDeEJILFNBQUtJLElBQUwsQ0FBVUQsS0FBVjtBQUNBLFFBQUlBLE1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