MCPcopy Index your code
hub / github.com/josdejong/mathjs / parseImplicitMultiplication

Function parseImplicitMultiplication

src/expression/parse.js:1101–1128  ·  view source on GitHub ↗

* implicit multiplication * @return {Node} node * @private

(state)

Source from the content-addressed store, hash-verified

1099 * @private
1100 */
1101 function parseImplicitMultiplication (state) {
1102 let node, last
1103
1104 node = parseRule2(state)
1105 last = node
1106
1107 while (true) {
1108 if ((state.tokenType === TOKENTYPE.SYMBOL) ||
1109 (state.token === 'in' && isConstantNode(node)) ||
1110 (state.token === 'in' && isOperatorNode(node) && node.fn === 'unaryMinus' && isConstantNode(node.args[0])) ||
1111 (state.tokenType === TOKENTYPE.NUMBER &&
1112 !isConstantNode(last) &&
1113 (!isOperatorNode(last) || last.op === '!')) ||
1114 (state.token === '(')) {
1115 // parse implicit multiplication
1116 //
1117 // symbol: implicit multiplication like '2a', '(2+3)a', 'a b'
1118 // number: implicit multiplication like '(2+3)2'
1119 // parenthesis: implicit multiplication like '2(3+4)', '(3+4)(1+2)'
1120 last = parseRule2(state)
1121 node = new OperatorNode('*', 'multiply', [node, last], true /* implicit */)
1122 } else {
1123 break
1124 }
1125 }
1126
1127 return node
1128 }
1129
1130 /**
1131 * Infamous "rule 2" as described in https://github.com/josdejong/mathjs/issues/792#issuecomment-361065370

Callers 1

Calls 3

isConstantNodeFunction · 0.90
isOperatorNodeFunction · 0.90
parseRule2Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…