Commit 7e5f3e7d authored by GoshaZotov's avatar GoshaZotov

new cFormulaOperators[]() -> cFormulaOperators[].prototype

parent 27473595
...@@ -2664,7 +2664,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2664,7 +2664,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cRangeUnionOperator() { function cRangeUnionOperator() {
//cBaseOperator.apply(this, [':', 50, 2]);
} }
cRangeUnionOperator.prototype = Object.create(cBaseOperator.prototype); cRangeUnionOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -2717,7 +2716,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2717,7 +2716,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cRangeIntersectionOperator() { function cRangeIntersectionOperator() {
//cBaseOperator.apply(this, [' ', 50, 2]);
} }
cRangeIntersectionOperator.prototype = Object.create(cBaseOperator.prototype); cRangeIntersectionOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -2775,7 +2773,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2775,7 +2773,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cUnarMinusOperator() { function cUnarMinusOperator() {
//cBaseOperator.apply(this, ['un_minus'/**name operator*/, 49/**priority of operator*/, 1/**count arguments*/]);
} }
cUnarMinusOperator.prototype = Object.create(cBaseOperator.prototype); cUnarMinusOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -2815,7 +2812,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2815,7 +2812,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cUnarPlusOperator() { function cUnarPlusOperator() {
//cBaseOperator.apply(this, ['un_plus', 49, 1]);
} }
cUnarPlusOperator.prototype = Object.create(cBaseOperator.prototype); cUnarPlusOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -2850,7 +2846,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2850,7 +2846,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cAddOperator() { function cAddOperator() {
//cBaseOperator.apply(this, ['+', 20]);
} }
cAddOperator.prototype = Object.create(cBaseOperator.prototype); cAddOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -2887,7 +2882,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2887,7 +2882,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cMinusOperator() { function cMinusOperator() {
//cBaseOperator.apply(this, ['-', 20]);
} }
cMinusOperator.prototype = Object.create(cBaseOperator.prototype); cMinusOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -2924,7 +2918,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2924,7 +2918,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cPercentOperator() { function cPercentOperator() {
//cBaseOperator.apply(this, ['%', 45, 1]);
} }
cPercentOperator.prototype = Object.create(cBaseOperator.prototype); cPercentOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -2963,7 +2956,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2963,7 +2956,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cPowOperator() { function cPowOperator() {
//cBaseOperator.apply(this, ['^', 40]);
} }
cPowOperator.prototype = Object.create(cBaseOperator.prototype); cPowOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3007,7 +2999,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3007,7 +2999,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cMultOperator() { function cMultOperator() {
//cBaseOperator.apply(this, ['*', 30]);
} }
cMultOperator.prototype = Object.create(cBaseOperator.prototype); cMultOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3045,7 +3036,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3045,7 +3036,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cDivOperator() { function cDivOperator() {
//cBaseOperator.apply(this, ['/', 30]);
} }
cDivOperator.prototype = Object.create(cBaseOperator.prototype); cDivOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3083,7 +3073,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3083,7 +3073,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cConcatSTROperator() { function cConcatSTROperator() {
//cBaseOperator.apply(this, ['&', 15]);
} }
cConcatSTROperator.prototype = Object.create(cBaseOperator.prototype); cConcatSTROperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3116,7 +3105,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3116,7 +3105,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cEqualsOperator() { function cEqualsOperator() {
//cBaseOperator.apply(this, ['=', 10]);
} }
cEqualsOperator.prototype = Object.create(cBaseOperator.prototype); cEqualsOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3155,7 +3143,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3155,7 +3143,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cNotEqualsOperator() { function cNotEqualsOperator() {
//cBaseOperator.apply(this, ['<>', 10]);
} }
cNotEqualsOperator.prototype = Object.create(cBaseOperator.prototype); cNotEqualsOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3195,7 +3182,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3195,7 +3182,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cLessOperator() { function cLessOperator() {
//cBaseOperator.apply(this, ['<', 10]);
} }
cLessOperator.prototype = Object.create(cBaseOperator.prototype); cLessOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3235,7 +3221,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3235,7 +3221,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cLessOrEqualOperator() { function cLessOrEqualOperator() {
//cBaseOperator.apply(this, ['<=', 10]);
} }
cLessOrEqualOperator.prototype = Object.create(cBaseOperator.prototype); cLessOrEqualOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3274,7 +3259,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3274,7 +3259,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cGreaterOperator() { function cGreaterOperator() {
//cBaseOperator.apply(this, ['>', 10]);
} }
cGreaterOperator.prototype = Object.create(cBaseOperator.prototype); cGreaterOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3313,7 +3297,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3313,7 +3297,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
* @extends {cBaseOperator} * @extends {cBaseOperator}
*/ */
function cGreaterOrEqualOperator() { function cGreaterOrEqualOperator() {
//cBaseOperator.apply(this, ['>=', 10]);
} }
cGreaterOrEqualOperator.prototype = Object.create(cBaseOperator.prototype); cGreaterOrEqualOperator.prototype = Object.create(cBaseOperator.prototype);
...@@ -3360,12 +3343,11 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -3360,12 +3343,11 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cSpecialOperandEnd.prototype.type = cElementType.specialFunctionEnd; cSpecialOperandEnd.prototype.type = cElementType.specialFunctionEnd;
/* cFormulaOperators is container for holding all ECMA-376 operators, see chapter $18.17.2.2 in "ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference" */ /* cFormulaOperators is container for holding all ECMA-376 operators, see chapter $18.17.2.2 in "ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference" */
var cFormulaOperators = { var cFormulaOperators = {
'(' : parentLeft, '(': parentLeft,
')' : parentRight, ')': parentRight,
'{' : function () { '{': function () {
var r = {}; var r = {};
r.name = '{'; r.name = '{';
r.toString = function () { r.toString = function () {
...@@ -3373,7 +3355,7 @@ var cFormulaOperators = { ...@@ -3373,7 +3355,7 @@ var cFormulaOperators = {
}; };
return r; return r;
}, },
'}' : function () { '}': function () {
var r = {}; var r = {};
r.name = '}'; r.name = '}';
r.toString = function () { r.toString = function () {
...@@ -3381,28 +3363,28 @@ var cFormulaOperators = { ...@@ -3381,28 +3363,28 @@ var cFormulaOperators = {
}; };
return r; return r;
}, /* 50 is highest priority */ }, /* 50 is highest priority */
':' : cRangeUnionOperator, ':': cRangeUnionOperator,
' ' : cRangeIntersectionOperator, ' ': cRangeIntersectionOperator,
'un_minus': cUnarMinusOperator, 'un_minus': cUnarMinusOperator,
'un_plus' : cUnarPlusOperator, 'un_plus': cUnarPlusOperator,
'%' : cPercentOperator, '%': cPercentOperator,
'^' : cPowOperator, '^': cPowOperator,
'*' : cMultOperator, '*': cMultOperator,
'/' : cDivOperator, '/': cDivOperator,
'+' : cAddOperator, '+': cAddOperator,
'-' : cMinusOperator, '-': cMinusOperator,
'&' : cConcatSTROperator /*concat str*/, '&': cConcatSTROperator /*concat str*/,
'=' : cEqualsOperator/*equals*/, '=': cEqualsOperator/*equals*/,
'<>' : cNotEqualsOperator, '<>': cNotEqualsOperator,
'<' : cLessOperator, '<': cLessOperator,
'<=' : cLessOrEqualOperator, '<=': cLessOrEqualOperator,
'>' : cGreaterOperator, '>': cGreaterOperator,
'>=' : cGreaterOrEqualOperator '>=': cGreaterOrEqualOperator
/* 10 is lowest priopity */ /* 10 is lowest priopity */
}; };
/* cFormulaFunctionGroup is container for holding all ECMA-376 function, see chapter $18.17.7 in "ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference" */ /* cFormulaFunctionGroup is container for holding all ECMA-376 function, see chapter $18.17.7 in "ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference" */
/* /*
Каждая формула представляет собой копию функции cBaseFunction. Каждая формула представляет собой копию функции cBaseFunction.
Для реализации очередной функции необходимо указать количество (минимальное и максимальное) принимаемых аргументов. Берем в спецификации. Для реализации очередной функции необходимо указать количество (минимальное и максимальное) принимаемых аргументов. Берем в спецификации.
Также необходино написать реализацию методов Calculate и getInfo(возвращает название функции и вид/количетво аргументов). Также необходино написать реализацию методов Calculate и getInfo(возвращает название функции и вид/количетво аргументов).
...@@ -4796,10 +4778,10 @@ parserFormula.prototype.setFormula = function(formula) { ...@@ -4796,10 +4778,10 @@ parserFormula.prototype.setFormula = function(formula) {
if (t.operand_expected) { if (t.operand_expected) {
if ('-' === t.operand_str) { if ('-' === t.operand_str) {
t.operand_expected = true; t.operand_expected = true;
found_operator = new cFormulaOperators['un_minus'](); found_operator = cFormulaOperators['un_minus'].prototype;
} else if ('+' === t.operand_str) { } else if ('+' === t.operand_str) {
t.operand_expected = true; t.operand_expected = true;
found_operator = new cFormulaOperators['un_plus'](); found_operator = cFormulaOperators['un_plus'].prototype;
} else if (' ' === t.operand_str) { } else if (' ' === t.operand_str) {
return true; return true;
} else { } else {
...@@ -4811,21 +4793,21 @@ parserFormula.prototype.setFormula = function(formula) { ...@@ -4811,21 +4793,21 @@ parserFormula.prototype.setFormula = function(formula) {
} else if (!t.operand_expected) { } else if (!t.operand_expected) {
if ('-' === t.operand_str) { if ('-' === t.operand_str) {
t.operand_expected = true; t.operand_expected = true;
found_operator = new cFormulaOperators['-'](); found_operator = cFormulaOperators['-'].prototype;
} else if ('+' === t.operand_str) { } else if ('+' === t.operand_str) {
t.operand_expected = true; t.operand_expected = true;
found_operator = new cFormulaOperators['+'](); found_operator = cFormulaOperators['+'].prototype;
} else if (':' === t.operand_str) { } else if (':' === t.operand_str) {
t.operand_expected = true; t.operand_expected = true;
found_operator = new cFormulaOperators[':'](); found_operator = cFormulaOperators[':'].prototype;
} else if ('%' === t.operand_str) { } else if ('%' === t.operand_str) {
t.operand_expected = false; t.operand_expected = false;
found_operator = new cFormulaOperators['%'](); found_operator = cFormulaOperators['%'].prototype;
} else if (' ' === t.operand_str && t.pCurrPos === t.Formula.length) { } else if (' ' === t.operand_str && t.pCurrPos === t.Formula.length) {
return true; return true;
} else { } else {
if (t.operand_str in cFormulaOperators) { if (t.operand_str in cFormulaOperators) {
found_operator = new cFormulaOperators[t.operand_str](); found_operator = cFormulaOperators[t.operand_str].prototype;
t.operand_expected = true; t.operand_expected = true;
} else { } else {
t.error.push(c_oAscError.ID.FrmlWrongOperator); t.error.push(c_oAscError.ID.FrmlWrongOperator);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment