MCPcopy
hub / github.com/josdejong/mathjs / parseSymbol

Function parseSymbol

src/expression/parse.js:1382–1405  ·  view source on GitHub ↗

* parse symbols: functions, variables, constants, units * @return {Node} node * @private

(state)

Source from the content-addressed store, hash-verified

1380 * @private
1381 */
1382 function parseSymbol (state) {
1383 let node, name
1384
1385 if (state.tokenType === TOKENTYPE.SYMBOL ||
1386 (state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS)) {
1387 name = state.token
1388
1389 getToken(state)
1390
1391 if (hasOwnProperty(CONSTANTS, name)) { // true, false, null, ...
1392 node = new ConstantNode(CONSTANTS[name])
1393 } else if (NUMERIC_CONSTANTS.includes(name)) { // NaN, Infinity
1394 node = new ConstantNode(numeric(name, 'number'))
1395 } else {
1396 node = new SymbolNode(name)
1397 }
1398
1399 // parse function parameters and matrix index
1400 node = parseAccessors(state, node)
1401 return node
1402 }
1403
1404 return parseString(state)
1405 }
1406
1407 /**
1408 * parse accessors:

Callers 1

parseCustomNodesFunction · 0.85

Calls 4

hasOwnPropertyFunction · 0.90
getTokenFunction · 0.85
parseAccessorsFunction · 0.85
parseStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…