xlsxp
Version:
An Excel formula parser in javascript/typescript
1,349 lines (1,339 loc) • 551 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
exports.Kind = void 0;
(function (Kind) {
Kind[Kind["INFIX"] = 0] = "INFIX";
Kind[Kind["PREFIX"] = 1] = "PREFIX";
Kind[Kind["POSTFIX"] = 2] = "POSTFIX";
Kind[Kind["VALUE"] = 3] = "VALUE";
Kind[Kind["LIST"] = 4] = "LIST";
Kind[Kind["NAME"] = 5] = "NAME";
Kind[Kind["FCALL"] = 6] = "FCALL";
Kind[Kind["MISSING"] = 7] = "MISSING";
Kind[Kind["SINGLE_SHEET"] = 8] = "SINGLE_SHEET";
Kind[Kind["SHEET_RANGE"] = 9] = "SHEET_RANGE";
Kind[Kind["COLUMN_RANGE"] = 10] = "COLUMN_RANGE";
Kind[Kind["ROW_RANGE"] = 11] = "ROW_RANGE";
Kind[Kind["CELL"] = 12] = "CELL";
Kind[Kind["AREA"] = 13] = "AREA";
Kind[Kind["EXTERNAL_CELL_REFERENCE"] = 14] = "EXTERNAL_CELL_REFERENCE";
Kind[Kind["TABLE_IDENTIFIER"] = 15] = "TABLE_IDENTIFIER";
Kind[Kind["TABLE_COLUMN"] = 16] = "TABLE_COLUMN";
Kind[Kind["TABLE_COLUMN_RANGE"] = 17] = "TABLE_COLUMN_RANGE";
Kind[Kind["TABLE_SPECIFIER"] = 18] = "TABLE_SPECIFIER";
Kind[Kind["STRUCTURED_REFERENCE"] = 19] = "STRUCTURED_REFERENCE";
Kind[Kind["FUNCTION_NAME"] = 20] = "FUNCTION_NAME";
})(exports.Kind || (exports.Kind = {}));
var Node = /** @class */ (function () {
function Node(kind) {
this.kind = kind;
}
return Node;
}());
var InfixNode = /** @class */ (function (_super) {
__extends(InfixNode, _super);
function InfixNode(lhs, op, rhs) {
var _this = _super.call(this, exports.Kind.INFIX) || this;
_this.op = op;
_this.lhs = lhs;
_this.rhs = rhs;
return _this;
}
return InfixNode;
}(Node));
var PrefixNode = /** @class */ (function (_super) {
__extends(PrefixNode, _super);
function PrefixNode(op, expr) {
var _this = _super.call(this, exports.Kind.PREFIX) || this;
_this.op = op;
_this.expr = expr;
return _this;
}
return PrefixNode;
}(Node));
var PostfixNode = /** @class */ (function (_super) {
__extends(PostfixNode, _super);
function PostfixNode(expr, op) {
var _this = _super.call(this, exports.Kind.POSTFIX) || this;
_this.op = op;
_this.expr = expr;
return _this;
}
return PostfixNode;
}(Node));
exports.ValueType = void 0;
(function (ValueType) {
ValueType[ValueType["ERROR"] = 0] = "ERROR";
ValueType[ValueType["LOGICAL"] = 1] = "LOGICAL";
ValueType[ValueType["NUMBER"] = 2] = "NUMBER";
ValueType[ValueType["STRING"] = 3] = "STRING";
ValueType[ValueType["ARRAY"] = 4] = "ARRAY";
})(exports.ValueType || (exports.ValueType = {}));
var ValueNode = /** @class */ (function (_super) {
__extends(ValueNode, _super);
function ValueNode(type) {
var _this = _super.call(this, exports.Kind.VALUE) || this;
_this.type = type;
return _this;
}
return ValueNode;
}(Node));
exports.ErrorValue = void 0;
(function (ErrorValue) {
ErrorValue[ErrorValue["REF"] = 0] = "REF";
ErrorValue[ErrorValue["DIV0"] = 1] = "DIV0";
ErrorValue[ErrorValue["NA"] = 2] = "NA";
ErrorValue[ErrorValue["NAME"] = 3] = "NAME";
ErrorValue[ErrorValue["NULL"] = 4] = "NULL";
ErrorValue[ErrorValue["NUM"] = 5] = "NUM";
ErrorValue[ErrorValue["VALUE"] = 6] = "VALUE";
ErrorValue[ErrorValue["GETTING_DATA"] = 7] = "GETTING_DATA";
ErrorValue[ErrorValue["SPILL"] = 8] = "SPILL";
})(exports.ErrorValue || (exports.ErrorValue = {}));
var ErrorValueNode = /** @class */ (function (_super) {
__extends(ErrorValueNode, _super);
function ErrorValueNode(value) {
var _this = _super.call(this, exports.ValueType.ERROR) || this;
_this.value = value;
return _this;
}
return ErrorValueNode;
}(ValueNode));
var LogicalValueNode = /** @class */ (function (_super) {
__extends(LogicalValueNode, _super);
function LogicalValueNode(value) {
var _this = _super.call(this, exports.ValueType.LOGICAL) || this;
_this.value = value;
return _this;
}
return LogicalValueNode;
}(ValueNode));
var NumberValueNode = /** @class */ (function (_super) {
__extends(NumberValueNode, _super);
function NumberValueNode(value) {
var _this = _super.call(this, exports.ValueType.NUMBER) || this;
_this.value = value;
return _this;
}
return NumberValueNode;
}(ValueNode));
var StringValueNode = /** @class */ (function (_super) {
__extends(StringValueNode, _super);
function StringValueNode(value) {
var _this = _super.call(this, exports.ValueType.STRING) || this;
_this.value = value;
return _this;
}
return StringValueNode;
}(ValueNode));
var ListNode = /** @class */ (function (_super) {
__extends(ListNode, _super);
function ListNode(node) {
var _this = _super.call(this, exports.Kind.LIST) || this;
_this.list = [];
if (node !== undefined) {
_this.list.push(node);
}
return _this;
}
ListNode.prototype.push = function (node) {
this.list.push(node);
};
return ListNode;
}(Node));
var ArrayValueNode = /** @class */ (function (_super) {
__extends(ArrayValueNode, _super);
function ArrayValueNode(row) {
var _this = _super.call(this, exports.ValueType.ARRAY) || this;
_this.value = [row];
return _this;
}
ArrayValueNode.prototype.push = function (row) {
this.value.push(row);
};
return ArrayValueNode;
}(ValueNode));
var NameNode = /** @class */ (function (_super) {
__extends(NameNode, _super);
function NameNode(name) {
var _this = _super.call(this, exports.Kind.NAME) || this;
_this.name = name;
return _this;
}
return NameNode;
}(Node));
var FunctionNameNode = /** @class */ (function (_super) {
__extends(FunctionNameNode, _super);
function FunctionNameNode(name) {
var _this = _super.call(this, exports.Kind.FUNCTION_NAME) || this;
_this.name = name;
return _this;
}
return FunctionNameNode;
}(Node));
// single-sheet = [workbook-index] sheet-name / apostrophe [workbook-index] sheet-name-special apostrophe
var SingleSheetNode = /** @class */ (function (_super) {
__extends(SingleSheetNode, _super);
function SingleSheetNode(sheet, workbook) {
var _this = _super.call(this, exports.Kind.SINGLE_SHEET) || this;
_this.sheet = sheet;
_this.workbook = workbook;
return _this;
}
return SingleSheetNode;
}(Node));
// sheet-range = [workbook-index] sheet-name ":" sheet-name / apostrophe [workbook-index] sheet-name-special ":" sheet-name-special apostrophe
var SheetRangeNode = /** @class */ (function (_super) {
__extends(SheetRangeNode, _super);
function SheetRangeNode(start, end, workbook) {
var _this = _super.call(this, exports.Kind.SHEET_RANGE) || this;
_this.start = start;
_this.end = end;
_this.workbook = workbook;
return _this;
}
return SheetRangeNode;
}(Node));
var ColumnRangeNode = /** @class */ (function (_super) {
__extends(ColumnRangeNode, _super);
function ColumnRangeNode(start, end, flags) {
if (flags === void 0) { flags = 0; }
var _this = _super.call(this, exports.Kind.COLUMN_RANGE) || this;
_this.start = start;
_this.end = end;
_this.flags = flags;
return _this;
}
return ColumnRangeNode;
}(Node));
var RowRangeNode = /** @class */ (function (_super) {
__extends(RowRangeNode, _super);
function RowRangeNode(start, end, flags) {
if (flags === void 0) { flags = 0; }
var _this = _super.call(this, exports.Kind.ROW_RANGE) || this;
_this.start = start;
_this.end = end;
_this.flags = flags;
return _this;
}
return RowRangeNode;
}(Node));
var CellNode = /** @class */ (function (_super) {
__extends(CellNode, _super);
function CellNode(row, column, flags) {
if (flags === void 0) { flags = 0; }
var _this = _super.call(this, exports.Kind.CELL) || this;
_this.row = row;
_this.column = column;
_this.flags = flags;
return _this;
}
return CellNode;
}(Node));
var AreaNode = /** @class */ (function (_super) {
__extends(AreaNode, _super);
function AreaNode(start, end) {
var _this = _super.call(this, exports.Kind.AREA) || this;
_this.start = start;
_this.end = end;
return _this;
}
return AreaNode;
}(Node));
var ExternalCellReference = /** @class */ (function (_super) {
__extends(ExternalCellReference, _super);
function ExternalCellReference(sheet, cell) {
var _this = _super.call(this, exports.Kind.EXTERNAL_CELL_REFERENCE) || this;
_this.sheet = sheet;
_this.cell = cell;
return _this;
}
return ExternalCellReference;
}(Node));
var TableIdentifierNode = /** @class */ (function (_super) {
__extends(TableIdentifierNode, _super);
function TableIdentifierNode(name, workbook) {
var _this = _super.call(this, exports.Kind.TABLE_IDENTIFIER) || this;
_this.name = name;
_this.workbook = workbook;
return _this;
}
return TableIdentifierNode;
}(Node));
var TableColumnNode = /** @class */ (function (_super) {
__extends(TableColumnNode, _super);
function TableColumnNode(name) {
var _this = _super.call(this, exports.Kind.TABLE_COLUMN) || this;
_this.name = name;
return _this;
}
return TableColumnNode;
}(Node));
var TableColumnRangeNode = /** @class */ (function (_super) {
__extends(TableColumnRangeNode, _super);
function TableColumnRangeNode(first, last) {
var _this = _super.call(this, exports.Kind.TABLE_COLUMN_RANGE) || this;
_this.first = first;
_this.last = last;
return _this;
}
return TableColumnRangeNode;
}(Node));
var TABLE_ALL = 0x01;
var TABLE_DATA = 0x02;
var TABLE_HEADERS = 0x04;
var TABLE_TOTALS = 0x08;
var TABLE_THIS_ROW = 0x10;
var TableSpecifierNode = /** @class */ (function (_super) {
__extends(TableSpecifierNode, _super);
function TableSpecifierNode(value) {
var _this = _super.call(this, exports.Kind.TABLE_SPECIFIER) || this;
_this.value = value;
return _this;
}
return TableSpecifierNode;
}(Node));
var StructuredReferenceNode = /** @class */ (function (_super) {
__extends(StructuredReferenceNode, _super);
function StructuredReferenceNode(specifier, column) {
if (specifier === void 0) { specifier = 0; }
var _this = _super.call(this, exports.Kind.STRUCTURED_REFERENCE) || this;
_this.specifier = specifier;
_this.column = column;
return _this;
}
return StructuredReferenceNode;
}(Node));
var FunctionCallNode = /** @class */ (function (_super) {
__extends(FunctionCallNode, _super);
function FunctionCallNode(name, args) {
var _this = _super.call(this, exports.Kind.FCALL) || this;
_this.name = name;
_this.args = args;
return _this;
}
return FunctionCallNode;
}(Node));
var MissingNode = /** @class */ (function (_super) {
__extends(MissingNode, _super);
function MissingNode() {
return _super.call(this, exports.Kind.MISSING) || this;
}
return MissingNode;
}(Node));
var Formula = /** @class */ (function () {
function Formula() {
}
return Formula;
}());
function atoi26(s) {
var result = 0;
for (var k = 0; k < s.length; k++) {
var code = s.charCodeAt(k);
if (code >= 97) {
result = result * 26 + code - 97 + 1;
}
else {
result = result * 26 + code - 65 + 1;
}
}
return result;
}
var arraycopy = function (src, srcPos, dest, destPos, length) {
for (var i = 0; i < length; i++) {
dest[destPos + i] = src[srcPos + i];
}
};
var fill = function (a, fromIndex, toIndex, val) {
for (var i = fromIndex; i < toIndex; i++) {
a[i] = val;
}
};
var printStream = {
print: function (msg) { return console.log(msg); },
println: function (msg) { return console.log(msg); }
};
var Position = /** @class */ (function () {
function Position(line, column) {
this.line = line;
this.column = column;
}
Position.prototype.equals = function (p) {
return p.line == this.line && p.column == this.column;
};
Position.prototype.toString = function () {
return this.line + '.' + this.column;
};
return Position;
}());
var new_any = function (n) {
var array = [];
for (var i = 0; i < n; i++) {
array.push(null);
}
return array;
};
var YYACCEPT = 0;
var YYABORT = 1;
var YYPUSH_MORE = 4;
var YYERROR = 2;
var YYERRLAB = 3;
var YYNEWSTATE = 4;
var YYDEFAULT = 5;
var YYREDUCE = 6;
var YYERRLAB1 = 7;
var YYGETTOKEN = 9;
function yyPactValueIsDefault(yyvalue) {
return yyvalue == yypact_ninf_;
}
function yyTableValueIsError(yyvalue) {
return yyvalue == yytable_ninf_;
}
var yypact_ninf_ = -38;
var yytable_ninf_ = -1;
var yypact_ = yypact_init();
function yypact_init() {
return [
117, 117, 117, 117, 117, 49, 267, -38, -38, -38, -38, -38, -38, -38, -38,
-38, -38, 6, 12, 284, -38, -38, 4, 17, 21, -38, 160, -38, -38, -38, -38,
-38, -38, -38, -38, 187, 83, 83, 83, -38, -38, 20, -38, 32, -38, 30, 43,
-38, -9, 35, 215, -20, -38, 5, -3, -38, -38, 117, -38, -38, 117, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117, 117, 117, -38, -38, 221, 3, 16, 267,
-38, 267, -38, -38, -38, -38, -38, -38, 214, 2, -38, 272, 83, 286, 214, 286,
83, 258, 258, 258, 83, 258, 258, 258, -38, -38, -38, 35, -38, -38, 80, 117,
214, 214,
];
}
var yydefact_ = yydefact_init();
function yydefact_init() {
return [
0, 0, 0, 0, 0, 0, 0, 62, 63, 64, 65, 66, 30, 31, 32, 33, 27, 0, 0, 0, 44,
45, 47, 0, 0, 2, 3, 6, 25, 40, 41, 26, 28, 55, 57, 0, 20, 21, 22, 58, 71, 0,
67, 59, 61, 69, 0, 38, 0, 36, 0, 0, 54, 0, 0, 48, 1, 0, 24, 23, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 56, 0, 0, 0, 0, 34, 0, 35, 42, 29, 43, 46, 49,
51, 0, 19, 12, 9, 7, 4, 8, 10, 14, 18, 17, 11, 15, 13, 16, 68, 60, 70, 37,
39, 50, 0, 0, 52, 53,
];
}
var yypgoto_ = yypgoto_init();
function yypgoto_init() {
return [
-38, -38, -38, -1, -2, -38, -26, -38, -38, -37, -38, -38, -38, 7, 36, -38,
0, -38, -21, -18,
];
}
var yydefgoto_ = yydefgoto_init();
function yydefgoto_init() {
return [
0, 24, 25, 26, 27, 48, 49, 28, 29, 30, 31, 55, 88, 32, 33, 41, 34, 43, 44,
45,
];
}
var yytable_ = yytable_init();
function yytable_init() {
return [
35, 36, 37, 38, 47, 42, 1, 86, 78, 2, 50, 3, 108, 82, 84, 109, 51, 79, 4, 5,
53, 56, 6, 20, 21, 22, 54, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 74, 23, 75, 76, 77, 80, 40, 85, 81, 106, 87, 104, 52, 89, 83,
105, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 39, 0, 0, 103,
47, 0, 107, 7, 8, 9, 10, 11, 0, 0, 57, 0, 58, 1, 59, 0, 2, 110, 3, 40, 0, 0,
0, 0, 0, 4, 5, 0, 0, 6, 0, 69, 111, 112, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 1, 23, 0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 4, 5, 0, 0,
6, 0, 0, 0, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
57, 23, 58, 0, 59, 60, 0, 0, 61, 62, 63, 64, 65, 0, 0, 66, 67, 68, 0, 0, 0,
69, 0, 0, 70, 71, 72, 57, 0, 58, 0, 59, 60, 0, 73, 61, 62, 0, 64, 65, 0, 0,
66, 67, 68, 0, 0, 0, 69, 0, 0, 70, 71, 72, 57, 0, 58, 0, 59, 60, 0, 0, 61,
62, 0, 64, 65, 0, 0, 66, 67, 68, 0, 0, 5, 69, 0, 0, 70, 71, 72, 0, 7, 8, 9,
10, 11, 81, 7, 8, 9, 10, 11, 0, 19, 20, 21, 22, 57, 0, 58, 0, 59, 60, 40, 0,
61, 62, 0, 64, 65, 0, 57, 0, 58, 0, 59, 0, 0, 69, 61, 62, 0, 64, 65, 0, 57,
0, 58, 6, 59, 0, 0, 69, 61, 0, 0, 0, 65, 12, 13, 14, 15, 5, 46, 0, 0, 69, 0,
0, 0, 7, 8, 9, 10, 11,
];
}
var yycheck_ = yycheck_init();
function yycheck_init() {
return [
1, 2, 3, 4, 6, 5, 9, 10, 17, 12, 4, 14, 10, 50, 51, 13, 4, 26, 21, 22, 16,
0, 25, 43, 44, 45, 9, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 23, 47, 13, 16, 4, 13, 46, 45, 35, 78, 54, 75, 19, 57, 50, 76,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 23, -1, -1, 75, 78, -1,
80, 30, 31, 32, 33, 34, -1, -1, 3, -1, 5, 9, 7, -1, 12, 13, 14, 46, -1, -1,
-1, -1, -1, 21, 22, -1, -1, 25, -1, 24, 109, 110, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 9, 47, -1, 12, -1, 14, -1, -1, -1,
-1, -1, -1, 21, 22, -1, -1, 25, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 3, 47, 5, -1, 7, 8, -1, -1, 11, 12, 13,
14, 15, -1, -1, 18, 19, 20, -1, -1, -1, 24, -1, -1, 27, 28, 29, 3, -1, 5,
-1, 7, 8, -1, 10, 11, 12, -1, 14, 15, -1, -1, 18, 19, 20, -1, -1, -1, 24,
-1, -1, 27, 28, 29, 3, -1, 5, -1, 7, 8, -1, -1, 11, 12, -1, 14, 15, -1, -1,
18, 19, 20, -1, -1, 22, 24, -1, -1, 27, 28, 29, -1, 30, 31, 32, 33, 34, 35,
30, 31, 32, 33, 34, -1, 42, 43, 44, 45, 3, -1, 5, -1, 7, 8, 46, -1, 11, 12,
-1, 14, 15, -1, 3, -1, 5, -1, 7, -1, -1, 24, 11, 12, -1, 14, 15, -1, 3, -1,
5, 25, 7, -1, -1, 24, 11, -1, -1, -1, 15, 35, 36, 37, 38, 22, 40, -1, -1,
24, -1, -1, -1, 30, 31, 32, 33, 34,
];
}
var yystos_ = yystos_init();
function yystos_init() {
return [
0, 9, 12, 14, 21, 22, 25, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 47, 50, 51, 52, 53, 56, 57, 58, 59, 62, 63, 65, 52, 52, 52,
52, 23, 46, 64, 65, 66, 67, 68, 40, 53, 54, 55, 4, 4, 63, 16, 9, 60, 0, 3,
5, 7, 8, 11, 12, 13, 14, 15, 18, 19, 20, 24, 27, 28, 29, 10, 23, 13, 16, 4,
17, 26, 13, 35, 58, 62, 58, 45, 10, 52, 61, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 65, 67, 68, 55, 53, 10, 13, 13, 52, 52,
];
}
var yyr1_ = yyr1_init();
function yyr1_init() {
return [
0, 49, 50, 51, 51, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 54, 54,
55, 55, 56, 56, 57, 57, 58, 58, 58, 58, 59, 60, 60, 61, 61, 61, 62, 62, 63,
63, 63, 64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 67, 67, 68,
];
}
var yyr2_ = yyr2_init();
function yyr2_init() {
return [
0, 2, 1, 1, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2,
1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 3, 1, 3, 1, 3, 1, 1, 3, 3, 1, 1, 3, 1, 2, 2,
3, 1, 3, 4, 2, 1, 3, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1,
];
}
var yyrline_ = yyrline_init();
function yyrline_init() {
return [
0, 96, 96, 99, 100, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 132,
133, 134, 135, 136, 137, 141, 142, 146, 147, 151, 152, 156, 157, 161, 162,
163, 164, 168, 172, 173, 177, 178, 179, 183, 184, 188, 189, 190, 194, 195,
196, 200, 201, 202, 203, 204, 208, 209, 213, 214, 218,
];
}
function yytranslate_(t) {
var code_max = 303;
if (t <= 0)
return SymbolKind.S_YYEOF;
else if (t <= code_max)
return SymbolKind.get(yytranslate_table_[t]);
else
return SymbolKind.S_YYUNDEF;
}
var yytranslate_table_ = yytranslate_table_init();
function yytranslate_table_init() {
return [
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
];
}
var YYLAST_ = 318;
var YYEMPTY_ = -2;
var YYFINAL_ = 56;
var YYNTOKENS_ = 49;
function i18n(s) {
return s;
}
var Parser = /** @class */ (function () {
function Parser(yylexer, formula) {
this.yyDebugStream = printStream;
this.yydebug = 0;
this.yynerrs = 0;
this.yyerrstatus_ = 0;
this.yychar = YYEMPTY_;
this.yytoken = null;
this.yyn = 0;
this.yylen = 0;
this.yystate = 0;
this.yystack = new YYStack();
this.label = YYNEWSTATE;
this.yyerrloc = null;
this.yylloc = new Location(null, null);
this.yylval = null;
this.push_parse_initialized = false;
this.yylexer = yylexer;
this.formula = formula;
}
Parser.prototype.yylloc_set = function (rhs, n) {
if (0 < n)
return new Location(rhs.locationAt(n - 1).begin, rhs.locationAt(0).end);
else
return new Location(rhs.locationAt(0).end);
};
Parser.prototype.getDebugStream = function () {
return this.yyDebugStream;
};
Parser.prototype.setDebugStream = function (s) {
this.yyDebugStream = s;
};
Parser.prototype.getDebugLevel = function () {
return this.yydebug;
};
Parser.prototype.setDebugLevel = function (level) {
this.yydebug = level;
};
Parser.prototype.getNumberOfErrors = function () {
return this.yynerrs;
};
Parser.prototype.yyerror = function (msg) {
this.yylexer.yyerror(null, msg);
};
Parser.prototype.yyerror_1 = function (loc, msg) {
this.yylexer.yyerror(loc, msg);
};
Parser.prototype.yyerror_2 = function (pos, msg) {
this.yylexer.yyerror(new Location(pos), msg);
};
Parser.prototype.yycdebug = function (s) {
if (0 < this.yydebug)
this.yyDebugStream.println(s);
};
Parser.prototype.recovering = function () {
return this.yyerrstatus_ == 0;
};
Parser.prototype.yyLRGotoState = function (yystate, yysym) {
var yyr = yypgoto_[yysym - YYNTOKENS_] + yystate;
if (0 <= yyr && yyr <= YYLAST_ && yycheck_[yyr] == yystate)
return yytable_[yyr];
else
return yydefgoto_[yysym - YYNTOKENS_];
};
Parser.prototype.yyaction = function (yyn, yystack, yylen) {
var yyval = 0 < yylen ? this.yystack.valueAt(yylen - 1) : this.yystack.valueAt(0);
var yyloc = this.yylloc_set(yystack, yylen);
this.yyReducePrint(yyn, yystack);
switch (yyn) {
case 2:
if (yyn == 2) {
this.formula.node = this.yystack.valueAt(0);
}
break;
case 3:
if (yyn == 3) {
yyval = this.yystack.valueAt(0);
}
break;
case 4:
if (yyn == 4) {
yyval = new InfixNode(this.yystack.valueAt(2), ',', this.yystack.valueAt(0));
}
break;
case 5:
if (yyn == 5) {
yyval = this.yystack.valueAt(1);
}
break;
case 6:
if (yyn == 6) {
yyval = this.yystack.valueAt(0);
}
break;
case 7:
if (yyn == 7) {
yyval = new InfixNode(this.yystack.valueAt(2), '+', this.yystack.valueAt(0));
}
break;
case 8:
if (yyn == 8) {
yyval = new InfixNode(this.yystack.valueAt(2), '-', this.yystack.valueAt(0));
}
break;
case 9:
if (yyn == 9) {
yyval = new InfixNode(this.yystack.valueAt(2), '*', this.yystack.valueAt(0));
}
break;
case 10:
if (yyn == 10) {
yyval = new InfixNode(this.yystack.valueAt(2), '/', this.yystack.valueAt(0));
}
break;
case 11:
if (yyn == 11) {
yyval = new InfixNode(this.yystack.valueAt(2), '^', this.yystack.valueAt(0));
}
break;
case 12:
if (yyn == 12) {
yyval = new InfixNode(this.yystack.valueAt(2), '&', this.yystack.valueAt(0));
}
break;
case 13:
if (yyn == 13) {
yyval = new InfixNode(this.yystack.valueAt(2), '<>', this.yystack.valueAt(0));
}
break;
case 14:
if (yyn == 14) {
yyval = new InfixNode(this.yystack.valueAt(2), '<', this.yystack.valueAt(0));
}
break;
case 15:
if (yyn == 15) {
yyval = new InfixNode(this.yystack.valueAt(2), '<=', this.yystack.valueAt(0));
}
break;
case 16:
if (yyn == 16) {
yyval = new InfixNode(this.yystack.valueAt(2), '>=', this.yystack.valueAt(0));
}
break;
case 17:
if (yyn == 17) {
yyval = new InfixNode(this.yystack.valueAt(2), '>', this.yystack.valueAt(0));
}
break;
case 18:
if (yyn == 18) {
yyval = new InfixNode(this.yystack.valueAt(2), '=', this.yystack.valueAt(0));
}
break;
case 19:
if (yyn == 19) {
yyval = new InfixNode(this.yystack.valueAt(2), ' ', this.yystack.valueAt(0));
}
break;
case 20:
if (yyn == 20) {
yyval = new PrefixNode('+', this.yystack.valueAt(0));
}
break;
case 21:
if (yyn == 21) {
yyval = new PrefixNode('-', this.yystack.valueAt(0));
}
break;
case 22:
if (yyn == 22) {
yyval = new PrefixNode('@', this.yystack.valueAt(0));
}
break;
case 23:
if (yyn == 23) {
yyval = new PostfixNode(this.yystack.valueAt(1), '%');
}
break;
case 24:
if (yyn == 24) {
yyval = new PostfixNode(this.yystack.valueAt(1), '#');
}
break;
case 25:
if (yyn == 25) {
yyval = this.yystack.valueAt(0);
}
break;
case 26:
if (yyn == 26) {
yyval = this.yystack.valueAt(0);
}
break;
case 27:
if (yyn == 27) {
yyval = this.yystack.valueAt(0);
}
break;
case 28:
if (yyn == 28) {
yyval = this.yystack.valueAt(0);
}
break;
case 29:
if (yyn == 29) {
yyval = this.yystack.valueAt(0);
}
break;
case 30:
if (yyn == 30) {
yyval = this.yystack.valueAt(0);
}
break;
case 31:
if (yyn == 31) {
yyval = this.yystack.valueAt(0);
}
break;
case 32:
if (yyn == 32) {
yyval = this.yystack.valueAt(0);
}
break;
case 33:
if (yyn == 33) {
yyval = this.yystack.valueAt(0);
}
break;
case 34:
if (yyn == 34) {
yyval = this.yystack.valueAt(1);
}
break;
case 35:
if (yyn == 35) {
yyval = this.yystack.valueAt(0);
}
break;
case 36:
if (yyn == 36) {
yyval = new ArrayValueNode(this.yystack.valueAt(0).list);
}
break;
case 37:
if (yyn == 37) {
yyval = this.yystack.valueAt(2);
this.yystack.valueAt(2).push(this.yystack.valueAt(0).list);
}
break;
case 38:
if (yyn == 38) {
yyval = new ListNode(this.yystack.valueAt(0));
}
break;
case 39:
if (yyn == 39) {
yyval = this.yystack.valueAt(2);
this.yystack.valueAt(2).push(this.yystack.valueAt(0));
}
break;
case 40:
if (yyn == 40) {
yyval = this.yystack.valueAt(0);
}
break;
case 41:
if (yyn == 41) {
yyval = this.yystack.valueAt(0);
}
break;
case 42:
if (yyn == 42) {
yyval = new ExternalCellReference(this.yystack.valueAt(2), this.yystack.valueAt(0));
}
break;
case 43:
if (yyn == 43) {
yyval = new ExternalCellReference(this.yystack.valueAt(2), this.yystack.valueAt(0));
}
break;
case 44:
if (yyn == 44) {
yyval = this.yystack.valueAt(0);
}
break;
case 45:
if (yyn == 45) {
yyval = this.yystack.valueAt(0);
}
break;
case 46:
if (yyn == 46) {
yyval = new AreaNode(this.yystack.valueAt(2), this.yystack.valueAt(0));
}
break;
case 47:
if (yyn == 47) {
yyval = this.yystack.valueAt(0);
}
break;
case 48:
if (yyn == 48) {
yyval = new FunctionCallNode(this.yystack.valueAt(1), this.yystack.valueAt(0));
}
break;
case 49:
if (yyn == 49) {
yyval = new ListNode();
}
break;
case 50:
if (yyn == 50) {
yyval = this.yystack.valueAt(1);
}
break;
case 51:
if (yyn == 51) {
yyval = new ListNode(this.yystack.valueAt(0));
}
break;
case 52:
if (yyn == 52) {
yyval = this.yystack.valueAt(2);
yyval.push(this.yystack.valueAt(0));
}
break;
case 53:
if (yyn == 53) {
yyval = this.yystack.valueAt(3);
yyval.push(new MissingNode());
yyval.push(this.yystack.valueAt(0));
}
break;
case 54:
if (yyn == 54) {
yyval = this.yystack.valueAt(0);
this.yystack.valueAt(0).table =
this.yystack.valueAt(1);
}
break;
case 55:
if (yyn == 55) {
yyval = this.yystack.valueAt(0);
}
break;
case 56:
if (yyn == 56) {
yyval = this.yystack.valueAt(1);
}
break;
case 57:
if (yyn == 57) {
yyval = new StructuredReferenceNode(this.yystack.valueAt(0).value);
}
break;
case 58:
if (yyn == 58) {
yyval = new StructuredReferenceNode(0);
}
break;
case 59:
if (yyn == 59) {
yyval = new StructuredReferenceNode(this.yystack.valueAt(0).value);
}
break;
case 60:
if (yyn == 60) {
yyval = new StructuredReferenceNode(this.yystack.valueAt(2).value, this.yystack.valueAt(0));
}
break;
case 61:
if (yyn == 61) {
yyval = new StructuredReferenceNode(0, this.yystack.valueAt(0));
}
break;
case 62:
if (yyn == 62) {
yyval = new TableSpecifierNode(TABLE_ALL);
}
break;
case 63:
if (yyn == 63) {
yyval = new TableSpecifierNode(TABLE_DATA);
}
break;
case 64:
if (yyn == 64) {
yyval = new TableSpecifierNode(TABLE_HEADERS);
}
break;
case 65:
if (yyn == 65) {
yyval = new TableSpecifierNode(TABLE_TOTALS);
}
break;
case 66:
if (yyn == 66) {
yyval = new TableSpecifierNode(TABLE_THIS_ROW);
}
break;
case 67:
if (yyn == 67) {
yyval = this.yystack.valueAt(0);
}
break;
case 68:
if (yyn == 68) {
this.yystack.valueAt(2).value |= this.yystack.valueAt(0).value;
yyval = this.yystack.valueAt(2);
}
break;
case 69:
if (yyn == 69) {
yyval = new TableColumnRangeNode(this.yystack.valueAt(0));
}
break;
case 70:
if (yyn == 70) {
yyval = new TableColumnRangeNode(this.yystack.valueAt(2), this.yystack.valueAt(0));
}
break;
case 71:
if (yyn == 71) {
yyval = this.yystack.valueAt(0);
}
break;
}
this.yySymbolPrint('-> $$ =', SymbolKind.get(yyr1_[yyn]), yyval, yyloc);
this.yystack.pop_1(yylen);
yylen = 0;
var yystate = this.yyLRGotoState(this.yystack.stateAt(0), yyr1_[yyn]);
this.yystack.push(yystate, yyval, yyloc);
return YYNEWSTATE;
};
Parser.prototype.yySymbolPrint = function (s, yykind, yyvalue, yylocation) {
if (0 < this.yydebug) {
this.yycdebug(s +
(yykind.getCode() < YYNTOKENS_ ? ' token ' : ' nterm ') +
yykind.getName() +
' (' +
yylocation +
': ' +
(yyvalue == null ? '(null)' : yyvalue.toString()) +
')');
}
};
Parser.prototype.push_parse = function (yylextoken, yylexval, yylexloc) {
var yyloc;
if (!this.push_parse_initialized) {
this.push_parse_initialize();
this.yycdebug('Starting parse');
this.yyerrstatus_ = 0;
}
else
this.label = YYGETTOKEN;
var push_token_consumed = true;
for (;;)
switch (this.label) {
case YYNEWSTATE:
this.yycdebug('Entering state ' + this.yystate);
if (0 < this.yydebug)
this.yystack.print(this.yyDebugStream);
if (this.yystate == YYFINAL_) {
this.label = YYACCEPT;
break;
}
this.yyn = yypact_[this.yystate];
if (yyPactValueIsDefault(this.yyn)) {
this.label = YYDEFAULT;
break;
}
case YYGETTOKEN:
if (this.yychar == YYEMPTY_) {
if (!push_token_consumed)
return YYPUSH_MORE;
this.yycdebug('Reading a token');
this.yychar = yylextoken;
this.yylval = yylexval;
this.yylloc = yylexloc;
push_token_consumed = false;
}
this.yytoken = yytranslate_(this.yychar);
this.yySymbolPrint('Next token is', this.yytoken, this.yylval, this.yylloc);
if (this.yytoken == SymbolKind.S_YYerror) {
this.yychar = YYUNDEF;
this.yytoken = SymbolKind.S_YYUNDEF;
this.yyerrloc = this.yylloc;
this.label = YYERRLAB1;
}
else {
this.yyn += this.yytoken.getCode();
if (this.yyn < 0 ||
YYLAST_ < this.yyn ||
yycheck_[this.yyn] != this.yytoken.getCode())
this.label = YYDEFAULT;
else if ((this.yyn = yytable_[this.yyn]) <= 0) {
if (yyTableValueIsError(this.yyn))
this.label = YYERRLAB;
else {
this.yyn = -this.yyn;
this.label = YYREDUCE;
}
}
else {
this.yySymbolPrint('Shifting', this.yytoken, this.yylval, this.yylloc);
this.yychar = YYEMPTY_;
if (this.yyerrstatus_ > 0)
--this.yyerrstatus_;
this.yystate = this.yyn;
this.yystack.push(this.yystate, this.yylval, this.yylloc);
this.label = YYNEWSTATE;
}
}
break;
case YYDEFAULT:
this.yyn = yydefact_[this.yystate];
if (this.yyn == 0)
this.label = YYERRLAB;
else
this.label = YYREDUCE;
break;
case YYREDUCE:
this.yylen = yyr2_[this.yyn];
this.label = this.yyaction(this.yyn, this.yystack, this.yylen);
this.yystate = this.yystack.stateAt(0);
break;
case YYERRLAB:
if (this.yyerrstatus_ == 0) {
++this.yynerrs;
if (this.yychar == YYEMPTY_)
this.yytoken = null;
this.yyreportSyntaxError(new Context(this.yystack, this.yytoken, this.yylloc));
}
this.yyerrloc = this.yylloc;
if (this.yyerrstatus_ == 3) {
if (this.yychar <= YYEOF) {
if (this.yychar == YYEOF) {
this.label = YYABORT;
break;
}
}
else
this.yychar = YYEMPTY_;
}
this.label = YYERRLAB1;
break;
case YYERROR:
this.yyerrloc = this.yystack.locationAt(this.yylen - 1);
this.yystack.pop_1(this.yylen);
this.yylen = 0;
this.yystate = this.yystack.stateAt(0);
this.label = YYERRLAB1;
break;
case YYERRLAB1:
this.yyerrstatus_ = 3;
for (;;) {
this.yyn = yypact_[this.yystate];
if (!yyPactValueIsDefault(this.yyn)) {
this.yyn += SymbolKind.S_YYerror.getCode();
if (0 <= this.yyn &&
this.yyn <= YYLAST_ &&
yycheck_[this.yyn] == SymbolKind.S_YYerror.getCode()) {
this.yyn = yytable_[this.yyn];
if (0 < this.yyn)
break;
}
}
if (this.yystack.height == 0) {
this.label = YYABORT;
break;
}
this.yyerrloc = this.yystack.locationAt(0);
this.yystack.pop();
this.yystate = this.yystack.stateAt(0);
if (0 < this.yydebug)
this.yystack.print(this.yyDebugStream);
}
if (this.label == YYABORT)
break;
this.yystack.push(0, null, this.yylloc);
this.yystack.push(0, null, this.yyerrloc);
yyloc = this.yylloc_set(this.yystack, 2);
this.yystack.pop_1(2);
this.yySymbolPrint('Shifting', SymbolKind.get(yystos_[this.yyn]), this.yylval, yyloc);
this.yystate = this.yyn;
this.yystack.push(this.yyn, this.yylval, yyloc);
this.label = YYNEWSTATE;
break;
case YYACCEPT:
this.push_parse_initialized = false;
return YYACCEPT;
case YYABORT:
this.push_parse_initialized = false;
return YYABORT;
}
};
Parser.prototype.push_parse_initialize = function () {
this.yychar = YYEMPTY_;
this.yytoken = null;
this.yyn = 0;
this.yylen = 0;
this.yystate = 0;
this.yystack = new YYStack();
this.label = YYNEWSTATE;
this.yynerrs = 0;
this.yyerrloc = null;
this.yylloc = new Location(null, null);
this.yylval = null;
this.yystack.push(this.yystate, this.yylval, this.yylloc);
this.push_parse_initialized = true;
};
Parser.prototype.push_parse_1 = function (yylextoken, yylexval, yylexpos) {
return this.push_parse(yylextoken, yylexval, new Location(yylexpos));
};
Parser.prototype.yyreportSyntaxError = function (yyctx) {
this.yylexer.reportSyntaxError(yyctx);
};
Parser.prototype.yyReducePrint = function (yyrule, yystack) {
if (this.yydebug == 0)
return;
var yylno = yyrline_[yyrule];
var yynrhs = yyr2_[yyrule];
this.yycdebug('Reducing stack by rule ' + (yyrule - 1) + ' (line ' + yylno + '):');
for (var yyi = 0; yyi < yynrhs; yyi++)
this.yySymbolPrint(' $' + (yyi + 1) + ' =', SymbolKind.get(yystos_[this.yystack.stateAt(yynrhs - (yyi + 1))]), this.yystack.valueAt(yynrhs - (yyi + 1)), this.yystack.locationAt(yynrhs - (yyi + 1)));
};
return Parser;
}());
var Location = /** @class */ (function () {
function Location() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (args.length === 1 &&
(args[0] instanceof Position || args[0] === null)) {
this.constructor_0(args[0]);
}
else if (args.length === 2 &&
(args[0] instanceof Position || args[0] === null) &&
(args[1] instanceof Position || args[1] === null)) {
this.constructor_1(args[0], args[1]);
}
else
throw Error('Unknown type(s)');
}
Location.prototype.constructor_0 = function (loc) {
this.begin = this.end = loc;
};
Location.prototype.constructor_1 = function (begin, end) {
this.begin = begin;
this.end = end;
};
Location.prototype.toString = function () {
if (this.begin.equals(this.end))
return this.begin.toString();
else
return this.begin.toString() + '-' + this.end.toString();
};
return Location;
}());
var SymbolKind = /** @class */ (function () {
function SymbolKind(n) {
this.yycode_ = n;
}
SymbolKind.get = function (code) {
return SymbolKind.values_[code];
};
SymbolKind.prototype.getCode = function () {
return this.yycode_;
};
SymbolKind.yynames_init = function () {
return [
i18n('end of file'),
i18n('error'),
i18n('invalid token'),
' ',
'!',
'#',
'$',
'%',
'&',
'(',
')',
'*',
'+',
',',
'-',
'/',
':',
';',
'<',
'=',
'>',
'@',
'[',
']',
'^',
'{',
'}',
'<=',
'<>',
'>=',
'[#All]',
'[#Data]',
'[#Headers]',
'[#Totals]',
'[#This Row]',
i18n('error constant'),
i18n('logical constant'),
i18n('numeric constant'),
i18n('string constant'),
i18n('name'),
i18n('single sheet'),
i18n('sheet range'),
i18n('table identifier'),
i18n('column range'),
i18n('row range'),
i18n('cell'),
i18n('table column'),
i18n('function name'),
'NEG',
'$accept',
'start',
'formula',
'expression',
'constant',
'constant_list_rows',
'constant_list_row',
'cell_reference',
'external_cell_reference',
'a1_reference',
'function_call',
'argument_list',
'non_empty_argument_list',
'structure_reference',
'intra_table_reference',
'inner_reference',
'keyword',
'keyword_list',
'column_range',
'column',
null,
];
};
SymbolKind.prototype.getName = function () {
return SymbolKind.yynames_[this.yycode_];
};
SymbolKind.S_YYEOF = new SymbolKind(0);
SymbolKind.S_YYerror = new SymbolKind(1);
SymbolKind.S_YYUNDEF = new SymbolKind(2);
SymbolKind.S_SPACE = new SymbolKind(3);
SymbolKind.S_BANG = new SymbolKind(4);
SymbolKind.S_HASH = new SymbolKind(5);
SymbolKind.S_DOLLAR = new SymbolKind(6);
SymbolKind.S_PERCENT = new SymbolKind(7);
SymbolKind.S_AMPER = new SymbolKind(8);
SymbolKind.S_LPAREN = new SymbolKind(9);
SymbolKind.S_RPAREN = new SymbolKind(10);
SymbolKind.S_STAR = new SymbolKind(11);
SymbolKind.S_PLUS = new SymbolKind(12);
SymbolKind.S_UNION = new SymbolKind(13);
SymbolKind.S_MINUS = new SymbolKind(14);
SymbolKind.S_SLASH = new SymbolKind(15);
SymbolKind.S_RANGE = new SymbolKind(16);
SymbolKind.S_SEM