@leankylin-sheet/formula-parser 3.1.31 → 3.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +82 -161
- package/dist/index.js +82 -161
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -447,82 +447,7 @@ registerOperation(func$a.SYMBOL, func$a);
|
|
|
447
447
|
registerOperation(func$b.SYMBOL, func$b);
|
|
448
448
|
registerOperation(func$9.SYMBOL, func$9);
|
|
449
449
|
|
|
450
|
-
|
|
451
|
-
/*
|
|
452
|
-
Returns a Parser object of the following structure:
|
|
453
|
-
|
|
454
|
-
Parser: {
|
|
455
|
-
yy: {}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
Parser.prototype: {
|
|
459
|
-
yy: {},
|
|
460
|
-
trace: function(),
|
|
461
|
-
symbols_: {associative list: name ==> number},
|
|
462
|
-
terminals_: {associative list: number ==> name},
|
|
463
|
-
productions_: [...],
|
|
464
|
-
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
|
465
|
-
table: [...],
|
|
466
|
-
defaultActions: {...},
|
|
467
|
-
parseError: function(str, hash),
|
|
468
|
-
parse: function(input),
|
|
469
|
-
|
|
470
|
-
lexer: {
|
|
471
|
-
EOF: 1,
|
|
472
|
-
parseError: function(str, hash),
|
|
473
|
-
setInput: function(input),
|
|
474
|
-
input: function(),
|
|
475
|
-
unput: function(str),
|
|
476
|
-
more: function(),
|
|
477
|
-
less: function(n),
|
|
478
|
-
pastInput: function(),
|
|
479
|
-
upcomingInput: function(),
|
|
480
|
-
showPosition: function(),
|
|
481
|
-
test_match: function(regex_match_array, rule_index),
|
|
482
|
-
next: function(),
|
|
483
|
-
lex: function(),
|
|
484
|
-
begin: function(condition),
|
|
485
|
-
popState: function(),
|
|
486
|
-
_currentRules: function(),
|
|
487
|
-
topState: function(),
|
|
488
|
-
pushState: function(condition),
|
|
489
|
-
|
|
490
|
-
options: {
|
|
491
|
-
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
|
492
|
-
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
|
493
|
-
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
|
494
|
-
},
|
|
495
|
-
|
|
496
|
-
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
|
497
|
-
rules: [...],
|
|
498
|
-
conditions: {associative list: name ==> set},
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
token location info (@$, _$, etc.): {
|
|
504
|
-
first_line: n,
|
|
505
|
-
last_line: n,
|
|
506
|
-
first_column: n,
|
|
507
|
-
last_column: n,
|
|
508
|
-
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
|
513
|
-
text: (matched text)
|
|
514
|
-
token: (the produced terminal token, if any)
|
|
515
|
-
line: (yylineno)
|
|
516
|
-
}
|
|
517
|
-
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
|
518
|
-
loc: (yylloc)
|
|
519
|
-
expected: (string describing the set of expected tokens)
|
|
520
|
-
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
|
521
|
-
}
|
|
522
|
-
*/
|
|
523
|
-
|
|
524
|
-
/* addresses */
|
|
525
|
-
var simpleSheetName = "[A-Za-z0-9_\xC0-\u02AF]+";
|
|
450
|
+
var simpleSheetName = "[A-Za-z0-9_\u4E00-\u9FFF]+";
|
|
526
451
|
var quotedSheetName = "'(?:(?!').|'')*'";
|
|
527
452
|
var sheetNameRegexp = "(?:".concat(simpleSheetName, "|").concat(quotedSheetName, ")!");
|
|
528
453
|
var ABSOLUTE_CELL = new RegExp("^(?:".concat(sheetNameRegexp, ")?(?:[$][A-Za-z]+[$][0-9]+)"));
|
|
@@ -567,13 +492,13 @@ var parser = {
|
|
|
567
492
|
trace: function trace() {},
|
|
568
493
|
yy: {},
|
|
569
494
|
symbols_: {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
495
|
+
error: 2,
|
|
496
|
+
expressions: 3,
|
|
497
|
+
expression: 4,
|
|
498
|
+
EOF: 5,
|
|
499
|
+
variableSequence: 6,
|
|
500
|
+
number: 7,
|
|
501
|
+
STRING: 8,
|
|
577
502
|
"&": 9,
|
|
578
503
|
"=": 10,
|
|
579
504
|
"+": 11,
|
|
@@ -581,28 +506,28 @@ var parser = {
|
|
|
581
506
|
")": 13,
|
|
582
507
|
"<": 14,
|
|
583
508
|
">": 15,
|
|
584
|
-
|
|
509
|
+
NOT: 16,
|
|
585
510
|
"-": 17,
|
|
586
511
|
"*": 18,
|
|
587
512
|
"/": 19,
|
|
588
513
|
"^": 20,
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
514
|
+
FUNCTION: 21,
|
|
515
|
+
expseq: 22,
|
|
516
|
+
cell: 23,
|
|
517
|
+
ABSOLUTE_CELL: 24,
|
|
518
|
+
RELATIVE_CELL: 25,
|
|
519
|
+
MIXED_CELL: 26,
|
|
595
520
|
":": 27,
|
|
596
|
-
|
|
521
|
+
ARRAY: 28,
|
|
597
522
|
";": 29,
|
|
598
523
|
",": 30,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
524
|
+
VARIABLE: 31,
|
|
525
|
+
DECIMAL: 32,
|
|
526
|
+
NUMBER: 33,
|
|
602
527
|
"%": 34,
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
528
|
+
ERROR: 35,
|
|
529
|
+
$accept: 0,
|
|
530
|
+
$end: 1
|
|
606
531
|
},
|
|
607
532
|
terminals_: {
|
|
608
533
|
5: "EOF",
|
|
@@ -651,46 +576,46 @@ var parser = {
|
|
|
651
576
|
this.$ = yy.trimEdges($$[$0]);
|
|
652
577
|
break;
|
|
653
578
|
case 5:
|
|
654
|
-
this.$ = yy.evaluateByOperator(
|
|
579
|
+
this.$ = yy.evaluateByOperator("&", [$$[$0 - 2], $$[$0]]);
|
|
655
580
|
break;
|
|
656
581
|
case 6:
|
|
657
|
-
this.$ = yy.evaluateByOperator(
|
|
582
|
+
this.$ = yy.evaluateByOperator("=", [$$[$0 - 2], $$[$0]]);
|
|
658
583
|
break;
|
|
659
584
|
case 7:
|
|
660
|
-
this.$ = yy.evaluateByOperator(
|
|
585
|
+
this.$ = yy.evaluateByOperator("+", [$$[$0 - 2], $$[$0]]);
|
|
661
586
|
break;
|
|
662
587
|
case 8:
|
|
663
588
|
this.$ = $$[$0 - 1];
|
|
664
589
|
break;
|
|
665
590
|
case 9:
|
|
666
|
-
this.$ = yy.evaluateByOperator(
|
|
591
|
+
this.$ = yy.evaluateByOperator("<=", [$$[$0 - 3], $$[$0]]);
|
|
667
592
|
break;
|
|
668
593
|
case 10:
|
|
669
|
-
this.$ = yy.evaluateByOperator(
|
|
594
|
+
this.$ = yy.evaluateByOperator(">=", [$$[$0 - 3], $$[$0]]);
|
|
670
595
|
break;
|
|
671
596
|
case 11:
|
|
672
|
-
this.$ = yy.evaluateByOperator(
|
|
597
|
+
this.$ = yy.evaluateByOperator("<>", [$$[$0 - 3], $$[$0]]);
|
|
673
598
|
break;
|
|
674
599
|
case 12:
|
|
675
|
-
this.$ = yy.evaluateByOperator(
|
|
600
|
+
this.$ = yy.evaluateByOperator("NOT", [$$[$0 - 2], $$[$0]]);
|
|
676
601
|
break;
|
|
677
602
|
case 13:
|
|
678
|
-
this.$ = yy.evaluateByOperator(
|
|
603
|
+
this.$ = yy.evaluateByOperator(">", [$$[$0 - 2], $$[$0]]);
|
|
679
604
|
break;
|
|
680
605
|
case 14:
|
|
681
|
-
this.$ = yy.evaluateByOperator(
|
|
606
|
+
this.$ = yy.evaluateByOperator("<", [$$[$0 - 2], $$[$0]]);
|
|
682
607
|
break;
|
|
683
608
|
case 15:
|
|
684
|
-
this.$ = yy.evaluateByOperator(
|
|
609
|
+
this.$ = yy.evaluateByOperator("-", [$$[$0 - 2], $$[$0]]);
|
|
685
610
|
break;
|
|
686
611
|
case 16:
|
|
687
|
-
this.$ = yy.evaluateByOperator(
|
|
612
|
+
this.$ = yy.evaluateByOperator("*", [$$[$0 - 2], $$[$0]]);
|
|
688
613
|
break;
|
|
689
614
|
case 17:
|
|
690
|
-
this.$ = yy.evaluateByOperator(
|
|
615
|
+
this.$ = yy.evaluateByOperator("/", [$$[$0 - 2], $$[$0]]);
|
|
691
616
|
break;
|
|
692
617
|
case 18:
|
|
693
|
-
this.$ = yy.evaluateByOperator(
|
|
618
|
+
this.$ = yy.evaluateByOperator("^", [$$[$0 - 2], $$[$0]]);
|
|
694
619
|
break;
|
|
695
620
|
case 19:
|
|
696
621
|
var n1 = yy.invertNumber($$[$0]);
|
|
@@ -733,7 +658,7 @@ var parser = {
|
|
|
733
658
|
this.$ = [$$[$0]];
|
|
734
659
|
break;
|
|
735
660
|
case 39:
|
|
736
|
-
this.$ = yy.trimEdges(yytext).split(
|
|
661
|
+
this.$ = yy.trimEdges(yytext).split(",");
|
|
737
662
|
break;
|
|
738
663
|
case 40:
|
|
739
664
|
case 41:
|
|
@@ -748,7 +673,7 @@ var parser = {
|
|
|
748
673
|
this.$ = $$[$0];
|
|
749
674
|
break;
|
|
750
675
|
case 45:
|
|
751
|
-
this.$ = ($$[$0 - 2] +
|
|
676
|
+
this.$ = ($$[$0 - 2] + "." + $$[$0]) * 1;
|
|
752
677
|
break;
|
|
753
678
|
case 46:
|
|
754
679
|
this.$ = $$[$0 - 1] * 0.01;
|
|
@@ -1308,7 +1233,7 @@ var parser = {
|
|
|
1308
1233
|
lstack = [],
|
|
1309
1234
|
// location stack
|
|
1310
1235
|
table = this.table,
|
|
1311
|
-
yytext =
|
|
1236
|
+
yytext = "",
|
|
1312
1237
|
yylineno = 0,
|
|
1313
1238
|
yyleng = 0,
|
|
1314
1239
|
recovering = 0,
|
|
@@ -1317,7 +1242,6 @@ var parser = {
|
|
|
1317
1242
|
var args = lstack.slice.call(arguments, 1);
|
|
1318
1243
|
|
|
1319
1244
|
//this.reductionCount = this.shiftCount = 0;
|
|
1320
|
-
|
|
1321
1245
|
var lexer = Object.create(this.lexer);
|
|
1322
1246
|
var sharedState = {
|
|
1323
1247
|
yy: {}
|
|
@@ -1331,13 +1255,13 @@ var parser = {
|
|
|
1331
1255
|
lexer.setInput(input, sharedState.yy);
|
|
1332
1256
|
sharedState.yy.lexer = lexer;
|
|
1333
1257
|
sharedState.yy.parser = this;
|
|
1334
|
-
if (typeof lexer.yylloc ==
|
|
1258
|
+
if (typeof lexer.yylloc == "undefined") {
|
|
1335
1259
|
lexer.yylloc = {};
|
|
1336
1260
|
}
|
|
1337
1261
|
var yyloc = lexer.yylloc;
|
|
1338
1262
|
lstack.push(yyloc);
|
|
1339
1263
|
var ranges = lexer.options && lexer.options.ranges;
|
|
1340
|
-
if (typeof sharedState.yy.parseError ===
|
|
1264
|
+
if (typeof sharedState.yy.parseError === "function") {
|
|
1341
1265
|
this.parseError = sharedState.yy.parseError;
|
|
1342
1266
|
} else {
|
|
1343
1267
|
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
@@ -1351,7 +1275,7 @@ var parser = {
|
|
|
1351
1275
|
var token;
|
|
1352
1276
|
token = lexer.lex() || EOF;
|
|
1353
1277
|
// if token isn't its numeric value, convert
|
|
1354
|
-
if (typeof token !==
|
|
1278
|
+
if (typeof token !== "number") {
|
|
1355
1279
|
token = self.symbols_[token] || token;
|
|
1356
1280
|
}
|
|
1357
1281
|
return token;
|
|
@@ -1372,18 +1296,18 @@ var parser = {
|
|
|
1372
1296
|
state = stack[stack.length - 1];
|
|
1373
1297
|
|
|
1374
1298
|
// use default actions if available
|
|
1299
|
+
|
|
1375
1300
|
if (_this.defaultActions[state]) {
|
|
1376
1301
|
action = _this.defaultActions[state];
|
|
1377
1302
|
} else {
|
|
1378
|
-
if (symbol === null || typeof symbol ==
|
|
1303
|
+
if (symbol === null || typeof symbol == "undefined") {
|
|
1379
1304
|
symbol = lex();
|
|
1380
1305
|
}
|
|
1381
1306
|
// read action for current state and first input
|
|
1382
1307
|
action = table[state] && table[state][symbol];
|
|
1383
1308
|
}
|
|
1384
|
-
|
|
1385
1309
|
// handle parse error
|
|
1386
|
-
if (typeof action ===
|
|
1310
|
+
if (typeof action === "undefined" || !action.length || !action[0]) {
|
|
1387
1311
|
// Return the rule stack depth where the nearest error rule can be found.
|
|
1388
1312
|
// Return FALSE when no error recovery rule was found.
|
|
1389
1313
|
var locateNearestErrorRecoveryRule = function locateNearestErrorRecoveryRule(state) {
|
|
@@ -1404,7 +1328,7 @@ var parser = {
|
|
|
1404
1328
|
++depth;
|
|
1405
1329
|
}
|
|
1406
1330
|
};
|
|
1407
|
-
errStr =
|
|
1331
|
+
errStr = "";
|
|
1408
1332
|
if (!recovering) {
|
|
1409
1333
|
// first see if there's any chance at hitting an error recovery rule:
|
|
1410
1334
|
error_rule_depth = locateNearestErrorRecoveryRule(state);
|
|
@@ -1417,9 +1341,9 @@ var parser = {
|
|
|
1417
1341
|
}
|
|
1418
1342
|
}
|
|
1419
1343
|
if (lexer.showPosition) {
|
|
1420
|
-
errStr =
|
|
1344
|
+
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (_this.terminals_[symbol] || symbol) + "'";
|
|
1421
1345
|
} else {
|
|
1422
|
-
errStr =
|
|
1346
|
+
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (_this.terminals_[symbol] || symbol) + "'");
|
|
1423
1347
|
}
|
|
1424
1348
|
_this.parseError(errStr, {
|
|
1425
1349
|
text: lexer.match,
|
|
@@ -1436,7 +1360,7 @@ var parser = {
|
|
|
1436
1360
|
// just recovered from another error
|
|
1437
1361
|
if (recovering == 3) {
|
|
1438
1362
|
if (symbol === EOF || preErrorSymbol === EOF) {
|
|
1439
|
-
throw new Error(errStr ||
|
|
1363
|
+
throw new Error(errStr || "Parsing halted while starting to recover from another error.");
|
|
1440
1364
|
}
|
|
1441
1365
|
|
|
1442
1366
|
// discard current lookahead and grab another
|
|
@@ -1449,7 +1373,7 @@ var parser = {
|
|
|
1449
1373
|
|
|
1450
1374
|
// try to recover from error
|
|
1451
1375
|
if (error_rule_depth === false) {
|
|
1452
|
-
throw new Error(errStr ||
|
|
1376
|
+
throw new Error(errStr || "Parsing halted. No suitable error recovery rule available.");
|
|
1453
1377
|
}
|
|
1454
1378
|
popStack(error_rule_depth);
|
|
1455
1379
|
preErrorSymbol = symbol == TERROR ? null : symbol; // save the lookahead token
|
|
@@ -1458,10 +1382,9 @@ var parser = {
|
|
|
1458
1382
|
action = table[state] && table[state][TERROR];
|
|
1459
1383
|
recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
|
|
1460
1384
|
}
|
|
1461
|
-
|
|
1462
1385
|
// this shouldn't happen, unless resolve defaults are off
|
|
1463
1386
|
if (action[0] instanceof Array && action.length > 1) {
|
|
1464
|
-
throw new Error(
|
|
1387
|
+
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
|
1465
1388
|
}
|
|
1466
1389
|
switch (action[0]) {
|
|
1467
1390
|
case 1:
|
|
@@ -1491,7 +1414,6 @@ var parser = {
|
|
|
1491
1414
|
case 2:
|
|
1492
1415
|
// reduce
|
|
1493
1416
|
//this.reductionCount++;
|
|
1494
|
-
|
|
1495
1417
|
len = _this.productions_[action[1]][1];
|
|
1496
1418
|
|
|
1497
1419
|
// perform semantic action
|
|
@@ -1507,7 +1429,7 @@ var parser = {
|
|
|
1507
1429
|
yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
|
|
1508
1430
|
}
|
|
1509
1431
|
r = _this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));
|
|
1510
|
-
if (typeof r !==
|
|
1432
|
+
if (typeof r !== "undefined") {
|
|
1511
1433
|
return {
|
|
1512
1434
|
v: r
|
|
1513
1435
|
};
|
|
@@ -1561,8 +1483,8 @@ var lexer = function () {
|
|
|
1561
1483
|
this._input = input;
|
|
1562
1484
|
this._more = this._backtrack = this.done = false;
|
|
1563
1485
|
this.yylineno = this.yyleng = 0;
|
|
1564
|
-
this.yytext = this.matched = this.match =
|
|
1565
|
-
this.conditionStack = [
|
|
1486
|
+
this.yytext = this.matched = this.match = "";
|
|
1487
|
+
this.conditionStack = ["INITIAL"];
|
|
1566
1488
|
this.yylloc = {
|
|
1567
1489
|
first_line: 1,
|
|
1568
1490
|
first_column: 0,
|
|
@@ -1633,7 +1555,7 @@ var lexer = function () {
|
|
|
1633
1555
|
if (this.options.backtrack_lexer) {
|
|
1634
1556
|
this._backtrack = true;
|
|
1635
1557
|
} else {
|
|
1636
|
-
return this.parseError(
|
|
1558
|
+
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
|
|
1637
1559
|
text: "",
|
|
1638
1560
|
token: null,
|
|
1639
1561
|
line: this.yylineno
|
|
@@ -1648,7 +1570,7 @@ var lexer = function () {
|
|
|
1648
1570
|
// displays already matched input, i.e. for error messages
|
|
1649
1571
|
pastInput: function pastInput() {
|
|
1650
1572
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
1651
|
-
return (past.length > 20 ?
|
|
1573
|
+
return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
|
1652
1574
|
},
|
|
1653
1575
|
// displays upcoming input, i.e. for error messages
|
|
1654
1576
|
upcomingInput: function upcomingInput() {
|
|
@@ -1656,7 +1578,7 @@ var lexer = function () {
|
|
|
1656
1578
|
if (next.length < 20) {
|
|
1657
1579
|
next += this._input.substr(0, 20 - next.length);
|
|
1658
1580
|
}
|
|
1659
|
-
return (next.substr(0, 20) + (next.length > 20 ?
|
|
1581
|
+
return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
|
1660
1582
|
},
|
|
1661
1583
|
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
1662
1584
|
showPosition: function showPosition() {
|
|
@@ -1739,8 +1661,8 @@ var lexer = function () {
|
|
|
1739
1661
|
}
|
|
1740
1662
|
var token, match, tempMatch, index;
|
|
1741
1663
|
if (!this._more) {
|
|
1742
|
-
this.yytext =
|
|
1743
|
-
this.match =
|
|
1664
|
+
this.yytext = "";
|
|
1665
|
+
this.match = "";
|
|
1744
1666
|
}
|
|
1745
1667
|
var rules = this._currentRules();
|
|
1746
1668
|
for (var i = 0; i < rules.length; i++) {
|
|
@@ -1780,7 +1702,7 @@ var lexer = function () {
|
|
|
1780
1702
|
if (this._input === "") {
|
|
1781
1703
|
return this.EOF;
|
|
1782
1704
|
} else {
|
|
1783
|
-
return this.parseError(
|
|
1705
|
+
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
|
1784
1706
|
text: "",
|
|
1785
1707
|
token: null,
|
|
1786
1708
|
line: this.yylineno
|
|
@@ -1837,8 +1759,7 @@ var lexer = function () {
|
|
|
1837
1759
|
options: {},
|
|
1838
1760
|
performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
|
1839
1761
|
switch ($avoiding_name_collisions) {
|
|
1840
|
-
case 0
|
|
1841
|
-
/* skip whitespace */
|
|
1762
|
+
case 0 /* skip whitespace */:
|
|
1842
1763
|
break;
|
|
1843
1764
|
case 1:
|
|
1844
1765
|
return 8;
|
|
@@ -1869,7 +1790,7 @@ var lexer = function () {
|
|
|
1869
1790
|
case 14:
|
|
1870
1791
|
return 9;
|
|
1871
1792
|
case 15:
|
|
1872
|
-
return
|
|
1793
|
+
return " ";
|
|
1873
1794
|
case 16:
|
|
1874
1795
|
return 32;
|
|
1875
1796
|
case 17:
|
|
@@ -1909,16 +1830,16 @@ var lexer = function () {
|
|
|
1909
1830
|
case 34:
|
|
1910
1831
|
return 34;
|
|
1911
1832
|
case 35:
|
|
1912
|
-
return
|
|
1833
|
+
return "#";
|
|
1913
1834
|
case 36:
|
|
1914
1835
|
return 5;
|
|
1915
1836
|
}
|
|
1916
1837
|
},
|
|
1917
1838
|
rules: [/^(?:\s+)/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*'[^'!])/, /^(?:[A-Za-z]{1,}[A-Za-z_0-9\.]+(?=[(]))/, /^(?:#[A-Z0-9\/]+(!|\?)?)/, ABSOLUTE_CELL, MIXED_CELL_COL, MIXED_CELL_ROW, RELATIVE_CELL, /^(?:[A-Za-z\.]+(?=[(]))/, /^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)/, /^(?:[A-Za-z_]+)/, /^(?:[0-9]+)/, /^(?:\[(.*)?\])/, /^(?:&)/, /^(?: )/, /^(?:[.])/, /^(?::)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\()/, /^(?:\))/, /^(?:>)/, /^(?:<)/, /^(?:NOT\b)/, /^(?:")/, /^(?:')/, /^(?:!)/, /^(?:=)/, /^(?:%)/, /^(?:[#])/, /^(?:$)/],
|
|
1918
1839
|
conditions: {
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1840
|
+
INITIAL: {
|
|
1841
|
+
rules: [0, 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],
|
|
1842
|
+
inclusive: true
|
|
1922
1843
|
}
|
|
1923
1844
|
}
|
|
1924
1845
|
};
|
|
@@ -1968,13 +1889,13 @@ function rowLabelToIndex(label) {
|
|
|
1968
1889
|
* @returns {String} Returns row label (eq. '1', '7').
|
|
1969
1890
|
*/
|
|
1970
1891
|
function rowIndexToLabel(row) {
|
|
1971
|
-
var result =
|
|
1892
|
+
var result = "";
|
|
1972
1893
|
if (row >= 0) {
|
|
1973
1894
|
result = "".concat(row + 1);
|
|
1974
1895
|
}
|
|
1975
1896
|
return result;
|
|
1976
1897
|
}
|
|
1977
|
-
var COLUMN_LABEL_BASE =
|
|
1898
|
+
var COLUMN_LABEL_BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
1978
1899
|
var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
|
|
1979
1900
|
|
|
1980
1901
|
/**
|
|
@@ -1985,7 +1906,7 @@ var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
|
|
|
1985
1906
|
*/
|
|
1986
1907
|
function columnLabelToIndex(label) {
|
|
1987
1908
|
var result = 0;
|
|
1988
|
-
if (typeof label ===
|
|
1909
|
+
if (typeof label === "string") {
|
|
1989
1910
|
label = label.toUpperCase();
|
|
1990
1911
|
for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
|
|
1991
1912
|
result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
|
|
@@ -2002,14 +1923,14 @@ function columnLabelToIndex(label) {
|
|
|
2002
1923
|
* @returns {String} Returns column label (eq. 'ABB', 'CNQ').
|
|
2003
1924
|
*/
|
|
2004
1925
|
function columnIndexToLabel(column) {
|
|
2005
|
-
var result =
|
|
1926
|
+
var result = "";
|
|
2006
1927
|
while (column >= 0) {
|
|
2007
1928
|
result = String.fromCharCode(column % COLUMN_LABEL_BASE_LENGTH + 97) + result;
|
|
2008
1929
|
column = Math.floor(column / COLUMN_LABEL_BASE_LENGTH) - 1;
|
|
2009
1930
|
}
|
|
2010
1931
|
return result.toUpperCase();
|
|
2011
1932
|
}
|
|
2012
|
-
var simpleSheetName$1 = "[A-Za-z0-9_\
|
|
1933
|
+
var simpleSheetName$1 = "[A-Za-z0-9_\u4E00-\u9FFF]+";
|
|
2013
1934
|
var quotedSheetName$1 = "'(?:(?!').|'')*'";
|
|
2014
1935
|
var sheetNameRegexp$1 = "(".concat(simpleSheetName$1, "|").concat(quotedSheetName$1, ")!");
|
|
2015
1936
|
var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
|
|
@@ -2021,7 +1942,7 @@ var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?
|
|
|
2021
1942
|
* @returns {Array} Returns an array of objects.
|
|
2022
1943
|
*/
|
|
2023
1944
|
function extractLabel(label) {
|
|
2024
|
-
if (typeof label !==
|
|
1945
|
+
if (typeof label !== "string" || !LABEL_EXTRACT_REGEXP.test(label)) {
|
|
2025
1946
|
return [];
|
|
2026
1947
|
}
|
|
2027
1948
|
var _label$toUpperCase$ma = label.toUpperCase().match(LABEL_EXTRACT_REGEXP),
|
|
@@ -2036,11 +1957,11 @@ function extractLabel(label) {
|
|
|
2036
1957
|
return [{
|
|
2037
1958
|
index: rowLabelToIndex(row),
|
|
2038
1959
|
label: row,
|
|
2039
|
-
isAbsolute: rowAbs ===
|
|
1960
|
+
isAbsolute: rowAbs === "$"
|
|
2040
1961
|
}, {
|
|
2041
1962
|
index: columnLabelToIndex(column),
|
|
2042
1963
|
label: column,
|
|
2043
|
-
isAbsolute: columnAbs ===
|
|
1964
|
+
isAbsolute: columnAbs === "$"
|
|
2044
1965
|
}, sheetName];
|
|
2045
1966
|
}
|
|
2046
1967
|
|
|
@@ -2052,8 +1973,8 @@ function extractLabel(label) {
|
|
|
2052
1973
|
* @returns {String} Returns cell label.
|
|
2053
1974
|
*/
|
|
2054
1975
|
function toLabel(row, column) {
|
|
2055
|
-
var rowLabel = (row.isAbsolute ?
|
|
2056
|
-
var columnLabel = (column.isAbsolute ?
|
|
1976
|
+
var rowLabel = (row.isAbsolute ? "$" : "") + rowIndexToLabel(row.index);
|
|
1977
|
+
var columnLabel = (column.isAbsolute ? "$" : "") + columnIndexToLabel(column.index);
|
|
2057
1978
|
return columnLabel + rowLabel;
|
|
2058
1979
|
}
|
|
2059
1980
|
|
|
@@ -2090,7 +2011,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2090
2011
|
_this.variables = Object.create(null);
|
|
2091
2012
|
_this.functions = Object.create(null);
|
|
2092
2013
|
_this.options = Object.create(null);
|
|
2093
|
-
_this.setVariable(
|
|
2014
|
+
_this.setVariable("TRUE", true).setVariable("FALSE", false).setVariable("NULL", null);
|
|
2094
2015
|
return _this;
|
|
2095
2016
|
}
|
|
2096
2017
|
|
|
@@ -2110,8 +2031,8 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2110
2031
|
var error$1 = null;
|
|
2111
2032
|
this.options = options;
|
|
2112
2033
|
try {
|
|
2113
|
-
if (expression ===
|
|
2114
|
-
result =
|
|
2034
|
+
if (expression === "") {
|
|
2035
|
+
result = "";
|
|
2115
2036
|
} else {
|
|
2116
2037
|
result = this.parser.parse(expression);
|
|
2117
2038
|
}
|
|
@@ -2170,7 +2091,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2170
2091
|
key: "_callVariable",
|
|
2171
2092
|
value: function _callVariable(name) {
|
|
2172
2093
|
var value = this.getVariable(name);
|
|
2173
|
-
this.emit(
|
|
2094
|
+
this.emit("callVariable", name, function (newValue) {
|
|
2174
2095
|
if (newValue !== void 0) {
|
|
2175
2096
|
value = newValue;
|
|
2176
2097
|
}
|
|
@@ -2224,7 +2145,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2224
2145
|
if (fn) {
|
|
2225
2146
|
value = fn(params);
|
|
2226
2147
|
}
|
|
2227
|
-
this.emit(
|
|
2148
|
+
this.emit("callFunction", name, params, function (newValue) {
|
|
2228
2149
|
if (newValue !== void 0) {
|
|
2229
2150
|
value = newValue;
|
|
2230
2151
|
}
|
|
@@ -2256,7 +2177,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2256
2177
|
throw Error(ERROR_NAME);
|
|
2257
2178
|
}
|
|
2258
2179
|
var value = void 0;
|
|
2259
|
-
this.emit(
|
|
2180
|
+
this.emit("callCellValue", {
|
|
2260
2181
|
label: label,
|
|
2261
2182
|
row: row,
|
|
2262
2183
|
column: column,
|
|
@@ -2311,7 +2232,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2311
2232
|
startCell.label = toLabel(startCell.row, startCell.column);
|
|
2312
2233
|
endCell.label = toLabel(endCell.row, endCell.column);
|
|
2313
2234
|
var value = [];
|
|
2314
|
-
this.emit(
|
|
2235
|
+
this.emit("callRangeValue", startCell, endCell, this.options, function () {
|
|
2315
2236
|
var _value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2316
2237
|
value = _value;
|
|
2317
2238
|
});
|
package/dist/index.js
CHANGED
|
@@ -476,82 +476,7 @@ registerOperation(func$a.SYMBOL, func$a);
|
|
|
476
476
|
registerOperation(func$b.SYMBOL, func$b);
|
|
477
477
|
registerOperation(func$9.SYMBOL, func$9);
|
|
478
478
|
|
|
479
|
-
|
|
480
|
-
/*
|
|
481
|
-
Returns a Parser object of the following structure:
|
|
482
|
-
|
|
483
|
-
Parser: {
|
|
484
|
-
yy: {}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
Parser.prototype: {
|
|
488
|
-
yy: {},
|
|
489
|
-
trace: function(),
|
|
490
|
-
symbols_: {associative list: name ==> number},
|
|
491
|
-
terminals_: {associative list: number ==> name},
|
|
492
|
-
productions_: [...],
|
|
493
|
-
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
|
494
|
-
table: [...],
|
|
495
|
-
defaultActions: {...},
|
|
496
|
-
parseError: function(str, hash),
|
|
497
|
-
parse: function(input),
|
|
498
|
-
|
|
499
|
-
lexer: {
|
|
500
|
-
EOF: 1,
|
|
501
|
-
parseError: function(str, hash),
|
|
502
|
-
setInput: function(input),
|
|
503
|
-
input: function(),
|
|
504
|
-
unput: function(str),
|
|
505
|
-
more: function(),
|
|
506
|
-
less: function(n),
|
|
507
|
-
pastInput: function(),
|
|
508
|
-
upcomingInput: function(),
|
|
509
|
-
showPosition: function(),
|
|
510
|
-
test_match: function(regex_match_array, rule_index),
|
|
511
|
-
next: function(),
|
|
512
|
-
lex: function(),
|
|
513
|
-
begin: function(condition),
|
|
514
|
-
popState: function(),
|
|
515
|
-
_currentRules: function(),
|
|
516
|
-
topState: function(),
|
|
517
|
-
pushState: function(condition),
|
|
518
|
-
|
|
519
|
-
options: {
|
|
520
|
-
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
|
521
|
-
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
|
522
|
-
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
|
523
|
-
},
|
|
524
|
-
|
|
525
|
-
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
|
526
|
-
rules: [...],
|
|
527
|
-
conditions: {associative list: name ==> set},
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
token location info (@$, _$, etc.): {
|
|
533
|
-
first_line: n,
|
|
534
|
-
last_line: n,
|
|
535
|
-
first_column: n,
|
|
536
|
-
last_column: n,
|
|
537
|
-
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
|
542
|
-
text: (matched text)
|
|
543
|
-
token: (the produced terminal token, if any)
|
|
544
|
-
line: (yylineno)
|
|
545
|
-
}
|
|
546
|
-
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
|
547
|
-
loc: (yylloc)
|
|
548
|
-
expected: (string describing the set of expected tokens)
|
|
549
|
-
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
|
550
|
-
}
|
|
551
|
-
*/
|
|
552
|
-
|
|
553
|
-
/* addresses */
|
|
554
|
-
var simpleSheetName = "[A-Za-z0-9_\xC0-\u02AF]+";
|
|
479
|
+
var simpleSheetName = "[A-Za-z0-9_\u4E00-\u9FFF]+";
|
|
555
480
|
var quotedSheetName = "'(?:(?!').|'')*'";
|
|
556
481
|
var sheetNameRegexp = "(?:".concat(simpleSheetName, "|").concat(quotedSheetName, ")!");
|
|
557
482
|
var ABSOLUTE_CELL = new RegExp("^(?:".concat(sheetNameRegexp, ")?(?:[$][A-Za-z]+[$][0-9]+)"));
|
|
@@ -596,13 +521,13 @@ var parser = {
|
|
|
596
521
|
trace: function trace() {},
|
|
597
522
|
yy: {},
|
|
598
523
|
symbols_: {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
524
|
+
error: 2,
|
|
525
|
+
expressions: 3,
|
|
526
|
+
expression: 4,
|
|
527
|
+
EOF: 5,
|
|
528
|
+
variableSequence: 6,
|
|
529
|
+
number: 7,
|
|
530
|
+
STRING: 8,
|
|
606
531
|
"&": 9,
|
|
607
532
|
"=": 10,
|
|
608
533
|
"+": 11,
|
|
@@ -610,28 +535,28 @@ var parser = {
|
|
|
610
535
|
")": 13,
|
|
611
536
|
"<": 14,
|
|
612
537
|
">": 15,
|
|
613
|
-
|
|
538
|
+
NOT: 16,
|
|
614
539
|
"-": 17,
|
|
615
540
|
"*": 18,
|
|
616
541
|
"/": 19,
|
|
617
542
|
"^": 20,
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
543
|
+
FUNCTION: 21,
|
|
544
|
+
expseq: 22,
|
|
545
|
+
cell: 23,
|
|
546
|
+
ABSOLUTE_CELL: 24,
|
|
547
|
+
RELATIVE_CELL: 25,
|
|
548
|
+
MIXED_CELL: 26,
|
|
624
549
|
":": 27,
|
|
625
|
-
|
|
550
|
+
ARRAY: 28,
|
|
626
551
|
";": 29,
|
|
627
552
|
",": 30,
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
553
|
+
VARIABLE: 31,
|
|
554
|
+
DECIMAL: 32,
|
|
555
|
+
NUMBER: 33,
|
|
631
556
|
"%": 34,
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
557
|
+
ERROR: 35,
|
|
558
|
+
$accept: 0,
|
|
559
|
+
$end: 1
|
|
635
560
|
},
|
|
636
561
|
terminals_: {
|
|
637
562
|
5: "EOF",
|
|
@@ -680,46 +605,46 @@ var parser = {
|
|
|
680
605
|
this.$ = yy.trimEdges($$[$0]);
|
|
681
606
|
break;
|
|
682
607
|
case 5:
|
|
683
|
-
this.$ = yy.evaluateByOperator(
|
|
608
|
+
this.$ = yy.evaluateByOperator("&", [$$[$0 - 2], $$[$0]]);
|
|
684
609
|
break;
|
|
685
610
|
case 6:
|
|
686
|
-
this.$ = yy.evaluateByOperator(
|
|
611
|
+
this.$ = yy.evaluateByOperator("=", [$$[$0 - 2], $$[$0]]);
|
|
687
612
|
break;
|
|
688
613
|
case 7:
|
|
689
|
-
this.$ = yy.evaluateByOperator(
|
|
614
|
+
this.$ = yy.evaluateByOperator("+", [$$[$0 - 2], $$[$0]]);
|
|
690
615
|
break;
|
|
691
616
|
case 8:
|
|
692
617
|
this.$ = $$[$0 - 1];
|
|
693
618
|
break;
|
|
694
619
|
case 9:
|
|
695
|
-
this.$ = yy.evaluateByOperator(
|
|
620
|
+
this.$ = yy.evaluateByOperator("<=", [$$[$0 - 3], $$[$0]]);
|
|
696
621
|
break;
|
|
697
622
|
case 10:
|
|
698
|
-
this.$ = yy.evaluateByOperator(
|
|
623
|
+
this.$ = yy.evaluateByOperator(">=", [$$[$0 - 3], $$[$0]]);
|
|
699
624
|
break;
|
|
700
625
|
case 11:
|
|
701
|
-
this.$ = yy.evaluateByOperator(
|
|
626
|
+
this.$ = yy.evaluateByOperator("<>", [$$[$0 - 3], $$[$0]]);
|
|
702
627
|
break;
|
|
703
628
|
case 12:
|
|
704
|
-
this.$ = yy.evaluateByOperator(
|
|
629
|
+
this.$ = yy.evaluateByOperator("NOT", [$$[$0 - 2], $$[$0]]);
|
|
705
630
|
break;
|
|
706
631
|
case 13:
|
|
707
|
-
this.$ = yy.evaluateByOperator(
|
|
632
|
+
this.$ = yy.evaluateByOperator(">", [$$[$0 - 2], $$[$0]]);
|
|
708
633
|
break;
|
|
709
634
|
case 14:
|
|
710
|
-
this.$ = yy.evaluateByOperator(
|
|
635
|
+
this.$ = yy.evaluateByOperator("<", [$$[$0 - 2], $$[$0]]);
|
|
711
636
|
break;
|
|
712
637
|
case 15:
|
|
713
|
-
this.$ = yy.evaluateByOperator(
|
|
638
|
+
this.$ = yy.evaluateByOperator("-", [$$[$0 - 2], $$[$0]]);
|
|
714
639
|
break;
|
|
715
640
|
case 16:
|
|
716
|
-
this.$ = yy.evaluateByOperator(
|
|
641
|
+
this.$ = yy.evaluateByOperator("*", [$$[$0 - 2], $$[$0]]);
|
|
717
642
|
break;
|
|
718
643
|
case 17:
|
|
719
|
-
this.$ = yy.evaluateByOperator(
|
|
644
|
+
this.$ = yy.evaluateByOperator("/", [$$[$0 - 2], $$[$0]]);
|
|
720
645
|
break;
|
|
721
646
|
case 18:
|
|
722
|
-
this.$ = yy.evaluateByOperator(
|
|
647
|
+
this.$ = yy.evaluateByOperator("^", [$$[$0 - 2], $$[$0]]);
|
|
723
648
|
break;
|
|
724
649
|
case 19:
|
|
725
650
|
var n1 = yy.invertNumber($$[$0]);
|
|
@@ -762,7 +687,7 @@ var parser = {
|
|
|
762
687
|
this.$ = [$$[$0]];
|
|
763
688
|
break;
|
|
764
689
|
case 39:
|
|
765
|
-
this.$ = yy.trimEdges(yytext).split(
|
|
690
|
+
this.$ = yy.trimEdges(yytext).split(",");
|
|
766
691
|
break;
|
|
767
692
|
case 40:
|
|
768
693
|
case 41:
|
|
@@ -777,7 +702,7 @@ var parser = {
|
|
|
777
702
|
this.$ = $$[$0];
|
|
778
703
|
break;
|
|
779
704
|
case 45:
|
|
780
|
-
this.$ = ($$[$0 - 2] +
|
|
705
|
+
this.$ = ($$[$0 - 2] + "." + $$[$0]) * 1;
|
|
781
706
|
break;
|
|
782
707
|
case 46:
|
|
783
708
|
this.$ = $$[$0 - 1] * 0.01;
|
|
@@ -1337,7 +1262,7 @@ var parser = {
|
|
|
1337
1262
|
lstack = [],
|
|
1338
1263
|
// location stack
|
|
1339
1264
|
table = this.table,
|
|
1340
|
-
yytext =
|
|
1265
|
+
yytext = "",
|
|
1341
1266
|
yylineno = 0,
|
|
1342
1267
|
yyleng = 0,
|
|
1343
1268
|
recovering = 0,
|
|
@@ -1346,7 +1271,6 @@ var parser = {
|
|
|
1346
1271
|
var args = lstack.slice.call(arguments, 1);
|
|
1347
1272
|
|
|
1348
1273
|
//this.reductionCount = this.shiftCount = 0;
|
|
1349
|
-
|
|
1350
1274
|
var lexer = Object.create(this.lexer);
|
|
1351
1275
|
var sharedState = {
|
|
1352
1276
|
yy: {}
|
|
@@ -1360,13 +1284,13 @@ var parser = {
|
|
|
1360
1284
|
lexer.setInput(input, sharedState.yy);
|
|
1361
1285
|
sharedState.yy.lexer = lexer;
|
|
1362
1286
|
sharedState.yy.parser = this;
|
|
1363
|
-
if (typeof lexer.yylloc ==
|
|
1287
|
+
if (typeof lexer.yylloc == "undefined") {
|
|
1364
1288
|
lexer.yylloc = {};
|
|
1365
1289
|
}
|
|
1366
1290
|
var yyloc = lexer.yylloc;
|
|
1367
1291
|
lstack.push(yyloc);
|
|
1368
1292
|
var ranges = lexer.options && lexer.options.ranges;
|
|
1369
|
-
if (typeof sharedState.yy.parseError ===
|
|
1293
|
+
if (typeof sharedState.yy.parseError === "function") {
|
|
1370
1294
|
this.parseError = sharedState.yy.parseError;
|
|
1371
1295
|
} else {
|
|
1372
1296
|
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
@@ -1380,7 +1304,7 @@ var parser = {
|
|
|
1380
1304
|
var token;
|
|
1381
1305
|
token = lexer.lex() || EOF;
|
|
1382
1306
|
// if token isn't its numeric value, convert
|
|
1383
|
-
if (typeof token !==
|
|
1307
|
+
if (typeof token !== "number") {
|
|
1384
1308
|
token = self.symbols_[token] || token;
|
|
1385
1309
|
}
|
|
1386
1310
|
return token;
|
|
@@ -1401,18 +1325,18 @@ var parser = {
|
|
|
1401
1325
|
state = stack[stack.length - 1];
|
|
1402
1326
|
|
|
1403
1327
|
// use default actions if available
|
|
1328
|
+
|
|
1404
1329
|
if (_this.defaultActions[state]) {
|
|
1405
1330
|
action = _this.defaultActions[state];
|
|
1406
1331
|
} else {
|
|
1407
|
-
if (symbol === null || typeof symbol ==
|
|
1332
|
+
if (symbol === null || typeof symbol == "undefined") {
|
|
1408
1333
|
symbol = lex();
|
|
1409
1334
|
}
|
|
1410
1335
|
// read action for current state and first input
|
|
1411
1336
|
action = table[state] && table[state][symbol];
|
|
1412
1337
|
}
|
|
1413
|
-
|
|
1414
1338
|
// handle parse error
|
|
1415
|
-
if (typeof action ===
|
|
1339
|
+
if (typeof action === "undefined" || !action.length || !action[0]) {
|
|
1416
1340
|
// Return the rule stack depth where the nearest error rule can be found.
|
|
1417
1341
|
// Return FALSE when no error recovery rule was found.
|
|
1418
1342
|
var locateNearestErrorRecoveryRule = function locateNearestErrorRecoveryRule(state) {
|
|
@@ -1433,7 +1357,7 @@ var parser = {
|
|
|
1433
1357
|
++depth;
|
|
1434
1358
|
}
|
|
1435
1359
|
};
|
|
1436
|
-
errStr =
|
|
1360
|
+
errStr = "";
|
|
1437
1361
|
if (!recovering) {
|
|
1438
1362
|
// first see if there's any chance at hitting an error recovery rule:
|
|
1439
1363
|
error_rule_depth = locateNearestErrorRecoveryRule(state);
|
|
@@ -1446,9 +1370,9 @@ var parser = {
|
|
|
1446
1370
|
}
|
|
1447
1371
|
}
|
|
1448
1372
|
if (lexer.showPosition) {
|
|
1449
|
-
errStr =
|
|
1373
|
+
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (_this.terminals_[symbol] || symbol) + "'";
|
|
1450
1374
|
} else {
|
|
1451
|
-
errStr =
|
|
1375
|
+
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (_this.terminals_[symbol] || symbol) + "'");
|
|
1452
1376
|
}
|
|
1453
1377
|
_this.parseError(errStr, {
|
|
1454
1378
|
text: lexer.match,
|
|
@@ -1465,7 +1389,7 @@ var parser = {
|
|
|
1465
1389
|
// just recovered from another error
|
|
1466
1390
|
if (recovering == 3) {
|
|
1467
1391
|
if (symbol === EOF || preErrorSymbol === EOF) {
|
|
1468
|
-
throw new Error(errStr ||
|
|
1392
|
+
throw new Error(errStr || "Parsing halted while starting to recover from another error.");
|
|
1469
1393
|
}
|
|
1470
1394
|
|
|
1471
1395
|
// discard current lookahead and grab another
|
|
@@ -1478,7 +1402,7 @@ var parser = {
|
|
|
1478
1402
|
|
|
1479
1403
|
// try to recover from error
|
|
1480
1404
|
if (error_rule_depth === false) {
|
|
1481
|
-
throw new Error(errStr ||
|
|
1405
|
+
throw new Error(errStr || "Parsing halted. No suitable error recovery rule available.");
|
|
1482
1406
|
}
|
|
1483
1407
|
popStack(error_rule_depth);
|
|
1484
1408
|
preErrorSymbol = symbol == TERROR ? null : symbol; // save the lookahead token
|
|
@@ -1487,10 +1411,9 @@ var parser = {
|
|
|
1487
1411
|
action = table[state] && table[state][TERROR];
|
|
1488
1412
|
recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
|
|
1489
1413
|
}
|
|
1490
|
-
|
|
1491
1414
|
// this shouldn't happen, unless resolve defaults are off
|
|
1492
1415
|
if (action[0] instanceof Array && action.length > 1) {
|
|
1493
|
-
throw new Error(
|
|
1416
|
+
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
|
1494
1417
|
}
|
|
1495
1418
|
switch (action[0]) {
|
|
1496
1419
|
case 1:
|
|
@@ -1520,7 +1443,6 @@ var parser = {
|
|
|
1520
1443
|
case 2:
|
|
1521
1444
|
// reduce
|
|
1522
1445
|
//this.reductionCount++;
|
|
1523
|
-
|
|
1524
1446
|
len = _this.productions_[action[1]][1];
|
|
1525
1447
|
|
|
1526
1448
|
// perform semantic action
|
|
@@ -1536,7 +1458,7 @@ var parser = {
|
|
|
1536
1458
|
yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
|
|
1537
1459
|
}
|
|
1538
1460
|
r = _this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));
|
|
1539
|
-
if (typeof r !==
|
|
1461
|
+
if (typeof r !== "undefined") {
|
|
1540
1462
|
return {
|
|
1541
1463
|
v: r
|
|
1542
1464
|
};
|
|
@@ -1590,8 +1512,8 @@ var lexer = function () {
|
|
|
1590
1512
|
this._input = input;
|
|
1591
1513
|
this._more = this._backtrack = this.done = false;
|
|
1592
1514
|
this.yylineno = this.yyleng = 0;
|
|
1593
|
-
this.yytext = this.matched = this.match =
|
|
1594
|
-
this.conditionStack = [
|
|
1515
|
+
this.yytext = this.matched = this.match = "";
|
|
1516
|
+
this.conditionStack = ["INITIAL"];
|
|
1595
1517
|
this.yylloc = {
|
|
1596
1518
|
first_line: 1,
|
|
1597
1519
|
first_column: 0,
|
|
@@ -1662,7 +1584,7 @@ var lexer = function () {
|
|
|
1662
1584
|
if (this.options.backtrack_lexer) {
|
|
1663
1585
|
this._backtrack = true;
|
|
1664
1586
|
} else {
|
|
1665
|
-
return this.parseError(
|
|
1587
|
+
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
|
|
1666
1588
|
text: "",
|
|
1667
1589
|
token: null,
|
|
1668
1590
|
line: this.yylineno
|
|
@@ -1677,7 +1599,7 @@ var lexer = function () {
|
|
|
1677
1599
|
// displays already matched input, i.e. for error messages
|
|
1678
1600
|
pastInput: function pastInput() {
|
|
1679
1601
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
1680
|
-
return (past.length > 20 ?
|
|
1602
|
+
return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
|
1681
1603
|
},
|
|
1682
1604
|
// displays upcoming input, i.e. for error messages
|
|
1683
1605
|
upcomingInput: function upcomingInput() {
|
|
@@ -1685,7 +1607,7 @@ var lexer = function () {
|
|
|
1685
1607
|
if (next.length < 20) {
|
|
1686
1608
|
next += this._input.substr(0, 20 - next.length);
|
|
1687
1609
|
}
|
|
1688
|
-
return (next.substr(0, 20) + (next.length > 20 ?
|
|
1610
|
+
return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
|
1689
1611
|
},
|
|
1690
1612
|
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
1691
1613
|
showPosition: function showPosition() {
|
|
@@ -1768,8 +1690,8 @@ var lexer = function () {
|
|
|
1768
1690
|
}
|
|
1769
1691
|
var token, match, tempMatch, index;
|
|
1770
1692
|
if (!this._more) {
|
|
1771
|
-
this.yytext =
|
|
1772
|
-
this.match =
|
|
1693
|
+
this.yytext = "";
|
|
1694
|
+
this.match = "";
|
|
1773
1695
|
}
|
|
1774
1696
|
var rules = this._currentRules();
|
|
1775
1697
|
for (var i = 0; i < rules.length; i++) {
|
|
@@ -1809,7 +1731,7 @@ var lexer = function () {
|
|
|
1809
1731
|
if (this._input === "") {
|
|
1810
1732
|
return this.EOF;
|
|
1811
1733
|
} else {
|
|
1812
|
-
return this.parseError(
|
|
1734
|
+
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
|
1813
1735
|
text: "",
|
|
1814
1736
|
token: null,
|
|
1815
1737
|
line: this.yylineno
|
|
@@ -1866,8 +1788,7 @@ var lexer = function () {
|
|
|
1866
1788
|
options: {},
|
|
1867
1789
|
performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
|
1868
1790
|
switch ($avoiding_name_collisions) {
|
|
1869
|
-
case 0
|
|
1870
|
-
/* skip whitespace */
|
|
1791
|
+
case 0 /* skip whitespace */:
|
|
1871
1792
|
break;
|
|
1872
1793
|
case 1:
|
|
1873
1794
|
return 8;
|
|
@@ -1898,7 +1819,7 @@ var lexer = function () {
|
|
|
1898
1819
|
case 14:
|
|
1899
1820
|
return 9;
|
|
1900
1821
|
case 15:
|
|
1901
|
-
return
|
|
1822
|
+
return " ";
|
|
1902
1823
|
case 16:
|
|
1903
1824
|
return 32;
|
|
1904
1825
|
case 17:
|
|
@@ -1938,16 +1859,16 @@ var lexer = function () {
|
|
|
1938
1859
|
case 34:
|
|
1939
1860
|
return 34;
|
|
1940
1861
|
case 35:
|
|
1941
|
-
return
|
|
1862
|
+
return "#";
|
|
1942
1863
|
case 36:
|
|
1943
1864
|
return 5;
|
|
1944
1865
|
}
|
|
1945
1866
|
},
|
|
1946
1867
|
rules: [/^(?:\s+)/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*'[^'!])/, /^(?:[A-Za-z]{1,}[A-Za-z_0-9\.]+(?=[(]))/, /^(?:#[A-Z0-9\/]+(!|\?)?)/, ABSOLUTE_CELL, MIXED_CELL_COL, MIXED_CELL_ROW, RELATIVE_CELL, /^(?:[A-Za-z\.]+(?=[(]))/, /^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)/, /^(?:[A-Za-z_]+)/, /^(?:[0-9]+)/, /^(?:\[(.*)?\])/, /^(?:&)/, /^(?: )/, /^(?:[.])/, /^(?::)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\()/, /^(?:\))/, /^(?:>)/, /^(?:<)/, /^(?:NOT\b)/, /^(?:")/, /^(?:')/, /^(?:!)/, /^(?:=)/, /^(?:%)/, /^(?:[#])/, /^(?:$)/],
|
|
1947
1868
|
conditions: {
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1869
|
+
INITIAL: {
|
|
1870
|
+
rules: [0, 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],
|
|
1871
|
+
inclusive: true
|
|
1951
1872
|
}
|
|
1952
1873
|
}
|
|
1953
1874
|
};
|
|
@@ -1997,13 +1918,13 @@ function rowLabelToIndex(label) {
|
|
|
1997
1918
|
* @returns {String} Returns row label (eq. '1', '7').
|
|
1998
1919
|
*/
|
|
1999
1920
|
function rowIndexToLabel(row) {
|
|
2000
|
-
var result =
|
|
1921
|
+
var result = "";
|
|
2001
1922
|
if (row >= 0) {
|
|
2002
1923
|
result = "".concat(row + 1);
|
|
2003
1924
|
}
|
|
2004
1925
|
return result;
|
|
2005
1926
|
}
|
|
2006
|
-
var COLUMN_LABEL_BASE =
|
|
1927
|
+
var COLUMN_LABEL_BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
2007
1928
|
var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
|
|
2008
1929
|
|
|
2009
1930
|
/**
|
|
@@ -2014,7 +1935,7 @@ var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
|
|
|
2014
1935
|
*/
|
|
2015
1936
|
function columnLabelToIndex(label) {
|
|
2016
1937
|
var result = 0;
|
|
2017
|
-
if (typeof label ===
|
|
1938
|
+
if (typeof label === "string") {
|
|
2018
1939
|
label = label.toUpperCase();
|
|
2019
1940
|
for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
|
|
2020
1941
|
result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
|
|
@@ -2031,14 +1952,14 @@ function columnLabelToIndex(label) {
|
|
|
2031
1952
|
* @returns {String} Returns column label (eq. 'ABB', 'CNQ').
|
|
2032
1953
|
*/
|
|
2033
1954
|
function columnIndexToLabel(column) {
|
|
2034
|
-
var result =
|
|
1955
|
+
var result = "";
|
|
2035
1956
|
while (column >= 0) {
|
|
2036
1957
|
result = String.fromCharCode(column % COLUMN_LABEL_BASE_LENGTH + 97) + result;
|
|
2037
1958
|
column = Math.floor(column / COLUMN_LABEL_BASE_LENGTH) - 1;
|
|
2038
1959
|
}
|
|
2039
1960
|
return result.toUpperCase();
|
|
2040
1961
|
}
|
|
2041
|
-
var simpleSheetName$1 = "[A-Za-z0-9_\
|
|
1962
|
+
var simpleSheetName$1 = "[A-Za-z0-9_\u4E00-\u9FFF]+";
|
|
2042
1963
|
var quotedSheetName$1 = "'(?:(?!').|'')*'";
|
|
2043
1964
|
var sheetNameRegexp$1 = "(".concat(simpleSheetName$1, "|").concat(quotedSheetName$1, ")!");
|
|
2044
1965
|
var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
|
|
@@ -2050,7 +1971,7 @@ var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?
|
|
|
2050
1971
|
* @returns {Array} Returns an array of objects.
|
|
2051
1972
|
*/
|
|
2052
1973
|
function extractLabel(label) {
|
|
2053
|
-
if (typeof label !==
|
|
1974
|
+
if (typeof label !== "string" || !LABEL_EXTRACT_REGEXP.test(label)) {
|
|
2054
1975
|
return [];
|
|
2055
1976
|
}
|
|
2056
1977
|
var _label$toUpperCase$ma = label.toUpperCase().match(LABEL_EXTRACT_REGEXP),
|
|
@@ -2065,11 +1986,11 @@ function extractLabel(label) {
|
|
|
2065
1986
|
return [{
|
|
2066
1987
|
index: rowLabelToIndex(row),
|
|
2067
1988
|
label: row,
|
|
2068
|
-
isAbsolute: rowAbs ===
|
|
1989
|
+
isAbsolute: rowAbs === "$"
|
|
2069
1990
|
}, {
|
|
2070
1991
|
index: columnLabelToIndex(column),
|
|
2071
1992
|
label: column,
|
|
2072
|
-
isAbsolute: columnAbs ===
|
|
1993
|
+
isAbsolute: columnAbs === "$"
|
|
2073
1994
|
}, sheetName];
|
|
2074
1995
|
}
|
|
2075
1996
|
|
|
@@ -2081,8 +2002,8 @@ function extractLabel(label) {
|
|
|
2081
2002
|
* @returns {String} Returns cell label.
|
|
2082
2003
|
*/
|
|
2083
2004
|
function toLabel(row, column) {
|
|
2084
|
-
var rowLabel = (row.isAbsolute ?
|
|
2085
|
-
var columnLabel = (column.isAbsolute ?
|
|
2005
|
+
var rowLabel = (row.isAbsolute ? "$" : "") + rowIndexToLabel(row.index);
|
|
2006
|
+
var columnLabel = (column.isAbsolute ? "$" : "") + columnIndexToLabel(column.index);
|
|
2086
2007
|
return columnLabel + rowLabel;
|
|
2087
2008
|
}
|
|
2088
2009
|
|
|
@@ -2119,7 +2040,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2119
2040
|
_this.variables = Object.create(null);
|
|
2120
2041
|
_this.functions = Object.create(null);
|
|
2121
2042
|
_this.options = Object.create(null);
|
|
2122
|
-
_this.setVariable(
|
|
2043
|
+
_this.setVariable("TRUE", true).setVariable("FALSE", false).setVariable("NULL", null);
|
|
2123
2044
|
return _this;
|
|
2124
2045
|
}
|
|
2125
2046
|
|
|
@@ -2139,8 +2060,8 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2139
2060
|
var error$1 = null;
|
|
2140
2061
|
this.options = options;
|
|
2141
2062
|
try {
|
|
2142
|
-
if (expression ===
|
|
2143
|
-
result =
|
|
2063
|
+
if (expression === "") {
|
|
2064
|
+
result = "";
|
|
2144
2065
|
} else {
|
|
2145
2066
|
result = this.parser.parse(expression);
|
|
2146
2067
|
}
|
|
@@ -2199,7 +2120,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2199
2120
|
key: "_callVariable",
|
|
2200
2121
|
value: function _callVariable(name) {
|
|
2201
2122
|
var value = this.getVariable(name);
|
|
2202
|
-
this.emit(
|
|
2123
|
+
this.emit("callVariable", name, function (newValue) {
|
|
2203
2124
|
if (newValue !== void 0) {
|
|
2204
2125
|
value = newValue;
|
|
2205
2126
|
}
|
|
@@ -2253,7 +2174,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2253
2174
|
if (fn) {
|
|
2254
2175
|
value = fn(params);
|
|
2255
2176
|
}
|
|
2256
|
-
this.emit(
|
|
2177
|
+
this.emit("callFunction", name, params, function (newValue) {
|
|
2257
2178
|
if (newValue !== void 0) {
|
|
2258
2179
|
value = newValue;
|
|
2259
2180
|
}
|
|
@@ -2285,7 +2206,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2285
2206
|
throw Error(ERROR_NAME);
|
|
2286
2207
|
}
|
|
2287
2208
|
var value = void 0;
|
|
2288
|
-
this.emit(
|
|
2209
|
+
this.emit("callCellValue", {
|
|
2289
2210
|
label: label,
|
|
2290
2211
|
row: row,
|
|
2291
2212
|
column: column,
|
|
@@ -2340,7 +2261,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2340
2261
|
startCell.label = toLabel(startCell.row, startCell.column);
|
|
2341
2262
|
endCell.label = toLabel(endCell.row, endCell.column);
|
|
2342
2263
|
var value = [];
|
|
2343
|
-
this.emit(
|
|
2264
|
+
this.emit("callRangeValue", startCell, endCell, this.options, function () {
|
|
2344
2265
|
var _value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2345
2266
|
value = _value;
|
|
2346
2267
|
});
|