@leankylin-sheet/formula-parser 3.1.31 → 3.1.33
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 +85 -162
- package/dist/index.js +85 -162
- 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,18 @@ 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
|
-
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]+)/,
|
|
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]+)/,
|
|
1839
|
+
// /^(?:[A-Za-z_]+)/,
|
|
1840
|
+
/^(?:\{\{[^{}}]+\}\})/, /^(?:[0-9]+)/, /^(?:\[(.*)?\])/, /^(?:&)/, /^(?: )/, /^(?:[.])/, /^(?::)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\()/, /^(?:\))/, /^(?:>)/, /^(?:<)/, /^(?:NOT\b)/, /^(?:")/, /^(?:')/, /^(?:!)/, /^(?:=)/, /^(?:%)/, /^(?:[#])/, /^(?:$)/],
|
|
1918
1841
|
conditions: {
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1842
|
+
INITIAL: {
|
|
1843
|
+
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],
|
|
1844
|
+
inclusive: true
|
|
1922
1845
|
}
|
|
1923
1846
|
}
|
|
1924
1847
|
};
|
|
@@ -1968,13 +1891,13 @@ function rowLabelToIndex(label) {
|
|
|
1968
1891
|
* @returns {String} Returns row label (eq. '1', '7').
|
|
1969
1892
|
*/
|
|
1970
1893
|
function rowIndexToLabel(row) {
|
|
1971
|
-
var result =
|
|
1894
|
+
var result = "";
|
|
1972
1895
|
if (row >= 0) {
|
|
1973
1896
|
result = "".concat(row + 1);
|
|
1974
1897
|
}
|
|
1975
1898
|
return result;
|
|
1976
1899
|
}
|
|
1977
|
-
var COLUMN_LABEL_BASE =
|
|
1900
|
+
var COLUMN_LABEL_BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
1978
1901
|
var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
|
|
1979
1902
|
|
|
1980
1903
|
/**
|
|
@@ -1985,7 +1908,7 @@ var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
|
|
|
1985
1908
|
*/
|
|
1986
1909
|
function columnLabelToIndex(label) {
|
|
1987
1910
|
var result = 0;
|
|
1988
|
-
if (typeof label ===
|
|
1911
|
+
if (typeof label === "string") {
|
|
1989
1912
|
label = label.toUpperCase();
|
|
1990
1913
|
for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
|
|
1991
1914
|
result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
|
|
@@ -2002,14 +1925,14 @@ function columnLabelToIndex(label) {
|
|
|
2002
1925
|
* @returns {String} Returns column label (eq. 'ABB', 'CNQ').
|
|
2003
1926
|
*/
|
|
2004
1927
|
function columnIndexToLabel(column) {
|
|
2005
|
-
var result =
|
|
1928
|
+
var result = "";
|
|
2006
1929
|
while (column >= 0) {
|
|
2007
1930
|
result = String.fromCharCode(column % COLUMN_LABEL_BASE_LENGTH + 97) + result;
|
|
2008
1931
|
column = Math.floor(column / COLUMN_LABEL_BASE_LENGTH) - 1;
|
|
2009
1932
|
}
|
|
2010
1933
|
return result.toUpperCase();
|
|
2011
1934
|
}
|
|
2012
|
-
var simpleSheetName$1 = "[A-Za-z0-9_\
|
|
1935
|
+
var simpleSheetName$1 = "[A-Za-z0-9_\u4E00-\u9FFF]+";
|
|
2013
1936
|
var quotedSheetName$1 = "'(?:(?!').|'')*'";
|
|
2014
1937
|
var sheetNameRegexp$1 = "(".concat(simpleSheetName$1, "|").concat(quotedSheetName$1, ")!");
|
|
2015
1938
|
var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
|
|
@@ -2021,7 +1944,7 @@ var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?
|
|
|
2021
1944
|
* @returns {Array} Returns an array of objects.
|
|
2022
1945
|
*/
|
|
2023
1946
|
function extractLabel(label) {
|
|
2024
|
-
if (typeof label !==
|
|
1947
|
+
if (typeof label !== "string" || !LABEL_EXTRACT_REGEXP.test(label)) {
|
|
2025
1948
|
return [];
|
|
2026
1949
|
}
|
|
2027
1950
|
var _label$toUpperCase$ma = label.toUpperCase().match(LABEL_EXTRACT_REGEXP),
|
|
@@ -2036,11 +1959,11 @@ function extractLabel(label) {
|
|
|
2036
1959
|
return [{
|
|
2037
1960
|
index: rowLabelToIndex(row),
|
|
2038
1961
|
label: row,
|
|
2039
|
-
isAbsolute: rowAbs ===
|
|
1962
|
+
isAbsolute: rowAbs === "$"
|
|
2040
1963
|
}, {
|
|
2041
1964
|
index: columnLabelToIndex(column),
|
|
2042
1965
|
label: column,
|
|
2043
|
-
isAbsolute: columnAbs ===
|
|
1966
|
+
isAbsolute: columnAbs === "$"
|
|
2044
1967
|
}, sheetName];
|
|
2045
1968
|
}
|
|
2046
1969
|
|
|
@@ -2052,8 +1975,8 @@ function extractLabel(label) {
|
|
|
2052
1975
|
* @returns {String} Returns cell label.
|
|
2053
1976
|
*/
|
|
2054
1977
|
function toLabel(row, column) {
|
|
2055
|
-
var rowLabel = (row.isAbsolute ?
|
|
2056
|
-
var columnLabel = (column.isAbsolute ?
|
|
1978
|
+
var rowLabel = (row.isAbsolute ? "$" : "") + rowIndexToLabel(row.index);
|
|
1979
|
+
var columnLabel = (column.isAbsolute ? "$" : "") + columnIndexToLabel(column.index);
|
|
2057
1980
|
return columnLabel + rowLabel;
|
|
2058
1981
|
}
|
|
2059
1982
|
|
|
@@ -2090,7 +2013,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2090
2013
|
_this.variables = Object.create(null);
|
|
2091
2014
|
_this.functions = Object.create(null);
|
|
2092
2015
|
_this.options = Object.create(null);
|
|
2093
|
-
_this.setVariable(
|
|
2016
|
+
_this.setVariable("TRUE", true).setVariable("FALSE", false).setVariable("NULL", null);
|
|
2094
2017
|
return _this;
|
|
2095
2018
|
}
|
|
2096
2019
|
|
|
@@ -2110,8 +2033,8 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2110
2033
|
var error$1 = null;
|
|
2111
2034
|
this.options = options;
|
|
2112
2035
|
try {
|
|
2113
|
-
if (expression ===
|
|
2114
|
-
result =
|
|
2036
|
+
if (expression === "") {
|
|
2037
|
+
result = "";
|
|
2115
2038
|
} else {
|
|
2116
2039
|
result = this.parser.parse(expression);
|
|
2117
2040
|
}
|
|
@@ -2170,7 +2093,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2170
2093
|
key: "_callVariable",
|
|
2171
2094
|
value: function _callVariable(name) {
|
|
2172
2095
|
var value = this.getVariable(name);
|
|
2173
|
-
this.emit(
|
|
2096
|
+
this.emit("callVariable", name, function (newValue) {
|
|
2174
2097
|
if (newValue !== void 0) {
|
|
2175
2098
|
value = newValue;
|
|
2176
2099
|
}
|
|
@@ -2224,7 +2147,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2224
2147
|
if (fn) {
|
|
2225
2148
|
value = fn(params);
|
|
2226
2149
|
}
|
|
2227
|
-
this.emit(
|
|
2150
|
+
this.emit("callFunction", name, params, function (newValue) {
|
|
2228
2151
|
if (newValue !== void 0) {
|
|
2229
2152
|
value = newValue;
|
|
2230
2153
|
}
|
|
@@ -2256,7 +2179,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2256
2179
|
throw Error(ERROR_NAME);
|
|
2257
2180
|
}
|
|
2258
2181
|
var value = void 0;
|
|
2259
|
-
this.emit(
|
|
2182
|
+
this.emit("callCellValue", {
|
|
2260
2183
|
label: label,
|
|
2261
2184
|
row: row,
|
|
2262
2185
|
column: column,
|
|
@@ -2311,7 +2234,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2311
2234
|
startCell.label = toLabel(startCell.row, startCell.column);
|
|
2312
2235
|
endCell.label = toLabel(endCell.row, endCell.column);
|
|
2313
2236
|
var value = [];
|
|
2314
|
-
this.emit(
|
|
2237
|
+
this.emit("callRangeValue", startCell, endCell, this.options, function () {
|
|
2315
2238
|
var _value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2316
2239
|
value = _value;
|
|
2317
2240
|
});
|
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,18 @@ 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
|
-
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]+)/,
|
|
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]+)/,
|
|
1868
|
+
// /^(?:[A-Za-z_]+)/,
|
|
1869
|
+
/^(?:\{\{[^{}}]+\}\})/, /^(?:[0-9]+)/, /^(?:\[(.*)?\])/, /^(?:&)/, /^(?: )/, /^(?:[.])/, /^(?::)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\()/, /^(?:\))/, /^(?:>)/, /^(?:<)/, /^(?:NOT\b)/, /^(?:")/, /^(?:')/, /^(?:!)/, /^(?:=)/, /^(?:%)/, /^(?:[#])/, /^(?:$)/],
|
|
1947
1870
|
conditions: {
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1871
|
+
INITIAL: {
|
|
1872
|
+
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],
|
|
1873
|
+
inclusive: true
|
|
1951
1874
|
}
|
|
1952
1875
|
}
|
|
1953
1876
|
};
|
|
@@ -1997,13 +1920,13 @@ function rowLabelToIndex(label) {
|
|
|
1997
1920
|
* @returns {String} Returns row label (eq. '1', '7').
|
|
1998
1921
|
*/
|
|
1999
1922
|
function rowIndexToLabel(row) {
|
|
2000
|
-
var result =
|
|
1923
|
+
var result = "";
|
|
2001
1924
|
if (row >= 0) {
|
|
2002
1925
|
result = "".concat(row + 1);
|
|
2003
1926
|
}
|
|
2004
1927
|
return result;
|
|
2005
1928
|
}
|
|
2006
|
-
var COLUMN_LABEL_BASE =
|
|
1929
|
+
var COLUMN_LABEL_BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
2007
1930
|
var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
|
|
2008
1931
|
|
|
2009
1932
|
/**
|
|
@@ -2014,7 +1937,7 @@ var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
|
|
|
2014
1937
|
*/
|
|
2015
1938
|
function columnLabelToIndex(label) {
|
|
2016
1939
|
var result = 0;
|
|
2017
|
-
if (typeof label ===
|
|
1940
|
+
if (typeof label === "string") {
|
|
2018
1941
|
label = label.toUpperCase();
|
|
2019
1942
|
for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
|
|
2020
1943
|
result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
|
|
@@ -2031,14 +1954,14 @@ function columnLabelToIndex(label) {
|
|
|
2031
1954
|
* @returns {String} Returns column label (eq. 'ABB', 'CNQ').
|
|
2032
1955
|
*/
|
|
2033
1956
|
function columnIndexToLabel(column) {
|
|
2034
|
-
var result =
|
|
1957
|
+
var result = "";
|
|
2035
1958
|
while (column >= 0) {
|
|
2036
1959
|
result = String.fromCharCode(column % COLUMN_LABEL_BASE_LENGTH + 97) + result;
|
|
2037
1960
|
column = Math.floor(column / COLUMN_LABEL_BASE_LENGTH) - 1;
|
|
2038
1961
|
}
|
|
2039
1962
|
return result.toUpperCase();
|
|
2040
1963
|
}
|
|
2041
|
-
var simpleSheetName$1 = "[A-Za-z0-9_\
|
|
1964
|
+
var simpleSheetName$1 = "[A-Za-z0-9_\u4E00-\u9FFF]+";
|
|
2042
1965
|
var quotedSheetName$1 = "'(?:(?!').|'')*'";
|
|
2043
1966
|
var sheetNameRegexp$1 = "(".concat(simpleSheetName$1, "|").concat(quotedSheetName$1, ")!");
|
|
2044
1967
|
var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
|
|
@@ -2050,7 +1973,7 @@ var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?
|
|
|
2050
1973
|
* @returns {Array} Returns an array of objects.
|
|
2051
1974
|
*/
|
|
2052
1975
|
function extractLabel(label) {
|
|
2053
|
-
if (typeof label !==
|
|
1976
|
+
if (typeof label !== "string" || !LABEL_EXTRACT_REGEXP.test(label)) {
|
|
2054
1977
|
return [];
|
|
2055
1978
|
}
|
|
2056
1979
|
var _label$toUpperCase$ma = label.toUpperCase().match(LABEL_EXTRACT_REGEXP),
|
|
@@ -2065,11 +1988,11 @@ function extractLabel(label) {
|
|
|
2065
1988
|
return [{
|
|
2066
1989
|
index: rowLabelToIndex(row),
|
|
2067
1990
|
label: row,
|
|
2068
|
-
isAbsolute: rowAbs ===
|
|
1991
|
+
isAbsolute: rowAbs === "$"
|
|
2069
1992
|
}, {
|
|
2070
1993
|
index: columnLabelToIndex(column),
|
|
2071
1994
|
label: column,
|
|
2072
|
-
isAbsolute: columnAbs ===
|
|
1995
|
+
isAbsolute: columnAbs === "$"
|
|
2073
1996
|
}, sheetName];
|
|
2074
1997
|
}
|
|
2075
1998
|
|
|
@@ -2081,8 +2004,8 @@ function extractLabel(label) {
|
|
|
2081
2004
|
* @returns {String} Returns cell label.
|
|
2082
2005
|
*/
|
|
2083
2006
|
function toLabel(row, column) {
|
|
2084
|
-
var rowLabel = (row.isAbsolute ?
|
|
2085
|
-
var columnLabel = (column.isAbsolute ?
|
|
2007
|
+
var rowLabel = (row.isAbsolute ? "$" : "") + rowIndexToLabel(row.index);
|
|
2008
|
+
var columnLabel = (column.isAbsolute ? "$" : "") + columnIndexToLabel(column.index);
|
|
2086
2009
|
return columnLabel + rowLabel;
|
|
2087
2010
|
}
|
|
2088
2011
|
|
|
@@ -2119,7 +2042,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2119
2042
|
_this.variables = Object.create(null);
|
|
2120
2043
|
_this.functions = Object.create(null);
|
|
2121
2044
|
_this.options = Object.create(null);
|
|
2122
|
-
_this.setVariable(
|
|
2045
|
+
_this.setVariable("TRUE", true).setVariable("FALSE", false).setVariable("NULL", null);
|
|
2123
2046
|
return _this;
|
|
2124
2047
|
}
|
|
2125
2048
|
|
|
@@ -2139,8 +2062,8 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2139
2062
|
var error$1 = null;
|
|
2140
2063
|
this.options = options;
|
|
2141
2064
|
try {
|
|
2142
|
-
if (expression ===
|
|
2143
|
-
result =
|
|
2065
|
+
if (expression === "") {
|
|
2066
|
+
result = "";
|
|
2144
2067
|
} else {
|
|
2145
2068
|
result = this.parser.parse(expression);
|
|
2146
2069
|
}
|
|
@@ -2199,7 +2122,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2199
2122
|
key: "_callVariable",
|
|
2200
2123
|
value: function _callVariable(name) {
|
|
2201
2124
|
var value = this.getVariable(name);
|
|
2202
|
-
this.emit(
|
|
2125
|
+
this.emit("callVariable", name, function (newValue) {
|
|
2203
2126
|
if (newValue !== void 0) {
|
|
2204
2127
|
value = newValue;
|
|
2205
2128
|
}
|
|
@@ -2253,7 +2176,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2253
2176
|
if (fn) {
|
|
2254
2177
|
value = fn(params);
|
|
2255
2178
|
}
|
|
2256
|
-
this.emit(
|
|
2179
|
+
this.emit("callFunction", name, params, function (newValue) {
|
|
2257
2180
|
if (newValue !== void 0) {
|
|
2258
2181
|
value = newValue;
|
|
2259
2182
|
}
|
|
@@ -2285,7 +2208,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2285
2208
|
throw Error(ERROR_NAME);
|
|
2286
2209
|
}
|
|
2287
2210
|
var value = void 0;
|
|
2288
|
-
this.emit(
|
|
2211
|
+
this.emit("callCellValue", {
|
|
2289
2212
|
label: label,
|
|
2290
2213
|
row: row,
|
|
2291
2214
|
column: column,
|
|
@@ -2340,7 +2263,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
|
|
|
2340
2263
|
startCell.label = toLabel(startCell.row, startCell.column);
|
|
2341
2264
|
endCell.label = toLabel(endCell.row, endCell.column);
|
|
2342
2265
|
var value = [];
|
|
2343
|
-
this.emit(
|
|
2266
|
+
this.emit("callRangeValue", startCell, endCell, this.options, function () {
|
|
2344
2267
|
var _value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2345
2268
|
value = _value;
|
|
2346
2269
|
});
|